AnsweredAssumed Answered

Cannot delete relationship

Question asked by christian_wenz on Oct 9, 2013
Latest reply on Jan 3, 2014 by gcluis
Hi everybody,

I have a problem deleting peer associations in alfresco 4.1.5 via OpenCMIS (0.10.0/Java/AtomPub).
The association links a folder with several documents.



<aspects>
   <aspect name="zap:recordContent">
      <associations>
         <association name="zap:recordContainsDocument">
            <source>
               <mandatory>false</mandatory>
               <many>true</many>
            </source>
            <target>
               <class>cm:content</class>
               <mandatory>false</mandatory>
               <many>true</many>
            </target>
         </association>
      </associations>
   </aspect>
</aspects>



I'm using the following code in order to delete the association:


…  
   Document cmisDoc = (org.apache.chemistry.opencmis.client.api.Document) getCmisSession().getObject(doc.getUuid());
   OperationContext ctx = getCmisSession().createOperationContext();
   ItemIterable<Relationship> assocs = getCmisSession().getRelationships(new ObjectIdImpl(cmisDoc.getId()), true,
            RelationshipDirection.EITHER, null, ctx);

   for (Relationship relationship : assocs) {
   log.info("Deleting" + relationship.getName());
   log.info(relationship.getId());
   relationship.delete();
   }



When I execute this piece of code I get this alfresco server excpetion:


2013-10-09 09:20:02,112  ERROR [extensions.webscripts.AbstractRuntime] [http-808
0-1] Exception from executeScript - redirecting to status template error: 090900
01 16 is not an object ID
org.springframework.extensions.webscripts.WebScriptException: 09090001 16 is no
t an object ID
        at org.alfresco.repo.cmis.reference.AssociationIdRelationshipReference.g
etAssocRef(AssociationIdRelationshipReference.java:63)
        at org.alfresco.repo.cmis.rest.CMISScript.getAssociation(CMISScript.java
:378)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:155)
        at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:24
3)
        at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:66)

        at org.mozilla.javascript.gen.c6._c3(file:/C:/PPI/Sandbox/Alfresco_4.1.5
/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfre
sco/cmis/relationship.delete.js:75)
        at org.mozilla.javascript.gen.c6.call(file:/C:/PPI/Sandbox/Alfresco_4.1.
5/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfr
esco/cmis/relationship.delete.js)
        at org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java
:108)
        at org.mozilla.javascript.gen.c6._c0(file:/C:/PPI/Sandbox/Alfresco_4.1.5
/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfre
sco/cmis/relationship.delete.js:105)
        at org.mozilla.javascript.gen.c6.call(file:/C:/PPI/Sandbox/Alfresco_4.1.
5/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfr
esco/cmis/relationship.delete.js)
        at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:3
93)
        at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:283
4)
        at org.mozilla.javascript.gen.c6.call(file:/C:/PPI/Sandbox/Alfresco_4.1.
5/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfr
esco/cmis/relationship.delete.js)
        at org.mozilla.javascript.gen.c6.exec(file:/C:/PPI/Sandbox/Alfresco_4.1.
5/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfr
esco/cmis/relationship.delete.js)
        at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(Rhin
oScriptProcessor.java:492)
        at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptPro
cessor.java:198)
        at org.alfresco.repo.processor.ScriptServiceImpl.execute(ScriptServiceIm
pl.java:212)
        at org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptSer
viceImpl.java:174)
        at org.alfresco.repo.web.scripts.RepositoryScriptProcessor.executeScript
(RepositoryScriptProcessor.java:102)
        at org.springframework.extensions.webscripts.AbstractWebScript.executeSc
ript(AbstractWebScript.java:1305)
        at org.alfresco.repo.cmis.rest.CMISWebScript.executeScript(CMISWebScript
.java:46)
        at org.springframework.extensions.webscripts.DeclarativeWebScript.execut
e(DeclarativeWebScript.java:86)
        at org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(Repositor
yContainer.java:417)
        at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransacti
on(RetryingTransactionHelper.java:401)
        at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecut
e(RepositoryContainer.java:479)
        at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecut
eAs(RepositoryContainer.java:517)
        at org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(Repos
itoryContainer.java:333)
        at org.springframework.extensions.webscripts.AbstractRuntime.executeScri
pt(AbstractRuntime.java:377)
        at org.springframework.extensions.webscripts.AbstractRuntime.executeScri
pt(AbstractRuntime.java:209)
        at org.springframework.extensions.webscripts.servlet.WebScriptServlet.se
rvice(WebScriptServlet.java:132)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:206)
        at org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(Global
LocalizationFilter.java:61)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:191)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
torBase.java:470)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:293)
        at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcesso
r.java:877)
        at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.pr
ocess(Http11AprProtocol.java:594)
        at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:16
75)
        at java.lang.Thread.run(Thread.java:662)
Caused by: org.alfresco.cmis.CMISInvalidArgumentException: 16 is not an object I
D
        at org.alfresco.cmis.mapping.CMISServicesImpl.getObject(CMISServicesImpl
.java:1413)
        at org.alfresco.cmis.mapping.CMISServicesImpl.getReadableObject(CMISServ
icesImpl.java:1431)
        at org.alfresco.repo.cmis.reference.AssociationIdRelationshipReference.g
etAssocRef(AssociationIdRelationshipReference.java:59)
        … 50 more


For better understanding of the problem I used fiddler recording the network communication between my OpenCMIS client and alfresco. Three requests are involved deleting the association on the server:

<li>GET /alfresco/s/cmis/s/workspace:SpacesStore/i/92d3c77c-c890-4206-8951-0f6468860fa8/rels?includeSubRelationshipTypes=true&relationshipDirection=either&includeAllowableActions=true&maxItems=100&skipCount=0 </li>
<li>GET /alfresco/s/cmis/arg/n?noderef=assoc%3A16&filter=&includeAllowableActions=true&includePolicyIds=false&includeRelationships=none&includeACL=false&renditionFilter=cmis%3Anone </li>
<li>DELETE /alfresco/s/cmis/rel/16?allVersions=true </li>

The last one returns 400 "Bad request". What's wrong with that script?
I think that the template parameter inserts a wrong assoc id.
If I call the same web script out of a REST client using "assoc%3A16" instead of "16" the request is successful (DELETE /alfresco/s/cmis/rel/assoc%3A16?allVersions=true ).

Does anybody have the same problem? Is it a bug?

Outcomes