Package eu.planets_project.ifr.core.storage.impl.jcr

Examples of eu.planets_project.ifr.core.storage.impl.jcr.JcrDigitalObjectManagerImpl


   * removes all JCR registry entries
   */
  public void clearJcr() {
    log.info("StorageBackingBean clearJcr()");
    try {
          JcrDigitalObjectManagerImpl dodm =
              (JcrDigitalObjectManagerImpl) JcrDigitalObjectManagerImpl.getInstance();
      log.info("StorageBackingBean clearJcr() remove all.");
         dodm.removeAll();
      this.loadTree();
    } catch (Exception e) {
      log.info("StorageBackingBean clearJcr() error: " + e.getMessage());     
    }
  }
View Full Code Here


             
      // Insert in JCR repository
            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
View Full Code Here

     
      // 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 ");           
View Full Code Here

             
      // Insert in JCR repository
            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(IDENITFY_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()), IDENTIFY_EVENT);
          dgoB = addEvent(dgoB, eIdentifyFormat, URI.create(types[0]), false);
             }
           }

      // 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());


     
      // Migration service
      DigitalObject dgoC = null;
          wfResultItem.addLogInfo("STEP 4: Starting migration");
          wfResultItem.addLogInfo("processingDigo.getPermanentUri(): " + processingDigo.getPermanentUri() +
              ", dgoB.getPermanentUri(): " + dgoB.getPermanentUri());
         
        DataRegistry dataRegistry = DataRegistryFactory.getDataRegistry();
        URI baseUri = DataRegistryFactory.createDataRegistryIdFromName(DOJCRConstants.REGISTRY_NAME);
      wfResultItem.addLogInfo("base URI: " + baseUri);
      URI resUri = URI.create(baseUri.toString() + dgoB.getPermanentUri().toString());
      wfResultItem.addLogInfo("resUri: " + resUri);

      URI dgoCRef = runMigration(migrate, resUri, true);
      wfResultItem.addLogInfo("Completed migration. URI: " + dgoCRef);
     
      // Add migration resulting text to metadata
      if (dgoCRef != null) {
        try {
          baseUri = new PDURI(dgoCRef.normalize()).formDataRegistryRootURI();
          wfResultItem.addLogInfo("migration base URI: " + baseUri);
     
          dgoC = dataRegistry.getDigitalObjectManager(baseUri).retrieve(dgoCRef)
          wfResultItem.addLogInfo("dgoC: " + dgoC.toString());
          if (dgoC != null && dgoB.getPermanentUri() != null) {
              Event eMigration = buildEvent(dgoB.getPermanentUri(), MIGRATE_EVENT);
            dgoC = addEvent(dgoC, eMigration, null, true);
               }

        } catch (Exception e) {
          wfResultItem.addLogInfo("migration error: " + e.getMessage());
        }
      }
     
      // Insert in JCR repository
            wfResultItem.addLogInfo("STEP 5: Insert in JCR repository. initial digital object: " + dgoC.toString());
            dgoC = dodm.store(MIGRATE_PATH, dgoC, true);
           wfResultItem.addLogInfo("Completed storing in JCR repository: " + dgoC.toString());
                                           
            wfResultItem.setEndTime(System.currentTimeMillis());

      wfResultItem
View Full Code Here

     
      // Insert in JCR repository
            wfResultItem.addLogInfo("STEP 2: Insert in JCR repository. initial digital object: " + dgoB.toString());
            // Manage the Digital Object Data Registry:
            wfResultItem.addLogInfo("Initialize JCR repository instance.");
            JcrDigitalObjectManagerImpl dodm =
               (JcrDigitalObjectManagerImpl) JcrDigitalObjectManagerImpl.getInstance();
            dgoB = dodm.store(PERMANENT_URI_PATH, dgoB, true);
           wfResultItem.addLogInfo("Completed storing in JCR repository: " + dgoB.toString());
                                           
            wfResultItem.setEndTime(System.currentTimeMillis());

      wfResultItem
View Full Code Here

    try {
      // Clean up JCR repository
            wfResultItem.addLogInfo("Clean up JCR repository. initial digital object: " + dgoA.toString());
            // Manage the Digital Object Data Registry:
            wfResultItem.addLogInfo("Initialize JCR repository instance.");
            JcrDigitalObjectManagerImpl dodm =
               (JcrDigitalObjectManagerImpl) JcrDigitalObjectManagerImpl.getInstance();
            dodm.removeAll();
         
           wfResultItem.addLogInfo("Completed clean up of JCR repository.");
            wfResultItem.setEndTime(System.currentTimeMillis());

      wfResultItem
View Full Code Here

     
      // 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.");           
View Full Code Here

            try {
              wfResultItem.addLogInfo("****** initial DO. " + dgo.toString());
              // Manage the Digital Object Data Registry:
              wfResultItem.addLogInfo("Create JCR for digital object.");
                JcrDigitalObjectManagerImpl dodm =
                  (JcrDigitalObjectManagerImpl) JcrDigitalObjectManagerImpl.getInstance();
               
          // Prepare data for digital object - to remove later
            Metadata META1 = new Metadata(URI.create("http://planets-project.eu"), "meta1", "meta1");
            Metadata META2 = new Metadata(URI.create("http://planets-project.eu"), "meta2", "meta2");
            Metadata[] metaList = new Metadata[2];
            metaList[0] = META1;
            metaList[1] = META2;
            Event[] eventList = new Event[2];
            Agent agent = new Agent("id", "name", "type");
            List<eu.planets_project.services.datatypes.Property> propList = new ArrayList<eu.planets_project.services.datatypes.Property>();
            eu.planets_project.services.datatypes.Property
            prop1 = new eu.planets_project.services.datatypes.Property.Builder(URI.create("http://planets-project.eu"))
                 .name("Java JVM System Properties")
                 .value("value")
                 .description("description")
                 .unit("unit")
                 .type("type")
                 .build();
            eu.planets_project.services.datatypes.Property
            prop2 = new eu.planets_project.services.datatypes.Property.Builder(URI.create("http://planets-project.eu"))
                 .name("Java JVM System Properties2")
                 .value("value2")
                 .description("description2")
                 .unit("unit2")
                 .type("type2")
                 .build();
            propList.add(prop1);
            propList.add(prop2);
            Event event1 = new Event("summary1", "datetime1", 10.23d, agent, propList);
            Event event2 = new Event("summary2", "datetime2", 22.45d, agent, propList);
            eventList[0] = event1;
            eventList[1] = event2;

        dgo = new DigitalObject.Builder(dgo.getContent())
            .title(dgo.getTitle())
                     .permanentUri(DOREP)
                     .manifestationOf(DOFORMAT)
                     .format(DOFORMAT)
                     .metadata(metaList)
                     .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());
              }
View Full Code Here

     
        try {
            wfResultItem.addLogInfo("****** initial DO. " + dgo.toString());
            // Manage the Digital Object Data Registry:
            wfResultItem.addLogInfo("Create JCR for digital object.");
            JcrDigitalObjectManagerImpl dodm =
              (JcrDigitalObjectManagerImpl) JcrDigitalObjectManagerImpl.getInstance();
            wfResultItem.addLogInfo("****** digital object before store.");
          dgo = dodm.store(PERMANENT_URI_PATH, dgo, true);
          wfResultItem.addLogInfo("****** digital object after store: " + dgo.toString());
          URI permanentUri = dgo.getPermanentUri();
            wfResultItem.addLogInfo("Store DO in JCR res: " + permanentUri.toString());
          DigitalObject tmpDO = dodm.retrieve(permanentUri, true);
            wfResultItem.addLogInfo("result DO from JCR content length: " + tmpDO.getContent().length());
            wfResultItem.addLogInfo("result DO from JCR after retrieve: " + tmpDO.toString());
            wfResultItem.setEndTime(System.currentTimeMillis());

    } catch (Exception e) {
View Full Code Here

    @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    InputStream is = null;
   
    JcrDigitalObjectManagerImpl jcrDo =
      (JcrDigitalObjectManagerImpl) JcrDigitalObjectManagerImpl.getInstance();
   
    String id = request.getParameter(ID_PARAMETER_NAME);
    try {
      if(id==null) throw new DigitalObjectNotFoundException("id is null");
     
           // Fix up any encoding issues:
            id = PDURI.encodePlanetsUriStringAsUri(id).toASCIIString();
     
      // unfortunately, we have to search for the right metadata field
      DigitalObject object = jcrDo.retrieve(new URI(id), false);     
      for(Metadata md : object.getMetadata()) {
        if(md.getName() != null && md.getName().equals(MIME_TYPE_METADATA_NAME))
          response.setContentType(md.getContent());
      }     
      is = jcrDo.retrieveContentAsStream(object.getPermanentUri());
     
      // read from input stream and write to client
      int bytesRead = 0;
      byte[] buffer = new byte[BUFFER_SIZE];
      while((bytesRead=is.read(buffer))!=-1){
View Full Code Here

TOP

Related Classes of eu.planets_project.ifr.core.storage.impl.jcr.JcrDigitalObjectManagerImpl

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.