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

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


        return product;
    }

    public static Reference getReference(ResultSet rs) throws SQLException {
        Reference r = new Reference();
        r.setOrigReference(rs.getString("product_orig_reference"));
        r.setDataStoreReference(rs.getString("product_datastore_reference"));
        r.setFileSize(rs.getLong("product_reference_filesize"));
        r.setMimeType(rs.getString("product_reference_mimetype"));
        return r;
    }
View Full Code Here


        quietNotifyTransferProduct(product);

        // for each file reference, transfer the file to the remote file manager
        for (Iterator<Reference> i = product.getProductReferences().iterator(); i
                .hasNext();) {
            Reference r = i.next();
            // test whether or not the reference is a directory or a file
            File refFile = null;
            try {
                refFile = new File(new URI(r.getOrigReference()));
            } catch (URISyntaxException e) {
                LOG.log(Level.WARNING, "Unable to test if reference: ["
                        + r.getOrigReference()
                        + "] is a directory: skipping it");
                continue;
            }

            if (!refFile.isDirectory()) {
                LOG.log(Level.FINE, "Reference: [" + r.getOrigReference()
                        + "] is file: transferring it");

                try {
                    remoteTransfer(r, product);
                } catch (URISyntaxException e) {
                    LOG.log(Level.WARNING, "Error transferring file: ["
                            + r.getOrigReference() + "]: URISyntaxException: "
                            + e.getMessage());
                }
            } else {
                LOG.log(Level.FINE, "RemoteTransfer: skipping reference: ["
                        + refFile.getAbsolutePath() + "] of product: ["
View Full Code Here

            // get its references
            List<Reference> refs = quietGetReferences(p);

            if (refs != null && refs.size() > 0) {
                for (Iterator<Reference> j = refs.iterator(); j.hasNext();) {
                    Reference r = j.next();

                    long bytesTransferred = getBytesTransferred(r);

                    if (bytesTransferred > 0
                            && bytesTransferred < r.getFileSize() && !isDir(r)) {
                        FileTransferStatus status = new FileTransferStatus();
                        status.setBytesTransferred(bytesTransferred);
                        status.setFileRef(r);
                        status.setParentProduct(p);
                        currTransfers.add(status);
View Full Code Here

        long totalBytesTransferred = 0L;
        long totalProductSize = 0L;

        if (refs.size() > 0) {
            for (Iterator<Reference> j = refs.iterator(); j.hasNext();) {
                Reference r = (Reference) j.next();

                long bytesTransferred = getBytesTransferred(r);

                if (!isDir(r)) {
                    // only add this if > 0
                    if (bytesTransferred > 0) {
                        totalBytesTransferred += bytesTransferred;
                    }

                    // add this no matter what
                    totalProductSize += r.getFileSize();
                }

            }
        }
View Full Code Here

            File dir = stack.pop();
            // add the reference for the dir
            // except if it's the rootDir, then, skip it
            if (!dir.equals(dirRoot)) {
                try {
                    Reference r = new Reference();
                    r.setOrigReference(dir.toURL().toExternalForm());
                    r.setFileSize(dir.length());
                    references.add(r);
                } catch (MalformedURLException e) {
                    e.printStackTrace();
                    LOG.log(Level.WARNING,
                            "MalformedURLException when generating reference for dir: "
                                    + dir);
                }
            }

            File[] files = dir.listFiles(FILE_FILTER);

            for (int i = 0; i < files.length; i++) {
                // add the file references
                try {
                    Reference r = new Reference();
                    r.setOrigReference(files[i].toURL().toExternalForm());
                    r.setFileSize(files[i].length());
                    references.add(r);
                } catch (MalformedURLException e) {
                    e.printStackTrace();
                    LOG.log(Level.WARNING,
                            "MalformedURLException when generating reference for file: "
View Full Code Here

                .getDataStoreReference();
        String origDirRef = references.get(0).getOrigReference();
        String origDirRefName = new File(origDirRef).getName();

        for (Iterator<Reference> i = references.iterator(); i.hasNext();) {
            Reference r = i.next();

            // don't bother with the first one, because it's already set
            // correctly
            if (r.getOrigReference().equals(origDirRef)) {
                continue;
            }

            // get the first occurence of the origDir name in the string
            // then, the ref becomes:
            // toDir+r.getOrigRef.substring(first occurence of
            // origDir).substring(first occurence of '/'+1)

            String dataStoreRef = toDirRef;
            int firstOccurenceOfOrigDir = r.getOrigReference().indexOf(
                    origDirRefName);
            String tmpRef = r.getOrigReference().substring(
                    firstOccurenceOfOrigDir);
            LOG.log(Level.FINER, "tmpRef: " + tmpRef);
            int firstOccurenceSlash = tmpRef.indexOf("/");
            dataStoreRef += tmpRef.substring(firstOccurenceSlash + 1);

            LOG.log(Level.FINE, "VersioningUtils: Generated data store ref: "
                    + dataStoreRef + " from origRef: " + r.getOrigReference());
            r.setDataStoreReference(dataStoreRef);
        }

    }
View Full Code Here

    }

    public static void createBasicDataStoreRefsFlat(String productName,
            String productRepoPath, List<Reference> references) {
        for (Iterator<Reference> i = references.iterator(); i.hasNext();) {
            Reference r = i.next();

            String dataStoreRef = null;
            String productRepoPathRef = null;

            try {
                productRepoPathRef = new File(new URI(productRepoPath)).toURL()
                        .toExternalForm();

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

                dataStoreRef = productRepoPathRef
                        + URLEncoder.encode(productName, "UTF-8") + "/"
                        + new File(new URI(r.getOrigReference())).getName();
            } catch (IOException e) {
                LOG.log(Level.WARNING,
                        "VersioningUtils: Error generating dataStoreRef for "
                                + r.getOrigReference() + ": Message: "
                                + e.getMessage());
            } catch (URISyntaxException e) {
                LOG.log(Level.WARNING,
                        "VersioningUtils: Error generating dataStoreRef for "
                                + r.getOrigReference() + ": Message: "
                                + e.getMessage());
            }

            LOG.log(Level.FINE, "VersioningUtils: Generated data store ref: "
                    + dataStoreRef + " from origRef: " + r.getOrigReference());
            r.setDataStoreReference(dataStoreRef);
        }

    }
View Full Code Here

    public static void addRefsFromUris(Product p, List<String> uris) {
        // add the refs to the Product
        for (Iterator<String> i = uris.iterator(); i.hasNext();) {
            String ref = i.next();
            Reference r = new Reference(ref, null, quietGetFileSizeFromUri(ref));
            p.getProductReferences().add(r);
        }
    }
View Full Code Here

            // productTypeRepo/productName/fileName.productionDateTime
            // we'll use the format: yyyy.dd.MM.HH.mm.ss

            for (Iterator<Reference> i = product.getProductReferences().iterator(); i
                    .hasNext();) {
                Reference r = i.next();
                String dataStoreRef = null;

                try {
                    dataStoreRef = new File(new URI(product.getProductType()
                            .getProductRepositoryPath())).toURL()
                            .toExternalForm()
                            + "/"
                            + product.getProductName()
                            + "/"
                            + new File(new URI(r.getOrigReference())).getName()
                            + "." + productionDateTime;
                    LOG.log(Level.FINER,
                            "DateTimeVersioner: Generated dataStoreRef: "
                                    + dataStoreRef + " from original ref: "
                                    + r.getOrigReference());
                    r.setDataStoreReference(dataStoreRef);
                } catch (URISyntaxException e) {
                    LOG
                            .log(
                                    Level.WARNING,
                                    "DateTimeVersioner: Error generating URI to get name "
                                            + "of original ref while generating data store ref for orig ref: "
                                            + r.getOrigReference()
                                            + ": Message: " + e.getMessage());
                    // try and keep generating
                } catch (MalformedURLException e) {
                    LOG.log(Level.WARNING,
                            "DateTimeVersioner: Error getting URL for product repository path "
                                    + product.getProductType()
                                            .getProductRepositoryPath()
                                    + ": Message: " + e.getMessage());
                    // try and keep generating
                }

            }
        } else if (product.getProductStructure().equals(
                Product.STRUCTURE_HIERARCHICAL)) {
            // if its heirarchical, then we'll version the files within the
            // directory
            // first, we need to get a list of all the references from the
            // original dir
            Reference origDirRef = (Reference) product.getProductReferences()
                    .get(0);

            try {
                String dataStoreRef = new File(new URI(product.getProductType()
                        .getProductRepositoryPath())).toURL().toExternalForm()
                        + URLEncoder.encode(product.getProductName(), "UTF-8")
                        + "/";
                LOG.log(Level.INFO,
                        "DateTimeVersioner: generated DataStore ref: "
                                + dataStoreRef + " from origDirRef: "
                                + origDirRef.getOrigReference());
                origDirRef.setDataStoreReference(dataStoreRef);
            } catch (MalformedURLException e) {
                LOG.log(Level.WARNING,
                        "DateTimeVersioner: MalformedURLException while generating "
                                + "initial data store ref for origRef: "
                                + origDirRef.getOrigReference());
                throw new VersioningException(e);
            } catch (URISyntaxException e) {
                LOG.log(Level.WARNING,
                        "DateTimeVersioner: Error creating File reference from original dir URI: "
                                + origDirRef.getOrigReference() + ": Message: "
                                + e.getMessage());
                throw new VersioningException(
                        "Unable to generate references from original dir reference for product: "
                                + product.getProductName() + ": Message: "
                                + e.getMessage());
            } catch (UnsupportedEncodingException e) {
                LOG.log(Level.WARNING,
                        "DateTimeVersioner: UnsupportedEncodingException while generating "
                                + "initial data store ref for origRef: "
                                + origDirRef.getOrigReference());
                throw new VersioningException(e);
            }

            // create the basic data store refs
            VersioningUtils.createBasicDataStoreRefsHierarchical(product
View Full Code Here

    }

    private void addProductDateTimeToReferences(List<Reference> references,
            String productionDateTime) {
        for (Iterator<Reference> i = references.iterator(); i.hasNext();) {
            Reference r = i.next();
            if (!r.getOrigReference().endsWith("/")) {
                r.setDataStoreReference(r.getDataStoreReference() + "."
                        + productionDateTime);
            }
        }
    }
View Full Code Here

TOP

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

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.