Search in sources :

Example 1 with DeploymentResourceResponse

use of org.wso2.carbon.bpmn.rest.model.repository.DeploymentResourceResponse in project carbon-business-process by wso2.

the class DeploymentService method getDeploymentResourceForDifferentUrl.

@GET
@Path("/{deploymentId}/resources/{resourcePath:.*}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getDeploymentResourceForDifferentUrl(@PathParam("deploymentId") String deploymentId, @PathParam("resourcePath") String resourcePath) {
    if (log.isDebugEnabled()) {
        log.debug("deploymentId:" + deploymentId + " resourcePath:" + resourcePath);
    }
    RepositoryService repositoryService = BPMNOSGIService.getRepositoryService();
    // Check if deployment exists
    Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
    if (deployment == null) {
        throw new ActivitiObjectNotFoundException("Could not find a deployment with id '" + deploymentId + "'.", Deployment.class);
    }
    List<String> resourceList = repositoryService.getDeploymentResourceNames(deploymentId);
    if (resourceList.contains(resourcePath)) {
        // Build resource representation
        DeploymentResourceResponse deploymentResourceResponse = new RestResponseFactory().createDeploymentResourceResponse(deploymentId, resourcePath, Utils.resolveContentType(resourcePath), uriInfo.getBaseUri().toString());
        return Response.ok().entity(deploymentResourceResponse).build();
    } else {
        // Resource not found in deployment
        throw new ActivitiObjectNotFoundException("Could not find a resource with id '" + resourcePath + "' in deployment '" + deploymentId + "'.", Deployment.class);
    }
}
Also used : RestResponseFactory(org.wso2.carbon.bpmn.rest.common.RestResponseFactory) Deployment(org.activiti.engine.repository.Deployment) DeploymentResourceResponse(org.wso2.carbon.bpmn.rest.model.repository.DeploymentResourceResponse) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) RepositoryService(org.activiti.engine.RepositoryService) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)1 RepositoryService (org.activiti.engine.RepositoryService)1 Deployment (org.activiti.engine.repository.Deployment)1 RestResponseFactory (org.wso2.carbon.bpmn.rest.common.RestResponseFactory)1 DeploymentResourceResponse (org.wso2.carbon.bpmn.rest.model.repository.DeploymentResourceResponse)1