Deploying Custom Resources with the Resource Server

Using Maven overlay functionality, it is easy to deploy custom resources with the Resource Server. 

  1. Create a new Maven project with the resources you want to add or modify.  At Yale we wanted to include custom xsl and css required by some of our portlets, and to modify jquery-ui-1.7.2-smoothness.css to fix a bug in the accordion menu styles for IE6.  All other resources will be inherited from the Resource Server. We also wanted to override the log4j.properties, to ensure that logging from the resource server complied with our logging standards and that logs were saved in a standard location.
    src
      main
        resources
          log4j.properties
    src
      main
        webapp
          rs
            jqueryui
              1.7.2
                theme
                  smoothness
                    jquery-ui-1.7.2-smoothness.css
            yale
              <custom resources>
    
  2. Create a pom for the project using the maven war plugin overlay functionality to merge the Resource  Server 1.0.8 with your project.  Note the exclusion of the .min.css file that is being modified in the custom resource project. 
    <dependencies>
        <!-- ===== Compile Time Dependencies ============================== -->
        <dependency>
            <groupId>org.jasig.resourceserver</groupId>
            <artifactId>resource-server-content<artifactId>
            <version>1.0.8</version>
            <type>war</type>
        </dependency>
    </dependencies>
    
    <build>
        <plugins>
            <plugin>
                <groupId>net.sf.alchim</groupId>
                <artifactId>yuicompressor-maven-plugin</artifactId>
                <version>0.7.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compress</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <excludes>
                        <exclude>**/*.min.js</exclude>
                        <exclude>**/*.min.css</exclude>
                    </excludes>
                    <linebreakpos>10000</linebreakpos>
                    <suffix>.min</suffix>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1-beta-1</version>
                <configuration>
                    <nonFilteredFileExtensions>
                        <!-- default value contains jpg,jpeg,gif,bmp,png -->
                        <nonFilteredFileExtension>jar</nonFilteredFileExtension>
                        <nonFilteredFileExtension>class</nonFilteredFileExtension>
                    </nonFilteredFileExtensions>
                    <overlays>
                        <overlay>
                            <groupId>org.jasig.resourceserver</groupId>
                            <artifactId>resource-server-content</artifactId>
                            <filtered>false</filtered>
                        </overlay>
                    </overlays>
                    <dependentWarExcludes>**/jquery-ui-1.7.2-smoothness.min.css</dependentWarExcludes>
                </configuration>
            </plugin>
        </plugins>
    </build>
    
  3. Add the custom resource server to your UPortal installation. At Yale, filtering for the framework, portlets, and any other web applications deployed with the portal, including log file location for a given environment (dev, test, prod), occurs during the uPortal build process.  To include the custom resource server, do the following:
    1. Add the ResourceServingWebapp to the uportal-portlets-overlay file structure
      uportal-portlets-overlay
        ResourceServingWebapp
          pom.xml
      
      <?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"
          >
      
          <parent>
              <groupId>org.jasig.portal.portlets-overlay</groupId>
              <artifactId>uportal-portlets-overlay-parent</artifactId>
              <version>3.1.1</version>
          </parent>
      
          <modelVersion>4.0.0</modelVersion>
          <artifactId>ResourceServingWebapp</artifactId>
          <packaging>war</packaging>
      
          <name>Resource Server Webapp</name>
          <description>Overlay on Resource Server Webapp.</description>
      
          <dependencies>
              <!-- ===== Compile Time Dependencies ============================== -->
              <dependency>
                  <groupId>edu.yale.its.portal</groupId>
                  <artifactId>YaleResources</artifactId>
                  <version>${YaleResources.version}</version>
                   <classifier>unfiltered</classifier>
                  <type>war</type>
              </dependency>
          </dependencies>
      
          <build>
      
              <filters>
                  <filter>${basedir}/../../src/main/filters/filter-${environment}.properties</filter>
              </filters>
              <plugins>
                  <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-war-plugin</artifactId>
                      <version>2.1-beta-1</version>
                      <configuration>
      		    <nonFilteredFileExtensions>
      			<!-- default value contains jpg,jpeg,gif,bmp,png -->
      			<nonFilteredFileExtension>jar</nonFilteredFileExtension>
      			<nonFilteredFileExtension>class</nonFilteredFileExtension>
      		    </nonFilteredFileExtensions>
      		    <overlays>
      			<overlay>
      			    <groupId>edu.yale.its.portal</groupId>
      			    <artifactId>YaleResources</artifactId>
      			    <classifier>unfiltered</classifier>
      			    <filtered>true</filtered>
      			</overlay>
      		    </overlays>
      		</configuration>
                  </plugin>
              </plugins>
          </build>
      </project>
      
    2. Add the ResourceServingWebapp to the uportal-portlets-overlay pom.xml modules.
      <modules>
         .....
         <module>ResourceServingWebapp</module>
       </modules>