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

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


    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


//    @KSession("ksession1")
    KieSession ksession = null;

    public JobResult requestApproval( final JobRequest jobRequest ) {
        logger.info( "Approval request for Job: " + jobRequest.getJobId() + " received." );
        final JobResult jobResult = new JobResult();
        jobResult.setJobId( jobRequest.getJobId() );
        jobResult.setStatus( jobRequest.getStatus() );

        //If no ksession is available default to true
        if ( ksession == null ) {
            return jobResult;
        }
View Full Code Here

        logger.info( "RemoveRepositoryFromOrganizationalUnitRequest event approved. Performing requested operation." );
        helper.removeRepositoryFromOrganizationalUnit( jobRequest.getJobId(), jobRequest.getOrganizationalUnitName(), jobRequest.getRepositoryName() );
    }

    private boolean approveRequest( final JobRequest jobRequest ) {
        final JobResult result = approvalService.requestApproval( jobRequest );
        return result.getStatus().equals( JobStatus.APPROVED );
    }
View Full Code Here

        jobs = Collections.synchronizedMap( cache );
    }

    public void onUpateJobStatus( final @Observes JobResult jobResult ) {
        String jobId = jobResult.getJobId();
        JobResult job = jobs.get( jobId );

        if ( job == null ) {
            //the job has gone probably because its done and has been removed.
            logger.info( "-----onUpateJobStatus--- , can not find jobId:" + jobId + ", the job has gone probably because its done and has been removed." );
            return;
View Full Code Here

    @Produces(MediaType.APPLICATION_JSON)
    @Path("/jobs/{jobId}")
    public JobResult getJobStatus( @PathParam("jobId") String jobId ) {
        logger.info( "-----getJobStatus--- , jobId:" + jobId );

        JobResult job = jobs.get( jobId );

        if ( job == null ) {
            //the job has gone probably because its done and has been removed.
            logger.info( "-----getJobStatus--- , can not find jobId:" + jobId + ", the job has gone probably because its done and has been removed." );
            job = new JobResult();
            job.setStatus( JobStatus.GONE );
            return job;
        }

        return job;
    }
View Full Code Here

    @Produces(MediaType.APPLICATION_JSON)
    @Path("/jobs/{jobId}")
    public JobResult removeJob( @PathParam("jobId") String jobId ) {
        logger.info( "-----removeJob--- , jobId:" + jobId );

        JobResult job = jobs.get( jobId );

        if ( job == null ) {
            //the job has gone probably because its done and has been removed.
            logger.info( "-----removeJob--- , can not find jobId:" + jobId + ", the job has gone probably because its done and has been removed." );
            job = new JobResult();
            job.setStatus( JobStatus.GONE );
            return job;
        }

        jobs.remove( jobId );
        job.setStatus( JobStatus.GONE );
        return job;
    }
View Full Code Here

        CreateOrCloneRepositoryRequest jobRequest = new CreateOrCloneRepositoryRequest();
        jobRequest.setStatus( JobStatus.ACCEPTED );
        jobRequest.setJobId( id );
        jobRequest.setRepository( repository );

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

        createOrCloneJobRequestEvent.fire( jobRequest );

        return jobRequest;
View Full Code Here

        RemoveRepositoryRequest jobRequest = new RemoveRepositoryRequest();
        jobRequest.setStatus( JobStatus.ACCEPTED );
        jobRequest.setJobId( id );
        jobRequest.setRepositoryName( repositoryName );

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

        removeRepositoryRequestEvent.fire( jobRequest );

        return jobRequest;
View Full Code Here

        jobRequest.setJobId( id );
        jobRequest.setRepositoryName( repositoryName );
        jobRequest.setProjectName( project.getName() );
        jobRequest.setDescription( project.getDescription() );

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

        createProjectRequestEvent.fire( jobRequest );

        return jobRequest;
View Full Code Here

        jobRequest.setStatus( JobStatus.ACCEPTED );
        jobRequest.setJobId( id );
        jobRequest.setRepositoryName( repositoryName );
        jobRequest.setProjectName( projectName );

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

        compileProjectRequestEvent.fire( jobRequest );

        return jobRequest;
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.