public static void addRefsFromUris(Product p, List<String> uris) { // add the refs to the Product for (String ref : uris) { Reference r = new Reference(ref, null, (p.getProductStructure().equals(Product.STRUCTURE_STREAM) ? -1 : quietGetFileSizeFromUri(ref))); p.getProductReferences().add(r); } }
public static void addRefsFromUris(Product p, List<String> uris) { // add the refs to the Product for (String ref : uris) { Reference r = new Reference(ref, null, (p.getProductStructure().equals(Product.STRUCTURE_STREAM) ? -1 : quietGetFileSizeFromUri(ref))); p.getProductReferences().add(r); } }
if (product.getProductStructure().equals(Product.STRUCTURE_HIERARCHICAL)) { try { copyDirToDir(product, directory); throw new DataTransferException(e); } else if (product.getProductStructure().equals(Product.STRUCTURE_FLAT)) { try { copyFilesToDir(product, directory); throw new DataTransferException(e); } else if (product.getProductStructure().equals(Product.STRUCTURE_STREAM)) { LOG.log(Level.INFO,"Streaming products are not transfered."); } else { throw new DataTransferException( "Cannot transfer product on unknown ProductStructure: " + product.getProductStructure());
protected File getProductFile(Product product) throws MetExtractionException { File prodFile; if (product.getProductStructure() .equals(Product.STRUCTURE_HIERARCHICAL)) { try { prodFile = new File(getRootRefPath(product .getProductReferences(), product.getProductType() .getProductRepositoryPath())); } catch (Exception e) { LOG.log(Level.SEVERE, e.getMessage()); throw new MetExtractionException("URI exception parsing: [" + product.getRootRef().getOrigReference() + "]"); } } else { try { prodFile = new File(new URI(((Reference) product .getProductReferences().get(0)).getOrigReference())); } catch (Exception e) { throw new MetExtractionException("URI exception parsing: [" + ((Reference) product.getProductReferences().get(0)) .getOrigReference() + "]"); } } return prodFile; }
protected File getProductFile(Product product) throws MetExtractionException { File prodFile; if (product.getProductStructure() .equals(Product.STRUCTURE_HIERARCHICAL)) { try { prodFile = new File(getRootRefPath(product .getProductReferences(), product.getProductType() .getProductRepositoryPath())); } catch (Exception e) { LOG.log(Level.SEVERE, e.getMessage()); throw new MetExtractionException("URI exception parsing: [" + product.getRootRef().getOrigReference() + "]"); } } else { try { prodFile = new File(new URI(((Reference) product .getProductReferences().get(0)).getOrigReference())); } catch (Exception e) { throw new MetExtractionException("URI exception parsing: [" + ((Reference) product.getProductReferences().get(0)) .getOrigReference() + "]"); } } return prodFile; }
public void createDataStoreReferences(Product product, Metadata metadata) throws VersioningException { // since we need the metadata, if the metadata is null, throw an // exception if (metadata == null) { throw new VersioningException( "Unable to version product with no metadata!"); } // we also only deal with Flat products, that is, Products with a single // reference if (flatProducts && !product.getProductStructure() .equals(Product.STRUCTURE_FLAT)) { throw new VersioningException( "Can only handle FLAT product structures"); } // get the product type repo path String productTypeRepoPath = VersioningUtils .getAbsolutePathFromUri(product.getProductType() .getProductRepositoryPath()); // parse the file path spec String filePathRef = parseFilePathSpec(filePathSpec, productTypeRepoPath, metadata); String filePathUri = new File(filePathRef).toURI().toString(); Reference r = (Reference) product.getProductReferences().get(0); LOG.log(Level.INFO, "Generated data store ref: [" + filePathUri + "] from origRef: [" + r.getOrigReference() + "]"); r.setDataStoreReference(filePathUri); }
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; }
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; }
public void createDataStoreReferences(Product product, Metadata metadata) throws VersioningException { // since we need the metadata, if the metadata is null, throw an // exception if (metadata == null) { throw new VersioningException( "Unable to version product with no metadata!"); } // we also only deal with Flat products, that is, Products with a single // reference if (flatProducts && !product.getProductStructure() .equals(Product.STRUCTURE_FLAT)) { throw new VersioningException( "Can only handle FLAT product structures"); } // get the product type repo path String productTypeRepoPath = VersioningUtils .getAbsolutePathFromUri(product.getProductType() .getProductRepositoryPath()); // parse the file path spec String filePathRef = parseFilePathSpec(filePathSpec, productTypeRepoPath, metadata); String filePathUri = new File(filePathRef).toURI().toString(); Reference r = (Reference) product.getProductReferences().get(0); LOG.log(Level.INFO, "Generated data store ref: [" + filePathUri + "] from origRef: [" + r.getOrigReference() + "]"); r.setDataStoreReference(filePathUri); }
this.addKeyValueToMap(fields, Parameters.PRODUCT_STRUCTURE, product.getProductStructure()); this.addKeyValueToMap(fields, Parameters.PRODUCT_TRANSFER_STATUS, product.getTransferStatus()); ProductType productType = product.getProductType();
this.addKeyValueToMap(fields, Parameters.PRODUCT_STRUCTURE, product.getProductStructure()); this.addKeyValueToMap(fields, Parameters.PRODUCT_TRANSFER_STATUS, product.getTransferStatus()); ProductType productType = product.getProductType();
+ p.getProductName() + ",type=" + p.getProductType().getName() + ",structure=" + p.getProductStructure() + ", transferStatus=" + p.getTransferStatus() + "]");
public Metadata doExtract(Product product, Metadata met) throws MetExtractionException { Metadata extractMet = new Metadata(); merge(met, extractMet); if (product.getProductStructure().equals(Product.STRUCTURE_FLAT)) { Reference prodRef = (Reference) product.getProductReferences().get( 0); extractMet.addMetadata(MIME_TYPE, prodRef.getMimeType().getName()); extractMet.addMetadata(MIME_TYPE, prodRef.getMimeType() .getType().getType()); extractMet.addMetadata(MIME_TYPE, prodRef.getMimeType() .getType().getSubtype()); } return extractMet; }
public Metadata doExtract(Product product, Metadata met) throws MetExtractionException { Metadata extractMet = new Metadata(); merge(met, extractMet); if (product.getProductStructure().equals(Product.STRUCTURE_FLAT)) { Reference prodRef = (Reference) product.getProductReferences().get( 0); extractMet.addMetadata(MIME_TYPE, prodRef.getMimeType().getName()); extractMet.addMetadata(MIME_TYPE, prodRef.getMimeType() .getType().getType()); extractMet.addMetadata(MIME_TYPE, prodRef.getMimeType() .getType().getSubtype()); } return extractMet; }
+ p.getProductName() + ",type=" + p.getProductType().getName() + ",structure=" + p.getProductStructure() + ", transferStatus=" + p.getTransferStatus() + "]");
@Override protected Product createSerializableVersionOf(Product product) { SerializableProduct sp = new SerializableProduct(); sp.setProductId(product.getProductId()); sp.setProductName(product.getProductName()); sp.setProductReferences(product.getProductReferences()); sp.setProductStructure(product.getProductStructure()); sp.setProductType(product.getProductType()); sp.setRootRef(product.getRootRef()); sp.setTransferStatus(product.getTransferStatus()); return sp; }
@Override protected Product createSerializableVersionOf(Product product) { SerializableProduct sp = new SerializableProduct(); sp.setProductId(product.getProductId()); sp.setProductName(product.getProductName()); sp.setProductReferences(product.getProductReferences()); sp.setProductStructure(product.getProductStructure()); sp.setProductType(product.getProductType()); sp.setRootRef(product.getRootRef()); sp.setTransferStatus(product.getTransferStatus()); return sp; }
@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); } }
@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); } }
public static AvroProduct getAvroProduct(Product product){ AvroProduct avroProduct = new AvroProduct(); if (product.getProductId() != null) avroProduct.setProductId(product.getProductId()); if (product.getProductName() != null) avroProduct.setProductName(product.getProductName()); if (product.getProductType() != null) avroProduct.setProductType(getAvroProductType(product.getProductType())); if (product.getProductType() != null) avroProduct.setProductStructure(product.getProductStructure()); //referince List<Reference> references = product.getProductReferences(); if (references != null){ List<AvroReference> avroReferences = AvroTypeFactory.getAvroReferences(product.getProductReferences()); avroProduct.setReferences(avroReferences); } if (product.getTransferStatus() != null) avroProduct.setTransferStatus(product.getTransferStatus()); if (product.getRootRef() != null) avroProduct.setRootRef(getAvroReference(product.getRootRef())); return avroProduct; }