Package eu.planets_project.services.datatypes

Examples of eu.planets_project.services.datatypes.Parameter


        // Create service parameter list
        List<Parameter> parameterList = new ArrayList<Parameter>();
        if (success) {
            log.info("Extracted cropping coordinates: " + left + "/" + top + "/" + right + "/" + bottom);

            parameterList.add(new Parameter("top_left_point", top + "," + left));
            parameterList.add(new Parameter("bottom_right_point", bottom + "," + right));
        } else {
            log
                    .warn("No cropping coordinates found in DigitalObject metadata - defaulting to parameters in XML config!");

            Parameter pTopLeftPoint;
            Parameter pBottomRightPoint;
            pTopLeftPoint = this.getServiceCallConfigs(this.crop).getPropertyAsParameter("top_left_point");
            if (pTopLeftPoint != null) {
                parameterList.add(pTopLeftPoint);
            }
View Full Code Here


        // URI migrateFromURI = new URI(migrateFrom);
        URI migrateToURI = this.getServiceCallConfigs(this.migrate).getPropertyAsURI(SER_PARAM_MIGRATE_TO);

        // Create service parameter list
        List<Parameter> parameterList = new ArrayList<Parameter>();
        Parameter pCompressionType = this.getServiceCallConfigs(this.migrate).getPropertyAsParameter("compressionType");
        if (pCompressionType != null) {
            parameterList.add(pCompressionType);
        }

        Parameter pCompressionQuality = this.getServiceCallConfigs(this.migrate).getPropertyAsParameter(
                "compressionQuality");
        if (pCompressionQuality != null) {
            parameterList.add(pCompressionQuality);
        }
View Full Code Here

                "getCommandLine() did not return the value just set.",
                originalCommandLine, migrationPath.getCommandLine());

        final ArrayList<Parameter> toolParameters = new ArrayList<Parameter>();
        // Options for the 'cat' command
        toolParameters.add(new Parameter("param1", "-n"));
        // Options for the 'tr' command
        toolParameters.add(new Parameter("param2", "'[:lower:]' '[:upper:]'"));

        TempFile input = new TempFile("tempSource");
        input.setFile(new File("/random-source-name"));
        migrationPath.setTempInputFile(input);
View Full Code Here

     * @throws Exception
     */
    @Before
    public void setUp() throws Exception {

  this.testParameters.add(new Parameter("mode", "complete"));

  DocumentLocator documentLocator = new DocumentLocator(
    "deprecatedGenericWrapperV1ExampleConfigFile.xml");
  this.genericWrapper = new GenericMigrationWrapper(documentLocator
    .getDocument(), this.getClass().getCanonicalName());
View Full Code Here

     */
    public DBMigrationPathFactoryTest() {
  this.environmentParameters = new HashMap<String, Parameter>();
  Parameter.Builder parameterBuilder = new Parameter.Builder(
    "shellcommand", "sh");
  Parameter parameter = parameterBuilder.build();
  this.environmentParameters.put(parameter.getName(), parameter);

  parameterBuilder = new Parameter.Builder("shellcommandoption", "-c");
  parameter = parameterBuilder.build();
  this.environmentParameters.put(parameter.getName(), parameter);

  parameterBuilder = new Parameter.Builder("catcommand", "cat");
  parameter = parameterBuilder.build();
  this.environmentParameters.put(parameter.getName(), parameter);

  parameterBuilder = new Parameter.Builder("trcommand", "tr");
  parameter = parameterBuilder.build();
  this.environmentParameters.put(parameter.getName(), parameter);
    }
View Full Code Here

  // Verify the tool parameters.

  final Map<String, Parameter> testParameters = new HashMap<String, Parameter>();
  Parameter.Builder parameterBuilder = new Parameter.Builder("param1",
    "-n");
  Parameter parameter = parameterBuilder.build();
  testParameters.put(parameter.getName(), parameter);

  parameterBuilder = new Parameter.Builder("param2",
    "'[:lower:]' '[:upper:]'");
  parameter = parameterBuilder.build();
  testParameters.put(parameter.getName(), parameter);

  final Collection<Parameter> toolParameters = migrationPath
    .getToolParameters();
  assertEquals(
    "Unexpected number of parameters defined for the migration path.",
    2, toolParameters.size());
  final HashMap<String, Parameter> parametersToTest = new HashMap<String, Parameter>();
  for (Parameter toolParameter : toolParameters) {
      parametersToTest.put(toolParameter.getName(), toolParameter);
  }

  for (String parameterName : testParameters.keySet()) {

      final Parameter parameterToTest = parametersToTest
        .get(parameterName);
      assertNotNull("The parameter '" + parameterName + "' was not "
        + "defined for the migration path.", parameterToTest);

      assertNotNull("No description specified for parameter: "
        + parameterName, parameterToTest.getDescription());

      assertTrue("Empty description specified for parameter: "
        + parameterName,
        parameterToTest.getDescription().length() > 0);

      assertNull("Un-expected default parameter value for parameter: "
        + parameterName, parameterToTest.getValue());
  }

  // Verify the command line information

  final Map<String, File> testFileDeclarations = new HashMap<String, File>();
View Full Code Here

  Assert.assertEquals(commandLine, migrationPath.getCommandLine());

  final ArrayList<Parameter> toolParameters = new ArrayList<Parameter>();
  // Options for the 'cat' command
  toolParameters.add(new Parameter("param1", "-n"));
  // Options for the 'tr' command
  toolParameters.add(new Parameter("param2", "'[:lower:]' '[:upper:]'"));

  migrationPath.addTempFilesDeclaration("myInterimFile",
    "/random-temp-file-name");

  final String executableCommandLine = migrationPath.getCommandLine().getParameters().get(2);
View Full Code Here

    /**
     * @throws Exception
     */
    @Test
    public void testMigrateUsingTempFiles() throws Exception {
  this.testParameters.add(new Parameter("mode", "complete"));

  MigrateResult migrationResult = this.genericWrapper.migrate(
    getDigitalTestObject(), this.sourceFormatURI, this.destinationFormatURI,
    this.testParameters);

View Full Code Here

      sd.version("2.0");
      sd.name(NAME);
      sd.type(Validate.class.getCanonicalName());
      List<Parameter> parameterList = new ArrayList<Parameter>();
     
      Parameter user_doc_schema_param =
       
        new Parameter.Builder("user-doc-schema", "[1) The RelaxNG-Schema read to a String / 2) a URL where the schema can be retrieved from.]")
                        .type("String")
                            .description("1) You can pass a custom doc-schema file to validate against, read into a String." + NEWLINE +
                                   "2) You can also pass a URL to load the schema. " + NEWLINE +
                                   "To indicate this, please use 'doc-schema-url=' marker. Please see the following example:" + NEWLINE +
                                   "EXAMPLE:" + NEWLINE + 
                                   "--------" + NEWLINE +
                                   "user-doc-schema=doc-schema-url=http://docs.oasis-open.org/office/v1.1/OS/OpenDocument-schema-v1.1.rng")
                            .build();
      parameterList.add(user_doc_schema_param);
     
      Parameter user_doc_strict_schema_param =
       
        new Parameter.Builder("user-doc-strict-schema", "[1) The RelaxNG-Schema read to a String / 2) a URL where the schema can be retrieved from.]")
                      .type("String")
                      .description("1) You can pass a custom doc-strict-schema file to validate against, read into a String." + NEWLINE +
                                   "2) You can also pass a URL to load the schema. " + NEWLINE +
                                   "To indicate this, please use 'doc-strict-schema-url=' marker. Please see the following example:" + NEWLINE +
                                   "EXAMPLE:" + NEWLINE + 
                                   "--------" + NEWLINE +
                                   "user-doc-strict-schema=doc-strict-schema-url=http://docs.oasis-open.org/office/v1.1/OS/OpenDocument-strict-schema-v1.1.rng" + NEWLINE +
                                   "PLEASE NOTE: If you pass a [user-doc-strict-schema] file, you have to pass a [user-doc-schema] as well, as the strict schema usually references the doc-schema, " +
                                   "obviously this won't work, if you haven't passed any ;-).")
                      .build();
      parameterList.add(user_doc_strict_schema_param);
     
      Parameter user_manifest_schema_param =
       
        new Parameter.Builder("user-manifest-schema", "[1) The RelaxNG-Schema read to a String / 2) a URL where the schema can be retrieved from.]")
                      .type("String")
                      .description("1) You can pass a custom manifest-schema file to validate against, read into a String." + NEWLINE +
                                   "2) You can also pass a URL to load the schema. " + NEWLINE +
                                   "To indicate this, please use 'manifest-schema-url=' marker. Please see the following example:" + NEWLINE +
                                   "EXAMPLE:" + NEWLINE + 
                                   "--------" + NEWLINE +
                                   "user-manifest-schema=manifest-schema-url=http://docs.oasis-open.org/office/v1.1/OS/OpenDocument-manifest-schema-v1.1.rng")
                      .build();
      parameterList.add(user_manifest_schema_param);
     
      Parameter user_dsig_schema_param =
       
        new Parameter.Builder("user-dsig-schema", "[1) The RelaxNG-Schema read to a String / 2) a URL where the schema can be retrieved from.]")
                      .type("String")
                      .description("1) You can pass a custom RNG dsig-schema file to validate against, read into a String." + NEWLINE +
                                   "2) You can also pass a URL to load the schema. " + NEWLINE +
                                   "To indicate this, please use 'dsig-schema-url=' marker. Please see the following example:" + NEWLINE +
                                   "EXAMPLE:" + NEWLINE + 
                                   "--------" + NEWLINE +
                                   "user-dsig-schema=dsig-schema-url=http://docs.oasis-open.org/office/v1.2/part3/cd01/OpenDocument-dsig-schema-v1.2-cd1.rng" + NEWLINE +
                                   "The dsig-schema is used to validate all signatures attached to a document. Signing documents is possible since v1.2, so for all " +
                                   "files with a lower version this feature is not applicable!")
                      .build();
      parameterList.add(user_dsig_schema_param);
     
      Parameter strict_validation_param = new Parameter.Builder("strict-validation", "true/false")
                        .type("boolean")
                        .description("Enable STRICT Validation (i.e. validate against the strict-schema. Default is false/disabled." + NEWLINE +
                            "PLEASE NOTE: 1) If you enable STRICT validation and pass a [user-doc-schema] without passing a [user-doc-strict-schema], STRICT validation will be disabled." + NEWLINE +
                            "             2) Enabling STRICT validation for a ODF v1.2 file will have no effect and thus this parameter is ignored for ODF v1.2 files!")
                        .build();
View Full Code Here

        wfResultItem.addLogInfo("for endpoint: " + wri.getServiceEndpoint());
      }

      String initialFileName = dgoA.getPermanentUri().toString().substring(
          dgoA.getPermanentUri().toString().lastIndexOf(URI_SEPARATOR) + 1 );
              wfResultItem.addLogInfo(new Message("Characterisation", new Parameter("File", initialFileName), new Parameter(
                    "Result", "Properties")));
              wfResultItem.addLogInfo(new Message("Identification", new Parameter("File", initialFileName), new Parameter(
                    "Result", Arrays.asList(types).toString())));

            // Extract metadata - will otherwise get lost between steps!
            String metadata = "";
            List<Metadata> mList = dgoA.getMetadata();
            if ((mList != null) && (mList.size() > 0)) {
                metadata = mList.get(0).getContent();
            }

            if (metadata == null) {
              wfResultItem.addLogInfo("No metadata contained in DigitalObject!");
            } else {
              wfResultItem.addLogInfo("Extracted metadata: " + metadata);
            }           

      // Migration service
          wfResultItem.addLogInfo("STEP 3: Starting migration");
      URI dgoBRef = runMigration(migrate, dgoA.getPermanentUri(), true);
      wfResultItem.addLogInfo("Completed migration. URI: " + dgoBRef);
     
      String migrationEndpoint = "";
      for (WorkflowResultItem wri : getWFResult().getWorkflowResultItems()) {
        wfResultItem.addLogInfo("for Migration parameter: " + Arrays.asList(wri.getServiceParameters()).toString());
        wfResultItem.addLogInfo("for endpoint: " + wri.getServiceEndpoint());
        if (wri.getServiceParameters().size() > 0
            && Arrays.asList(wri.getServiceParameters()).toString().contains("migration")) {
          wfResultItem.addLogInfo(new Message("Migration", new Parameter("Input", Arrays.asList(types).toString())
          , new Parameter("Result", Arrays.asList(wri.getServiceParameters()).toString())));
          migrationEndpoint = wri.getServiceEndpoint();
        }
      }

      // Evaluate migrated file data
      String migratedFileName = "";
      String migratedFileSize = "";
     
      if (dgoBRef != null) {
        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) {
        wfResultItem.addLogInfo("read file content error: " + e.getMessage());
      }
          
           wfResultItem.addLogInfo("before create SIP archive");
      String sipFileName = createZipArchive(filenames);
           wfResultItem.addLogInfo("After create SIP archive sipFileName: " + sipFileName);
      String zipFileRes = sipFileName.substring(sipFileName.lastIndexOf(URI_SEPARATOR) + 1);
           wfResultItem.addLogInfo("After create SIP archive zipFileRes: " + zipFileRes);
     
      wfResultItem.addLogInfo("host auth: "  + this.getHostAuthority());
        URI zipOutFolder = new URI("http",this.getHostAuthority(),"/wee-gen/id-"+this.getWorkflowReportingLogger().getResultsId(),null,null);
        URL zipFileURL = new URL(zipOutFolder+"/" + zipFileRes);
      wfResultItem.addLogInfo("zipFileURL: "  + zipFileURL);

          wfResultItem.addLogInfo(new Message("SIP", new Parameter("Files", Arrays.asList(filenames).toString()), new Parameter(
                    "Result", zipFileURL.toString())));
      List<URL> uris = new ArrayList<URL>();
      uris.add(zipFileURL);
      wfResultItem.addLogInfo(this.link(uris));
View Full Code Here

TOP

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

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.