cancel
Showing results for 
Search instead for 
Did you mean: 

OpenCmis Extension, trying to query custom Aspects

jba
Champ in-the-making
Champ in-the-making
Dear all,
It's been quite a few weeks now I am breaking my teeth against that, so I thought I would ask the community.
I have a custom made model looking roughly like this :
<type name="re:doc">
         <title>Document racine</title>
         <parent>cm:content</parent>
      </type>
      <aspect name="re:webable">
         <title>RAE Webable</title>
         <properties>
            <property name="re:published">
               <type>d:boolean</type>
            </property>
            <property name="re:isActive">
               <type>d:boolean</type>
               <default>false</default>
            </property>
         </properties>
      </aspect>
etc..
I understood that in order to query those custom made aspects , I had to include OpenCMIS Extension in my classpath. I suppose I did it well because when I go here :
http://localhost:8080/alfresco/cmisbrowse?url=http://localhost:8080/alfresco/service/cmis/type/cmisSmiley Tongueo...
i can see all my custom aspects alright
[img]http://i740.photobucket.com/albums/xx44/tsushimaii/cmis.jpg[/img]
Now I try to query those aspects using curl so of course something like this works
SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE '%ville%'
but something like this doesn't
SELECT cmis:name FROM cmis:document WHERE re:isActive = true
error code :
HTTP call to [http://localhost:8080/alfresco/service/cmis/queries] returned [500]. Response: Web Script Status 500 - Internal Error Web Script Status 500 - Internal Error The Web Script /alfresco/service/cmis/queries has responded with a status of 500 - Internal Error. 500 Description: An error inside the HTTP server which prevented it from fulfilling the request.   Message:05280002 Wrapped Exception (with status template): 05280003 Failed to execute script 'classpath*:alfresco/templates/webscripts/org/alfresco/cmis/queries.post.cmisquery.js': 05280002 Invalid column for cmis:document.re:isActive   Exception:org.alfresco.cmis.CMISQueryException - 05280002 Invalid column for cmis:document.re:isActive   org.alfresco.cmis.search.CMISQueryParser.buildColumnReference(CMISQueryParser.java:1538) org.alfresco.cmis.search.CMISQueryParser.getFunctionArgument(CMISQueryParser.java:1130) org.alfresco.cmis.search.CMISQueryParser.buildPredicate(CMISQueryParser.java:358) org.alfresco.cmis.search.CMISQueryParser.buildTest(CMISQueryParser.java:283) org.alfresco.cmis.search.CMISQueryParser.buildNegation(CMISQueryParser.java:263) org.alfresco.cmis.search.CMISQueryParser.buildConjunction(CMISQueryParser.java:232) org.alfresco.cmis.search.CMISQueryParser.buildDisjunction(CMISQueryParser.java:205) org.alfresco.cmis.search.CMISQueryParser.parse(CMISQueryParser.java:160) org.alfresco.cmis.search.CMISQueryServiceImpl.query(CMISQueryServiceImpl.java:126) org.alfresco.repo.cmis.rest.CMISScript.query(CMISScript.java:652) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:597) org.mozilla.javascript.MemberBox.invoke(MemberBox.java:155) org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:243) org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76) org.mozilla.javascript.gen.c3._c0(file:/H:/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/cmis/queries.post.cmisquery.js:67) org.mozilla.javascript.gen.c3.call(file:/H:/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/cmis/queries.post.cmisquery.js) org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393) org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834) org.mozilla.javascript.gen.c3.call(file:/H:/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/cmis/queries.post.cmisquery.js) org.mozilla.javascript.gen.c3.exec(file:/H:/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/cmis/queries.post.cmisquery.js) org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:472) org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:190) org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:282) org.alfresco.repo.web.scripts.RepositoryScriptProcessor.executeScript(RepositoryScriptProcessor.java:102) org.springframework.extensions.webscripts.AbstractWebScript.executeScript(AbstractWebScript.java:981) org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:86) org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:377) org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:381) org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:436) org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:466) org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:304) org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:333) org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:189) org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:118) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:58) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861) org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579) org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1584) java.lang.Thread.run(Thread.java:662)   Exception:org.alfresco.scripts.ScriptException - 05280003 Failed to execute script 'classpath*:alfresco/templates/webscripts/org/alfresco/cmis/queries.post.cmisquery.js': 05280002 Invalid column for cmis:document.re:isActive   org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:194)   Exception:org.springframework.extensions.webscripts.WebScriptException - 05280002 Wrapped Exception (with status template): 05280003 Failed to execute script 'classpath*:alfresco/templates/webscripts/org/alfresco/cmis/queries.post.cmisquery.js': 05280002 Invalid column for cmis:document.re:isActive   org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:758)   Server:Community v3.4.0 (e 3419) schema 4 113 Time:28 juin 2011 13:53:55   Diagnostics:Inspect Web Script (org/alfresco/cmis/queries.post) 

Really, i wonder where I have it completely wrong, so any help appreciated
thanks for viewing
JBA
9 REPLIES 9

jpotts
World-Class Innovator
World-Class Innovator
Have you looked at this wiki page? It describes how to query for aspects. You have to do a join.

Jeff

jba
Champ in-the-making
Champ in-the-making
Thanks Jeff, I indeed overlooked those two lines - indeed doing something like this works without any error message

select d.*, o.* from cmis:document as d join re:webable as o on d.cmis:objectid = o.cmis:objectid

But how could I query a *property* of such an aspect be it a boolean like a re:isActive or -worse- a Category like in my sample below, this I couldn't find.

<aspect name="re:stport">
         <title>Structure porteuse</title>  
         <parent>cm:generalclassifiable</parent>
         <properties>
            <property name="re:stpor">
               <title>Structure porteuse</title>
               <type>d:category</type>
               <mandatory>false</mandatory>
            <multiple>false</multiple>
               <index enabled="true">
                      <atomic>true</atomic>
                      <stored>true</stored>
                      <tokenised>true</tokenised>
               </index>
            </property>
         </properties>
      </aspect>
really, any extra help appreciated !

jpotts
World-Class Innovator
World-Class Innovator
Here's an example using the sc:statusIndicator property of sc:statusable:

select d.*, o.* from cmis:document as d join sc:statusable as o on d.cmis:objectid = o.cmis:objectid where o.sc:statusIndicator = 'Green'

And here's an example using the sc:isActive property of sc:webable:

select d.*, o.* from cmis:document as d join sc:webable as o on d.cmis:objectid = o.cmis:objectid where o.sc:isActive = True

Category is more complicated. I think that may require a join if it is even possible at all.

If you haven't found it already, you might look into using the Apache Chemistry Workbench. It's a handy little Java Swing app that you can use to quickly test queries, run groovy scripts, or simply browse your CMIS repository.

Jeff

jba
Champ in-the-making
Champ in-the-making
Thanks SO much for helping Jeff Smiley Happy Smiley Happy
I will try using the Apache Chemistry Workbench as you suggest. If I ever find about Categories queries I will post it here
Thanks again
JB

jba
Champ in-the-making
Champ in-the-making
Sorry to unearth that old thread -I am still trying to query custom aspects and Joins work really well but I have an extra problem -how can I have (or make up like it actually exists) a query that works on *two* or *several* aspects ?

Actually while trying the code below -a double joint- I got that in the error message "Advanced join is not supported  "

SELECT d.*, o.*,p.* FROM cmis:document AS d JOIN re:webable AS o ON d.cmis:objectid = o.cmis:objectid JOIN re:status AS p ON d.cmis:objectid = o.cmis:objectid WHERE o.re:isActive = True AND p.re:status='test'

So the questions would be
-can I actually query several aspects / aspects properties ?
- if yes, what's wrong in my code?
Thanks for looking
JB

PS error message
HTTP call to [http://localhost:8080/alfresco/service/cmis/queries] returned [500]. Response: Web Script Status 500 - Internal Error Web Script Status 500 - Internal Error The Web Script /alfresco/service/cmis/queries has responded with a status of 500 - Internal Error. 500 Description: An error inside the HTTP server which prevented it from fulfilling the request.   Message:09280016 Wrapped Exception (with status template): 09280033 Failed to execute script 'classpath*:alfresco/templates/webscripts/org/alfresco/cmis/queries.post.cmisquery.js': Advanced join is not supported   Exception:java.lang.UnsupportedOperationException - Advanced join is not supported   org.alfresco.repo.search.impl.querymodel.impl.lucene.LuceneQueryEngine.executeQuery(LuceneQueryEngine.java:132) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:597) org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307) org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:80) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) $Proxy113.executeQuery(Unknown Source) org.alfresco.cmis.search.CMISQueryServiceImpl.query(CMISQueryServiceImpl.java:128) org.alfresco.repo.cmis.rest.CMISScript.query(CMISScript.java:652) sun.reflect.GeneratedMethodAccessor649.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:597) org.mozilla.javascript.MemberBox.invoke(MemberBox.java:155) org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:243) org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76) org.mozilla.javascript.gen.c2._c0(file:/H:/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/cmis/queries.post.cmisquery.js:67) org.mozilla.javascript.gen.c2.call(file:/H:/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/cmis/queries.post.cmisquery.js) org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393) org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834) org.mozilla.javascript.gen.c2.call(file:/H:/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/cmis/queries.post.cmisquery.js) org.mozilla.javascript.gen.c2.exec(file:/H:/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/cmis/queries.post.cmisquery.js) org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:472) org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:190) org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:282) org.alfresco.repo.web.scripts.RepositoryScriptProcessor.executeScript(RepositoryScriptProcessor.java:102) org.springframework.extensions.webscripts.AbstractWebScript.executeScript(AbstractWebScript.java:981) org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:86) org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:377) org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:381) org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:436) org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:466) org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:304) org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:333) org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:189) org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:118) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:58) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861) org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579) org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1584) java.lang.Thread.run(Thread.java:662)   Exception:org.alfresco.scripts.ScriptException - 09280033 Failed to execute script 'classpath*:alfresco/templates/webscripts/org/alfresco/cmis/queries.post.cmisquery.js': Advanced join is not supported   org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:194)   Exception:org.springframework.extensions.webscripts.WebScriptException - 09280016 Wrapped Exception (with status template): 09280033 Failed to execute script 'classpath*:alfresco/templates/webscripts/org/alfresco/cmis/queries.post.cmisquery.js': Advanced join is not supported   org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:758)   Server:Community v3.4.0 (e 3419) schema 4 113 Time:28 oct. 2011 16:31:10   Diagnostics:Inspect Web Script (org/alfresco/cmis/queries.post) 

sindhu
Champ in-the-making
Champ in-the-making
I have created custom object types in alfresco and I could use it directly through UI too. But,I am not getting any records or even errors while querying through the custom object types.Please let me know what could be wrong..

kaynezhang
World-Class Innovator
World-Class Innovator
How did you query through your custom object types? in what search language? what is your  search string?

loulinyuan
Champ in-the-making
Champ in-the-making
With a query similar to "select d.*, o.* from cmis:document as d join sc:statusable as o on d.cmisSmiley Surprisedbjectid = o.cmisSmiley Surprisedbjectid where o.sc:statusIndicator = 'Green'", I could get a list of CmisObject (myObj) back, from which I could use myObj.getName() and myObj.getId() to retrieve the document name and object id. However, myObj.getPolicies() returns null, even though I could see the values of the properties in Alfresco Share. Can you please advise how to retrieve properties values for an aspect that has been applied to a document using OpenCMIS?

jpotts
World-Class Innovator
World-Class Innovator
Using OpenCMIS and the <a href="http://code.google.com/a/apache-extras.org/p/alfresco-opencmis-extension/">Alfresco Extension for OpenCMIS</a> you can do this:


      if (!doc.hasAspect("P:cm:geographic")) {
         doc.addAspect("P:cm:geographic");
         System.out.println("Added aspect");
      } else {
         System.out.println("Doc already had aspect");
      }
      
      HashMap<String, Object> props = new HashMap<String, Object>();
      props.put("cm:latitude", 52.513871);
      props.put("cm:longitude", 13.391106);      
      doc.updateProperties(props);
      
      System.out.println("Latitude: " + doc.getProperty("cm:latitude").getValueAsString());
      System.out.println("Longitude: " + doc.getProperty("cm:longitude").getValueAsString());


Retrieving property values defined in an aspect is no different than retrieving values defined in a type when you are using the OpenCMIS extension.

Jeff