org.camunda.bpm.engine.RepositoryService.getCaseDiagram()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中org.camunda.bpm.engine.RepositoryService.getCaseDiagram方法的一些代码示例,展示了RepositoryService.getCaseDiagram的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RepositoryService.getCaseDiagram方法的具体详情如下:
包路径:org.camunda.bpm.engine.RepositoryService
类名称:RepositoryService
方法名:getCaseDiagram

RepositoryService.getCaseDiagram介绍

[英]Gives access to a deployed case diagram, e.g., a PNG image, through a stream of bytes.
[中]通过字节流访问已部署的案例图,例如PNG图像。

代码示例

代码示例来源:origin: camunda/camunda-bpm-platform

@Override
public Response getCaseDefinitionDiagram() {
 CaseDefinition definition = engine.getRepositoryService().getCaseDefinition(caseDefinitionId);
 InputStream caseDiagram = engine.getRepositoryService().getCaseDiagram(caseDefinitionId);
 if (caseDiagram == null) {
  return Response.noContent().build();
 } else {
  String fileName = definition.getDiagramResourceName();
  return Response.ok(caseDiagram).header("Content-Disposition", "attachment; filename=" + fileName)
    .type(ProcessDefinitionResourceImpl.getMediaTypeForFileSuffix(fileName)).build();
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Override
public Response getCaseDefinitionDiagram() {
 CaseDefinition definition = engine.getRepositoryService().getCaseDefinition(caseDefinitionId);
 InputStream caseDiagram = engine.getRepositoryService().getCaseDiagram(caseDefinitionId);
 if (caseDiagram == null) {
  return Response.noContent().build();
 } else {
  String fileName = definition.getDiagramResourceName();
  return Response.ok(caseDiagram).header("Content-Disposition", "attachment; filename=" + fileName)
    .type(ProcessDefinitionResourceImpl.getMediaTypeForFileSuffix(fileName)).build();
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void getCaseDiagramWithAuthenticatedTenant() {
 identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
 InputStream inputStream = repositoryService.getCaseDiagram(caseDefinitionId);
 assertThat(inputStream, notNullValue());
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testCaseDiagramNotExist() {
 // setup additional mock behavior
 when(repositoryServiceMock.getCaseDiagram(MockProvider.EXAMPLE_CASE_DEFINITION_ID)).thenReturn(null);
 // call method
 given().pathParam("id", MockProvider.EXAMPLE_CASE_DEFINITION_ID)
   .expect().statusCode(Status.NO_CONTENT.getStatusCode())
   .when().get(DIAGRAM_DEFINITION_URL);
 // verify service interaction
 verify(repositoryServiceMock).getCaseDefinition(MockProvider.EXAMPLE_CASE_DEFINITION_ID);
 verify(repositoryServiceMock).getCaseDiagram(MockProvider.EXAMPLE_CASE_DEFINITION_ID);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void getCaseDiagramDisabledTenantCheck() {
 processEngineConfiguration.setTenantCheckEnabled(false);
 identityService.setAuthentication("user", null, null);
 InputStream inputStream = repositoryService.getCaseDiagram(caseDefinitionId);
 assertThat(inputStream, notNullValue());
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void failToGetCaseDiagramNoAuthenticatedTenants() {
 identityService.setAuthentication("user", null, null);
 // declare expected exception
 thrown.expect(ProcessEngineException.class);
 thrown.expectMessage("Cannot get the case definition");
 repositoryService.getCaseDiagram(caseDefinitionId);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testCaseDiagramRetrieval() throws FileNotFoundException, URISyntaxException {
 // setup additional mock behavior
 File file = getFile("/processes/todo-process.png");
 when(repositoryServiceMock.getCaseDiagram(MockProvider.EXAMPLE_CASE_DEFINITION_ID))
   .thenReturn(new FileInputStream(file));
 // call method
 byte[] actual = given().pathParam("id", MockProvider.EXAMPLE_CASE_DEFINITION_ID)
   .expect()
    .statusCode(Status.OK.getStatusCode())
    .contentType("image/png")
    .header("Content-Disposition", "attachment; filename=" +
      MockProvider.EXAMPLE_CASE_DEFINITION_DIAGRAM_RESOURCE_NAME)
   .when().get(DIAGRAM_DEFINITION_URL).getBody().asByteArray();
 // verify service interaction
 verify(repositoryServiceMock).getCaseDefinition(MockProvider.EXAMPLE_CASE_DEFINITION_ID);
 verify(repositoryServiceMock).getCaseDiagram(MockProvider.EXAMPLE_CASE_DEFINITION_ID);
 // compare input stream with response body bytes
 byte[] expected = IoUtil.readInputStream(new FileInputStream(file), "case diagram");
 Assert.assertArrayEquals(expected, actual);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testCaseDiagramNullFilename() throws FileNotFoundException, URISyntaxException {
 // setup additional mock behavior
 File file = getFile("/processes/todo-process.png");
 when(repositoryServiceMock.getCaseDefinition(MockProvider.EXAMPLE_CASE_DEFINITION_ID).getDiagramResourceName())
  .thenReturn(null);
 when(repositoryServiceMock.getCaseDiagram(MockProvider.EXAMPLE_CASE_DEFINITION_ID))
   .thenReturn(new FileInputStream(file));
 // call method
 byte[] actual = given().pathParam("id", MockProvider.EXAMPLE_CASE_DEFINITION_ID)
  .expect()
  .statusCode(Status.OK.getStatusCode())
  .contentType("application/octet-stream")
  .header("Content-Disposition", "attachment; filename=" + null)
  .when().get(DIAGRAM_DEFINITION_URL).getBody().asByteArray();
 // verify service interaction
 verify(repositoryServiceMock).getCaseDiagram(MockProvider.EXAMPLE_CASE_DEFINITION_ID);
 // compare input stream with response body bytes
 byte[] expected = IoUtil.readInputStream(new FileInputStream(file), "case diagram");
 Assert.assertArrayEquals(expected, actual);
}

代码示例来源:origin: org.camunda.bpm/camunda-engine-rest-jaxrs2

@Override
public Response getCaseDefinitionDiagram() {
 CaseDefinition definition = engine.getRepositoryService().getCaseDefinition(caseDefinitionId);
 InputStream caseDiagram = engine.getRepositoryService().getCaseDiagram(caseDefinitionId);
 if (caseDiagram == null) {
  return Response.noContent().build();
 } else {
  String fileName = definition.getDiagramResourceName();
  return Response.ok(caseDiagram).header("Content-Disposition", "attachment; filename=" + fileName)
    .type(ProcessDefinitionResourceImpl.getMediaTypeForFileSuffix(fileName)).build();
 }
}

代码示例来源:origin: org.camunda.bpm/camunda-engine

@Test
public void getCaseDiagramWithAuthenticatedTenant() {
 identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
 InputStream inputStream = repositoryService.getCaseDiagram(caseDefinitionId);
 assertThat(inputStream, notNullValue());
}

代码示例来源:origin: org.camunda.bpm/camunda-engine

@Test
public void getCaseDiagramDisabledTenantCheck() {
 processEngineConfiguration.setTenantCheckEnabled(false);
 identityService.setAuthentication("user", null, null);
 InputStream inputStream = repositoryService.getCaseDiagram(caseDefinitionId);
 assertThat(inputStream, notNullValue());
}

代码示例来源:origin: org.camunda.bpm/camunda-engine

@Test
public void failToGetCaseDiagramNoAuthenticatedTenants() {
 identityService.setAuthentication("user", null, null);
 // declare expected exception
 thrown.expect(ProcessEngineException.class);
 thrown.expectMessage("Cannot get the case definition");
 repositoryService.getCaseDiagram(caseDefinitionId);
}

相关文章

微信公众号

最新文章

更多

RepositoryService类方法