Package org.apache.oodt.cas.filemgr.structs

Examples of org.apache.oodt.cas.filemgr.structs.Product


        }

    }

    public boolean hasProduct(String productName) throws CatalogException {
        Product p = catalog.getProductByName(productName);
        return p != null
                && p.getTransferStatus().equals(Product.STATUS_RECEIVED);
    }
View Full Code Here


                && p.getTransferStatus().equals(Product.STATUS_RECEIVED);
    }

    public Hashtable<String, Object> getMetadata(
            Hashtable<String, Object> productHash) throws CatalogException {
        Product product = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
        return this.getMetadata(product).getHashtable();
    }
View Full Code Here

    }

    public Hashtable<String, Object> getReducedMetadata(
            Hashtable<String, Object> productHash, Vector<String> elements)
            throws CatalogException {
        Product product = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
        return this.getReducedMetadata(product, elements).getHashtable();
    }
View Full Code Here

    public Vector<Hashtable<String, Object>> getProductReferences(
            Hashtable<String, Object> productHash)
            throws CatalogException {
        List<Reference> referenceList = null;
        Product product = XmlRpcStructFactory.getProductFromXmlRpc(productHash);

        try {
            referenceList = catalog.getProductReferences(product);
            return XmlRpcStructFactory.getXmlRpcReferences(referenceList);
        } catch (CatalogException e) {
            e.printStackTrace();
            LOG.log(Level.SEVERE, "Unable to obtain references for product: ["
                    + product.getProductName() + "]: Message: "
                    + e.getMessage());
            throw new CatalogException(e.getMessage());
        }

    }
View Full Code Here

    }

    public Hashtable<String, Object> getProductById(String productId)
            throws CatalogException {
        Product product = null;

        try {
            product = catalog.getProductById(productId);
            // it is possible here that the underlying catalog did not
            // set the ProductType
            // to obey the contract of the File Manager, we need to make
            // sure its set here
            product.setProductType(this.repositoryManager
                    .getProductTypeById(product.getProductType()
                            .getProductTypeId()));
            return XmlRpcStructFactory.getXmlRpcProduct(product);
        } catch (CatalogException e) {
            e.printStackTrace();
            LOG.log(Level.SEVERE, "Unable to obtain product by id: ["
                    + productId + "]: Message: " + e.getMessage());
            throw new CatalogException(e.getMessage());
        } catch (RepositoryManagerException e) {
            e.printStackTrace();
            LOG.log(Level.SEVERE, "Unable to obtain product type by id: ["
                    + product.getProductType().getProductTypeId()
                    + "]: Message: " + e.getMessage());
            throw new CatalogException(e.getMessage());
        }

    }
View Full Code Here

    }

    public Hashtable<String, Object> getProductByName(String productName)
            throws CatalogException {
        Product product = null;

        try {
            product = catalog.getProductByName(productName);
            // it is possible here that the underlying catalog did not
            // set the ProductType
            // to obey the contract of the File Manager, we need to make
            // sure its set here
            product.setProductType(this.repositoryManager
                    .getProductTypeById(product.getProductType()
                            .getProductTypeId()));
            return XmlRpcStructFactory.getXmlRpcProduct(product);
        } catch (CatalogException e) {
            e.printStackTrace();
            LOG.log(Level.SEVERE, "Unable to obtain product by name: ["
                    + productName + "]: Message: " + e.getMessage());
            throw new CatalogException(e.getMessage());
        } catch (RepositoryManagerException e) {
            e.printStackTrace();
            LOG.log(Level.SEVERE, "Unable to obtain product type by id: ["
                    + product.getProductType().getProductTypeId()
                    + "]: Message: " + e.getMessage());
            throw new CatalogException(e.getMessage());
        }
    }
View Full Code Here

            List<QueryResult> queryResults = new LinkedList<QueryResult>();
            for (ProductType productType : productTypes) {
                List<String> productIds = catalog.query(this.getCatalogQuery(
                        complexQuery, productType), productType);
                for (String productId : productIds) {
                    Product product = catalog.getProductById(productId);
                    product.setProductType(productType);
                    QueryResult qr = new QueryResult(product, this
                            .getReducedMetadata(product, complexQuery
                                    .getReducedMetadata()));
                    qr.setToStringFormat(complexQuery
                            .getToStringResultFormat());
View Full Code Here

        }
    }

    public synchronized String catalogProduct(Hashtable<String, Object> productHash)
            throws CatalogException {
        Product p = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
        return catalogProduct(p);
    }
View Full Code Here

        return catalogProduct(p);
    }

    public synchronized boolean addMetadata(Hashtable<String, Object> productHash,
            Hashtable<String, String> metadata) throws CatalogException {
        Product p = XmlRpcStructFactory.getProductFromXmlRpc(productHash);
        Metadata m = new Metadata();
        m.addMetadata((Hashtable)metadata);
        return addMetadata(p, m);
    }
View Full Code Here

                    || (clientTransfer && dataTransferClass == null)) {
                System.err.println(ingestProductOperation);
                System.exit(1);
            }

            Product product = new Product();
            product.setProductName(productName);
            product.setProductStructure(productStructure);
            product
                    .setProductType(client
                            .getProductTypeByName(productTypeName));

            if (clientTransfer) {
                client.setDataTransfer(GenericFileManagerObjectFactory
                        .getDataTransferServiceFromFactory(dataTransferClass));
            }

            // need to build up the ref uri list in case the Product structure
            // is
            // heirarchical
            if (product.getProductStructure().equals(
                    Product.STRUCTURE_HIERARCHICAL)) {
                String ref = (String) refs.get(0);
                refs.addAll(VersioningUtils.getURIsFromDir(new File(
                        new URI(ref))));
            }

            // add Product References from the URI list
            VersioningUtils.addRefsFromUris(product, refs);

            try {
                Metadata metadata = null;
                URL metaUrl = new File(new URI(metadataFileName)).toURL();
                metadata = new SerializableMetadata(metaUrl.openStream());
                System.out.println("ingestProduct: Result: "
                        + client.ingestProduct(product, metadata,
                                clientTransfer));
            } catch (Exception e) {
                e.printStackTrace();
                LOG.log(Level.SEVERE, "Exception ingesting product!: Message: "
                        + e.getMessage());
                throw new RuntimeException(e);
            }

        } else if (operation.equals("--hasProduct")) {
            String productName = null;

            for (int i = 4; i < args.length; i++) {
                if (args[i].equals("--productName")) {
                    productName = args[++i];
                }
            }

            if (productName == null) {
                System.err.println(hasProductOperation);
                System.exit(1);
            }

            try {
                System.out.println("hasProduct: Result: "
                        + client.hasProduct(productName));
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            }
        } else if (operation.equals("--getProductTypeByName")) {
            String productTypeName = null;

            for (int i = 4; i < args.length; i++) {
                if (args[i].equals("--productTypeName")) {
                    productTypeName = args[++i];
                }
            }

            if (productTypeName == null) {
                System.err.println(getProductTypeByNameOperation);
                System.exit(1);
            }

            try {
                ProductType type = client.getProductTypeByName(productTypeName);
                System.out.println("getProductTypeByName: Result: [name="
                        + type.getName() + ", description="
                        + type.getDescription() + ", id="
                        + type.getProductTypeId() + ", versionerClass="
                        + type.getVersioner() + ", repositoryPath="
                        + type.getProductRepositoryPath() + "]");
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            }
        } else if (operation.equals("--getNumProducts")) {
            String typeName = null;

            for (int i = 4; i < args.length; i++) {
                if (args[i].equals("--productTypeName")) {
                    typeName = args[++i];
                }
            }

            if (typeName == null) {
                System.err.println(getNumProductsOperation);
                System.exit(1);
            }

            try {
                System.out.println("Type: ["
                        + typeName
                        + "], Num Products: ["
                        + client.getNumProducts(client
                                .getProductTypeByName(typeName)) + "]");
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            }
        } else if (operation.equals("--getFirstPage")) {
            String typeName = null;

            for (int i = 4; i < args.length; i++) {
                if (args[i].equals("--productTypeName")) {
                    typeName = args[++i];
                }
            }

            if (typeName == null) {
                System.err.println(getFirstPageOperation);
                System.exit(1);
            }

            try {
                ProductType type = client.getProductTypeByName(typeName);
                ProductPage firstPage = client.getFirstPage(type);

                System.out.println("Page: [num=" + firstPage.getPageNum()
                        + ", totalPages=" + firstPage.getTotalPages()
                        + ", pageSize=" + firstPage.getPageSize() + "]");
                System.out.println("Products:");

                if (firstPage.getPageProducts() != null
                        && firstPage.getPageProducts().size() > 0) {
                    for (Iterator<Product> i = firstPage.getPageProducts()
                            .iterator(); i.hasNext();) {
                        Product p = i.next();
                        System.out.println("Product: [id=" + p.getProductId()
                                + ",name=" + p.getProductName() + ",type="
                                + p.getProductType().getName() + ",structure="
                                + p.getProductStructure() + ", transferStatus="
                                + p.getTransferStatus() + "]");
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            }

        } else if (operation.equals("--getNextPage")) {
            String typeName = null;
            int currentPageNum = -1;

            for (int i = 4; i < args.length; i++) {
                if (args[i].equals("--productTypeName")) {
                    typeName = args[++i];
                } else if (args[i].equals("--currentPageNum")) {
                    currentPageNum = Integer.parseInt(args[++i]);
                }
            }

            if (typeName == null || currentPageNum == -1) {
                System.err.println(getNextPageOperation);
                System.exit(1);
            }

            try {
                ProductType type = client.getProductTypeByName(typeName);
                ProductPage firstPage = client.getFirstPage(type);
                ProductPage currentPage = new ProductPage();
                currentPage.setPageNum(currentPageNum);
                currentPage.setPageSize(firstPage.getPageSize());
                currentPage.setTotalPages(firstPage.getTotalPages());
                ProductPage nextPage = client.getNextPage(type, currentPage);

                System.out.println("Page: [num=" + nextPage.getPageNum()
                        + ", totalPages=" + nextPage.getTotalPages()
                        + ", pageSize=" + nextPage.getPageSize() + "]");
                System.out.println("Products:");

                if (nextPage.getPageProducts() != null
                        && nextPage.getPageProducts().size() > 0) {
                    for (Iterator<Product> i = nextPage.getPageProducts()
                            .iterator(); i.hasNext();) {
                        Product p = i.next();
                        System.out.println("Product: [id=" + p.getProductId()
                                + ",name=" + p.getProductName() + ",type="
                                + p.getProductType().getName() + ",structure="
                                + p.getProductStructure() + ", transferStatus="
                                + p.getTransferStatus() + "]");
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            }
        } else if (operation.equals("--getPrevPage")) {
            String typeName = null;
            int currentPageNum = -1;

            for (int i = 4; i < args.length; i++) {
                if (args[i].equals("--productTypeName")) {
                    typeName = args[++i];
                } else if (args[i].equals("--currentPageNum")) {
                    currentPageNum = Integer.parseInt(args[++i]);
                }
            }

            if (typeName == null || currentPageNum == -1) {
                System.err.println(getNextPageOperation);
                System.exit(1);
            }

            try {
                ProductType type = client.getProductTypeByName(typeName);
                ProductPage firstPage = client.getFirstPage(type);
                ProductPage currentPage = new ProductPage();
                currentPage.setPageNum(currentPageNum);
                currentPage.setPageSize(firstPage.getPageSize());
                currentPage.setTotalPages(firstPage.getTotalPages());
                ProductPage prevPage = client.getPrevPage(type, currentPage);

                System.out.println("Page: [num=" + prevPage.getPageNum()
                        + ", totalPages=" + prevPage.getTotalPages()
                        + ", pageSize=" + prevPage.getPageSize() + "]");
                System.out.println("Products:");

                if (prevPage.getPageProducts() != null
                        && prevPage.getPageProducts().size() > 0) {
                    for (Iterator<Product> i = prevPage.getPageProducts()
                            .iterator(); i.hasNext();) {
                        Product p = i.next();
                        System.out.println("Product: [id=" + p.getProductId()
                                + ",name=" + p.getProductName() + ",type="
                                + p.getProductType().getName() + ",structure="
                                + p.getProductStructure() + ", transferStatus="
                                + p.getTransferStatus() + "]");
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            }
        } else if (operation.equals("--getLastPage")) {
            String typeName = null;

            for (int i = 4; i < args.length; i++) {
                if (args[i].equals("--productTypeName")) {
                    typeName = args[++i];
                }
            }

            if (typeName == null) {
                System.err.println(getLastPageOperation);
                System.exit(1);
            }

            try {
                ProductType type = client.getProductTypeByName(typeName);
                ProductPage lastPage = client.getLastPage(type);

                System.out.println("Page: [num=" + lastPage.getPageNum()
                        + ", totalPages=" + lastPage.getTotalPages()
                        + ", pageSize=" + lastPage.getPageSize() + "]");
                System.out.println("Products:");

                if (lastPage.getPageProducts() != null
                        && lastPage.getPageProducts().size() > 0) {
                    for (Iterator<Product> i = lastPage.getPageProducts()
                            .iterator(); i.hasNext();) {
                        Product p = i.next();
                        System.out.println("Product: [id=" + p.getProductId()
                                + ",name=" + p.getProductName() + ",type="
                                + p.getProductType().getName() + ",structure="
                                + p.getProductStructure() + ", transferStatus="
                                + p.getTransferStatus() + "]");
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            }

        } else if (operation.equals("--getCurrentTransfer")) {
            FileTransferStatus status = null;

            try {
                status = client.getCurrentFileTransfer();
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            }

            System.out.println("File Transfer: [ref={orig="
                    + status.getFileRef().getOrigReference() + ",ds="
                    + status.getFileRef().getDataStoreReference()
                    + "},product=" + status.getParentProduct().getProductName()
                    + ",fileSize=" + status.getFileRef().getFileSize()
                    + ",amtTransferred=" + status.getBytesTransferred()
                    + ",pct=" + status.computePctTransferred() + "]");
        } else if (operation.equals("--getCurrentTransfers")) {
            List<FileTransferStatus> statuses = null;

            try {
                statuses = client.getCurrentFileTransfers();
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            }

            if (statuses != null && statuses.size() > 0) {
                for (Iterator<FileTransferStatus> i = statuses.iterator(); i
                        .hasNext();) {
                    FileTransferStatus status = i.next();
                    System.out.println("File Transfer: [ref={orig="
                            + status.getFileRef().getOrigReference() + ",ds="
                            + status.getFileRef().getDataStoreReference()
                            + "},product="
                            + status.getParentProduct().getProductName()
                            + ",fileSize=" + status.getFileRef().getFileSize()
                            + ",amtTransferred=" + status.getBytesTransferred()
                            + ",pct=" + status.computePctTransferred() + "]");
                }
            }
        } else if (operation.equals("--getProductPctTransferred")) {
            String productTypeName = null, productId = null;

            for (int i = 4; i < args.length; i++) {
                if (args[i].equals("--productId")) {
                    productId = args[++i];
                } else if (args[i].equals("--productTypeName")) {
                    productTypeName = args[++i];
                }
            }

            if (productTypeName == null || productId == null) {
                System.err.println(getProductPctTransferredOperation);
                System.exit(1);
            }

            Product product = new Product();
            product.setProductName(" ");
            product.setProductStructure(" ");
            product
                    .setProductType(client
                            .getProductTypeByName(productTypeName));
            product.setProductId(productId);

            double pct = 0.0;

            try {
                pct = client.getProductPctTransferred(product);
View Full Code Here

TOP

Related Classes of org.apache.oodt.cas.filemgr.structs.Product

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.