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

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


   }

   @VisibleForTesting
   static Product createProduct(URI path) {
      Product product = new Product();
      Reference reference = new Reference();
      reference.setDataStoreReference(path.toString());
      product.setProductReferences(Lists.newArrayList(reference));
      return product;
   }
View Full Code Here


    // now get a reference to the zip file that we want to write
    ZipOutputStream out = new ZipOutputStream(new FileOutputStream(
        productZipFilePath));

    for (Iterator i = product.getProductReferences().iterator(); i.hasNext();) {
      Reference r = (Reference) i.next();

      try {
        File prodFile = new File(new URI(r.getDataStoreReference()));
        if (prodFile.isDirectory()) {
            LOG.log(Level.WARNING, "Data store reference is a directory. Not adding directory to the zip file: ["
                    + r.getDataStoreReference() + "]");
            continue;
        }
        String filename = prodFile.getName();
        FileInputStream in = new FileInputStream(prodFile.getAbsoluteFile());
        addZipEntryFromStream(in, out, filename);
        in.close();
      } catch (URISyntaxException e) {
        LOG.log(Level.WARNING, "Unable to get filename from uri: ["
            + r.getDataStoreReference() + "]");
      }

    }

    // add met file
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);
                   
                    if (locationsMatch(r.getDataStoreReference(), newLocPath)) {
                      LOG.log(Level.INFO, "Current and New locations match. "+p.getProductName()+" was not moved.");
                      continue;
                    }
                   
                    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

    }

    public static List<Reference> getReferencesFromXmlRpc(Vector<Hashtable<String, Object>> referenceVector) {
        List<Reference> references = new Vector<Reference>();
        for (Iterator<Hashtable<String, Object>> i = referenceVector.iterator(); i.hasNext();) {
            Reference r = getReferenceFromXmlRpc(i.next());
            references.add(r);
        }
        return references;
    }
View Full Code Here

                : reference.getMimeType().getName());
        return referenceHash;
    }

    public static Reference getReferenceFromXmlRpc(Hashtable<String, Object> referenceHash) {
        Reference reference = new Reference();
        reference.setDataStoreReference((String) referenceHash
                .get("dataStoreReference"));
        reference.setOrigReference((String) referenceHash.get("origReference"));
        reference.setFileSize(Long.parseLong(referenceHash.get("fileSize").toString()));
        reference.setMimeType((String) referenceHash.get("mimeType"));
        return reference;
    }
View Full Code Here

            conn.setAutoCommit(false);
            statement = conn.createStatement();

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

                String addRefSql = "INSERT INTO "
                        + productRefTable
                        + " "
                        + "(product_id, product_orig_reference, product_datastore_reference, product_reference_filesize, product_reference_mimetype) "
                        + "VALUES ("
                        + quoteIt(product.getProductId())
                        + ", '"
                        + r.getOrigReference()
                        + "', '"
                        + r.getDataStoreReference()
                        + "', "
                        + r.getFileSize()
                        + ",'"
                        + ((r.getMimeType() == null) ? "" : r.getMimeType()
                                .getName()) + "')";

                LOG.log(Level.FINE, "addProductReferences: Executing: "
                        + addRefSql);
                statement.execute(addRefSql);
View Full Code Here

                            + client.getFileManagerUrl() + "]: Message: "
                            + e.getMessage());
        }

        for (int i = 0; i < refs.size(); i++) {
            Reference ref = (Reference) refs.get(i);

            if (commit) {
                try {
                    client.removeFile(new File(new URI(ref
                            .getDataStoreReference())).getAbsolutePath());
                } catch (DataTransferException e) {
                    LOG.log(Level.WARNING, "Unable to delete reference : ["
                            + ref.getDataStoreReference() + "] for product : ["
                            + productId + "] from file manager : ["
                            + client.getFileManagerUrl() + "]: Message: "
                            + e.getMessage());
                } catch (URISyntaxException e) {
                    LOG.log(Level.WARNING,
                            "uri syntax exception getting file absolute path from URI: ["
                                    + ref.getDataStoreReference()
                                    + "]: Message: " + e.getMessage());
                }
            } else {
                LOG.log(Level.INFO, "Delete file: ["
                        + ref.getDataStoreReference() + "]");
            }

        }

        if (commit) {
View Full Code Here

                    + getProductRefSql);
            rs = statement.executeQuery(getProductRefSql);

            references = new Vector<Reference>();
            while (rs.next()) {
                Reference r = DbStructFactory.getReference(rs);
                references.add(r);
            }

        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

            statement.execute(deleteProductSql);

            // now add the new ones back in
            for (Iterator<Reference> i = product.getProductReferences().iterator(); i
                    .hasNext();) {
                Reference r = i.next();

                String addRefSql = "INSERT INTO "
                        + productRefTable
                        + " "
                        + "(product_id, product_orig_reference, product_datastore_reference, product_reference_filesize,"
                        + "product_reference_mimetype) " + "VALUES ("
                        + product.getProductId() + ", '" + r.getOrigReference()
                        + "', '" + r.getDataStoreReference() + "', "
                        + r.getFileSize() + ",'" + r.getMimeType().getName()
                        + "')";

                LOG.log(Level.FINE, "updateProductReferences: Executing: "
                        + addRefSql);
                statement.execute(addRefSql);
View Full Code Here

    }

    try
    {
      // Retrieve the reference file.
      Reference reference = resource.getReference();
      File refFile = new File(new URI(reference.getDataStoreReference()));
      if (!refFile.exists())
      {
        throw new BadRequestException("Unable to locate the source file for the"
          + " reference.");
      }
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.