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

我已編輯了我的問題,並且請不要爲解決方案提供負面投票。它對我有幫助..謝謝........... –

相關問題