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

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


            }

            // get the first reference, it tells us what directory to move it
            // to
            // TODO: fix that hack :-)
            Reference r = (Reference) product.getProductReferences().get(0);

            String dataStoreRef = null;

            try {
                dataStoreRef = new File(new URI(productRepoPath)).toURL()
                        .toExternalForm()
                        + URLEncoder.encode(productName, "UTF-8") + "/";
                LOG.log(Level.INFO, "BasicVersioner: generated DataStore ref: "
                        + dataStoreRef + " from origRef: "
                        + r.getOrigReference());
                r.setDataStoreReference(dataStoreRef);
                VersioningUtils.createBasicDataStoreRefsHierarchical(product
                        .getProductReferences());
            } catch (URISyntaxException e) {
                LOG.log(Level.WARNING,
                        "BasicVersioner: URISyntaxException while generating initial "
                                + "data store ref for origRef: "
                                + r.getOrigReference());
                throw new VersioningException(e);
            } catch (MalformedURLException e) {
                LOG.log(Level.WARNING,
                        "BasicVersioner: MalformedURLException while generating initial "
                                + "data store ref for origRef: "
                                + r.getOrigReference());
                throw new VersioningException(e);
            } catch (UnsupportedEncodingException e) {
                LOG.log(Level.WARNING,
                        "BasicVersioner: UnsupportedEncodingException while generating "
                                + "initial data store ref for origRef: "
                                + r.getOrigReference());
                throw new VersioningException(e);
            }

        } else if (product.getProductStructure().equals(Product.STRUCTURE_FLAT)) {
            // just use the VersioningUtils
View Full Code Here


                        .getProperty("org.apache.oodt.cas.filemgr.mime.type.repository"));

        String productName = null;
        String productRepo = null;
        String transferType = null;
        Reference dirReference = null;

        List<Reference> fileReferences = null;

        for (int i = 0; i < args.length; i++) {
            if (args[i].equals("--dir")) {
                transferType = "dir";
                dirReference = new Reference();
                dirReference.setOrigReference(new File(new URI(args[++i]))
                        .toURI().toString());
                LOG.log(Level.FINER,
                        "LocalFileTransfer.main: Generated orig reference: "
                                + dirReference.getOrigReference());
            } else if (args[i].equals("--files")) {
                transferType = "files";
                fileReferences = new Vector<Reference>();
                for (int j = i + 1; j < args.length; j++) {
                    LOG.log(Level.FINER,
                            "LocalFileTransfer.main: Adding file ref: "
                                    + args[j]);
                    fileReferences.add(new Reference(args[j], null, new File(
                            args[j]).length(), mimeTypeRepo
                            .getMimeType(args[j])));
                }
            } else if (args[i].equals("--productName")) {
                productName = args[++i];
            } else if (args[i].equals("--productRepo")) {
                productRepo = args[++i];
            }
        }

        if (transferType == null
                || (transferType != null && ((transferType.equals("dir") && dirReference == null)
                        || (transferType.equals("files") && fileReferences == null)
                        || (transferType != null && !(transferType
                                .equals("dir") || transferType.equals("files")))
                        || productName == null || productRepo == null))) {
            System.err.println(usage);
            System.exit(1);
        }

        // construct a new Product
        Product p = new Product();
        p.setProductName(productName);

        if (transferType.equals("dir")) {
            p.setProductStructure(Product.STRUCTURE_HIERARCHICAL);
            dirReference.setDataStoreReference(new File(new URI(productRepo))
                    .toURL().toExternalForm()
                    + URLEncoder.encode(p.getProductName(), "UTF-8") + "/");
            p.getProductReferences().add(dirReference);
            /* we'll do a simple versioning scheme ourselves: no versioning! */
            p.getProductReferences().addAll(
                    VersioningUtils.getReferencesFromDir(new File(new URI(
                            dirReference.getOrigReference()))));
            VersioningUtils.createBasicDataStoreRefsHierarchical(p
                    .getProductReferences());
        } else if (transferType.equals("files")) {
            p.setProductStructure("Flat");
            p.getProductReferences().addAll(fileReferences);
View Full Code Here

    }

    private void moveDirToProductRepo(Product product) throws IOException,
            URISyntaxException {
        Reference dirRef = (Reference) product.getProductReferences().get(0);
        LOG.log(Level.INFO, "LocalDataTransferer: Moving Directory: "
                + dirRef.getOrigReference() + " to "
                + dirRef.getDataStoreReference());

        // notify the file manager that we started
        quietNotifyTransferProduct(product);

        for (Iterator<Reference> i = product.getProductReferences().iterator(); i
                .hasNext();) {
            Reference r = i.next();
            File fileRef = new File(new URI(r.getOrigReference()));

            if (fileRef.isFile()) {
                moveFile(r, false);
            } 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
                if (!new File(new URI(r.getDataStoreReference())).exists()) {
                    LOG.log(Level.FINER, "Directory: ["
                            + r.getDataStoreReference()
                            + "] doesn't exist: creating it");
                    if (!new File(new URI(r.getDataStoreReference())).mkdirs()) {
                        LOG.log(Level.WARNING, "Unable to create directory: ["
                                + r.getDataStoreReference()
                                + "] in local data transferer");
                    }
                }
            }
        }
View Full Code Here

        // notify the file manager that we started
        quietNotifyTransferProduct(product);

        for (Iterator<Reference> i = refs.iterator(); i.hasNext();) {
            Reference r = (Reference) i.next();
            moveFile(r, true);
        }

        // notify the file manager that we're done
        quietNotifyProductTransferComplete(product);
View Full Code Here

        String dataStorePath = productTypeRepoPath + filename;
        String dataStoreRef = new File(dataStorePath).toURI().toString();

        // get the first reference back
        // set its data store ref
        Reference ref = (Reference) product.getProductReferences().get(0);
        LOG.log(Level.INFO, "Generated data store ref: [" + dataStoreRef
                + "] from origRef: [" + ref.getOrigReference() + "]");
        ref.setDataStoreReference(dataStoreRef);

    }
View Full Code Here

        // 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);
    }
View Full Code Here

                for (Iterator j = page.getPageProducts().iterator(); j
                        .hasNext();) {
                    Product p = (Product) j.next();
                    p.setProductReferences(fmgrClient.getProductReferences(p));
                    Metadata met = fmgrClient.getMetadata(p);
                    Reference r = ((Reference) p.getProductReferences().get(0));
                    String newLocPath = PathUtils.replaceEnvVariables(
                            this.pathSpec, met);

                    LOG.log(Level.INFO, "Moving product: ["
                            + p.getProductName() + "] from: ["
                            + new File(new URI(r.getDataStoreReference()))
                            + "] to: [" + newLocPath + "]");
                    long timeBefore = System.currentTimeMillis();
                    fmgrClient.moveProduct(p, newLocPath);
                    long timeAfter = System.currentTimeMillis();
                    double seconds = ((timeAfter - timeBefore) * 1.0) / (1000.0);
View Full Code Here

        double pct = transferStatusTracker.getPctTransferred(product);
        return pct;
    }

    public double getRefPctTransferred(Hashtable<String, Object> refHash) {
        Reference reference = XmlRpcStructFactory
                .getReferenceFromXmlRpc(refHash);
        double pct = 0.0;

        try {
            pct = transferStatusTracker.getPctTransferred(reference);
        } catch (Exception e) {
            e.printStackTrace();
            LOG.log(Level.WARNING,
                    "Exception getting transfer percentage for ref: ["
                            + reference.getOrigReference() + "]: Message: "
                            + e.getMessage());
        }
        return pct;
    }
View Full Code Here

                        "Flat products must have a single reference: cannot move");
            }

            // okay, it's fine to move it
            // first, we need to update the data store ref
            Reference r = (Reference) p.getProductReferences().get(0);
            if (r.getDataStoreReference().equals(
                    new File(newPath).toURI().toString())) {
                throw new DataTransferException("cannot move product: ["
                        + p.getProductName() + "] to same location: ["
                        + r.getDataStoreReference() + "]");
            }

            // create a copy of the current data store path: we'll need it to
            // do the data transfer
            Reference copyRef = new Reference(r);

            // update the copyRef to have the data store ref as the orig ref
            // the the newLoc as the new ref
            copyRef.setOrigReference(r.getDataStoreReference());
            copyRef.setDataStoreReference(new File(newPath).toURI().toString());

            p.getProductReferences().clear();
            p.getProductReferences().add(copyRef);

            // now transfer it
            try {
                this.dataTransfer.transferProduct(p);
            } catch (IOException e) {
                throw new DataTransferException(e.getMessage());
            }

            // now delete the original copy
            try {
                if (!new File(new URI(copyRef.getOrigReference())).delete()) {
                    LOG.log(Level.WARNING, "Deletion of original file: ["
                            + r.getDataStoreReference()
                            + "] on product move returned false");
                }
            } catch (URISyntaxException e) {
View Full Code Here

            if ((origRefs.length == dataStoreRefs.length)
                    && (origRefs.length == refLengths.length)) {
                List<Reference> references = new Vector<Reference>();
                for (int i = 0; i < origRefs.length; i++) {
                    Reference r = new Reference();
                    r.setOrigReference(origRefs[i]);
                    r.setDataStoreReference(dataStoreRefs[i]);
                    r.setFileSize((Long.parseLong(refLengths[i])));
                    if (refMimeTypes != null)
                        r.setMimeType(refMimeTypes[i]);
                    references.add(r);
                }

                product.setProductReferences(references);
            } else {
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.