public String ingestProduct(Hashtable<String, Object> productHash,
Hashtable<String, String> metadata, boolean clientTransfer)
throws VersioningException, RepositoryManagerException,
DataTransferException, 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((Hashtable)metadata);
addMetadata(p, m);
if (!clientTransfer) {
LOG.log(Level.FINEST,
"File Manager: ingest: no client transfer enabled, "
+ "server transfering product: [" + p.getProductName() + "]");
// version the product
Versioner versioner = null;
try {
versioner = GenericFileManagerObjectFactory
.getVersionerFromClassName(p.getProductType().getVersioner());
versioner.createDataStoreReferences(p, m);
} 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);
// 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) {
e.printStackTrace();
throw new CatalogException("Error ingesting product [" + p + "] : "
+ e.getMessage());
}