use of bio.terra.common.exception.InconsistentFieldsException in project terra-workspace-manager by DataBiosphere.
the class MarkPrivateResourcesAbandonedStep method undoStep.
@Override
public StepResult undoStep(FlightContext context) throws InterruptedException {
FlightMap workingMap = context.getWorkingMap();
boolean userStillInWorkspace = workingMap.get(ControlledResourceKeys.REMOVED_USER_IS_WORKSPACE_MEMBER, Boolean.class);
// to private resources.
if (userStillInWorkspace) {
return StepResult.getStepResultSuccess();
}
List<ResourceRolePair> resourceRolePairs = workingMap.get(ControlledResourceKeys.RESOURCE_ROLES_TO_REMOVE, new TypeReference<>() {
});
List<ControlledResource> uniqueControlledResources = resourceRolePairs.stream().map(ResourceRolePair::getResource).distinct().collect(Collectors.toList());
for (ControlledResource resource : uniqueControlledResources) {
PrivateResourceState privateResourceState = resource.getPrivateResourceState().orElseThrow(() -> new InconsistentFieldsException("Received private resource without private resource state set"));
resourceDao.setPrivateResourceState(resource, privateResourceState);
}
return StepResult.getStepResultSuccess();
}
Aggregations