You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by rl...@apache.org on 2013/07/25 18:50:00 UTC

svn commit: r1507062 [1/4] - in /oodt/trunk/webapp/fmprod: ./ src/main/java/org/apache/oodt/cas/product/data/ src/main/java/org/apache/oodt/cas/product/service/configurations/ src/main/java/org/apache/oodt/cas/product/service/exceptions/ src/main/java/...

Author: rlaidlaw
Date: Thu Jul 25 16:49:58 2013
New Revision: 1507062

URL: http://svn.apache.org/r1507062
Log:
OODT-611: Implemented a JAX-RS interface to access File Manager products as raw data.

Added:
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/configurations/
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/exceptions/
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/exceptions/BadRequestException.java   (with props)
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/exceptions/InternalServerErrorException.java   (with props)
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/exceptions/NotFoundException.java   (with props)
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/DatasetResource.java   (with props)
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/ProductResource.java   (with props)
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/ReferenceResource.java   (with props)
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/TransferResource.java   (with props)
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/FileResponder.java   (with props)
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/NullResponder.java   (with props)
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/Responder.java   (with props)
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/ResponderFactory.java   (with props)
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/UnrecognizedFormatResponder.java   (with props)
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/ZipResponder.java   (with props)
    oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/
    oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/resources/
    oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/resources/DatasetResourceTest.java   (with props)
    oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/resources/ProductResourceTest.java   (with props)
    oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/resources/ReferenceResourceTest.java   (with props)
    oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/resources/ResourceTestBase.java   (with props)
    oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/
    oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/FileResponderTest.java   (with props)
    oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/NullResponderTest.java   (with props)
    oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/ResponderFactoryTest.java   (with props)
    oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/UnrecognizedFormatResponderTest.java   (with props)
    oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/ZipResponderTest.java   (with props)
    oodt/trunk/webapp/fmprod/src/test/resources/filemgr/
    oodt/trunk/webapp/fmprod/src/test/resources/filemgr/etc/
    oodt/trunk/webapp/fmprod/src/test/resources/filemgr/etc/filemgr.properties   (with props)
    oodt/trunk/webapp/fmprod/src/test/resources/filemgr/etc/logging.properties   (with props)
    oodt/trunk/webapp/fmprod/src/test/resources/filemgr/etc/mime-types.xml   (with props)
    oodt/trunk/webapp/fmprod/src/test/resources/filemgr/ingest/
    oodt/trunk/webapp/fmprod/src/test/resources/filemgr/ingest/flat/
    oodt/trunk/webapp/fmprod/src/test/resources/filemgr/ingest/flat/location.txt   (with props)
    oodt/trunk/webapp/fmprod/src/test/resources/filemgr/ingest/flat/location.txt.met
    oodt/trunk/webapp/fmprod/src/test/resources/filemgr/ingest/flat/test
    oodt/trunk/webapp/fmprod/src/test/resources/filemgr/ingest/flat/test.txt   (with props)
    oodt/trunk/webapp/fmprod/src/test/resources/filemgr/ingest/flat/test.txt.met
    oodt/trunk/webapp/fmprod/src/test/resources/filemgr/ingest/hierarchical/
    oodt/trunk/webapp/fmprod/src/test/resources/filemgr/ingest/hierarchical/test/
    oodt/trunk/webapp/fmprod/src/test/resources/filemgr/ingest/hierarchical/test.met
    oodt/trunk/webapp/fmprod/src/test/resources/filemgr/ingest/hierarchical/test/file.txt   (with props)
    oodt/trunk/webapp/fmprod/src/test/resources/filemgr/ingest/hierarchical/test/subdirectory/
    oodt/trunk/webapp/fmprod/src/test/resources/filemgr/ingest/hierarchical/test/subdirectory/sub-file.txt   (with props)
    oodt/trunk/webapp/fmprod/src/test/resources/filemgr/logs/
    oodt/trunk/webapp/fmprod/src/test/resources/filemgr/policy/
    oodt/trunk/webapp/fmprod/src/test/resources/filemgr/policy/core/
    oodt/trunk/webapp/fmprod/src/test/resources/filemgr/policy/core/elements.xml   (with props)
    oodt/trunk/webapp/fmprod/src/test/resources/filemgr/policy/core/product-type-element-map.xml   (with props)
    oodt/trunk/webapp/fmprod/src/test/resources/filemgr/policy/core/product-types.xml   (with props)
    oodt/trunk/webapp/fmprod/src/test/resources/filemgr/repository/
    oodt/trunk/webapp/fmprod/src/test/resources/filemgr/workingDir/
Modified:
    oodt/trunk/webapp/fmprod/pom.xml
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataUtils.java
    oodt/trunk/webapp/fmprod/src/main/webapp/WEB-INF/web.xml
    oodt/trunk/webapp/fmprod/src/test/resources/test.logging.properties

Modified: oodt/trunk/webapp/fmprod/pom.xml
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/pom.xml?rev=1507062&r1=1507061&r2=1507062&view=diff
==============================================================================
--- oodt/trunk/webapp/fmprod/pom.xml (original)
+++ oodt/trunk/webapp/fmprod/pom.xml Thu Jul 25 16:49:58 2013
@@ -1,21 +1,24 @@
 <?xml version='1.0' encoding='UTF-8'?>
 <!--
-Licensed to the Apache Software Foundation (ASF) under one or more contributor
-license agreements.  See the NOTICE.txt file distributed with this work for
-additional information regarding copyright ownership.  The ASF licenses this
-file to you under the Apache License, Version 2.0 (the "License"); you may not
-use this file except in compliance with the License.  You may obtain a copy of
-the License at
+  Licensed to the Apache Software Foundation (ASF) under one or more contributor
+  license agreements.  See the NOTICE.txt file distributed with this work for
+  additional information regarding copyright ownership.  The ASF licenses this
+  file to you under the Apache License, Version 2.0 (the "License"); you may not
+  use this file except in compliance with the License.  You may obtain a copy of
+  the License at
 
-     http://www.apache.org/licenses/LICENSE-2.0
+      http://www.apache.org/licenses/LICENSE-2.0
 
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
-License for the specific language governing permissions and limitations under
-the License.
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+  License for the specific language governing permissions and limitations under
+  the License.
 -->
-<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">
+<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>
   <parent>
     <groupId>org.apache.oodt</groupId>
@@ -26,10 +29,13 @@ the License.
   <artifactId>cas-product</artifactId>
   <packaging>war</packaging>
   <name>CAS Product Server</name>
-  <description>This project builds on top of the CAS file management component and exposes its
-     underlying data delivery capabilities using the OODT ProductServer component. All-in-all,
-     this project contributes an OODT LargeProductHandler component, that can be used to deliver
-     and format a CAS product structure into an OODT XML Query Result Set.</description>
+  <description>
+    This project builds on top of the CAS file management component and exposes
+    its underlying data delivery capabilities using the OODT ProductServer
+    component. All-in-all, this project contributes an OODT LargeProductHandler
+    component, that can be used to deliver and format a CAS product structure
+    into an OODT XML Query Result Set.
+  </description>
   <build>
     <testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
     <plugins>
@@ -46,14 +52,17 @@ the License.
                 <include>CHANGES.txt</include>
               </includes>
               <targetPath>META-INF/</targetPath>
-            </resource>          
+            </resource>
           </webResources>
           <warSourceDirectory>src/main/webapp</warSourceDirectory>
-          <containerConfigXML>src/main/resources/cas-product-tomcat-5.5.9.xml</containerConfigXML>
+          <containerConfigXML>
+            src/main/resources/cas-product-tomcat-5.5.9.xml
+          </containerConfigXML>
         </configuration>
       </plugin>
       <plugin>
-        <!-- NOTE: We don't need a groupId specification because the group is
+        <!--
+          NOTE: We don't need a groupId specification because the group is
           org.apache.maven.plugins ...which is assumed by default.
         -->
         <artifactId>maven-assembly-plugin</artifactId>
@@ -67,39 +76,26 @@ the License.
       </plugin>
       <plugin>
         <artifactId>maven-surefire-plugin</artifactId>
-        <version>2.4.3</version>
         <configuration>
-          <forkMode>pertest</forkMode>
-          <useSystemClassLoader>false</useSystemClassLoader>
           <systemProperties>
-             <property>
-               <name>java.util.logging.config.file</name>
-               <value>${basedir}/src/test/resources/test.logging.properties</value>
-              </property>
-           </systemProperties>
-           <forkedProcessTimeoutInSeconds>0</forkedProcessTimeoutInSeconds>
-           <redirectTestOutputToFile>true</redirectTestOutputToFile>
-            <includes>
-              <include>**/*Test*.java</include>
-            </includes>
+            <property>
+              <name>java.util.logging.config.file</name>
+              <value>
+                ${basedir}/src/test/resources/test.logging.properties
+              </value>
+            </property>
+          </systemProperties>
+          <excludes>
+            <exclude>
+             org/apache/oodt/cas/product/service/resources/ResourceTestBase.java
+            </exclude>
+          </excludes>
         </configuration>
       </plugin>
     </plugins>
   </build>
   <dependencies>
     <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>3.8.2</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>xmlunit</groupId>
-      <artifactId>xmlunit</artifactId>
-      <version>1.2</version>
-      <scope>test</scope>
-    </dependency>    
-    <dependency>
       <groupId>org.apache.oodt</groupId>
       <artifactId>cas-filemgr</artifactId>
       <version>${project.parent.version}</version>
@@ -129,15 +125,47 @@ the License.
       <scope>compile</scope>
     </dependency>
     <dependency>
+      <groupId>org.apache.tika</groupId>
+      <artifactId>tika-core</artifactId>
+      <version>0.8</version>
+    </dependency>
+    <dependency>
       <groupId>javax.servlet</groupId>
       <artifactId>servlet-api</artifactId>
       <version>2.4</version>
       <scope>provided</scope>
     </dependency>
     <dependency>
+      <!--
+        Zip4j is released under the Apache License, Version 2.0
+        For reference, see: http://www.lingala.net/zip4j/about.php
+      -->
+      <groupId>net.lingala.zip4j</groupId>
+      <artifactId>zip4j</artifactId>
+      <version>1.3.1</version>
+    </dependency>
+    <dependency>
       <groupId>org.apache.cxf</groupId>
       <artifactId>cxf-rt-frontend-jaxrs</artifactId>
       <version>2.6.8</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.cxf</groupId>
+      <artifactId>cxf-rt-transports-local</artifactId>
+      <version>2.6.8</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.easymock</groupId>
+      <artifactId>easymock</artifactId>
+      <version>3.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.11</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 </project>

Modified: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataUtils.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataUtils.java?rev=1507062&r1=1507061&r2=1507062&view=diff
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataUtils.java (original)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataUtils.java Thu Jul 25 16:49:58 2013
@@ -18,14 +18,6 @@
 
 package org.apache.oodt.cas.product.data;
 
-//OODT imports
-import org.apache.oodt.cas.filemgr.structs.Product;
-import org.apache.oodt.cas.filemgr.structs.ProductType;
-import org.apache.oodt.cas.filemgr.structs.Reference;
-import org.apache.oodt.cas.metadata.Metadata;
-import org.apache.oodt.cas.metadata.SerializableMetadata;
-import org.apache.oodt.commons.xml.XMLUtils;
-
 //JDK imports
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -43,6 +35,13 @@ import java.util.logging.Logger;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
 
+//OODT imports
+import org.apache.oodt.cas.filemgr.structs.Product;
+import org.apache.oodt.cas.filemgr.structs.ProductType;
+import org.apache.oodt.cas.filemgr.structs.Reference;
+import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.cas.metadata.SerializableMetadata;
+
 /**
  * 
  * Utility methods for delivering data using the filemgr servlet data API.
@@ -85,16 +84,16 @@ public final class DataUtils implements 
     // output stream: else that will cause the generated datset zip to be
     // included as well!
     File[] productZipFiles = new File(workingDirPath).listFiles(ZIP_FILTER);
+    if (productZipFiles == null || productZipFiles.length == 0)
+    {
+      throw new Exception("No product zip files to include in dataset: ["
+          + type.getName() + "]");
+    }
 
     // now get a reference to the zip file that we want to write
     ZipOutputStream out = new ZipOutputStream(new FileOutputStream(
         datasetZipFilePath));
 
-    if (productZipFiles == null || productZipFiles.length == 0) {
-      throw new Exception("No product zip files to include in dataset: ["
-          + type.getName() + "]");
-    }
-
     for (int i = 0; i < productZipFiles.length; i++) {
       String filename = productZipFiles[i].getName();
       FileInputStream in = new FileInputStream(productZipFiles[i]

Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/exceptions/BadRequestException.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/exceptions/BadRequestException.java?rev=1507062&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/exceptions/BadRequestException.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/exceptions/BadRequestException.java Thu Jul 25 16:49:58 2013
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.oodt.cas.product.service.exceptions;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+/**
+ * This type of exception returns an HTTP 'bad request' response (status code
+ * 400) with an additional message.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+public class BadRequestException extends WebApplicationException
+{
+  // Auto-generated ID for serialization.
+  private static final long serialVersionUID = -705065311316100022L;
+
+  /**
+   * Constructor that adds a message to the 'bad request' (status code 400)
+   * HTTP response.
+   * @param message the message to add to the response
+   */
+  public BadRequestException(String message)
+  {
+    super(Response.status(Response.Status.BAD_REQUEST).entity(message)
+      .type(MediaType.TEXT_PLAIN).build());
+  }
+}

Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/exceptions/BadRequestException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/exceptions/InternalServerErrorException.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/exceptions/InternalServerErrorException.java?rev=1507062&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/exceptions/InternalServerErrorException.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/exceptions/InternalServerErrorException.java Thu Jul 25 16:49:58 2013
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.oodt.cas.product.service.exceptions;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+/**
+ * This type of exception returns an HTTP 'internal server error' response
+ * (status code 500) with an additional message.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+public class InternalServerErrorException extends WebApplicationException
+{
+  // Auto-generated ID for serialization.
+  private static final long serialVersionUID = -6132240509391531373L;
+
+  /**
+   * Constructor that adds a message to the 'internal server error' (status code
+   * 500) HTTP response.
+   * @param message the message to add to the response
+   */
+  public InternalServerErrorException(String message)
+  {
+    super(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message)
+      .type(MediaType.TEXT_PLAIN).build());
+  }
+}

Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/exceptions/InternalServerErrorException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/exceptions/NotFoundException.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/exceptions/NotFoundException.java?rev=1507062&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/exceptions/NotFoundException.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/exceptions/NotFoundException.java Thu Jul 25 16:49:58 2013
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.oodt.cas.product.service.exceptions;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+/**
+ * This type of exception returns an HTTP 'not found' response (status code 404)
+ * with an additional message.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+public class NotFoundException extends WebApplicationException
+{
+  // Auto-generated ID for serialization.
+  private static final long serialVersionUID = -3835077083758525919L;
+
+  /**
+   * Constructor that adds a message to the 'not found' (status code 404)
+   * HTTP response.
+   * @param message the message to add to the response
+   */
+  public NotFoundException(String message)
+  {
+    super(Response.status(Response.Status.NOT_FOUND).entity(message)
+      .type(MediaType.TEXT_PLAIN).build());
+  }
+}

Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/exceptions/NotFoundException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/DatasetResource.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/DatasetResource.java?rev=1507062&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/DatasetResource.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/DatasetResource.java Thu Jul 25 16:49:58 2013
@@ -0,0 +1,186 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.oodt.cas.product.service.resources;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+
+import org.apache.oodt.cas.filemgr.structs.Product;
+import org.apache.oodt.cas.filemgr.structs.ProductType;
+import org.apache.oodt.cas.filemgr.system.XmlRpcFileManagerClient;
+import org.apache.oodt.cas.product.service.exceptions.BadRequestException;
+import org.apache.oodt.cas.product.service.exceptions.NotFoundException;
+import org.apache.oodt.cas.product.service.responders.Responder;
+import org.apache.oodt.cas.product.service.responders.ResponderFactory;
+
+/**
+ * A JAX-RS resource representing a dataset - a set of {@link Product} objects
+ * maintained by the file manager.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+@Path("/dataset")
+public class DatasetResource
+{
+  // The product type associated with the resource.
+  private ProductType productType;
+
+  // The list of product resources associated with the resource.
+  private List<ProductResource> productResources =
+    new ArrayList<ProductResource>();
+
+  // The path to the working directory used to store temporary files for
+  // responses.
+  private String workingDirPath;
+
+  @Context
+  private ServletContext context;
+
+
+
+  /**
+   * Gets an HTTP response for a set of {@link Product} objects from the file
+   * manager.
+   * @param typeID the ID of the {@link ProductType} for the data set
+   * @param format the requested MIME type for the {@link Response}
+   * @return HTTP response containing a set of products
+   */
+  @GET
+  public Response getResponse(@QueryParam("typeID") String typeID,
+    @QueryParam("format") String format)
+  {
+    if (typeID == null)
+    {
+      throw new BadRequestException("The typeID parameter is required.");
+    }
+
+    try
+    {
+      XmlRpcFileManagerClient client = new XmlRpcFileManagerClient(new URL(
+        context.getInitParameter("filemgr.url")));
+      productType = client.getProductTypeById(typeID);
+
+      // Set a working directory to store product files.
+      setWorkingDirPath(context.getInitParameter("filemgr.working.dir"));
+      String productDirPath = getWorkingDirPath();
+      productDirPath += productDirPath.endsWith("/") ? "" : "/";
+      productDirPath += productType.getName();
+
+      // Add all products of the chosen type to the dataset.
+      for (Product product : client.getProductsByProductType(productType))
+      {
+        product.setProductReferences(client.getProductReferences(product));
+        productResources.add(new ProductResource(product,
+          client.getMetadata(product), productDirPath));
+      }
+
+      Responder responder = ResponderFactory.createResponder(format);
+      return responder.createResponse(this);
+    }
+    catch (Exception e)
+    {
+      throw new NotFoundException("The requested resource could not be found. "
+        + e.getMessage());
+    }
+  }
+
+
+
+  /**
+   * Gets the dataset's product type.
+   * @return the product type
+   */
+  public ProductType getProductType()
+  {
+    return productType;
+  }
+
+
+
+  /**
+   * Gets the dataset's list of product resources.
+   * @return the product resources
+   */
+  public List<ProductResource> getProductResources()
+  {
+    return productResources;
+  }
+
+
+
+  /**
+   * Gets the working directory path.
+   * @return the workingDirPath
+   */
+  public String getWorkingDirPath()
+  {
+    return workingDirPath;
+  }
+
+
+
+  /**
+   * Sets the productType.
+   * @param productType the productType to set
+   */
+  public void setProductType(ProductType productType)
+  {
+    this.productType = productType;
+  }
+
+
+
+  /**
+   * Sets the productResources.
+   * @param productResources the productResources to set
+   */
+  public void setProductResources(List<ProductResource> productResources)
+  {
+    this.productResources = productResources;
+  }
+
+
+
+  /**
+   * Sets the working directory path.
+   * @param workingDirPath the workingDirPath to set
+   */
+  public void setWorkingDirPath(String workingDirPath)
+  {
+    this.workingDirPath = workingDirPath;
+  }
+
+
+
+  /**
+   * Sets the servlet context.
+   * @param context the servlet context to set
+   */
+  public void setServletContext(ServletContext context)
+  {
+    this.context = context;
+  }
+}

Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/DatasetResource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/ProductResource.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/ProductResource.java?rev=1507062&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/ProductResource.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/ProductResource.java Thu Jul 25 16:49:58 2013
@@ -0,0 +1,217 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.oodt.cas.product.service.resources;
+
+import java.net.URL;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+
+import org.apache.oodt.cas.filemgr.structs.Product;
+import org.apache.oodt.cas.filemgr.system.XmlRpcFileManagerClient;
+import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.cas.product.service.exceptions.NotFoundException;
+import org.apache.oodt.cas.product.service.responders.Responder;
+import org.apache.oodt.cas.product.service.responders.ResponderFactory;
+
+/**
+ * A JAX-RS resource representing a {@link Product}.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+public class ProductResource
+{
+  // The product associated with the resource.
+  private Product product;
+
+  // The metadata associated with the resource.
+  private Metadata metadata;
+
+  // The index of the reference within the product's reference list (default 0).
+  private int index;
+
+  // The path to the working directory used to store temporary files for
+  // responses.
+  private String workingDirPath;
+
+  @Context
+  private ServletContext context;
+
+
+
+  /**
+   * Default constructor.
+   */
+  public ProductResource()
+  {
+  }
+
+  /**
+   * This constructor can be used by DatasetResources to create
+   * ProductResource instances.
+   * @param product the product associated with the resource
+   * @param metadata the metadata associated with the resource
+   * @param workingDirPath the working directory for streaming files
+   */
+  public ProductResource(Product product, Metadata metadata,
+    String workingDirPath)
+  {
+    this.product = product;
+    this.metadata = metadata;
+    this.workingDirPath = workingDirPath;
+  }
+
+
+
+  /**
+   * Gets an HTTP response for a {@link Product} from the file manager.
+   * @param productID the ID of the product
+   * @param refIndex the index of a specific reference within the product's list
+   * of references
+   * @param format the requested format of the response
+   * @return HTTP response containing the requested product
+   */
+  @GET
+  @Path("/{path: product|data}")
+  public Response getResponse(@QueryParam("productID") String productID,
+    @QueryParam("refIndex") int refIndex,
+    @QueryParam("format") String format)
+  {
+    try
+    {
+      setWorkingDirPath(context.getInitParameter("filemgr.working.dir"));
+      XmlRpcFileManagerClient client = new XmlRpcFileManagerClient(new URL(
+        context.getInitParameter("filemgr.url")));
+      product = client.getProductById(productID);
+      product.setProductReferences(client.getProductReferences(product));
+      metadata = client.getMetadata(product);
+      index = refIndex;
+
+      Responder responder = ResponderFactory.createResponder(format);
+      return responder.createResponse(this);
+    }
+    catch (Exception e)
+    {
+      throw new NotFoundException("The requested resource could not be found. "
+        + e.getMessage());
+    }
+  }
+
+
+
+  /**
+   * Gets the product.
+   * @return the product
+   */
+  public Product getProduct()
+  {
+    return product;
+  }
+
+
+
+  /**
+   * Gets the metadata.
+   * @return the metadata
+   */
+  public Metadata getMetadata()
+  {
+    return metadata;
+  }
+
+
+
+  /**
+   * Gets the reference index.
+   * @return the index
+   */
+  public int getIndex()
+  {
+    return index;
+  }
+
+
+
+  /**
+   * Gets the working directory path.
+   * @return the workingDirPath
+   */
+  public String getWorkingDirPath()
+  {
+    return workingDirPath;
+  }
+
+
+
+  /**
+   * Sets the product.
+   * @param product the product to set
+   */
+  public void setProduct(Product product)
+  {
+    this.product = product;
+  }
+
+
+
+  /**
+   * Sets the metadata.
+   * @param metadata the metadata to set
+   */
+  public void setMetadata(Metadata metadata)
+  {
+    this.metadata = metadata;
+  }
+
+
+
+  /**
+   * Sets the index.
+   * @param index the index to set
+   */
+  public void setIndex(int index)
+  {
+    this.index = index;
+  }
+
+
+
+  /**
+   * Sets the working directory path.
+   * @param workingDirPath the workingDirPath to set
+   */
+  public void setWorkingDirPath(String workingDirPath)
+  {
+    this.workingDirPath = workingDirPath;
+  }
+
+
+
+  /**
+   * Sets the servlet context.
+   * @param context the servlet context to set.
+   */
+  public void setServletContext(ServletContext context)
+  {
+    this.context = context;
+  }
+}

Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/ProductResource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/ReferenceResource.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/ReferenceResource.java?rev=1507062&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/ReferenceResource.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/ReferenceResource.java Thu Jul 25 16:49:58 2013
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.oodt.cas.product.service.resources;
+
+import java.net.URL;
+import java.util.List;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+
+import org.apache.oodt.cas.filemgr.structs.Product;
+import org.apache.oodt.cas.filemgr.structs.Reference;
+import org.apache.oodt.cas.filemgr.system.XmlRpcFileManagerClient;
+import org.apache.oodt.cas.product.service.exceptions.NotFoundException;
+import org.apache.oodt.cas.product.service.responders.Responder;
+import org.apache.oodt.cas.product.service.responders.ResponderFactory;
+
+/**
+ * A JAX-RS resource representing a {@link Reference}.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+@Path("/reference")
+public class ReferenceResource
+{
+  // The reference associated with the resource.
+  private Reference reference;
+
+  // The path to the working directory used to store temporary files for
+  // responses.
+  private String workingDirPath;
+
+  @Context
+  private ServletContext context;
+
+
+
+  /**
+   * Gets an HTTP response for a {@link Reference} from a {@link Product} from
+   * the file manager.
+   * @param productID the ID of the product that the reference belongs to
+   * @param refIndex the index of the reference within the product's list of
+   * references
+   * @param format the requested response format
+   * @return a response representing the reference in the requested format
+   */
+  @GET
+  public Response getResponse(@QueryParam("productID") String productID,
+    @QueryParam("refIndex") int refIndex,
+    @QueryParam("format") String format)
+  {
+    try
+    {
+      setWorkingDirPath(context.getInitParameter("filemgr.working.dir"));
+      XmlRpcFileManagerClient client = new XmlRpcFileManagerClient(new URL(
+        context.getInitParameter("filemgr.url")));
+      Product product = client.getProductById(productID);
+      List<Reference> references = client.getProductReferences(product);
+      this.reference = references.get(refIndex);
+      Responder responder = ResponderFactory.createResponder(format);
+      return responder.createResponse(this);
+    }
+    catch (Exception e)
+    {
+      throw new NotFoundException("The requested resource could not be found. "
+        + e.getMessage());
+    }
+  }
+
+
+
+  /**
+   * Gets the reference.
+   *
+   * @return the reference
+   */
+  public Reference getReference()
+  {
+    return reference;
+  }
+
+
+
+  /**
+   * Gets the working directory path.
+   * @return the workingDirPath
+   */
+  public String getWorkingDirPath()
+  {
+    return workingDirPath;
+  }
+
+
+
+  /**
+   * Sets the servlet context.
+   * @param context the servlet context to set.
+   */
+  public void setServletContext(ServletContext context)
+  {
+    this.context = context;
+  }
+
+
+
+  /**
+   * Sets the reference.
+   * @param reference the reference to set
+   */
+  public void setReference(Reference reference)
+  {
+    this.reference = reference;
+  }
+
+
+
+  /**
+   * Sets the working directory path.
+   * @param workingDirPath the workingDirPath to set
+   */
+  public void setWorkingDirPath(String workingDirPath)
+  {
+    this.workingDirPath = workingDirPath;
+  }
+}

Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/ReferenceResource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/TransferResource.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/TransferResource.java?rev=1507062&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/TransferResource.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/TransferResource.java Thu Jul 25 16:49:58 2013
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.oodt.cas.product.service.resources;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Response;
+
+/**
+ * A resource representing information on data transfers for the file manager.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+@Path("/transfer")
+public class TransferResource
+{
+  // Additional response status constant not found in Response.Status class.
+  private static final int RESPONSE_STATUS_NOT_IMPLEMENTED = 501;
+
+
+
+  /**
+   * Gets information about current transfers in progress.
+   * @return HTTP response with information on current transfers
+   */
+  @GET
+  public Response getResponse()
+  {
+    return Response.status(RESPONSE_STATUS_NOT_IMPLEMENTED)
+      .entity("Transfer information via JAX-RS has not been implemented yet.")
+      .build();
+  }
+}

Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/TransferResource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/FileResponder.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/FileResponder.java?rev=1507062&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/FileResponder.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/FileResponder.java Thu Jul 25 16:49:58 2013
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.oodt.cas.product.service.responders;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.List;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
+
+import org.apache.oodt.cas.filemgr.structs.Product;
+import org.apache.oodt.cas.filemgr.structs.Reference;
+import org.apache.oodt.cas.product.service.exceptions.NotFoundException;
+import org.apache.oodt.cas.product.service.resources.DatasetResource;
+import org.apache.oodt.cas.product.service.resources.ProductResource;
+import org.apache.oodt.cas.product.service.resources.ReferenceResource;
+import org.apache.oodt.cas.product.service.resources.TransferResource;
+import org.apache.tika.Tika;
+import org.apache.tika.mime.MimeType;
+
+/**
+ * Generates HTTP responses for resources using their MIME types.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+public class FileResponder implements Responder
+{
+  @Override
+  public Response createResponse(ReferenceResource resource)
+  {
+    return createReferenceResponse(resource.getReference());
+  }
+
+
+
+  @Override
+  public Response createResponse(ProductResource resource)
+  {
+    Product product = resource.getProduct();
+    List<Reference> references = product.getProductReferences();
+    int index = resource.getIndex();
+    if (index < 0 || index >= references.size())
+    {
+      return Response.status(Response.Status.BAD_REQUEST)
+        .entity("Index out of range.").build();
+    }
+    return createReferenceResponse(references.get(index));
+  }
+
+
+
+  @Override
+  public Response createResponse(DatasetResource resource)
+  {
+    return Response.status(Response.Status.BAD_REQUEST)
+      .entity("Format not valid for this resource type.").build();
+  }
+
+
+
+  @Override
+  public Response createResponse(TransferResource resource)
+  {
+    return Response.status(Response.Status.BAD_REQUEST)
+      .entity("Format not valid for this resource type.").build();
+  }
+
+
+
+  /*
+   * Creates a response for a given reference.
+   */
+  private Response createReferenceResponse(Reference reference)
+  {
+    String contentType;
+    String dataStoreReference = reference.getDataStoreReference();
+    MimeType mimeType = reference.getMimeType();
+    if (mimeType != null &&
+        mimeType.getName() != null &&
+       !mimeType.getName().equals(""))
+    {
+      contentType = mimeType.getName();
+    }
+    else
+    {
+      contentType = new Tika().detect(dataStoreReference);
+    }
+
+    try
+    {
+      File file = new File(new URI(dataStoreReference));
+      if (!file.exists() || file.isDirectory())
+      {
+        return Response.status(Response.Status.BAD_REQUEST)
+          .entity("The requested reference is not a valid file.").build();
+      }
+
+      ResponseBuilder response = Response.ok(file);
+      response.type(contentType);
+      response.header("Content-Disposition",
+        "attachment; filename=\"" + file.getName() + "\"");
+      return response.build();
+    }
+    catch (URISyntaxException e)
+    {
+      throw new NotFoundException("The source file(s) for the reference could" +
+        " not be found at the intended location. " + e.getMessage());
+    }
+  }
+}

Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/FileResponder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/NullResponder.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/NullResponder.java?rev=1507062&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/NullResponder.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/NullResponder.java Thu Jul 25 16:49:58 2013
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.oodt.cas.product.service.responders;
+
+import javax.ws.rs.core.Response;
+
+import org.apache.oodt.cas.product.service.resources.DatasetResource;
+import org.apache.oodt.cas.product.service.resources.ProductResource;
+import org.apache.oodt.cas.product.service.resources.ReferenceResource;
+import org.apache.oodt.cas.product.service.resources.TransferResource;
+
+/**
+ * Generates default HTTP responses where the format is not specified.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+public class NullResponder implements Responder
+{
+
+  @Override
+  public Response createResponse(ReferenceResource resource)
+  {
+    return Response.status(Response.Status.BAD_REQUEST)
+      .entity("Format not specified.").build();
+  }
+
+  @Override
+  public Response createResponse(ProductResource resource)
+  {
+    return Response.status(Response.Status.BAD_REQUEST)
+      .entity("Format not specified.").build();
+  }
+
+  @Override
+  public Response createResponse(DatasetResource resource)
+  {
+    return Response.status(Response.Status.BAD_REQUEST)
+      .entity("Format not specified.").build();
+  }
+
+  @Override
+  public Response createResponse(TransferResource resource)
+  {
+    return Response.status(Response.Status.BAD_REQUEST)
+      .entity("Format not specified.").build();
+  }
+}

Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/NullResponder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/Responder.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/Responder.java?rev=1507062&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/Responder.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/Responder.java Thu Jul 25 16:49:58 2013
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.oodt.cas.product.service.responders;
+
+import javax.ws.rs.core.Response;
+
+import org.apache.oodt.cas.product.service.resources.DatasetResource;
+import org.apache.oodt.cas.product.service.resources.ProductResource;
+import org.apache.oodt.cas.product.service.resources.ReferenceResource;
+import org.apache.oodt.cas.product.service.resources.TransferResource;
+
+/**
+ * Specifies behavior for an HTTP response generator for different resources.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+public interface Responder
+{
+  /**
+   * Creates an HTTP response for a {@link ReferenceResource}.
+   * @param resource the reference resource for which to create the response
+   * @return the appropriate HTTP response for the given resource
+   */
+  Response createResponse(ReferenceResource resource);
+
+  /**
+   * Creates an HTTP response for a {@link ProductResource}.
+   * @param resource the product resource for which to create the response
+   * @return the appropriate HTTP response for the given resource
+   */
+  Response createResponse(ProductResource resource);
+
+  /**
+   * Creates an HTTP response for a {@link DatasetResource}.
+   * @param resource the dataset resource for which to create the response
+   * @return the appropriate HTTP response for the given resource
+   */
+  Response createResponse(DatasetResource resource);
+
+  /**
+   * Creates an HTTP response for a {@link TransferResource}.
+   * @param resource the transfer resource for which to create the response
+   * @return the appropriate HTTP response for the given resource
+   */
+  Response createResponse(TransferResource resource);
+}

Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/Responder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/ResponderFactory.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/ResponderFactory.java?rev=1507062&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/ResponderFactory.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/ResponderFactory.java Thu Jul 25 16:49:58 2013
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.oodt.cas.product.service.responders;
+
+/**
+ * Factory to generate {@link Responder} objects.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+public class ResponderFactory
+{
+  /**
+   * Creates a new {@link Responder} subtype.
+   * @param type the type of responder to create
+   * @return a new instance of a responder subtype
+   */
+  public static Responder createResponder(String type)
+  {
+    if (type == null)
+    {
+      return new NullResponder();
+    }
+    else if (type.equals("file"))
+    {
+      return new FileResponder();
+    }
+    else if (type.equals("zip"))
+    {
+      return new ZipResponder();
+    }
+
+    return new UnrecognizedFormatResponder();
+  }
+}

Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/ResponderFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/UnrecognizedFormatResponder.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/UnrecognizedFormatResponder.java?rev=1507062&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/UnrecognizedFormatResponder.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/UnrecognizedFormatResponder.java Thu Jul 25 16:49:58 2013
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.oodt.cas.product.service.responders;
+
+import javax.ws.rs.core.Response;
+
+import org.apache.oodt.cas.product.service.resources.DatasetResource;
+import org.apache.oodt.cas.product.service.resources.ProductResource;
+import org.apache.oodt.cas.product.service.resources.ReferenceResource;
+import org.apache.oodt.cas.product.service.resources.TransferResource;
+
+/**
+ * Generates HTTP responses when the requested response type is unrecognized.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+public class UnrecognizedFormatResponder implements Responder
+{
+  @Override
+  public Response createResponse(ReferenceResource resource)
+  {
+    return Response.status(Response.Status.BAD_REQUEST)
+      .entity("Unrecognized format.").build();
+  }
+
+  @Override
+  public Response createResponse(ProductResource resource)
+  {
+    return Response.status(Response.Status.BAD_REQUEST)
+      .entity("Unrecognized format.").build();
+  }
+
+  @Override
+  public Response createResponse(DatasetResource resource)
+  {
+    return Response.status(Response.Status.BAD_REQUEST)
+      .entity("Unrecognized format.").build();
+  }
+
+  @Override
+  public Response createResponse(TransferResource resource)
+  {
+    return Response.status(Response.Status.BAD_REQUEST)
+      .entity("Unrecognized format.").build();
+  }
+}

Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/UnrecognizedFormatResponder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/ZipResponder.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/ZipResponder.java?rev=1507062&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/ZipResponder.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/ZipResponder.java Thu Jul 25 16:49:58 2013
@@ -0,0 +1,312 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.oodt.cas.product.service.responders;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.util.List;
+import java.util.logging.Logger;
+import java.util.logging.Level;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
+
+import net.lingala.zip4j.core.ZipFile;
+import net.lingala.zip4j.model.ZipParameters;
+import net.lingala.zip4j.util.Zip4jConstants;
+
+import org.apache.oodt.cas.filemgr.structs.Product;
+import org.apache.oodt.cas.filemgr.structs.ProductType;
+import org.apache.oodt.cas.filemgr.structs.Reference;
+import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.cas.metadata.SerializableMetadata;
+import org.apache.oodt.cas.product.service.exceptions.BadRequestException;
+import org.apache.oodt.cas.product.service.exceptions.NotFoundException;
+import org.apache.oodt.cas.product.service.resources.DatasetResource;
+import org.apache.oodt.cas.product.service.resources.ProductResource;
+import org.apache.oodt.cas.product.service.resources.ReferenceResource;
+import org.apache.oodt.cas.product.service.resources.TransferResource;
+
+/**
+ * Generates HTTP responses using the application/zip MIME type.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+public class ZipResponder implements Responder
+{
+  private static final Logger LOGGER = Logger.getLogger(ZipResponder.class
+    .getName());
+
+  @Override
+  public Response createResponse(ReferenceResource resource)
+  {
+    try
+    {
+      File file = createZipFile(resource);
+      ResponseBuilder response = Response.ok(file);
+      response.type("application/zip");
+      response.header("Content-Disposition",
+        "attachment; filename=\"" + file.getName() + "\"");
+      return response.build();
+    }
+    catch (Exception e)
+    {
+      throw new NotFoundException("A representation of the requested resource" +
+        " in the requested format could not be found. " + e.getMessage());
+    }
+  }
+
+
+
+  @Override
+  public Response createResponse(ProductResource resource)
+  {
+    try
+    {
+      File file = createZipFile(resource);
+      ResponseBuilder response = Response.ok(file);
+      response.type("application/zip");
+      response.header("Content-Disposition",
+        "attachment; filename=\"" + file.getName() + "\"");
+      return response.build();
+    }
+    catch (Exception e)
+    {
+      throw new NotFoundException("A representation of the requested resource" +
+        " in the requested format could not be found. " + e.getMessage());
+    }
+  }
+
+
+
+  @Override
+  public Response createResponse(DatasetResource resource)
+  {
+    try
+    {
+      File file = createZipFile(resource);
+      ResponseBuilder response = Response.ok(file);
+      response.type("application/zip");
+      response.header("Content-Disposition",
+        "attachment; filename=\"" + file.getName() + "\"");
+      return response.build();
+    }
+    catch (Exception e)
+    {
+      throw new NotFoundException("A representation of the requested resource" +
+        " in the requested format could not be found. " + e.getMessage());
+    }
+  }
+
+
+
+  @Override
+  public Response createResponse(TransferResource resource)
+  {
+    return Response.status(Response.Status.BAD_REQUEST)
+      .entity("Format not valid for this resource type.").build();
+  }
+
+
+
+  /**
+   * Creates a zip file for a single reference.
+   * @throws Exception (FileNotFoundException, IOException, URISyntaxException,
+   * ZipException)
+   */
+  private File createZipFile(ReferenceResource resource) throws Exception
+  {
+    // Create the working directory if it doesn't already exist.
+    String workingDirPath = resource.getWorkingDirPath();
+    workingDirPath += workingDirPath.endsWith("/") ? "" : "/";
+    File workingDir = new File(workingDirPath);
+    if (!workingDir.exists() && !workingDir.mkdirs())
+    {
+      throw new IOException("Unable to create working directory.");
+    }
+
+    // Retrieve the reference file.
+    Reference reference = resource.getReference();
+    File refFile = new File(new URI(reference.getDataStoreReference()));
+    if (!refFile.exists())
+    {
+      throw new BadRequestException("Unable to locate the source file for the" +
+        " reference.");
+    }
+
+    // Try to remove previously created zip files that have the same name.
+    File file = new File(workingDirPath + refFile.getName() + ".zip");
+    if (file.exists() && !file.delete())
+    {
+      LOGGER.log(Level.FINE, "Could not delete an existing zip file ("
+        + file.getAbsolutePath()
+        + ") before creating a new zip file with the same name.");
+    }
+
+    // Add the reference file to the zip file.
+    ZipFile zipFile = new ZipFile(file);
+    ZipParameters parameters = new ZipParameters();
+    parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
+    parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
+    zipFile.addFile(refFile, parameters);
+
+    return file;
+  }
+
+
+
+  /**
+   * Creates a zip file containing all of the reference files in the supplied
+   * resource's product, along with the supplied resource's metadata.
+   * @throws Exception (FileNotFoundException, IOException, URISyntaxException,
+   * ZipException)
+   */
+  private File createZipFile(ProductResource resource) throws Exception
+  {
+    // Create the working directory if it doesn't already exist.
+    String workingDirPath = resource.getWorkingDirPath();
+    workingDirPath += workingDirPath.endsWith("/") ? "" : "/";
+    File workingDir = new File(workingDirPath);
+    if (!workingDir.exists() && !workingDir.mkdirs())
+    {
+      throw new IOException("Unable to create working directory.");
+    }
+
+    Product product = resource.getProduct();
+
+    // Try to remove previously created zip files that have the same name.
+    File file = new File(workingDirPath + product.getProductName() + ".zip");
+    if (file.exists() && !file.delete())
+    {
+      LOGGER.log(Level.FINE, "Could not delete an existing zip file ("
+        + file.getAbsolutePath()
+        + ") before creating a new zip file with the same name.");
+    }
+
+    // Add all of the product's references to the zip file.
+    ZipFile zipFile = new ZipFile(file);
+    ZipParameters parameters = new ZipParameters();
+    parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
+    parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
+
+    // Assumes that for hierarchical products, the first reference is the root
+    // directory and all contents of this directory are included in the product.
+    List<Reference> references = product.getProductReferences();
+    Reference rootReference = references.get(0);
+    File rootFile = new File(new URI(rootReference.getDataStoreReference()));
+    if (rootFile.isDirectory())
+    {
+      zipFile.addFolder(rootFile, parameters);
+    }
+    else
+    {
+      for (Reference reference : references)
+      {
+        zipFile.addFile(new File(new URI(reference.getDataStoreReference())),
+          parameters);
+      }
+    }
+
+    // Add the product's metadata to the zip.
+    parameters.setFileNameInZip(product.getProductName() + ".met");
+    parameters.setSourceExternalStream(true);
+    zipFile.addStream(getMetadataInputStream(resource.getMetadata()),
+      parameters);
+
+    return file;
+  }
+
+
+
+  /**
+   * Creates a zip file containing all of the zipped products thet belong to the
+   * data set's product type.
+   * @throws Exception (FileNotFoundException, IOException, URISyntaxException,
+   * ZipException)
+   */
+  private File createZipFile(DatasetResource resource) throws Exception
+  {
+    // Create the working directory if it doesn't already exist.
+    String workingDirPath = resource.getWorkingDirPath();
+    workingDirPath += workingDirPath.endsWith("/") ? "" : "/";
+    File workingDir = new File(workingDirPath);
+    if (!workingDir.exists() && !workingDir.mkdirs())
+    {
+      throw new IOException("Unable to create working directory.");
+    }
+
+    ProductType productType = resource.getProductType();
+
+    // Try to remove a previously created zip file with the same name.
+    File file = new File(workingDirPath + productType.getName() + ".zip");
+    if (file.exists() && !file.delete())
+    {
+      LOGGER.log(Level.FINE, "Could not delete an existing zip file ("
+        + file.getAbsolutePath()
+        + ") before creating a new zip file with the same name.");
+    }
+
+    // Add all of the product's references to the zip file.
+    ZipFile zipFile = new ZipFile(file);
+    ZipParameters parameters = new ZipParameters();
+    parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
+    parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
+
+    // Create zip archives for each product and add them to the dataset zip.
+    for (ProductResource productResource : resource.getProductResources())
+    {
+      File refFile = createZipFile(productResource);
+      zipFile.addFile(refFile, parameters);
+      if (refFile.exists() && !refFile.delete())
+      {
+        LOGGER.log(Level.FINE, "Could not delete a temporary product zip ("
+            + refFile.getAbsolutePath()
+            + ") after adding it to the dataset zip.");
+      }
+    }
+
+    // Add the dataset's metadata to the zip.
+    parameters.setFileNameInZip(productType.getName() + ".met");
+    parameters.setSourceExternalStream(true);
+    zipFile.addStream(getMetadataInputStream(productType.getTypeMetadata()),
+      parameters);
+
+    return file;
+  }
+
+
+
+  /**
+   * Creates an {@link InputStream} of metadata information.
+   * @param metadata the metadata object to add to the input stream
+   * @return an input stream containing the metadata information
+   * @throws IOException if the data cannot be written to the stream
+   */
+  private InputStream getMetadataInputStream(Metadata metadata)
+    throws IOException
+  {
+    ByteArrayOutputStream os = new ByteArrayOutputStream();
+    SerializableMetadata serMetadata = new SerializableMetadata(metadata);
+    serMetadata.writeMetadataToXmlStream(os);
+    return new ByteArrayInputStream(os.toByteArray());
+  }
+}

Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/ZipResponder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: oodt/trunk/webapp/fmprod/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/webapp/WEB-INF/web.xml?rev=1507062&r1=1507061&r2=1507062&view=diff
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/webapp/WEB-INF/web.xml (original)
+++ oodt/trunk/webapp/fmprod/src/main/webapp/WEB-INF/web.xml Thu Jul 25 16:49:58 2013
@@ -1,65 +1,112 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
-Licensed to the Apache Software Foundation (ASF) under one or more contributor
-license agreements.  See the NOTICE.txt file distributed with this work for
-additional information regarding copyright ownership.  The ASF licenses this
-file to you under the Apache License, Version 2.0 (the "License"); you may not
-use this file except in compliance with the License.  You may obtain a copy of
-the License at
-
-     http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
-License for the specific language governing permissions and limitations under
-the License.
+  Licensed to the Apache Software Foundation (ASF) under one or more contributor
+  license agreements.  See the NOTICE.txt file distributed with this work for
+  additional information regarding copyright ownership.  The ASF licenses this
+  file to you under the Apache License, Version 2.0 (the "License"); you may not
+  use this file except in compliance with the License.  You may obtain a copy of
+  the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+  License for the specific language governing permissions and limitations under
+  the License.
 -->
-<!DOCTYPE web-app
-    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
-    "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app version="2.5"
+  xmlns="http://java.sun.com/xml/ns/javaee"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
+  <display-name>CAS Product Server</display-name>
+
 
-<web-app>
   <context-param>
     <param-name>filemgr.url</param-name>
     <param-value>http://localhost:9000</param-value>
   </context-param>
+
   <context-param>
     <param-name>filemgr.ns</param-name>
-    <param-value>cas|urn:oodt:|rdf|http://www.w3.org/1999/02/22-rdf-syntax-ns#</param-value>
+    <param-value>
+      cas|urn:oodt:|rdf|http://www.w3.org/1999/02/22-rdf-syntax-ns#
+    </param-value>
   </context-param>
+
   <context-param>
     <param-name>filemgr.ns.default</param-name>
     <param-value>cas</param-value>
   </context-param>
+
   <context-param>
     <param-name>filemgr.working.dir</param-name>
     <param-value>/tmp</param-value>
   </context-param>
 
+
   <servlet>
     <servlet-name>RSSServlet</servlet-name>
-    <servlet-class>org.apache.oodt.cas.product.rss.RSSProductServlet</servlet-class>
+    <servlet-class>
+      org.apache.oodt.cas.product.rss.RSSProductServlet
+    </servlet-class>
   </servlet>
+
   <servlet>
     <servlet-name>RSSTransferServlet</servlet-name>
-    <servlet-class>org.apache.oodt.cas.product.rss.RSSProductTransferServlet</servlet-class>
+    <servlet-class>
+      org.apache.oodt.cas.product.rss.RSSProductTransferServlet
+    </servlet-class>
   </servlet>
+
   <servlet>
     <servlet-name>RDFProductServlet</servlet-name>
-    <servlet-class>org.apache.oodt.cas.product.rdf.RDFProductServlet</servlet-class>
+    <servlet-class>
+      org.apache.oodt.cas.product.rdf.RDFProductServlet
+    </servlet-class>
   </servlet>
+
   <servlet>
-      <servlet-name>RDFDatasetServlet</servlet-name>
-      <servlet-class>org.apache.oodt.cas.product.rdf.RDFDatasetServlet</servlet-class>
+    <servlet-name>RDFDatasetServlet</servlet-name>
+    <servlet-class>
+      org.apache.oodt.cas.product.rdf.RDFDatasetServlet
+    </servlet-class>
   </servlet>
+
   <servlet>
     <servlet-name>DataDeliveryServlet</servlet-name>
-    <servlet-class>org.apache.oodt.cas.product.data.DataDeliveryServlet</servlet-class>
+    <servlet-class>
+      org.apache.oodt.cas.product.data.DataDeliveryServlet
+    </servlet-class>
   </servlet>
+
   <servlet>
     <servlet-name>DatasetDeliveryServlet</servlet-name>
-    <servlet-class>org.apache.oodt.cas.product.data.DatasetDeliveryServlet</servlet-class>
+    <servlet-class>
+      org.apache.oodt.cas.product.data.DatasetDeliveryServlet
+    </servlet-class>
+  </servlet>
+
+  <servlet>
+    <servlet-name>CXFServlet</servlet-name>
+    <servlet-class>
+      org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet
+    </servlet-class>
+    <init-param>
+      <param-name>jaxrs.serviceClasses</param-name>
+      <param-value>
+        org.apache.oodt.cas.product.service.resources.ReferenceResource,
+        org.apache.oodt.cas.product.service.resources.ProductResource,
+        org.apache.oodt.cas.product.service.resources.DatasetResource,
+        org.apache.oodt.cas.product.service.resources.TransferResource
+      </param-value>
+    </init-param>
+    <init-param>
+      <param-name>jaxrs.scope</param-name>
+      <param-value>prototype</param-value>
+    </init-param>
   </servlet>
 
 
@@ -87,10 +134,14 @@ the License.
     <servlet-name>DataDeliveryServlet</servlet-name>
     <url-pattern>/data</url-pattern>
   </servlet-mapping>
-  
+
   <servlet-mapping>
     <servlet-name>DatasetDeliveryServlet</servlet-name>
     <url-pattern>/dataset</url-pattern>
-  </servlet-mapping>  
+  </servlet-mapping>
 
+  <servlet-mapping>
+    <servlet-name>CXFServlet</servlet-name>
+    <url-pattern>/service/*</url-pattern>
+  </servlet-mapping>
 </web-app>

Added: oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/resources/DatasetResourceTest.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/resources/DatasetResourceTest.java?rev=1507062&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/resources/DatasetResourceTest.java (added)
+++ oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/resources/DatasetResourceTest.java Thu Jul 25 16:49:58 2013
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.oodt.cas.product.service.resources;
+
+import static org.junit.Assert.*;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.core.Response;
+
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.cxf.transport.local.LocalConduit;
+import org.apache.cxf.transport.local.LocalTransportFactory;
+import org.easymock.EasyMock;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Implements tests for methods in the {@link DatasetResource} class.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+public class DatasetResourceTest extends ResourceTestBase
+{
+  // The web server.
+  private static Server server;
+
+
+
+  /**
+   * Starts a web server using the local transport protocol.  Uses a mock
+   * servlet context to inject context parameters into the JAX-RS resource.
+   */
+  @BeforeClass
+  public static void startWebServer()
+  {
+    // The JAX-RS resource to test.
+    DatasetResource resource = new DatasetResource();
+
+    // Create a web server for testing using local transport.
+    JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
+    sf.setTransportId(LocalTransportFactory.TRANSPORT_ID);
+    sf.setServiceBean(resource);
+    sf.setAddress("local://service");
+    server = sf.create();
+
+    // Use a mock servlet context for the resource.
+    // This is done after creating the server to avoid being overwritten by
+    // the server's default context.
+    ServletContext mockContext = EasyMock.createNiceMock(ServletContext.class);
+    EasyMock.expect(mockContext.getInitParameter("filemgr.url"))
+      .andReturn(getFileManagerUrl()).anyTimes();
+    EasyMock.expect(mockContext.getInitParameter("filemgr.working.dir"))
+      .andReturn(getWorkingDirLocation()).anyTimes();
+    EasyMock.replay(mockContext);
+    resource.setServletContext(mockContext);
+  }
+
+
+
+  /**
+   * Shuts down the web server.
+   */
+  @AfterClass
+  public static void stopWebServer()
+  {
+    // Stop the server.
+    server.stop();
+    server.destroy();
+  }
+
+
+
+  /**
+   * Tests the response for a request to the 'dataset' URL with query
+   * parameters specifying a specific product type and a 'zip' response format.
+   */
+  @Test
+  public void testGetZipResponseGenericFileDataset()
+  {
+    WebClient client = WebClient.create("local://service");
+    WebClient.getConfig(client).getRequestContext()
+      .put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE);
+    client.accept("application/zip");
+    client.path("/dataset");
+    client.query("typeID", "urn:oodt:GenericFile");
+    client.query("format", "zip");
+
+    Response response = client.get();
+    assertEquals("Incorrect response status.", 200, response.getStatus());
+    assertEquals("Incorrect content type in response.",
+      "application/zip", response.getMetadata().get("Content-Type").get(0));
+    assertEquals("Incorrect content disposition in response",
+      "attachment; filename=\"GenericFile.zip\"",
+      response.getMetadata().get("Content-Disposition").get(0));
+  }
+
+
+
+  /**
+   * Tests the response for a request to the 'dataset' URL with query
+   * parameters specifying a specific product type and a 'zip' response format.
+   */
+  @Test
+  public void testGetZipResponseLocationAwareDataset()
+  {
+    WebClient client = WebClient.create("local://service");
+    WebClient.getConfig(client).getRequestContext()
+      .put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE);
+    client.accept("application/zip");
+    client.path("/dataset");
+    client.query("typeID", "urn:oodt:LocationAwareProduct");
+    client.query("format", "zip");
+
+    Response response = client.get();
+    assertEquals("Incorrect response status.", 200, response.getStatus());
+    assertEquals("Incorrect content type in response.",
+      "application/zip", response.getMetadata().get("Content-Type").get(0));
+    assertEquals("Incorrect content disposition in response",
+      "attachment; filename=\"LocationAwareProduct.zip\"",
+      response.getMetadata().get("Content-Disposition").get(0));
+  }
+}

Propchange: oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/resources/DatasetResourceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native