 
					
				
		
04-26-2007 07:23 AM
public class AddIssue
{
   
   private final static Store STORE = new Store(Constants.WORKSPACE_STORE, "SpacesStore"); 
   
   private String username = "admin";
   private String password = "admin";
   private static final String ASSOC_CONTAINS = "{http://www.alfresco.org/model/content/1.0}contains";
   public static void main(String[] args) {
      new AddIssue();
   }
   public AddIssue() {
     //filename for the document
      String filename = "issue1.jpg";
      
      // path to the file that should be uploaded
      String file = "org/alfresco/webservice/test/resources/test.jpg";
      
      // where to put the file 
      String location = "/app:company_home/cm:Dokumente/cm:Daniel";
      
      // what kind of file is it?
      String filetype = "image/jpeg";
            
        try {
           // Authentication
           AuthenticationUtils.startSession(username, password);
          
           // get classification Service
           ClassificationServiceSoapBindingStub classificationService = WebServiceFactory.getClassificationService(); 
           
        
           
           // Upload
           
           // Upload binary content into the repository
           //Reference reference = Query1.executeSearch();
           
           ParentReference parentReference = new ParentReference(STORE, null, location ,ASSOC_CONTAINS, ASSOC_CONTAINS);
           
          
           // Create the content
           NamedValue[] properties = new NamedValue[]{Utils.createNamedValue(Constants.PROP_NAME, filename)};
          
           CMLCreate create = new CMLCreate("1", parentReference, null, null, null, Constants.TYPE_CONTENT, properties);
                      CML cml = new CML();
           cml.setCreate(new CMLCreate[]{create});
           UpdateResult[] result = WebServiceFactory.getRepositoryService().update(cml);
          
           
           // Get the created node and create the format
           Reference newContentNode = result[0].getDestination();              
           ContentFormat format = new ContentFormat(filetype, "UTF-8");  
           
           // Open the file and convert to byte array
           InputStream viewStream = newContentNode.getClass().getClassLoader().getResourceAsStream(file);
           byte[] bytes = ContentUtils.convertToByteArray(viewStream);
           
           
           // Write the content
           WebServiceFactory.getContentService().write(newContentNode, Constants.PROP_CONTENT, bytes, format);
           
           
           
           
           
             } catch (Exception e) {
         e.printStackTrace();
      } finally {
         AuthenticationUtils.endSession();
         System.out.println("Everything seems to be good");
      }
   }
} 04-26-2007 12:20 PM
 
					
				
		
04-26-2007 12:26 PM
04-26-2007 10:39 PM
 
					
				
		
04-27-2007 09:32 AM
private final static Store STORE = new Store(Constants.WORKSPACE_STORE, "SpacesStore"); 
Reference catRef = new Reference(STORE, null, "cm:generalclassifiable/cm:Test/cm:Test2");
04-27-2007 11:31 AM
 
					
				
		
04-29-2007 03:17 AM
 
					
				
		
05-02-2007 07:10 AM
 
					
				
		
11-27-2007 11:06 AM
 
					
				
		
03-05-2009 04:34 AM
 
					
				
				
			
		
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.