public void onSuccess(final String packageRef, final Asset[] assets, final String name, final String description) {
//for each selcted resource we are going to add a xml entry
final StringBuilder result = new StringBuilder("");
for (int i = 0; i < assets.length; i++) {
final Asset asset = assets[i];
String partialResult = resourceXMLElementTemplate;
String nameString = "";
if (name.length() != 0) {
if (assets.length == 1) {
nameString = "name=\"" + name.trim() + "\"";
} else {
//add index to the name to avoid duplication
nameString = "name=\"" + name.trim() + i + "\"";
}
}
partialResult = partialResult.replace("{name}",
nameString);
String descriptionString = "";
if (description.length() != 0) {
descriptionString = "description=\"" + description.trim() + "\"";
}
partialResult = partialResult.replace("{description}",
descriptionString);
final String type = convertAssetFormatToResourceType(asset.getFormat());
if (type == null) {
throw new IllegalArgumentException(Constants.INSTANCE.UnknownResourceFormat(asset.getFormat()));
}
partialResult = partialResult.replace("{type}", type);
partialResult = partialResult.replace("{source}", buildDownloadLink(asset, packageRef));