Package eu.planets_project.services.datatypes

Examples of eu.planets_project.services.datatypes.DigitalObject


        //run identification service one
        String[] sTypes1 = runIdentification1(dgo,wfResult);
         log.debug("ran execute(): identification1: identified #"+ sTypes1.length+ "of types, using first one as migrate_from input");
       
        //call a migration service - and use output of service1 as input
        DigitalObject migDigO =  runMigrationService(dgo,sTypes1[0],wfResult);
         log.debug("ran execute(): migration1 for digitalObject");
       
        //Call identification service2 on the migration services output.
        String[] sTypes2 = runIdentification2(migDigO, wfResult);
         log.debug("ran execute(): identification2: identified #"+ sTypes2.length+ "of types, checking if the expected one is contained");
View Full Code Here


        /* Create the content: */
    System.out.println("Creating DigitalObjectContent c1");
        DigitalObjectContent c1 = Content.byReference(purl.toURL().openStream());
    System.out.println("Creating DigitalObject object");
        /* Given these, we can instantiate our object: */
        DigitalObject object = new DigitalObject.Builder(c1).permanentUri(purl).title(purl.toString()).build();
      // Check digital object. Title should not be null
    System.out.println("Setting store flag to true");
        boolean storeFlag = true;
        // Now store it
        URI pdURI = null;
        try {
        System.out.println("calling this.dom.storeAsNew(object)");
            pdURI = DigitalObjectManagerTests.dom.storeAsNew(object);
            System.out.println("StoreAsNew returned the URI:" + pdURI);
        } catch (Exception e) {
        System.out.println("Caught an exception in storeAsNew, here's the details");
          e.printStackTrace();
        System.out.println("Asserting it's a not stored exception");
          assertTrue("Expecting exception to be DigitalObjectNotStoredException", e.getClass().equals(DigitalObjectNotStoredException.class));
        System.out.println("Setting storeFlag to false");
          storeFlag = false;
        } catch (Throwable t) {
        System.out.println("Caught a throwable in storeAsNew, here's the details");
          t.printStackTrace();
        System.out.println("Setting storeFlag to false");
          storeFlag = false;
        }
       
    System.out.println("Creating new version of object");
        object = new DigitalObject.Builder(object.getContent()).title("mytitle").build();
    System.out.println("asserting the title is not null");
        assertNotNull("NOT expecting object.getTitle() to be null", object.getTitle());
       
        if (storeFlag)
        {
          DigitalObject retObject = null;
      // Then retrieve it and check it's the same
        System.out.println("now retrieving object to test (ret object)");
      System.out.println("Retrieving the test object using URI:" + pdURI);
      try {
        retObject = DigitalObjectManagerTests.dom.retrieve(pdURI);
      } catch (DigitalObjectNotFoundException e) {
        e.printStackTrace();
        throw e;
      } catch (Exception e) {
        System.out.println("Caught unexpected exception calling retrieve()");
        e.printStackTrace();
        fail("this.dom.retrive failed with an unexpected exception");
      }
      System.out.println("Creating new Purl");
      URI newPurl = new File(AllStorageSuite.TEST_DATA_BASE, FILE).toURI();
      System.out.println("Creating digital object c2");
      DigitalObjectContent c2 = Content.byReference(newPurl.toURL().openStream());
      System.out.println("Creating new Expected object");
      DigitalObject expectedObject = new DigitalObject.Builder(c2).build();
     
      // Check that retObject is not null
      assertNotNull("Not expecting returned object to be null", retObject);
     
      System.out.println("Trying content match between expectedObject and retobject");
      // Only test if retObject is not null, this can't happen because of a previous assert
      if (retObject != null) {
              assertEquals("Retrieve Digital Object content (" +
                  expectedObject.getContent() +
                  ") doesn't match that stored (" + retObject.getContent() +
                  ")", expectedObject.getContent(),
                      retObject.getContent());
      }
      // We can test that the list method works properly now also
      // Get the root URI
      System.out.println("trying list out");
View Full Code Here

          parameterList = this.getServiceCallConfigs(identify1).getAllPropertiesAsParameters();
        }else{
          parameterList = new ArrayList<Parameter>();
        }
       
        DigitalObject digo = this.getDataRegistry().retrieve(digoRef);
         
        IdentifyResult results = identify1.identify(digo,parameterList);
        ServiceReport report = results.getReport();
        List<URI> types = results.getTypes();
       
View Full Code Here

      //document
      wfResultItem.setServiceParameters(configProperties);
      wfResultItem.setStartTime(System.currentTimeMillis());
          wfResultItem.setServiceEndpoint(comparexcdl1.describe().getEndpoint());
         
          DigitalObject digo1 = this.getDataRegistry().retrieve(digo1Ref);
          DigitalObject digo2 = this.getDataRegistry().retrieve(digo2Ref);
     
          //call the comparison service
      CompareResult result = comparexcdl1.compare(digo1, digo2,
          configProperties);
       
View Full Code Here

      FileUtils.forceMkdir(work_folder);
  }
 
  @Test
    public void toFileDigitalObjectFile() throws IOException {
        DigitalObject object = new DigitalObject.Builder(Content.byReference(testZip)).build();
        File file = File.createTempFile("planets", null);
        DigitalObjectUtils.toFile(object, file);
        Assert.assertTrue(IOUtils.contentEquals(object.getContent().getInputStream(), file.toURI()
                .toURL().openStream()));
    }
View Full Code Here

                .toURL().openStream()));
    }
   
    @Test
    public void toFileDigitalObject() throws MalformedURLException, IOException {
        DigitalObject object = new DigitalObject.Builder(Content.byReference(testZip)).build();
        File file = DigitalObjectUtils.toFile(object);
        Assert.assertTrue(IOUtils.contentEquals(object.getContent().getInputStream(), file.toURI()
                .toURL().openStream()));
    }
View Full Code Here

        out.close();
       
        //3. build the digo by reference
        URI httpRef = this.getHttpFileRef(fOut);
        DigitalObjectContent content = Content.byReference(httpRef.toURL());
        DigitalObject ret = new DigitalObject.Builder(digo).content(content).permanentUri(digo.getPermanentUri()).build();
        return ret;
    }
View Full Code Here

    }
 
  @Test
  public void testCreateZipTypeDigObFolder() {
    printTestTitle("Test createZipTypeDigOb() from FOLDER");
    DigitalObject result = DigitalObjectUtils.createZipTypeDigitalObject(testFolder, testFolder.getName(), true, false, true);
   
    assertTrue("DigitalObject should NOT be NULL!", result!=null);
    printDigOb(result);
    File resultFile = new File(work_folder, result.getTitle());
    DigitalObjectUtils.toFile(result, resultFile);
    System.out.println("Result size: " + resultFile.length());
  }
View Full Code Here

  }
 
  @Test
  public void testCreateZipTypeDigObZip() {
    printTestTitle("Test createZipTypeDigOb() from ZIP file");
    DigitalObject result = DigitalObjectUtils.createZipTypeDigitalObject(testZip, testFolder.getName(), true, false, true);
    assertTrue("DigitalObject should NOT be NULL!", result!=null);
    printDigOb(result);
  }
View Full Code Here

  }
 
  @Test
  public void testGetFragmentFromZipTypeDigitalObject() {
    printTestTitle("Test getFragmentFromZipTypeDigitalObject()");
    DigitalObject result = DigitalObjectUtils.createZipTypeDigitalObject(testFolder, "getFragmentTest.zip", false, false, true);
    List<String> fragments = result.getFragments();
    DigitalObject fragmentDigOb = null;
    Random random = new Random();
    int index = random.nextInt(fragments.size());
    System.err.println("Getting file: " + fragments.get(index));
    fragmentDigOb = DigitalObjectUtils.getFragment(result, fragments.get(index), false);
    printDigOb(fragmentDigOb);
View Full Code Here

TOP

Related Classes of eu.planets_project.services.datatypes.DigitalObject

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.