您需要创建一个新文件夹。从post请求提取参数时出错。
创建一个PostWebScript
接受路径参数和要创建的新文件夹的名称
{“path”:“sx/administration/dictionaries/general”、“newfoldername”:“testfolder”}
通过这种方式(路径),在文件夹noderef newdocumentnoderef=nodeservice.createnode(noderefparent,contentmodel.assoc_contains,qname.createqname(namespaceservice.content_model_1_0_uri,newfoldername),lmrcontentmodel.getqname(“cm:folder”).getchildref()中创建一个具有适当名称的新文件夹;
公共类webscriptpost扩展了declarativewebscript{@autowired private nodeservice nodeservice@自动连线专用存储库;
public final void setNodeService(final NodeService nodeService) {
this.nodeService = nodeService;
}
protected Map<String, Object> executeImpl(WebScriptRequest req,
Status status) {
Map<String, Object> model = new HashMap<String, Object>();
String path = (String) req.getParameter("path");
String newFolderName = (String) req.getParameter("newFolderName");
System.out.println(path);
System.out.println(newFolderName);
model.put("path", path);
model.put("newFolderName", newFolderName);
NodeRef nodeRef = repository.findNodeRef("path", path.split("/"));
NodeRef newDocumentNodeRef = nodeService.createNode(nodeRef,
ContentModel.ASSOC_CONTAINS,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, newFolderName),
LmrContentModel.getQName("cm:folder")
).getChildRef();
return model;
}
}
<webscript>
<shortname>CreateFolder</shortname>
<description>CreateFolder</description>
<url>/create?path={path?}&newFolderName={newFolderName?}</url>
<format default="json">extension</format>
<authentication runas="admin">guest</authentication>
<transaction>required</transaction>
</webscript>
{"CreateFolder" :
{
"path" : "${path}",
"newFolderName" : "${newFolderName}"
}
}
日志错误
2021-07-27 12:32:00,017 DEBUG [impl.customHistoryApp.LoginLogout] [http-nio-8080-exec-4] try to saveData in LoginLogout
2021-07-27 12:32:00,020 DEBUG [impl.customHistoryApp.LoginLogout] [http-nio-8080-exec-4] finished saveData in LoginLogout
SX/Administration/Dictionaries/General
null
2021-07-27 12:32:00,095 ERROR [extensions.webscripts.AbstractRuntime] [http-nio-8080-exec-4] Exception from executeScript: 06270024 Wrapped Exception (with status template): A QName must consist of a local name
org.springframework.extensions.webscripts.WebScriptException: 06270024 Wrapped Exception (with status template): A QName must consist of a local name
at org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:1139)
at org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:171)
at org.alfresco.repo.web.scripts.RepositoryContainer$3.execute(RepositoryContainer.java:519)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:450)
at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:587)
at org.alfresco.repo.web.scripts.RepositoryContainer$4.doWork(RepositoryContainer.java:664)
at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:623)
at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:668)
at org.alfresco.repo.web.scripts.RepositoryContainer.executeScriptInternal(RepositoryContainer.java:428)
at org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:308)
at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:399)
at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:210)
at org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:132)
at org.alfresco.repo.web.scripts.AlfrescoWebScriptServlet.service(AlfrescoWebScriptServlet.java:43)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.alfresco.module.aosmodule.service.ContextRootFilter.doFilter(ContextRootFilter.java:93)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:68)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.alfresco.web.app.servlet.ClearSecurityContextFilter.doFilter(ClearSecurityContextFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:528)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:810)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.alfresco.service.namespace.InvalidQNameException: A QName must consist of a local name
at org.alfresco.service.namespace.QName.createQName(QName.java:74)
at alfresco.extension.templates.webscripts.repository.post_web.WebScriptPost.executeImpl(WebScriptPost.java:41)
at org.springframework.extensions.webscripts.DeclarativeWebScript.executeImpl(DeclarativeWebScript.java:235)
at org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:64)
http://localhost:8080/alfresco/s/create?path=sx/administration/dictionaries/general&newfoldernam...
路径正常退出,newfoldername但没有。请帮助!
暂无答案!
目前还没有任何答案,快来回答吧!