2013-05-23 3 views
1

OpenCmis in-memory을 테스트 용으로 사용합니다. 그러나 문서를 만들 때 versioningState를 다른 것으로 설정 한 다음 versioningState.NONE을 설정할 수 없습니다.작성된 문서는 버전이 없습니다.

public void test() { 
    String filename = "test123"; 
    Folder folder = this.session.getRootFolder(); 

    // Create a doc 
    Map<String, Object> properties = new HashMap<String, Object>(); 
    properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document"); 
    properties.put(PropertyIds.NAME, filename); 
    String docText = "This is a sample document"; 
    byte[] content = docText.getBytes(); 
    InputStream stream = new ByteArrayInputStream(content); 
    ContentStream contentStream = this.session.getObjectFactory().createContentStream(filename, Long.valueOf(content.length), "text/plain", stream); 

    Document doc = folder.createDocument(
      properties, 
      contentStream, 
      VersioningState.MAJOR); 
} 

내가 얻을 예외 :

org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException: The versioning state flag is imcompatible to the type definition. 

무엇 오전

몇 가지 방법을 버전 관리가되지 않고 생성 된 문서는 ... 나는 http://chemistry.apache.org/java/examples/example-create-update.html

시험 방법의 코드를 사용 내가 빠졌어? 버전 관리를 허용하지 않는 : 나는 OBJECT_TYPE_ID '문서 CMIS가'발견 다음 코드를 실행함으로써

나는 이유를 발견

답변

1

...

.

코드 (source)를 사용할 수있는 모든 OBJECT_TYPE_ID의를 볼 수 있습니다 :

TYPE : CMIS 폴더 (CMIS 폴더 유형에 대한 설명) ID : CMIS

boolean includePropertyDefintions = true; 
     for (t in session.getTypeDescendants(
      null, // start at the top of the tree 
      -1, // infinite depth recursion 
      includePropertyDefintions // include prop defs 
      )) { 
     printTypes(t, ""); 
     } 

    static void printTypes(Tree tree, String tab) {   
     ObjectType objType = tree.getItem(); 
     println(tab + "TYPE:" + objType.getDisplayName() + 
      " (" + objType.getDescription() + ")"); 
     // Print some of the common attributes for this type 
     print(tab + " Id:" + objType.getId());        
     print(" Fileable:" + objType.isFileable()); 
     print(" Queryable:" + objType.isQueryable()); 

     if (objType instanceof DocumentType) {        
     print(" [DOC Attrs->] Versionable:" + 
      ((DocumentType)objType).isVersionable()); 
     print(" Content:" + 
      ((DocumentType)objType).getContentStreamAllowed()); 
     } 
     println(""); // end the line 
     for (t in tree.getChildren()) { 
     // there are more - call self for next level 
     printTypes(t, tab + " "); 
     } 
    } 

이이 같은 목록에 결과 : 폴더 Fileable : true 쿼리 가능 : true

TYPE : CMIS 문서 (CMIS 문서 형식 설명) ID : cmis : document 파일 가능 : true Queryab 제작 : 사실 [DOC Attrs->] 버전 관리 : 잘못된 내용 : MyDocType1 Fileable : 사실 Queryable에서 :
이드가 내 타입 1 레벨 1 (제 1 형 레벨 1 유형에 대한 설명) :

TYPE 허용 진정한 [DOC Attrs->] 버전 관리 : 잘못된 내용 : 허용

TYPE : VersionedType (VersionedType 유형에 대한 설명)
ID : VersionableType Fileable : 사실 Queryable에서 : 사실 [DOC Attrs->] 버전 관리 : 사실 내용 : 허용

마지막 OBJECT_TYPE_ID가 versionable : true ...를 가지고 있고 그것을 사용할 때 작동한다는 것을 알 수 있습니다.

관련 문제