Package eu.planets_project.services.datatypes

Examples of eu.planets_project.services.datatypes.DigitalObject


   *        This is a format identified by identification service
   * @return changed digital object with new content value
   */
  public static DigitalObject addEvent(DigitalObject digitalObject, Event newEvent)
    {
    DigitalObject res = null;
   
      if (digitalObject != null && newEvent != null)
      {
        DigitalObject.Builder b = new DigitalObject.Builder(digitalObject.getContent());
        if (digitalObject.getTitle() != null) b.title(digitalObject.getTitle());
View Full Code Here


   *        This is a new digital object metadata object
   * @return changed digital object with new metadata list value
   */
  public static DigitalObject addMetadata(DigitalObject digitalObject, Metadata newMetadata)
    {
    DigitalObject res = null;
   
      if (digitalObject != null && newMetadata != null)
      {
        DigitalObject.Builder b = new DigitalObject.Builder(digitalObject.getContent());
        if (digitalObject.getTitle() != null) b.title(digitalObject.getTitle());
View Full Code Here

      wfResultItem.setServiceEndpoint(new URL(endpoint));
    }
    wfResultItem.setStartTime(System.currentTimeMillis());
   
    //resolve the digital Object reference
    DigitalObject digo = this.retrieveDigitalObjectDataRegistryRef(digoRef);
   
    //call the identification service
    IdentifyResult identifyResults = identifyService.identify(digo,parameterList);
   
    // document
    wfResultItem.setEndTime(System.currentTimeMillis());
    ServiceReport report = identifyResults.getReport();
    // report service status and type
    wfResultItem.setServiceReport(report);
    if (report.getType() == Type.ERROR) {
      String s = "Service execution failed: " + report.getMessage();
      wfResultItem.addLogInfo(s);
      throw new Exception(s);
    }
   
    //document the comparison's output
    URI ret = null;
    if((identifyResults.getTypes()!=null)&&(identifyResults.getTypes().size()>0)){
      wfResultItem.addLogInfo("identifying properties of object: "+digo.getPermanentUri());
      for(URI uri : identifyResults.getTypes()){
        if(ret == null){
          ret = uri;
        }
        String extractedInfo = "[uri: "+uri+"] \n";
View Full Code Here

          java.lang.String.class);
      if (endpoint != null) {
        wfResultItem.setServiceEndpoint(new URL(endpoint));
      }
         
          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

          // Special treatment for digital object presentation
          if (dom != null) {
            try {
//              log.log(Level.INFO, "StorageDigitalObjectReference getLeafname() dom != null, puri: " + puri);
              if (puri.toString().contains(DOJCRConstants.DOJCR)) {
              DigitalObject obj = dom.getDigitalObjectManager(
                  DataRegistryFactory.createDataRegistryIdFromName(DOJCRConstants.REGISTRY_NAME)).retrieve(puri);   
                if (obj.getTitle() != null) {
                  String title = obj.getTitle();
                  path = path.concat("_" + title);
                }
              }
            } catch (Exception e) {
              log.log(Level.INFO,
View Full Code Here

        try {
            DataRegistry dataRegistry = DataRegistryFactory.getDataRegistry();
          URI baseUri = new PDURI(dgoBRef.normalize()).formDataRegistryRootURI();
          wfResultItem.addLogInfo("base URI " + baseUri);
     
          DigitalObject obj = dataRegistry.getDigitalObjectManager(baseUri).retrieve(dgoBRef);   
          wfResultItem.addLogInfo("obj: " + obj.toString());

          InputStream contentStream = obj.getContent().getInputStream();             
              BufferedReader br = new BufferedReader(new InputStreamReader(contentStream));
              StringBuilder sb = new StringBuilder();
              String line = null;
   
              while ((line = br.readLine()) != null) {
                sb.append(line + "\n");
              }
   
              br.close();
            migratedFileName = dgoA.getPermanentUri().toString().substring(
                dgoA.getPermanentUri().toString().lastIndexOf(URI_SEPARATOR) + 1 );
            migratedFileSize = Integer.toString(sb.toString().length());
        } catch (Exception e) {
          wfResultItem.addLogInfo("migration error: " + e.getMessage());
        }
      }
     
      // Insert in JCR repository
            wfResultItem.addLogInfo("STEP 4: Insert in JCR repository. initial digital object: " + dgoA.toString());
            // Manage the Digital Object Data Registry:
            wfResultItem.addLogInfo("Initialize JCR repository instance.");
            JcrDigitalObjectManagerImpl dodm =
               (JcrDigitalObjectManagerImpl) JcrDigitalObjectManagerImpl.getInstance();
            DigitalObject dgoB = dodm.store(PERMANENT_URI_PATH, dgoA, true);
           wfResultItem.addLogInfo("Completed storing in JCR repository: " + dgoB.toString());
          
          wfResultItem.addLogInfo(new Message("JCRinsert", new Parameter("Digital Object", dgoB.getTitle()), new Parameter(
                    "Result", dgoB.getPermanentUri().toString())));

           // Enrich digital object with format information from identification service
           if (types != null) {
             wfResultItem.addLogInfo("Identified formats count: " + types.length);
        for (int i=0; i<types.length; i++) {
          wfResultItem.addLogInfo("type[" + i + "]: " + types[i]);
        }     

        if (types[0] != null) {
            List<Property> pList = new ArrayList<Property>();
            Property pIdentificationContent = new Property.Builder(URI.create("Identify"))
                  .name("content by reference")
                  .value(types[0].toString())
                  .description("This is a format for initial document identified by identification service")
                  .unit("URI")
                  .type("digital object format")
                  .build();
            pList.add(pIdentificationContent);
            Event eIdentifyFormat = new Event(
                IDENTIFICATION_EVENT, System.currentTimeMillis() + "", new Double(DURATION),
                new Agent("http://testbed-dev.planets-project.ait.ac.at:80/pserv-pc-droid/Droid?wsdl"
                    , identify.NAME, identify.QNAME.toString()),
                pList);
          dgoB = addEvent(dgoB, eIdentifyFormat, URI.create(types[0]));
         
          List<Property> pMigrationList = new ArrayList<Property>();
          Property pMigrationContent = new Property.Builder(URI.create("Migrate"))
                .name("content by reference")
                .value(types[0].toString())
                .description("This is a migration event")
                .unit("URI")
                .type("digital object format")
                .build();
          pMigrationList.add(pMigrationContent);
            Event eMigration = new Event(
                MIGRATION_EVENT, System.currentTimeMillis() + "", new Double(DURATION),
                new Agent(migrationEndpoint, migrate.NAME, migrate.QNAME.toString()),
                pMigrationList);
          dgoB = addEvent(dgoB, eMigration, null);
         
               // add create SIP event
          List<Property> pSipList = new ArrayList<Property>();
          Property pSipContent = new Property.Builder(URI.create("CreateSIP"))
                .name("SIP message")
                .value(types[0].toString())
                .description("This is a SIP message creation")
                .unit("file")
                .type("ZIP format")
                .build();
          pSipList.add(pSipContent);
          Event eSip = new Event(
              SIP_CREATION_EVENT, System.currentTimeMillis() + "", new Double(DURATION),
              new Agent("ZIP file", "The SIP message creation", "ZIP"),
              pSipList);
          dgoB = addEvent(dgoB, eSip, null);         
             }
           }
          
      // Update digital object in JCR repository
            wfResultItem.addLogInfo("STEP 5: Update digital object in JCR repository. initial digital object: " +
                dgoB.toString());
           dgoB = dodm.updateDigitalObject(dgoB, false);
           wfResultItem.addLogInfo("Completed update in JCR repository. result digital object: " + dgoB.toString());
           
            // Create SIP message (ZIP archive) and send it back to the initial repository
            wfResultItem.addLogInfo(
                "STEP 6: Send enriched digital object back to the initial repository as SIP. Create ZIP archive.");           
        List<String> filenames = new ArrayList<String>();
      String parentDir = "OriginalEpublication";
      String strHeaderDirectory = "";
      String strContentDirectory = parentDir + "/content";
      createDirectories(strHeaderDirectory);
      createDirectories(strContentDirectory);
           wfResultItem.addLogInfo("before resHeader");
           String resHeader = createMetadataXml(strHeaderDirectory, types[0]
                                                , migratedFileName, migratedFileSize);
           if (resHeader != null) {
               wfResultItem.addLogInfo("resHeader != null: " + resHeader);
             filenames.add(resHeader);
           }
           wfResultItem.addLogInfo("after resHeader");
          
           // add file to SIP content
      try {
        String resContent = addFileToZipContent(strContentDirectory, dgoB.getContent().getInputStream());
             wfResultItem.addLogInfo("add file to SIP content");
             if (resContent != null) {
               filenames.add(resContent);
             }
      } catch (Exception e) {
View Full Code Here

   *        This is a format identified by identification service
   * @return changed digital object with new event value
   */
  public static DigitalObject addEvent(DigitalObject digitalObject, Event newEvent, URI identifiedFormat)
    {
    DigitalObject res = null;
   
      if (digitalObject != null && newEvent != null)
      {
        DigitalObject.Builder b = new DigitalObject.Builder(digitalObject.getContent());
        if (digitalObject.getTitle() != null) b.title(digitalObject.getTitle());
View Full Code Here

   *        This is a new digital object metadata object
   * @return changed digital object with new metadata list value
   */
  public static DigitalObject addMetadata(DigitalObject digitalObject, Metadata newMetadata)
    {
    DigitalObject res = null;
   
      if (digitalObject != null && newMetadata != null)
      {
        DigitalObject.Builder b = new DigitalObject.Builder(digitalObject.getContent());
        if (digitalObject.getTitle() != null) b.title(digitalObject.getTitle());
View Full Code Here

                     .events(eventList)
                     .build();

               
        wfResultItem.addLogInfo("****** Store DO in JCR. " + dgo.toString());
              DigitalObject resultDO = dodm.store(PERMANENT_URI_PATH, dgo, true);
              DigitalObject resultDO2 = dodm.store(PERMANENT_URI_PATH_2, dgo, true);
              DigitalObject resultDO3 = dodm.store(PERMANENT_URI_PATH_3, dgo, true);
              URI permanentUri = resultDO.getPermanentUri();
              URI permanentUri2 = resultDO2.getPermanentUri();
              URI permanentUri3 = resultDO3.getPermanentUri();
              wfResultItem.addLogInfo("Store DO in JCR res: " + permanentUri.toString());
                wfResultItem.addLogInfo("Store DO2 in JCR res: " + permanentUri2.toString());
                wfResultItem.addLogInfo("Store DO3 in JCR res: " + permanentUri3.toString());
              DigitalObject tmpDO = dodm.retrieve(permanentUri, true);
              wfResultItem.addLogInfo("result DO from JCR title: " + tmpDO.getTitle());
                wfResultItem.addLogInfo("result DO from JCR content length: " + tmpDO.getContent().length());
               
            DigitalObjectContent c2 = dodm.retrieveContent(permanentUri);
            wfResultItem.addLogInfo("retrieveContent result length: " + c2.length());

              tmpDO = dodm.retrieve(permanentUri, false);
              wfResultItem.addLogInfo("retrieve DO without content");
              if (tmpDO.getContent() != null)
              {
                wfResultItem.addLogInfo("result DO without content from JCR content length: " + tmpDO.getContent().length());
              }

                // Identify
              wfResultItem.addLogInfo("starting identify object: ");
                String[] types = runIdentification(dgo, wfResultItem);
View Full Code Here

                       
                        FormatRegistry fr = FormatRegistryFactory.getFormatRegistry();
                        //String ext = fr.getFirstExtension(new URI(types[0]));
                        log.info("Getting extension: " + ext);
                        if (ext != null) {
                            DigitalObject dgoOut = runMigrateService(dgo, fr.createExtensionUri(ext), wfResult);
                           
                            objects.add(dgoOut);
                            log.info(new Message("Migration", new Parameter("Input", ext), new Parameter("Result", dgo
                                    .getTitle())));
                        }
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.