Package eu.planets_project.services.datatypes

Examples of eu.planets_project.services.datatypes.DigitalObject$Adapter


       * @return Nodes filled with data
       * @return
       */
      public static TreeNode standardTraverseTree(
          TreeNode node, TreeNode _node, DataModelConfiguration currentConfiguration) {
             DigitalObject o = null;
             
             boolean proceedOk = true;
            
               if (_node != null) {
                  if (_node.getData() != null) {
            try {
                         URI uri = ((RegistryPropertyImpl)_node.getData()).getUri();
                       log.info("#### StorageBackingBean DoTreeView standardTraverseTree() uri: " + uri);
               o = dr.getDataManager(uri).retrieve(uri);
            } catch (Exception e) {
              log.info("StorageBackingBean DoTreeView standardTraverseTree() error: " + e.getMessage());
              proceedOk = false;
            }
                     if (o != null)
                     log.info("StorageBackingBean DoTreeView standardTraverseTree() digitalObject: " + o.toString());
                  }
               }

               if (o != null && proceedOk) {
                   log.info("StorageBackingBean DoTreeView standardTraverseTree() o != null currentConfiguration: " + currentConfiguration);
                 if (currentConfiguration.equals(DataModelConfiguration.PLANETS)) {
                    TreeNodeImpl childNode = new TreeNodeImpl();
                    childNode.setData(ModelConfiguration.DIGITAL_OBJECT_MODEL.name());
                    childNode.setParent(node);
                    node.removeChild(NODE_ID);
                    node.addChild(NODE_ID, childNode);
 
                    if (o.getTitle() != null) {
                      addNode(childNode, ModelConfiguration.DigitalObjectModel.TITLE.name(), o.getTitle());
                    }
                    if (o.getPermanentUri() != null) {
                      addNode(childNode, ModelConfiguration.DigitalObjectModel.PLANETS_URI.name(),
                          o.getPermanentUri().toString());
                    }
                    if (o.getFormat() != null) {
                      addNode(childNode, ModelConfiguration.DigitalObjectModel.FORMAT.name(),
                          o.getFormat().toString());
                    }
                    if (o.getManifestationOf() != null) {
                      addNode(childNode, ModelConfiguration.DigitalObjectModel.MANIFESTATION_OF.name(),
                          o.getManifestationOf().toString());
                    }
                    describeMetadata(childNode, o);
                    describeEvents(childNode, o);
                 } else {
                    TreeNodeImpl childNode = new TreeNodeImpl();
                    childNode.setData(ModelConfiguration.PREMIS_MODEL.name());
                    childNode.setParent(node);
                    node.removeChild(NODE_ID);
                    node.addChild(NODE_ID, childNode);
 
                      TreeNode idNode = addNode(childNode, ModelConfiguration.PremisModel.OBJECT_IDENTIFIER.name());
                    if (o.getPermanentUri() != null) {
                      addNode(idNode, ModelConfiguration.PremisModel.ObjectIdentifier.TYPE.name(), "URI");
                      addNode(idNode, ModelConfiguration.PremisModel.ObjectIdentifier.VALUE.name(),
                          o.getPermanentUri().toString());
                    }
                    if (o.getTitle() != null) {
                      addNode(childNode, ModelConfiguration.PremisModel.ORIGINAL_NAME.name(), o.getTitle());
                    }
                      TreeNode charNode = addNode(childNode, ModelConfiguration.PremisModel.OBJECT_CHARACTERISTICS.name());
                    if (o.getFormat() != null) {
                      addNode(charNode, ModelConfiguration.PremisModel.ObjectCharacteristics.FORMAT.name(),
                          o.getFormat().toString());
                    }
                      TreeNode relationshipNode = addNode(childNode, ModelConfiguration.PremisModel.RELATIONSHIP.name());
                      addNode(relationshipNode,
                          ModelConfiguration.PremisModel.Relationship.RELATED_OBJECT_IDENTIFIER.name());
                    if (o.getManifestationOf() != null) {
                      addNode(idNode,
                          ModelConfiguration.PremisModel.Relationship.RelatedObjectIdentifier.TYPE.name(), "URI");
                      addNode(idNode, ModelConfiguration.PremisModel.Relationship.RelatedObjectIdentifier.VALUE.name(),
                          o.getManifestationOf().toString());
                    }
                    describeSignificantProperties(childNode, o);
                    describeLinkingEventIds(childNode, o);                  
                 }
                }
View Full Code Here


       
        // Clone the content:
        File tmpFile = DigitalObjectUtils.toFile(digitalObject);
       
        // Create a new Digital Object, based on the old one:
        DigitalObject newDO = new DigitalObject.Builder(digitalObject).content(Content.byReference(tmpFile)).build();
       
        boolean success = newDO != null;
        ServiceReport report;
        if (success) {
            report = new ServiceReport(ServiceReport.Type.INFO, ServiceReport.Status.SUCCESS,
                    "Passed through");
            System.out.println("Passing back: " + newDO.getContent().length() + " bytes");
        } else {
            report = new ServiceReport(Type.ERROR, Status.TOOL_ERROR, "Null result");
        }
        MigrateResult migrateResult = new MigrateResult(newDO, report);
        System.out.println("Pass-through migration: " + migrateResult);
View Full Code Here

     * {@inheritDoc}
     */
    public MigrateResult migrate(DigitalObject digitalObject, URI inputFormat,
            URI outputFormat, List<Parameter> parameters) {

        DigitalObject result = null;
        Properties userProps = null;
        InputStream stream = null;
        File outHTML = null;
        File inHTML = DigitalObjectUtils.toFile(digitalObject);
        File logFile = new File(inHTML.getParentFile(), LOG_FILE_NAME);
View Full Code Here

   * @see eu.planets_project.ifr.core.storage.api.DigitalObjectManagerBase#retrieve(java.net.URI)
   */
  @Override
  public DigitalObject retrieve(URI pdURI)
      throws DigitalObjectNotFoundException {
    DigitalObject retObj = null;
        DigitalObject.Builder dob;

        // Look for the XML:
    try {
          // All files should have a binary:
View Full Code Here

      // First we need to update the purl and the content object reference
      URI purl = doBinary.toURI();
          /* Create the content: */
          DigitalObjectContent c1 = Content.byReference(purl.toURL());
          /* Given these, we can instantiate our object: */
          DigitalObject object = new DigitalObject.Builder(digitalObject).permanentUri(pdURI).content(c1).build();
      OutputStream outStream = new FileOutputStream(doMetadata);
      outStream.write(object.toXml().getBytes());
      outStream.close();
    } catch (UnsupportedEncodingException e) {
      log.severe("Unsupported encodeing exception");
      log.severe(e.getMessage());
      log.severe(e.getStackTrace().toString());
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

            parameterList.add(pCompressionQuality);
        }

        MigrateResult migrateResult = this.migrate.migrate(digO, migrateFromURI, migrateToURI, parameterList);
       
        DigitalObject dgoOut = migrateResult.getDigitalObject();
       
        //put filename without extenstion if empty
        if(dgoOut.getTitle() == null) {
          String title_ = digO.getTitle().substring(0,digO.getTitle().lastIndexOf('.'));
          if(migrateToURI.toString().toLowerCase().lastIndexOf("siard") > 0) title_ = title_ + ".siard";
          dgoOut = (new DigitalObject.Builder(dgoOut)).title(title_).build();
        }
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();
              String migrationResult = sb.toString();
                wfResultItem.addLogInfo("Migrated file contents: " + migrationResult);
            Metadata migrationMetadata = new Metadata(dgoA.getPermanentUri(), MIGRATION_METADATA, migrationResult);
            dgoA = addMetadata(dgoA, migrationMetadata);
        } catch (Exception e) {
          wfResultItem.addLogInfo("migration error: " + e.getMessage());
        }
      }
     
      // Insert in JCR repository
            wfResultItem.addLogInfo("STEP 3: 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());
          
           // Enrich digital object with metadata from characterization service
      Metadata characterisationMetadata = new Metadata(dgoB.getPermanentUri(), CHARACTERISATION_METADATA, "testdata");
      dgoB = addMetadata(dgoB, characterisationMetadata);

      // Update digital object in JCR repository
            wfResultItem.addLogInfo("STEP 4: 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());
           
           
            // TODO Send back to the initial repository
            wfResultItem.addLogInfo("STEP 5: Send enriched digital object back to the initial repository ");           
           wfResultItem.addLogInfo("Completed sending of enriched digital object to the initial repository.");
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.addLogInfo("STEP 2: 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());
           
           // 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) {
            Event eIdentifyFormat = buildEvent(URI.create(types[0].toString()));
          dgoB = addEvent(dgoB, eIdentifyFormat, URI.create(types[0]));
             }
           }

      // Update digital object in JCR repository
            wfResultItem.addLogInfo("STEP 3: 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());

            wfResultItem.setEndTime(System.currentTimeMillis());

      wfResultItem
        .addLogInfo("Successfully completed workflow for digitalObject with permanent uri:"
View Full Code Here

TOP

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

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.