0

我在将自定义小部件和服务添加到基于 aikau webscript 的页面时遇到问题。在我看来,它无法正确加载模型。但我无法理解它的原因。它被正确包含(据我所见..?),它是语法正确的 javascript(我或多或少地复制和削减了一个教程),并从其他工作的 Aikau 页面调用。为什么它不起作用?:(

该项目位于 All-In-One SDK 项目中。我已按照 Aikau 小部件的 alfresco 页面上的说明进行操作: https ://docs.alfresco.com/5.2/concepts/dev-extensions-share-aikau-widgets.html

也就是说,定义一个 .js 文件,将它放在正确的文件夹中 (,并创建一个扩展模块来指向它的位置。

实际内容(该文件用于 Aikau 服务的目的)基于 Aikau github 教程中的占位符服务: https ://github.com/Alfresco/Aikau/blob/master/tutorial/chapters/Tutorial7.md

扩展模块

<module>
            <id>Company Aikau Widgets</id>
            <version>1.0.1</version>
            <auto-deploy>true</auto-deploy>
            <configurations>
                <config evaluator="string-compare" condition="WebFramework"
                    replace="false">
                    <web-framework>
                        <dojo-pages>
                            <packages>
                                <package name="example"
                                    location="js/company" />
                            </packages>
                        </dojo-pages>
                    </web-framework>
                </config>
            </configurations>
        </module>

只要不包含 ProcessService,页面 (helloworld2.get.js) 内容就可以正常工作。

model.jsonModel = {
    services: [
        "alfresco/services/ActionService",
        "company/services/ProcessService"
   ],
    widgets: [
        {
            id: "SET_PAGE_TITLE",
            name: "alfresco/header/SetTitle",
            config: {
                title: "Process\u00F6versikt"
            }
        },
        {
            name: "alfresco/buttons/AlfButton",
            config: {
                label: "HELLO BUTTON",
                iconClass: "alf-folder-up-icon",
                publishTopic: "SEARCH_BUTTON_PRESS"
            }
        }
    ]
}; 

ProcessService.js,位于 share-jar-project/src/main/resources/alfresco/web-extension/site-data/extensions/js/company/services/

define(["dojo/_base/declare",
        "alfresco/core/Core",
        "dojo/_base/lang"],
        function(declare, Core, lang) {   
        return declare([Core], {    

            constructor: function tutorial_UserAndGroupService__constructor(args) {
            lang.mixin(this, args);
            this.alfSubscribe("SEARCH_BUTTON_PRESS", lang.hitch(this, this.runWebscript));
        },

        runWebscript: function tutorial_UserAndGroupService__getGroups(payload) {
            console.log("service works.");
        },
    });
});

结果让我很困惑。首先,无论该服务是否实际包含在页面中,我都会收到一条错误消息(在登录页面加载期间):

2019-08-02 09:22:46,737  WARN  [surf.persister.AbstractStoreObjectPersister] [http-bio-8080-exec-8] Failure to load model object for path: extensions/js/company/services/ProcessService.js
org.springframework.extensions.surf.exception.ModelObjectPersisterException: Failure to load model object for path: extensions/js/company/services/ProcessService.js
        at org.springframework.extensions.surf.persister.ReadOnlyStoreObjectPersister.getObjectByPath(ReadOnlyStoreObjectPersister.java:628)
        at org.springframework.extensions.surf.persister.AbstractStoreObjectPersister.getObjectsFromPaths(AbstractStoreObjectPersister.java:374)
        at org.springframework.extensions.surf.persister.AbstractStoreObjectPersister.getAllObjects(AbstractStoreObjectPersister.java:311)
        at org.springframework.extensions.surf.persister.MultiObjectPersister.getAllObjects(MultiObjectPersister.java:399)
        at org.springframework.extensions.surf.ObjectPersistenceService.getAllObjects(ObjectPersistenceService.java:452)
        at org.springframework.extensions.surf.ModelObjectService.getAllObjects(ModelObjectService.java:616)
        at org.springframework.extensions.surf.ModuleDeploymentService.getExtensionModules(ModuleDeploymentService.java:368)
        at org.springframework.extensions.surf.ModuleDeploymentService.getAllConfiguredExtensionModules(ModuleDeploymentService.java:353)
        at org.springframework.extensions.surf.ModuleDeploymentService.getDeployedModules(ModuleDeploymentService.java:471)
        at org.springframework.extensions.surf.extensibility.impl.BasicExtensibilityModuleHandler.evaluateModules(BasicExtensibilityModuleHandler.java:191)
        at org.springframework.extensions.surf.support.AbstractRequestContext.getEvaluatedModules(AbstractRequestContext.java:1008)
        at org.springframework.extensions.surf.support.AbstractRequestContext.getExtendingModuleFiles(AbstractRequestContext.java:1221)
        at org.springframework.extensions.webscripts.WebTemplateProcessor.executeScriptBodyExtensions(WebTemplateProcessor.java:237)
        at org.springframework.extensions.webscripts.WebTemplateProcessor.executeBody(WebTemplateProcessor.java:348)
        at org.springframework.extensions.surf.render.AbstractProcessor.execute(AbstractProcessor.java:58)
        at org.springframework.extensions.surf.render.RenderService.processTemplate(RenderService.java:724)
        at org.springframework.extensions.surf.render.bean.TemplateInstanceRenderer.calculateComponentDependencies(TemplateInstanceRenderer.java:77)
        at org.springframework.extensions.surf.render.bean.TemplateInstanceRenderer.body(TemplateInstanceRenderer.java:136)
        at org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:78)
        at org.springframework.extensions.surf.render.bean.PageRenderer.body(PageRenderer.java:86)
        at org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:78)
        at org.springframework.extensions.surf.render.RenderService.renderPage(RenderService.java:770)
        at org.springframework.extensions.surf.mvc.PageView.dispatchPage(PageView.java:412)
        at org.springframework.extensions.surf.mvc.PageView.renderView(PageView.java:251)
        at org.springframework.extensions.surf.mvc.AbstractWebFrameworkView.renderMergedOutputModel(AbstractWebFrameworkView.java:321)
        at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:264)
        at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1216)
        at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1001)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:867)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:951)
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:842)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:827)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.springframework.extensions.webscripts.servlet.SecurityHeadersFilter.doFilter(SecurityHeadersFilter.java:177)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.springframework.extensions.webscripts.servlet.CSRFFilter.doFilter(CSRFFilter.java:322)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.alfresco.web.site.servlet.SSOAuthenticationFilter.doFilter(SSOAuthenticationFilter.java:474)
        at org.alfresco.web.site.servlet.SSOAuthenticationFilter.doFilter(SSOAuthenticationFilter.java:443)
        at org.springframework.extensions.webscripts.servlet.BeanProxyFilter.doFilter(BeanProxyFilter.java:80)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.alfresco.web.site.servlet.MTAuthenticationFilter.doFilter(MTAuthenticationFilter.java:81)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: org.dom4j.DocumentException: Error on line 1 of document  : Content is not allowed in prolog. Nested exception: Content is not allowed in prolog.
        at org.dom4j.io.SAXReader.read(SAXReader.java:482)
        at org.dom4j.DocumentHelper.parseText(DocumentHelper.java:278)
        at org.springframework.extensions.surf.util.XMLUtil.parse(XMLUtil.java:221)
        at org.springframework.extensions.surf.util.XMLUtil.parse(XMLUtil.java:237)
        at org.springframework.extensions.surf.persister.ReadOnlyStoreObjectPersister.getObjectByPath(ReadOnlyStoreObjectPersister.java:602)
        ... 67 more

其次,当我尝试加载实际页面时,我收到错误消息

2019-08-02 09:32:32,706  ERROR [extensions.surf.DependencyAggregator] [http-bio-8080-exec-2] Could not find compressed file: /company/services/ProcessService.js

我一定错过了什么,但是什么?

4

1 回答 1

0

看到帖子无法删除,我找到了这个错误的原因,我想应该回答我自己的问题。

这个问题有几个原因。首先,扩展模块小部件位置值错误。至少对我来说,教程错误地指定了它。他们是否想要类似的东西

<package name="example" location="js/company" />

应该是这样的

<package name="company" location="resources/maven-sdk-tutorial-share-jar/js/company"/>

请注意,我更改了包名称。这是第二个原因。当我检查活动包时,已经有一个名为 example 的包,它位于另一个位置。始终确保您也更改名称,不要像我一样懒惰地坚持使用“示例”或“教程”。

第三个原因是我将小部件文件放在了错误的位置。

ProcessService.js,位于

share-jar-project/src/main/resources/alfresco/web-extension/site-data/extensions/js/company/services/

实际上应该位于

/share-jar-project/src/main/resources/META-INF/resources/share-jar-project/js/omicron/services/

这只是我读得太快了。在文档页面中,它指定了应该在哪里部署东西 https://docs.alfresco.com/5.2/concepts/dev-extensions-share-aikau-widgets.html 我将小部件放置在扩展模块的路径中,这显然是错误的。

所以总结一下;

  1. 确保您有正确的指定位置
  2. 确保你给所有东西一个唯一的名字
  3. 确保将文件放在文档指定的位置

唷。我想这就是全部。希望下一个人能发现这很有用。

于 2019-08-05T05:43:07.863 回答