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:05 UTC
[2/6] oodt git commit: OODT-917 alter XMLRPC interface to support
more generic map types where suitable
OODT-917 alter XMLRPC interface to support more generic map types where suitable
Project: http://git-wip-us.apache.org/repos/asf/oodt/repo
Commit: http://git-wip-us.apache.org/repos/asf/oodt/commit/3e0e5972
Tree: http://git-wip-us.apache.org/repos/asf/oodt/tree/3e0e5972
Diff: http://git-wip-us.apache.org/repos/asf/oodt/diff/3e0e5972
Branch: refs/heads/master
Commit: 3e0e5972a6f6466add63d4edd204264eb3f50499
Parents: aa5e31a
Author: Tom Barber <to...@analytical-labs.com>
Authored: Wed Nov 4 12:09:13 2015 +0000
Committer: Tom Barber <to...@analytical-labs.com>
Committed: Wed Nov 4 12:09:13 2015 +0000
----------------------------------------------------------------------
.../cas/filemgr/system/XmlRpcFileManager.java | 573 ++++++-------------
.../filemgr/system/XmlRpcFileManagerClient.java | 42 +-
.../cas/filemgr/util/XmlRpcStructFactory.java | 261 +++------
.../org/apache/oodt/cas/metadata/Metadata.java | 16 +-
4 files changed, 275 insertions(+), 617 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/oodt/blob/3e0e5972/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 4be4dc1..e5ad57b 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,6 +56,7 @@ import org.apache.xmlrpc.WebServer;
import com.google.common.collect.Lists;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -162,13 +163,17 @@ public class XmlRpcFileManager {
return status;
}
- public boolean transferringProduct(Map<String, Object> productHash) {
+ 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;
}
- public Map<String, Object> getCurrentFileTransfer() {
+ public Map<String, Object> getCurrentFileTransferCore() {
FileTransferStatus status = transferStatusTracker
.getCurrentFileTransfer();
if (status == null) {
@@ -189,12 +194,18 @@ public class XmlRpcFileManager {
}
}
- public double getProductPctTransferred(Map<String, Object> productHash) {
+ 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 getRefPctTransferred(Map<String, Object> refHash) {
+ 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;
@@ -211,18 +222,29 @@ public class XmlRpcFileManager {
return pct;
}
- public boolean removeProductTransferStatus(Map<String, Object> productHash) {
+ 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 isTransferComplete(Map<String, Object> productHash) {
+ 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 Map<String, Object> pagedQuery(
+ Hashtable<String, Object> queryHash,
+ Hashtable<String, Object> productTypeHash,
+ int pageNum) throws CatalogException {
+ return this.pagedQueryCore(queryHash,productTypeHash,pageNum);
+ }
- public Map<String, Object> pagedQuery(
+ public Map<String, Object> pagedQueryCore(
Map<String, Object> queryHash,
Map<String, Object> productTypeHash,
int pageNum) throws CatalogException {
@@ -256,23 +278,13 @@ public class XmlRpcFileManager {
return XmlRpcStructFactory.getXmlRpcProductPage(prodPage);
}
- public Map<String, Object> getFirstPage(
- Map<String, Object> productTypeHash) {
- ProductType type = XmlRpcStructFactory
- .getProductTypeFromXmlRpc(productTypeHash);
- ProductPage page = catalog.getFirstPage(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> getFirstPage(
+ Hashtable<String, Object> productTypeHash){
+ return this.getFirstPageCore(productTypeHash);
+ }
- public Hashtable<String, Object> getFirstPage(
- Hashtable<String, Object> productTypeHash) {
+ public Map<String, Object> getFirstPageCore(
+ Map<String, Object> productTypeHash) {
ProductType type = XmlRpcStructFactory
.getProductTypeFromXmlRpc(productTypeHash);
ProductPage page = catalog.getFirstPage(type);
@@ -286,7 +298,12 @@ public class XmlRpcFileManager {
return XmlRpcStructFactory.getXmlRpcProductPage(page);
}
- public Map<String, Object> getLastPage(
+
+ public Map<String, Object> getLastPage(
+ Hashtable<String, Object> productTypeHash){
+ return this.getLastPageCore(productTypeHash);
+ }
+ public Map<String, Object> getLastPageCore(
Map<String, Object> productTypeHash) {
ProductType type = XmlRpcStructFactory
.getProductTypeFromXmlRpc(productTypeHash);
@@ -301,7 +318,12 @@ public class XmlRpcFileManager {
return XmlRpcStructFactory.getXmlRpcProductPage(page);
}
- public Map<String, Object> getNextPage(
+ public Map<String, Object> getNextPage(
+ Hashtable<String, Object> productTypeHash,
+ 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
@@ -318,8 +340,12 @@ public class XmlRpcFileManager {
}
return XmlRpcStructFactory.getXmlRpcProductPage(page);
}
-
- public Map<String, Object> getPrevPage(
+ public Map<String, Object> getPrevPage(
+ Hashtable<String, Object> productTypeHash,
+ 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
@@ -337,7 +363,12 @@ public class XmlRpcFileManager {
return XmlRpcStructFactory.getXmlRpcProductPage(page);
}
- public String addProductType(Map<String, Object> productTypeHash)
+ 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);
@@ -346,44 +377,26 @@ public class XmlRpcFileManager {
}
- public synchronized boolean setProductTransferStatus(
- Map<String, Object> productHash)
- throws CatalogException {
- Product product = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
- catalog.setProductTransferStatus(product);
- return true;
- }
-
public synchronized boolean setProductTransferStatus(
Hashtable<String, Object> productHash)
throws CatalogException {
+ return this.setProductTransferStatusCore(productHash);
+ }
+
+ public synchronized boolean setProductTransferStatusCore(
+ Map<String, Object> productHash)
+ throws CatalogException {
Product product = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
catalog.setProductTransferStatus(product);
return true;
}
- public int getNumProducts(Map<String, Object> productTypeHash)
- throws CatalogException {
- int numProducts;
-
- ProductType type = XmlRpcStructFactory
- .getProductTypeFromXmlRpc(productTypeHash);
-
- try {
- numProducts = catalog.getNumProducts(type);
- } catch (CatalogException e) {
- LOG.log(Level.SEVERE, e.getMessage());
- LOG.log(Level.WARNING,
- "Exception when getting num products: Message: "
- + e.getMessage());
- throw new CatalogException(e.getMessage(), e);
- }
-
- return numProducts;
- }
-
public int getNumProducts(Hashtable<String, Object> productTypeHash)
throws CatalogException {
+ return this.getNumProductsCore(productTypeHash);
+ }
+ public int getNumProductsCore(Map<String, Object> productTypeHash)
+ throws CatalogException {
int numProducts;
ProductType type = XmlRpcStructFactory
@@ -418,7 +431,7 @@ public class XmlRpcFileManager {
}
}
- public List<Hashtable<String, Object>> getTopNProducts(int n)
+ public List<Map<String, Object>> getTopNProducts(int n)
throws CatalogException {
List<Product> topNProducts;
@@ -434,27 +447,12 @@ public class XmlRpcFileManager {
}
}
- public List<Hashtable<String, Object>> getTopNProducts(int n,
+ public List<Map<String, Object>> getTopNProducts(int n,
Hashtable<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);
- }
-
+ return this.getTopNProductsCore(n, productTypeHash);
}
- public List<Map<String, Object>> getTopNProducts(int n,
+ public List<Map<String, Object>> getTopNProductsCore(int n,
Map<String, Object> productTypeHash)
throws CatalogException {
ProductType type = XmlRpcStructFactory
@@ -481,31 +479,29 @@ public class XmlRpcFileManager {
&& p.getTransferStatus().equals(Product.STATUS_RECEIVED);
}
- public Map<String, Object> getMetadata(
+
+ 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).getMap();
+ return this.getMetadata(product).getHashTable();
}
- public Hashtable<String, Object> getMetadata(
- Hashtable<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> getReducedMetadata(
+ public Map<String, Object> getReducedMetadataCore(
Map<String, Object> productHash, Vector<String> elements)
throws CatalogException {
Product product = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
- return this.getReducedMetadata(product, elements).getMap();
+ return this.getReducedMetadata(product, elements).getHashTable();
}
- public Hashtable<String, Object> getReducedMetadata(
- Hashtable<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;
@@ -523,28 +519,15 @@ public class XmlRpcFileManager {
}
}
- public List<Map<String, Object>> getProductReferences(
- Map<String, Object> productHash)
- throws CatalogException {
- List<Reference> referenceList;
- Product product = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
-
- try {
- referenceList = catalog.getProductReferences(product);
- return XmlRpcStructFactory.getXmlRpcReferencesMap(referenceList);
- } catch (CatalogException e) {
- LOG.log(Level.SEVERE, e.getMessage());
- LOG.log(Level.SEVERE, "Unable to obtain references for product: ["
- + product.getProductName() + "]: Message: "
- + e.getMessage());
- throw new CatalogException(e.getMessage(), e);
- }
-
- }
-
- public List<Hashtable<String, Object>> getProductReferences(
+ public List<Map<String, Object>> getProductReferences(
Hashtable<String, Object> productHash)
throws CatalogException {
+ return this.getProductReferencesCore(productHash);
+ }
+
+ public List<Map<String, Object>> getProductReferencesCore(
+ Map<String, Object> productHash)
+ throws CatalogException {
List<Reference> referenceList;
Product product = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
@@ -617,7 +600,12 @@ public class XmlRpcFileManager {
}
}
- public List<Map<String, Object>> getProductsByProductType(
+ 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
@@ -636,24 +624,6 @@ public class XmlRpcFileManager {
}
}
- public List<Hashtable<String, Object>> getProductsByProductType(
- Hashtable<String, Object> productTypeHash)
- throws CatalogException {
- ProductType type = XmlRpcStructFactory
- .getProductTypeFromXmlRpc(productTypeHash);
- List<Product> productList;
-
- 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);
- }
- }
public List<Map<String, Object>> getElementsByProductType(
Map<String, Object> productTypeHash)
throws ValidationLayerException {
@@ -706,7 +676,11 @@ public class XmlRpcFileManager {
}
}
- public List<Map<String, Object>> complexQueryMap(
+ 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
@@ -766,81 +740,17 @@ public class XmlRpcFileManager {
+ e.getMessage(), e);
}
}
-
- public List<Hashtable<String, Object>> complexQuery(
- Hashtable<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(
- Map<String, Object> queryHash,
- Map<String, Object> productTypeHash)
- throws CatalogException {
- Query query = XmlRpcStructFactory.getQueryFromXmlRpcMap(queryHash);
- ProductType type = XmlRpcStructFactory
- .getProductTypeFromXmlRpc(productTypeHash);
- return XmlRpcStructFactory.getXmlRpcProductListMap(this.query(query, type));
- }
-
- public List<Hashtable<String, Object>> query(
+ public List<Map<String, Object>> query(
Hashtable<String, Object> queryHash,
Hashtable<String, Object> productTypeHash)
throws CatalogException {
+ return this.queryCore(queryHash, productTypeHash);
+ }
+
+ public List<Map<String, Object>> queryCore(
+ Map<String, Object> queryHash,
+ Map<String, Object> productTypeHash)
+ throws CatalogException {
Query query = XmlRpcStructFactory.getQueryFromXmlRpc(queryHash);
ProductType type = XmlRpcStructFactory
.getProductTypeFromXmlRpc(productTypeHash);
@@ -854,7 +764,7 @@ public class XmlRpcFileManager {
return XmlRpcStructFactory.getXmlRpcProductType(type);
}
- public Hashtable<String, Object> getProductTypeByName(String productTypeName)
+ public Map<String, Object> getProductTypeByName(String productTypeName)
throws RepositoryManagerException {
ProductType type = repositoryManager
.getProductTypeByName(productTypeName);
@@ -876,8 +786,13 @@ public class XmlRpcFileManager {
throw new RepositoryManagerException(e.getMessage(), e);
}
}
-
- public synchronized boolean updateMetadata(Map<String, Object> productHash,
+ public synchronized boolean updateMetadata(Hashtable<String, Object> productHash,
+ 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();
@@ -888,28 +803,22 @@ public class XmlRpcFileManager {
return true;
}
- public synchronized boolean updateMetadata(Hashtable<String, Object> productHash,
- Hashtable<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 catalogProduct(Map<String, Object> productHash)
+ public synchronized String catalogProductCore(Map<String, Object> productHash)
throws CatalogException {
Product p = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
return catalogProduct(p);
}
- public synchronized String catalogProduct(Hashtable<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 addMetadata(Map<String, Object> productHash,
+ public synchronized boolean addMetadataCore(Map<String, Object> productHash,
Map<String, String> metadata) throws CatalogException {
Product p = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
Metadata m = new Metadata();
@@ -917,14 +826,7 @@ public class XmlRpcFileManager {
return addMetadata(p, m) != null;
}
- public synchronized boolean addMetadata(Hashtable<String, Object> productHash,
- Hashtable<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 addProductReferences(Map<String, Object> productHash)
+ public synchronized boolean addProductReferencesCore(Map<String, Object> productHash)
throws CatalogException {
Product product = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
return addProductReferences(product);
@@ -932,12 +834,16 @@ public class XmlRpcFileManager {
public synchronized boolean addProductReferences(Hashtable<String, Object> productHash)
throws CatalogException {
- Product product = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
- return addProductReferences(product);
+ return this.addProductReferencesCore(productHash);
+ }
+
+ public String ingestProduct(Hashtable<String, Object> ph, Hashtable<String, String> m, boolean ct)
+ throws CatalogException {
+ return this.ingestProductCore(ph, m, ct);
}
- public String ingestProduct(Map<String, Object> productHash,
+ public String ingestProductCore(Map<String, Object> productHash,
Map<String, String> metadata, boolean clientTransfer)
throws
CatalogException {
@@ -1012,83 +918,7 @@ public class XmlRpcFileManager {
}
}
-
- public String ingestProduct(Hashtable<String, Object> productHash,
- Hashtable<String, String> metadata, boolean clientTransfer)
- throws
- CatalogException {
-
- Product p = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
-
- try {
- // first, create the product
- p.setTransferStatus(Product.STATUS_TRANSFER);
- catalogProduct(p);
-
- // now add the metadata
- Metadata m = new Metadata();
- m.addMetadata((Map)metadata);
- Metadata expandedMetdata = addMetadata(p, m);
-
- // version the product
- if (!clientTransfer || (Boolean.getBoolean("org.apache.oodt.cas.filemgr.serverside.versioning"))) {
- Versioner versioner;
- try {
- versioner = GenericFileManagerObjectFactory
- .getVersionerFromClassName(p.getProductType().getVersioner());
- if (versioner != null) {
- versioner.createDataStoreReferences(p, expandedMetdata);
- }
- } catch (Exception e) {
- LOG.log(Level.SEVERE,
- "ingestProduct: VersioningException when versioning Product: "
- + p.getProductName() + " with Versioner "
- + p.getProductType().getVersioner() + ": Message: "
- + e.getMessage());
- throw new VersioningException(e);
- }
-
- // add the newly versioned references to the data store
- addProductReferences(p);
- }
-
- if (!clientTransfer) {
- LOG.log(Level.FINEST,
- "File Manager: ingest: no client transfer enabled, "
- + "server transfering product: [" + p.getProductName() + "]");
-
- // now transfer the product
- try {
- dataTransfer.transferProduct(p);
- // now update the product's transfer status in the data store
- p.setTransferStatus(Product.STATUS_RECEIVED);
-
- try {
- catalog.setProductTransferStatus(p);
- } catch (CatalogException e) {
- LOG.log(Level.SEVERE, "ingestProduct: CatalogException "
- + "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());
- throw new DataTransferException(e);
- }
- }
-
- // that's it!
- return p.getProductId();
- } catch (Exception e) {
- LOG.log(Level.SEVERE, e.getMessage());
- throw new CatalogException("Error ingesting product [" + p + "] : "
- + e.getMessage(),e);
- }
-
- }
- public byte[] retrieveFile(String filePath, int offset, int numBytes)
+ public byte[] retrieveFile(String filePath, int offset, int numBytes)
throws DataTransferException {
FileInputStream is = null;
try {
@@ -1174,7 +1004,12 @@ public class XmlRpcFileManager {
return success;
}
- public boolean moveProduct(Map<String, Object> productHash, String newPath)
+ 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);
@@ -1242,73 +1077,6 @@ public class XmlRpcFileManager {
}
}
- public boolean moveProduct(Hashtable<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 removeFile(String filePath) throws DataTransferException, IOException {
// TODO(bfoster): Clean this up so that it deletes by product not file.
Product product = new Product();
@@ -1319,7 +1087,10 @@ public class XmlRpcFileManager {
return true;
}
- public boolean modifyProduct(Map<?, ?> productHash) throws CatalogException {
+ public boolean modifyProduct(Hashtable<?, ?> productHash) throws CatalogException {
+ return this.modifyProductCore(productHash);
+ }
+ public boolean modifyProductCore(Map<?, ?> productHash) throws CatalogException {
Product p = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
try {
@@ -1346,48 +1117,46 @@ public class XmlRpcFileManager {
return true;
}
-
- public Map<String, Object> getCatalogValues(
+ 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).getMap();
+ return this.getCatalogValues(m, productType).getHashTable();
}
- public Hashtable<String, Object> getCatalogValues(
+ public Map<String, Object> getOrigValues(
Hashtable<String, Object> metadataHash,
Hashtable<String, Object> productTypeHash)
throws RepositoryManagerException {
- Metadata m = new Metadata();
- m.addMetadata(metadataHash);
- ProductType productType = XmlRpcStructFactory.getProductTypeFromXmlRpc(productTypeHash);
- return this.getCatalogValues(m, productType).getHashTable();
+ return this.getOrigValuesCore(metadataHash, productTypeHash);
}
- public Map<String, Object> getOrigValues(
+ 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).getMap();
+ return this.getOrigValues(m, productType).getHashTable();
}
- public Hashtable<String, Object> getOrigValues(
- Hashtable<String, Object> metadataHash,
+ public Map<String, Object> getCatalogQuery(
+ Hashtable<String, Object> queryHash,
Hashtable<String, Object> productTypeHash)
- throws RepositoryManagerException {
- Metadata m = new Metadata();
- m.addMetadata(metadataHash);
- ProductType productType = XmlRpcStructFactory.getProductTypeFromXmlRpc(productTypeHash);
- return this.getOrigValues(m, productType).getHashTable();
+ throws RepositoryManagerException, QueryFormulationException {
+ return this.getCatalogQueryCore(queryHash, productTypeHash);
}
-
- public Map<String, Object> getCatalogQuery(
+ public Map<String, Object> getCatalogQueryCore(
Map<String, Object> queryHash,
Map<String, Object> productTypeHash)
throws RepositoryManagerException, QueryFormulationException {
@@ -1396,14 +1165,6 @@ public class XmlRpcFileManager {
return XmlRpcStructFactory.getXmlRpcQuery(this.getCatalogQuery(query, productType));
}
- public Hashtable<String, Object> getCatalogQuery(
- Hashtable<String, Object> queryHash,
- Hashtable<String, Object> productTypeHash)
- throws RepositoryManagerException, QueryFormulationException {
- Query query = XmlRpcStructFactory.getQueryFromXmlRpc(queryHash);
- ProductType productType = XmlRpcStructFactory.getProductTypeFromXmlRpc(productTypeHash);
- return XmlRpcStructFactory.getXmlRpcQuery(this.getCatalogQuery(query, productType));
- }
public static void main(String[] args) throws IOException {
int portNum = -1;
@@ -1508,7 +1269,7 @@ public class XmlRpcFileManager {
}
Metadata met = new Metadata();
- met.addMetadata(metadata.getMap());
+ met.addMetadata(metadata.getHashTable());
if (product.getProductType().getExtractors() != null) {
for (ExtractorSpec spec: product.getProductType().getExtractors()) {
http://git-wip-us.apache.org/repos/asf/oodt/blob/3e0e5972/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManagerClient.java
----------------------------------------------------------------------
diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManagerClient.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManagerClient.java
index 5c471d9..cb80e08 100644
--- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManagerClient.java
+++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManagerClient.java
@@ -223,7 +223,7 @@ public class XmlRpcFileManagerClient {
public boolean transferringProduct(Product product)
throws DataTransferException {
Vector<Object> argList = new Vector<Object>();
- Hashtable<String, Object> productHash = XmlRpcStructFactory
+ Map<String, Object> productHash = XmlRpcStructFactory
.getXmlRpcProduct(product);
argList.add(productHash);
@@ -636,10 +636,10 @@ public class XmlRpcFileManagerClient {
Vector<Object> argList = new Vector<Object>();
argList.add(n);
- Vector<Hashtable<String, Object>> topNProducts;
+ Vector<Map<String, Object>> topNProducts;
try {
- topNProducts = (Vector<Hashtable<String, Object>>) client.execute(
+ topNProducts = (Vector<Map<String, Object>>) client.execute(
"filemgr.getTopNProducts", argList);
} catch (XmlRpcException e) {
throw new CatalogException(e);
@@ -660,10 +660,10 @@ public class XmlRpcFileManagerClient {
.getXmlRpcProductType(type);
argList.add(productTypeHash);
- Vector<Hashtable<String, Object>> topNProducts;
+ Vector<Map<String, Object>> topNProducts;
try {
- topNProducts = (Vector<Hashtable<String, Object>>) client.execute(
+ topNProducts = (Vector<Map<String, Object>>) client.execute(
"filemgr.getTopNProducts", argList);
} catch (XmlRpcException e) {
throw new CatalogException(e);
@@ -869,10 +869,10 @@ public class XmlRpcFileManagerClient {
.getXmlRpcProductType(type);
argList.add(productTypeHash);
- Vector<Hashtable<String, Object>> productVector;
+ Vector<Map<String, Object>> productVector;
try {
- productVector = (Vector<Hashtable<String, Object>>) client.execute(
+ productVector = (Vector<Map<String, Object>>) client.execute(
"filemgr.getProductsByProductType", argList);
} catch (XmlRpcException e) {
throw new CatalogException(e);
@@ -896,10 +896,10 @@ public class XmlRpcFileManagerClient {
argList.add(productTypeHash);
- Vector<Hashtable<String, Object>> elementVector;
+ Vector<Map<String, Object>> elementVector;
try {
- elementVector = (Vector<Hashtable<String, Object>>) client.execute(
+ elementVector = (Vector<Map<String, Object>>) client.execute(
"filemgr.getElementsByProductType", argList);
} catch (XmlRpcException e) {
throw new ValidationLayerException(e);
@@ -990,12 +990,12 @@ public class XmlRpcFileManagerClient {
public List<QueryResult> complexQuery(ComplexQuery complexQuery)
throws CatalogException {
try {
- Hashtable<String, Object> complexQueryHash = XmlRpcStructFactory
+ Map<String, Object> complexQueryHash = XmlRpcStructFactory
.getXmlRpcComplexQuery(complexQuery);
Vector<Object> argList = new Vector<Object>();
argList.add(complexQueryHash);
@SuppressWarnings("unchecked")
- Vector<Hashtable<String, Object>> queryResultHashVector = (Vector<Hashtable<String, Object>>) client
+ Vector<Map<String, Object>> queryResultHashVector = (Vector<Map<String, Object>>) client
.execute("filemgr.complexQuery", argList);
return XmlRpcStructFactory
.getQueryResultsFromXmlRpc(queryResultHashVector);
@@ -1016,10 +1016,10 @@ public class XmlRpcFileManagerClient {
argList.add(queryHash);
argList.add(typeHash);
- Vector<Hashtable<String, Object>> productVector;
+ Vector<Map<String, Object>> productVector;
try {
- productVector = (Vector<Hashtable<String, Object>>) client.execute(
+ productVector = (Vector<Map<String, Object>>) client.execute(
"filemgr.query", argList);
} catch (XmlRpcException e) {
LOG.log(Level.SEVERE, e.getMessage());
@@ -1114,13 +1114,13 @@ public class XmlRpcFileManagerClient {
throws CatalogException {
Vector<Object> argList = new Vector<Object>();
- Vector<Hashtable<String, Object>> productReferenceVector;
- Hashtable<String, Object> productHash = XmlRpcStructFactory
+ Vector<Map<String, Object>> productReferenceVector;
+ Map<String, Object> productHash = XmlRpcStructFactory
.getXmlRpcProduct(product);
argList.add(productHash);
try {
- productReferenceVector = (Vector<Hashtable<String, Object>>) client
+ productReferenceVector = (Vector<Map<String, Object>>) client
.execute("filemgr.getProductReferences", argList);
} catch (XmlRpcException e) {
throw new CatalogException(e);
@@ -1140,11 +1140,11 @@ public class XmlRpcFileManagerClient {
public Product getProductById(String productId) throws CatalogException {
Vector<Object> argList = new Vector<Object>();
- Hashtable<String, Object> productHash;
+ Map<String, Object> productHash;
argList.add(productId);
try {
- productHash = (Hashtable<String, Object>) client.execute(
+ productHash = (Map<String, Object>) client.execute(
"filemgr.getProductById", argList);
} catch (XmlRpcException e) {
throw new CatalogException(e);
@@ -1163,11 +1163,11 @@ public class XmlRpcFileManagerClient {
public Product getProductByName(String productName) throws CatalogException {
Vector<Object> argList = new Vector<Object>();
- Hashtable<String, Object> productHash;
+ Map<String, Object> productHash;
argList.add(productName);
try {
- productHash = (Hashtable<String, Object>) client.execute(
+ productHash = (Map<String, Object>) client.execute(
"filemgr.getProductByName", argList);
} catch (XmlRpcException e) {
throw new CatalogException(e);
@@ -1187,7 +1187,7 @@ public class XmlRpcFileManagerClient {
try {
// ingest product
Vector<Object> argList = new Vector<Object>();
- Hashtable<String, Object> productHash = XmlRpcStructFactory
+ Map<String, Object> productHash = XmlRpcStructFactory
.getXmlRpcProduct(product);
argList.add(productHash);
argList.add(metadata.getHashTable());
http://git-wip-us.apache.org/repos/asf/oodt/blob/3e0e5972/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/XmlRpcStructFactory.java
----------------------------------------------------------------------
diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/XmlRpcStructFactory.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/XmlRpcStructFactory.java
index a7b4964..d10ef2a 100644
--- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/XmlRpcStructFactory.java
+++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/util/XmlRpcStructFactory.java
@@ -67,7 +67,7 @@ public final class XmlRpcStructFactory {
public static Map<String, Object> getXmlRpcFileTransferStatus(
FileTransferStatus status) {
- Map<String, Object> statusHash = new ConcurrentHashMap<String, Object>();
+ Map<String, Object> statusHash = new Hashtable<String, Object>();
statusHash.put("bytesTransferred",Long.toString(status
.getBytesTransferred()));
statusHash.put("parentProduct", getXmlRpcProduct(status
@@ -113,7 +113,7 @@ public final class XmlRpcStructFactory {
return statuses;
}
- public static Hashtable<String, Object> getXmlRpcProductPage(ProductPage page) {
+ public static Map<String, Object> getXmlRpcProductPage(ProductPage page) {
Hashtable<String, Object>productPageHash = new Hashtable<String, Object>();
productPageHash.put("totalPages", page.getTotalPages());
productPageHash.put("pageNum", page.getPageNum());
@@ -123,16 +123,6 @@ public final class XmlRpcStructFactory {
return productPageHash;
}
- public static Map<String, Object> getXmlRpcProductPageMap(ProductPage page) {
- Map<String, Object>productPageHash = new ConcurrentHashMap<String, Object>();
- productPageHash.put("totalPages", page.getTotalPages());
- productPageHash.put("pageNum", page.getPageNum());
- productPageHash.put("pageSize", page.getPageSize());
- productPageHash.put("pageProducts", getXmlRpcProductList(page
- .getPageProducts()));
- return productPageHash;
- }
-
@SuppressWarnings("unchecked")
public static ProductPage getProductPageFromXmlRpc(Map<String, Object> productPageHash) {
ProductPage page = new ProductPage();
@@ -140,36 +130,12 @@ public final class XmlRpcStructFactory {
page
.setPageSize((Integer) productPageHash.get("pageSize"));
page.setTotalPages((Integer) productPageHash.get("totalPages"));
- page.setPageProducts(getProductListFromXmlRpc((Vector<Hashtable<String, Object>>) productPageHash
+ page.setPageProducts(getProductListFromXmlRpc((Vector<Map<String, Object>>) productPageHash
.get("pageProducts")));
return page;
}
- public static Hashtable<String, Object> getXmlRpcComplexQuery(ComplexQuery complexQuery) {
- Hashtable<String, Object> complexQueryHash = getXmlRpcQuery(complexQuery);
- if (complexQuery.getReducedProductTypeNames() != null) {
- complexQueryHash
- .put("reducedProductTypeNames", new Vector<String>(complexQuery.getReducedProductTypeNames()));
- } else {
- complexQueryHash.put("reducedProductTypeNames", new Vector<String>());
- }
- if (complexQuery.getReducedMetadata() != null) {
- complexQueryHash.put("reducedMetadata", new Vector<String>(complexQuery.getReducedMetadata()));
- } else {
- complexQueryHash.put("reducedMetadata", new Vector<String>());
- }
- if (complexQuery.getSortByMetKey() != null) {
- complexQueryHash.put("sortByMetKey", complexQuery.getSortByMetKey());
- }
- if (complexQuery.getToStringResultFormat() != null) {
- complexQueryHash.put("toStringResultFormat", complexQuery.getToStringResultFormat());
- }
- if (complexQuery.getQueryFilter() != null) {
- complexQueryHash.put("queryFilter", getXmlRpcQueryFilter(complexQuery.getQueryFilter()));
- }
- return complexQueryHash;
- }
- public static Map<String, Object> getXmlRpcComplexQueryMap(ComplexQuery complexQuery) {
+ public static Map<String, Object> getXmlRpcComplexQuery(ComplexQuery complexQuery) {
Map<String, Object> complexQueryHash = getXmlRpcQuery(complexQuery);
if (complexQuery.getReducedProductTypeNames() != null) {
complexQueryHash
@@ -193,8 +159,9 @@ public final class XmlRpcStructFactory {
}
return complexQueryHash;
}
+
@SuppressWarnings("unchecked")
- public static ComplexQuery getComplexQueryFromXmlRpc(Hashtable<String, Object> complexQueryHash) {
+ public static ComplexQuery getComplexQueryFromXmlRpc(Map<String, Object> complexQueryHash) {
ComplexQuery complexQuery = new ComplexQuery();
complexQuery.setCriteria(getQueryFromXmlRpc(complexQueryHash).getCriteria());
if (((Vector<String>) complexQueryHash.get("reducedProductTypeNames")).size() > 0) {
@@ -265,8 +232,8 @@ public final class XmlRpcStructFactory {
return filterAlgor;
}
- public static Vector<Hashtable<String, Object>> getXmlRpcQueryResults(List<QueryResult> queryResults) {
- Vector<Hashtable<String, Object>> queryResultHashVector = new Vector<Hashtable<String, Object>>();
+ public static Vector<Map<String, Object>> getXmlRpcQueryResults(List<QueryResult> queryResults) {
+ Vector<Map<String, Object>> queryResultHashVector = new Vector<Map<String, Object>>();
for (QueryResult queryResult : queryResults) {
queryResultHashVector.add(getXmlRpcQueryResult(queryResult));
}
@@ -281,9 +248,9 @@ public final class XmlRpcStructFactory {
return queryResultHashVector;
}
- public static List<QueryResult> getQueryResultsFromXmlRpc(Vector<Hashtable<String, Object>> queryResultHashVector) {
+ public static List<QueryResult> getQueryResultsFromXmlRpc(Vector<Map<String, Object>> queryResultHashVector) {
List<QueryResult> queryResults = new Vector<QueryResult>();
- for (Hashtable<String, Object> queryResultHash : queryResultHashVector) {
+ for (Map<String, Object> queryResultHash : queryResultHashVector) {
queryResults.add(getQueryResultFromXmlRpc(queryResultHash));
}
return queryResults;
@@ -297,28 +264,20 @@ public final class XmlRpcStructFactory {
}
return queryResults;
}
- public static Hashtable<String, Object> getXmlRpcQueryResult(QueryResult queryResult) {
+ public static Map<String, Object> getXmlRpcQueryResult(QueryResult queryResult) {
Hashtable<String, Object> queryResultHash = new Hashtable<String, Object>();
if (queryResult.getToStringFormat() != null) {
queryResultHash.put("toStringFormat", queryResult.getToStringFormat());
}
queryResultHash.put("product", getXmlRpcProduct(queryResult.getProduct()));
- queryResultHash.put("metadata", queryResult.getMetadata().getMap());
- return queryResultHash;
- }
- public static Map<String, Object> getXmlRpcQueryResultMap(QueryResult queryResult) {
- Map<String, Object> queryResultHash = new ConcurrentHashMap<String, Object>();
- if (queryResult.getToStringFormat() != null) {
- queryResultHash.put("toStringFormat", queryResult.getToStringFormat());
- }
- queryResultHash.put("product", getXmlRpcProduct(queryResult.getProduct()));
- queryResultHash.put("metadata", queryResult.getMetadata().getMap());
+ queryResultHash.put("metadata", queryResult.getMetadata().getHashTable());
return queryResultHash;
}
+
@SuppressWarnings("unchecked")
public static QueryResult getQueryResultFromXmlRpc(Map<String, Object> queryResultHash) {
- Product product = getProductFromXmlRpc((Hashtable<String, Object>) queryResultHash.get("product"));
+ Product product = getProductFromXmlRpc((Map<String, Object>) queryResultHash.get("product"));
Metadata metadata = new Metadata();
metadata.addMetadata((Map<String, Object>) queryResultHash.get("metadata"));
QueryResult queryResult = new QueryResult(product, metadata);
@@ -326,8 +285,8 @@ public final class XmlRpcStructFactory {
return queryResult;
}
- public static Hashtable<String, Object> getXmlRpcProduct(Product product) {
- Hashtable<String, Object> productHash = new Hashtable<String, Object>();
+ public static Map<String, Object> getXmlRpcProduct(Product product) {
+ Map<String, Object> productHash = new Hashtable<String, Object>();
if (product.getProductId() != null) {
productHash.put("id", product.getProductId());
}
@@ -354,57 +313,33 @@ public final class XmlRpcStructFactory {
return productHash;
}
- public static Product getProductFromXmlRpc(Map<?, ?> productHash) {
- /*Hashtable ht = new Hashtable();
- ht.putAll(productHash);*/
- Product product = new Product();
- product.setProductId((String) productHash.get("id"));
- product.setProductName((String) productHash.get("name"));
- if (productHash.get("type") != null) {
- product.setProductType(getProductTypeFromXmlRpc(
- (Hashtable<String, Object>) productHash.get("type")));
- }
- product.setProductStructure((String) productHash.get("structure"));
- product.setTransferStatus((String) productHash.get("transferStatus"));
- if (productHash.get("references") != null) {
- product.setProductReferences(getReferencesFromXmlRpc(
- (Vector<Hashtable<String, Object>>) productHash
- .get("references")));
- }
- if (productHash.get("rootReference") != null) {
- product.setRootRef(getReferenceFromXmlRpc(
- (Hashtable<String, Object>) productHash.get("rootReference")));
- }
- return product;
- }
-
@SuppressWarnings("unchecked")
- public static Product getProductFromXmlRpc(Hashtable<?, ?> productHash) {
+ public static Product getProductFromXmlRpc(Map<?, ?> productHash) {
Product product = new Product();
product.setProductId((String) productHash.get("id"));
product.setProductName((String) productHash.get("name"));
if (productHash.get("type") != null) {
product.setProductType(getProductTypeFromXmlRpc(
- (Hashtable<String, Object>) productHash.get("type")));
+ (Map<String, Object>) productHash.get("type")));
}
product.setProductStructure((String) productHash.get("structure"));
product.setTransferStatus((String) productHash.get("transferStatus"));
if (productHash.get("references") != null) {
product.setProductReferences(getReferencesFromXmlRpc(
- (Vector<Hashtable<String, Object>>) productHash
+ (Vector<Map<String, Object>>) productHash
.get("references")));
}
if (productHash.get("rootReference") != null) {
product.setRootRef(getReferenceFromXmlRpc(
- (Hashtable<String, Object>) productHash.get("rootReference")));
+ (Map<String, Object>) productHash.get("rootReference")));
}
return product;
}
- public static List<Product> getProductListFromXmlRpc(Vector<Hashtable<String, Object>> productVector) {
+ public static List<Product> getProductListFromXmlRpc(Vector<Map<String, Object>> productVector) {
List<Product> productList = new Vector<Product>();
- for (Hashtable<String, Object> productHash : productVector) {
+ for (Map<String, Object> productHash : productVector) {
Product product = getProductFromXmlRpc(productHash);
productList.add(product);
}
@@ -427,15 +362,15 @@ public final class XmlRpcStructFactory {
return productVector;
}
- public static Vector<Hashtable<String, Object>> getXmlRpcProductList(List<Product> products) {
- Vector<Hashtable<String, Object>> productVector = new Vector<Hashtable<String, Object>>();
+ public static Vector<Map<String, Object>> getXmlRpcProductList(List<Product> products) {
+ Vector<Map<String, Object>> productVector = new Vector<Map<String, Object>>();
if (products == null) {
return productVector;
}
for (Product product : products) {
- Hashtable<String, Object> productHash = getXmlRpcProduct(product);
+ Map<String, Object> productHash = getXmlRpcProduct(product);
productVector.add(productHash);
}
@@ -466,36 +401,8 @@ public final class XmlRpcStructFactory {
return productTypeList;
}
- public static Map<String, Object> getXmlRpcProductTypeMap(ProductType type) {
- Map<String, Object> productTypeHash = new ConcurrentHashMap<String, Object>();
- // TODO(bfoster): ProductType ID is currently required by XmlRpcFileManager.
- productTypeHash.put("id", type.getProductTypeId());
- if (type.getName() != null) {
- productTypeHash.put("name", type.getName());
- }
- if (type.getDescription() != null) {
- productTypeHash.put("description", type.getDescription());
- }
- if (type.getProductRepositoryPath() != null) {
- productTypeHash.put("repositoryPath",type.getProductRepositoryPath());
- }
- if (type.getVersioner() != null) {
- productTypeHash.put("versionerClass", type.getVersioner());
- }
- if (type.getTypeMetadata() != null) {
- productTypeHash.put("typeMetadata", type.getTypeMetadata().getMap());
- }
- if (type.getExtractors() != null) {
- productTypeHash.put("typeExtractors", getXmlRpcTypeExtractors(type.getExtractors()));
- }
- if (type.getHandlers() != null) {
- productTypeHash.put("typeHandlers", getXmlRpcTypeHandlers(type.getHandlers()));
- }
- return productTypeHash;
- }
-
- public static Hashtable<String, Object> getXmlRpcProductType(ProductType type) {
- Hashtable<String, Object> productTypeHash = new Hashtable<String, Object>();
+ public static Map<String, Object> getXmlRpcProductType(ProductType type) {
+ Map<String, Object> productTypeHash = new Hashtable<String, Object>();
// TODO(bfoster): ProductType ID is currently required by XmlRpcFileManager.
productTypeHash.put("id", type.getProductTypeId());
if (type.getName() != null) {
@@ -537,19 +444,19 @@ public final class XmlRpcStructFactory {
}
if (productTypeHash.get("typeExtractors") != null) {
type.setExtractors(getTypeExtractorsFromXmlRpc(
- (Vector<Hashtable<String, Object>>) productTypeHash
+ (Vector<Map<String, Object>>) productTypeHash
.get("typeExtractors")));
}
if (productTypeHash.get("typeHandlers") != null) {
type.setHandlers(getTypeHandlersFromXmlRpc(
- (Vector<Hashtable<String, Object>>) productTypeHash
+ (Vector<Map<String, Object>>) productTypeHash
.get("typeHandlers")));
}
return type;
}
- public static Vector<Hashtable<String, Object>> getXmlRpcTypeExtractors(List<ExtractorSpec> extractors) {
- Vector<Hashtable<String, Object>> extractorsVector = new Vector<Hashtable<String, Object>>();
+ public static Vector<Map<String, Object>> getXmlRpcTypeExtractors(List<ExtractorSpec> extractors) {
+ Vector<Map<String, Object>> extractorsVector = new Vector<Map<String, Object>>();
if (extractors != null && extractors.size() > 0) {
for (ExtractorSpec spec : extractors) {
@@ -571,26 +478,15 @@ public final class XmlRpcStructFactory {
return extractorsVector;
}
- public static Hashtable<String, Object> getXmlRpcExtractorSpec(ExtractorSpec spec) {
- Hashtable<String, Object> extractorHash = new Hashtable<String, Object>();
+ public static Map<String, Object> getXmlRpcExtractorSpec(ExtractorSpec spec) {
+ Map<String, Object> extractorHash = new Hashtable<String, Object>();
extractorHash.put("className", spec.getClassName());
extractorHash.put("config",
getXmlRpcProperties(spec.getConfiguration()));
return extractorHash;
}
- public static Vector<Hashtable<String, Object>> getXmlRpcTypeHandlers(List<TypeHandler> typeHandlers) {
- Vector<Hashtable<String, Object>> handlersVector = new Vector<Hashtable<String, Object>>();
-
- if (typeHandlers != null && typeHandlers.size() > 0) {
- for (TypeHandler typeHandler : typeHandlers) {
- handlersVector.add(getXmlRpcTypeHandler(typeHandler));
- }
- }
-
- return handlersVector;
- }
- public static Vector<Map<String, Object>> getXmlRpcTypeHandlersMap(List<TypeHandler> typeHandlers) {
+ public static Vector<Map<String, Object>> getXmlRpcTypeHandlers(List<TypeHandler> typeHandlers) {
Vector<Map<String, Object>> handlersVector = new Vector<Map<String, Object>>();
if (typeHandlers != null && typeHandlers.size() > 0) {
@@ -602,8 +498,8 @@ public final class XmlRpcStructFactory {
return handlersVector;
}
- public static Hashtable<String, Object> getXmlRpcTypeHandler(TypeHandler typeHandler) {
- Hashtable<String, Object> handlerHash = new Hashtable<String, Object>();
+ public static Map<String, Object> getXmlRpcTypeHandler(TypeHandler typeHandler) {
+ Map<String, Object> handlerHash = new Hashtable<String, Object>();
handlerHash.put("className", typeHandler != null ?
typeHandler.getClass().getCanonicalName():"");
handlerHash.put("elementName", typeHandler != null ?
@@ -611,20 +507,11 @@ public final class XmlRpcStructFactory {
return handlerHash;
}
- public static Map<String, Object> getXmlRpcTypeHandlerMap(TypeHandler typeHandler) {
- Map<String, Object> handlerHash = new ConcurrentHashMap<String, Object>();
- handlerHash.put("className", typeHandler != null ?
- typeHandler.getClass().getCanonicalName():"");
- handlerHash.put("elementName", typeHandler != null ?
- typeHandler.getElementName():"");
- return handlerHash;
- }
-
- public static List<ExtractorSpec> getTypeExtractorsFromXmlRpc(Vector<Hashtable<String, Object>> extractorsVector) {
+ public static List<ExtractorSpec> getTypeExtractorsFromXmlRpc(Vector<Map<String, Object>> extractorsVector) {
List<ExtractorSpec> extractors = new Vector<ExtractorSpec>();
if (extractorsVector != null && extractorsVector.size() > 0) {
- for (Hashtable<String, Object> extractorSpecHash : extractorsVector) {
+ for (Map<String, Object> extractorSpecHash : extractorsVector) {
extractors.add(getExtractorSpecFromXmlRpc(extractorSpecHash));
}
}
@@ -638,16 +525,16 @@ public final class XmlRpcStructFactory {
ExtractorSpec spec = new ExtractorSpec();
spec.setClassName((String) extractorSpecHash.get("className"));
spec
- .setConfiguration(getPropertiesFromXmlRpc((Hashtable<String, String>) extractorSpecHash
+ .setConfiguration(getPropertiesFromXmlRpc((Map<String, String>) extractorSpecHash
.get("config")));
return spec;
}
- public static List<TypeHandler> getTypeHandlersFromXmlRpc(Vector<Hashtable<String, Object>> handlersVector) {
+ public static List<TypeHandler> getTypeHandlersFromXmlRpc(Vector<Map<String, Object>> handlersVector) {
List<TypeHandler> handlers = new Vector<TypeHandler>();
if (handlersVector != null && handlersVector.size() > 0) {
- for (Hashtable<String, Object> typeHandlerHash : handlersVector) {
+ for (Map<String, Object> typeHandlerHash : handlersVector) {
handlers.add(getTypeHandlerFromXmlRpc(typeHandlerHash));
}
}
@@ -656,7 +543,7 @@ public final class XmlRpcStructFactory {
}
public static TypeHandler getTypeHandlerFromXmlRpc(
- Hashtable<String, Object> typeHandlerHash) {
+ Map<String, Object> typeHandlerHash) {
TypeHandler typeHandler = GenericFileManagerObjectFactory
.getTypeHandlerFromClassName((String) typeHandlerHash.get("className"));
if(typeHandler != null) {
@@ -678,8 +565,8 @@ public final class XmlRpcStructFactory {
return props;
}
- public static Hashtable<String, String> getXmlRpcProperties(Properties props) {
- Hashtable<String, String> propHash = new Hashtable<String, String>();
+ public static Map<String, String> getXmlRpcProperties(Properties props) {
+ Map<String, String> propHash = new Hashtable<String, String>();
if (props != null && props.keySet().size() > 0) {
for (Object o : props.keySet()) {
@@ -707,31 +594,31 @@ public final class XmlRpcStructFactory {
return refVector;
}
- public static Vector<Hashtable<String, Object>> getXmlRpcReferences(List<Reference> references) {
- Vector<Hashtable<String, Object>> refVector = new Vector<Hashtable<String, Object>>();
+ public static Vector<Map<String, Object>> getXmlRpcReferences(List<Reference> references) {
+ Vector<Map<String, Object>> refVector = new Vector<Map<String, Object>>();
if (references == null) {
return refVector;
}
for (Reference reference : references) {
- Hashtable<String, Object> refHash = getXmlRpcReference(reference);
+ Map<String, Object> refHash = getXmlRpcReference(reference);
refVector.add(refHash);
}
return refVector;
}
- public static List<Reference> getReferencesFromXmlRpc(Vector<Hashtable<String, Object>> referenceVector) {
+ public static List<Reference> getReferencesFromXmlRpc(Vector<Map<String, Object>> referenceVector) {
List<Reference> references = new Vector<Reference>();
- for (Hashtable<String, Object> aReferenceVector : referenceVector) {
+ for (Map<String, Object> aReferenceVector : referenceVector) {
Reference r = getReferenceFromXmlRpc(aReferenceVector);
references.add(r);
}
return references;
}
- public static Hashtable<String, Object> getXmlRpcReference(Reference reference) {
- Hashtable<String, Object> referenceHash = new Hashtable<String, Object>();
+ public static Map<String, Object> getXmlRpcReference(Reference reference) {
+ Map<String, Object> referenceHash = new Hashtable<String, Object>();
referenceHash.put("origReference", reference.getOrigReference());
referenceHash.put("dataStoreReference", reference
.getDataStoreReference() != null ? reference
@@ -753,7 +640,7 @@ public final class XmlRpcStructFactory {
return reference;
}
- public static Reference getReferenceFromXmlRpcHashtable(Hashtable<String, Object> referenceHash) {
+ public static Reference getReferenceFromXmlRpcHashtable(Map<String, Object> referenceHash) {
Reference reference = new Reference();
reference.setDataStoreReference((String) referenceHash
.get("dataStoreReference"));
@@ -763,10 +650,10 @@ public final class XmlRpcStructFactory {
return reference;
}
- public static Vector<Hashtable<String, Object>> getXmlRpcElementListHashtable(List<Element> elementList) {
- Vector<Hashtable<String, Object>> elementVector = new Vector<Hashtable<String, Object>>(elementList.size());
+ public static Vector<Map<String, Object>> getXmlRpcElementListHashtable(List<Element> elementList) {
+ Vector<Map<String, Object>> elementVector = new Vector<Map<String, Object>>(elementList.size());
for (Element element : elementList) {
- Hashtable<String, Object> elementHash = getXmlRpcElementHashTable(element);
+ Map<String, Object> elementHash = getXmlRpcElementHashTable(element);
elementVector.add(elementHash);
}
return elementVector;
@@ -775,23 +662,23 @@ public final class XmlRpcStructFactory {
public static Vector<Map<String, Object>> getXmlRpcElementList(List<Element> elementList) {
Vector<Map<String, Object>> elementVector = new Vector<Map<String, Object>>(elementList.size());
for (Element element : elementList) {
- HashMap<String, Object> elementHash = getXmlRpcElement(element);
+ Map<String, Object> elementHash = getXmlRpcElement(element);
elementVector.add(elementHash);
}
return elementVector;
}
- public static List<Element> getElementListFromXmlRpc(Vector<Hashtable<String, Object>> elementVector) {
+ public static List<Element> getElementListFromXmlRpc(Vector<Map<String, Object>> elementVector) {
List<Element> elementList = new Vector<Element>(elementVector.size());
- for (Hashtable<String, Object> elementHash : elementVector) {
+ for (Map<String, Object> elementHash : elementVector) {
Element element = getElementFromXmlRpc(elementHash);
elementList.add(element);
}
return elementList;
}
- public static HashMap<String, Object> getXmlRpcElement(Element element) {
- HashMap<String, Object> elementHash = new HashMap<String, Object>();
+ public static Map<String, Object> getXmlRpcElement(Element element) {
+ Map<String, Object> elementHash = new HashMap<String, Object>();
elementHash.put("id", element.getElementId());
elementHash.put("name", element.getElementName());
@@ -803,8 +690,8 @@ public final class XmlRpcStructFactory {
return elementHash;
}
- public static Hashtable<String, Object> getXmlRpcElementHashTable(Element element) {
- Hashtable<String, Object> elementHash = new Hashtable<String, Object>();
+ public static Map<String, Object> getXmlRpcElementHashTable(Element element) {
+ Map<String, Object> elementHash = new Hashtable<String, Object>();
elementHash.put("id", element.getElementId());
elementHash.put("name", element.getElementName());
@@ -816,7 +703,7 @@ public final class XmlRpcStructFactory {
return elementHash;
}
- public static Element getElementFromXmlRpc(Hashtable<String, Object> elementHash) {
+ public static Element getElementFromXmlRpc(Map<String, Object> elementHash) {
Element element = new Element();
element.setElementId((String) elementHash.get("id"));
element.setElementName((String) elementHash.get("name"));
@@ -826,14 +713,14 @@ public final class XmlRpcStructFactory {
return element;
}
- public static Hashtable<String, Object> getXmlRpcQuery(Query query) {
- Hashtable<String, Object> queryHash = new Hashtable<String, Object>();
- Vector<Hashtable<String, Object>> criteriaVector = getXmlRpcQueryCriteriaList(query.getCriteria());
+ public static Map<String, Object> getXmlRpcQuery(Query query) {
+ Map<String, Object> queryHash = new Hashtable<String, Object>();
+ Vector<Map<String, Object>> criteriaVector = getXmlRpcQueryCriteriaList(query.getCriteria());
queryHash.put("criteria", criteriaVector);
return queryHash;
}
- public static Query getQueryFromXmlRpc(Hashtable<String, Object> queryHash) {
+ public static Query getQueryFromXmlRpc(Map<String, Object> queryHash) {
Query query = new Query();
@SuppressWarnings("unchecked")
List<QueryCriteria> criteria = getQueryCriteriaListFromXmlRpc((Vector<Map<String, Object>>) queryHash
@@ -851,10 +738,10 @@ public final class XmlRpcStructFactory {
return query;
}
- public static Vector<Hashtable<String, Object>> getXmlRpcQueryCriteriaList(List<QueryCriteria> criteriaList) {
- Vector<Hashtable<String, Object>> criteriaVector = new Vector<Hashtable<String, Object>>(criteriaList.size());
+ public static Vector<Map<String, Object>> getXmlRpcQueryCriteriaList(List<QueryCriteria> criteriaList) {
+ Vector<Map<String, Object>> criteriaVector = new Vector<Map<String, Object>>(criteriaList.size());
for (QueryCriteria criteria : criteriaList) {
- Hashtable<String, Object> criteriaHash = getXmlRpcQueryCriteria(criteria);
+ Map<String, Object> criteriaHash = getXmlRpcQueryCriteria(criteria);
criteriaVector.add(criteriaHash);
}
@@ -871,8 +758,8 @@ public final class XmlRpcStructFactory {
return criteriaList;
}
- public static Hashtable<String, Object> getXmlRpcQueryCriteria(QueryCriteria criteria) {
- Hashtable<String, Object> criteriaHash = new Hashtable<String, Object>();
+ public static Map<String, Object> getXmlRpcQueryCriteria(QueryCriteria criteria) {
+ Map<String, Object> criteriaHash = new Hashtable<String, Object>();
criteriaHash.put("class",criteria.getClass().getCanonicalName());
if(criteria instanceof TermQueryCriteria){
@@ -888,11 +775,11 @@ public final class XmlRpcStructFactory {
} else if(criteria instanceof BooleanQueryCriteria){
BooleanQueryCriteria boolQuery = (BooleanQueryCriteria) criteria;
criteriaHash.put("operator", boolQuery.getOperator());
- Vector<Hashtable<String, Object>> termsHash = new Vector<Hashtable<String, Object>>();
+ Vector<Map<String, Object>> termsHash = new Vector<Map<String, Object>>();
List<QueryCriteria> terms = boolQuery.getTerms();
for (QueryCriteria term : terms) {
- Hashtable<String, Object> termHash = getXmlRpcQueryCriteria(term);
+ Map<String, Object> termHash = getXmlRpcQueryCriteria(term);
termsHash.add(termHash);
}
criteriaHash.put("terms", termsHash);
http://git-wip-us.apache.org/repos/asf/oodt/blob/3e0e5972/metadata/src/main/java/org/apache/oodt/cas/metadata/Metadata.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/oodt/cas/metadata/Metadata.java b/metadata/src/main/java/org/apache/oodt/cas/metadata/Metadata.java
index 73a21dc..0f10a81 100644
--- a/metadata/src/main/java/org/apache/oodt/cas/metadata/Metadata.java
+++ b/metadata/src/main/java/org/apache/oodt/cas/metadata/Metadata.java
@@ -15,8 +15,6 @@
package org.apache.oodt.cas.metadata;
-//JDK imports
-
import java.util.Collections;
import java.util.concurrent.ConcurrentHashMap;
import java.util.Hashtable;
@@ -486,7 +484,19 @@ public class Metadata {
public Group(String name) {
this.name = name;
this.values = new Vector<String>();
- this.children = new ConcurrentHashMap<String, Group>();
+ this.children = new Hashtable<String, Group>();
+ }
+
+ public Group(String name, boolean legacy) {
+ this.name = name;
+ this.values = new Vector<String>();
+ if(legacy){
+ this.children = new Hashtable<String, Group>();
+ }
+ else{
+ this.children = new ConcurrentHashMap<String, Group>();
+ }
+
}
public String getName() {