1

我想将所有露天存储库内容从一个存储库迁移到其他存储库。但我不想要现有的文件夹结构。 在迁移时,我必须根据一些业务需求验证内容,并且基于内容类型,我必须在新的存储库中创建不同的文件夹结构。如何使用Open CMIS将内容从一个露天存储库迁移到其他使用Open CMIS

以前是否有人这样做过。 请帮忙。

在此先感谢...

+2

它是在同一台服务器,我的意思是它只是将内容从存储库移动到另一个 –

+0

@Yagami Light否,服务器是不同的 –

+1

我可以给出一个关于它的答案(使用CMIS),但我相信你可以找到一个你对此感兴趣吗? (它就像下载和重新上传这个文件包含文件夹) –

回答

1

好吧,我给的解决方案是不是最好的,但我认为它会工作,我们将开始与一个简单的文档,看看它的工作(我们将modifie答案)

获得一个

文件的inputStram我认为这是最重要的部分

public InputStream getTheInputStream() {  
Document newDocument = (Document) getSession(serverURL, userName, password).getObject(path); 
ContentStream cs = newDocument.getContentStream(null); 
return cs.getStream(); 
} 

移动从服务器A的inputStram到服务器B

public void transfert() throws FileNotFoundException, IOException { 
    Session sessionB = getSession(serverUrlB, usernameB, passwordB); 

    //////////////////////////// GET THE FOLDER THAT YOU WILL WORK WITH 
    Folder root = sessionB.getRootFolder(); 
    //////////////////////////// GET THE FOLDER THAT YOU WILL WORK WITH 
    File newfile = new File(fileName); 
    String nom = fileName; 
    Map<String, Object> properties = new HashMap<>(); 
    properties.put(PropertyIds.OBJECT_TYPE_ID, BaseTypeId.CMIS_DOCUMENT.value()); 
    properties.put(PropertyIds.NAME, nom); 
    List<Ace> addAces = new LinkedList<>(); 
    List<Ace> removeAces = new LinkedList<>(); 
    List<Policy> policies = new LinkedList<>(); 
    String extension = FilenameUtils.getExtension(nom); 
    ContentStream contentStream = new ContentStreamImpl("content." + extension, BigInteger.valueOf(nom).length()), 
      new MimetypesFileTypeMap().getContentType(newfile), (theInputStream); 
    Document dc = root.createDocument(properties, contentStream, VersioningState.MAJOR, policies, addAces, removeAces, sessionB.getDefaultContext());   

} 

试试这个方法,并告诉我,如果它的工作,如果你不具备的getSession方法只是看这个帖子get session method

+0

请理解我们将一步步工作 –

+0

请使用您确切知道路径的文件来尝试使用 –

+0

我已编辑了我的问题,并且请不要为解决方案提供负面投票。它对我有帮助..谢谢........... –

相关问题