AnsweredAssumed Answered

cmis deleteTree in web script

Question asked by silenr0c on Aug 2, 2013
Latest reply on Aug 6, 2013 by silenr0c
Hi Folks,

I try to delete folder using cmis.deleteTree in webscript, following is js code, but I get error below.
Not sure because deleteTree is non existant function or there are some wrong parameter in it.
I'm not so sure UnfileObject.DELETE is valid.

p.s. I notice there are some api, but it stated as deprecated in lifecycle so I didn't bother to try it.
<blockquote>
Authentication:   none
Transaction:   none
Format Style:   any
Default Format:   text
Lifecycle:   deprecated
Id:   org/alfresco/cmis/test.post
Descriptor:   classpath:alfresco/templates/webscripts/org/alfresco/cmis/test.post.desc.xml

Delete Folder Tree (deleteTree)
DELETE /alfresco/service/cmis/i/{id}/tree?continueOnFailure={continueOnFailure?}&unfileObjects={unfileObjects}
DELETE /alfresco/service/cmis/s/{store}/i/{id}/tree?continueOnFailure={continueOnFailure?}&unfileObjects={unfileObjects}
DELETE /alfresco/service/cmis/p{path}/tree?continueOnFailure={continueOnFailure?}&unfileObjects={unfileObjects}
DELETE /alfresco/service/cmis/s/{store}/p{path}/tree?continueOnFailure={continueOnFailure?}&unfileObjects={unfileObjects}
DELETE /alfresco/service/api/node/{store_type}/{store_id}/{id}/tree?continueOnFailure={continueOnFailure?}&unfileObjects={unfileObjects}
DELETE /alfresco/service/api/path/{store_type}/{store_id}/{nodepath}/tree?continueOnFailure={continueOnFailure?}&unfileObjects={unfileObjects}

Deletes the specified folder and all of its child and descendant objects.

</blockquote>

Thanks for your help & kind attention
- silenr0c -

Additional Info:
- Alfresco Edition : Community v4.2.0 (4576) schema 6,022


// get the sample user connection
var connectionId = "cmis-sample-connection"
var cmisConnection = cmis.getConnection(connectionId)
if (cmisConnection == null) {
   // if no connection exists, talk to the local server
   cmisConnection = cmis.getConnection()
}

var cmisSession = cmisConnection.getSession()

// get arguments
var path = args["path"]

if (path != null )
{
  // get path folder
  var parentFolder = cmisSession.getObjectByPath(path)

  //delete folder
  parentFolder.deleteFolder(true, UnfileObject.DELETE, true);
}


<blockquote>The Web Script /alfresco/service/cmissamples/deletefolder 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:   07020044 Wrapped Exception (with status template): 070216449 Failed to execute script '/cmis/cmisdeletefolder.get.js (in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts)': 070216448 TypeError: Cannot find function deleteFolder. (workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts/cmis/cmisdeletefolder.get.js#27)

Exception:   org.mozilla.javascript.EcmaError - TypeError: Cannot find function deleteFolder. (workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts/cmis/cmisdeletefolder.get.js#27)

org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3350)
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3340)
org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3356)
org.mozilla.javascript.ScriptRuntime.typeError1(ScriptRuntime.java:3368)
org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3428)
org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2052)
org.mozilla.javascript.gen.c15._c0(workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts/cmis/cmisdeletefolder.get.js:27)
org.mozilla.javascript.gen.c15.call(workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts/cmis/cmisdeletefolder.get.js)
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
org.mozilla.javascript.gen.c15.call(workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts/cmis/cmisdeletefolder.get.js)
org.mozilla.javascript.gen.c15.exec(workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts/cmis/cmisdeletefolder.get.js)
org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:492)
org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:198)
org.alfresco.repo.processor.ScriptServiceImpl.execute(ScriptServiceImpl.java:212)
org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:174)
org.alfresco.repo.web.scripts.RepositoryScriptProcessor.executeScript(RepositoryScriptProcessor.java:102)
org.springframework.extensions.webscripts.AbstractWebScript.executeScript(AbstractWebScript.java:1305)
org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:86)
org.alfresco.repo.web.scripts.RepositoryContainer$3.execute(RepositoryContainer.java:433)
org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:433)
org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:495)
org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:533)
org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:349)
org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:377)
org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)
org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:118)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:61)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1813)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
java.lang.Thread.run(Thread.java:722)

Exception:   org.alfresco.error.AlfrescoRuntimeException - 070216448 TypeError: Cannot find function deleteFolder. (workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts/cmis/cmisdeletefolder.get.js#27)

org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:516)

Exception:   org.alfresco.scripts.ScriptException - 070216449 Failed to execute script '/cmis/cmisdeletefolder.get.js (in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts)': 070216448 TypeError: Cannot find function deleteFolder. (workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts/cmis/cmisdeletefolder.get.js#27)

org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:202)

Exception:   org.springframework.extensions.webscripts.WebScriptException - 07020044 Wrapped Exception (with status template): 070216449 Failed to execute script '/cmis/cmisdeletefolder.get.js (in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts)': 070216448 TypeError: Cannot find function deleteFolder. (workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts/cmis/cmisdeletefolder.get.js#27)

org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:1067)

Server:   Community v4.2.0 (4576) schema 6,022
</blockquote>

Outcomes