Package eu.planets_project.services.datatypes

Examples of eu.planets_project.services.datatypes.ServiceReport


     * @throws Exception
     */
    private String[] runIdentification1(DigitalObject digo, WorkflowResult wfresult) throws Exception{
        List<Parameter> parameterList = new ArrayList<Parameter>();    
        IdentifyResult results = identify1.identify(digo,parameterList);
        ServiceReport report = results.getReport();
        List<URI> types = results.getTypes();

        if(report.getType() == Type.ERROR){
            String s = "Service execution failed: " + report.getMessage();
            log.debug(s);
            throw new Exception(s);
        }
        if(types.size()<1){
            String s = "The specified file type is currently not supported by this workflow";
View Full Code Here


     * @throws Exception
     */
    private String[] runIdentification2(DigitalObject digo,WorkflowResult wfresult) throws Exception{
        List<Parameter> parameterList = new ArrayList<Parameter>();
        IdentifyResult results = identify2.identify(digo,parameterList);
        ServiceReport report = results.getReport();
        List<URI> types = results.getTypes();

        if(report.getType() == Type.ERROR){
            String s = "Service execution failed: " + report.getMessage();
            log.debug(s);
            throw new Exception(s);
        }
        if(types.size()<1){
            String s = "The specified file type is currently not supported by this workflow";
View Full Code Here

        /*
         * Now call the migration service
         */
        MigrateResult migrateResult = this.migrate1.migrate(digO, migrateFromURI, migrateToURI, parameterList);
        ServiceReport report = migrateResult.getReport();

        if(report.getType() == Type.ERROR){
            String s = "Service execution failed: " + report.getMessage();
            log.debug(s);
            throw new Exception(s);
        }

        return migrateResult.getDigitalObject();
View Full Code Here

     */
    public IdentifyResult identify(final DigitalObject digitalObject,
            final List<Parameter> parameters) {
        File file = DigitalObjectUtils.toFile(digitalObject);
        List<URI> types = identifyOneBinary(file);
        ServiceReport report = null;
        if (types == null || types.size() == 0) {
            report = new ServiceReport(Type.ERROR, Status.TOOL_ERROR,
                    "No identification result for: " + file);
        } else {
            report = new ServiceReport(Type.INFO, Status.SUCCESS,
                    this.classificationText);
        }
        IdentifyResult.Method method = null;
        if (AnalysisController.FILE_CLASSIFICATION_POSITIVE_TEXT
                .equals(this.classificationText)) {
View Full Code Here

            //fine, is alreade written
        }

        //Execute the tool
        final ProcessRunner toolProcessRunner = new ProcessRunner();
        ServiceReport serviceReport = executeToolProcess(toolProcessRunner,
                                                         command, processStandardInput);



        if (serviceReport.getType() == Type.ERROR) {
            String message = "Failed migrating object with title '"
                             + sourceObject.getTitle() + "' from format URI: "
                             + sourceFormat + " to " + destinationFormat
                             + " Standard output: "
                             + toolProcessRunner.getProcessOutputAsString()
                             + "\nStandard error output: "
                             + toolProcessRunner.getProcessErrorAsString();
            serviceReport = new ServiceReport(Type.ERROR,
                                              Status.TOOL_ERROR, message);
            return new MigrateResult(null, serviceReport);
        }


        //cleanup
        if (migrationPath.useTempSourceFile()){
            migrationPath.getTempSourceFile().getFile().delete();
        }
        for (TempFile tempFile : migrationPath.getTempFileDeclarations()) {
            tempFile.getFile().delete();
        }


        //READING THE OUTPUT
        //TODO return a reference to the outputfile
        DigitalObject.Builder builder;


        if (migrationPath.useTempDestinationFile()){
            //we should read a temp file afterwards
            File outputfile = migrationPath.getTempOutputFile().getFile();
            if (returnByReference){
                builder = new DigitalObject.Builder(Content.byReference(outputfile));
            } else {
                builder = new DigitalObject.Builder(Content.byValue(outputfile));
                outputfile.delete();
            }


            String message = "Successfully migrated object with title '"
                             + sourceObject.getTitle() + "' from format URI: "
                             + sourceFormat + " to " + destinationFormat
                             + " Standard output: "
                             + toolProcessRunner.getProcessOutputAsString()
                             + "\nStandard error output: "
                             + toolProcessRunner.getProcessErrorAsString();
            serviceReport = new ServiceReport(Type.INFO, Status.SUCCESS,
                                              message);

        } else {

            if (returnByReference){
                //we should read the output
                builder = new DigitalObject.Builder(Content.byReference(toolProcessRunner.getProcessOutput()));
            } else{
                builder = new DigitalObject.Builder(Content.byValue(toolProcessRunner.getProcessOutput()));
            }
            String message = "Successfully migrated object with title '"
                             + sourceObject.getTitle() + "' from format URI: "
                             + sourceFormat + " to " + destinationFormat
                             + " Standard error output: "
                             + toolProcessRunner.getProcessErrorAsString();
            serviceReport = new ServiceReport(Type.INFO, Status.SUCCESS,
                                              message);


        }
View Full Code Here

        toolProcessRunner.setCommand(command);
        toolProcessRunner.setCollection(true);
        toolProcessRunner.setOutputCollectionByteSize(-1);

        toolProcessRunner.run();
        ServiceReport serviceReport;
        boolean toolError = toolProcessRunner.getReturnCode() != 0;
        if (toolError) {
            serviceReport = new ServiceReport(Type.ERROR, Status.TOOL_ERROR,
                                              toolProcessRunner.getProcessErrorAsString());
        } else {
            serviceReport = new ServiceReport(Type.INFO, Status.SUCCESS,
                                              toolProcessRunner.getProcessOutputAsString());
        }
        return serviceReport;
    }
View Full Code Here

            FileUtils.deleteQuietly(inputFile);
            FileUtils.deleteQuietly(outputFile);

            boolean toolError = pr.getReturnCode() == -1;
            ServiceReport log;
            if (toolError) {
                log = new ServiceReport(Type.ERROR, Status.TOOL_ERROR, pr
                        .getProcessErrorAsString());
            } else {
                log = new ServiceReport(Type.INFO, Status.SUCCESS, pr
                        .getProcessOutputAsString());
            }
            /*
             * log.properties = new ArrayList<Property>(); log.properties.add(
             * new Property( URI.create("planets:uri"), "name", "value") );
View Full Code Here

    + "\n%s", statusDescription, inputObject.getTitle(),
    migrationPath.getInputFormat(),
    migrationPath.getOutputFormat(), stdoutPart, toolProcessRunner
      .getProcessErrorAsString());

  final ServiceReport serviceReport = new ServiceReport(messageType,
    messageStatus, reportMessage);

  return new MigrateResult(resultObject, serviceReport);
    }
View Full Code Here

TOP

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

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.