本文整理汇总了Java中org.apache.oodt.cas.filemgr.structs.Product.getProductReferences方法的典型用法代码示例。如果您正苦于以下问题:Java Product.getProductReferences方法的具体用法?Java Product.getProductReferences怎么用?Java Product.getProductReferences使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.oodt.cas.filemgr.structs.Product
的用法示例。
在下文中一共展示了Product.getProductReferences方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testVersionerHierarchical
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
/**
* @since OODT-108
*/
public void testVersionerHierarchical() {
Product p = Product.getDefaultFlatProduct("test", "urn:oodt:GenericFile");
p.setProductStructure(Product.STRUCTURE_HIERARCHICAL);
Reference r = new Reference("file:///tmp", null, 0L);
Reference r2 = new Reference("file:///tmp/file1.txt", null, 4096L);
Reference r3 = new Reference("file:///tmp/file2.txt", null, 4096L);
p.getProductReferences().add(r);
p.getProductReferences().add(r2);
p.getProductReferences().add(r3);
InPlaceVersioner versioner = new InPlaceVersioner();
Metadata met = new Metadata();
try {
versioner.createDataStoreReferences(p, met);
} catch (Exception e) {
fail(e.getMessage());
}
for (Reference ref : p.getProductReferences()) {
assertEquals(ref.getDataStoreReference(), ref.getOrigReference());
}
}
示例2: deleteProduct
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
@Override
public void deleteProduct(Product product) throws DataTransferException, IOException {
for (Reference ref : product.getProductReferences()) {
String u;
try {
u = URI.create(ref.getDataStoreReference()).toURL().getPath();
}
catch (IllegalArgumentException e) {
u = URI.create("file://"+ref.getDataStoreReference()).toURL().getPath();
}
File dataFile = new File(u);
if (!dataFile.delete()) {
throw new IOException(String.format("Failed to delete file %s - delete returned false",
dataFile));
}
}
}
示例3: getFilePath
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
public String getFilePath(Product prod) {
if (!isConnected())
return "N/A";
if (prod.getProductReferences() == null) {
prod.setProductReferences(safeGetProductReferences(prod));
}
if (prod.getProductReferences() == null
|| (prod.getProductReferences() != null
&& prod.getProductReferences().size() == 0)) {
return "N/A";
}
// get the first ref
Reference r = (Reference) prod.getProductReferences().get(0);
return safeGetFileFromUri(r.getDataStoreReference()).getAbsolutePath();
}
示例4: validateProduct
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
protected void validateProduct(Product product, Metadata met)
throws MetExtractionException {
if (product.getProductType() == null || ((product
.getProductType().getName() == null || (product
.getProductType()
.getName()
.equals(""))))) {
throw new MetExtractionException("Product Type undefined");
}
if (product.getProductReferences() == null || (product
.getProductReferences().size() == 0)) {
throw new MetExtractionException("Product references undefined");
}
}
示例5: execute
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
@Override
public void execute(ActionMessagePrinter printer) throws CmdLineActionException {
try {
Product p = getProduct();
printer.println("Product:");
printer.println(" - ID: " + p.getProductId());
printer.println(" - Name: " + p.getProductName());
printer.println(" - ProductType: " + p.getProductType().getName());
printer.println(" - Structure: " + p.getProductStructure());
printer.println(" - Status: " + p.getTransferStatus());
if (p.getRootRef() != null) {
printer.println(" - RootRef: " + p.getRootRef().getDataStoreReference());
}
if (!p.getProductReferences().isEmpty()) {
printer.println(" - References: ");
for (Reference ref : p.getProductReferences()) {
printer.println(" - " + ref.getDataStoreReference()
+ " (" + ref.getFileSize() + ")");
}
}
} catch (Exception e) {
throw new CmdLineActionException("Failed to get product info : "
+ e.getMessage(), e);
}
}
示例6: addResultsFromProductId
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
private void addResultsFromProductId(XMLQuery query, Product product)
throws URISyntaxException {
if (product != null && product.getProductReferences() != null
&& product.getProductReferences().size() > 0) {
for (Reference r : product.getProductReferences()) {
query.getResults().add(toResult(r));
}
}
}
示例7: getProduct
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
/**
* Gets an HTTP response that represents a {@link Product} from the file
* manager.
* @param productId the ID of the product
* @return an HTTP response that represents a {@link Product} from the file
* manager
*/
@GET
@Path("product")
@Produces({"application/xml", "application/json", "application/atom+xml",
"application/rdf+xml", "application/rss+xml", "application/zip"})
public ProductResource getProduct(@QueryParam("productId") String productId)
{
if (productId == null || productId.trim().equals(""))
{
throw new BadRequestException("This URL requires a productId query "
+ "parameter with a product ID value, "
+ "e.g. /product?productId=1787a257-df87-11e2-8a2d-e3f6264e86c5");
}
try
{
FileManagerClient client = getContextClient();
// Find the product.
Product product = client.getProductById(productId);
product.setProductReferences(client.getProductReferences(product));
// Create the product resource, add the product data and return the
// resource as the HTTP response.
return new ProductResource(product, client.getMetadata(product),
product.getProductReferences(), getContextWorkingDir());
}
catch (Exception e)
{
String message = "Unable to find the requested resource.";
LOGGER.log(Level.FINE, message, e);
throw new NotFoundException(message + " " + e.getMessage());
}
}
示例8: retrieveProduct
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
@Override
public void retrieveProduct(Product product, File directory) throws DataTransferException,
IOException {
for (Reference ref : product.getProductReferences()) {
GetObjectRequest request = new GetObjectRequest(bucketName, stripProtocol(
ref.getDataStoreReference(), true));
S3Object file = s3Client.getObject(request);
stageFile(file, ref, directory);
}
}
示例9: deleteProduct
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
@Override
public void deleteProduct(Product product) throws DataTransferException, IOException {
for (Reference ref : product.getProductReferences()) {
DeleteObjectRequest request = new DeleteObjectRequest(bucketName, stripProtocol(
ref.getDataStoreReference(), true));
try {
s3Client.deleteObject(request);
} catch (AmazonClientException e) {
throw new DataTransferException(String.format(
"Failed to delete product reference %s from S3", ref.getDataStoreReference()), e);
}
}
}
示例10: retrieveProduct
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
public void retrieveProduct(Product product, File directory)
throws DataTransferException, IOException {
for (Reference reference : product.getProductReferences()) {
FileOutputStream fOut = null;
try {
File dataStoreFile = new File(new URI(
reference.getDataStoreReference()));
File dest = new File(directory, dataStoreFile.getName());
fOut = new FileOutputStream(dest, false);
LOG.log(
Level.INFO,
"RemoteDataTransfer: Copying File: " + "fmp:"
+ dataStoreFile.getAbsolutePath() + " to " + "file:"
+ dest.getAbsolutePath());
byte[] fileData;
int offset = 0;
while (true) {
fileData = (byte[]) client.retrieveFile(
dataStoreFile.getAbsolutePath(), offset, NUM_BYTES);
if (fileData.length <= 0) {
break;
}
fOut.write(fileData);
if (fileData.length < NUM_BYTES) {
break;
}
offset += NUM_BYTES;
}
} catch (Exception e) {
throw new DataTransferException("", e);
} finally {
try {
fOut.close();
} catch (Exception ignored) {
}
}
}
}
示例11: deleteProduct
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
@Override
public void deleteProduct(Product product) throws DataTransferException, IOException {
for (Reference ref : product.getProductReferences()) {
File dataFile = new File(URI.create(ref.getDataStoreReference()).toURL().getPath());
if (!dataFile.delete()) {
throw new IOException(String.format("Failed to delete file %s - delete returned false",
dataFile));
}
}
}
示例12: copyDirToDir
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
private void copyDirToDir(Product product, File directory)
throws IOException, URISyntaxException {
Reference dirRef = product.getProductReferences().get(0);
LOG.log(
Level.INFO,
"LocalDataTransferer: Staging Directory: "
+ dirRef.getDataStoreReference() + " into directory "
+ directory.getAbsolutePath());
for (Reference r : product.getProductReferences()) {
File fileRef = new File(new URI(r.getDataStoreReference()));
if (fileRef.isFile()) {
copyFile(r, directory);
} else if (fileRef.isDirectory()
&& (fileRef.list() != null && fileRef.list().length == 0)) {
// if it's a directory and it doesn't exist yet, we should
// create it
// just in case there's no files in it
File dest = new File(directory, fileRef.getName());
if (!new File(new URI(dest.getAbsolutePath())).exists()) {
LOG.log(Level.FINER, "Directory: [" + dest.getAbsolutePath()
+ "] doesn't exist: creating it");
try {
FileUtils.forceMkdir(new File(new URI(dest.getAbsolutePath())));
} catch (IOException e) {
LOG.log(
Level.WARNING,
"Unable to create directory: ["
+ dest.getAbsolutePath()
+ "] in local data transferer");
}
}
}
}
}
示例13: moveFilesToProductRepo
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
private void moveFilesToProductRepo(Product product) throws IOException,
URISyntaxException {
List<Reference> refs = product.getProductReferences();
// notify the file manager that we started
quietNotifyTransferProduct(product);
for (Reference r : refs) {
moveFile(r, true);
}
// notify the file manager that we're done
quietNotifyProductTransferComplete(product);
}
示例14: copyFilesToDir
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
private void copyFilesToDir(Product product, File directory)
throws IOException, URISyntaxException {
List<Reference> refs = product.getProductReferences();
for (Reference r : refs) {
copyFile(r, directory);
}
}
示例15: scrubRefs
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
private void scrubRefs(Product p) {
if (p.getProductReferences() == null) {
return;
}
for (Reference r : p.getProductReferences()) {
r.setDataStoreReference("");
}
}