You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by ma...@apache.org on 2015/11/04 13:19:08 UTC

[5/6] oodt git commit: OODT-917 alter XMLRPC interface to support more generic map types where suitable

http://git-wip-us.apache.org/repos/asf/oodt/blob/8705ccf4/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java
----------------------------------------------------------------------
diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java
index e5ad57b..8c78434 100644
--- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java
+++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java
@@ -56,7 +56,6 @@ import org.apache.xmlrpc.WebServer;
 
 import com.google.common.collect.Lists;
 
-
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
@@ -80,206 +79,205 @@ import java.util.logging.Logger;
  * @author mattmann
  * @author bfoster
  * @version $Revision$
- * 
- * <p>
- * An XML RPC-based File manager.
- * </p>
- * 
+ *          <p/>
+ *          <p> An XML RPC-based File manager. </p>
  */
 public class XmlRpcFileManager {
 
-    /* the port to run the XML RPC web server on, default is 1999 */
-    private int webServerPort = 1999;
-
-    /* our Catalog */
-    private Catalog catalog = null;
-
-    /* our RepositoryManager */
-    private RepositoryManager repositoryManager = null;
-
-    /* our DataTransfer */
-    private DataTransfer dataTransfer = null;
-
-    /* our log stream */
-    private static final Logger LOG = Logger.getLogger(XmlRpcFileManager.class.getName());
-
-    /* our xml rpc web server */
-    private WebServer webServer = null;
-
-    /* our data transfer status tracker */
-    private TransferStatusTracker transferStatusTracker = null;
-    
-    /* whether or not to expand a product instance into met */
-    private boolean expandProductMet;
-    
-    /**
-     * <p>
-     * Creates a new XmlRpcFileManager with the given metadata store factory,
-     * and the given data store factory, on the given port.
-     * </p>
-     * 
-     * @param port
-     *            The web server port to run the XML Rpc server on, defaults to
-     *            1999.
-     */
-    public XmlRpcFileManager(int port) throws IOException {
-        webServerPort = port;
-
-        // start up the web server
-        webServer = new WebServer(webServerPort);
-        webServer.addHandler("filemgr", this);
-        webServer.start();
-
-        this.loadConfiguration();
-        LOG.log(Level.INFO, "File Manager started by "
-                + System.getProperty("user.name", "unknown"));
+  /* the port to run the XML RPC web server on, default is 1999 */
+  private int webServerPort = 1999;
 
-    }
-    
-    public void setCatalog(Catalog catalog) {
-        this.catalog = catalog;
-    }
+  /* our Catalog */
+  private Catalog catalog = null;
 
-    public boolean isAlive() {
-        return true;
-    }
-    
-    public boolean refreshConfigAndPolicy() {
-      boolean status = false;
+  /* our RepositoryManager */
+  private RepositoryManager repositoryManager = null;
 
-      try {
-        this.loadConfiguration();
-        status = true;
-      } catch (Exception e) {
-        LOG.log(Level.SEVERE, e.getMessage());
-        LOG
-            .log(
-                Level.SEVERE,
-                "Unable to refresh configuration for file manager " +
-                "server: server may be in inoperable state: Message: "
-                    + e.getMessage());
-      }
-  
-      return status;
+  /* our DataTransfer */
+  private DataTransfer dataTransfer = null;
+
+  /* our log stream */
+  private static final Logger LOG = Logger.getLogger(XmlRpcFileManager.class.getName());
+
+  /* our xml rpc web server */
+  private WebServer webServer = null;
+
+  /* our data transfer status tracker */
+  private TransferStatusTracker transferStatusTracker = null;
+
+  /* whether or not to expand a product instance into met */
+  private boolean expandProductMet;
+
+  /**
+   * <p> Creates a new XmlRpcFileManager with the given metadata store factory, and the given data store factory, on the
+   * given port. </p>
+   *
+   * @param port The web server port to run the XML Rpc server on, defaults to 1999.
+   */
+  public XmlRpcFileManager(int port) throws IOException {
+    webServerPort = port;
+
+    // start up the web server
+    webServer = new WebServer(webServerPort);
+    webServer.addHandler("filemgr", this);
+    webServer.start();
+
+    this.loadConfiguration();
+    LOG.log(Level.INFO, "File Manager started by "
+                        + System.getProperty("user.name", "unknown"));
+
+  }
+
+  public void setCatalog(Catalog catalog) {
+    this.catalog = catalog;
+  }
+
+  public boolean isAlive() {
+    return true;
+  }
+
+  public boolean refreshConfigAndPolicy() {
+    boolean status = false;
+
+    try {
+      this.loadConfiguration();
+      status = true;
+    } catch (Exception e) {
+      LOG.log(Level.SEVERE, e.getMessage());
+      LOG
+          .log(
+              Level.SEVERE,
+              "Unable to refresh configuration for file manager " +
+              "server: server may be in inoperable state: Message: "
+              + e.getMessage());
     }
 
+    return status;
+  }
+
   public boolean transferringProduct(Hashtable<String, Object> productHash) {
     return this.transferringProductCore(productHash);
   }
 
   public boolean transferringProductCore(Map<String, Object> productHash) {
-        Product p = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
-        transferStatusTracker.transferringProduct(p);
-        return true;
-    }
+    Product p = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
+    transferStatusTracker.transferringProduct(p);
+    return true;
+  }
 
-    public Map<String, Object> getCurrentFileTransferCore() {
-        FileTransferStatus status = transferStatusTracker
-                .getCurrentFileTransfer();
-        if (status == null) {
-            return new ConcurrentHashMap<String, Object>();
-        } else {
-          return XmlRpcStructFactory.getXmlRpcFileTransferStatus(status);
-        }
+  public Map<String, Object> getCurrentFileTransferCore() {
+    FileTransferStatus status = transferStatusTracker
+        .getCurrentFileTransfer();
+    if (status == null) {
+      return new ConcurrentHashMap<String, Object>();
+    } else {
+      return XmlRpcStructFactory.getXmlRpcFileTransferStatus(status);
     }
+  }
 
-    public List<Map<String, Object>> getCurrentFileTransfers() {
-        List<FileTransferStatus> currentTransfers = transferStatusTracker.getCurrentFileTransfers();
+  public List<Map<String, Object>> getCurrentFileTransfers() {
+    List<FileTransferStatus> currentTransfers = transferStatusTracker.getCurrentFileTransfers();
 
-        if (currentTransfers != null && currentTransfers.size() > 0) {
-            return XmlRpcStructFactory
-                    .getXmlRpcFileTransferStatuses(currentTransfers);
-        } else {
-          return new Vector<Map<String, Object>>();
-        }
+    if (currentTransfers != null && currentTransfers.size() > 0) {
+      return XmlRpcStructFactory
+          .getXmlRpcFileTransferStatuses(currentTransfers);
+    } else {
+      return new Vector<Map<String, Object>>();
     }
+  }
 
   public double getProductPctTransferred(Hashtable<String, Object> productHash) {
     return this.getProductPctTransferredCore(productHash);
   }
-    public double getProductPctTransferredCore(Map<String, Object> productHash) {
-        Product product = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
-      return transferStatusTracker.getPctTransferred(product);
-    }
+
+  public double getProductPctTransferredCore(Map<String, Object> productHash) {
+    Product product = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
+    return transferStatusTracker.getPctTransferred(product);
+  }
 
   public double getRefPctTransferred(Hashtable<String, Object> refHash) {
     return getRefPctTransferredCore(refHash);
   }
-    public double getRefPctTransferredCore(Map<String, Object> refHash) {
-        Reference reference = XmlRpcStructFactory
-                .getReferenceFromXmlRpc(refHash);
-        double pct = 0.0;
 
-        try {
-            pct = transferStatusTracker.getPctTransferred(reference);
-        } catch (Exception e) {
-            LOG.log(Level.SEVERE, e.getMessage());
-            LOG.log(Level.WARNING,
-                    "Exception getting transfer percentage for ref: ["
-                            + reference.getOrigReference() + "]: Message: "
-                            + e.getMessage());
-        }
-        return pct;
+  public double getRefPctTransferredCore(Map<String, Object> refHash) {
+    Reference reference = XmlRpcStructFactory
+        .getReferenceFromXmlRpc(refHash);
+    double pct = 0.0;
+
+    try {
+      pct = transferStatusTracker.getPctTransferred(reference);
+    } catch (Exception e) {
+      LOG.log(Level.SEVERE, e.getMessage());
+      LOG.log(Level.WARNING,
+          "Exception getting transfer percentage for ref: ["
+          + reference.getOrigReference() + "]: Message: "
+          + e.getMessage());
     }
+    return pct;
+  }
 
   public boolean removeProductTransferStatus(Hashtable<String, Object> productHash) {
     return removeProductTransferStatusCore(productHash);
   }
-    public boolean removeProductTransferStatusCore(Map<String, Object> productHash) {
-        Product product = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
-        transferStatusTracker.removeProductTransferStatus(product);
-        return true;
-    }
+
+  public boolean removeProductTransferStatusCore(Map<String, Object> productHash) {
+    Product product = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
+    transferStatusTracker.removeProductTransferStatus(product);
+    return true;
+  }
+
   public boolean isTransferComplete(Hashtable<String, Object> productHash) {
     return this.isTransferCompleteCore(productHash);
   }
-    public boolean isTransferCompleteCore(Map<String, Object> productHash) {
-        Product product = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
-        return transferStatusTracker.isTransferComplete(product);
-    }
+
+  public boolean isTransferCompleteCore(Map<String, Object> productHash) {
+    Product product = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
+    return transferStatusTracker.isTransferComplete(product);
+  }
+
   public Map<String, Object> pagedQuery(
       Hashtable<String, Object> queryHash,
       Hashtable<String, Object> productTypeHash,
       int pageNum) throws CatalogException {
-  return this.pagedQueryCore(queryHash,productTypeHash,pageNum);
+    return this.pagedQueryCore(queryHash, productTypeHash, pageNum);
   }
 
-    public Map<String, Object> pagedQueryCore(
-            Map<String, Object> queryHash,
-            Map<String, Object> productTypeHash,
-            int pageNum) throws CatalogException {
-        ProductType type = XmlRpcStructFactory
-                .getProductTypeFromXmlRpc(productTypeHash);
-        Query query = XmlRpcStructFactory.getQueryFromXmlRpcMap(queryHash);
-
-        ProductPage prodPage;
+  public Map<String, Object> pagedQueryCore(
+      Map<String, Object> queryHash,
+      Map<String, Object> productTypeHash,
+      int pageNum) throws CatalogException {
+    ProductType type = XmlRpcStructFactory
+        .getProductTypeFromXmlRpc(productTypeHash);
+    Query query = XmlRpcStructFactory.getQueryFromXmlRpc(queryHash);
 
-        try {
-            prodPage = catalog.pagedQuery(this.getCatalogQuery(query, type), type, pageNum);
-
-            if (prodPage == null) {
-                prodPage = ProductPage.blankPage();
-            } else {
-                // it is possible here that the underlying catalog did not
-                // set the ProductType
-                // to obey the contract of the File Manager, we need to make
-                // sure its set here
-                setProductType(prodPage.getPageProducts());
-            }
-        } catch (Exception e) {
-            LOG.log(Level.SEVERE, e.getMessage());
-            LOG.log(Level.WARNING,
-                    "Catalog exception performing paged query for product type: ["
-                            + type.getProductTypeId() + "] query: [" + query
-                            + "]: Message: " + e.getMessage());
-            throw new CatalogException(e.getMessage(), e);
-        }
+    ProductPage prodPage;
 
-        return XmlRpcStructFactory.getXmlRpcProductPage(prodPage);
+    try {
+      prodPage = catalog.pagedQuery(this.getCatalogQuery(query, type), type, pageNum);
+
+      if (prodPage == null) {
+        prodPage = ProductPage.blankPage();
+      } else {
+        // it is possible here that the underlying catalog did not
+        // set the ProductType
+        // to obey the contract of the File Manager, we need to make
+        // sure its set here
+        setProductType(prodPage.getPageProducts());
+      }
+    } catch (Exception e) {
+      LOG.log(Level.SEVERE, e.getMessage());
+      LOG.log(Level.WARNING,
+          "Catalog exception performing paged query for product type: ["
+          + type.getProductTypeId() + "] query: [" + query
+          + "]: Message: " + e.getMessage());
+      throw new CatalogException(e.getMessage(), e);
     }
 
+    return XmlRpcStructFactory.getXmlRpcProductPage(prodPage);
+  }
+
   public Map<String, Object> getFirstPage(
-      Hashtable<String, Object> productTypeHash){
+      Hashtable<String, Object> productTypeHash) {
     return this.getFirstPageCore(productTypeHash);
   }
 
@@ -300,82 +298,86 @@ public class XmlRpcFileManager {
 
 
   public Map<String, Object> getLastPage(
-      Hashtable<String, Object> productTypeHash){
+      Hashtable<String, Object> productTypeHash) {
     return this.getLastPageCore(productTypeHash);
   }
-    public Map<String, Object> getLastPageCore(
-            Map<String, Object> productTypeHash) {
-        ProductType type = XmlRpcStructFactory
-                .getProductTypeFromXmlRpc(productTypeHash);
-        ProductPage page = catalog.getLastProductPage(type);
-        try {
-            setProductType(page.getPageProducts());
-        } catch (Exception e) {
-            LOG.log(Level.WARNING,
-                    "Unable to set product types for product page list: ["
-                            + page + "]");
-        }
-        return XmlRpcStructFactory.getXmlRpcProductPage(page);
+
+  public Map<String, Object> getLastPageCore(
+      Map<String, Object> productTypeHash) {
+    ProductType type = XmlRpcStructFactory
+        .getProductTypeFromXmlRpc(productTypeHash);
+    ProductPage page = catalog.getLastProductPage(type);
+    try {
+      setProductType(page.getPageProducts());
+    } catch (Exception e) {
+      LOG.log(Level.WARNING,
+          "Unable to set product types for product page list: ["
+          + page + "]");
     }
+    return XmlRpcStructFactory.getXmlRpcProductPage(page);
+  }
 
   public Map<String, Object> getNextPage(
       Hashtable<String, Object> productTypeHash,
-      Hashtable<String, Object> currentPageHash){
+      Hashtable<String, Object> currentPageHash) {
     return this.getNextPageCore(productTypeHash, currentPageHash);
   }
-    public Map<String, Object> getNextPageCore(
-            Map<String, Object> productTypeHash,
-            Map<String, Object> currentPageHash) {
-        ProductType type = XmlRpcStructFactory
-                .getProductTypeFromXmlRpc(productTypeHash);
-        ProductPage currPage = XmlRpcStructFactory
-                .getProductPageFromXmlRpc(currentPageHash);
-        ProductPage page = catalog.getNextPage(type, currPage);
-        try {
-            setProductType(page.getPageProducts());
-        } catch (Exception e) {
-            LOG.log(Level.WARNING,
-                    "Unable to set product types for product page list: ["
-                            + page + "]");
-        }
-        return XmlRpcStructFactory.getXmlRpcProductPage(page);
+
+  public Map<String, Object> getNextPageCore(
+      Map<String, Object> productTypeHash,
+      Map<String, Object> currentPageHash) {
+    ProductType type = XmlRpcStructFactory
+        .getProductTypeFromXmlRpc(productTypeHash);
+    ProductPage currPage = XmlRpcStructFactory
+        .getProductPageFromXmlRpc(currentPageHash);
+    ProductPage page = catalog.getNextPage(type, currPage);
+    try {
+      setProductType(page.getPageProducts());
+    } catch (Exception e) {
+      LOG.log(Level.WARNING,
+          "Unable to set product types for product page list: ["
+          + page + "]");
     }
+    return XmlRpcStructFactory.getXmlRpcProductPage(page);
+  }
+
   public Map<String, Object> getPrevPage(
       Hashtable<String, Object> productTypeHash,
-      Hashtable<String, Object> currentPageHash){
+      Hashtable<String, Object> currentPageHash) {
     return this.getPrevPageCore(productTypeHash, currentPageHash);
   }
+
   public Map<String, Object> getPrevPageCore(
-            Map<String, Object> productTypeHash,
-            Map<String, Object> currentPageHash) {
-        ProductType type = XmlRpcStructFactory
-                .getProductTypeFromXmlRpc(productTypeHash);
-        ProductPage currPage = XmlRpcStructFactory
-                .getProductPageFromXmlRpc(currentPageHash);
-        ProductPage page = catalog.getPrevPage(type, currPage);
-        try {
-            setProductType(page.getPageProducts());
-        } catch (Exception e) {
-            LOG.log(Level.WARNING,
-                    "Unable to set product types for product page list: ["
-                            + page + "]");
-        }
-        return XmlRpcStructFactory.getXmlRpcProductPage(page);
+      Map<String, Object> productTypeHash,
+      Map<String, Object> currentPageHash) {
+    ProductType type = XmlRpcStructFactory
+        .getProductTypeFromXmlRpc(productTypeHash);
+    ProductPage currPage = XmlRpcStructFactory
+        .getProductPageFromXmlRpc(currentPageHash);
+    ProductPage page = catalog.getPrevPage(type, currPage);
+    try {
+      setProductType(page.getPageProducts());
+    } catch (Exception e) {
+      LOG.log(Level.WARNING,
+          "Unable to set product types for product page list: ["
+          + page + "]");
     }
+    return XmlRpcStructFactory.getXmlRpcProductPage(page);
+  }
 
   public String addProductType(Hashtable<String, Object> productTypeHash)
       throws RepositoryManagerException {
     return this.addProductTypeCore(productTypeHash);
   }
 
-    public String addProductTypeCore(Map<String, Object> productTypeHash)
-            throws RepositoryManagerException {
-        ProductType productType = XmlRpcStructFactory
-                .getProductTypeFromXmlRpc(productTypeHash);
-        repositoryManager.addProductType(productType);
-        return productType.getProductTypeId();
+  public String addProductTypeCore(Map<String, Object> productTypeHash)
+      throws RepositoryManagerException {
+    ProductType productType = XmlRpcStructFactory
+        .getProductTypeFromXmlRpc(productTypeHash);
+    repositoryManager.addProductType(productType);
+    return productType.getProductTypeId();
 
-    }
+  }
 
   public synchronized boolean setProductTransferStatus(
       Hashtable<String, Object> productHash)
@@ -395,6 +397,7 @@ public class XmlRpcFileManager {
       throws CatalogException {
     return this.getNumProductsCore(productTypeHash);
   }
+
   public int getNumProductsCore(Map<String, Object> productTypeHash)
       throws CatalogException {
     int numProducts;
@@ -415,22 +418,6 @@ public class XmlRpcFileManager {
     return numProducts;
   }
 
-  public List<Map<String, Object>> getTopNProductsMap(int n)
-            throws CatalogException {
-        List<Product> topNProducts;
-
-        try {
-            topNProducts = catalog.getTopNProducts(n);
-            return XmlRpcStructFactory.getXmlRpcProductListMap(topNProducts);
-        } catch (Exception e) {
-            LOG.log(Level.SEVERE, e.getMessage());
-            LOG.log(Level.WARNING,
-                    "Exception when getting topN products: Message: "
-                            + e.getMessage());
-            throw new CatalogException(e.getMessage(), e);
-        }
-    }
-
   public List<Map<String, Object>> getTopNProducts(int n)
       throws CatalogException {
     List<Product> topNProducts;
@@ -452,72 +439,75 @@ public class XmlRpcFileManager {
       throws CatalogException {
     return this.getTopNProductsCore(n, productTypeHash);
   }
-    public List<Map<String, Object>> getTopNProductsCore(int n,
-            Map<String, Object> productTypeHash)
-            throws CatalogException {
-        ProductType type = XmlRpcStructFactory
-                .getProductTypeFromXmlRpc(productTypeHash);
-        List<Product> topNProducts;
 
-        try {
-            topNProducts = catalog.getTopNProducts(n, type);
-            return XmlRpcStructFactory.getXmlRpcProductListMap(topNProducts);
-        } catch (Exception e) {
-            LOG.log(Level.SEVERE, e.getMessage());
-            LOG.log(Level.WARNING,
-                    "Exception when getting topN products by product type: ["
-                            + type.getProductTypeId() + "]: Message: "
-                            + e.getMessage());
-            throw new CatalogException(e.getMessage(), e);
-        }
+  public List<Map<String, Object>> getTopNProductsCore(int n,
+                                                       Map<String, Object> productTypeHash)
+      throws CatalogException {
+    ProductType type = XmlRpcStructFactory
+        .getProductTypeFromXmlRpc(productTypeHash);
+    List<Product> topNProducts;
 
+    try {
+      topNProducts = catalog.getTopNProducts(n, type);
+      return XmlRpcStructFactory.getXmlRpcProductList(topNProducts);
+    } catch (Exception e) {
+      LOG.log(Level.SEVERE, e.getMessage());
+      LOG.log(Level.WARNING,
+          "Exception when getting topN products by product type: ["
+          + type.getProductTypeId() + "]: Message: "
+          + e.getMessage());
+      throw new CatalogException(e.getMessage(), e);
     }
 
-    public boolean hasProduct(String productName) throws CatalogException {
-        Product p = catalog.getProductByName(productName);
-        return p != null
-                && p.getTransferStatus().equals(Product.STATUS_RECEIVED);
-    }
+  }
+
+  public boolean hasProduct(String productName) throws CatalogException {
+    Product p = catalog.getProductByName(productName);
+    return p != null
+           && p.getTransferStatus().equals(Product.STATUS_RECEIVED);
+  }
 
 
   public Map<String, Object> getMetadata(
       Hashtable<String, Object> productHash) throws CatalogException {
     return this.getMetadataCore(productHash);
   }
-    public Map<String, Object> getMetadataCore(
-        Map<String, Object> productHash) throws CatalogException {
-        Product product = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
-        return this.getMetadata(product).getHashTable();
-    }
+
+  public Map<String, Object> getMetadataCore(
+      Map<String, Object> productHash) throws CatalogException {
+    Product product = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
+    return this.getMetadata(product).getHashTable();
+  }
 
   public Map<String, Object> getReducedMetadata(
       Hashtable<String, Object> productHash, Vector<String> elements)
       throws CatalogException {
     return this.getReducedMetadataCore(productHash, elements);
   }
-    public Map<String, Object> getReducedMetadataCore(
-            Map<String, Object> productHash, Vector<String> elements)
-            throws CatalogException {
-        Product product = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
-        return this.getReducedMetadata(product, elements).getHashTable();
-    }
 
-    public List<Map<String, Object>> getProductTypes()
-            throws RepositoryManagerException {
-        List<ProductType> productTypeList;
+  public Map<String, Object> getReducedMetadataCore(
+      Map<String, Object> productHash, Vector<String> elements)
+      throws CatalogException {
+    Product product = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
+    return this.getReducedMetadata(product, elements).getHashTable();
+  }
 
-        try {
-            productTypeList = repositoryManager.getProductTypes();
-            return XmlRpcStructFactory
-                    .getXmlRpcProductTypeList(productTypeList);
-        } catch (RepositoryManagerException e) {
-            LOG.log(Level.SEVERE, e.getMessage());
-            LOG.log(Level.SEVERE,
-                    "Unable to obtain product types from repository manager: Message: "
-                            + e.getMessage());
-            throw new RepositoryManagerException(e.getMessage(), e);
-        }
+  public List<Map<String, Object>> getProductTypes()
+      throws RepositoryManagerException {
+    List<ProductType> productTypeList;
+
+    try {
+      productTypeList = repositoryManager.getProductTypes();
+      return XmlRpcStructFactory
+          .getXmlRpcProductTypeList(productTypeList);
+    } catch (RepositoryManagerException e) {
+      LOG.log(Level.SEVERE, e.getMessage());
+      LOG.log(Level.SEVERE,
+          "Unable to obtain product types from repository manager: Message: "
+          + e.getMessage());
+      throw new RepositoryManagerException(e.getMessage(), e);
     }
+  }
 
   public List<Map<String, Object>> getProductReferences(
       Hashtable<String, Object> productHash)
@@ -543,203 +533,205 @@ public class XmlRpcFileManager {
     }
 
   }
-    public Map<String, Object> getProductById(String productId)
-            throws CatalogException {
-        Product product = null;
 
-        try {
-            product = catalog.getProductById(productId);
-            // it is possible here that the underlying catalog did not
-            // set the ProductType
-            // to obey the contract of the File Manager, we need to make
-            // sure its set here
-            product.setProductType(this.repositoryManager
-                    .getProductTypeById(product.getProductType()
-                            .getProductTypeId()));
-            return XmlRpcStructFactory.getXmlRpcProduct(product);
-        } catch (CatalogException e) {
-            LOG.log(Level.SEVERE, e.getMessage());
-            LOG.log(Level.SEVERE, "Unable to obtain product by id: ["
-                    + productId + "]: Message: " + e.getMessage());
-            throw new CatalogException(e.getMessage(), e);
-        } catch (RepositoryManagerException e) {
-            LOG.log(Level.SEVERE, e.getMessage());
-            LOG.log(Level.SEVERE, "Unable to obtain product type by id: ["
-                    + product.getProductType().getProductTypeId()
-                    + "]: Message: " + e.getMessage());
-            throw new CatalogException(e.getMessage(), e);
-        }
+  public Map<String, Object> getProductById(String productId)
+      throws CatalogException {
+    Product product = null;
 
+    try {
+      product = catalog.getProductById(productId);
+      // it is possible here that the underlying catalog did not
+      // set the ProductType
+      // to obey the contract of the File Manager, we need to make
+      // sure its set here
+      product.setProductType(this.repositoryManager
+          .getProductTypeById(product.getProductType()
+                                     .getProductTypeId()));
+      return XmlRpcStructFactory.getXmlRpcProduct(product);
+    } catch (CatalogException e) {
+      LOG.log(Level.SEVERE, e.getMessage());
+      LOG.log(Level.SEVERE, "Unable to obtain product by id: ["
+                            + productId + "]: Message: " + e.getMessage());
+      throw new CatalogException(e.getMessage(), e);
+    } catch (RepositoryManagerException e) {
+      LOG.log(Level.SEVERE, e.getMessage());
+      LOG.log(Level.SEVERE, "Unable to obtain product type by id: ["
+                            + product.getProductType().getProductTypeId()
+                            + "]: Message: " + e.getMessage());
+      throw new CatalogException(e.getMessage(), e);
     }
 
-    public Map<String, Object> getProductByName(String productName)
-            throws CatalogException {
-        Product product = null;
+  }
 
-        try {
-            product = catalog.getProductByName(productName);
-            // it is possible here that the underlying catalog did not
-            // set the ProductType
-            // to obey the contract of the File Manager, we need to make
-            // sure its set here
-            product.setProductType(this.repositoryManager
-                    .getProductTypeById(product.getProductType()
-                            .getProductTypeId()));
-            return XmlRpcStructFactory.getXmlRpcProduct(product);
-        } catch (CatalogException e) {
-            LOG.log(Level.SEVERE, e.getMessage());
-            LOG.log(Level.SEVERE, "Unable to obtain product by name: ["
-                    + productName + "]: Message: " + e.getMessage());
-            throw new CatalogException(e.getMessage(), e);
-        } catch (RepositoryManagerException e) {
-            LOG.log(Level.SEVERE, e.getMessage());
-            LOG.log(Level.SEVERE, "Unable to obtain product type by id: ["
-                    + product.getProductType().getProductTypeId()
-                    + "]: Message: " + e.getMessage());
-            throw new CatalogException(e.getMessage(), e);
-        }
+  public Map<String, Object> getProductByName(String productName)
+      throws CatalogException {
+    Product product = null;
+
+    try {
+      product = catalog.getProductByName(productName);
+      // it is possible here that the underlying catalog did not
+      // set the ProductType
+      // to obey the contract of the File Manager, we need to make
+      // sure its set here
+      product.setProductType(this.repositoryManager
+          .getProductTypeById(product.getProductType()
+                                     .getProductTypeId()));
+      return XmlRpcStructFactory.getXmlRpcProduct(product);
+    } catch (CatalogException e) {
+      LOG.log(Level.SEVERE, e.getMessage());
+      LOG.log(Level.SEVERE, "Unable to obtain product by name: ["
+                            + productName + "]: Message: " + e.getMessage());
+      throw new CatalogException(e.getMessage(), e);
+    } catch (RepositoryManagerException e) {
+      LOG.log(Level.SEVERE, e.getMessage());
+      LOG.log(Level.SEVERE, "Unable to obtain product type by id: ["
+                            + product.getProductType().getProductTypeId()
+                            + "]: Message: " + e.getMessage());
+      throw new CatalogException(e.getMessage(), e);
     }
+  }
 
   public List<Map<String, Object>> getProductsByProductType(
       Hashtable<String, Object> productTypeHash)
       throws CatalogException {
     return this.getProductsByProductTypeCore(productTypeHash);
   }
-    public List<Map<String, Object>> getProductsByProductTypeCore(
-            Map<String, Object> productTypeHash)
-            throws CatalogException {
-        ProductType type = XmlRpcStructFactory
-                .getProductTypeFromXmlRpc(productTypeHash);
-        List<Product> productList;
 
-        try {
-            productList = catalog.getProductsByProductType(type);
-            return XmlRpcStructFactory.getXmlRpcProductListMap(productList);
-        } catch (Exception e) {
-            LOG.log(Level.SEVERE, e.getMessage());
-            LOG.log(Level.SEVERE,
-                    "Exception obtaining products by product type for type: ["
-                            + type.getName() + "]: Message: " + e.getMessage());
-            throw new CatalogException(e.getMessage(), e);
-        }
-    }
+  public List<Map<String, Object>> getProductsByProductTypeCore(
+      Map<String, Object> productTypeHash)
+      throws CatalogException {
+    ProductType type = XmlRpcStructFactory
+        .getProductTypeFromXmlRpc(productTypeHash);
+    List<Product> productList;
 
-    public List<Map<String, Object>> getElementsByProductType(
-            Map<String, Object> productTypeHash)
-            throws ValidationLayerException {
-        ProductType type = XmlRpcStructFactory
-                .getProductTypeFromXmlRpc(productTypeHash);
-        List<Element> elementList;
+    try {
+      productList = catalog.getProductsByProductType(type);
+      return XmlRpcStructFactory.getXmlRpcProductList(productList);
+    } catch (Exception e) {
+      LOG.log(Level.SEVERE, e.getMessage());
+      LOG.log(Level.SEVERE,
+          "Exception obtaining products by product type for type: ["
+          + type.getName() + "]: Message: " + e.getMessage());
+      throw new CatalogException(e.getMessage(), e);
+    }
+  }
 
-        try {
-            elementList = catalog.getValidationLayer().getElements(type);
-          Map hm = new ConcurrentHashMap();
-            return XmlRpcStructFactory.getXmlRpcElementList(elementList);
-        } catch (Exception e) {
-            LOG.log(Level.SEVERE, e.getMessage());
-            LOG.log(Level.SEVERE,
-                    "Exception obtaining elements for product type: ["
-                            + type.getName() + "]: Message: " + e.getMessage());
-            throw new ValidationLayerException(e.getMessage(), e);
-        }
+  public List<Map<String, Object>> getElementsByProductType(
+      Map<String, Object> productTypeHash)
+      throws ValidationLayerException {
+    ProductType type = XmlRpcStructFactory
+        .getProductTypeFromXmlRpc(productTypeHash);
+    List<Element> elementList;
 
+    try {
+      elementList = catalog.getValidationLayer().getElements(type);
+      return XmlRpcStructFactory.getXmlRpcElementList(elementList);
+    } catch (Exception e) {
+      LOG.log(Level.SEVERE, e.getMessage());
+      LOG.log(Level.SEVERE,
+          "Exception obtaining elements for product type: ["
+          + type.getName() + "]: Message: " + e.getMessage());
+      throw new ValidationLayerException(e.getMessage(), e);
     }
 
-    public Map<String, Object> getElementById(String elementId)
-            throws ValidationLayerException {
-        Element element;
+  }
 
-        try {
-            element = catalog.getValidationLayer().getElementById(elementId);
-            return XmlRpcStructFactory.getXmlRpcElement(element);
-        } catch (Exception e) {
-            LOG.log(Level.SEVERE, e.getMessage());
-            LOG.log(Level.SEVERE, "exception retrieving element by id: ["
-                    + elementId + "]: Message: " + e.getMessage());
-            throw new ValidationLayerException(e.getMessage(), e);
-        }
+  public Map<String, Object> getElementById(String elementId)
+      throws ValidationLayerException {
+    Element element;
+
+    try {
+      element = catalog.getValidationLayer().getElementById(elementId);
+      return XmlRpcStructFactory.getXmlRpcElement(element);
+    } catch (Exception e) {
+      LOG.log(Level.SEVERE, e.getMessage());
+      LOG.log(Level.SEVERE, "exception retrieving element by id: ["
+                            + elementId + "]: Message: " + e.getMessage());
+      throw new ValidationLayerException(e.getMessage(), e);
     }
+  }
 
-    public Map<String, Object> getElementByName(String elementName)
-            throws ValidationLayerException {
-        Element element;
+  public Map<String, Object> getElementByName(String elementName)
+      throws ValidationLayerException {
+    Element element;
 
-        try {
-            element = catalog.getValidationLayer()
-                    .getElementByName(elementName);
-            return XmlRpcStructFactory.getXmlRpcElement(element);
-        } catch (Exception e) {
-            LOG.log(Level.SEVERE, e.getMessage());
-            LOG.log(Level.SEVERE, "exception retrieving element by name: ["
-                    + elementName + "]: Message: " + e.getMessage());
-            throw new ValidationLayerException(e.getMessage(), e);
-        }
+    try {
+      element = catalog.getValidationLayer()
+                       .getElementByName(elementName);
+      return XmlRpcStructFactory.getXmlRpcElement(element);
+    } catch (Exception e) {
+      LOG.log(Level.SEVERE, e.getMessage());
+      LOG.log(Level.SEVERE, "exception retrieving element by name: ["
+                            + elementName + "]: Message: " + e.getMessage());
+      throw new ValidationLayerException(e.getMessage(), e);
     }
+  }
 
-  public List<Map<String,Object>> complexQuery(Hashtable<String, Object> complexQueryHash) throws CatalogException{
+  public List<Map<String, Object>> complexQuery(Hashtable<String, Object> complexQueryHash) throws CatalogException {
     return this.complexQueryCore(complexQueryHash);
   }
 
-    public List<Map<String, Object>> complexQueryCore(
-            Map<String, Object> complexQueryHash) throws CatalogException {
-        try {
-            ComplexQuery complexQuery = XmlRpcStructFactory
-                    .getComplexQueryFromXmlRpcMap(complexQueryHash);
-
-            // get ProductTypes
-            List<ProductType> productTypes;
-            if (complexQuery.getReducedProductTypeNames() == null) {
-                productTypes = this.repositoryManager.getProductTypes();
-            } else {
-                productTypes = new Vector<ProductType>();
-                for (String productTypeName : complexQuery
-                        .getReducedProductTypeNames()) {
-                  productTypes.add(this.repositoryManager
-                      .getProductTypeByName(productTypeName));
-                }
-            }
-
-            // get Metadata
-            List<QueryResult> queryResults = new LinkedList<QueryResult>();
-            for (ProductType productType : productTypes) {
-                List<String> productIds = catalog.query(this.getCatalogQuery(
-                        complexQuery, productType), productType);
-                for (String productId : productIds) {
-                    Product product = catalog.getProductById(productId);
-                    product.setProductType(productType);
-                    QueryResult qr = new QueryResult(product, this
-                            .getReducedMetadata(product, complexQuery
-                                    .getReducedMetadata()));
-                    qr.setToStringFormat(complexQuery
-                            .getToStringResultFormat());
-                    queryResults.add(qr);
-                }
-            }
-
-            LOG.log(Level.INFO, "Query returned " + queryResults.size()
-                    + " results");
-
-            // filter query results
-            if (complexQuery.getQueryFilter() != null) {
-                queryResults = applyFilterToResults(queryResults, complexQuery
-                        .getQueryFilter());
-                LOG.log(Level.INFO, "Filter returned " + queryResults.size()
-                        + " results");
-            }
-
-            // sort query results
-            if (complexQuery.getSortByMetKey() != null) {
-              queryResults = sortQueryResultList(queryResults, complexQuery
-                  .getSortByMetKey());
-            }
-
-            return XmlRpcStructFactory.getXmlRpcQueryResultsMap(queryResults);
-        } catch (Exception e) {
-            LOG.log(Level.SEVERE, e.getMessage());
-            throw new CatalogException("Failed to perform complex query : "
-                    + e.getMessage(), e);
+  public List<Map<String, Object>> complexQueryCore(
+      Map<String, Object> complexQueryHash) throws CatalogException {
+    try {
+      ComplexQuery complexQuery = XmlRpcStructFactory
+          .getComplexQueryFromXmlRpc(complexQueryHash);
+
+      // get ProductTypes
+      List<ProductType> productTypes;
+      if (complexQuery.getReducedProductTypeNames() == null) {
+        productTypes = this.repositoryManager.getProductTypes();
+      } else {
+        productTypes = new Vector<ProductType>();
+        for (String productTypeName : complexQuery
+            .getReducedProductTypeNames()) {
+          productTypes.add(this.repositoryManager
+              .getProductTypeByName(productTypeName));
         }
+      }
+
+      // get Metadata
+      List<QueryResult> queryResults = new LinkedList<QueryResult>();
+      for (ProductType productType : productTypes) {
+        List<String> productIds = catalog.query(this.getCatalogQuery(
+            complexQuery, productType), productType);
+        for (String productId : productIds) {
+          Product product = catalog.getProductById(productId);
+          product.setProductType(productType);
+          QueryResult qr = new QueryResult(product, this
+              .getReducedMetadata(product, complexQuery
+                  .getReducedMetadata()));
+          qr.setToStringFormat(complexQuery
+              .getToStringResultFormat());
+          queryResults.add(qr);
+        }
+      }
+
+      LOG.log(Level.INFO, "Query returned " + queryResults.size()
+                          + " results");
+
+      // filter query results
+      if (complexQuery.getQueryFilter() != null) {
+        queryResults = applyFilterToResults(queryResults, complexQuery
+            .getQueryFilter());
+        LOG.log(Level.INFO, "Filter returned " + queryResults.size()
+                            + " results");
+      }
+
+      // sort query results
+      if (complexQuery.getSortByMetKey() != null) {
+        queryResults = sortQueryResultList(queryResults, complexQuery
+            .getSortByMetKey());
+      }
+
+      return XmlRpcStructFactory.getXmlRpcQueryResults(queryResults);
+    } catch (Exception e) {
+      LOG.log(Level.SEVERE, e.getMessage());
+      throw new CatalogException("Failed to perform complex query : "
+                                 + e.getMessage(), e);
     }
+  }
+
   public List<Map<String, Object>> query(
       Hashtable<String, Object> queryHash,
       Hashtable<String, Object> productTypeHash)
@@ -757,12 +749,6 @@ public class XmlRpcFileManager {
     return XmlRpcStructFactory.getXmlRpcProductList(this.query(query, type));
   }
 
-    public Map<String, Object> getProductTypeByNameMap(String productTypeName)
-            throws RepositoryManagerException {
-        ProductType type = repositoryManager
-                .getProductTypeByName(productTypeName);
-        return XmlRpcStructFactory.getXmlRpcProductType(type);
-    }
 
   public Map<String, Object> getProductTypeByName(String productTypeName)
       throws RepositoryManagerException {
@@ -771,66 +757,69 @@ public class XmlRpcFileManager {
     return XmlRpcStructFactory.getXmlRpcProductType(type);
   }
 
-    public Map<String, Object> getProductTypeById(String productTypeId)
-            throws RepositoryManagerException {
-        ProductType type;
+  public Map<String, Object> getProductTypeById(String productTypeId)
+      throws RepositoryManagerException {
+    ProductType type;
 
-        try {
-            type = repositoryManager.getProductTypeById(productTypeId);
-            return XmlRpcStructFactory.getXmlRpcProductType(type);
-        } catch (Exception e) {
-            LOG.log(Level.SEVERE, e.getMessage());
-            LOG.log(Level.SEVERE,
-                    "Exception obtaining product type by id for product type: ["
-                            + productTypeId + "]: Message: " + e.getMessage());
-            throw new RepositoryManagerException(e.getMessage(), e);
-        }
+    try {
+      type = repositoryManager.getProductTypeById(productTypeId);
+      return XmlRpcStructFactory.getXmlRpcProductType(type);
+    } catch (Exception e) {
+      LOG.log(Level.SEVERE, e.getMessage());
+      LOG.log(Level.SEVERE,
+          "Exception obtaining product type by id for product type: ["
+          + productTypeId + "]: Message: " + e.getMessage());
+      throw new RepositoryManagerException(e.getMessage(), e);
     }
+  }
+
   public synchronized boolean updateMetadata(Hashtable<String, Object> productHash,
-                                                 Hashtable<String, Object> metadataHash) throws CatalogException{
+                                             Hashtable<String, Object> metadataHash) throws CatalogException {
 
     return this.updateMetadataCore(productHash, metadataHash);
   }
 
-    public synchronized boolean updateMetadataCore(Map<String, Object> productHash,
-        Map<String, Object> metadataHash) throws CatalogException{
-        Product product = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
-        Metadata met = new Metadata();
-        met.addMetadata(metadataHash);
-        Metadata oldMetadata = catalog.getMetadata(product);
-        catalog.removeMetadata(oldMetadata, product);
-        catalog.addMetadata(met, product);
-        return true;
-    }
+  public synchronized boolean updateMetadataCore(Map<String, Object> productHash,
+                                                 Map<String, Object> metadataHash) throws CatalogException {
+    Product product = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
+    Metadata met = new Metadata();
+    met.addMetadata(metadataHash);
+    Metadata oldMetadata = catalog.getMetadata(product);
+    catalog.removeMetadata(oldMetadata, product);
+    catalog.addMetadata(met, product);
+    return true;
+  }
 
   public synchronized String catalogProduct(Hashtable<String, Object> productHash)
       throws CatalogException {
     return this.catalogProductCore(productHash);
 
   }
-    public synchronized String catalogProductCore(Map<String, Object> productHash)
-            throws CatalogException {
-        Product p = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
-        return catalogProduct(p);
-    }
+
+  public synchronized String catalogProductCore(Map<String, Object> productHash)
+      throws CatalogException {
+    Product p = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
+    return catalogProduct(p);
+  }
 
   public synchronized boolean addMetadata(Hashtable<String, Object> productHash,
                                           Hashtable<String, String> metadata) throws CatalogException {
     return this.addMetadataCore(productHash, metadata);
   }
-    public synchronized boolean addMetadataCore(Map<String, Object> productHash,
-            Map<String, String> metadata) throws CatalogException {
-        Product p = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
-        Metadata m = new Metadata();
-        m.addMetadata((Map)metadata);
-        return addMetadata(p, m) != null;
-    }
 
-    public synchronized boolean addProductReferencesCore(Map<String, Object> productHash)
-            throws CatalogException {
-        Product product = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
-        return addProductReferences(product);
-    }
+  public synchronized boolean addMetadataCore(Map<String, Object> productHash,
+                                              Map<String, String> metadata) throws CatalogException {
+    Product p = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
+    Metadata m = new Metadata();
+    m.addMetadata((Map) metadata);
+    return addMetadata(p, m) != null;
+  }
+
+  public synchronized boolean addProductReferencesCore(Map<String, Object> productHash)
+      throws CatalogException {
+    Product product = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
+    return addProductReferences(product);
+  }
 
   public synchronized boolean addProductReferences(Hashtable<String, Object> productHash)
       throws CatalogException {
@@ -844,9 +833,9 @@ public class XmlRpcFileManager {
 
 
   public String ingestProductCore(Map<String, Object> productHash,
-      Map<String, String> metadata, boolean clientTransfer)
+                                  Map<String, String> metadata, boolean clientTransfer)
       throws
-        CatalogException {
+      CatalogException {
 
     Product p = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
 
@@ -857,7 +846,7 @@ public class XmlRpcFileManager {
 
       // now add the metadata
       Metadata m = new Metadata();
-      m.addMetadata((Map)metadata);
+      m.addMetadata((Map) metadata);
       Metadata expandedMetdata = addMetadata(p, m);
 
       // version the product
@@ -872,9 +861,9 @@ public class XmlRpcFileManager {
         } catch (Exception e) {
           LOG.log(Level.SEVERE,
               "ingestProduct: VersioningException when versioning Product: "
-                  + p.getProductName() + " with Versioner "
-                  + p.getProductType().getVersioner() + ": Message: "
-                  + e.getMessage());
+              + p.getProductName() + " with Versioner "
+              + p.getProductType().getVersioner() + ": Message: "
+              + e.getMessage());
           throw new VersioningException(e);
         }
 
@@ -884,8 +873,8 @@ public class XmlRpcFileManager {
 
       if (!clientTransfer) {
         LOG.log(Level.FINEST,
-              "File Manager: ingest: no client transfer enabled, "
-                  + "server transfering product: [" + p.getProductName() + "]");
+            "File Manager: ingest: no client transfer enabled, "
+            + "server transfering product: [" + p.getProductName() + "]");
 
         // now transfer the product
         try {
@@ -897,14 +886,14 @@ public class XmlRpcFileManager {
             catalog.setProductTransferStatus(p);
           } catch (CatalogException e) {
             LOG.log(Level.SEVERE, "ingestProduct: CatalogException "
-                + "when updating product transfer status for Product: "
-                + p.getProductName() + " Message: " + e.getMessage());
+                                  + "when updating product transfer status for Product: "
+                                  + p.getProductName() + " Message: " + e.getMessage());
             throw e;
           }
         } catch (Exception e) {
           LOG.log(Level.SEVERE,
               "ingestProduct: DataTransferException when transfering Product: "
-                  + p.getProductName() + ": Message: " + e.getMessage());
+              + p.getProductName() + ": Message: " + e.getMessage());
           throw new DataTransferException(e);
         }
       }
@@ -914,224 +903,230 @@ public class XmlRpcFileManager {
     } catch (Exception e) {
       LOG.log(Level.SEVERE, e.getMessage());
       throw new CatalogException("Error ingesting product [" + p + "] : "
-          + e.getMessage(),e);
+                                 + e.getMessage(), e);
     }
 
   }
+
   public byte[] retrieveFile(String filePath, int offset, int numBytes)
-         throws DataTransferException {
-      FileInputStream is = null;
-      try {
-         byte[] fileData = new byte[numBytes];
-         (is = new FileInputStream(filePath)).skip(offset);
-         int bytesRead = is.read(fileData);
-         if (bytesRead != -1) {
-            byte[] fileDataTruncated = new byte[bytesRead];
-            System.arraycopy(fileData, 0, fileDataTruncated, 0, bytesRead);
-            return fileDataTruncated;
-         } else {
-            return new byte[0];
-         }
-      } catch (Exception e) {
-         LOG.log(Level.SEVERE, "Failed to read '" + numBytes
-               + "' bytes from file '" + filePath + "' at index '" + offset
-               + "' : " + e.getMessage(), e);
-         throw new DataTransferException("Failed to read '" + numBytes
-               + "' bytes from file '" + filePath + "' at index '" + offset
-               + "' : " + e.getMessage(), e);
-      } finally {
-         try {
-           if (is != null) {
-             is.close();
-           }
-         } catch (Exception ignored) {}
+      throws DataTransferException {
+    FileInputStream is = null;
+    try {
+      byte[] fileData = new byte[numBytes];
+      (is = new FileInputStream(filePath)).skip(offset);
+      int bytesRead = is.read(fileData);
+      if (bytesRead != -1) {
+        byte[] fileDataTruncated = new byte[bytesRead];
+        System.arraycopy(fileData, 0, fileDataTruncated, 0, bytesRead);
+        return fileDataTruncated;
+      } else {
+        return new byte[0];
       }
-   }
-    
-    public boolean transferFile(String filePath, byte[] fileData, int offset,
-            int numBytes) {
-        File outFile = new File(filePath);
-        boolean success = true;
-
-        FileOutputStream fOut = null;
-
-        if (outFile.exists()) {
-            try {
-                fOut = new FileOutputStream(outFile, true);
-            } catch (FileNotFoundException e) {
-                LOG.log(Level.SEVERE, e.getMessage());
-                LOG.log(Level.SEVERE,
-                        "FileNotFoundException when trying to use RandomAccess file on "
-                                + filePath + ": Message: " + e.getMessage());
-                success = false;
-            }
-        } else {
-            // create the output directory
-            String outFileDirPath = outFile.getAbsolutePath().substring(0,
-                    outFile.getAbsolutePath().lastIndexOf("/"));
-            LOG.log(Level.INFO, "Outfile directory: " + outFileDirPath);
-            File outFileDir = new File(outFileDirPath);
-            outFileDir.mkdirs();
-
-            try {
-                fOut = new FileOutputStream(outFile, false);
-            } catch (FileNotFoundException e) {
-                LOG.log(Level.SEVERE, e.getMessage());
-                LOG.log(Level.SEVERE,
-                        "FileNotFoundException when trying to use RandomAccess file on "
-                                + filePath + ": Message: " + e.getMessage());
-                success = false;
-            }
+    } catch (Exception e) {
+      LOG.log(Level.SEVERE, "Failed to read '" + numBytes
+                            + "' bytes from file '" + filePath + "' at index '" + offset
+                            + "' : " + e.getMessage(), e);
+      throw new DataTransferException("Failed to read '" + numBytes
+                                      + "' bytes from file '" + filePath + "' at index '" + offset
+                                      + "' : " + e.getMessage(), e);
+    } finally {
+      try {
+        if (is != null) {
+          is.close();
         }
+      } catch (Exception ignored) {
+      }
+    }
+  }
 
-        if (success) {
-            try {
-                fOut.write(fileData, (int) offset, (int) numBytes);
-            } catch (IOException e) {
-                LOG.log(Level.SEVERE, e.getMessage());
-                LOG.log(Level.SEVERE, "IOException when trying to write file "
-                        + filePath + ": Message: " + e.getMessage());
-                success = false;
-            } finally {
-              try {
-                  fOut.close();
-              } catch (Exception ignore) {
-              }
-
-            }
+  public boolean transferFile(String filePath, byte[] fileData, int offset,
+                              int numBytes) {
+    File outFile = new File(filePath);
+    boolean success = true;
+
+    FileOutputStream fOut = null;
+
+    if (outFile.exists()) {
+      try {
+        fOut = new FileOutputStream(outFile, true);
+      } catch (FileNotFoundException e) {
+        LOG.log(Level.SEVERE, e.getMessage());
+        LOG.log(Level.SEVERE,
+            "FileNotFoundException when trying to use RandomAccess file on "
+            + filePath + ": Message: " + e.getMessage());
+        success = false;
+      }
+    } else {
+      // create the output directory
+      String outFileDirPath = outFile.getAbsolutePath().substring(0,
+          outFile.getAbsolutePath().lastIndexOf("/"));
+      LOG.log(Level.INFO, "Outfile directory: " + outFileDirPath);
+      File outFileDir = new File(outFileDirPath);
+      outFileDir.mkdirs();
+
+      try {
+        fOut = new FileOutputStream(outFile, false);
+      } catch (FileNotFoundException e) {
+        LOG.log(Level.SEVERE, e.getMessage());
+        LOG.log(Level.SEVERE,
+            "FileNotFoundException when trying to use RandomAccess file on "
+            + filePath + ": Message: " + e.getMessage());
+        success = false;
+      }
+    }
+
+    if (success) {
+      try {
+        fOut.write(fileData, (int) offset, (int) numBytes);
+      } catch (IOException e) {
+        LOG.log(Level.SEVERE, e.getMessage());
+        LOG.log(Level.SEVERE, "IOException when trying to write file "
+                              + filePath + ": Message: " + e.getMessage());
+        success = false;
+      } finally {
+        try {
+          fOut.close();
+        } catch (Exception ignore) {
         }
 
-      return success;
+      }
     }
 
+    return success;
+  }
+
   public boolean moveProduct(Hashtable<String, Object> productHash, String newPath)
       throws DataTransferException {
 
     return this.moveProductCore(productHash, newPath);
   }
-    public boolean moveProductCore(Map<String, Object> productHash, String newPath)
-            throws DataTransferException {
-
-        Product p = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
-
-        // first thing we care about is if the product is flat or heirarchical
-        if (p.getProductStructure().equals(Product.STRUCTURE_FLAT)) {
-            // we just need to get its first reference
-            if (p.getProductReferences() == null || (p.getProductReferences().size() != 1)) {
-                throw new DataTransferException(
-                        "Flat products must have a single reference: cannot move");
-            }
-
-            // okay, it's fine to move it
-            // first, we need to update the data store ref
-            Reference r = p.getProductReferences().get(0);
-            if (r.getDataStoreReference().equals(
-                    new File(newPath).toURI().toString())) {
-                throw new DataTransferException("cannot move product: ["
-                        + p.getProductName() + "] to same location: ["
-                        + r.getDataStoreReference() + "]");
-            }
-
-            // create a copy of the current data store path: we'll need it to
-            // do the data transfer
-            Reference copyRef = new Reference(r);
-
-            // update the copyRef to have the data store ref as the orig ref
-            // the the newLoc as the new ref
-            copyRef.setOrigReference(r.getDataStoreReference());
-            copyRef.setDataStoreReference(new File(newPath).toURI().toString());
-
-            p.getProductReferences().clear();
-            p.getProductReferences().add(copyRef);
-
-            // now transfer it
-            try {
-                this.dataTransfer.transferProduct(p);
-            } catch (IOException e) {
-                throw new DataTransferException(e);
-            }
-
-            // now delete the original copy
-            try {
-                if (!new File(new URI(copyRef.getOrigReference())).delete()) {
-                    LOG.log(Level.WARNING, "Deletion of original file: ["
-                            + r.getDataStoreReference()
-                            + "] on product move returned false");
-                }
-            } catch (URISyntaxException e) {
-                throw new DataTransferException(
-                        "URI Syntax exception trying to remove original product ref: Message: "
-                                + e.getMessage(), e);
-            }
-
-            // now save the updated reference
-            try {
-                this.catalog.modifyProduct(p);
-                return true;
-            } catch (CatalogException e) {
-                throw new DataTransferException(e.getMessage(),e);
-            }
-        } else {
-          throw new UnsupportedOperationException(
-              "Moving of heirarhical and stream products not supported yet");
+
+  public boolean moveProductCore(Map<String, Object> productHash, String newPath)
+      throws DataTransferException {
+
+    Product p = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
+
+    // first thing we care about is if the product is flat or heirarchical
+    if (p.getProductStructure().equals(Product.STRUCTURE_FLAT)) {
+      // we just need to get its first reference
+      if (p.getProductReferences() == null || (p.getProductReferences().size() != 1)) {
+        throw new DataTransferException(
+            "Flat products must have a single reference: cannot move");
+      }
+
+      // okay, it's fine to move it
+      // first, we need to update the data store ref
+      Reference r = p.getProductReferences().get(0);
+      if (r.getDataStoreReference().equals(
+          new File(newPath).toURI().toString())) {
+        throw new DataTransferException("cannot move product: ["
+                                        + p.getProductName() + "] to same location: ["
+                                        + r.getDataStoreReference() + "]");
+      }
+
+      // create a copy of the current data store path: we'll need it to
+      // do the data transfer
+      Reference copyRef = new Reference(r);
+
+      // update the copyRef to have the data store ref as the orig ref
+      // the the newLoc as the new ref
+      copyRef.setOrigReference(r.getDataStoreReference());
+      copyRef.setDataStoreReference(new File(newPath).toURI().toString());
+
+      p.getProductReferences().clear();
+      p.getProductReferences().add(copyRef);
+
+      // now transfer it
+      try {
+        this.dataTransfer.transferProduct(p);
+      } catch (IOException e) {
+        throw new DataTransferException(e);
+      }
+
+      // now delete the original copy
+      try {
+        if (!new File(new URI(copyRef.getOrigReference())).delete()) {
+          LOG.log(Level.WARNING, "Deletion of original file: ["
+                                 + r.getDataStoreReference()
+                                 + "] on product move returned false");
         }
-    }
+      } catch (URISyntaxException e) {
+        throw new DataTransferException(
+            "URI Syntax exception trying to remove original product ref: Message: "
+            + e.getMessage(), e);
+      }
 
-    public boolean removeFile(String filePath) throws DataTransferException, IOException {
-      // TODO(bfoster): Clean this up so that it deletes by product not file.
-      Product product = new Product();
-      Reference r = new Reference();
-      r.setDataStoreReference(filePath);
-      product.setProductReferences(Lists.newArrayList(r));
-      dataTransfer.deleteProduct(product);
-      return true;
+      // now save the updated reference
+      try {
+        this.catalog.modifyProduct(p);
+        return true;
+      } catch (CatalogException e) {
+        throw new DataTransferException(e.getMessage(), e);
+      }
+    } else {
+      throw new UnsupportedOperationException(
+          "Moving of heirarhical and stream products not supported yet");
     }
+  }
+
+  public boolean removeFile(String filePath) throws DataTransferException, IOException {
+    // TODO(bfoster): Clean this up so that it deletes by product not file.
+    Product product = new Product();
+    Reference r = new Reference();
+    r.setDataStoreReference(filePath);
+    product.setProductReferences(Lists.newArrayList(r));
+    dataTransfer.deleteProduct(product);
+    return true;
+  }
 
   public boolean modifyProduct(Hashtable<?, ?> productHash) throws CatalogException {
     return this.modifyProductCore(productHash);
   }
-    public boolean modifyProductCore(Map<?, ?> productHash) throws CatalogException {
-        Product p = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
 
-        try {
-            catalog.modifyProduct(p);
-        } catch (CatalogException e) {
-            LOG.log(Level.WARNING, "Exception modifying product: ["
-                    + p.getProductId() + "]: Message: " + e.getMessage(), e);
-            throw e;
-        }
+  public boolean modifyProductCore(Map<?, ?> productHash) throws CatalogException {
+    Product p = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
 
-        return true;
+    try {
+      catalog.modifyProduct(p);
+    } catch (CatalogException e) {
+      LOG.log(Level.WARNING, "Exception modifying product: ["
+                             + p.getProductId() + "]: Message: " + e.getMessage(), e);
+      throw e;
     }
 
-    public boolean removeProduct(Map<String, Object> productHash) throws CatalogException {
-        Product p = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
+    return true;
+  }
 
-        try {
-            catalog.removeProduct(p);
-        } catch (CatalogException e) {
-            LOG.log(Level.WARNING, "Exception modifying product: ["
-                    + p.getProductId() + "]: Message: " + e.getMessage(), e);
-            throw e;
-        }
+  public boolean removeProduct(Map<String, Object> productHash) throws CatalogException {
+    Product p = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
 
-        return true;
+    try {
+      catalog.removeProduct(p);
+    } catch (CatalogException e) {
+      LOG.log(Level.WARNING, "Exception modifying product: ["
+                             + p.getProductId() + "]: Message: " + e.getMessage(), e);
+      throw e;
     }
+
+    return true;
+  }
+
   public Map<String, Object> getCatalogValues(
       Hashtable<String, Object> metadataHash,
       Hashtable<String, Object> productTypeHash)
       throws RepositoryManagerException {
     return this.getCatalogValuesCore(metadataHash, productTypeHash);
   }
-    public Map<String, Object> getCatalogValuesCore(
-            Map<String, Object> metadataHash,
-            Map<String, Object> productTypeHash)
-            throws RepositoryManagerException {
-        Metadata m = new Metadata();
-        m.addMetadata(metadataHash);
-        ProductType productType = XmlRpcStructFactory.getProductTypeFromXmlRpc(productTypeHash);
-        return this.getCatalogValues(m, productType).getHashTable();
-    }
+
+  public Map<String, Object> getCatalogValuesCore(
+      Map<String, Object> metadataHash,
+      Map<String, Object> productTypeHash)
+      throws RepositoryManagerException {
+    Metadata m = new Metadata();
+    m.addMetadata(metadataHash);
+    ProductType productType = XmlRpcStructFactory.getProductTypeFromXmlRpc(productTypeHash);
+    return this.getCatalogValues(m, productType).getHashTable();
+  }
 
   public Map<String, Object> getOrigValues(
       Hashtable<String, Object> metadataHash,
@@ -1140,15 +1135,15 @@ public class XmlRpcFileManager {
     return this.getOrigValuesCore(metadataHash, productTypeHash);
   }
 
-    public Map<String, Object> getOrigValuesCore(
-        Map<String, Object> metadataHash,
-        Map<String, Object> productTypeHash)
-            throws RepositoryManagerException {
-        Metadata m = new Metadata();
-        m.addMetadata(metadataHash);
-        ProductType productType = XmlRpcStructFactory.getProductTypeFromXmlRpc(productTypeHash);
-        return this.getOrigValues(m, productType).getHashTable();
-    }
+  public Map<String, Object> getOrigValuesCore(
+      Map<String, Object> metadataHash,
+      Map<String, Object> productTypeHash)
+      throws RepositoryManagerException {
+    Metadata m = new Metadata();
+    m.addMetadata(metadataHash);
+    ProductType productType = XmlRpcStructFactory.getProductTypeFromXmlRpc(productTypeHash);
+    return this.getOrigValues(m, productType).getHashTable();
+  }
 
   public Map<String, Object> getCatalogQuery(
       Hashtable<String, Object> queryHash,
@@ -1156,305 +1151,306 @@ public class XmlRpcFileManager {
       throws RepositoryManagerException, QueryFormulationException {
     return this.getCatalogQueryCore(queryHash, productTypeHash);
   }
-    public Map<String, Object> getCatalogQueryCore(
-            Map<String, Object> queryHash,
-            Map<String, Object> productTypeHash)
-            throws RepositoryManagerException, QueryFormulationException {
-        Query query = XmlRpcStructFactory.getQueryFromXmlRpcMap(queryHash);
-        ProductType productType = XmlRpcStructFactory.getProductTypeFromXmlRpc(productTypeHash);
-        return XmlRpcStructFactory.getXmlRpcQuery(this.getCatalogQuery(query, productType));
-    }
-
 
-  public static void main(String[] args) throws IOException {
-        int portNum = -1;
-        String usage = "FileManager --portNum <port number for xml rpc service>\n";
+  public Map<String, Object> getCatalogQueryCore(
+      Map<String, Object> queryHash,
+      Map<String, Object> productTypeHash)
+      throws RepositoryManagerException, QueryFormulationException {
+    Query query = XmlRpcStructFactory.getQueryFromXmlRpc(queryHash);
+    ProductType productType = XmlRpcStructFactory.getProductTypeFromXmlRpc(productTypeHash);
+    return XmlRpcStructFactory.getXmlRpcQuery(this.getCatalogQuery(query, productType));
+  }
 
-        for (int i = 0; i < args.length; i++) {
-            if (args[i].equals("--portNum")) {
-                portNum = Integer.parseInt(args[++i]);
-            }
-        }
 
-        if (portNum == -1) {
-            System.err.println(usage);
-            System.exit(1);
-        }
-        
-        @SuppressWarnings("unused")
-        XmlRpcFileManager manager = new XmlRpcFileManager(portNum);
+  public static void main(String[] args) throws IOException {
+    int portNum = -1;
+    String usage = "FileManager --portNum <port number for xml rpc service>\n";
 
-        for (;;) {
-          try {
-            Thread.currentThread().join();
-          } catch (InterruptedException ignore) {
-          }
-        }
+    for (int i = 0; i < args.length; i++) {
+      if (args[i].equals("--portNum")) {
+        portNum = Integer.parseInt(args[++i]);
+      }
     }
 
-    public boolean shutdown() {
-        if (this.webServer != null) {
-            this.webServer.shutdown();
-            this.webServer = null;
-            return true;
-        } else {
-          return false;
-        }
+    if (portNum == -1) {
+      System.err.println(usage);
+      System.exit(1);
     }
 
-    private synchronized String catalogProduct(Product p)
-            throws CatalogException {
-        try {
-            catalog.addProduct(p);
-        } catch (CatalogException e) {
-            LOG.log(Level.SEVERE,
-                    "ingestProduct: CatalogException when adding Product: "
-                            + p.getProductName() + " to Catalog: Message: "
-                            + e.getMessage());
-            throw e;
-        }
+    @SuppressWarnings("unused")
+    XmlRpcFileManager manager = new XmlRpcFileManager(portNum);
 
-        return p.getProductId();
+    for (; ; ) {
+      try {
+        Thread.currentThread().join();
+      } catch (InterruptedException ignore) {
+      }
     }
+  }
 
-    private synchronized Metadata addMetadata(Product p, Metadata m)
-            throws CatalogException {
-        
-        //apply handlers
-        try {
-            m = this.getCatalogValues(m, p.getProductType());
-        } catch (Exception e) {
-            LOG.log(Level.SEVERE, "Failed to get handlers for product '" + p
-                    + "' : " + e.getMessage());
-        }
-        
-        // first do server side metadata extraction
-        Metadata metadata = runExtractors(p, m);
-
-        try {
-            catalog.addMetadata(metadata, p);
-        } catch (CatalogException e) {
-            LOG.log(Level.SEVERE,
-                    "ingestProduct: CatalogException when adding metadata "
-                            + metadata + " for product: " + p.getProductName()
-                            + ": Message: " + e.getMessage());
-            throw e;
-        } catch (Exception e) {
-            LOG.log(Level.SEVERE, e.getMessage());
-            LOG.log(Level.SEVERE,
-                    "ingestProduct: General Exception when adding metadata "
-                            + metadata + " for product: " + p.getProductName()
-                            + ": Message: " + e.getMessage());
-            throw new CatalogException(e.getMessage(),e);
-        }
+  public boolean shutdown() {
+    if (this.webServer != null) {
+      this.webServer.shutdown();
+      this.webServer = null;
+      return true;
+    } else {
+      return false;
+    }
+  }
 
-        return metadata;
+  private synchronized String catalogProduct(Product p)
+      throws CatalogException {
+    try {
+      catalog.addProduct(p);
+    } catch (CatalogException e) {
+      LOG.log(Level.SEVERE,
+          "ingestProduct: CatalogException when adding Product: "
+          + p.getProductName() + " to Catalog: Message: "
+          + e.getMessage());
+      throw e;
     }
 
-    private Metadata runExtractors(Product product, Metadata metadata) throws CatalogException {
-        // make sure that the product type definition is present
-        if(product.getProductType() == null){
-          LOG.log(Level.SEVERE, "Failed to run extractor for: "+product.getProductId()+":"+product
-              .getProductName()+" product type cannot be null.");
-          throw new CatalogException("Failed to run extractor for: "+product.getProductId()+":"+product
-              .getProductName()+" product type cannot be null.");
-        }
-        try {
-            product.setProductType(repositoryManager.getProductTypeById(product
-                    .getProductType().getProductTypeId()));
-        } catch (RepositoryManagerException e) {
-            LOG.log(Level.SEVERE, "Failed to load ProductType " + product
-              .getProductType().getProductTypeId(), e);
-            return null;
-        }
+    return p.getProductId();
+  }
 
-        Metadata met = new Metadata();
-        met.addMetadata(metadata.getHashTable());
-
-        if (product.getProductType().getExtractors() != null) {
-            for (ExtractorSpec spec: product.getProductType().getExtractors()) {
-                FilemgrMetExtractor extractor = GenericFileManagerObjectFactory
-                        .getExtractorFromClassName(spec.getClassName());
-              if (extractor != null) {
-                extractor.configure(spec.getConfiguration());
-              }
-              LOG.log(Level.INFO, "Running Met Extractor: ["
-                        + (extractor != null ? extractor.getClass().getName() : null)
-                        + "] for product type: ["
-                        + product.getProductType().getName() + "]");
-                try {
-                    met = extractor != null ? extractor.extractMetadata(product, met) : null;
-                } catch (MetExtractionException e) {
-                    LOG.log(Level.SEVERE,
-                            "Exception extractor metadata from product: ["
-                                    + product.getProductName()
-                                    + "]: using extractor: ["
-                                    + extractor.getClass().getName()
-                                    + "]: Message: " + e.getMessage(), e);
-                }
-            }
-        }
+  private synchronized Metadata addMetadata(Product p, Metadata m)
+      throws CatalogException {
 
-        return met;
+    //apply handlers
+    try {
+      m = this.getCatalogValues(m, p.getProductType());
+    } catch (Exception e) {
+      LOG.log(Level.SEVERE, "Failed to get handlers for product '" + p
+                            + "' : " + e.getMessage());
     }
 
-    private synchronized boolean addProductReferences(Product product)
-            throws CatalogException {
-        catalog.addProductReferences(product);
-        return true;
+    // first do server side metadata extraction
+    Metadata metadata = runExtractors(p, m);
+
+    try {
+      catalog.addMetadata(metadata, p);
+    } catch (CatalogException e) {
+      LOG.log(Level.SEVERE,
+          "ingestProduct: CatalogException when adding metadata "
+          + metadata + " for product: " + p.getProductName()
+          + ": Message: " + e.getMessage());
+      throw e;
+    } catch (Exception e) {
+      LOG.log(Level.SEVERE, e.getMessage());
+      LOG.log(Level.SEVERE,
+          "ingestProduct: General Exception when adding metadata "
+          + metadata + " for product: " + p.getProductName()
+          + ": Message: " + e.getMessage());
+      throw new CatalogException(e.getMessage(), e);
     }
 
-    private void setProductType(List<Product> products) throws RepositoryManagerException {
-        if (products != null && products.size() > 0) {
-          for (Product p : products) {
-              p.setProductType(repositoryManager.getProductTypeById(p
-                  .getProductType().getProductTypeId()));
-          }
-        }
+    return metadata;
+  }
+
+  private Metadata runExtractors(Product product, Metadata metadata) throws CatalogException {
+    // make sure that the product type definition is present
+    if (product.getProductType() == null) {
+      LOG.log(Level.SEVERE, "Failed to run extractor for: " + product.getProductId() + ":" + product
+          .getProductName() + " product type cannot be null.");
+      throw new CatalogException("Failed to run extractor for: " + product.getProductId() + ":" + product
+          .getProductName() + " product type cannot be null.");
     }
-    
-    private List<Product> query(Query query, ProductType productType) throws CatalogException {
-        List<String> productIdList;
-        List<Product> productList;
-
-        try {            
-            productIdList = catalog.query(this.getCatalogQuery(query, productType), productType);
-
-            if (productIdList != null && productIdList.size() > 0) {
-                productList = new Vector<Product>(productIdList.size());
-              for (String productId : productIdList) {
-                Product product = catalog.getProductById(productId);
-                // it is possible here that the underlying catalog did not
-                // set the ProductType
-                // to obey the contract of the File Manager, we need to make
-                // sure its set here
-                product.setProductType(this.repositoryManager
-                    .getProductTypeById(product.getProductType()
-                                               .getProductTypeId()));
-                productList.add(product);
-              }
-                return productList;
-            } else {
-                return new Vector<Product>(); // null values not supported by XML-RPC
-            }
-        } catch (Exception e) {
-            LOG.log(Level.SEVERE, e.getMessage());
-            LOG.log(Level.SEVERE,
-                    "Exception performing query against catalog for product type: ["
-                            + productType.getName() + "] Message: " + e.getMessage());
-            throw new CatalogException(e.getMessage(),e);
+    try {
+      product.setProductType(repositoryManager.getProductTypeById(product
+          .getProductType().getProductTypeId()));
+    } catch (RepositoryManagerException e) {
+      LOG.log(Level.SEVERE, "Failed to load ProductType " + product
+          .getProductType().getProductTypeId(), e);
+      return null;
+    }
+
+    Metadata met = new Metadata();
+    met.addMetadata(metadata.getHashTable());
+
+    if (product.getProductType().getExtractors() != null) {
+      for (ExtractorSpec spec : product.getProductType().getExtractors()) {
+        FilemgrMetExtractor extractor = GenericFileManagerObjectFactory
+            .getExtractorFromClassName(spec.getClassName());
+        if (extractor != null) {
+          extractor.configure(spec.getConfiguration());
         }
-    }
-    
-    private Metadata getReducedMetadata(Product product, List<String> elements) throws CatalogException {
+        LOG.log(Level.INFO, "Running Met Extractor: ["
+                            + (extractor != null ? extractor.getClass().getName() : null)
+                            + "] for product type: ["
+                            + product.getProductType().getName() + "]");
         try {
-            Metadata m;
-            if (elements != null && elements.size() > 0) {
-                m = catalog.getReducedMetadata(product, elements);
-            }else {
-                m = this.getMetadata(product);
-            }
-            if(this.expandProductMet) {
-              m = this.buildProductMetadata(product, m);
-            }
-            return this.getOrigValues(m, product.getProductType());
-        } catch (Exception e) {
-            LOG.log(Level.SEVERE, e.getMessage());
-            LOG.log(Level.SEVERE,
-                    "Exception obtaining metadata from catalog for product: ["
-                            + product.getProductId() + "]: Message: "
-                            + e.getMessage());
-            throw new CatalogException(e.getMessage(),e);
+          met = extractor != null ? extractor.extractMetadata(product, met) : null;
+        } catch (MetExtractionException e) {
+          LOG.log(Level.SEVERE,
+              "Exception extractor metadata from product: ["
+              + product.getProductName()
+              + "]: using extractor: ["
+              + extractor.getClass().getName()
+              + "]: Message: " + e.getMessage(), e);
         }
+      }
     }
-    
-    private Metadata getMetadata(Product product) throws CatalogException {
-        try {
-            Metadata m = catalog.getMetadata(product);
-            if(this.expandProductMet) {
-              m = this.buildProductMetadata(product, m);
-            }
-            return this.getOrigValues(m, product.getProductType());
-        } catch (Exception e) {
-            LOG.log(Level.SEVERE, e.getMessage());
-            LOG.log(Level.SEVERE,
-                    "Exception obtaining metadata from catalog for product: ["
-                            + product.getProductId() + "]: Message: "
-                            + e.getMessage());
-            throw new CatalogException(e.getMessage(),e);
-        }
+
+    return met;
+  }
+
+  private synchronized boolean addProductReferences(Product product)
+      throws CatalogException {
+    catalog.addProductReferences(product);
+    return true;
+  }
+
+  private void setProductType(List<Product> products) throws RepositoryManagerException {
+    if (products != null && products.size() > 0) {
+      for (Product p : products) {
+        p.setProductType(repositoryManager.getProductTypeById(p
+            .getProductType().getProductTypeId()));
+      }
     }
-    
-    private Metadata getOrigValues(Metadata metadata, ProductType productType) 
-            throws RepositoryManagerException {
-        List<TypeHandler> handlers = this.repositoryManager.getProductTypeById(
-                productType.getProductTypeId()).getHandlers();
-        if (handlers != null) {
-          for (TypeHandler handler : handlers) {
-            handler.postGetMetadataHandle(metadata);
-          }
+  }
+
+  private List<Product> query(Query query, ProductType productType) throws CatalogException {
+    List<String> productIdList;
+    List<Product> productList;
+
+    try {
+      productIdList = catalog.query(this.getCatalogQuery(query, productType), productType);
+
+      if (productIdList != null && productIdList.size() > 0) {
+        productList = new Vector<Product>(productIdList.size());
+        for (String productId : productIdList) {
+          Product product = catalog.getProductById(productId);
+          // it is possible here that the underlying catalog did not
+          // set the ProductType
+          // to obey the contract of the File Manager, we need to make
+          // sure its set here
+          product.setProductType(this.repositoryManager
+              .getProductTypeById(product.getProductType()
+                                         .getProductTypeId()));
+          productList.add(product);
         }
-        return metadata;
+        return productList;
+      } else {
+        return new Vector<Product>(); // null values not supported by XML-RPC
+      }
+    } catch (Exception e) {
+      LOG.log(Level.SEVERE, e.getMessage());
+      LOG.log(Level.SEVERE,
+          "Exception performing query against catalog for product type: ["
+          + productType.getName() + "] Message: " + e.getMessage());
+      throw new CatalogException(e.getMessage(), e);
     }
-    
-    private Metadata getCatalogValues(Metadata metadata, ProductType productType) 
-            throws RepositoryManagerException {
-        List<TypeHandler> handlers = this.repositoryManager.getProductTypeById(
-                productType.getProductTypeId()).getHandlers();
-        if (handlers != null) {
-          for (TypeHandler handler : handlers) {
-            handler.preAddMetadataHandle(metadata);
-          }
-        }
-        return metadata;
+  }
+
+  private Metadata getReducedMetadata(Product product, List<String> elements) throws CatalogException {
+    try {
+      Metadata m;
+      if (elements != null && elements.size() > 0) {
+        m = catalog.getReducedMetadata(product, elements);
+      } else {
+        m = this.getMetadata(product);
+      }
+      if (this.expandProductMet) {
+        m = this.buildProductMetadata(product, m);
+      }
+      return this.getOrigValues(m, product.getProductType());
+    } catch (Exception e) {
+      LOG.log(Level.SEVERE, e.getMessage());
+      LOG.log(Level.SEVERE,
+          "Exception obtaining metadata from catalog for product: ["
+          + product.getProductId() + "]: Message: "
+          + e.getMessage());
+      throw new CatalogException(e.getMessage(), e);
     }
-    
-    private Query getCatalogQuery(Query query, ProductType productType)
-            throws RepositoryManagerException, QueryFormulationException {
-        List<TypeHandler> handlers = this.repositoryManager.getProductTypeById(
-                productType.getProductTypeId()).getHandlers();
-        if (handlers != null) {
-          for (TypeHandler handler : handlers) {
-            handler.preQueryHandle(query);
-          }
-        }
-        return query;
+  }
+
+  private Metadata getMetadata(Product product) throws CatalogException {
+    try {
+      Metadata m = catalog.getMetadata(product);
+      if (this.expandProductMet) {
+        m = this.buildProductMetadata(product, m);
+      }
+      return this.getOrigValues(m, product.getProductType());
+    } catch (Exception e) {
+      LOG.log(Level.SEVERE, e.getMessage());
+      LOG.log(Level.SEVERE,
+          "Exception obtaining metadata from catalog for product: ["
+          + product.getProductId() + "]: Message: "
+          + e.getMessage());
+      throw new CatalogException(e.getMessage(), e);
     }
+  }
 
-    @SuppressWarnings("unchecked")
-    private List<QueryResult> applyFilterToResults(
-            List<QueryResult> queryResults, QueryFilter queryFilter)
-        throws Exception {
-        List<TimeEvent> events = new LinkedList<TimeEvent>();
-        for (QueryResult queryResult : queryResults) {
-            Metadata m = new Metadata();
-            m.addMetadata(queryFilter.getPriorityMetKey(), queryResult
-                .getMetadata().getMetadata(queryFilter.getPriorityMetKey()));
-            events.add(new ObjectTimeEvent<QueryResult>(
-                DateUtils.getTimeInMillis(DateUtils.toCalendar(queryResult
-                    .getMetadata().getMetadata(queryFilter.getStartDateTimeMetKey()),
-                    DateUtils.FormatType.UTC_FORMAT), DateUtils.julianEpoch), 
-                DateUtils.getTimeInMillis(DateUtils.toCalendar(queryResult.getMetadata()
-                    .getMetadata(queryFilter.getEndDateTimeMetKey()),
-                    DateUtils.FormatType.UTC_FORMAT),
-                DateUtils.julianEpoch), queryFilter.getConverter()
-                    .convertToPriority(this.getCatalogValues(m,
-                    queryResult.getProduct().getProductType())
-                    .getMetadata(queryFilter.getPriorityMetKey())),
-                queryResult));
-        }
-        events = queryFilter.getFilterAlgor().filterEvents(events);
-        List<QueryResult> filteredQueryResults = new LinkedList<QueryResult>();
-        for (TimeEvent event : events) {
-          filteredQueryResults.add(((ObjectTimeEvent<QueryResult>) event)
-              .getTimeObject());
-        }
+  private Metadata getOrigValues(Metadata metadata, ProductType productType)
+      throws RepositoryManagerException {
+    List<TypeHandler> handlers = this.repositoryManager.getProductTypeById(
+        productType.getProductTypeId()).getHandlers();
+    if (handlers != null) {
+      for (TypeHandler handler : handlers) {
+        handler.postGetMetadataHandle(metadata);
+      }
+    }
+    return metadata;
+  }
 
-        return filteredQueryResults;
+  private Metadata getCat

<TRUNCATED>