簡體   English   中英

在Maven項目中從Alfresco刪除遠程跟蹤圖像

[英]Removing the remote tracking image from Alfresco within a Maven project

Alfresco 3.2c具有一個跟蹤圖像,該圖像使用我需要為項目刪除的Javascript注入到頁腳中。 org/alfresco/web/scripts/MessagesWebScript.java類的alfresco-share-src.zip中,JavaScript實際上是在SDK中進行硬編碼的。

我們目前正在使用Maven項目構建Alfresco,並且它從maven插件和存儲庫中提取了大部分Alfresco和Share,從而為我們提供了清晰的根目錄構建。但是,由於此類是硬編碼的,因此我們不想觸及原始的jars / zips,我以為我可以將文件的新副本添加到share/src/main/java/org/alfresco/web/scripts/MessagesWebScript.java ,將其編譯到war文件的WEB-INF中,從而覆蓋會從罐子里拿出來(是的,我知道這樣做很不好)。

但是,如果僅添加文件, /share/src/main/java/org/alfresco/web/scripts/MessagesWebScript.java:[48,80] error: cannot find symbol收到錯誤/share/src/main/java/org/alfresco/web/scripts/MessagesWebScript.java:[48,80] error: cannot find symbol在行上/share/src/main/java/org/alfresco/web/scripts/MessagesWebScript.java:[48,80] error: cannot find symbol

public class MessagesWebScript extends org.springframework.extensions.webscripts.MessagesWebScript

這使我相信它並沒有引入用於構建war文件的相同依賴項(即spring-surf-parent依賴項)。 如果我嘗試將該依賴項添加到share.pom文件中(如下所示),則maven成功構建,但是該依賴項以某種方式提取了servlet API jar文件,將其添加到了war中,然后得到了預期The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory錯誤The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory

    <dependency>
            <groupId>org.springframework.extensions.surf</groupId>
            <artifactId>spring-surf-parent</artifactId>
            <version>1.2.0-M3</version>
    </dependency>

我的share.pom如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>share</artifactId>
<name>Alfresco Share Client</name>
<packaging>war</packaging>
<description>Alfresco Share Client</description>
<parent>
    <groupId>nz.net.mycompany</groupId>
    <artifactId>custom-alfresco</artifactId>
    <version>1.0-SNAPSHOT</version>
</parent>


<dependencies>
    <dependency>
        <groupId>${alfresco.groupId}</groupId>
        <artifactId>share</artifactId>
        <type>war</type>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.1</version><!--$NO-MVN-MAN-VER$-->
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.2.5</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>com.github.searls</groupId>
        <artifactId>jasmine-maven-plugin</artifactId>
        <version>1.3.1.2</version>
    </dependency>

</dependencies>
<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
        <resource>
            <directory>jetty</directory>
            <filtering>true</filtering>
        </resource>
    </resources>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2.1</version>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <goals>
                        <goal>exec</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <executable>${basedir}/src/scripts/less2css.sh</executable>
                <arguments>
                    <argument>${basedir}</argument>
                </arguments>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <excludes>
                    <!-- Integration Tests should not be run here -->
                    <exclude>**/IT*.java</exclude>
                </excludes>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.14.1</version>
            <executions>
                <execution>
                    <goals>
<!--                             <goal>integration-test</goal> -->
<!--                             <goal>verify</goal> -->
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>com.github.searls</groupId>
            <artifactId>jasmine-maven-plugin</artifactId>
            <version>1.3.1.2</version>
            <executions>
                <execution>
                    <goals>
                        <goal>test</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <webDriverClassName>org.openqa.selenium.phantomjs.PhantomJSDriver</webDriverClassName>
                <webDriverCapabilities>
                    <phantomjs.binary.path>${project.basedir}/src/test/bin/phantomjs</phantomjs.binary.path>
                </webDriverCapabilities>
                <preloadSources>
                    <source>${project.basedir}/src/test/javascript/fixtures/fixture_messages.js</source>
                </preloadSources>
                <jsSrcDir>${project.basedir}/target/share/js/</jsSrcDir>
                <jsTestSrcDir>${project.basedir}/src/test/javascript/</jsTestSrcDir>
                <sourceIncludes>
                    <!-- add the ones we want first -->
                    <include>**/yui-common.js</include>
                    <include>**/alfresco.js</include>
                    <!-- Then the default -->
                    <include>**/*.js</include>
                </sourceIncludes>
                <haltOnFailure>false</haltOnFailure>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <!-- Here is can control the order of overlay of your (WAR, AMP, etc.) dependencies
                | NOTE: At least one WAR dependency must be uncompressed first
                | NOTE: In order to have a dependency effectively added to the WAR you need to
                | explicitly mention it in the overlay section.
                | NOTE: First-win resource strategy is used by the WAR plugin
                -->
                <overlays>
                    <!-- The current project customizations -->
                    <overlay />
                    <!-- The Share WAR -->
                    <overlay>
                        <groupId>${alfresco.groupId}</groupId>
                        <artifactId>share</artifactId>
                        <type>war</type>
                        <!-- To allow inclusion of META-INF -->
                        <excludes />
                    </overlay>
                </overlays>
            </configuration>
        </plugin>
    </plugins>
</build>
</project>

如果我理解正確,您想重寫一個Java類,在這種情況下,該類恰巧實現了Web腳本,但是將共享WAR與此類的派生副本重新打包的解決方案不起作用。

重新定義核心Alfresco(在這種情況下為Share)是一個壞主意。 該Web腳本在web應用類路徑的Spring配置文件alfresco/slingshot-application-context.xml中聲明,因此,您應該做的是在alfresco/web-extension下的您自己的*-context.xml文件中覆蓋它,例如

<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
       http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
   <!--  I18N resources and messages Web Script -->
   <bean id="webscript.org.springframework.extensions.messages.get" 
         parent="webscript" 
         class="my.custom.namespace.MessagesWebScript">
      <property name="webFrameworkConfigElement" ref="webframework.config.element"/>
      <property name="dependencyHandler" ref="dependency.handler"/>
   </bean>
</beans>

沒有理由不應該從一開始就通過Spring實現覆蓋。 Spring Bean是為此目的而設計的,它幾乎不增加工作量,同時使您能夠更有效地調試(如果它沒有按預期工作)。

顯然,您還需要確保將自定義類my.custom.namespace.MessagesWebScript編譯為構建的一部分,並且聽起來好像目前還沒有這樣做。 這可能是因為您在POM中缺少一些JAR(而非WAR)依賴關系-請查看我們使用的Google Docs集成共享POM

最后,我建議您將自定義文件打包為AMP文件 Alfresco Maven SDK為此提供了全面支持,您只需要將其聲明為父級-有關示例,請參閱Google Docs父級POM

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM