2

私のモデルは次のようになります。

2つのフォルダー(HTML)と(画像)があります。大量のファイルが画像フォルダー内に挿入されます。私が実装しようとしているビジネス ユース ケースのごく一部は、クライアントが chapter1.html を要求したときに、その chapter1.html に関連付けられているすべての画像を A​​lfresco リポジトリから取得して送信する必要があるというものです。

私は CMIS を使用しており、CMIS が提供するほとんどのことを実行できます。ほとんどのチュートリアルとコード スニペットを実行して、次の方法で関係を作成できました。

https://anonsvn.springframework.org/svn/se-surf/branches/DEV_CMIS_2/sandbox/spring-cmis/spring-cmis-test/src/main/java/org/springframework/extensions/cmis/test/CmisCreateTest.ジャワ

  1. testCreateRelationship(): 正常に動作しますが、Context に setIncludeRelationships を設定して getRelationships() を呼び出すと、再び空が返されます。

  2. testBelarus(): 機能せず、次の例外をスローします (org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException: Bad Request)。

ここの「関係」セクションhttp://chemistry.apache.org/java/developing/guide.htmlにあるコード スニペットを使用 して、作成に成功しましたが、その特定の HTML の参照された画像を取得するのが難しいことがわかりました。

Alfresco in prod に行くのを妨げているのはこれだけなので、解決策を提案してください。

間違った方法で実行している場合 (関係を作成している場合)、および私の要件に対してより良い解決策がある場合 (カスタム モデル/alfcmis:nodeRef/cmiscustom:docprop_string を使用するなど) がある場合は、提案してください。

どんな助けでも大歓迎です。

ありがとう

4

1 に答える 1

3

testCreateRelationship()からのコードを貼り付け、最後にいくつかのコードを追加して、関係を取得してコンソールに出力する方法を示します(運が悪か​​ったので、この方法を試したように聞こえますか?以下のコードはとにかく私のリポジトリで機能します):

public void testCreateRelationship()
{
    Session session = createSession();
    Folder root = session.getRootFolder();

    Map<String,String> newFolderProps = new HashMap<String, String>();
    newFolderProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
    String name = "testCreateRelationship " + System.currentTimeMillis();
    newFolderProps.put(PropertyIds.NAME, name);
    Folder folder = root.createFolder(newFolderProps, null, null, null, session.getDefaultContext());
    System.out.println(folder.getName());

    Map<String,String> newDocProps1 = new HashMap<String, String>();
    newDocProps1.put(PropertyIds.OBJECT_TYPE_ID, "D:cmiscustom:document");
    newDocProps1.put(PropertyIds.NAME, "Test Doc 1");
    ContentStream contentStream1 = new ContentStreamImpl("xyz.txt", null, "plain/text", new ByteArrayInputStream("some content".getBytes()));
    Document doc1 = folder.createDocument(newDocProps1, contentStream1, VersioningState.MAJOR, null, null, null, session.getDefaultContext());

    Map<String,String> newDocProps2 = new HashMap<String, String>();
    newDocProps2.put(PropertyIds.OBJECT_TYPE_ID, "D:cmiscustom:document");
    newDocProps2.put(PropertyIds.NAME, "Test Doc 2");
    ContentStream contentStream2 = new ContentStreamImpl("xyz.txt", null, "plain/text", new ByteArrayInputStream("some content".getBytes()));
    Document doc2 = folder.createDocument(newDocProps2, contentStream2, VersioningState.MAJOR, null, null, null, session.getDefaultContext());

    Map<String, Serializable> relProps = new HashMap<String, Serializable>(); 
    relProps.put("cmis:sourceId", doc1.getId()); 
    relProps.put("cmis:targetId", doc2.getId()); 
    relProps.put("cmis:objectTypeId", "R:cmiscustom:assoc");
    session.createRelationship(relProps, null, null, null);

    // create a OperationContext that fetches relationships on both ends...
    OperationContext operationContext = new OperationContextImpl();
    operationContext.setIncludeRelationships(IncludeRelationships.BOTH);


    CmisObject object = session.getObject(doc1,operationContext);


    List<Relationship> relationships = object.getRelationships();
    for (Relationship rel : relationships){
        System.out.println("relation: "+ rel.getName());
    }
}
于 2013-01-28T20:28:36.347 に答える