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


      // Add all of the product's references to the zip file.
      // Assumes that for hierarchical products, the first reference is the root
      // directory and all of its contents are included in the product.
      List<Reference> references = resource.getProductReferences();
      Reference rootReference = references.get(0);
      File rootFile = new File(new URI(rootReference.getDataStoreReference()));
      if (rootFile.isDirectory())
      {
        // Add the directory and all of its contents.
        zipFile.addFolder(rootFile, parameters);
      }
View Full Code Here

         * org.apache.wicket.markup.html.list.ListView#populateItem(org.apache
         * .wicket.markup.html.list.ListItem)
         */
        @Override
        protected void populateItem(ListItem<Reference> refItem) {
          Reference r = refItem.getModelObject();
          String filePath = null;
          try {
            filePath = new File(new URI(r.getDataStoreReference()))
                .getAbsolutePath();
          } catch (Exception ignore) {
          }
         
          ExternalLink refLink = new ExternalLink("ref_file_path_link",
              "/" + app.getRootContext() + "/data?productID="+productId);
          refLink.add(new Label("ref_file_path", filePath));
          refItem.add(refLink);
          refItem.add(new Label("ref_file_size",
              String.valueOf(r.getFileSize())));
          try {
            refItem.add(new Label("ref_pct_transferred", NumberFormat
                .getPercentInstance()
                .format(fm.getFm().getRefPctTransferred(r))));
          } catch (DataTransferException e) {
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,
View Full Code Here

  {
    String productId = "123";
    int refIndex = 0;

    // Create a new ReferenceResource using a Reference instance.
    Reference reference = new Reference("original", "dataStore", 1000,
      new MimeTypes().forName("text/plain"));

    ReferenceResource resource = new ReferenceResource(productId, refIndex,
      reference, new File("/tmp"));


    // Generate the expected output.
    String expectedXml =
        "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"
      + "<reference>"
      + "<productId>" + productId + "</productId>"
      + "<refIndex>" + refIndex + "</refIndex>"
      + "<dataStoreReference>"
      +    reference.getDataStoreReference()
      + "</dataStoreReference>"
      + "<originalReference>"
      +    reference.getOrigReference()
      + "</originalReference>"
      + "<mimeType>" + reference.getMimeType().getName() + "</mimeType>"
      + "<fileSize>" + reference.getFileSize() "</fileSize>"
      + "</reference>";


    // Set up a JAXB context and marshall the ReferenceResource to XML.
    JAXBContext context = JAXBContext.newInstance(resource.getClass());
View Full Code Here

    Hashtable metadataEntries = new Hashtable<String, Object>();
    metadataEntries.put("CAS.Test", "test value");
    Metadata metadata = new Metadata();
    metadata.addMetadata(metadataEntries);

    Reference reference = new Reference("original", "dataStore", 1000,
      new MimeTypes().forName("text/plain"));
    List<Reference> references = new ArrayList<Reference>();
    references.add(reference);

    ProductType productType = new ProductType("1", "GenericFile", "test type",
      "repository", "versioner");

    Product product = new Product();
    product.setProductId("123");
    product.setProductName("test.txt");
    product.setProductStructure("flat");
    product.setProductType(productType);

    ProductResource resource = new ProductResource(product, metadata,
      references, new File("/tmp"));


    // Generate the expected output.
    String expectedXml =
        "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"
        + "<product>"
        + "<id>" + product.getProductId() + "</id>"
        + "<name>" + product.getProductName() + "</name>"
        + "<structure>" + product.getProductStructure() + "</structure>"
        + "<type>" + productType.getName() + "</type>"
        + "<metadata>"
        + "<keyval>"
        + "<key>" + metadata.getAllKeys().get(0) + "</key>"
        + "<val>" + metadata.getAllValues().get(0) + "</val>"
        + "</keyval>"
        + "</metadata>"
        + "<references>"
        + "<reference>"
        + "<productId>" + product.getProductId() + "</productId>"
        + "<refIndex>0</refIndex>"
        + "<dataStoreReference>"
        +    reference.getDataStoreReference()
        + "</dataStoreReference>"
        + "<originalReference>"
        +    reference.getOrigReference()
        + "</originalReference>"
        + "<mimeType>" + reference.getMimeType().getName() + "</mimeType>"
        + "<fileSize>" + reference.getFileSize() + "</fileSize>"
        + "</reference>"
        + "</references>"
        + "</product>";

View Full Code Here

    Product product = new Product();
    product.setProductId("TestProductId");
    product.setProductName("TestProductName");
    product.setProductReferences(Lists.newArrayList(
      new Reference("file:///orig/data/", "file://" + cwd + "/src/testdata/data/", 4096),
      new Reference("file:///orig/data/test-file-1.txt", "file://" + cwd + "/src/testdata/data/test-file-1.txt", 20),
      new Reference("file:///orig/data/test-file-2.txt", "file://" + cwd + "/src/testdata/data/test-file-2.txt", 20),
      new Reference("file:///orig/data/test-file-3.txt", "file://" + cwd + "/src/testdata/data/test-file-3.txt", 20)));
    product.setProductStructure(Product.STRUCTURE_HIERARCHICAL);
    product.setTransferStatus(Product.STATUS_RECEIVED);
    ProductType pt = new ProductType();
    pt.setName("TestProductType");
View Full Code Here

    // Create a ProductType.
    ProductType productType = new ProductType("1", "GenericFile", "test type",
      "repository", "versioner");

    // Create a ProductResource using Reference, Metadata and Product instances.
    Reference reference1 = new Reference("original1", "dataStore1", 500,
      new MimeTypes().forName("text/plain"));
    List<Reference> references1 = new ArrayList<Reference>();
    references1.add(reference1);

    Hashtable metadataEntries1 = new Hashtable<String, Object>();
    metadataEntries1.put("product1_meta", "test1");
    Metadata metadata1 = new Metadata();
    metadata1.addMetadata(metadataEntries1);

    Product product1 = new Product();
    product1.setProductId("123");
    product1.setProductName("test.txt");
    product1.setProductType(productType);

    ProductResource productResource1 = new ProductResource(product1, metadata1,
      references1, new File("/tmp"));


    // Create another ProductResource using Reference, Metadata and Product
    // instances.
    Reference reference2 = new Reference("original2", "dataStore2", 1000,
      new MimeTypes().forName("application/pdf"));
    List<Reference> references2 = new ArrayList<Reference>();
    references2.add(reference2);

    Hashtable metadataEntries2 = new Hashtable<String, Object>();
    metadataEntries2.put("product2_meta", "test2");
    Metadata metadata2 = new Metadata();
    metadata2.addMetadata(metadataEntries2);

    Product product2 = new Product();
    product2.setProductId("456");
    product2.setProductName("test2.txt");
    product2.setProductType(productType);

    ProductResource productResource2 = new ProductResource(product2, metadata2,
      references2, new File("/tmp"));

    // Create a DatasetResource using ProductType, Metadata and ProductResource
    // instances.
    Hashtable metadataEntries3 = new Hashtable<String, Object>();
    metadataEntries3.put("dataset_meta", "test3");
    Metadata metadata3 = new Metadata();
    metadata3.addMetadata(metadataEntries3);

    DatasetResource resource = new DatasetResource(
      productType.getProductTypeId(), productType.getName(), metadata3,
      new File("/tmp"));
    resource.addProductResource(productResource1);
    resource.addProductResource(productResource2);


    // Generate the expected output.
    String expectedXml =
        "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"
      + "<dataset>"
      +   "<id>" + productType.getProductTypeId() + "</id>"
      +   "<name>" + productType.getName() + "</name>"
      +   "<metadata>"
      +     "<keyval>"
      +       "<key>" + metadata3.getAllKeys().get(0) + "</key>"
      +       "<val>" + metadata3.getAllValues().get(0) + "</val>"
      +     "</keyval>"
      +   "</metadata>"
      +   "<products>"
      +     "<product>"
      +       "<id>" + product1.getProductId() + "</id>"
      +       "<name>" + product1.getProductName() + "</name>"
      +       "<type>" + productType.getName() + "</type>"
      +       "<metadata>"
      +         "<keyval>"
      +           "<key>" + metadata1.getAllKeys().get(0) + "</key>"
      +           "<val>" + metadata1.getAllValues().get(0) + "</val>"
      +         "</keyval>"
      +       "</metadata>"
      +       "<references>"
      +         "<reference>"
      +           "<productId>" + product1.getProductId() + "</productId>"
      +           "<refIndex>0</refIndex>"
      +           "<dataStoreReference>"
      +              reference1.getDataStoreReference()
      +           "</dataStoreReference>"
      +           "<originalReference>"
      +              reference1.getOrigReference()
      +           "</originalReference>"
      +           "<mimeType>"
      +              reference1.getMimeType().getName()
      +           "</mimeType>"
      +           "<fileSize>" + reference1.getFileSize() + "</fileSize>"
      +         "</reference>"
      +       "</references>"
      +     "</product>"
      +     "<product>"
      +       "<id>" + product2.getProductId() + "</id>"
      +       "<name>" + product2.getProductName() + "</name>"
      +       "<type>" + productType.getName() + "</type>"
      +       "<metadata>"
      +         "<keyval>"
      +           "<key>" + metadata2.getAllKeys().get(0) + "</key>"
      +           "<val>" + metadata2.getAllValues().get(0) + "</val>"
      +         "</keyval>"
      +       "</metadata>"
      +       "<references>"
      +         "<reference>"
      +           "<productId>" + product2.getProductId() + "</productId>"
      +           "<refIndex>0</refIndex>"
      +           "<dataStoreReference>"
      +              reference2.getDataStoreReference()
      +           "</dataStoreReference>"
      +           "<originalReference>"
      +              reference2.getOrigReference()
      +           "</originalReference>"
      +           "<mimeType>"
      +              reference2.getMimeType().getName()
      +           "</mimeType>"
      +           "<fileSize>" + reference2.getFileSize() + "</fileSize>"
      +         "</reference>"
      +       "</references>"
      +     "</product>"
      +   "</products>"
      + "</dataset>";
View Full Code Here

    Hashtable metadataEntries1 = new Hashtable<String, Object>();
    metadataEntries1.put("CAS.ProductReceivedTime", "2013-09-12T16:25:50.662Z");
    Metadata metadata1 = new Metadata();
    metadata1.addMetadata(metadataEntries1);

    Reference reference1 = new Reference("original1", "dataStore1", 1000,
      new MimeTypes().forName("text/plain"));

    ProductType productType1 = new ProductType("1", "TestType", "test type 1",
      "repository1", "versioner1");

    Product product1 = new Product();
    product1.setProductId("123");
    product1.setProductName("test product");
    product1.setProductStructure("flat");
    product1.setProductType(productType1);

    FileTransferStatus status1 = new FileTransferStatus(reference1, 1000, 100,
      product1);


    // Create another FileTransferStatus instance using Metadata, Reference,
    // ProductType and Product instances.
    Hashtable metadataEntries2 = new Hashtable<String, Object>();
    metadataEntries2.put("CAS.ProductReceivedTime", "2011-04-11T11:59:59.662Z");
    Metadata metadata2 = new Metadata();
    metadata2.addMetadata(metadataEntries2);

    Reference reference2 = new Reference("original2", "dataStore2", 500,
      new MimeTypes().forName("application/pdf"));

    ProductType productType2 = new ProductType("2", "TestType2", "test type 2",
        "repository2", "versioner2");

    Product product2 = new Product();
    product2.setProductId("456");
    product2.setProductName("test product 2");
    product2.setProductStructure("hierarchical");
    product2.setProductType(productType2);

    FileTransferStatus status2 = new FileTransferStatus(reference2, 500, 200,
      product2);


    // Create a TransfersResource using the two FileTransferStatus instances to
    // generate TransferResource instances for the TransfersResource.
    List<TransferResource> resources = new ArrayList<TransferResource>();
    resources.add(new TransferResource(product1, metadata1, status1));
    resources.add(new TransferResource(product2, metadata2, status2));
    TransfersResource resource = new TransfersResource("ALL", resources);

    // Generate the expected output.
    String expectedXml =
      "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"
      + "<transfers productId=\"ALL\">"
      + "<transfer>"
      + "<productName>" + product1.getProductName() + "</productName>"
      + "<productId>" + product1.getProductId() + "</productId>"
      + "<productTypeName>" + productType1.getName() + "</productTypeName>"
      + "<dataStoreReference>"
      +    reference1.getDataStoreReference()
      + "</dataStoreReference>"
      + "<origReference>" + reference1.getOrigReference() + "</origReference>"
      + "<mimeType>" + reference1.getMimeType().getName() + "</mimeType>"
      + "<fileSize>" + reference1.getFileSize() + "</fileSize>"
      + "<totalBytes>" + reference1.getFileSize() + "</totalBytes>"
      + "<bytesTransferred>"
      +    status1.getBytesTransferred()
      + "</bytesTransferred>"
      + "<percentComplete>"
      +    status1.computePctTransferred() * 100
      + "</percentComplete>"
      + "<productReceivedTime>"
      +    metadata1.getAllValues().get(0)
      + "</productReceivedTime>"
      + "</transfer>"
      + "<transfer>"
      + "<productName>" + product2.getProductName() + "</productName>"
      + "<productId>" + product2.getProductId() + "</productId>"
      + "<productTypeName>" + productType2.getName() + "</productTypeName>"
      + "<dataStoreReference>"
      +    reference2.getDataStoreReference()
      + "</dataStoreReference>"
      + "<origReference>" + reference2.getOrigReference() + "</origReference>"
      + "<mimeType>" + reference2.getMimeType().getName() + "</mimeType>"
      + "<fileSize>" + reference2.getFileSize() + "</fileSize>"
      + "<totalBytes>" + reference2.getFileSize() + "</totalBytes>"
      + "<bytesTransferred>"
      +    status2.getBytesTransferred()
      + "</bytesTransferred>"
      + "<percentComplete>"
      +    status2.computePctTransferred() * 100
 
View Full Code Here

    Hashtable metadataEntries = new Hashtable<String, Object>();
    metadataEntries.put("CAS.ProductReceivedTime", "2013-09-12T16:25:50.662Z");
    Metadata metadata = new Metadata();
    metadata.addMetadata(metadataEntries);

    Reference reference = new Reference("original", "dataStore", 1000,
      new MimeTypes().forName("text/plain"));

    ProductType productType = new ProductType("1", "GenericFile", "test type",
      "repository", "versioner");

    Product product = new Product();
    product.setProductId("123");
    product.setProductName("test product");
    product.setProductStructure("flat");
    product.setProductType(productType);

    FileTransferStatus status = new FileTransferStatus(reference, 1000, 100,
      product);

    TransferResource resource = new TransferResource(product, metadata, status);


    // Generate the expected output.
    String expectedXml =
      "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"
      + "<transfer>"
      + "<productName>" + product.getProductName() + "</productName>"
      + "<productId>" + product.getProductId() + "</productId>"
      + "<productTypeName>" + productType.getName() + "</productTypeName>"
      + "<dataStoreReference>"
      +   reference.getDataStoreReference()
      + "</dataStoreReference>"
      + "<origReference>"
      +   reference.getOrigReference()
      + "</origReference>"
      + "<mimeType>" + reference.getMimeType().getName() + "</mimeType>"
      + "<fileSize>" + reference.getFileSize() + "</fileSize>"
      + "<totalBytes>" + reference.getFileSize() + "</totalBytes>"
      + "<bytesTransferred>"
      +    status.getBytesTransferred()
      + "</bytesTransferred>"
      + "<percentComplete>"
      +    status.computePctTransferred() * 100
 
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.