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);
}
}
Aggregations