1 17 package org.alfresco.webservice.sample; 18 19 import org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub; 20 import org.alfresco.webservice.repository.UpdateResult; 21 import org.alfresco.webservice.types.CML; 22 import org.alfresco.webservice.types.CMLAddAspect; 23 import org.alfresco.webservice.types.CMLCreate; 24 import org.alfresco.webservice.types.NamedValue; 25 import org.alfresco.webservice.types.ParentReference; 26 import org.alfresco.webservice.types.Reference; 27 import org.alfresco.webservice.util.AuthenticationUtils; 28 import org.alfresco.webservice.util.Constants; 29 import org.alfresco.webservice.util.WebServiceFactory; 30 31 38 public class WebServiceSample4 extends WebServiceSampleBase 39 { 40 43 public static void main(String [] args) 44 throws Exception  45 { 46 AuthenticationUtils.startSession(USERNAME, PASSWORD); 47 try 48 { 49 createSampleData(); 51 52 RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService(); 54 55 ParentReference parentReference = new ParentReference(STORE, null, "/app:company_home/cm:sample_folder", Constants.ASSOC_CONTAINS, Constants.ASSOC_CONTAINS); 59 NamedValue[] properties = new NamedValue[]{new NamedValue(Constants.PROP_NAME, System.currentTimeMillis() + "_WebServiceSample4.txt")}; 60 CMLCreate create = new CMLCreate("id1", parentReference, Constants.TYPE_CONTENT, properties); 61 CMLAddAspect addAspect = new CMLAddAspect(Constants.ASPECT_VERSIONABLE, null, null, "id1"); 62 CML cml = new CML(); 63 cml.setCreate(new CMLCreate[]{create}); 64 cml.setAddAspect(new CMLAddAspect[]{addAspect}); 65 66 UpdateResult[] updateResults = repositoryService.update(cml); 68 69 for (UpdateResult updateResult : updateResults) 70 { 71 String sourceId = "none"; 72 Reference source = updateResult.getSource(); 73 if (source != null) 74 { 75 sourceId = source.getUuid(); 76 } 77 78 String destinationId = "none"; 79 Reference destination = updateResult.getDestination(); 80 if (destination != null) 81 { 82 destinationId = destination.getUuid(); 83 } 84 85 System.out.println( 86 "Command = " + updateResult.getStatement() + 87 "; Source = " + sourceId + 88 "; Destination = " + destinationId); 89 } 90 } 91 finally 92 { 93 AuthenticationUtils.endSession(); 95 } 96 } 97 } 98
| Popular Tags
|