diff options
author | avigaffa <avi.gaffa@amdocs.com> | 2018-11-28 11:57:09 +0200 |
---|---|---|
committer | Vitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com> | 2018-11-28 12:57:01 +0000 |
commit | 069997b0692f69c8870718edf63f5703e848948d (patch) | |
tree | 0d4a7948228a6d2d9188f36642c4f8079176c4d9 /workflow-designer-be/src/main | |
parent | 958f25139cd0743c30fdc1b519be67ef9238f39e (diff) |
Workflow Deprecation - Archive Workflow
returning workflow archiving status in a field called "archiving" instead of "status" when listing workflows
Change-Id: Ib75696257ecef0ef0646c0465e0bf6cb6d0533c1
Issue-ID: SDC-1866
Signed-off-by: avigaffa <avi.gaffa@amdocs.com>
Diffstat (limited to 'workflow-designer-be/src/main')
11 files changed, 39 insertions, 40 deletions
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowController.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowController.java index 8eb22390..ff06f828 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowController.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowController.java @@ -35,12 +35,12 @@ import org.onap.sdc.workflow.api.types.WorkflowStatusDto; import org.onap.sdc.workflow.services.WorkflowManager; import org.onap.sdc.workflow.services.WorkflowVersionManager; import org.onap.sdc.workflow.services.annotations.UserId; +import org.onap.sdc.workflow.services.types.ArchivingStatus; import org.onap.sdc.workflow.services.types.Page; import org.onap.sdc.workflow.services.types.PagingRequest; import org.onap.sdc.workflow.services.types.RequestSpec; import org.onap.sdc.workflow.services.types.SortingRequest; import org.onap.sdc.workflow.services.types.Workflow; -import org.onap.sdc.workflow.services.types.WorkflowStatus; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.HttpStatus; @@ -126,7 +126,7 @@ public class WorkflowController { @ApiOperation("Update workflow status") public ResponseEntity updateStatus(@RequestBody @Valid WorkflowStatusDto request, @PathVariable("workflowId") String workflowId, @UserId String user) { - workflowManager.updateStatus(workflowId,WorkflowStatus.valueOf(request.getStatus())); + workflowManager.updateStatus(workflowId, ArchivingStatus.valueOf(request.getStatus())); return new ResponseEntity(HttpStatus.OK); } diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStatesFormatter.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStatesFormatter.java index ebc7d693..cc17f928 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStatesFormatter.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStatesFormatter.java @@ -45,9 +45,8 @@ public class VersionStatesFormatter { return value == null ? null : Arrays.stream(value.split(",")).map(WorkflowVersionState::valueOf) .collect(Collectors.toSet()); } catch (IllegalArgumentException ex) { - LOGGER.warn(String.format( - "value %s is invalid and cannot be formatted to a set of version states, therefore it set to empty set", - value), ex); + LOGGER.warn("value {} is invalid and cannot be formatted to a set of version states, " + + "therefore it set to empty set", value, ex); return Collections.emptySet(); } } diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/WorkflowStatusValidator.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/ArchivingStatusValidator.java index b99b424a..bfbf7580 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/WorkflowStatusValidator.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/ArchivingStatusValidator.java @@ -18,9 +18,9 @@ package org.onap.sdc.workflow.api.validation; import javax.validation.ConstraintValidator; import javax.validation.ConstraintValidatorContext; -import org.onap.sdc.workflow.services.types.WorkflowStatus; +import org.onap.sdc.workflow.services.types.ArchivingStatus; -public class WorkflowStatusValidator implements ConstraintValidator<ValidStatus, String> { +public class ArchivingStatusValidator implements ConstraintValidator<ValidStatus, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { @@ -28,7 +28,7 @@ public class WorkflowStatusValidator implements ConstraintValidator<ValidStatus, return false; } else { try { - Enum.valueOf(WorkflowStatus.class, value); + Enum.valueOf(ArchivingStatus.class, value); return true; } catch (IllegalArgumentException var3) { return false; diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/ValidStatus.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/ValidStatus.java index 96325919..15778b1d 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/ValidStatus.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/ValidStatus.java @@ -27,7 +27,7 @@ import javax.validation.Payload; @Target({ElementType.TYPE, ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) @Documented -@Constraint(validatedBy = {WorkflowStatusValidator.class}) +@Constraint(validatedBy = {ArchivingStatusValidator.class}) public @interface ValidStatus { String message(); diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/WorkflowManager.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/WorkflowManager.java index 0f8f27e2..2c7a7c24 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/WorkflowManager.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/WorkflowManager.java @@ -17,10 +17,10 @@ package org.onap.sdc.workflow.services; import java.util.Set; +import org.onap.sdc.workflow.services.types.ArchivingStatus; import org.onap.sdc.workflow.services.types.Page; import org.onap.sdc.workflow.services.types.RequestSpec; import org.onap.sdc.workflow.services.types.Workflow; -import org.onap.sdc.workflow.services.types.WorkflowStatus; import org.onap.sdc.workflow.services.types.WorkflowVersionState; public interface WorkflowManager { @@ -33,5 +33,5 @@ public interface WorkflowManager { void update(Workflow workflow); - void updateStatus(String workflowId, WorkflowStatus status); + void updateStatus(String workflowId, ArchivingStatus status); } diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/ActivitySpecManagerImpl.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/ActivitySpecManagerImpl.java index 3cfaf4ae..640affe8 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/ActivitySpecManagerImpl.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/ActivitySpecManagerImpl.java @@ -127,7 +127,7 @@ public class ActivitySpecManagerImpl implements ActivitySpecManager { public void update(ActivitySpecEntity activitySpec) { Item retrievedItem = itemManager.get(activitySpec.getId()); if (retrievedItem == null) { - LOGGER.error(String.format("Activity Spec with id %s was not found", activitySpec.getId())); + LOGGER.error("Activity Spec with id {} was not found", activitySpec.getId()); throw new EntityNotFoundException(ACTIVITY_SPEC_NOT_FOUND); } uniqueValueService.updateUniqueValue(ACTIVITY_SPEC_NAME, retrievedItem.getName(), activitySpec.getName()); diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImpl.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImpl.java index 27257b49..3d9cda51 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImpl.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImpl.java @@ -40,7 +40,7 @@ import org.onap.sdc.workflow.services.types.RequestSpec; import org.onap.sdc.workflow.services.types.Sort; import org.onap.sdc.workflow.services.types.SortingRequest; import org.onap.sdc.workflow.services.types.Workflow; -import org.onap.sdc.workflow.services.types.WorkflowStatus; +import org.onap.sdc.workflow.services.types.ArchivingStatus; import org.onap.sdc.workflow.services.types.WorkflowVersionState; import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.logging.api.Logger; @@ -94,6 +94,7 @@ public class WorkflowManagerImpl implements WorkflowManager { .skip(requestSpec.getPaging().getOffset()) .limit(requestSpec.getPaging().getLimit()) .collect(Collectors.toList()); + return new Page<>(workflowsSlice, requestSpec.getPaging(), workflowItems.size()); } @@ -101,7 +102,6 @@ public class WorkflowManagerImpl implements WorkflowManager { public Workflow get(Workflow workflow) { Item retrievedItem = itemManager.get(workflow.getId()); if (retrievedItem == null) { - LOGGER.error(String.format("Workflow with id %s was not found", workflow.getId())); throw new EntityNotFoundException(String.format(WORKFLOW_NOT_FOUND_ERROR_MSG, workflow.getId())); } return this.workflowMapper.itemToWorkflow(retrievedItem); @@ -123,7 +123,6 @@ public class WorkflowManagerImpl implements WorkflowManager { public void update(Workflow workflow) { Item retrievedItem = itemManager.get(workflow.getId()); if (retrievedItem == null) { - LOGGER.error(String.format("Workflow with id %s was not found", workflow.getId())); throw new EntityNotFoundException(String.format(WORKFLOW_NOT_FOUND_ERROR_MSG, workflow.getId())); } @@ -141,16 +140,15 @@ public class WorkflowManagerImpl implements WorkflowManager { } @Override - public void updateStatus(String workflowId, WorkflowStatus status) { + public void updateStatus(String workflowId, ArchivingStatus status) { Item item = itemManager.get(workflowId); if (item == null) { - LOGGER.error(String.format("Workflow with id %s was not found",workflowId)); throw new EntityNotFoundException(String.format(WORKFLOW_NOT_FOUND_ERROR_MSG, workflowId)); } try { - if (WorkflowStatus.ARCHIVED.equals(status)) { + if (ArchivingStatus.ARCHIVED.equals(status)) { itemManager.archive(item); - } else if (WorkflowStatus.ACTIVE.equals(status)) { + } else if (ArchivingStatus.ACTIVE.equals(status)) { itemManager.restore(item); } } catch (CoreException ex) { @@ -158,7 +156,7 @@ public class WorkflowManagerImpl implements WorkflowManager { } } - private static RequestSpec getRequestSpec(RequestSpec requestSpec) { + private static RequestSpec getRequestSpec(RequestSpec requestSpec) { if (requestSpec == null) { return WORKSPACES_DEFAULT_REQUEST_SPEC; } @@ -196,10 +194,10 @@ public class WorkflowManagerImpl implements WorkflowManager { private Predicate<Item> createFilter(String itemStatusFilter, String searchNameFilter, Set<WorkflowVersionState> versionStatesFilter) { - Set<VersionStatus> versionStatusesFilter = - versionStatesFilter == null ? null : - versionStatesFilter.stream().map(versionStateMapper::workflowVersionStateToVersionStatus) - .collect(Collectors.toSet()); + Set<VersionStatus> versionStatusesFilter = versionStatesFilter == null ? null : + versionStatesFilter.stream() + .map(versionStateMapper::workflowVersionStateToVersionStatus) + .collect(Collectors.toSet()); Predicate<Item> filter = addSearchNameFilter(WORKFLOW_ITEM_TYPE_FILTER, searchNameFilter); @@ -210,13 +208,13 @@ public class WorkflowManagerImpl implements WorkflowManager { } private static Predicate<Item> addSearchNameFilter(Predicate<Item> filter, String searchNameFilter) { - return filter.and(item -> searchNameFilter == null - || item.getName().toLowerCase().contains(searchNameFilter.toLowerCase())); + return filter.and(item -> searchNameFilter == null || item.getName().toLowerCase() + .contains(searchNameFilter.toLowerCase())); } private static Predicate<Item> addVersionStatusFilter(Predicate<Item> filter, Set<VersionStatus> versionStatuses) { - return filter.and(item -> versionStatuses == null - || item.getVersionStatusCounters().keySet().stream().anyMatch(versionStatuses::contains)); + return filter.and(item -> versionStatuses == null || item.getVersionStatusCounters().keySet().stream() + .anyMatch(versionStatuses::contains)); } private static Predicate<Item> addItemStatusFilter(Predicate<Item> filter, String itemStatusFilter) { @@ -224,7 +222,7 @@ public class WorkflowManagerImpl implements WorkflowManager { try { ItemStatus.valueOf(itemStatusFilter.toUpperCase()); } catch (IllegalArgumentException e) { - LOGGER.debug(String.format("Illegal Workflow status filter: %s. Ignoring filter", itemStatusFilter)); + LOGGER.debug("Illegal Workflow status filter: {}. Ignoring filter", itemStatusFilter, e); return filter; } return filter.and(item -> item.getStatus().equals(ItemStatus.valueOf(itemStatusFilter.toUpperCase()))); diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java index 5eba8d4a..0078d226 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java @@ -215,10 +215,10 @@ public class WorkflowVersionManagerImpl implements WorkflowVersionManager { getVersion(workflowId, versionId); Optional<ArtifactEntity> artifactOptional = artifactRepository.get(workflowId, versionId); if (!artifactOptional.isPresent()) { - LOGGER.error(String.format("Workflow Version Artifact was not found for workflow id %s and version id %s", - workflowId, versionId)); + LOGGER.error("Workflow Version Artifact was not found for workflow id {} and version id {}", + workflowId, versionId); throw new EntityNotFoundException( - String.format("Artifact for workflow id %S version id %S was not found", workflowId, versionId)); + String.format("Artifact for workflow id %s version id %s was not found", workflowId, versionId)); } return artifactOptional.get(); } @@ -228,9 +228,8 @@ public class WorkflowVersionManagerImpl implements WorkflowVersionManager { validateWorkflowStatus(workflowId); WorkflowVersion retrievedVersion = get(workflowId, versionId); if (CERTIFIED.equals(retrievedVersion.getState())) { - LOGGER.error(String.format( - "Workflow Version is certified and can not be edited.Workflow id %s and version id %s", workflowId, - versionId)); + LOGGER.error("Workflow Version is certified and can not be edited.Workflow id {} and version id {}", + workflowId, versionId); throw new VersionModificationException(workflowId, versionId); } @@ -302,7 +301,7 @@ public class WorkflowVersionManagerImpl implements WorkflowVersionManager { return versions.stream().filter(version -> versionId.equals(version.getId())).findFirst(); } - protected void validateWorkflowStatus(String workflowId) { + void validateWorkflowStatus(String workflowId) { Item workflowItem = itemManager.get(workflowId); if (ItemStatus.ARCHIVED.equals(workflowItem.getStatus())) { throw new WorkflowModificationException(workflowId); diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/WorkflowMapper.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/WorkflowMapper.java index 1ca7c713..b7426670 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/WorkflowMapper.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/WorkflowMapper.java @@ -27,7 +27,8 @@ import org.openecomp.sdc.versioning.types.Item; @Mapper(componentModel = "spring", imports = ItemType.class, uses = VersionStateMapper.class) public interface WorkflowMapper { - @Mapping(source = "versionStatusCounters", target = "versionStates") + @Mappings({@Mapping(source = "versionStatusCounters", target = "versionStates"), + @Mapping(source = "status", target = "archiving")}) Workflow itemToWorkflow(Item item); @InheritInverseConfiguration diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/WorkflowStatus.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/ArchivingStatus.java index 6df7ff30..2e7eb22b 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/WorkflowStatus.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/ArchivingStatus.java @@ -16,7 +16,7 @@ package org.onap.sdc.workflow.services.types; -public enum WorkflowStatus { +public enum ArchivingStatus { ARCHIVED, ACTIVE } diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/Workflow.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/Workflow.java index 0c0179e2..fcac779f 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/Workflow.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/Workflow.java @@ -33,11 +33,13 @@ public class Workflow { private String id; @NotBlank(message = "Workflow name may not be blank.") - @Size(min = MIN_LENGTH, max = MAX_LENGTH, message = "Workflow name must be at least " + MIN_LENGTH + " characters, and no more than " + MAX_LENGTH +" characters.") + @Size(min = MIN_LENGTH, max = MAX_LENGTH, + message = "Workflow name must be at least " + MIN_LENGTH + " characters, and no more than " + MAX_LENGTH + + " characters.") @Pattern(regexp = "[A-Za-z0-9_. -]+", message = "Workflow name must contain only letters, digits and underscores.") private String name; private String description; private Set<WorkflowVersionState> versionStates; private Collection<WorkflowVersion> versions; - private WorkflowStatus status; + private ArchivingStatus archiving; } |