private Map<String, Object> getMetadataSocial(final Upload upload) {
    final Map<String, Object> params = new HashMap<>(3);
    final Permissions permissions = upload.getPermissions();
    if (Visibility.PUBLIC == permissions.getVisibility()
        || Visibility.SCHEDULED == permissions.getVisibility()) {

      final Social social = upload.getSocial();
      if (null != social.getMessage() && !social.getMessage().isEmpty()) {
        params.put("creator_share_custom_message", social.getMessage());
        params.put("creator_share_facebook", boolConverter(social.isFacebook()));
        params.put("creator_share_twitter", boolConverter(social.isTwitter()));
        params.put("creator_share_gplus", boolConverter(social.isGplus()));
      }
    }
    return params;
  }
  private Map<String, Object> getMetadataPermissions(final Upload upload) {
    final Map<String, Object> params = Maps.newHashMapWithExpectedSize(7);
    final Permissions permissions = upload.getPermissions();

    params.put("allow_comments", boolConverter(!(Comment.DENIED == permissions.getComment())));
    params.put(
        "allow_comments_detail", Comment.ALLOWED == permissions.getComment() ? "all" : "approval");
    params.put("allow_comment_ratings", boolConverter(permissions.isCommentvote()));
    params.put("allow_ratings", boolConverter(permissions.isRate()));
    params.put("allow_embedding", boolConverter(permissions.isEmbed()));
    params.put("self_racy", boolConverter(permissions.isAgeRestricted()));
    params.put("allow_public_stats", boolConverter(permissions.isPublicStatsViewable()));
    params.put("threed_type", permissions.getThreedD().name().toLowerCase());
    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));
  }