AnsweredAssumed Answered

Add cm:tagscope aspect to a folder

Question asked by juans on Dec 5, 2016

Hi

 

I would like to assign  aspect cm:tagscope to a folder and use the functionality that summarize the use of certain tag within nodes inside that folder. Basically what is described in this wiki entry https://community.alfresco.com/docs/DOC-5977-tagging
to obtain the tags summarized like this:

 

(taken from previous link)

The aspect defines a single d:content property containing the aggregated data in plain text. The structure of the content is as follows.

 

presentation|24
tech|23
dev|23
sales|18
video|18

 

 

I am using OpenCMIS. I checked the alfresco content model and the aspect exists. I tried to add a secondaryType to the folder.

Something like this:

        Session session = getSession();
        
        Folder folder = (Folder) session.getObjectByPath("/someRootFolder");

 

        String timeStamp = new Long(System.currentTimeMillis()).toString();
        String folderName = folderName1 + " (" + timeStamp + ")";
        
        Map <String, Object> properties = new HashMap<String, Object>();
        properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder,P:cm:tagscope");
        properties.put(PropertyIds.NAME, folderName);

 

        Folder folderCreated = folder.createFolder(properties);
        System.out.println("Created: " + folderCreated.getId());
        System.out.println("In path: " + folderCreated.getPath());

 

This is the stacktrace I get from the server:

 

org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException
  at org.alfresco.opencmis.AlfrescoCmisExceptionInterceptor.invoke(AlfrescoCmisExceptionInterceptor.java:99)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
  at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
  at com.sun.proxy.$Proxy305.create(Unknown Source)
  at org.apache.chemistry.opencmis.server.support.wrapper.ConformanceCmisServiceWrapper.create(ConformanceCmisServiceWrapper.java:727)
  at org.apache.chemistry.opencmis.server.impl.atompub.ObjectService$Create.serve(ObjectService.java:107)
  at org.apache.chemistry.opencmis.server.shared.Dispatcher.dispatch(Dispatcher.java:91)
  at org.apache.chemistry.opencmis.server.impl.atompub.CmisAtomPubServlet.dispatch(CmisAtomPubServlet.java:226)
  at org.apache.chemistry.opencmis.server.impl.atompub.CmisAtomPubServlet.service(CmisAtomPubServlet.java:173)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
  at org.alfresco.opencmis.CMISServletDispatcher.execute(CMISServletDispatcher.java:188)
  at org.alfresco.opencmis.CMISWebScript.execute(CMISWebScript.java:51)
  at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:460)
  at org.alfresco.rest.api.PublicApiRepositoryContainer.transactionedExecute(PublicApiRepositoryContainer.java:45)
  at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:649)
  at org.alfresco.repo.web.scripts.RepositoryContainer.executeScriptInternal(RepositoryContainer.java:421)
  at org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:301)
  at org.alfresco.rest.api.PublicApiRepositoryContainer.access$001(PublicApiRepositoryContainer.java:26)
  at org.alfresco.rest.api.PublicApiRepositoryContainer$1.doWork(PublicApiRepositoryContainer.java:81)
  at org.alfresco.repo.tenant.TenantUtil.runAsWork(TenantUtil.java:119)
  at org.alfresco.repo.tenant.TenantUtil.runAsTenant(TenantUtil.java:88)
  at org.alfresco.rest.api.PublicApiRepositoryContainer.executeScript(PublicApiRepositoryContainer.java:77)
  at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:382)
  at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:210)
  at org.alfresco.repo.web.scripts.TenantWebScriptServlet.service(TenantWebScriptServlet.java:74)
  at org.alfresco.rest.api.PublicApiWebScriptServlet.service(PublicApiWebScriptServlet.java:53)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
  at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
  at org.alfresco.repo.web.filter.beans.NullFilter.doFilter(NullFilter.java:68)
  at sun.reflect.GeneratedMethodAccessor706.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:497)
  at org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:125)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
  at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
  at com.sun.proxy.$Proxy284.doFilter(Unknown Source)
  at org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:82)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
  at org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:61)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
  at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
  at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
  at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074)
  at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
  at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
  at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
  at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
  at org.alfresco.opencmis.CMISConnector.processSecondaryTypes(CMISConnector.java:3206)
  at org.alfresco.opencmis.CMISConnector.setProperties(CMISConnector.java:3094)
  at org.alfresco.opencmis.AlfrescoCmisServiceImpl.createFolder(AlfrescoCmisServiceImpl.java:1161)
  at org.alfresco.opencmis.AlfrescoCmisServiceImpl.create(AlfrescoCmisServiceImpl.java:1107)
  at org.alfresco.opencmis.PublicApiAlfrescoCmisService.create(PublicApiAlfrescoCmisService.java:55)
  at sun.reflect.GeneratedMethodAccessor1330.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:497)
  at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
  at org.alfresco.repo.transaction.RetryingTransactionInterceptor$1.execute(RetryingTransactionInterceptor.java:79)
  at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:457)
  at org.alfresco.repo.transaction.RetryingTransactionInterceptor.invoke(RetryingTransactionInterceptor.java:69)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
  at org.alfresco.opencmis.AlfrescoCmisStreamInterceptor.invoke(AlfrescoCmisStreamInterceptor.java:72)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
  at org.alfresco.opencmis.AlfrescoCmisServiceInterceptor.invoke(AlfrescoCmisServiceInterceptor.java:101)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
  at org.alfresco.opencmis.AlfrescoCmisExceptionInterceptor.invoke(AlfrescoCmisExceptionInterceptor.java:83)
  ... 60 more

 

 

 

Previous to the execution of the code I see the following in the log:

 

[main] DEBUG org.apache.chemistry.opencmis.client.bindings.spi.http.DefaultHttpInvoker - Session d6dcdf8f-318c-45cf-a933-d8df66fec858: GET http://localhost:9090/alfresco/api/-default-/public/cmis/versions/1.1/atom/type?id=P%3Acm%3Atagscope
[main] TRACE org.apache.chemistry.opencmis.client.bindings.spi.http.DefaultHttpInvoker - Session d6dcdf8f-318c-45cf-a933-d8df66fec858: GET http://localhost:9090/alfresco/api/-default-/public/cmis/versions/1.1/atom/type?id=P%3Acm%3Atagscope > Headers: {null=[HTTP/1.1 200 OK], Date=[Mon, 05 Dec 2016 16:27:03 GMT], Transfer-Encoding=[chunked], Content-Type=[application/atom+xml; type=entry], Server=[Apache-Chemistry-OpenCMIS/0.11.0], Cache-Control=[private, max-age=0]}
[main] TRACE org.apache.chemistry.opencmis.client.bindings.cache.impl.CacheImpl - Type Link Cache: removed [-default-, P:cm:tagscope]
[main] TRACE org.apache.chemistry.opencmis.client.bindings.cache.impl.CacheImpl - Type Link Cache: put [-default-, P:cm:tagscope, self, application/atom+xml;type=entry] = http://localhost:9090/alfresco/api/-default-/public/cmis/versions/1.1/atom/type?id=P%3Acm%3Atagscope
[main] TRACE org.apache.chemistry.opencmis.client.bindings.cache.impl.CacheImpl - Type Link Cache: put [-default-, P:cm:tagscope, up, application/atom+xml;type=entry] = http://localhost:9090/alfresco/api/-default-/public/cmis/versions/1.1/atom/type?id=cmis%3Asecondary
[main] TRACE org.apache.chemistry.opencmis.client.bindings.cache.impl.CacheImpl - Type Link Cache: put [-default-, P:cm:tagscope, down, application/atom+xml;type=feed] = http://localhost:9090/alfresco/api/-default-/public/cmis/versions/1.1/atom/types?typeId=P%3Acm%3Atagscope
[main] TRACE org.apache.chemistry.opencmis.client.bindings.cache.impl.CacheImpl - Type Link Cache: put [-default-, P:cm:tagscope, down, application/cmistree+xml] = http://localhost:9090/alfresco/api/-default-/public/cmis/versions/1.1/atom/typedesc?typeId=P%3Acm%3Atagscope
[main] TRACE org.apache.chemistry.opencmis.client.bindings.cache.impl.CacheImpl - Type Definition Cache: put [-default-, P:cm:tagscope] = Type Definition [base id=CMIS_SECONDARY, id=P:cm:tagscope, display Name=Tag Scope, description=P:cm:tagscope, local name=tagscope, local namespace=http://www.alfresco.org/model/content/1.0, query name=cm:tagscope, parent id=cmis:secondary, is controllable ACL=false, is controllable policy=false, is creatable=false, is fileable=false, is fulltext indexed=true, is included in supertype query=true, is queryable=true, property definitions={cm:tagScopeSummary=Property Definition [id=cm:tagScopeSummary, display name=Tag Summary, description=Tag Summary, local name=tagScopeSummary, local namespace=http://www.alfresco.org/model/content/1.0, query name=cm:tagScopeSummary, property type=STRING, cardinality=MULTI, choice list=null, default value=[], is inherited=false, is open choice=null, is queryable=true, is required=false, updatability=READONLY][extensions=null], cmis:objectId=Property Definition [id=cmis:objectId, display name=Object Id, description=The unique object id (a node ref), local name=objectId, local namespace=http://www.alfresco.org/model/cmis/1.0/cs01, query name=cmis:objectId, property type=ID, cardinality=SINGLE, choice list=null, default value=[], is inherited=true, is open choice=null, is queryable=true, is required=false, updatability=READONLY][extensions=null], alfcmis:nodeRef=Property Definition [id=alfcmis:nodeRef, display name=Alfresco Node Ref, description=Alfresco Node Ref, local name=nodeRef, local namespace=http://www.alfresco.org/model/cmis/1.0/alfcmis, query name=alfcmis:nodeRef, property type=ID, cardinality=SINGLE, choice list=null, default value=[], is inherited=true, is open choice=null, is queryable=false, is required=false, updatability=READONLY][extensions=null], cmis:name=Property Definition [id=cmis:name, display name=Name, description=Name, local name=name, local namespace=http://www.alfresco.org/model/cmis/1.0/cs01, query name=cmis:name, property type=STRING, cardinality=SINGLE, choice list=null, default value=[], is inherited=true, is open choice=null, is queryable=true, is required=true, updatability=READWRITE][extensions=null], cmis:lastModifiedBy=Property Definition [id=cmis:lastModifiedBy, display name=Last Modified By, description=The authority who last modified this object, local name=lastModifiedBy, local namespace=http://www.alfresco.org/model/cmis/1.0/cs01, query name=cmis:lastModifiedBy, property type=STRING, cardinality=SINGLE, choice list=null, default value=[], is inherited=true, is open choice=null, is queryable=true, is required=false, updatability=READONLY][extensions=null], cmis:secondaryObjectTypeIds=Property Definition [id=cmis:secondaryObjectTypeIds, display name=Secondary Object Type Ids, description=Ids of the secondary object types for the object, local name=secondaryObjectTypeIds, local namespace=http://www.alfresco.org/model/cmis/1.0/cs01, query name=cmis:secondaryObjectTypeIds, property type=ID, cardinality=MULTI, choice list=null, default value=[], is inherited=true, is open choice=null, is queryable=true, is required=false, updatability=READWRITE][extensions=null], cmis:objectTypeId=Property Definition [id=cmis:objectTypeId, display name=Object Type Id, description=Id of the object’s type, local name=objectTypeId, local namespace=http://www.alfresco.org/model/cmis/1.0/cs01, query name=cmis:objectTypeId, property type=ID, cardinality=SINGLE, choice list=null, default value=[], is inherited=true, is open choice=null, is queryable=true, is required=true, updatability=ONCREATE][extensions=null], cmis:lastModificationDate=Property Definition [id=cmis:lastModificationDate, display name=Last Modified Date, description=The date this object was last modified, local name=lastModificationDate, local namespace=http://www.alfresco.org/model/cmis/1.0/cs01, query name=cmis:lastModificationDate, property type=DATETIME, cardinality=SINGLE, choice list=null, default value=[], is inherited=true, is open choice=null, is queryable=true, is required=false, updatability=READONLY][extensions=null], cmis:description=Property Definition [id=cmis:description, display name=Description, description=Description, local name=description, local namespace=http://www.alfresco.org/model/cmis/1.0/cs01, query name=cmis:description, property type=STRING, cardinality=SINGLE, choice list=null, default value=[], is inherited=true, is open choice=null, is queryable=true, is required=false, updatability=READWRITE][extensions=null], cmis:createdBy=Property Definition [id=cmis:createdBy, display name=Created by, description=The authority who created this object, local name=createdBy, local namespace=http://www.alfresco.org/model/cmis/1.0/cs01, query name=cmis:createdBy, property type=STRING, cardinality=SINGLE, choice list=null, default value=[], is inherited=true, is open choice=null, is queryable=true, is required=false, updatability=READONLY][extensions=null], cmis:baseTypeId=Property Definition [id=cmis:baseTypeId, display name=Base Type Id, description=Id of the base object type for the object, local name=baseTypeId, local namespace=http://www.alfresco.org/model/cmis/1.0/cs01, query name=cmis:baseTypeId, property type=ID, cardinality=SINGLE, choice list=null, default value=[], is inherited=true, is open choice=null, is queryable=true, is required=false, updatability=READONLY][extensions=null], cmis:creationDate=Property Definition [id=cmis:creationDate, display name=Creation Date, description=The object creation date, local name=creationDate, local namespace=http://www.alfresco.org/model/cmis/1.0/cs01, query name=cmis:creationDate, property type=DATETIME, cardinality=SINGLE, choice list=null, default value=[], is inherited=true, is open choice=null, is queryable=true, is required=false, updatability=READONLY][extensions=null], cmis:changeToken=Property Definition [id=cmis:changeToken, display name=Change token, description=Change Token, local name=changeToken, local namespace=http://www.alfresco.org/model/cmis/1.0/cs01, query name=cmis:changeToken, property type=STRING, cardinality=SINGLE, choice list=null, default value=[], is inherited=true, is open choice=null, is queryable=false, is required=false, updatability=READONLY][extensions=null]}, typeMutability=null][extensions=null]
[main] DEBUG org.apache.chemistry.opencmis.client.bindings.spi.http.DefaultHttpInvoker - Session d6dcdf8f-318c-45cf-a933-d8df66fec858: POST http://localhost:9090/alfresco/api/-default-/public/cmis/versions/1.1/atom/children?id=ee07a9a3-45f3-47de-9431-212595b01fac
[main] TRACE org.apache.chemistry.opencmis.client.bindings.spi.http.DefaultHttpInvoker - Session d6dcdf8f-318c-45cf-a933-d8df66fec858: POST http://localhost:9090/alfresco/api/-default-/public/cmis/versions/1.1/atom/children?id=ee07a9a3-45f3-47de-9431-212595b01fac > Headers: {null=[HTTP/1.1 500 Internal Server Error], Date=[Mon, 05 Dec 2016 16:32:19 GMT], Transfer-Encoding=[chunked], Connection=[close], Content-Type=[text/html;charset=UTF-8], Server=[Apache-Chemistry-OpenCMIS/0.11.0], Cache-Control=[private, max-age=0]}
Exception in thread "main" org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException: null
    at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.convertStatusCode(AbstractAtomPubService.java:493)
    at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.post(AbstractAtomPubService.java:635)
    at org.apache.chemistry.opencmis.client.bindings.spi.atompub.ObjectServiceImpl.createFolder(ObjectServiceImpl.java:159)
    at org.apache.chemistry.opencmis.client.runtime.SessionImpl.createFolder(SessionImpl.java:1091)
    at org.apache.chemistry.opencmis.client.runtime.FolderImpl.createFolder(FolderImpl.java:116)
    at org.apache.chemistry.opencmis.client.runtime.FolderImpl.createFolder(FolderImpl.java:459)
    at com.someco.cmis.examples.CMISExampleBase.tagscopeExample(CMISExampleBase.java:253)
    at com.someco.cmis.examples.TagScopeExample.main(TagScopeExample.java:16)

 

 

My questions are:

1. Does this functionality of summarizing tags still works in current alfresco version ? I am using Community v5.1.0 (r127059-b7) 
2. What am I doing wrong in my code ?
3. Do I have to enable something else in alfresco for this to work ?

Outcomes