oodt-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rlaid...@apache.org
Subject svn commit: r1517154 [1/2] - in /oodt/trunk: ./ webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/ webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/ webapp/fmprod/src/main/java/org/apache/oodt/cas/produ...
Date Sat, 24 Aug 2013 15:48:53 GMT
Author: rlaidlaw
Date: Sat Aug 24 15:48:52 2013
New Revision: 1517154

URL: http://svn.apache.org/r1517154
Log:
OODT-651: Improve parameter initialization, validation and logging for JAXRS service.

Added:
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/Resource.java   (with props)
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/servlets/
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/servlets/CasProductJaxrsServlet.java   (with props)
    oodt/trunk/webapp/fmprod/src/main/resources/logging.properties   (with props)
Modified:
    oodt/trunk/CHANGES.txt
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/DatasetResource.java
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/ProductResource.java
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/ReferenceResource.java
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/TransferResource.java
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/FileResponder.java
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/ZipResponder.java
    oodt/trunk/webapp/fmprod/src/main/webapp/META-INF/context.xml
    oodt/trunk/webapp/fmprod/src/main/webapp/WEB-INF/web.xml
    oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/resources/DatasetResourceTest.java
    oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/resources/ProductResourceTest.java
    oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/resources/ReferenceResourceTest.java
    oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/resources/ResourceTestBase.java
    oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/FileResponderTest.java
    oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/NullResponderTest.java
    oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/ResponderFactoryTest.java
    oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/UnrecognizedFormatResponderTest.java
    oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/ZipResponderTest.java
    oodt/trunk/webapp/fmprod/src/test/resources/filemgr/policy/core/product-types.xml
    oodt/trunk/webapp/fmprod/src/test/resources/test.logging.properties

Modified: oodt/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/oodt/trunk/CHANGES.txt?rev=1517154&r1=1517153&r2=1517154&view=diff
==============================================================================
--- oodt/trunk/CHANGES.txt (original)
+++ oodt/trunk/CHANGES.txt Sat Aug 24 15:48:52 2013
@@ -4,6 +4,9 @@ Apache OODT Change Log
 Release 0.7 - Current Development
 ---------------------------------
 
+* OODT-651 Improve parameter initialization, validation and logging for
+  CAS-Product web application (rlaidlaw)
+
 * OODT-650 Remove duplicate context container example from CAS-Product web
   application (rlaidlaw)
 

Modified: 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=1517154&r1=1517153&r2=1517154&view=diff
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/DatasetResource.java (original)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/DatasetResource.java Sat Aug 24 15:48:52 2013
@@ -17,21 +17,20 @@
 
 package org.apache.oodt.cas.product.service.resources;
 
-import java.net.URL;
+import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
-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.metadata.util.PathUtils;
 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;
@@ -44,8 +43,11 @@ import org.apache.oodt.cas.product.servi
  * @version $Revision$
  */
 @Path("/dataset")
-public class DatasetResource
+public class DatasetResource extends Resource
 {
+  private static final Logger LOGGER = Logger.getLogger(DatasetResource.class
+    .getName());
+
   // The product type associated with the resource.
   private ProductType productType;
 
@@ -53,13 +55,6 @@ public class DatasetResource
   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;
-
 
 
   /**
@@ -80,24 +75,18 @@ public class DatasetResource
 
     try
     {
-      XmlRpcFileManagerClient client = new XmlRpcFileManagerClient(
-        new URL(PathUtils.replaceEnvVariables(
-          context.getInitParameter("filemgr.url"))));
+      setWorkingDir(getContextWorkingDir());
+      XmlRpcFileManagerClient client = getContextClient();
       productType = client.getProductTypeById(typeID);
-
-      // Set a working directory to store product files.
-      setWorkingDirPath(PathUtils.replaceEnvVariables(
-        context.getInitParameter("filemgr.working.dir")));
-      String productDirPath = getWorkingDirPath();
-      productDirPath += productDirPath.endsWith("/") ? "" : "/";
-      productDirPath += productType.getName();
+      String productDirPath = getContextWorkingDir().getCanonicalPath()
+        + "/" + 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));
+          client.getMetadata(product), new File(productDirPath)));
       }
 
       Responder responder = ResponderFactory.createResponder(format);
@@ -105,8 +94,9 @@ public class DatasetResource
     }
     catch (Exception e)
     {
-      throw new NotFoundException("The requested resource could not be found. "
-        + e.getMessage());
+      String message = "Unable to find the requested resource.";
+      LOGGER.log(Level.FINE, message, e);
+      throw new NotFoundException(message + " " + e.getMessage());
     }
   }
 
@@ -135,17 +125,6 @@ public class DatasetResource
 
 
   /**
-   * Gets the working directory path.
-   * @return the workingDirPath
-   */
-  public String getWorkingDirPath()
-  {
-    return workingDirPath;
-  }
-
-
-
-  /**
    * Sets the productType.
    * @param productType the productType to set
    */
@@ -164,26 +143,4 @@ public class DatasetResource
   {
     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;
-  }
 }

Modified: 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=1517154&r1=1517153&r2=1517154&view=diff
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/ProductResource.java (original)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/ProductResource.java Sat Aug 24 15:48:52 2013
@@ -17,19 +17,18 @@
 
 package org.apache.oodt.cas.product.service.resources;
 
-import java.net.URL;
+import java.io.File;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
-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.metadata.util.PathUtils;
 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;
@@ -39,8 +38,11 @@ import org.apache.oodt.cas.product.servi
  * @author rlaidlaw
  * @version $Revision$
  */
-public class ProductResource
+public class ProductResource extends Resource
 {
+  private static final Logger LOGGER = Logger.getLogger(ProductResource.class
+    .getName());
+
   // The product associated with the resource.
   private Product product;
 
@@ -50,13 +52,6 @@ public class ProductResource
   // 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;
-
 
 
   /**
@@ -71,14 +66,14 @@ public class ProductResource
    * 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
+   * @param workingDir the working directory for streaming files
    */
   public ProductResource(Product product, Metadata metadata,
-    String workingDirPath)
+    File workingDir)
   {
     this.product = product;
     this.metadata = metadata;
-    this.workingDirPath = workingDirPath;
+    setWorkingDir(workingDir);
   }
 
 
@@ -99,11 +94,8 @@ public class ProductResource
   {
     try
     {
-      setWorkingDirPath(PathUtils.replaceEnvVariables(
-        context.getInitParameter("filemgr.working.dir")));
-      XmlRpcFileManagerClient client = new XmlRpcFileManagerClient(
-        new URL(PathUtils.replaceEnvVariables(
-          context.getInitParameter("filemgr.url"))));
+      setWorkingDir(getContextWorkingDir());
+      XmlRpcFileManagerClient client = getContextClient();
       product = client.getProductById(productID);
       product.setProductReferences(client.getProductReferences(product));
       metadata = client.getMetadata(product);
@@ -114,8 +106,9 @@ public class ProductResource
     }
     catch (Exception e)
     {
-      throw new NotFoundException("The requested resource could not be found. "
-        + e.getMessage());
+      String message = "Unable to find the requested resource.";
+      LOGGER.log(Level.FINE, message, e);
+      throw new NotFoundException(message + " " + e.getMessage());
     }
   }
 
@@ -155,17 +148,6 @@ public class ProductResource
 
 
   /**
-   * Gets the working directory path.
-   * @return the workingDirPath
-   */
-  public String getWorkingDirPath()
-  {
-    return workingDirPath;
-  }
-
-
-
-  /**
    * Sets the product.
    * @param product the product to set
    */
@@ -195,26 +177,4 @@ public class ProductResource
   {
     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;
-  }
 }

Modified: 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=1517154&r1=1517153&r2=1517154&view=diff
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/ReferenceResource.java (original)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/ReferenceResource.java Sat Aug 24 15:48:52 2013
@@ -17,20 +17,18 @@
 
 package org.apache.oodt.cas.product.service.resources;
 
-import java.net.URL;
 import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
-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.metadata.util.PathUtils;
 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;
@@ -41,18 +39,14 @@ import org.apache.oodt.cas.product.servi
  * @version $Revision$
  */
 @Path("/reference")
-public class ReferenceResource
+public class ReferenceResource extends Resource
 {
+  private static final Logger LOGGER = Logger.getLogger(ReferenceResource.class
+    .getName());
+
   // 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;
-
 
 
   /**
@@ -71,21 +65,20 @@ public class ReferenceResource
   {
     try
     {
-      setWorkingDirPath(PathUtils.replaceEnvVariables(
-        context.getInitParameter("filemgr.working.dir")));
-      XmlRpcFileManagerClient client = new XmlRpcFileManagerClient(
-        new URL(PathUtils.replaceEnvVariables(
-          context.getInitParameter("filemgr.url"))));
+      setWorkingDir(getContextWorkingDir());
+      XmlRpcFileManagerClient client = getContextClient();
       Product product = client.getProductById(productID);
       List<Reference> references = client.getProductReferences(product);
-      this.reference = references.get(refIndex);
+      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());
+      String message = "Unable to find the requested resource.";
+      LOGGER.log(Level.FINE, message, e);
+      throw new NotFoundException(message + " " + e.getMessage());
     }
   }
 
@@ -93,7 +86,6 @@ public class ReferenceResource
 
   /**
    * Gets the reference.
-   *
    * @return the reference
    */
   public Reference getReference()
@@ -104,28 +96,6 @@ public class ReferenceResource
 
 
   /**
-   * 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
    */
@@ -133,15 +103,4 @@ public class ReferenceResource
   {
     this.reference = reference;
   }
-
-
-
-  /**
-   * Sets the working directory path.
-   * @param workingDirPath the workingDirPath to set
-   */
-  public void setWorkingDirPath(String workingDirPath)
-  {
-    this.workingDirPath = workingDirPath;
-  }
 }

Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/Resource.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/Resource.java?rev=1517154&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/Resource.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/Resource.java Sat Aug 24 15:48:52 2013
@@ -0,0 +1,109 @@
+package org.apache.oodt.cas.product.service.resources;
+
+import java.io.File;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.core.Context;
+
+import org.apache.oodt.cas.filemgr.system.XmlRpcFileManagerClient;
+import org.apache.oodt.cas.product.service.servlets.CasProductJaxrsServlet;
+
+/**
+ * Specifies default behaviour for resource types.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+public abstract class Resource
+{
+  private static final Logger LOGGER = Logger.getLogger(Resource.class
+    .getName());
+
+  // The servlet context, which is used to retrieve context parameters.
+  @Context
+  private ServletContext context;
+
+  // The file manager's working directory for this resource.
+  private File workingDir;
+
+  /**
+   * Gets the file manager's working directory for this resource.
+   * @return the working directory
+   */
+  public File getWorkingDir()
+  {
+    return workingDir;
+  }
+
+
+
+  /**
+   * Sets the file manager's working directory for this resource.
+   * @param workingDir the working directory to set
+   */
+  public void setWorkingDir(File workingDir)
+  {
+    this.workingDir = workingDir;
+  }
+
+
+
+  /**
+   * Gets the file manager's working directory from the servlet context.
+   * @return the file manager working directory
+   * @throws Exception if an object cannot be retrieved from the context
+   * attribute
+   */
+  public File getContextWorkingDir() throws Exception
+  {
+    Object workingDirObject = context
+      .getAttribute(CasProductJaxrsServlet.ATTR_NAME_WORKINGDIR);
+    if (workingDirObject != null && workingDirObject instanceof File)
+    {
+      return (File) workingDirObject;
+    }
+
+    String message = "Unable to retrieve the file manager's working directory "
+      + "from the servlet context.";
+    LOGGER.log(Level.WARNING, message);
+    throw new Exception(message);
+  }
+
+
+
+  /**
+   * Gets the servlet's file manager client instance from the servlet context.
+   * @return the file manager client instance from the servlet context attribute
+   * @throws Exception if an object cannot be retrieved from the context
+   * attribute
+   */
+  public XmlRpcFileManagerClient getContextClient()
+    throws Exception
+  {
+    // Get the file manager client from the servlet context.
+    Object clientObject = context
+      .getAttribute(CasProductJaxrsServlet.ATTR_NAME_CLIENT);
+    if (clientObject != null &&
+        clientObject instanceof XmlRpcFileManagerClient)
+    {
+      return (XmlRpcFileManagerClient) clientObject;
+    }
+
+    String message = "Unable to retrieve the file manager client from the "
+      + "servlet context.";
+    LOGGER.log(Level.WARNING, message);
+    throw new Exception(message);
+  }
+
+
+
+  /**
+   * 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/Resource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 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=1517154&r1=1517153&r2=1517154&view=diff
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/TransferResource.java (original)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/resources/TransferResource.java Sat Aug 24 15:48:52 2013
@@ -27,7 +27,7 @@ import javax.ws.rs.core.Response;
  * @version $Revision$
  */
 @Path("/transfer")
-public class TransferResource
+public class TransferResource extends Resource
 {
   // Additional response status constant not found in Response.Status class.
   private static final int RESPONSE_STATUS_NOT_IMPLEMENTED = 501;

Modified: 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=1517154&r1=1517153&r2=1517154&view=diff
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/FileResponder.java (original)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/FileResponder.java Sat Aug 24 15:48:52 2013
@@ -21,6 +21,8 @@ import java.io.File;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.ResponseBuilder;
@@ -42,6 +44,9 @@ import org.apache.tika.mime.MimeType;
  */
 public class FileResponder implements Responder
 {
+  private static final Logger LOGGER = Logger.getLogger(FileResponder.class
+    .getName());
+
   @Override
   public Response createResponse(ReferenceResource resource)
   {
@@ -108,8 +113,11 @@ public class FileResponder implements Re
       File file = new File(new URI(dataStoreReference));
       if (!file.exists() || file.isDirectory())
       {
+        String message =
+          "Unable to locate the reference source file(s) in the data store.";
+        LOGGER.log(Level.FINE, message);
         return Response.status(Response.Status.BAD_REQUEST)
-          .entity("The requested reference is not a valid file.").build();
+          .entity(message).build();
       }
 
       ResponseBuilder response = Response.ok(file);
@@ -120,8 +128,10 @@ public class FileResponder implements Re
     }
     catch (URISyntaxException e)
     {
-      throw new NotFoundException("The source file(s) for the reference could" +
-        " not be found at the intended location. " + e.getMessage());
+      String message =
+        "Problem with the data store URI for the reference source file(s).";
+      LOGGER.log(Level.FINE, message, e);
+      throw new NotFoundException(message + " " + e.getMessage());
     }
   }
 }

Modified: 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=1517154&r1=1517153&r2=1517154&view=diff
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/ZipResponder.java (original)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/responders/ZipResponder.java Sat Aug 24 15:48:52 2013
@@ -70,8 +70,9 @@ public class ZipResponder implements Res
     }
     catch (Exception e)
     {
-      throw new NotFoundException("A representation of the requested resource" +
-        " in the requested format could not be found. " + e.getMessage());
+      throw new NotFoundException(
+        "Unable to get the requested resource in application/zip format. "
+          + e.getMessage());
     }
   }
 
@@ -91,8 +92,9 @@ public class ZipResponder implements Res
     }
     catch (Exception e)
     {
-      throw new NotFoundException("A representation of the requested resource" +
-        " in the requested format could not be found. " + e.getMessage());
+      throw new NotFoundException(
+        "Unable to get the requested resource in application/zip format. "
+          + e.getMessage());
     }
   }
 
@@ -112,8 +114,9 @@ public class ZipResponder implements Res
     }
     catch (Exception e)
     {
-      throw new NotFoundException("A representation of the requested resource" +
-        " in the requested format could not be found. " + e.getMessage());
+      throw new NotFoundException(
+        "Unable to get the requested resource in application/zip format. "
+          + e.getMessage());
     }
   }
 
@@ -136,12 +139,13 @@ public class ZipResponder implements Res
   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);
+    File workingDir = resource.getWorkingDir();
     if (!workingDir.exists() && !workingDir.mkdirs())
     {
-      throw new IOException("Unable to create working directory.");
+      String message = "Unable to create the working directory ("
+        + workingDir.getAbsolutePath() + ") to build the zip file.";
+      LOGGER.log(Level.FINE, message);
+      throw new IOException(message);
     }
 
     // Retrieve the reference file.
@@ -154,10 +158,12 @@ public class ZipResponder implements Res
     }
 
     // Try to remove previously created zip files that have the same name.
+    String workingDirPath = workingDir.getCanonicalPath();
+    workingDirPath += workingDirPath.endsWith("/") ? "" : "/";
     File file = new File(workingDirPath + refFile.getName() + ".zip");
     if (file.exists() && !file.delete())
     {
-      LOGGER.log(Level.FINE, "Could not delete an existing zip file ("
+      LOGGER.log(Level.FINE, "Unable to delete an existing zip file ("
         + file.getAbsolutePath()
         + ") before creating a new zip file with the same name.");
     }
@@ -183,21 +189,23 @@ public class ZipResponder implements Res
   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);
+    File workingDir = resource.getWorkingDir();
     if (!workingDir.exists() && !workingDir.mkdirs())
     {
-      throw new IOException("Unable to create working directory.");
+      String message = "Unable to create the working directory ("
+        + workingDir.getAbsolutePath() + ") to build the zip file.";
+      LOGGER.log(Level.FINE, message);
+      throw new IOException(message);
     }
 
     Product product = resource.getProduct();
 
     // Try to remove previously created zip files that have the same name.
-    File file = new File(workingDirPath + product.getProductName() + ".zip");
+    File file = new File(workingDir.getCanonicalPath() + "/"
+      + product.getProductName() + ".zip");
     if (file.exists() && !file.delete())
     {
-      LOGGER.log(Level.FINE, "Could not delete an existing zip file ("
+      LOGGER.log(Level.FINE, "Unable to delete an existing zip file ("
         + file.getAbsolutePath()
         + ") before creating a new zip file with the same name.");
     }
@@ -246,21 +254,23 @@ public class ZipResponder implements Res
   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);
+    File workingDir = resource.getWorkingDir();
     if (!workingDir.exists() && !workingDir.mkdirs())
     {
-      throw new IOException("Unable to create working directory.");
+      String message = "Unable to create the working directory ("
+        + workingDir.getAbsolutePath() + ") to build the zip file.";
+      LOGGER.log(Level.FINE, message);
+      throw new IOException(message);
     }
 
     ProductType productType = resource.getProductType();
 
     // Try to remove a previously created zip file with the same name.
-    File file = new File(workingDirPath + productType.getName() + ".zip");
+    File file = new File(workingDir.getCanonicalPath() + "/"
+      + productType.getName() + ".zip");
     if (file.exists() && !file.delete())
     {
-      LOGGER.log(Level.FINE, "Could not delete an existing zip file ("
+      LOGGER.log(Level.FINE, "Unable to delete an existing zip file ("
         + file.getAbsolutePath()
         + ") before creating a new zip file with the same name.");
     }
@@ -278,9 +288,9 @@ public class ZipResponder implements Res
       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.");
+        LOGGER.log(Level.FINE, "Unable to delete a temporary product zip ("
+          + refFile.getAbsolutePath()
+          + ") after adding it to the dataset zip.");
       }
     }
 

Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/servlets/CasProductJaxrsServlet.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/servlets/CasProductJaxrsServlet.java?rev=1517154&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/servlets/CasProductJaxrsServlet.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/servlets/CasProductJaxrsServlet.java Sat Aug 24 15:48:52 2013
@@ -0,0 +1,119 @@
+package org.apache.oodt.cas.product.service.servlets;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+import org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet;
+import org.apache.oodt.cas.filemgr.structs.exceptions.ConnectionException;
+import org.apache.oodt.cas.filemgr.system.XmlRpcFileManagerClient;
+import org.apache.oodt.cas.metadata.util.PathUtils;
+
+/**
+ * Provides a single place to initialize items such as the file manager client,
+ * working directory and responder configurations when the web application is
+ * started up.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+public class CasProductJaxrsServlet extends CXFNonSpringJaxrsServlet
+{
+  private static final Logger LOGGER = Logger.getLogger(CasProductJaxrsServlet
+    .class.getName());
+
+  // Auto-generated ID for serialization.
+  private static final long serialVersionUID = -1835790185000773396L;
+
+  // Default URL for the file manager
+  private static final String DEFAULT_FM_URL = "http://localhost:9000";
+
+  // Servlet context parameter names.
+  private static final String PARAM_NAME_URL = "filemgr.url";
+  private static final String PARAM_NAME_WORKINGDIR = "filemgr.working.dir";
+
+  /**
+   * The name of the servlet context attribute that holds a client for the file
+   * manager, a {@link XmlRpcFileManagerClient} object.
+   */
+  public static final String ATTR_NAME_CLIENT = "client";
+
+  /**
+   * The name of the servlet context attribute that holds the file manager's
+   * working directory, a {@link File} object.
+   */
+  public static final String ATTR_NAME_WORKINGDIR = "workingDir";
+
+  @Override
+  public void init(ServletConfig configuration) throws ServletException
+  {
+    super.init(configuration);
+    ServletContext context = configuration.getServletContext();
+
+    // Initialize the file manager client.
+    try
+    {
+      URL url = null;
+      String urlParameter = context.getInitParameter(PARAM_NAME_URL);
+      if (urlParameter != null)
+      {
+        // Get the file manager URL from the context parameter.
+        url = new URL(PathUtils.replaceEnvVariables(urlParameter));
+      }
+      else
+      {
+        // Try the default URL for the file manager.
+        LOGGER.log(Level.WARNING, "Unable to find the servlet context parameter"
+          + " (\"" + PARAM_NAME_URL + "\") for the file manager's URL.");
+        url = new URL(DEFAULT_FM_URL);
+      }
+
+      // Attempt to connect the client to the file manager and if successful
+      // store the client as a context attribute for other objects to access.
+      XmlRpcFileManagerClient client = new XmlRpcFileManagerClient(url);
+      context.setAttribute(ATTR_NAME_CLIENT, client);
+    }
+    catch (MalformedURLException e)
+    {
+      LOGGER.log(Level.SEVERE,
+        "Encountered a malformed URL for the file manager.", e);
+      throw new ServletException(e);
+    }
+    catch (ConnectionException e)
+    {
+      LOGGER.log(Level.SEVERE, "Client unable to connect to the file manager.",
+        e);
+      throw new ServletException(e);
+    }
+
+    // Initialize the file manager working directory.
+    String workingDirPath = context.getInitParameter(PARAM_NAME_WORKINGDIR);
+    if (workingDirPath != null)
+    {
+      // Validate the path.
+      File workingDir = new File(PathUtils.replaceEnvVariables(workingDirPath));
+      if (workingDir.exists() && workingDir.isDirectory())
+      {
+        context.setAttribute(ATTR_NAME_WORKINGDIR, workingDir);
+      }
+      else
+      {
+        LOGGER.log(Level.SEVERE, "Unable to locate the working directory ("
+          + workingDir.getAbsolutePath() + ") for the file manager.");
+      }
+    }
+    else
+    {
+      String message = "Unable to find the servlet context parameter "
+        + "(\"" + PARAM_NAME_WORKINGDIR
+        + "\") for the file manager's working directory.";
+      LOGGER.log(Level.SEVERE, message);
+      throw new ServletException(message);
+    }
+  }
+}

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

Added: oodt/trunk/webapp/fmprod/src/main/resources/logging.properties
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/resources/logging.properties?rev=1517154&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/resources/logging.properties (added)
+++ oodt/trunk/webapp/fmprod/src/main/resources/logging.properties Sat Aug 24 15:48:52 2013
@@ -0,0 +1,38 @@
+# 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.
+
+# This is an example logging properties file for use in the deployed web
+# application on an Apache Tomcat web server.
+
+# Log levels: OFF, SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST, ALL
+
+handlers = org.apache.juli.FileHandler
+
+org.apache.juli.FileHandler.level = FINE
+org.apache.juli.FileHandler.directory = ${catalina.base}/logs
+org.apache.juli.FileHandler.prefix = fmprod.
+
+# CAS-Product service settings
+org.apache.oodt.cas.product.service = FINE
+
+# File manager settings
+org.apache.oodt.cas.filemgr.level = SEVERE
+
+# XMLRPC commons-httpclient transport layer settings
+org.apache.commons.httpclient.level = WARNING
+httpclient.wire.level = WARNING
+
+# Apache CXF settings
+org.apache.cxf.level = WARNING

Propchange: oodt/trunk/webapp/fmprod/src/main/resources/logging.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: oodt/trunk/webapp/fmprod/src/main/webapp/META-INF/context.xml
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/webapp/META-INF/context.xml?rev=1517154&r1=1517153&r2=1517154&view=diff
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/webapp/META-INF/context.xml (original)
+++ oodt/trunk/webapp/fmprod/src/main/webapp/META-INF/context.xml Sat Aug 24 15:48:52 2013
@@ -22,6 +22,13 @@ the License.
   <Valve className="org.apache.catalina.valves.AccessLogValve"
     prefix="fmprod_access_log." suffix=".txt" pattern="common"/>
 
+  <Parameter name="filemgr.ns"
+    value="cas|urn:oodt:|rdf|http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+    override="false"/>
+
+  <Parameter name="filemgr.ns.default"
+    value="cas" override="false"/>
+
   <Parameter name="filemgr.url"
     value="[FILEMGR_URL]" override="false"/>
 

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=1517154&r1=1517153&r2=1517154&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 Sat Aug 24 15:48:52 2013
@@ -23,30 +23,6 @@
 
   <display-name>CAS Product Server</display-name>
 
-
-  <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>
-  </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>
@@ -92,7 +68,7 @@
   <servlet>
     <servlet-name>CXFServlet</servlet-name>
     <servlet-class>
-      org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet
+      org.apache.oodt.cas.product.service.servlets.CasProductJaxrsServlet
     </servlet-class>
     <init-param>
       <param-name>jaxrs.serviceClasses</param-name>
@@ -107,6 +83,7 @@
       <param-name>jaxrs.scope</param-name>
       <param-value>prototype</param-value>
     </init-param>
+    <load-on-startup>1</load-on-startup>
   </servlet>
 
 

Modified: 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=1517154&r1=1517153&r2=1517154&view=diff
==============================================================================
--- oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/resources/DatasetResourceTest.java (original)
+++ oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/resources/DatasetResourceTest.java Sat Aug 24 15:48:52 2013
@@ -17,17 +17,12 @@
 
 package org.apache.oodt.cas.product.service.resources;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
 
-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;
@@ -39,38 +34,13 @@ import org.junit.Test;
  */
 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.
+   * Starts up the web server.
    */
   @BeforeClass
-  public static void startWebServer()
+  public static void setUpBeforeClass()
   {
-    // 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);
+    startWebServer(new DatasetResource());
   }
 
 
@@ -79,11 +49,9 @@ public class DatasetResourceTest extends
    * Shuts down the web server.
    */
   @AfterClass
-  public static void stopWebServer()
+  public static void tearDownAfterClass()
   {
-    // Stop the server.
-    server.stop();
-    server.destroy();
+    stopWebServer();
   }
 
 
@@ -95,7 +63,7 @@ public class DatasetResourceTest extends
   @Test
   public void testGetZipResponseGenericFileDataset()
   {
-    WebClient client = WebClient.create("local://service");
+    WebClient client = WebClient.create(SERVER_URL);
     WebClient.getConfig(client).getRequestContext()
       .put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE);
     client.accept("application/zip");
@@ -121,7 +89,7 @@ public class DatasetResourceTest extends
   @Test
   public void testGetZipResponseLocationAwareDataset()
   {
-    WebClient client = WebClient.create("local://service");
+    WebClient client = WebClient.create(SERVER_URL);
     WebClient.getConfig(client).getRequestContext()
       .put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE);
     client.accept("application/zip");

Modified: oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/resources/ProductResourceTest.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/resources/ProductResourceTest.java?rev=1517154&r1=1517153&r2=1517154&view=diff
==============================================================================
--- oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/resources/ProductResourceTest.java (original)
+++ oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/resources/ProductResourceTest.java Sat Aug 24 15:48:52 2013
@@ -17,18 +17,13 @@
 
 package org.apache.oodt.cas.product.service.resources;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
 
-import javax.servlet.ServletContext;
 import javax.ws.rs.core.MediaType;
 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;
@@ -40,38 +35,13 @@ import org.junit.Test;
  */
 public class ProductResourceTest 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.
+   * Starts up the web server.
    */
   @BeforeClass
-  public static void startWebServer()
+  public static void setUpBeforeClass()
   {
-    // The JAX-RS resource to test.
-    ProductResource resource = new ProductResource();
-
-    // 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);
+    startWebServer(new ProductResource());
   }
 
 
@@ -80,11 +50,9 @@ public class ProductResourceTest extends
    * Shuts down the web server.
    */
   @AfterClass
-  public static void stopWebServer()
+  public static void tearDownAfterClass()
   {
-    // Stop the server.
-    server.stop();
-    server.destroy();
+    stopWebServer();
   }
 
 
@@ -97,7 +65,7 @@ public class ProductResourceTest extends
   public void testGetFileResponseFlatProduct()
   {
     String contentType = MediaType.TEXT_PLAIN;
-    WebClient client = WebClient.create("local://service");
+    WebClient client = WebClient.create(SERVER_URL);
     WebClient.getConfig(client).getRequestContext()
       .put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE);
     client.accept(contentType);
@@ -125,7 +93,7 @@ public class ProductResourceTest extends
   public void testGetFileResponseHierarchicalProduct()
   {
     String contentType = MediaType.TEXT_PLAIN;
-    WebClient client = WebClient.create("local://service");
+    WebClient client = WebClient.create(SERVER_URL);
     WebClient.getConfig(client).getRequestContext()
       .put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE);
     client.accept(contentType);
@@ -149,7 +117,7 @@ public class ProductResourceTest extends
   @Test
   public void testGetZipResponse()
   {
-    WebClient client = WebClient.create("local://service");
+    WebClient client = WebClient.create(SERVER_URL);
     WebClient.getConfig(client).getRequestContext()
       .put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE);
     client.accept("application/zip");
@@ -175,7 +143,7 @@ public class ProductResourceTest extends
   @Test
   public void testGetZipResponseDataUrl()
   {
-    WebClient client = WebClient.create("local://service");
+    WebClient client = WebClient.create(SERVER_URL);
     WebClient.getConfig(client).getRequestContext()
       .put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE);
     client.accept("application/zip");

Modified: oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/resources/ReferenceResourceTest.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/resources/ReferenceResourceTest.java?rev=1517154&r1=1517153&r2=1517154&view=diff
==============================================================================
--- oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/resources/ReferenceResourceTest.java (original)
+++ oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/resources/ReferenceResourceTest.java Sat Aug 24 15:48:52 2013
@@ -19,15 +19,10 @@ package org.apache.oodt.cas.product.serv
 
 import static org.junit.Assert.assertEquals;
 
-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;
@@ -39,37 +34,13 @@ import org.junit.Test;
  */
 public class ReferenceResourceTest 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.
+   * Starts up the web server.
    */
   @BeforeClass
-  public static void startWebServer()
+  public static void setUpBeforeClass()
   {
-    ReferenceResource resource = new ReferenceResource();
-
-    // 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);
+    startWebServer(new ReferenceResource());
   }
 
 
@@ -78,11 +49,9 @@ public class ReferenceResourceTest exten
    * Shuts down the web server.
    */
   @AfterClass
-  public static void stopWebServer()
+  public static void tearDownAfterClass()
   {
-    // Stop the server.
-    server.stop();
-    server.destroy();
+    stopWebServer();
   }
 
 
@@ -94,7 +63,7 @@ public class ReferenceResourceTest exten
   @Test
   public void testGetFileResponseFlatProduct()
   {
-    WebClient client = WebClient.create("local://service");
+    WebClient client = WebClient.create(SERVER_URL);
     WebClient.getConfig(client).getRequestContext()
       .put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE);
     client.accept("text/plain");
@@ -121,7 +90,7 @@ public class ReferenceResourceTest exten
   @Test
   public void testGetFileResponseHierarchicalProduct()
   {
-    WebClient client = WebClient.create("local://service");
+    WebClient client = WebClient.create(SERVER_URL);
     WebClient.getConfig(client).getRequestContext()
       .put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE);
     client.accept("text/plain");
@@ -145,7 +114,7 @@ public class ReferenceResourceTest exten
   @Test
   public void testGetDefaultResponseHierarchicalProduct()
   {
-    WebClient client = WebClient.create("local://service");
+    WebClient client = WebClient.create(SERVER_URL);
     WebClient.getConfig(client).getRequestContext()
       .put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE);
     client.accept("text/plain");
@@ -168,7 +137,7 @@ public class ReferenceResourceTest exten
   @Test
   public void testGetZipResponse()
   {
-    WebClient client = WebClient.create("local://service");
+    WebClient client = WebClient.create(SERVER_URL);
     WebClient.getConfig(client).getRequestContext()
       .put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE);
     client.accept("application/zip");

Modified: oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/resources/ResourceTestBase.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/resources/ResourceTestBase.java?rev=1517154&r1=1517153&r2=1517154&view=diff
==============================================================================
--- oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/resources/ResourceTestBase.java (original)
+++ oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/resources/ResourceTestBase.java Sat Aug 24 15:48:52 2013
@@ -19,17 +19,23 @@ package org.apache.oodt.cas.product.serv
 
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.net.URL;
 import java.util.Hashtable;
 
+import javax.servlet.ServletContext;
+
 import org.apache.commons.io.FileUtils;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
+import org.apache.cxf.transport.local.LocalTransportFactory;
 import org.apache.oodt.cas.filemgr.ingest.StdIngester;
 import org.apache.oodt.cas.filemgr.metadata.CoreMetKeys;
 import org.apache.oodt.cas.filemgr.structs.Product;
 import org.apache.oodt.cas.filemgr.system.XmlRpcFileManager;
+import org.apache.oodt.cas.filemgr.system.XmlRpcFileManagerClient;
 import org.apache.oodt.cas.metadata.Metadata;
 import org.apache.oodt.cas.metadata.SerializableMetadata;
+import org.easymock.EasyMock;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 
@@ -47,14 +53,27 @@ public class ResourceTestBase
   private static final int FM_PORT = 50001;
   private static final String FM_URL = "http://localhost:" + FM_PORT;
 
-  // The file manager.
+  // The URL of the web server.
+  protected static final String SERVER_URL = "local://service";
+
+  // The file manager and client.
   private static XmlRpcFileManager fileManager;
+  private static XmlRpcFileManagerClient client;
+
+  // The web server.
+  private static Server server;
+
+  // The file manager's catalog directory.
+  private static File catalogDir;
+
+  // The file manager's repository directory.
+  private static File repositoryDir;
 
-  // The location of the file manager's catalog.
-  private static String catalogLocation;
-  private static String repositoryLocation;
-  private static String workingDirLocation;
-  private static String logsLocation;
+  // The file manager's logs directory.
+  private static File logsDir;
+
+  // The file manager's working directory.
+  private static File workingDir;
 
   // The type of data transfer factory used by the ingester.
   private static final String TRANSFER_FACTORY =
@@ -68,25 +87,26 @@ public class ResourceTestBase
 
 
   /**
-   * Sets up a file manager and ingests test data into the file manager catalog.
+   * Sets up a file manager, ingests test data into the file manager's catalog
+   * and initializes a file manager client.
    * @throws Exception exceptions such as MalformedURLException, IOException
-   * and IngestException could occur when setting up the file manager and
-   * ingesting data.  Any such exception is considered an overall failure and
-   * is therefore propagated upwards for JUnit to handle
+   * and IngestException could occur when setting up the file manager and client
+   * and ingesting data.  Any such exception is considered an overall failure
+   * and is therefore propagated upwards for JUnit to handle
    */
   @BeforeClass
   public static void startUpFileManager() throws Exception
   {
-    startFileManager();
+    initializeFileManager();
     ingestTestData();
+    client = new XmlRpcFileManagerClient(new URL(FM_URL));
   }
 
 
 
   /**
-   * Shuts down the web server, stops the file manager and destroys the ingested
-   * test data.
-   * @throws Exception An IOException is thrown if the file manager catalog
+   * Stops the file manager and destroys the ingested test data.
+   * @throws Exception (IOException) if the file manager catalog
    * cannot be deleted.  This is considered an overall failure and so it is
    * propagated upwards for JUnit to handle
    */
@@ -97,53 +117,98 @@ public class ResourceTestBase
     fileManager.shutdown();
 
     // Destroy the ingested test data.
-    FileUtils.deleteDirectory(new File(catalogLocation));
+    FileUtils.deleteDirectory(catalogDir);
 
-    // Clean up the repository, workingDir and logs directories.
-    FileUtils.cleanDirectory(new File(repositoryLocation));
-    FileUtils.cleanDirectory(new File(workingDirLocation));
-    FileUtils.cleanDirectory(new File(logsLocation));
+    // Clean up the repository, logs and workingDir directories.
+    FileUtils.cleanDirectory(repositoryDir);
+    FileUtils.cleanDirectory(logsDir);
+    FileUtils.cleanDirectory(workingDir);
+  }
+
+
+
+  /**
+   * Starts a web server using the local transport protocol and uses a mock
+   * servlet context to inject context parameters into the JAX-RS resource
+   * under test.
+   * @param resource the resource to associate with the server and servlet
+   * context
+   */
+  public static void startWebServer(Resource resource)
+  {
+    // Create a web server for testing using local transport.
+    JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
+    sf.setTransportId(LocalTransportFactory.TRANSPORT_ID);
+    sf.setServiceBean(resource);
+    sf.setAddress(SERVER_URL);
+    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.getAttribute("client"))
+      .andReturn(getClient()).anyTimes();
+    EasyMock.expect(mockContext.getAttribute("workingDir"))
+      .andReturn(getWorkingDir()).anyTimes();
+    EasyMock.replay(mockContext);
+    resource.setServletContext(mockContext);
+  }
+
+
+
+  /**
+   * Shuts down the web server.
+   */
+  public static void stopWebServer()
+  {
+    // Stop the server.
+    server.stop();
+    server.destroy();
   }
 
 
 
   /**
    * Sets up and starts a file manager.
-   * @throws FileNotFoundException, IOException, Exception
+   * @throws Exception
    */
-  private static void startFileManager() throws Exception
+  private static void initializeFileManager() throws Exception
   {
-    catalogLocation = new File("./src/test/resources/filemgr/catalog")
-      .getCanonicalPath();
-    repositoryLocation = new File("./src/test/resources/filemgr/repository")
-      .getCanonicalPath();
-    workingDirLocation = new File("./src/test/resources/filemgr/workingDir")
-      .getCanonicalPath();
-    logsLocation = new File("./src/test/resources/filemgr/logs")
-      .getCanonicalPath();
+    String fileMgrDirLocation = "./src/test/resources/filemgr";
+
+    // Initialize file manager directories.
+    catalogDir = new File(new File(fileMgrDirLocation + "/catalog")
+      .getCanonicalPath());
+    repositoryDir = new File(new File(fileMgrDirLocation + "/repository")
+      .getCanonicalPath());
+    logsDir = new File(new File(fileMgrDirLocation + "/logs")
+      .getCanonicalPath());
+    workingDir = new File(new File(fileMgrDirLocation + "/workingDir")
+      .getCanonicalPath());
 
     // Set properties for the file manager.
-    FileInputStream fis = new FileInputStream(
-      "./src/test/resources/filemgr/etc/filemgr.properties");
+    FileInputStream fis = new FileInputStream(fileMgrDirLocation +
+      "/etc/filemgr.properties");
     System.getProperties().load(fis);
     fis.close();
 
     System.setProperty("java.util.logging.config.file",
-      new File("./src/test/resources/filemgr/etc/logging.properties")
+      new File(fileMgrDirLocation + "/etc/logging.properties")
         .getCanonicalPath());
     System.setProperty("org.apache.oodt.cas.filemgr.repositorymgr.dirs",
-      "file://" + new File("./src/test/resources/filemgr/policy/core")
+      "file://" + new File(fileMgrDirLocation + "/policy/core")
         .getCanonicalPath());
     System.setProperty("org.apache.oodt.cas.filemgr.validation.dirs",
-      "file://" + new File("./src/test/resources/filemgr/policy/core")
+      "file://" + new File(fileMgrDirLocation + "/policy/core")
         .getCanonicalPath());
     System.setProperty("org.apache.oodt.cas.filemgr.mime.type.repository",
-      new File("./src/test/resources/filemgr/etc/mime-types.xml")
+      new File(fileMgrDirLocation + "/etc/mime-types.xml")
         .getCanonicalPath());
     System.setProperty("filemgr.catalog.factory",
       "org.apache.oodt.cas.filemgr.catalog.LuceneCatalogFactory");
     System.setProperty("org.apache.oodt.cas.filemgr.catalog.lucene.idxPath",
-      catalogLocation);
+      catalogDir.getAbsolutePath());
 
     // Start the file manager.
     fileManager = new XmlRpcFileManager(FM_PORT);
@@ -152,15 +217,17 @@ public class ResourceTestBase
     // product-types.xml with a dynamically constructed repository location.
     Hashtable<String, Object> genericTypeHash = fileManager
       .getProductTypeByName("GenericFile");
-    genericTypeHash.put("repositoryPath", "file://" + repositoryLocation);
+    genericTypeHash.put("repositoryPath", "file://"
+      + repositoryDir.getAbsolutePath());
     fileManager.addProductType(genericTypeHash);
 
-
     // Overwrite the repository path for the LocationAwareProduct product type
-    // defined in product-types.xml with a dynamically constructed repository location.
+    // defined in product-types.xml with a dynamically constructed repository
+    // location.
     Hashtable<String, Object> locationAwareTypeHash = fileManager
       .getProductTypeByName("LocationAwareProduct");
-    locationAwareTypeHash.put("repositoryPath", "file://" + repositoryLocation);
+    locationAwareTypeHash.put("repositoryPath", "file://"
+      + repositoryDir.getAbsolutePath());
     fileManager.addProductType(locationAwareTypeHash);
   }
 
@@ -168,59 +235,53 @@ public class ResourceTestBase
 
   /**
    * Ingests test data into the file manager repository.
-   * @throws FileNotFoundException, IOException, MalformedURLException,
-   * IngestException
+   * @throws Exception
    */
   private static void ingestTestData() throws Exception
   {
-    StdIngester ingester = new StdIngester(TRANSFER_FACTORY);
-
     // Ingest a flat product of type GenericFile.
-    FileInputStream ffis = new FileInputStream(
-      "./src/test/resources/filemgr/ingest/flat/test.txt.met");
-    Metadata fMeta = new SerializableMetadata(ffis);
-    ffis.close();
-    fMeta.addMetadata(CoreMetKeys.FILE_LOCATION,
-      new File("./src/test/resources/filemgr/ingest/flat").getCanonicalPath());
-    fMeta.addMetadata(CoreMetKeys.FILENAME, "test.txt");
-    fMeta.addMetadata(CoreMetKeys.PRODUCT_TYPE, "GenericFile");
-    fMeta.addMetadata(CoreMetKeys.PRODUCT_STRUCTURE, Product.STRUCTURE_FLAT);
+    genericFileFlatProductId = ingestProduct(
+      "./src/test/resources/filemgr/ingest/flat", "test.txt",
+      "GenericFile", Product.STRUCTURE_FLAT);
 
-    genericFileFlatProductId = ingester.ingest(new URL(FM_URL),
-      new File("./src/test/resources/filemgr/ingest/flat/test.txt"), fMeta);
+    // Ingest a hierarchical product of type GenericFile.
+    genericFileHierarchicalProductId = ingestProduct(
+      "./src/test/resources/filemgr/ingest/hierarchical", "test",
+      "GenericFile", Product.STRUCTURE_HIERARCHICAL);
 
+    // Ingest a flat product of type LocationAwareProduct.
+    locationAwareFlatProductId = ingestProduct(
+      "./src/test/resources/filemgr/ingest/flat", "location.txt",
+      "LocationAwareProduct", Product.STRUCTURE_FLAT);
+  }
 
-    // Ingest a hierarchical product of type GenericFile.
-    FileInputStream hfis = new FileInputStream(
-      "./src/test/resources/filemgr/ingest/hierarchical/test.met");
-    Metadata hMeta = new SerializableMetadata(hfis);
-    hfis.close();
-    hMeta.addMetadata(CoreMetKeys.FILE_LOCATION,
-      new File("./src/test/resources/filemgr/ingest/hierarchical")
-        .getCanonicalPath());
-    hMeta.addMetadata(CoreMetKeys.FILENAME, "test");
-    hMeta.addMetadata(CoreMetKeys.PRODUCT_TYPE, "GenericFile");
-    hMeta.addMetadata(CoreMetKeys.PRODUCT_STRUCTURE,
-      Product.STRUCTURE_HIERARCHICAL);
-
-    genericFileHierarchicalProductId = ingester.ingest(new URL(FM_URL),
-      new File("./src/test/resources/filemgr/ingest/hierarchical/test"),
-        hMeta);
 
 
-    // Ingest a flat product of type LocationAwareProduct.
-    FileInputStream lfis = new FileInputStream(
-      "./src/test/resources/filemgr/ingest/flat/location.txt.met");
-    Metadata lMeta = new SerializableMetadata(lfis);
-    lfis.close();
-    lMeta.addMetadata(CoreMetKeys.FILE_LOCATION,
-      new File("./src/test/resources/filemgr/ingest/flat").getCanonicalPath());
-    lMeta.addMetadata(CoreMetKeys.FILENAME, "location.txt");
-    lMeta.addMetadata(CoreMetKeys.PRODUCT_TYPE, "LocationAwareProduct");
-    lMeta.addMetadata(CoreMetKeys.PRODUCT_STRUCTURE, Product.STRUCTURE_FLAT);
+  /**
+   * Creates a product with associated metadata and ingests it into the file
+   * manager's repository.
+   * @param productBaseDir the directory containing the product's file(s)
+   * @param productName the product's name
+   * @param productType the product's type, e.g. GenericFile
+   * @param productStructure the product's structure, i.e. flat or hierarchical
+   * @return the ID of the ingested product
+   * @throws Exception
+   */
+  private static String ingestProduct(String productBaseDir, String productName,
+    String productType, String productStructure) throws Exception
+  {
+    FileInputStream fis = new FileInputStream(productBaseDir + "/" + productName
+      + ".met");
+    Metadata meta = new SerializableMetadata(fis);
+    fis.close();
+    meta.addMetadata(CoreMetKeys.FILE_LOCATION,
+      new File(productBaseDir).getCanonicalPath());
+    meta.addMetadata(CoreMetKeys.FILENAME, productName);
+    meta.addMetadata(CoreMetKeys.PRODUCT_TYPE, productType);
+    meta.addMetadata(CoreMetKeys.PRODUCT_STRUCTURE, productStructure);
 
-    locationAwareFlatProductId = ingester.ingest(new URL(FM_URL),
-      new File("./src/test/resources/filemgr/ingest/flat/location.txt"), lMeta);
+    return new StdIngester(TRANSFER_FACTORY).ingest(new URL(FM_URL),
+      new File(productBaseDir + "/" + productName), meta);
   }
 
 
@@ -248,7 +309,7 @@ public class ResourceTestBase
 
 
   /**
-   * Gets the product ID for the flat product of type Location Aware Product.
+   * Gets the product ID for the flat product of type LocationAwareProduct.
    * @return the locationAwareFlatProductId
    */
   public static String getLocationAwareFlatProductId()
@@ -259,22 +320,22 @@ public class ResourceTestBase
 
 
   /**
-   * Gets the file manager's URL.
-   * @return the file manager's URL.
+   * Gets the file manager client.
+   * @return the file manager client
    */
-  public static String getFileManagerUrl()
+  public static XmlRpcFileManagerClient getClient()
   {
-    return FM_URL;
+    return client;
   }
 
 
 
   /**
-   * Gets the file manager's working directory location.
-   * @return the file manager's working directory location
+   * Gets the file manager's working directory.
+   * @return the file manager's working directory
    */
-  public static String getWorkingDirLocation()
+  public static File getWorkingDir()
   {
-    return workingDirLocation;
+    return workingDir;
   }
 }

Modified: oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/FileResponderTest.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/FileResponderTest.java?rev=1517154&r1=1517153&r2=1517154&view=diff
==============================================================================
--- oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/FileResponderTest.java (original)
+++ oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/FileResponderTest.java Sat Aug 24 15:48:52 2013
@@ -41,7 +41,8 @@ import org.junit.Test;
 public class FileResponderTest
 {
   /**
-   * Tests the {@link Response} returned by the createResponse method when a
+   * Tests the {@link Response} returned by the
+   * {@link FileResponder#createResponse createResponse} method when a
    * {@link ReferenceResource} is supplied as the argument, where the reference
    * has both a file extension and a MIME type.
    * @throws Exception (IOException) if getCanonicalPath fails.  This would be
@@ -73,7 +74,8 @@ public class FileResponderTest
 
 
   /**
-   * Tests the {@link Response} returned by the createResponse method when a
+   * Tests the {@link Response} returned by the
+   * {@link FileResponder#createResponse createResponse} method when a
    * {@link ReferenceResource} is supplied as the argument, where the reference
    * has a file extension but no MIME type.
    * @throws Exception (IOException) if getCanonicalPath fails.  This would be
@@ -104,7 +106,8 @@ public class FileResponderTest
 
 
   /**
-   * Tests the {@link Response} returned by the createResponse method when a
+   * Tests the {@link Response} returned by the
+   * {@link FileResponder#createResponse createResponse} method when a
    * {@link ReferenceResource} is supplied as the argument, where the reference
    * has a MIME type but no file extension.
    * @throws Exception (IOException) if getCanonicalPath fails.  This would be
@@ -136,7 +139,8 @@ public class FileResponderTest
 
 
   /**
-   * Tests the {@link Response} returned by the createResponse method when a
+   * Tests the {@link Response} returned by the
+   * {@link FileResponder#createResponse createResponse} method when a
    * {@link ReferenceResource} is supplied as the argument, where the reference
    * has neither a MIME type nor a file extension.
    * @throws Exception (IOException) if getCanonicalPath fails.  This would be
@@ -169,8 +173,8 @@ public class FileResponderTest
 
   /**
    * Tests the status code and content of the {@link Response} returned by the
-   * createResponse method when a {@link ProductResource} is supplied as the
-   * argument.
+   * {@link FileResponder#createResponse createResponse} method when a
+   * {@link ProductResource} is supplied as the argument.
    * @throws Exception (IOException) if getCanonicalPath fails.  This would be
    * considered a test failure, so it is propagated upwards for JUnit to handle
    */
@@ -223,8 +227,9 @@ public class FileResponderTest
 
   /**
    * Tests the status code and message of the {@link Response} returned by the
-   * createResponse method when a {@link ProductResource} is supplied as the
-   * argument and the requested reference does not exist.
+   * {@link FileResponder#createResponse createResponse} method when a
+   * {@link ProductResource} is supplied as the argument and the requested
+   * reference does not exist.
    */
   @Test
   public void testCreateResponseProductResourceNoReferences()
@@ -254,8 +259,8 @@ public class FileResponderTest
 
   /**
    * Tests the status code and message of the {@link Response} returned by the
-   * createResponse method when a {@link DatasetResource} is supplied as the
-   * argument.
+   * {@link FileResponder#createResponse createResponse} method when a
+   * {@link DatasetResource} is supplied as the argument.
    */
   @Test
   public void testCreateResponseDatasetResource()
@@ -272,8 +277,8 @@ public class FileResponderTest
 
   /**
    * Tests the status code and message of the {@link Response} returned by the
-   * createResponse method when a {@link TransferResource} is supplied as the
-   * argument.
+   * {@link FileResponder#createResponse createResponse} method when a
+   * {@link TransferResource} is supplied as the argument.
    */
   @Test
   public void testCreateResponseTransferResource()

Modified: oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/NullResponderTest.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/NullResponderTest.java?rev=1517154&r1=1517153&r2=1517154&view=diff
==============================================================================
--- oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/NullResponderTest.java (original)
+++ oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/NullResponderTest.java Sat Aug 24 15:48:52 2013
@@ -36,8 +36,8 @@ public class NullResponderTest
 {
   /**
    * Tests the status code of the {@link Response} returned by the
-   * createResponse method when a {@link ReferenceResource} is supplied as the
-   * argument.
+   * {@link NullResponder#createResponse createResponse} method when a
+   * {@link ReferenceResource} is supplied as the argument.
    */
   @Test
   public void testCreateResponseReferenceResource()
@@ -53,8 +53,8 @@ public class NullResponderTest
 
   /**
    * Tests the status code of the {@link Response} returned by the
-   * createResponse method when a {@link ProductResource} is supplied as the
-   * argument.
+   * {@link NullResponder#createResponse createResponse} method when a
+   * {@link ProductResource} is supplied as the argument.
    */
   @Test
   public void testCreateResponseProductResource()
@@ -70,8 +70,8 @@ public class NullResponderTest
 
   /**
    * Tests the status code of the {@link Response} returned by the
-   * createResponse method when a {@link DatasetResource} is supplied as the
-   * argument.
+   * {@link NullResponder#createResponse createResponse} method when a
+   * {@link DatasetResource} is supplied as the argument.
    */
   @Test
   public void testCreateResponseDatasetResource()
@@ -87,8 +87,8 @@ public class NullResponderTest
 
   /**
    * Tests the status code of the {@link Response} returned by the
-   * createResponse method when a {@link TransferResource} is supplied as the
-   * argument.
+   * {@link NullResponder#createResponse createResponse} method when a
+   * {@link TransferResource} is supplied as the argument.
    */
   @Test
   public void testCreateResponseTransferResource()

Modified: oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/ResponderFactoryTest.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/ResponderFactoryTest.java?rev=1517154&r1=1517153&r2=1517154&view=diff
==============================================================================
--- oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/ResponderFactoryTest.java (original)
+++ oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/ResponderFactoryTest.java Sat Aug 24 15:48:52 2013
@@ -29,8 +29,9 @@ import org.junit.Test;
 public class ResponderFactoryTest
 {
   /**
-   * Tests that the createResponder method returns a {@link NullResponder} when
-   * null is supplied as the argument.
+   * Tests that the {@link ResponderFactory#createResponder createResponder}
+   * method returns a {@link NullResponder} when null is supplied as the
+   * argument.
    */
   @Test
   public void testCreateNullResponder()
@@ -42,9 +43,9 @@ public class ResponderFactoryTest
 
 
   /**
-   * Tests that the createResponder method returns an
-   * {@link UnrecognizedFormatResponder} when an unrecognized string is supplied
-   * as the argument.
+   * Tests that the {@link ResponderFactory#createResponder createResponder}
+   * method returns an {@link UnrecognizedFormatResponder} when an unrecognized
+   * string is supplied as the argument.
    */
   @Test
   public void testCreateUnrecognizedFormatResponder()
@@ -57,8 +58,9 @@ public class ResponderFactoryTest
 
 
   /**
-   * Tests that the createResponder method returns a {@link FileResponder} when
-   * "file" is supplied as the argument.
+   * Tests that the {@link ResponderFactory#createResponder createResponder}
+   * method returns a {@link FileResponder} when "file" is supplied as the
+   * argument.
    */
   @Test
   public void testCreateFileResponder()
@@ -70,8 +72,9 @@ public class ResponderFactoryTest
 
 
   /**
-   * Tests that the createResponder method returns a {@link ZipResponder} when
-   * "zip" is supplied as the argument.
+   * Tests that the {@link ResponderFactory#createResponder createResponder}
+   * method returns a {@link ZipResponder} when "zip" is supplied as the
+   * argument.
    */
   @Test
   public void testCreateZipResponder()

Modified: oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/UnrecognizedFormatResponderTest.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/UnrecognizedFormatResponderTest.java?rev=1517154&r1=1517153&r2=1517154&view=diff
==============================================================================
--- oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/UnrecognizedFormatResponderTest.java (original)
+++ oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/UnrecognizedFormatResponderTest.java Sat Aug 24 15:48:52 2013
@@ -37,8 +37,8 @@ public class UnrecognizedFormatResponder
 {
   /**
    * Tests the status code of the {@link Response} returned by the
-   * createResponse method when a {@link ReferenceResource} is supplied as the
-   * argument.
+   * {@link UnrecognizedFormatResponder#createResponse createResponse} method
+   * when a {@link ReferenceResource} is supplied as the argument.
    */
   @Test
   public void testCreateResponseReferenceResource()
@@ -54,8 +54,8 @@ public class UnrecognizedFormatResponder
 
   /**
    * Tests the status code of the {@link Response} returned by the
-   * createResponse method when a {@link ProductResource} is supplied as the
-   * argument.
+   * {@link UnrecognizedFormatResponder#createResponse createResponse} method
+   * when a {@link ProductResource} is supplied as the argument.
    */
   @Test
   public void testCreateResponseProductResource()
@@ -71,8 +71,8 @@ public class UnrecognizedFormatResponder
 
   /**
    * Tests the status code of the {@link Response} returned by the
-   * createResponse method when a {@link DatasetResource} is supplied as the
-   * argument.
+   * {@link UnrecognizedFormatResponder#createResponse createResponse} method
+   * when a {@link DatasetResource} is supplied as the argument.
    */
   @Test
   public void testCreateResponseDatasetResource()
@@ -88,8 +88,8 @@ public class UnrecognizedFormatResponder
 
   /**
    * Tests the status code of the {@link Response} returned by the
-   * createResponse method when a {@link TransferResource} is supplied as the
-   * argument.
+   * {@link UnrecognizedFormatResponder#createResponse createResponse} method
+   * when a {@link TransferResource} is supplied as the argument.
    */
   @Test
   public void testCreateResponseTransferResource()

Modified: oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/ZipResponderTest.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/ZipResponderTest.java?rev=1517154&r1=1517153&r2=1517154&view=diff
==============================================================================
--- oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/ZipResponderTest.java (original)
+++ oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/responders/ZipResponderTest.java Sat Aug 24 15:48:52 2013
@@ -48,8 +48,8 @@ public class ZipResponderTest
 {
   /**
    * Tests the status code and message of the {@link Response} returned by the
-   * createResponse method when a {@link ReferenceResource} is supplied as the
-   * argument.
+   * {@link ZipResponder#createResponse createResponse} method when a
+   * {@link ReferenceResource} is supplied as the argument.
    * @throws Exception (IOException) and this would be considered a test
    * failure, so it's propagated upwards for JUnit to handle
    */
@@ -66,7 +66,7 @@ public class ZipResponderTest
 
     ReferenceResource resource = new ReferenceResource();
     resource.setReference(reference);
-    resource.setWorkingDirPath(workingDir.getCanonicalPath());
+    resource.setWorkingDir(new File(workingDir.getCanonicalPath()));
 
     Responder responder = new ZipResponder();
     Response response = responder.createResponse(resource);
@@ -85,8 +85,8 @@ public class ZipResponderTest
 
   /**
    * Tests the status code and message of the {@link Response} returned by the
-   * createResponse method when a {@link ReferenceResource} is supplied as the
-   * argument.
+   * {@link ZipResponder#createResponse createResponse} method when a
+   * {@link ReferenceResource} is supplied as the argument.
    * @throws Exception (IOException) and this would be considered a test
    * failure, so it's propagated upwards for JUnit to handle
    */
@@ -103,7 +103,7 @@ public class ZipResponderTest
 
     ReferenceResource resource = new ReferenceResource();
     resource.setReference(reference);
-    resource.setWorkingDirPath(workingDir.getCanonicalPath());
+    resource.setWorkingDir(new File(workingDir.getCanonicalPath()));
 
     Responder responder = new ZipResponder();
     Response response = responder.createResponse(resource);
@@ -122,8 +122,8 @@ public class ZipResponderTest
 
   /**
    * Tests the status code and message of the {@link Response} returned by the
-   * createResponse method when a {@link ProductResource} is supplied as the
-   * argument.
+   * {@link ZipResponder#createResponse createResponse} method when a
+   * {@link ProductResource} is supplied as the argument.
    * @throws Exception (FileNotFoundException, IOException, ZipException) and
    * any of these would be considered test failures, so they're propagated
    * upwards for JUnit to handle
@@ -161,7 +161,7 @@ public class ZipResponderTest
     ProductResource resource = new ProductResource();
     resource.setProduct(product);
     resource.setMetadata(metadata);
-    resource.setWorkingDirPath(workingDir.getCanonicalPath());
+    resource.setWorkingDir(new File(workingDir.getCanonicalPath()));
 
     // Test the response.
     Responder responder = new ZipResponder();
@@ -181,8 +181,8 @@ public class ZipResponderTest
 
   /**
    * Tests the status code and message of the {@link Response} returned by the
-   * createResponse method when a {@link ProductResource} is supplied as the
-   * argument.
+   * {@link ZipResponder#createResponse createResponse} method when a
+   * {@link ProductResource} is supplied as the argument.
    * @throws Exception (FileNotFoundException, IOException, ZipException) and
    * any of these would be considered test failures, so they're propagated
    * upwards for JUnit to handle
@@ -224,7 +224,7 @@ public class ZipResponderTest
     ProductResource resource = new ProductResource();
     resource.setProduct(product);
     resource.setMetadata(metadata);
-    resource.setWorkingDirPath(workingDir.getCanonicalPath());
+    resource.setWorkingDir(new File(workingDir.getCanonicalPath()));
 
     // Test the response.
     Responder responder = new ZipResponder();
@@ -244,8 +244,8 @@ public class ZipResponderTest
 
   /**
    * Tests the status code and message of the {@link Response} returned by the
-   * createResponse method when a {@link DatasetResource} is supplied as the
-   * argument.
+   * {@link ZipResponder#createResponse createResponse} method when a
+   * {@link DatasetResource} is supplied as the argument.
    * @throws Exception (FileNotFoundException, IOException, ZipException) and
    * any of these would be considered test failures, so they're propagated
    * upwards for JUnit to handle
@@ -314,13 +314,13 @@ public class ZipResponderTest
     // Create a dataset resource and add the products to it.
     DatasetResource resource = new DatasetResource();
     resource.setProductType(productType);
-    resource.setWorkingDirPath(workingDir.getCanonicalPath());
-    String productDirPath = resource.getWorkingDirPath() + "/"
-      + productType.getName();
+    String workingDirPath = workingDir.getCanonicalPath();
+    resource.setWorkingDir(new File(workingDirPath));
+    File productDir = new File(workingDirPath + "/" + productType.getName());
 
     List<ProductResource> resources = new ArrayList<ProductResource>();
-    resources.add(new ProductResource(hProd, hMeta, productDirPath));
-    resources.add(new ProductResource(fProd, fMeta, productDirPath));
+    resources.add(new ProductResource(hProd, hMeta, productDir));
+    resources.add(new ProductResource(fProd, fMeta, productDir));
     resource.setProductResources(resources);
 
     // Test the zip response for the dataset product.
@@ -341,8 +341,8 @@ public class ZipResponderTest
 
   /**
    * Tests the status code and message of the {@link Response} returned by the
-   * createResponse method when a {@link TransferResource} is supplied as the
-   * argument.
+   * {@link ZipResponder#createResponse createResponse} method when a
+   * {@link TransferResource} is supplied as the argument.
    */
   @Test
   public void testCreateResponseTransferResource()

Modified: oodt/trunk/webapp/fmprod/src/test/resources/filemgr/policy/core/product-types.xml
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/test/resources/filemgr/policy/core/product-types.xml?rev=1517154&r1=1517153&r2=1517154&view=diff
==============================================================================
--- oodt/trunk/webapp/fmprod/src/test/resources/filemgr/policy/core/product-types.xml (original)
+++ oodt/trunk/webapp/fmprod/src/test/resources/filemgr/policy/core/product-types.xml Sat Aug 24 15:48:52 2013
@@ -1,13 +1,29 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<cas:producttypes xmlns:cas="http://oodt.jpl.nasa.gov/1.0/cas">
-<type id="urn:oodt:GenericFile" name="GenericFile">
-<description>The default product type for any kind of file.</description>
-<repository path="file:///usr/local/src/oodt/webapp/fmprod/src/test/resources/filemgr/repository"/>
-<versioner class="org.apache.oodt.cas.filemgr.versioning.BasicVersioner"/>
-</type>
-<type id="urn:oodt:LocationAwareProduct" name="LocationAwareProduct">
-<description>A product type with location metadata.</description>
-<repository path="file:///usr/local/src/oodt/webapp/fmprod/src/test/resources/filemgr/repository"/>
-<versioner class="org.apache.oodt.cas.filemgr.versioning.BasicVersioner"/>
-</type>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<cas:producttypes xmlns:cas="http://oodt.apache.org/ns/cas">
+  <type id="urn:oodt:GenericFile" name="GenericFile">
+    <description>The default product type for any kind of file.</description>
+    <repository path="file:///path/to/filemgr/repository"/>
+    <versioner class="org.apache.oodt.cas.filemgr.versioning.BasicVersioner"/>
+  </type>
+  <type id="urn:oodt:LocationAwareProduct" name="LocationAwareProduct">
+    <description>A product type with location metadata.</description>
+    <repository path="file:///path/to/filemgr/repository"/>
+    <versioner class="org.apache.oodt.cas.filemgr.versioning.BasicVersioner"/>
+  </type>
 </cas:producttypes>



Mime
View raw message