Advertisement
robgonsalves

IPWS: GetLatest, CheckInAAF

Feb 8th, 2016
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.07 KB | None | 0 0
  1. // This is a sample program to:
  2. // 1. get the latest version of an AAF file from Interplay
  3. // 2. check in an AAF into Interplay
  4. // 3. print out the contents of a folder in Interplay
  5.  
  6. package com.avid.interplay.ws.client;
  7. import com.avid.interplay.ws.assets.*;
  8. import com.avid.interplay.ws.assets.types.*;
  9. import javax.activation.FileDataSource;
  10. import javax.activation.DataHandler;
  11. import java.io.*;
  12.  
  13. public class InterplayWSClient {
  14.  
  15.     public static void main(String[] args) {
  16.         getLatest();
  17.         checkInAAF();
  18.         getChildren();
  19.     }
  20.    
  21.     public static void getLatest() {
  22.         // setup the credentials
  23.         UserCredentialsType creds = new UserCredentialsType();
  24.         creds.setUsername("uuu");
  25.         creds.setPassword("ppp");
  26.        
  27.         // setup the service
  28.         Assets service = new Assets();
  29.         AssetsPortType port = service.getAssetsPort();
  30.  
  31.         // set the Interplay URI
  32.         GetLatestType body = new GetLatestType();
  33.         body.setInterplayURI("interplay://WGC?mobid=060a2b340101010101010f0013-000000-5649977d2af0818d-060e2b347f7f-2a80");
  34.        
  35.         try {
  36.             // make the call
  37.             GetLatestResponseType result;
  38.             result = port.getLatest(body, creds);
  39.            
  40.             // print out the results
  41.             if (result.getErrors() != null && result.getErrors().getError().size()>0)
  42.             {
  43.                 for (ErrorType error : result.getErrors().getError()) {
  44.                     System.out.println("Checkin error: " + error.getDetails());
  45.                 }
  46.             }
  47.             else {         
  48.                 // save out the file
  49.                 DataHandler dataHandler = result.getFile();
  50.                 FileOutputStream os = new FileOutputStream("c:\\folder\\theFile.aaf");
  51.                 dataHandler.writeTo(os);
  52.                 os.close();
  53.                
  54.                 System.out.println("GetLatest Success!");  
  55.             }
  56.  
  57.         } catch (AssetsFault e) {
  58.             e.printStackTrace();
  59.         } catch (FileNotFoundException e) {
  60.             e.printStackTrace();
  61.         } catch (IOException e) {
  62.             e.printStackTrace();
  63.         }
  64.     }
  65.    
  66.     public static void checkInAAF() {
  67.         // setup the credentials
  68.         UserCredentialsType creds = new UserCredentialsType();
  69.         creds.setUsername("uuu");
  70.         creds.setPassword("ppp");
  71.        
  72.         // setup the service
  73.         Assets service = new Assets();
  74.         AssetsPortType port = service.getAssetsPort();
  75.  
  76.         // set the parameters
  77.         CheckInAAFType body = new CheckInAAFType();
  78.         body.setInterplayURI("interplay://WGC/Catalogs/MyClips/CheckCallg/");
  79.        
  80.         // setup the data handler
  81.         FileDataSource fileDataSource = new FileDataSource(new File("c:\\folder\\theFile.aaf"));
  82.         DataHandler dataHandler = new DataHandler(fileDataSource);
  83.         body.setAAF(dataHandler);
  84.        
  85.         try {
  86.             // make the call
  87.             CheckInAAFResponseType result;
  88.             result = port.checkInAAF(body, creds);
  89.                    
  90.             // print out the results
  91.             if (result.getErrors() != null && result.getErrors().getError().size()>0)
  92.             {
  93.                 for (ErrorType error : result.getErrors().getError()) {
  94.                     System.out.println("Checkin error: " + error.getDetails());
  95.                 }
  96.             }
  97.             else {
  98.                 System.out.println("Success! Checked in: " + result.getInterplayURI());
  99.             }
  100.  
  101.         } catch (AssetsFault e) {
  102.             e.printStackTrace();
  103.         }
  104.     }
  105.    
  106.     public static void getChildren() {
  107.         // setup the credentials
  108.         UserCredentialsType creds = new UserCredentialsType();
  109.         creds.setUsername("uuu");
  110.         creds.setPassword("ppp");
  111.        
  112.         // setup the service
  113.         Assets service = new Assets();
  114.         AssetsPortType port = service.getAssetsPort();
  115.  
  116.         // set the parameters
  117.         GetChildrenType body = new GetChildrenType();
  118.         body.setInterplayURI("interplay://WGC/Catalogs/MyClips/CheckCallg/");
  119.         body.setIncludeFiles(false);
  120.         body.setIncludeFolders(false);
  121.         body.setIncludeMOBs(true);
  122.        
  123.         try {
  124.             // make the call
  125.             GetChildrenResponseType result;
  126.             result = port.getChildren(body, creds);
  127.  
  128.             // print out the results
  129.             for (AssetDescriptionType asset : result.getResults().getAssetDescription()) {
  130.                 System.out.println(asset.getInterplayURI());
  131.                 for (AttributeType att : asset.getAttributes().getAttribute()) {
  132.                     System.out.println(att.getGroup() + "." + att.getName() + " = " + att.getValue());
  133.                 }
  134.                 System.out.println();
  135.             }
  136.         } catch (AssetsFault e) {
  137.             e.printStackTrace();
  138.         }
  139.     }
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement