public UserTag getMatjiData(JsonObject object) throws MatjiException {
    if (object == null) return null;

    UserTag userTag = new UserTag();
    userTag.setId(getInt(object, "id"));
    userTag.setTagId(getInt(object, "tag_id"));
    userTag.setUserId(getInt(object, "user_id"));
    userTag.setCount(getInt(object, "count"));
    userTag.setCreatedAt(getString(object, "created_at"));
    userTag.setUpdatedAt(getString(object, "updated_at"));

    /* Set Tag */
    TagParser tagParser = new TagParser();
    userTag.setTag(tagParser.getMatjiData(getObject(object, "tag")));

    /* Set User */
    UserParser userParser = new UserParser();
    userTag.setUser(userParser.getMatjiData(getObject(object, "user")));

    return userTag;
  }
 private Map<String, Object> getMetadataMetadata(final Upload upload) {
   final Map<String, Object> params = Maps.newHashMapWithExpectedSize(4);
   final Metadata metadata = upload.getMetadata();
   params.put("title", metadata.getTitle());
   params.put("description", Strings.nullToEmpty(metadata.getDescription()));
   params.put(
       "keywords",
       Joiner.on(TagParser.TAG_DELIMITER)
           .skipNulls()
           .join(TagParser.parse(metadata.getKeywords(), true)));
   params.put(
       "reuse",
       License.YOUTUBE == metadata.getLicense() ? "all_rights_reserved" : "creative_commons");
   return params;
 }
  @Override
  public String atomBuilder(final Upload upload) {
    // create atom xml metadata - create object first, then convert with
    // xstream

    final Metadata metadata = upload.getMetadata();
    final VideoEntry videoEntry = new VideoEntry();
    videoEntry.mediaGroup.category = new ArrayList<>(1);
    videoEntry.mediaGroup.category.add(metadata.getCategory().toCategory());
    videoEntry.mediaGroup.license = metadata.getLicense().getMetaIdentifier();
    videoEntry.mediaGroup.title = metadata.getTitle();
    videoEntry.mediaGroup.description = metadata.getDescription();
    videoEntry.mediaGroup.keywords =
        Joiner.on(TagParser.TAG_DELIMITER)
            .skipNulls()
            .join(TagParser.parse(metadata.getKeywords()));
    final Permissions permissions = upload.getPermissions();

    if (Visibility.PRIVATE == permissions.getVisibility()
        || Visibility.SCHEDULED == permissions.getVisibility()) {
      videoEntry.mediaGroup.ytPrivate = new Object();
    }

    videoEntry.accessControl.add(
        new YoutubeAccessControl(
            "embed", PermissionStringConverter.convertBoolean(permissions.isEmbed())));
    videoEntry.accessControl.add(
        new YoutubeAccessControl(
            "rate", PermissionStringConverter.convertBoolean(permissions.isRate())));
    videoEntry.accessControl.add(
        new YoutubeAccessControl(
            "commentVote", PermissionStringConverter.convertBoolean(permissions.isCommentvote())));
    videoEntry.accessControl.add(
        new YoutubeAccessControl(
            "comment",
            PermissionStringConverter.convertInteger(permissions.getComment().ordinal())));
    videoEntry.accessControl.add(
        new YoutubeAccessControl(
            "list",
            PermissionStringConverter.convertBoolean(
                Visibility.PUBLIC == permissions.getVisibility())));

    // convert metadata with xstream
    final XStream xStream =
        new XStream(
            new DomDriver(Charsets.UTF_8.name()) {
              @Override
              public HierarchicalStreamWriter createWriter(final Writer out) {
                return new PrettyPrintWriter(out) {
                  boolean isCDATA;

                  @Override
                  public void startNode(
                      final String name, @SuppressWarnings("rawtypes") final Class clazz) {
                    super.startNode(name, clazz);
                    isCDATA =
                        "media:description".equals(name)
                            || "media:keywords".equals(name)
                            || "media:title".equals(name);
                  }

                  @Override
                  protected void writeText(final QuickWriter writer, String text) {
                    final String tmpText = Strings.nullToEmpty(text);
                    text = "null".equals(tmpText) ? "" : tmpText;
                    if (isCDATA) {
                      writer.write("<![CDATA[");
                      writer.write(text);
                      writer.write("]]>");
                    } else {
                      super.writeText(writer, text);
                    }
                  }
                };
              }
            });
    xStream.autodetectAnnotations(true);

    return String.format("<?xml version=\"1.0\" encoding=\"UTF-8\"?>%s", xStream.toXML(videoEntry));
  }