Unable to create custom classification

The following custom aspect has been added to my content model:

<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>

Now I want to be able to fill out a set of categories for classification. I use the following Webscript to populate the categories:

    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<>();
    }

When I execute the code, I get the following error:

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

The first two comments in the code are sample code from Alfresco that works great. The third comment commented out is an attempt to first create a classification to see if this works. The error I get when I uncomment an instruction createClassification:

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

So no luck. I hope there is someone who can see the problem. I read all the posts and forums that I could find about this, but could not find an answer.

I am using Alfresco community version 5.0d.

+4
1

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....
    }

, , .

, node cm:category category_root . TYPE:"cm:category_root" .

, cm:. , , cm:.

0

Source: https://habr.com/ru/post/1616257/


All Articles