1 var REST = library.REST.REST();
  2 
  3 /**
  4  * Gets the selection for the current user.
  5  */
  6 function getSelections() {
  7   var aSelections = savedSelectionManager.getSavedSelectionsForUser(
  8     context.getUser().username
  9   );
 10   for (var i = 0; i < aSelections.length; i++) {
 11     var aSelection = aSelections[i];
 12     var anIds = aSelection.getAssetIds();
 13     if (aSelection.getName() === "nologin") {
 14       continue;
 15     }
 16     var aJSON = {
 17       id: aSelection.getId(),
 18       resolver: "savedSelection://" + aSelection.getId(),
 19       name: aSelection.getName(),
 20       description: aSelection.getDescription(),
 21       public: aSelection.isPublicSelection(),
 22       shared: aSelection.isShared(),
 23     };
 24     if (REST.filterMatch(aJSON)) {
 25       aJSON.assets = context.getParameter("fullAssets", false) ? REST.getAssetInfo(anIds) : anIds;
 26       REST.push(null, aJSON, true);
 27     }
 28   }
 29 }
 30 
 31 /**
 32  * @name SavedSelections
 33  * @class Shows the saved selections available for the current user.
 34  * @description Displays the saved selections available to the current user and the asset data for each asset in the selection.
 35  * @param [verbose=false] Setting this to true will collect a variety of default values for each asset.
 36  * @param [FILTERS] Filtering can be applied to the "id", "name", "description", "public", "count", and "resolver"
 37  * @param [fields] An array of field id's to collect the values for each asset
 38  * @param [fullAssets] If not included, will only return assetIds and not asset objects
 39  * @returns [{SelectionData}, ... ]
 40  * @example /wf/restapi/v2/savedSelections
 41  *
 42  * Parameters: none
 43  *
 44  Response:
 45  [
 46     all Selections...
 47  ]
 48  * @example /wf/restapi/v2/savedSelections
 49  *
 50  * Parameters:
 51  * name=test
 52  * verbose=true
 53  * fullAssets=true
 54  *
 55  Response:
 56  [
 57 	 {
 58 	   "id": 2,
 59 	   "resolver": "savedSelection://2",
 60 	   "name": "TestAssets",
 61 	   "description": "",
 62 	   "public": false,
 63 	   "shared": false,
 64 	   "assets": [
 65 		 {
 66 		   "id": 201629349,
 67 		   "name": "REST.xmp",
 68 		   "path": "REST.xmp",
 69 		   "height": 1,
 70 		   "width": 1,
 71 		   "bytes": 2048,
 72 		   "lastModified": 1508164732000,
 73 		   "mimeType": "application/octet-stream",
 74 		   "previews": {
 75 			 "thumbnail": "../servlet/jb.view?table=thumbnails&col=thumbnails&id=pe_323031363239333439",
 76 			 "viewex": "../servlet/jb.view?table=viewex&col=viewex&id=pe_323031363239333439",
 77 			 "downloadUrl": "../servlet/dload?id=pe_323031363239333439"
 78 		   }
 79 		 },
 80 		 {
 81 		   "id": 201629375,
 82 		   "name": "newNameTest.txt",
 83 		   "path": "rename/newNameTest.txt",
 84 		   "height": 0,
 85 		   "width": 0,
 86 		   "bytes": 0,
 87 		   "lastModified": 1508167049000,
 88 		   "mimeType": "text/plain",
 89 		   "previews": {
 90 			 "thumbnail": "../servlet/jb.view?table=thumbnails&col=thumbnails&id=pe_323031363239333735",
 91 			 "viewex": "../servlet/jb.view?table=viewex&col=viewex&id=pe_323031363239333735",
 92 			 "downloadUrl": "../servlet/dload?id=pe_323031363239333735"
 93 		   }
 94 		 }
 95 	   ]
 96 	 }
 97  ]
 98  */
 99 function main() {
100   REST.setCallback(getSelections);
101   return REST.execute();
102 }
103 
104 main();
105