test_class.file: modules/flowable-rest/src/test/java/org/flowable/rest/service/api/repository/DeploymentResourceResourceTest.java
test_class.identifier: DeploymentResourceResourceTest
test_class.superclass: extends BaseSpringRestTestCase
test_case.body: @Test
      public void testGetDeploymentResource() throws Exception {
          try {
              String rawResourceName = "org/flowable/rest/service/api/repository/oneTaskProcess.bpmn20.xml";
              Deployment deployment = repositoryService.createDeployment().name("Deployment 1").addClasspathResource(rawResourceName)
                      .addInputStream("test.txt", new ByteArrayInputStream("Test content".getBytes())).deploy();
  
              // Build up the URL manually to make sure resource-id gets encoded
              // correctly as one piece
              HttpGet httpGet = new HttpGet(buildUrl(RestUrls.URL_DEPLOYMENT_RESOURCE, deployment.getId(), encode(rawResourceName)));
              httpGet.addHeader(new BasicHeader(HttpHeaders.ACCEPT, "application/json"));
              CloseableHttpResponse response = executeRequest(httpGet, HttpStatus.SC_OK);
              JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
              closeResponse(response);
              assertThatJson(responseNode)
                      .when(Option.IGNORING_EXTRA_FIELDS)
                      .isEqualTo("{"
                              + "    url: '" + buildUrl(RestUrls.URL_DEPLOYMENT_RESOURCE, deployment.getId(), rawResourceName) + "',"
                              + "    contentUrl: '" + buildUrl(RestUrls.URL_DEPLOYMENT_RESOURCE_CONTENT, deployment.getId(), rawResourceName) + "',"
                              + "    mediaType: 'text/xml',"
                              + "    type: 'processDefinition'"
                              + "}");
  
          } finally {
              // Always cleanup any created deployments, even if the test failed
              List<Deployment> deployments = repositoryService.createDeploymentQuery().list();
              for (Deployment deployment : deployments) {
                  repositoryService.deleteDeployment(deployment.getId(), true);
              }
          }
      }
test_case.class_method_signature: DeploymentResourceResourceTest.testGetDeploymentResource()
test_case.full_signature: @Test public void testGetDeploymentResource()
test_case.identifier: testGetDeploymentResource
test_case.invocations: deploy addInputStream addClasspathResource name createDeployment getBytes buildUrl getId encode addHeader executeRequest readTree getContent getEntity closeResponse isEqualTo when assertThatJson buildUrl getId buildUrl getId list createDeploymentQuery deleteDeployment getId
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGetDeploymentResource()
focal_class.declarator: restResponseFactory
focal_class.modifier: @Autowired
      protected
focal_class.original_string: @Autowired
      protected RestResponseFactory restResponseFactory;
focal_class.type: RestResponseFactory
focal_class.var_name: restResponseFactory
focal_class.declarator: contentTypeResolver
focal_class.modifier: @Autowired
      protected
focal_class.original_string: @Autowired
      protected ContentTypeResolver contentTypeResolver;
focal_class.type: ContentTypeResolver
focal_class.var_name: contentTypeResolver
focal_class.declarator: repositoryService
focal_class.modifier: @Autowired
      protected
focal_class.original_string: @Autowired
      protected RepositoryService repositoryService;
focal_class.type: RepositoryService
focal_class.var_name: repositoryService
focal_class.declarator: restApiInterceptor
focal_class.modifier: @Autowired(required=false)
      protected
focal_class.original_string: @Autowired(required=false)
      protected BpmnRestApiInterceptor restApiInterceptor;
focal_class.type: BpmnRestApiInterceptor
focal_class.var_name: restApiInterceptor
focal_class.file: modules/flowable-rest/src/main/java/org/flowable/rest/service/api/repository/DeploymentResourceResource.java
focal_class.identifier: DeploymentResourceResource
focal_class.class_method_signature: DeploymentResourceResource.getDeploymentResource(@ApiParam(name = "deploymentId") @PathVariable("deploymentId") String deploymentId, HttpServletRequest request)
focal_class.full_signature: @ApiOperation(value = "Get a deployment resource", tags = { "Deployment" }, notes = "Replace ** by ResourceId") /* * @ApiImplicitParams({ * * @ApiImplicitParam(name = "resourceId", dataType = "string", value = * "The id of the resource to get. Make sure you URL-encode the resourceId in case it contains forward slashes. Eg: use diagrams%2Fmy-process.bpmn20.xml instead of diagrams/Fmy-process.bpmn20.xml." * , paramType = "path") }) */ @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates both deployment and resource have been found and the resource has been returned."), @ApiResponse(code = 404, message = "Indicates the requested deployment was not found or there is no resource with the given id present in the deployment. The status-description contains additional information.") }) @GetMapping(value = "/repository/deployments/{deploymentId}/resources/**", produces = "application/json") public DeploymentResourceResponse getDeploymentResource(@ApiParam(name = "deploymentId") @PathVariable("deploymentId") String deploymentId, HttpServletRequest request)
focal_class.identifier: getDeploymentResource
focal_class.modifiers: @ApiOperation(value = "Get a deployment resource", tags = { "Deployment" }, notes = "Replace ** by ResourceId") /* * @ApiImplicitParams({ * * @ApiImplicitParam(name = "resourceId", dataType = "string", value = * "The id of the resource to get. Make sure you URL-encode the resourceId in case it contains forward slashes. Eg: use diagrams%2Fmy-process.bpmn20.xml instead of diagrams/Fmy-process.bpmn20.xml." * , paramType = "path") }) */ @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates both deployment and resource have been found and the resource has been returned."), @ApiResponse(code = 404, message = "Indicates the requested deployment was not found or there is no resource with the given id present in the deployment. The status-description contains additional information.") }) @GetMapping(value = "/repository/deployments/{deploymentId}/resources/**", produces = "application/json") public
focal_class.parameters: (@ApiParam(name = "deploymentId") @PathVariable("deploymentId") String deploymentId, HttpServletRequest request)
focal_class.return: DeploymentResourceResponse
focal_class.signature: DeploymentResourceResponse getDeploymentResource(@ApiParam(name = "deploymentId") @PathVariable("deploymentId") String deploymentId, HttpServletRequest request)
focal_method.body: @ApiOperation(value = "Get a deployment resource", tags = { "Deployment" }, notes = "Replace ** by ResourceId")
      /*
       * @ApiImplicitParams({
       * 
       * @ApiImplicitParam(name = "resourceId", dataType = "string", value =
       * "The id of the resource to get. Make sure you URL-encode the resourceId in case it contains forward slashes. Eg: use diagrams%2Fmy-process.bpmn20.xml instead of diagrams/Fmy-process.bpmn20.xml."
       * , paramType = "path") })
       */
      @ApiResponses(value = {
              @ApiResponse(code = 200, message = "Indicates both deployment and resource have been found and the resource has been returned."),
              @ApiResponse(code = 404, message = "Indicates the requested deployment was not found or there is no resource with the given id present in the deployment. The status-description contains additional information.")
      })
      @GetMapping(value = "/repository/deployments/{deploymentId}/resources/**", produces = "application/json")
      public DeploymentResourceResponse getDeploymentResource(@ApiParam(name = "deploymentId") @PathVariable("deploymentId") String deploymentId, HttpServletRequest request) {
          // The ** is needed because the name of the resource can actually contain forward slashes.
          // For example org/flowable/model.bpmn2. The number of forward slashes is unknown.
          // Using ** means that everything should get matched.
          // See also https://stackoverflow.com/questions/31421061/how-to-handle-requests-that-includes-forward-slashes/42403361#42403361
  
          // Check if deployment exists
          Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
          if (deployment == null) {
              throw new FlowableObjectNotFoundException("Could not find a deployment with id '" + deploymentId + "'.");
          }
          
          if (restApiInterceptor != null) {
              restApiInterceptor.accessDeploymentById(deployment);
          }
  
          String pathInfo = request.getPathInfo();
          String resourceName = pathInfo.replace("/repository/deployments/" + deploymentId + "/resources/", "");
  
          List<String> resourceList = repositoryService.getDeploymentResourceNames(deploymentId);
  
          if (resourceList.contains(resourceName)) {
              // Build resource representation
              DeploymentResourceResponse response = restResponseFactory.createDeploymentResourceResponse(deploymentId, resourceName, contentTypeResolver.resolveContentType(resourceName));
              return response;
  
          } else {
              // Resource not found in deployment
              throw new FlowableObjectNotFoundException("Could not find a resource with id '" + resourceName + "' in deployment '" + deploymentId + "'.");
          }
      }
focal_method.class_method_signature: DeploymentResourceResource.getDeploymentResource(@ApiParam(name = "deploymentId") @PathVariable("deploymentId") String deploymentId, HttpServletRequest request)
focal_method.full_signature: @ApiOperation(value = "Get a deployment resource", tags = { "Deployment" }, notes = "Replace ** by ResourceId") /* * @ApiImplicitParams({ * * @ApiImplicitParam(name = "resourceId", dataType = "string", value = * "The id of the resource to get. Make sure you URL-encode the resourceId in case it contains forward slashes. Eg: use diagrams%2Fmy-process.bpmn20.xml instead of diagrams/Fmy-process.bpmn20.xml." * , paramType = "path") }) */ @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates both deployment and resource have been found and the resource has been returned."), @ApiResponse(code = 404, message = "Indicates the requested deployment was not found or there is no resource with the given id present in the deployment. The status-description contains additional information.") }) @GetMapping(value = "/repository/deployments/{deploymentId}/resources/**", produces = "application/json") public DeploymentResourceResponse getDeploymentResource(@ApiParam(name = "deploymentId") @PathVariable("deploymentId") String deploymentId, HttpServletRequest request)
focal_method.identifier: getDeploymentResource
focal_method.invocations: singleResult deploymentId createDeploymentQuery accessDeploymentById getPathInfo replace getDeploymentResourceNames contains createDeploymentResourceResponse resolveContentType
focal_method.modifiers: @ApiOperation(value = "Get a deployment resource", tags = { "Deployment" }, notes = "Replace ** by ResourceId") /* * @ApiImplicitParams({ * * @ApiImplicitParam(name = "resourceId", dataType = "string", value = * "The id of the resource to get. Make sure you URL-encode the resourceId in case it contains forward slashes. Eg: use diagrams%2Fmy-process.bpmn20.xml instead of diagrams/Fmy-process.bpmn20.xml." * , paramType = "path") }) */ @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates both deployment and resource have been found and the resource has been returned."), @ApiResponse(code = 404, message = "Indicates the requested deployment was not found or there is no resource with the given id present in the deployment. The status-description contains additional information.") }) @GetMapping(value = "/repository/deployments/{deploymentId}/resources/**", produces = "application/json") public
focal_method.parameters: (@ApiParam(name = "deploymentId") @PathVariable("deploymentId") String deploymentId, HttpServletRequest request)
focal_method.return: DeploymentResourceResponse
focal_method.signature: DeploymentResourceResponse getDeploymentResource(@ApiParam(name = "deploymentId") @PathVariable("deploymentId") String deploymentId, HttpServletRequest request)