2014-09-11 105 views
0

我使用opencms java客戶端庫CMIS 1.1的alfresco 4.2。Alfresco CMIS查詢返回objectId,其中包含分號和版本

String serviceUrl = "http://URL/alfresco/api/-default-/public/cmis/versions/1.1/atom"; // Uncomment for Web Services binding 

    // default factory implementation 
    SessionFactory factory = SessionFactoryImpl.newInstance(); 
    Map<String, String> parameter = new HashMap<String, String>(); 
    // user credentials 
    parameter.put(SessionParameter.USER, "admin"); 
    parameter.put(SessionParameter.PASSWORD, "admin"); 
    // connection settings 
    parameter.put(SessionParameter.ATOMPUB_URL, serviceUrl); // Uncomment for Atom Pub binding 
    parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value()); // Uncomment for Atom Pub binding 

    // Set the alfresco object factory 
    // Used when using the CMIS extension for Alfresco for working with aspects 
    List<Repository> repositories = factory.getRepositories(parameter); 
    Session session = repositories.get(0).createSession(); 

    // Get some repository info 
    System.out.println("Repository Name: "+session.getRepositoryInfo().getName()); 
    System.out.println("Repository ID: "+session.getRepositoryInfo().getId()); 
    System.out.println("CMIS Version: "+session.getRepositoryInfo().getCmisVersion()); 

    List<String> cmisObjectId = new ArrayList<String>(); 

    StringBuilder sb = new StringBuilder(); 
    sb.append("select * from ged:document m"); 

    // execute query 
    ItemIterable<QueryResult> results = session.query(sb.toString(), false); 

    for (QueryResult qResult : results) { 

     PropertyData<?> propData = qResult.getPropertyById("cmis:objectId"); 
     String objectId = (String) propData.getFirstValue(); 
     cmisObjectId.add(objectId); 
     System.out.println(objectId); 
    } 

結果是:

e8137d5d-cf50-41c4-844a-ec98a44ee73a;1.0 
f86557af-89c3-4287-85c4-381e47896c1a;1.0 
d56b4e1e-e1dc-4514-9bd2-24080b7879a8;1.0 
59a0a9a8-8309-43b6-8040-bb3e9e448171;1.0 

但我想節點的ID沒有版本號,使用它的REST API調用。

謝謝。

回答

4

CMIS對象ID被定義爲不透明的字符串。格式將在不同的存儲庫實現中有所不同,並且可能在存儲庫版本之間有所不同

如果你想在露天NodeRef,並且你確定你跟一個露天的服務器,那麼你想要的屬性爲alfcmis:nodeRef

如果您連接到與Apache化學CMIS工作臺信息庫,你可以看到它報告的性質,並從那裏看到這樣

Workbench showing it

+0

謝謝你的事情,阿帕奇化學CMIS Workbench是非常有用的。我也看過cmis:versionSeriesId,但似乎所有對象都沒有這個屬性。只有「可版本化」的。所以我使用nodeRef並解析它以獲取id,標識符和協議。 – 2014-09-12 09:52:02