Package org.kie.workbench.common.services.shared.rest

Examples of org.kie.workbench.common.services.shared.rest.JobResult


        jobRequest.setJobId( id );
        jobRequest.setOrganizationalUnitName( organizationalUnit.getName() );
        jobRequest.setOwner( organizationalUnit.getOwner() );
        jobRequest.setRepositories( organizationalUnit.getRepositories() );

        JobResult jobResult = new JobResult();
        jobResult.setJobId( id );
        jobResult.setStatus( JobStatus.ACCEPTED );
        jobs.put( id, jobResult );

        createOrganizationalUnitRequestEvent.fire( jobRequest );

        return jobRequest;
View Full Code Here


        jobRequest.setStatus( JobStatus.ACCEPTED );
        jobRequest.setJobId( id );
        jobRequest.setOrganizationalUnitName( organizationalUnitName );
        jobRequest.setRepositoryName( repositoryName );

        JobResult jobResult = new JobResult();
        jobResult.setJobId( id );
        jobResult.setStatus( JobStatus.ACCEPTED );
        jobs.put( id, jobResult );

        addRepositoryToOrganizationalUnitRequest.fire( jobRequest );

        return jobRequest;
View Full Code Here

        jobRequest.setStatus( JobStatus.ACCEPTED );
        jobRequest.setJobId( id );
        jobRequest.setOrganizationalUnitName( organizationalUnitName );
        jobRequest.setRepositoryName( repositoryName );

        JobResult jobResult = new JobResult();
        jobResult.setJobId( id );
        jobResult.setStatus( JobStatus.ACCEPTED );
        jobs.put( id, jobResult );

        removeRepositoryFromOrganizationalUnitRequest.fire( jobRequest );

        return jobRequest;
View Full Code Here

    public void compileProject( final String jobId,
                                final String repositoryName,
                                final String projectName ) {
        logger.info( "-----JobRequestHelper:compileProject--- , repositoryName:" + repositoryName + ", project name:" + projectName );
        JobResult result = new JobResult();
        result.setJobId( jobId );

        org.uberfire.java.nio.file.Path repositoryPath = getRepositoryRootPath( repositoryName );

        if ( repositoryPath == null ) {
            result.setStatus( JobStatus.RESOURCE_NOT_EXIST );
            result.setResult( "Repository [" + repositoryName + "] does not exist" );
            jobResultEvent.fire( result );
        } else {
            Project project = projectService.resolveProject( Paths.convert( repositoryPath.resolve( projectName ) ) );

            if ( project == null ) {
                result.setStatus( JobStatus.RESOURCE_NOT_EXIST );
                result.setResult( "Project [" + projectName + "] does not exist" );
                jobResultEvent.fire( result );
                return;
            }

            BuildResults buildResults = buildService.build( project );

            result.setDetailedResult( buildResultsToDetailedStringMessages( buildResults.getMessages() ) );
            result.setStatus( buildResults.getMessages().isEmpty() ? JobStatus.SUCCESS : JobStatus.FAIL );
            jobResultEvent.fire( result );
        }
    }
View Full Code Here

    public void installProject( final String jobId,
                                final String repositoryName,
                                final String projectName ) {
        logger.info( "-----JobRequestHelper:installProject--- , repositoryName:" + repositoryName + ", project name:" + projectName );
        JobResult result = new JobResult();
        result.setJobId( jobId );

        org.uberfire.java.nio.file.Path repositoryPath = getRepositoryRootPath( repositoryName );

        if ( repositoryPath == null ) {
            result.setStatus( JobStatus.RESOURCE_NOT_EXIST );
            result.setResult( "Repository [" + repositoryName + "] does not exist" );
            jobResultEvent.fire( result );
            return;
        } else {
            Project project = projectService.resolveProject( Paths.convert( repositoryPath.resolve( projectName ) ) );

            if ( project == null ) {
                result.setStatus( JobStatus.RESOURCE_NOT_EXIST );
                result.setResult( "Project [" + projectName + "] does not exist" );
                jobResultEvent.fire( result );
                return;
            }

            BuildResults buildResults = null;
            try {
                buildResults = buildService.buildAndDeploy( project );

                result.setDetailedResult( buildResults == null ? null : deployResultToDetailedStringMessages( buildResults ) );
                result.setStatus( buildResults.getMessages().isEmpty() ? JobStatus.SUCCESS : JobStatus.FAIL );
            } catch ( Throwable t ) {
                List<String> errorResult = new ArrayList<String>();
                errorResult.add( t.getMessage() );
                result.setDetailedResult( errorResult );
                result.setStatus( JobStatus.FAIL );
            }

            jobResultEvent.fire( result );
        }
    }
View Full Code Here

    public void testProject( final String jobId,
                             final String repositoryName,
                             final String projectName,
                             final BuildConfig config ) {
        logger.info( "-----JobRequestHelper:testProject--- , repositoryName:" + repositoryName + ", project name:" + projectName );
        final JobResult result = new JobResult();
        result.setJobId( jobId );

        org.uberfire.java.nio.file.Path repositoryPath = getRepositoryRootPath( repositoryName );

        if ( repositoryPath == null ) {
            result.setStatus( JobStatus.RESOURCE_NOT_EXIST );
            result.setResult( "Repository [" + repositoryName + "] does not exist" );
            jobResultEvent.fire( result );
            return;
        } else {
            Project project = projectService.resolveProject( Paths.convert( repositoryPath.resolve( projectName ) ) );

            if ( project == null ) {
                result.setStatus( JobStatus.RESOURCE_NOT_EXIST );
                result.setResult( "Project [" + projectName + "] does not exist" );
                jobResultEvent.fire( result );
                return;
            }

            //TODO: Get session from BuildConfig or create a default session for testing if no session is provided.
            scenarioTestEditorService.runAllScenarios( project.getPomXMLPath(), new Event<TestResultMessage>() {
                @Override
                public void fire( TestResultMessage event ) {
                    result.setDetailedResult( testResultMessageToDetailedStringMessages( event ) );
                    result.setStatus( event.wasSuccessful() ? JobStatus.SUCCESS : JobStatus.FAIL );
                    jobResultEvent.fire( result );
                }

                //@Override
                public Event<TestResultMessage> select( Annotation... qualifiers ) {
View Full Code Here

    public void deployProject( final String jobId,
                               final String repositoryName,
                               final String projectName ) {
        logger.info( "-----JobRequestHelper:deployProject--- , repositoryName:" + repositoryName + ", project name:" + projectName );
        JobResult result = new JobResult();
        result.setJobId( jobId );

        org.uberfire.java.nio.file.Path repositoryPath = getRepositoryRootPath( repositoryName );

        if ( repositoryPath == null ) {
            result.setStatus( JobStatus.RESOURCE_NOT_EXIST );
            result.setResult( "Repository [" + repositoryName + "] does not exist" );
            jobResultEvent.fire( result );
            return;
        } else {
            Project project = projectService.resolveProject( Paths.convert( repositoryPath.resolve( projectName ) ) );

            if ( project == null ) {
                result.setStatus( JobStatus.RESOURCE_NOT_EXIST );
                result.setResult( "Project [" + projectName + "] does not exist" );
                jobResultEvent.fire( result );
                return;
            }

            BuildResults buildResults = buildService.buildAndDeploy( project );

            result.setDetailedResult( buildResults == null ? null : deployResultToDetailedStringMessages( buildResults ) );
            result.setStatus( buildResults.getMessages().isEmpty() ? JobStatus.SUCCESS : JobStatus.FAIL );
            jobResultEvent.fire( result );
        }
    }
View Full Code Here

    public void createOrganizationalUnit( final String jobId,
                                          final String organizationalUnitName,
                                          final String organizationalUnitOwner,
                                          final List<String> repositoryNameList ) {
        logger.info( "-----JobRequestHelper:createOrganizationalUnit--- , OrganizationalUnit name:" + organizationalUnitName + ", OrganizationalUnit owner:" + organizationalUnitOwner );
        JobResult result = new JobResult();
        result.setJobId( jobId );

        if ( organizationalUnitName == null || organizationalUnitName == null ) {
            result.setStatus( JobStatus.BAD_REQUEST );
            result.setResult( "OrganizationalUnit name and owner must be provided" );
            jobResultEvent.fire( result );
            return;
        }

        OrganizationalUnit organizationalUnit = null;
        List<org.uberfire.backend.repositories.Repository> repositories = new ArrayList<org.uberfire.backend.repositories.Repository>();
        if ( repositoryNameList != null && repositoryNameList.size() > 0 ) {
            for ( String repoName : repositoryNameList ) {
                org.uberfire.java.nio.file.Path repositoryPath = getRepositoryRootPath( repoName );

                if ( repositoryPath == null ) {
                    result.setStatus( JobStatus.RESOURCE_NOT_EXIST );
                    result.setResult( "Repository [" + repoName + "] does not exist" );
                    jobResultEvent.fire( result );
                    return;
                }
                GitRepository repo = new GitRepository( repoName );
                repositories.add( repo );
            }
            organizationalUnit = organizationalUnitService.createOrganizationalUnit( organizationalUnitName,
                                                                                     organizationalUnitOwner,
                                                                                     repositories );
        } else {
            organizationalUnit = organizationalUnitService.createOrganizationalUnit( organizationalUnitName,
                                                                                     organizationalUnitOwner );
        }

        if ( organizationalUnit != null ) {
            result.setResult( "OrganizationalUnit " + organizationalUnit.getName() + " is created successfully." );
            result.setStatus( JobStatus.SUCCESS );
        } else {
            result.setStatus( JobStatus.FAIL );
        }
        jobResultEvent.fire( result );
    }
View Full Code Here

    public void addRepositoryToOrganizationalUnit( final String jobId,
                                                   final String organizationalUnitName,
                                                   final String repositoryName ) {
        logger.info( "-----JobRequestHelper:addRepositoryToOrganizationalUnit--- , OrganizationalUnit name:" + organizationalUnitName + ", repository name:" + repositoryName );
        JobResult result = new JobResult();
        result.setJobId( jobId );

        if ( organizationalUnitName == null || repositoryName == null ) {
            result.setStatus( JobStatus.BAD_REQUEST );
            result.setResult( "OrganizationalUnit name and Repository name must be provided" );
            jobResultEvent.fire( result );
            return;
        }

        org.uberfire.java.nio.file.Path repositoryPath = getRepositoryRootPath( repositoryName );
        if ( repositoryPath == null ) {
            result.setStatus( JobStatus.RESOURCE_NOT_EXIST );
            result.setResult( "Repository [" + repositoryName + "] does not exist" );
            jobResultEvent.fire( result );
            return;
        }

        OrganizationalUnit organizationalUnit = new OrganizationalUnitImpl( organizationalUnitName,
                                                                            null );

        GitRepository repo = new GitRepository( repositoryName );
        try {
            organizationalUnitService.addRepository( organizationalUnit,
                                                     repo );
        } catch ( IllegalArgumentException e ) {
            result.setStatus( JobStatus.BAD_REQUEST );
            result.setResult( "OrganizationalUnit " + organizationalUnit.getName() + " not found" );
            jobResultEvent.fire( result );
            return;
        }

        result.setStatus( JobStatus.SUCCESS );
        jobResultEvent.fire( result );
    }
View Full Code Here

    public void removeRepositoryFromOrganizationalUnit( final String jobId,
                                                        final String organizationalUnitName,
                                                        final String repositoryName ) {
        logger.info( "-----JobRequestHelper:removeRepositoryFromOrganizationalUnit--- , OrganizationalUnit name:" + organizationalUnitName + ", repository name:" + repositoryName );
        JobResult result = new JobResult();
        result.setJobId( jobId );

        if ( organizationalUnitName == null || repositoryName == null ) {
            result.setStatus( JobStatus.BAD_REQUEST );
            result.setResult( "OrganizationalUnit name and Repository name must be provided" );
            jobResultEvent.fire( result );
            return;
        }

        org.uberfire.java.nio.file.Path repositoryPath = getRepositoryRootPath( repositoryName );
        if ( repositoryPath == null ) {
            result.setStatus( JobStatus.RESOURCE_NOT_EXIST );
            result.setResult( "Repository [" + repositoryName + "] does not exist" );
            jobResultEvent.fire( result );
            return;
        }

        OrganizationalUnit organizationalUnit = new OrganizationalUnitImpl( organizationalUnitName, null );
        GitRepository repo = new GitRepository( repositoryName );
        try {
            organizationalUnitService.removeRepository( organizationalUnit,
                                                        repo );
        } catch ( IllegalArgumentException e ) {
            result.setStatus( JobStatus.BAD_REQUEST );
            result.setResult( "OrganizationalUnit " + organizationalUnit.getName() + " not found" );
            jobResultEvent.fire( result );
            return;
        }

        result.setStatus( JobStatus.SUCCESS );
        jobResultEvent.fire( result );
    }
View Full Code Here

TOP

Related Classes of org.kie.workbench.common.services.shared.rest.JobResult

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.