cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieves tags in CMIS query

drahas
Champ in-the-making
Champ in-the-making
Hi

I'm using DotCMIS to access Alfresco documents and I want to retrieve documents and theirs tags in a query.
I have already done a simple query to retrieve my documents (SELECT d.* FROM cmis:document d WHERE IN_FOLDER('@folderID')) and it's working and after I call rest api to retrieve tags for each documents.
But I have some horrible performances for few documents, that is not possible …

Now I looking for a way to do it faster Smiley Happy
I have found this query : select d.*, o.* from cmis:document as d join cm:taggable as o on d.cmisSmiley Surprisedbjectid = o.cmisSmiley Surprisedbjectid
But it doesn't work in my case, CMIS error.

Somebody have an idea how to do it ?
8 REPLIES 8

afaust
Legendary Innovator
Legendary Innovator
Hello,

please be aware that joining on secondary types in a CMIS query is only possible if you use the CMIS 1.1 compliant API of Alfresco. Alfresco supports both CMIS 1.0 and CMIS 1.1 with different URL endpoints and you need to be aware of which you use (also which type of binding).

Alfresco also had some support for joining on aspects in CMIS 1.0, but via a different approach that resulted in slightly different queries.

So, please retry and ensure you use a CMIS 1.1 endpoint. If you use the cmisbrowser binding, you are guaranteed to use CMIS 1.1 as that binding has been introduced with that version and didn't exist in 1.0.
Then, if you still have an error, you should add it in your post so others can give better guidance.

Regards
Axel

drahas
Champ in-the-making
Champ in-the-making
Thank you for your help AFaust.

I'm a little bit lost in this differents url for CMIS,
I'm using this url : "http://[host]:[port]/alfresco/service/cmis and my queries work fine, but I need to retrieve tags now.

According the documentation I tried this url : http://[host]:[port]/alfresco/api/-default-/public/cmis/versions/1.1/atom. It's ok, I have same results.
But the query for tags return a "Bad request" exception

Have you an idea what i'm doing wrong ? ?

afaust
Legendary Innovator
Legendary Innovator
You still haven't provided any details about the "Bad request" exception - typically there should be some kind of exception stack trace in either the logs or the HTTP response body, or at least an error message that states what part of the request is "bad".

The URL http://[host]:[port]/alfresco/service/cmis is a legacy endpoint from Alfresco 3.4 and should not be used. It has been removed in Alfresco 5.0. The URL http://[host]:[port]/alfresco/api/-default-/public/cmis/versions/1.1/atom and the other variant with /cmisbrowser are the proper, supported endpoints.

drahas
Champ in-the-making
Champ in-the-making
Thank you again AFaust. I'm now using the http://[host]:[port]/alfresco/api/-default-/public/cmis/versions/1.1/atom url.

But when I execute this query "select d.*, o.* from cmis:document as d join cm:taggable as o on d.cmisSmiley Surprisedbjectid = o.cmisSmiley Surprisedbjectid" with DotCMIS I have this error :


<html><head><title>Apache Chemistry OpenCMIS - invalidArgument error</title><style><!–H1 {font-size:24px;line-height:normal;font-weight:bold;background-color:#f0f0f0;color:#003366;border-bottom:1px solid #3c78b5;padding:2px;} BODY {font-family:Verdana,arial,sans-serif;color:black;font-size:14px;} HR {color:#3c78b5;height:1px;}–></style></head><body><h1>HTTP Status 400 - <!–exception–>invalidArgument<!–/exception–></h1><p><!–message–>Unknown column/property cmis:objectid<!–/message–></p><hr noshade='noshade'/><!–stacktrace–><pre>
org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException: Unknown column/property cmis:objectid
   at org.alfresco.opencmis.search.CMISQueryParser.buildColumnReference(CMISQueryParser.java:1558)
   at org.alfresco.opencmis.search.CMISQueryParser.buildSource(CMISQueryParser.java:1480)
   at org.alfresco.opencmis.search.CMISQueryParser.parse(CMISQueryParser.java:138)
   at org.alfresco.repo.search.impl.solr.DbCmisQueryLanguage.executeQueryImpl(DbCmisQueryLanguage.java:116)
   at org.alfresco.repo.search.impl.solr.DbCmisQueryLanguage.executeQuery(DbCmisQueryLanguage.java:95)
   at org.alfresco.repo.search.impl.solr.DbOrIndexSwitchingQueryLanguage.executeQuery(DbOrIndexSwitchingQueryLanguage.java:122)
   at org.alfresco.repo.search.impl.solr.SolrOpenCMISQueryServiceImpl.query(SolrOpenCMISQueryServiceImpl.java:89)
   at sun.reflect.GeneratedMethodAccessor6409.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:606)
   at org.alfresco.repo.management.subsystems.SubsystemProxyFactory$1.invoke(SubsystemProxyFactory.java:72)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at com.sun.proxy.$Proxy144.query(Unknown Source)
   at org.alfresco.opencmis.CMISConnector.query(CMISConnector.java:2779)
   at org.alfresco.opencmis.AlfrescoCmisServiceImpl.query(AlfrescoCmisServiceImpl.java:2302)
   at sun.reflect.GeneratedMethodAccessor6408.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:606)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
   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:452)
   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:50)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at com.sun.proxy.$Proxy369.query(Unknown Source)
   at org.apache.chemistry.opencmis.server.support.CmisServiceWrapper.query(CmisServiceWrapper.java:1125)
   at org.apache.chemistry.opencmis.server.impl.atompub.DiscoveryService$Query.serve(DiscoveryService.java:115)
   at org.apache.chemistry.opencmis.server.shared.Dispatcher.dispatch(Dispatcher.java:88)
   at org.apache.chemistry.opencmis.server.impl.atompub.CmisAtomPubServlet.dispatch(CmisAtomPubServlet.java:225)
   at org.apache.chemistry.opencmis.server.impl.atompub.CmisAtomPubServlet.service(CmisAtomPubServlet.java:172)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
   at org.alfresco.opencmis.CMISServletDispatcher.execute(CMISServletDispatcher.java:173)
   at org.alfresco.opencmis.CMISWebScript.execute(CMISWebScript.java:51)
   at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:377)
   at org.alfresco.rest.api.PublicApiRepositoryContainer.transactionedExecute(PublicApiRepositoryContainer.java:45)
   at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:529)
   at org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:341)
   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:378)
   at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)
   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.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:501)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
   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:408)
   at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
   at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
   at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
   at java.lang.Thread.run(Thread.java:724)

</pre><!–/stacktrace–><hr noshade='noshade'/></body></html>


I have no idea how I can try to debug it outside DotCMIS.

drahas
Champ in-the-making
Champ in-the-making
Thank you again AFaust.

I'm now using the http://[host]:[port]/alfresco/api/-default-/public/cmis/versions/1.1/atom url.

But this query doesn't work : select d.*, o.* from cmis:document as d join cm:taggable as o on d.cmisSmiley Surprisedbjectid = o.cmisSmiley Surprisedbjectid (see error in attachement)

I dont know how to debug Alfresco query Smiley Sad

afaust
Legendary Innovator
Legendary Innovator
Well, the error message already includes everything you need to know: "Unknown column/property cmisSmiley Surprisedbjectid"
You simply have a typo in your query. You wrote cmisSmiley Surprisedbjectid instead of cmisSmiley SurprisedbjectId (capital i in Id) and that is not a valid column to query / join on.

drahas
Champ in-the-making
Champ in-the-making
Thank you Afaust,

I can now run this query correctly with alfresco rest service, but I have an error 500 when using DotCMIS (see attachement). Any idea ?

Now, I want to modify this query with adding an IN_FOLDER condition but I didn't find the good syntax.
I tried this : select d.*, o.* from cmis:document as d join cm:taggable as o on d.cmisSmiley SurprisedbjectId = o.cmisSmiley SurprisedbjectId where IN_FOLDER('workspace://SpacesStore/ed77ea8d-fac0-4fad-aecb-c29340afa482')
But I have an error 500 with alfresco rest (An error inside the HTTP server which prevented it from fulfilling the request).

Have you any tool which I can use to test my queries ?

afaust
Legendary Innovator
Legendary Innovator
Hello,

are there any logs for the error? The attached screenshot is not worth much unfortunately.
You can test CMIS queries via the Alfresco Node Browser tool in the Share UI (or in Alfresco 5.0.d and above in the Repository administration console UI).

Regards
Axel