Skip to content

Commit

Permalink
merged rollback branch in dev
Browse files Browse the repository at this point in the history
  • Loading branch information
LuciaM1 committed Nov 24, 2023
1 parent 26a0714 commit c021bd1
Showing 1 changed file with 6 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,16 @@
@ApplicationScoped
@Slf4j
public class WorkflowResourceServiceImpl implements WorkflowResourceService {

@Inject
WorkflowResourceRepository workflowResourceRepository;

@Inject
ResourceFileRepository resourceFileRepository;

@Inject
WorkflowResourceStorageService workflowResourceStorageService;

@Inject
@RestClient
ProcessClient processClient;


@Override
@WithTransaction
public Uni<WorkflowResource> save(WorkflowResource workflowResource) {
Expand Down Expand Up @@ -104,7 +99,6 @@ public Uni<Optional<WorkflowResource>> findByDefinitionKey(String definitionKey)
.onItem().transformToUni(x -> Uni.createFrom().item(Optional.ofNullable(x)));
}


public Uni<Boolean> checkWorkflowResourceFileExistence(UUID uuid) {
return this.findById(uuid)
.onItem()
Expand Down Expand Up @@ -201,7 +195,6 @@ public Uni<WorkflowResource> setDeployInfo(UUID uuid, DeployResponseDto response
WORKFLOW_FILE_DOES_NOT_EXIST);
}
WorkflowResource workflowResource = optionalWorkflowResource.get();

if (response.getDeployedProcessDefinitions() != null) {
Map<String, DeployedBPMNProcessDefinitionDto> deployedProcessDefinitions = response.getDeployedProcessDefinitions();
Optional<DeployedBPMNProcessDefinitionDto> optionalDeployedProcessDefinition = deployedProcessDefinitions.values()
Expand Down Expand Up @@ -302,7 +295,7 @@ public Uni<List<WorkflowResource>> getAll() {

@Override
@WithTransaction
public Uni<WorkflowResource> update(UUID id, File file,boolean isRollback) throws NoSuchAlgorithmException, IOException {
public Uni<WorkflowResource> update(UUID id, File file, boolean isRollback) throws NoSuchAlgorithmException, IOException {
return this.findById(id)
.onItem()
.transformToUni(Unchecked.function(workflow -> {
Expand Down Expand Up @@ -338,8 +331,6 @@ public Uni<WorkflowResource> update(UUID id, File file,boolean isRollback) throw
.onItem().transformToUni(updatedFile -> this.findById(id)
.onItem().transformToUni(optionalWorkflowResource -> Uni.createFrom().item(optionalWorkflowResource.get())));
}));


}

@Override
Expand All @@ -351,16 +342,16 @@ public Uni<WorkflowResource> rollback(UUID id) {
throw new AtmLayerException(Response.Status.NOT_FOUND, WORKFLOW_FILE_DOES_NOT_EXIST);
}
WorkflowResource workflowResourceToRollBack = workflow.get();
String camundaId=workflowResourceToRollBack.getCamundaDefinitionId();
if(camundaId==null){
throw new AtmLayerException("CamundaDefinitionId of the referenced resource is null: cannot rollback", Response.Status.NOT_FOUND,WORKFLOW_RESOURCE_NOT_DEPLOYED_CANNOT_ROLLBACK);
String camundaId = workflowResourceToRollBack.getCamundaDefinitionId();
if (camundaId == null) {
throw new AtmLayerException("CamundaDefinitionId of the referenced resource is null: cannot rollback", Response.Status.NOT_FOUND, WORKFLOW_RESOURCE_NOT_DEPLOYED_CANNOT_ROLLBACK);
}
return processClient.getDeployedResource(camundaId)
.onItem()
.transformToUni(Unchecked.function(file -> update(id,file,true)))
.transformToUni(Unchecked.function(file -> update(id, file, true)))
.onFailure()
.recoverWithUni(exception ->
Uni.createFrom().failure(new AtmLayerException("Error retrieving workflow resource from Process", Response.Status.INTERNAL_SERVER_ERROR,DEPLOYED_FILE_WAS_NOT_RETRIEVED))
Uni.createFrom().failure(new AtmLayerException("Error retrieving workflow resource from Process", Response.Status.INTERNAL_SERVER_ERROR, DEPLOYED_FILE_WAS_NOT_RETRIEVED))
);
}));
}
Expand Down

0 comments on commit c021bd1

Please sign in to comment.