无法创建自定义分类

Cannot create a custom classification

我已将以下自定义方面添加到我的内容模型中:

<aspect name="my:locationDocumentClassification">
    <title>My Location Document Classification</title>
    <parent>cm:classifiable</parent>
    <properties>
        <property name="my:locationDocumentCategory">
            <title>Location Document Categories</title>
            <type>d:category</type>
            <mandatory>false</mandatory>
            <multiple>false</multiple>
            <index enabled="true">
                <atomic>true</atomic>
                <stored>true</stored>
                <tokenised>false</tokenised>
            </index>
        </property> 
    </properties>
</aspect>

现在我希望能够将一组类别填充到分类中。我正在使用以下 Webscript 来填充类别:

    protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
//        NodeRef newRootCat = categoryService.createRootCategory(
//                StoreRef.STORE_REF_WORKSPACE_SPACESSTORE,
//                ContentModel.ASPECT_GEN_CLASSIFIABLE,
//                "testroot");
//        LOGGER.log(Level.INFO, "Created: {0}", newRootCat.toString());
//        NodeRef newCategory = categoryService.createCategory(newRootCat, "testcat");
//        LOGGER.log(Level.INFO, "Created: {0}", newCategory.toString());
//        NodeRef locationDocumentClassification = categoryService.createClassification(
//                StoreRef.STORE_REF_WORKSPACE_SPACESSTORE,
//                MyModel.ASPECT_MY_LOCATION_DOCUMENT_CLASSIFICATION, 
//                "locationDocumentClassification");
//        LOGGER.log(Level.INFO, "Created: {0}", locationDocumentClassification.toString());
        NodeRef locationDocumentRootCat = categoryService.createRootCategory(
                StoreRef.STORE_REF_WORKSPACE_SPACESSTORE,
                MyModel.ASPECT_MY_LOCATION_DOCUMENT_CLASSIFICATION,
                "testroot");
        LOGGER.log(Level.INFO, "Created: {0}", locationDocumentRootCat.toString());
        NodeRef klantDocCat = categoryService.createCategory(locationDocumentRootCat, "testcat");
        LOGGER.log(Level.INFO, "Created: {0}", klantDocCat.toString());
        return new HashMap<>();
    }

当我执行代码时,出现以下错误:

10170041 Wrapped Exception (with status template): 10170014 Missing classification: {http://my.company.com/model/content/1.0}locationDocumentClassification

代码中的前两个注释语句是来自 Alfresco 的示例代码,它运行良好。第三个被注释掉的语句是我试图首先创建一个分类以查看它是否有效。取消注释 createClassification 语句时出现的错误:

java.lang.UnsupportedOperationException         at org.alfresco.repo.search.impl.lucene.LuceneCategoryServiceImpl.createClassification(LuceneCategoryServiceImpl.java:369)

所以运气不好。我希望有人能看到问题所在。我阅读了我能找到的所有关于此的帖子和论坛,但找不到答案。

我正在使用 Alfresco 5.0d 社区版。

如果您下载 SDK 的源文件,您会看到您正在触发以下代码:

public NodeRef createRootCategory(StoreRef storeRef, QName aspectName, String name)
    {
        Set<NodeRef> nodeRefs = getClassificationNodes(storeRef, aspectName);
        if (nodeRefs.size() == 0)
        {
            throw new AlfrescoRuntimeException("Missing classification: " + aspectName);
        }
        NodeRef parent = nodeRefs.iterator().next();
        return createCategory(parent, name);
    }



private Set<NodeRef> getClassificationNodes(StoreRef storeRef, QName qname)
    {
        ResultSet resultSet = null;
        try
        {
            resultSet = indexerAndSearcher.getSearcher(storeRef, false).query(storeRef, "lucene",
                    "PATH:\"/" + getPrefix(qname.getNamespaceURI()) + ISO9075.encode(qname.getLocalName()) + "\"", null);

            etc....
    }

所以基本上它试图做的是搜索已经创建的类别并创建根目录。

所以您需要做的就是使用代码在 category_root 中创建类型为 cm:category 的节点,然后将您的方面添加到其中。 搜索 TYPE:"cm:category_root" 并创建它。

或者创建您自己的类型,其父级为 cm:category。唯一的问题是您需要更改很多 UI 元素,因为它们只检查类型 cm:category.