本文整理汇总了Java中org.apache.oodt.cas.filemgr.structs.Product.getProductId方法的典型用法代码示例。如果您正苦于以下问题:Java Product.getProductId方法的具体用法?Java Product.getProductId怎么用?Java Product.getProductId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.oodt.cas.filemgr.structs.Product
的用法示例。
在下文中一共展示了Product.getProductId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getXmlRpcProduct
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
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());
}
if (product.getProductName() != null) {
productHash.put("name", product.getProductName());
}
if (product.getProductType() != null) {
productHash.put("type", getXmlRpcProductType(product.getProductType()));
}
if (product.getProductStructure() != null) {
productHash.put("structure", product.getProductStructure());
}
if (product.getTransferStatus() != null) {
productHash.put("transferStatus", product.getTransferStatus());
}
if (product.getProductReferences() != null) {
productHash.put("references", getXmlRpcReferences(product
.getProductReferences()));
}
if (product.getRootRef() != null) {
productHash.put("rootReference", getXmlRpcReference(product
.getRootRef()));
}
return productHash;
}
示例2: catalogProduct
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
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;
}
return p.getProductId();
}
示例3: deleteCatalogMetadata
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
/**
* Method to delete a specific product from the catalog
*
* @param id
* identifier of CAS product - either 'id' or 'name' must be specified
* @param name
* name of CAS product - either 'id' or 'name' must be specified
* @return the product ID of the deleted product if deletion successful
*/
@POST
@Path(DELETE)
@Consumes("application/x-www-form-urlencoded")
@Produces("text/plain")
public String deleteCatalogMetadata(
@FormParam("id") String id,
@FormParam("name") String name) {
try {
// retrieve product from catalog
Product product;
if (StringUtils.hasText(id)) {
id = id.substring(id.lastIndexOf("/") + 1);
product = CurationService.config.getFileManagerClient().getProductById(id);
} else if (StringUtils.hasText(name)) {
product = CurationService.config.getFileManagerClient().getProductByName(name);
} else {
throw new Exception("Either the HTTP parameter 'id' or the HTTP parameter 'name' must be specified");
}
// remove product from catalog
this.deleteCatalogProduct(product);
// return product id to downstream processors
return "id="+product.getProductId();
} catch (Exception e) {
LOG.log(Level.SEVERE, e.getMessage());
// return error message
throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR);
}
}
示例4: testXmlMarshalling
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
/**
* Tests that {@link TransferResource transfer resources} are marshalled to
* the expected XML format.
* @throws IOException if the {@link Diff} constructor fails
* @throws JAXBException if the {@link JAXBContext} or {@link Marshaller} fail
* @throws MimeTypeException if {@link MimeTypes#forName(String)} fails
* @throws SAXException if the {@link Diff} constructor fails
*/
@Test
public void testXmlMarshalling() throws IOException, JAXBException,
MimeTypeException, SAXException
{
// Create a TransferResource using ProductType, Product, Metadata, Reference
// and FileTransferStatus instances.
Hashtable metadataEntries = new Hashtable<String, Object>();
metadataEntries.put("CAS.ProductReceivedTime", "2013-09-12T16:25:50.662Z");
Metadata metadata = new Metadata();
metadata.addMetadata(metadataEntries);
Reference reference = new Reference("original", "dataStore", 1000,
new MimeTypes().forName("text/plain"));
ProductType productType = new ProductType("1", "GenericFile", "test type",
"repository", "versioner");
Product product = new Product();
product.setProductId("123");
product.setProductName("test product");
product.setProductStructure(Product.STRUCTURE_FLAT);
product.setProductType(productType);
FileTransferStatus status = new FileTransferStatus(reference, 1000, 100,
product);
TransferResource resource = new TransferResource(product, metadata, status);
// Generate the expected output.
String expectedXml =
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"
+ "<transfer>"
+ "<productName>" + product.getProductName() + "</productName>"
+ "<productId>" + product.getProductId() + "</productId>"
+ "<productTypeName>" + productType.getName() + "</productTypeName>"
+ "<dataStoreReference>"
+ reference.getDataStoreReference()
+ "</dataStoreReference>"
+ "<origReference>"
+ reference.getOrigReference()
+ "</origReference>"
+ "<mimeType>" + reference.getMimeType().getName() + "</mimeType>"
+ "<fileSize>" + reference.getFileSize() + "</fileSize>"
+ "<totalBytes>" + reference.getFileSize() + "</totalBytes>"
+ "<bytesTransferred>"
+ status.getBytesTransferred()
+ "</bytesTransferred>"
+ "<percentComplete>"
+ status.computePctTransferred() * 100
+ "</percentComplete>"
+ "<productReceivedTime>"
+ metadata.getAllValues().get(0)
+ "</productReceivedTime>"
+ "</transfer>";
// Set up a JAXB context and marshall the DatasetResource to XML.
JAXBContext context = JAXBContext.newInstance(resource.getClass());
Marshaller marshaller = context.createMarshaller();
StringWriter writer = new StringWriter();
marshaller.marshal(resource, writer);
// Compare the expected and actual outputs.
XMLUnit.setIgnoreWhitespace(true);
XMLUnit.setIgnoreComments(true);
XMLUnit.setIgnoreAttributeOrder(true);
Diff diff = new Diff(expectedXml, writer.toString());
assertTrue("The output XML was different to the expected XML: "
+ diff.toString(), diff.identical());
}
示例5: addProduct
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
/**
* Method that adds a Product to the Catalog,
* persisting its fundamental CAS attributes (id, name, type, ingestion time, etc.).
* This method assigns the product a unique identifier, if not existing already.
*/
@Override
public void addProduct(Product product) throws CatalogException {
if(product.getProductId()!=null && this.getCompleteProductById(product.getProductId()) !=null) {
throw new CatalogException(
"Attempt to add a product that already existed: product: ["
+ product.getProductName() + "]");
} else {
LOG.info("Adding product:" + product.getProductName());
// generate product identifier if not existing already
if (!StringUtils.hasText(product.getProductId())) {
String productId = this.productIdGenerator.generateId(product);
product.setProductId(productId);
}
// serialize product for ingestion into Solr
List<String> docs = productSerializer.serialize(product, true); // create=true
// send records to Solr
solrClient.index(docs, true, productSerializer.getMimeType());
}
}