+
+int media_tag_create(media_tag_h *tag)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+
+ media_content_retvm_if(tag == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid tag");
+
+ media_tag_s *_tag = (media_tag_s*)calloc(1, sizeof(media_tag_s));
+ media_content_retvm_if(_tag == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+
+ _tag->tag_id = -1;
+ _tag->name = NULL;
+ _tag->item_list = NULL;
+
+ *tag = (media_tag_h)_tag;
+
+ return ret;
+}
+
+int media_tag_insert_to_db_v2(media_tag_h tag)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ media_tag_s *_tag = (media_tag_s*)tag;
+ media_tag_h tag_1;
+ int tag_id = -1;
+
+ media_content_retvm_if(_tag == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid tag");
+ media_content_retvm_if(!STRING_VALID(_tag->name), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid tag name");
+ media_content_retvm_if(_tag->tag_id != -1, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid tag insert");
+
+ ret = media_tag_insert_to_db(_tag->name, &tag_1);
+ if (ret != MEDIA_CONTENT_ERROR_NONE) {
+ media_content_error("fail media_tag_insert_to_db");
+ goto ERROR;
+ }
+
+ ret = media_tag_get_tag_id(tag_1, &tag_id);
+ if (ret != MEDIA_CONTENT_ERROR_NONE) {
+ media_content_error("fail media_tag_get_tag_id");
+ goto ERROR;
+ }
+
+ _tag->tag_id = tag_id;
+
+ ret = media_tag_update_to_db(tag);
+
+ERROR:
+ __media_tag_item_release(_tag);
+ media_tag_destroy(tag_1);
+
+ return ret;
+}
+
+int media_tag_update_to_db_v2(int tag_id, media_tag_h tag)
+{
+ media_tag_s *_tag = (media_tag_s*)tag;
+
+ media_content_retvm_if(_tag == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid tag");
+ media_content_retvm_if(tag_id == -1, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid tag update");
+
+ _tag->tag_id = tag_id;
+
+ return media_tag_update_to_db(tag);
+}