cancel
Showing results for 
Search instead for 
Did you mean: 

copy contents between 2 Alfresco servers

robertoroberto
Champ in-the-making
Champ in-the-making
Hi, How can I copy a content from a repository from an Alfresco Server  installed to an other repository on an other Alfresco Server?
Is it possible? Can you help me?
4 REPLIES 4

robertoroberto
Champ in-the-making
Champ in-the-making
Hi, How can I copy a content from a repository from an Alfresco Server  installed to an other repository on an other Alfresco Server?
Is it possible? Can you help me?

I want programmatically do it.
Thanks

robertoroberto
Champ in-the-making
Champ in-the-making
I have written this code to do a test on the same server.
this code downloads content from a folder, then write it in other folder.
After execution, the source file size is 45KB, after the copy in new folder his size is 20KB and the file is corrupted:
Can you help me? (sorry for my english)



URL url = new URL("http://localhost:8080/alfresco/download/attach/workspace/SpacesStore/'+contenuti.get(0)+'?ticket='+t...);
      URLConnection connection = url.openConnection();
      
      InputStream stream = connection.getInputStream();
      String nomedocumento="prova.pdf";
      
        ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();       
       
        // Create new content in the respository
        Reference newContentReference = createNewContent(STORE, contentService, nomedocumento, stream);



public static Reference createNewContent(Store STORE, ContentServiceSoapBindingStub contentService, String nomedocumento,InputStream stream)
     throws Exception
{
     // Create a parent reference, this contains information about the association we are createing to the new content and the
     // parent of the new content (the space retrived from the search)
     ParentReference parentReference = new ParentReference(STORE, null, "/app:company_home/app:user_homes/cm:administrator" ,ASSOC_CONTAINS, ASSOC_CONTAINS);
    
     // Define the content format for the content we are adding
     ContentFormat contentFormat = new ContentFormat("application/pdf", "UTF-8");
    
     NamedValue[] properties = new NamedValue[]{Utils.createNamedValue(Constants.PROP_NAME, System.currentTimeMillis() + "_" + name)};
     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);    
     byte[] bytes = ContentUtils.convertToByteArray(stream);
     Reference newContentNode = result[0].getDestination();
     Content content = contentService.write(newContentNode, Constants.PROP_CONTENT, bytes, contentFormat);
    
     // Get a reference to the newly created content
     return content.getNode();
}

robertoroberto
Champ in-the-making
Champ in-the-making
Hi, The problem is the download code, Can you tell me an other way to obtain the bytes of the content?
Thanks a lot

robertoroberto
Champ in-the-making
Champ in-the-making
uhm, the problem is the conversion from InputStream to bytes  :shock:
Can you help me?