本文整理汇总了Java中org.apache.oodt.cas.filemgr.structs.Product.STRUCTURE_FLAT属性的典型用法代码示例。如果您正苦于以下问题:Java Product.STRUCTURE_FLAT属性的具体用法?Java Product.STRUCTURE_FLAT怎么用?Java Product.STRUCTURE_FLAT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.oodt.cas.filemgr.structs.Product
的用法示例。
在下文中一共展示了Product.STRUCTURE_FLAT属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testIngestProduct
public void testIngestProduct() {
URL refUrl = this.getClass().getResource("/ingest/test.txt");
URL metUrl = this.getClass().getResource("/ingest/test.txt.met");
String productName = "TestProductName";
String structure = Product.STRUCTURE_FLAT;
String productTypeName = "TestProductType";
String metadataFile = new File(metUrl.getFile()).getAbsolutePath();
String dataTransferer = InPlaceDataTransferFactory.class
.getCanonicalName();
String ref = new File(refUrl.getFile()).getAbsolutePath();
cmdLineUtility
.run(("--url http://localhost:9000 --operation --ingestProduct"
+ " --productName " + productName + " --productStructure "
+ structure + " --productTypeName " + productTypeName
+ " --metadataFile " + metadataFile + " --refs " + ref
+ " --clientTransfer --dataTransfer " + dataTransferer)
.split(" "));
MethodCallDetails methodCallDetails = client.getLastMethodCallDetails();
assertEquals("ingestProduct", methodCallDetails.getMethodName());
assertEquals(productName,
((Product) methodCallDetails.getArgs().get(0)).getProductName());
assertEquals(structure,
((Product) methodCallDetails.getArgs().get(0))
.getProductStructure());
assertEquals(productTypeName,
((Product) methodCallDetails.getArgs().get(0)).getProductType()
.getName());
assertTrue(((Product) methodCallDetails.getArgs().get(0))
.getProductReferences().get(0).getOrigReference().endsWith(ref));
assertEquals("test.txt",
((Metadata) methodCallDetails.getArgs().get(1))
.getMetadata("Filename"));
assertEquals("GenericFile", ((Metadata) methodCallDetails.getArgs()
.get(1)).getMetadata("ProductType"));
assertEquals(true, methodCallDetails.getArgs().get(2));
}
示例2: ingest
public String ingest(URL fmUrl, File prodFile, Metadata met)
throws IngestException {
checkOrSetFileManager(fmUrl);
String productType = met.getMetadata(PRODUCT_TYPE);
String fileLocation = met.getMetadata(FILE_LOCATION);
String fileName = met.getMetadata(FILENAME);
if (!check(productType, PRODUCT_TYPE)
|| !check(fileLocation, FILE_LOCATION)
|| !check(fileName, FILENAME)) {
throw new IngestException("Must specify: " + PRODUCT_TYPE + " and "
+ FILENAME + " and " + FILE_LOCATION
+ " within metadata file. Cannot ingest product: ["
+ prodFile.getAbsolutePath() + "]");
}
// allow user to override default product name (Filename)
String productName = met.getMetadata(PRODUCT_NAME) != null ? met
.getMetadata(PRODUCT_NAME) : fileName;
// check to see if product structure was specified
String productStructure = met.getMetadata(PRODUCT_STRUCTURE);
if (productStructure == null) {
// try and guess the structure
if (prodFile.isDirectory()) {
productStructure = Product.STRUCTURE_HIERARCHICAL;
} else {
productStructure = Product.STRUCTURE_FLAT;
}
}
// create the product
Product product = new Product();
product.setProductName(productName);
product.setProductStructure(productStructure);
product.setProductType(getProductType(productType));
List<String> references = new Vector<String>();
if (!fileLocation.endsWith("/")) {
fileLocation += "/";
}
String fullFilePath = fileLocation + fileName;
references.add(new File(fullFilePath).toURI().toString());
if (productStructure.equals(Product.STRUCTURE_HIERARCHICAL)) {
references.addAll(VersioningUtils.getURIsFromDir(new File(
fullFilePath)));
}
// build refs and attach to product
VersioningUtils.addRefsFromUris(product, references);
LOG.log(Level.INFO, "StdIngester: ingesting product: " + PRODUCT_NAME
+ ": [" + productName + "]: " + PRODUCT_TYPE + ": ["
+ productType + "]: " + FILE_LOCATION + ": [" + fileLocation
+ "]");
String productID;
try {
productID = fmClient.ingestProduct(product, met, true);
} catch (Exception e) {
LOG.log(Level.SEVERE, e.getMessage());
LOG.log(Level.WARNING, "exception ingesting product: ["
+ productName + "]: Message: " + e.getMessage());
throw new IngestException("exception ingesting product: ["
+ productName + "]: Message: " + e.getMessage());
}
return productID;
}