1 /**
  2  * Workflow to return an asset/assets xmp using a REST call
  3  */
  4 var REST = library.REST.REST();
  5 var myData = {};
  6 
  7 /**
  8  * Adds an object to myData containing the xmp of the given asset
  9  *
 10  * @param theAssetID - an asset ID
 11  */
 12 function getXmp(theAssetID) {
 13   var aFile = fileManager.getFileObjectById(theAssetID);
 14   if (aFile == null) {
 15     REST.submitError(theAssetID, "The File does not exist");
 16     return;
 17   }
 18   myData[theAssetID] = aFile.xmp.asString();
 19 }
 20 
 21 /**
 22  * Returns a full XMP packet for each of the given Asset IDs.
 23  * @description Fetches the full XMP packets for all assets specified by assetID in 'src'. These XMP values are parsed into a text object keyed by AssetID from the JSON file in which they are contained, and by default are displayed to the user.
 24  * @example 'MBurl'/wf/restapi/1/getXmp?src=["AssetID"]
 25  * @example <a target="_blank" href=http://127.0.0.1:55555/wf/restapi/1/getXmp?src=["12345"]>http://127.0.0.1:55555/wf/restapi/1/getXmp?src=["12345"]</a>
 26  * @class Returns a full XMP packet for each of the given Asset IDs.
 27  * @name GetXMP
 28  * @param src AssetID/list of assetIDs to get the XMP from.
 29  * @returns ( {'AssetID': "XMP Packet Values",...} )
 30  */
 31 function main() {
 32   var aParameters = REST.getParametersToIterate("src");
 33   if (myData.error != null) {
 34     return REST.formatResponse();
 35   }
 36   REST.iterateThroughParameters(aParameters, getXmp);
 37   return REST.formatResponse();
 38 }
 39 main();
 40