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

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


            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 ("
                        + 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


                    + 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

        if (product != null && product.getProductReferences() != null
                && product.getProductReferences().size() > 0) {
            for (Iterator<Reference> i = product.getProductReferences()
                    .iterator(); i.hasNext();) {
                Reference r = i.next();
                query.getResults().add(toResult(r));
            }
        }

    }
View Full Code Here

  private void deliverProductFile(HttpServletRequest req,
      HttpServletResponse res, int index, String productID)
      throws CatalogException, IOException {
    Product product = client.getProductById(productID);
    List refs = client.getProductReferences(product);
    Reference ref = (Reference) refs.get(index);
    res.addHeader(CONTENT_LENGTH_HDR, String.valueOf(ref.getFileSize()));
    String contentType = (ref.getMimeType() != null
        && ref.getMimeType().getName() != null && !ref.getMimeType().getName()
        .equals("")) ? ref.getMimeType().getName() : DataUtils
        .guessTypeFromName(ref.getDataStoreReference());
    res.addHeader(CONTENT_TYPE_HDR, contentType);
    try {
      res.addHeader(CONTENT_DISPOSITION_HDR, "attachment; filename=\""
          + new File(new URI(ref.getDataStoreReference())).getName() + "\"");
    } catch (URISyntaxException e) {
      LOG.log(Level.WARNING,
          "Unable to sense filename from data store URI: Message: "
              + e.getMessage());
    }
    URL url = new URL(ref.getDataStoreReference());
    URLConnection c = url.openConnection();
    InputStream in = c.getInputStream();
    OutputStream out = res.getOutputStream();
    byte[] buf = new byte[512];
    int n;
View Full Code Here

            throws MetExtractionException {
        Metadata extractMet = new Metadata();
        merge(met, extractMet);

        if (product.getProductStructure().equals(Product.STRUCTURE_FLAT)) {
            Reference prodRef = (Reference) product.getProductReferences().get(
                    0);
            /*Reference mimeRef = new Reference(prodRef.getOrigReference(),
                    prodRef.getDataStoreReference(), prodRef.getFileSize());*/

            extractMet.addMetadata(MIME_TYPE, prodRef.getMimeType().getName());
            extractMet.addMetadata(MIME_TYPE, prodRef.getMimeType()
                    .getPrimaryType());
            extractMet.addMetadata(MIME_TYPE, prodRef.getMimeType()
                    .getSubType());
        }

        return extractMet;
    }
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(((Integer) referenceHash.get("fileSize"))
                .longValue());
        reference.setMimeType((String) referenceHash.get("mimeType"));
        return reference;
    }
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()));
        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

                            + 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

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.