当前位置: 首页>>代码示例>>Java>>正文


Java Product.getProductName方法代码示例

本文整理汇总了Java中org.apache.oodt.cas.filemgr.structs.Product.getProductName方法的典型用法代码示例。如果您正苦于以下问题:Java Product.getProductName方法的具体用法?Java Product.getProductName怎么用?Java Product.getProductName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.oodt.cas.filemgr.structs.Product的用法示例。


在下文中一共展示了Product.getProductName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCreateProductZipFileFromHierarchicalProduct

import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
public void testCreateProductZipFileFromHierarchicalProduct(){
	//Data store reference needs absolute path to test data
	String cwd=System.getProperty("user.dir");

	Product product = new Product();
	product.setProductId("TestProductId");
	product.setProductName("TestProductName");
	product.setProductReferences(Lists.newArrayList(
		new Reference("file:///orig/data/", "file://" + cwd + "/src/test/resources/", 4096),
		new Reference("file:///orig/data/test-file-1.txt", "file://" + cwd + "/src/test/resources/test-file-1.txt", 20),
		new Reference("file:///orig/data/test-file-2.txt", "file://" + cwd + "/src/test/resources/test-file-2.txt", 20),
		new Reference("file:///orig/data/test-file-3.txt", "file://" + cwd + "/src/test/resources/test-file-3.txt", 20)));
	product.setProductStructure(Product.STRUCTURE_HIERARCHICAL);
	product.setTransferStatus(Product.STATUS_RECEIVED);
	ProductType pt = new ProductType();
	pt.setName("TestProductType");

	Metadata metadata = new Metadata();

	String workingDirPath;
	workingDir = Files.createTempDir();
	workingDirPath = workingDir.getAbsolutePath();
	workingDir.deleteOnExit();

	String productZipFilePath = null;
	try {
		productZipFilePath = DataUtils.createProductZipFile(product, metadata, workingDirPath);
	} catch (Exception e) {
		fail(e.getMessage());
	}
	String zipFileName = product.getProductName() + ".zip";
	assertEquals(productZipFilePath, workingDirPath + "/" + zipFileName);
}
 
开发者ID:apache,项目名称:oodt,代码行数:34,代码来源:TestDataUtils.java

示例2: getMetadata

import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
private Metadata getMetadata(Product product) {
    Metadata met;

    try {
        met = this.fmClient.getMetadata(product);
    } catch (Exception e) {
        throw new RuntimeException("Unable to get metadata for product: ["
                + product.getProductName() + "]");
    }

    return met;
}
 
开发者ID:apache,项目名称:oodt,代码行数:13,代码来源:ProductDumper.java

示例3: 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;
}
 
开发者ID:apache,项目名称:oodt,代码行数:28,代码来源:XmlRpcStructFactory.java

示例4: updateCatalogMetadata

import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
/**
 * Updates the cataloged {@link Metadata} for a {@link Product} in the CAS
 * File Manager.
 * 
 * @param product
 *          The {@link Product} to update {@link Metadata} for.
 * @throws CatalogException
 *           If any error occurs during the update.
 * @throws IOException
 * @throws FileNotFoundException
 */
public void updateCatalogMetadata(Product product, Metadata newMetadata)
    throws CatalogException, IOException {
  InputStream is = new FileInputStream(CurationService.config.getFileMgrProps());
  try {
    System.getProperties().load(is);
  }
  finally{
    is.close();
  }
  Catalog catalog = this.getCatalog();
  
  Metadata oldMetadata = catalog.getMetadata(product);
  List<Reference> references = catalog.getProductReferences(product);
  Product newProduct = new Product(product.getProductName(), product
      .getProductType(), product.getProductStructure(), product
      .getTransferStatus(), product.getProductReferences());
  // Constructor is bugged and doesn't set transfer status
  newProduct.setTransferStatus(product.getTransferStatus());
  catalog.removeMetadata(oldMetadata, product);
  catalog.removeProduct(product);
  newProduct.setProductId(product.getProductId());
  catalog.addProduct(newProduct);
  newProduct.setProductReferences(references);
  catalog.addProductReferences(newProduct);
  catalog.addMetadata(newMetadata, newProduct);
}
 
开发者ID:apache,项目名称:oodt,代码行数:38,代码来源:MetadataResource.java

示例5: createProductZipFile

import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
public static String createProductZipFile(Product product, Metadata metadata,
    String workingDirPath) throws IOException {
  String productZipFileName = product.getProductName() + ".zip";
  workingDirPath += workingDirPath.endsWith("/") ? "" : "/";
  String productZipFilePath = workingDirPath + productZipFileName;

  // try and remove it first
  if (!new File(productZipFilePath).delete()) {
    LOG.log(Level.WARNING, "Attempt to remove temp zip file: ["
        + productZipFilePath + "] failed.");
  }

  // now get a reference to the zip file that we want to write
  ZipOutputStream out = new ZipOutputStream(new FileOutputStream(
      productZipFilePath));

  for (Reference r : product.getProductReferences()) {
    try {
      File prodFile = new File(new URI(r.getDataStoreReference()));
      if (prodFile.isDirectory()) {
        LOG.log(Level.WARNING, "Data store reference is a directory. Not adding directory to the zip file: ["
                               + r.getDataStoreReference() + "]");
        continue;
      }
      String filename = prodFile.getName();
      FileInputStream in = new FileInputStream(prodFile.getAbsoluteFile());
      addZipEntryFromStream(in, out, filename);
      in.close();
    } catch (URISyntaxException e) {
      LOG.log(Level.WARNING, "Unable to get filename from uri: ["
                             + r.getDataStoreReference() + "]");
    }

  }

  // add met file
  addMetFileToProductZip(metadata, product.getProductName(), out);

  // Complete the ZIP file
  out.close();

  // return the zip file path
  return productZipFilePath;

}
 
开发者ID:apache,项目名称:oodt,代码行数:46,代码来源:DataUtils.java

示例6: 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());
}
 
开发者ID:apache,项目名称:oodt,代码行数:79,代码来源:TransferResourceTest.java

示例7: generateId

import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
@Override
public String generateId(Product product) {
	return product.getProductName();
}
 
开发者ID:apache,项目名称:oodt,代码行数:5,代码来源:NameProductIdGenerator.java

示例8: createDataStoreReferences

import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
public void createDataStoreReferences(Product product, Metadata metadata)
        throws VersioningException {
    // we only handle single files, so throw exception if product is
    // heirarhical

    if (!product.getProductStructure().equals(Product.STRUCTURE_FLAT)) {
        throw new VersioningException(
                "SingleFileVersioner: unable to version" + " Product: ["
                        + product.getProductName()
                        + "] with heirarchical/stream structure");
    }

    // we need the Filename Metadata parameter for this to work
    String filename = metadata.getMetadata(FILENAME_FIELD);

    if (filename == null || (filename.equals(""))) {
        throw new VersioningException(
                "SingleFileVersioner: unable to version without "
                        + "Filename metadata field specified!");
    }

    // now we need the product type repo path
    String productTypeRepoPathUri = product.getProductType()
            .getProductRepositoryPath();
    String productTypeRepoPath = VersioningUtils
            .getAbsolutePathFromUri(productTypeRepoPathUri);

    if (!productTypeRepoPath.endsWith("/")) {
        productTypeRepoPath += "/";
    }

    // final file location is:
    // /productTypeRepoPath/Filename

    String dataStorePath = productTypeRepoPath + filename;
    String dataStoreRef = new File(dataStorePath).toURI().toString();

    // get the first reference back
    // set its data store ref
    Reference ref = product.getProductReferences().get(0);
    LOG.log(Level.INFO, "Generated data store ref: [" + dataStoreRef
            + "] from origRef: [" + ref.getOrigReference() + "]");
    ref.setDataStoreReference(dataStoreRef);

}
 
开发者ID:apache,项目名称:oodt,代码行数:46,代码来源:SingleFileBasicVersioner.java

示例9: 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());
	}

}
 
开发者ID:apache,项目名称:oodt,代码行数:35,代码来源:SolrCatalog.java


注:本文中的org.apache.oodt.cas.filemgr.structs.Product.getProductName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。