【问题标题】:Web script to get the parameters of the document获取文档参数的网页脚本
【发布时间】:2021-09-27 02:08:40
【问题描述】:

创建一个web脚本来获取java中文档的参数

示例网址

localhost:8080/alfresco/s/get-document-data?nodeRef=workspace://SpacesStore/3b3597e5-b5ec-41d5-b63b-54b050dccd1b&property=cm:name

我们使用 NodeService 来实现

nodeService.getProperty (new NodeRef (nodeRef), LmrContentModel.getQname (property));

因此脚本应该返回一种 Json 对象

{
"nodeRef": "workspace: // SpacesStore / 3b3597e5-b5ec-41d5-b63b-54b050dccd1b",
"value": "value property - the one we got from nodRef"
}

创建一个网络脚本以检索所有子文件夹设置。 请帮忙!

【问题讨论】:

  • 什么不起作用?您发布的代码看起来不像一个完整的 webscript,您编写了哪些代码,您在哪里卡住了?
  • 如何获取这一行:nodeService.NodeRef(new NodeRef(nodeRef), LmrContentModel.getQname(property)); json 与文档属性并获取指定的所有子文件夹设置。

标签: java alfresco freemarker


【解决方案1】:
public class SimpleWebScript extends AbstractWebScript {
    @Override
    public void execute(WebScriptRequest req, WebScriptResponse res)  throws IOException {
        try {
            List<ChildAssociationRef> nodeRef = nodeService.getChildAssocs(companyHomeRef);
            for (ChildAssociationRef childAssoc : nodeRef) {
                NodeRef childNodeRef = childAssoc.getChildRef();
                JSONObject obj = new JSONObject();
                obj.put("nodeRef", childAssoc);
                obj.put("value", childAssoc.getQName());
                String jsonString = obj.toString();
                res.getWriter().write(jsonString);
                ServiceRegistry serviceRegistry = (ServiceRegistry) context.getBean("ServiceRegistry");
            }
        } catch (JSONException e) {
            throw new WebScriptException("Unable to serialize JSON");

        }
    }
}

<beans>
    <bean id="webscript.org.alfresco.simple.get"
          class="org.alfresco.repository.SimpleWebScript"
          parent="webscript">
    </bean>
</beans>

<webscript>
<shortname>Document</shortname>
<description></description>
<url>/demoSimple?nodeRef={nodeRef}&amp;attach={attach?}</url>
<format default="json"></format>
<authentication>user</authentication>
<family>Alfresco Document</family>
</webscript>

这里我要获取文档的参数,这里是代码但是不行,是什么问题?

【讨论】:

  • 更新您的问题并在其中包含您的代码。不是答案
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-09-29
  • 2019-05-30
  • 1970-01-01
  • 2019-05-06
  • 1970-01-01
  • 2013-05-29
相关资源
最近更新 更多