diff options
Diffstat (limited to 'workflow-designer-be/src/main')
9 files changed, 35 insertions, 44 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 41f47674..2173c05a 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 @@ -1,7 +1,5 @@ package org.onap.sdc.workflow.api; -import static org.onap.sdc.workflow.api.RestConstants.USER_ID_HEADER_PARAM; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.onap.sdc.workflow.api.types.CollectionWrapper; @@ -9,11 +7,8 @@ import org.onap.sdc.workflow.persistence.types.Workflow; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; @RequestMapping("/workflows") @@ -26,13 +21,13 @@ public interface WorkflowController { @PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE) @ApiOperation("Create workflow") - ResponseEntity<?> create(Workflow workflow, String user); + ResponseEntity<Workflow> create(Workflow workflow, String user); - @GetMapping(path = "/{id}") + @GetMapping(path = "/{workflowId}") @ApiOperation("Get workflow") - Workflow get(String id, String user); + Workflow get(String workflowId, String user); - @PutMapping(path = "/{id}", consumes = MediaType.APPLICATION_JSON_VALUE) + @PutMapping(path = "/{workflowId}", consumes = MediaType.APPLICATION_JSON_VALUE) @ApiOperation("Update workflow") - Workflow update(Workflow workflow, String id, String user); + Workflow update(Workflow workflow, String workflowId, String user); } diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/impl/WorkflowControllerImpl.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/impl/WorkflowControllerImpl.java index f0b9f3ee..0d9ee4be 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/impl/WorkflowControllerImpl.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/impl/WorkflowControllerImpl.java @@ -31,22 +31,21 @@ public class WorkflowControllerImpl implements WorkflowController { } @Override - public ResponseEntity<?> create(@RequestBody Workflow workflow, @RequestHeader(USER_ID_HEADER_PARAM) String user) { - workflowManager.create(workflow); - return new ResponseEntity<>(workflow, HttpStatus.CREATED); + public ResponseEntity<Workflow> create(@RequestBody Workflow workflow, @RequestHeader(USER_ID_HEADER_PARAM) String user) { + return new ResponseEntity<>(workflowManager.create(workflow), HttpStatus.CREATED); } @Override - public Workflow get(@PathVariable("id") String id, @RequestHeader(USER_ID_HEADER_PARAM) String user) { + public Workflow get(@PathVariable("workflowId") String workflowId, @RequestHeader(USER_ID_HEADER_PARAM) String user) { Workflow workflow = new Workflow(); - workflow.setId(id); + workflow.setId(workflowId); return workflowManager.get(workflow); } @Override - public Workflow update(@RequestBody Workflow workflow, @PathVariable("id") String id, + public Workflow update(@RequestBody Workflow workflow, @PathVariable("workflowId") String workflowId, @RequestHeader(USER_ID_HEADER_PARAM) String user) { - workflow.setId(id); + workflow.setId(workflowId); workflowManager.update(workflow); return workflow; } diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/filters/SessionContextFilter.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/filters/SessionContextFilter.java index d4dc8a80..07d8eee7 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/filters/SessionContextFilter.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/filters/SessionContextFilter.java @@ -38,7 +38,6 @@ public class SessionContextFilter implements Filter { try { if (servletRequest instanceof HttpServletRequest) { - contextProvider.create(getUser(servletRequest), getTenant()); } @@ -54,7 +53,9 @@ public class SessionContextFilter implements Filter { } private String getUser(ServletRequest servletRequest) { - return ((HttpServletRequest) servletRequest).getHeader(USER_ID_HEADER_PARAM); + return "GLOBAL_USER"; + // TODO: 7/11/2018 get user from header when collaboration will be supported + //((HttpServletRequest) servletRequest).getHeader(USER_ID_HEADER_PARAM); } private String getTenant() { 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 565c4f5a..01c0b053 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 @@ -9,7 +9,7 @@ public interface WorkflowManager { Workflow get(Workflow workflow); - void create(Workflow workflow); + Workflow create(Workflow workflow); void update(Workflow workflow); } 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 cf1a7e18..8ac5025a 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 @@ -3,11 +3,11 @@ package org.onap.sdc.workflow.services.impl; import java.util.Collection; import java.util.function.Predicate; import java.util.stream.Collectors; -import org.onap.sdc.workflow.services.exceptions.EntityNotFoundException; -import org.onap.sdc.workflow.services.mappers.WorkflowMapper; import org.onap.sdc.workflow.persistence.types.Workflow; import org.onap.sdc.workflow.services.UniqueValueService; import org.onap.sdc.workflow.services.WorkflowManager; +import org.onap.sdc.workflow.services.exceptions.EntityNotFoundException; +import org.onap.sdc.workflow.services.impl.mappers.WorkflowMapper; import org.openecomp.sdc.versioning.ItemManager; import org.openecomp.sdc.versioning.types.Item; import org.openecomp.sdc.versioning.types.ItemStatus; @@ -18,13 +18,14 @@ import org.springframework.stereotype.Service; @Service("workflowManager") public class WorkflowManagerImpl implements WorkflowManager { - private static final String WORKFLOW_TYPE = "WORKFLOW"; + public static final String WORKFLOW_TYPE = "WORKFLOW"; private static final String WORKFLOW_NOT_FOUND_ERROR_MSG = "Workflow with id '%s' does not exist"; - protected static final Predicate<Item> ITEM_PREDICATE = item -> WORKFLOW_TYPE.equals(item.getType()); private static final String WORKFLOW_NAME_UNIQUE_TYPE = "WORKFLOW_NAME"; + static final Predicate<Item> ITEM_PREDICATE = item -> WORKFLOW_TYPE.equals(item.getType()); + private final ItemManager itemManager; private final UniqueValueService uniqueValueService; - private WorkflowMapper workflowMapper; + private final WorkflowMapper workflowMapper; @Autowired public WorkflowManagerImpl(ItemManager itemManager, @@ -36,8 +37,8 @@ public class WorkflowManagerImpl implements WorkflowManager { @Override public Collection<Workflow> list() { - return itemManager.list(ITEM_PREDICATE).stream() - .map(item -> workflowMapper.itemToWorkflow(item)).collect(Collectors.toList()); + return itemManager.list(ITEM_PREDICATE).stream().map(workflowMapper::itemToWorkflow) + .collect(Collectors.toList()); } @Override @@ -50,14 +51,14 @@ public class WorkflowManagerImpl implements WorkflowManager { } @Override - public void create(Workflow workflow) { + public Workflow create(Workflow workflow) { Item item = workflowMapper.workflowToItem(workflow); item.setStatus(ItemStatus.ACTIVE); - item.setType(WORKFLOW_TYPE); - uniqueValueService.validateUniqueValue(WORKFLOW_NAME_UNIQUE_TYPE, new String[]{workflow.getName()}); + uniqueValueService.validateUniqueValue(WORKFLOW_NAME_UNIQUE_TYPE, new String[] {workflow.getName()}); workflow.setId(itemManager.create(item).getId()); - uniqueValueService.createUniqueValue(WORKFLOW_NAME_UNIQUE_TYPE, new String[]{workflow.getName()}); + uniqueValueService.createUniqueValue(WORKFLOW_NAME_UNIQUE_TYPE, new String[] {workflow.getName()}); + return workflow; } @Override @@ -73,7 +74,6 @@ public class WorkflowManagerImpl implements WorkflowManager { item.setId(workflow.getId()); item.setStatus(retrievedItem.getStatus()); item.setVersionStatusCounters(retrievedItem.getVersionStatusCounters()); - item.setType(retrievedItem.getType()); itemManager.update(item); } } 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 dfcc6c63..e934efd3 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 @@ -19,7 +19,7 @@ import org.onap.sdc.workflow.services.exceptions.CreateVersionException; import org.onap.sdc.workflow.services.exceptions.EntityNotFoundException; import org.onap.sdc.workflow.services.exceptions.InvalidArtifactException; import org.onap.sdc.workflow.services.exceptions.VersionModificationException; -import org.onap.sdc.workflow.services.mappers.VersionMapper; +import org.onap.sdc.workflow.services.impl.mappers.VersionMapper; import org.openecomp.sdc.versioning.VersioningManager; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdc.versioning.types.VersionCreationMethod; diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/mappers/VersionMapper.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/VersionMapper.java index e36193f9..6e0c3d6d 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/mappers/VersionMapper.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/VersionMapper.java @@ -1,16 +1,9 @@ -package org.onap.sdc.workflow.services.mappers; +package org.onap.sdc.workflow.services.impl.mappers; -import java.util.Collections; -import java.util.Map; import org.mapstruct.InheritInverseConfiguration; import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Named; -import org.onap.sdc.workflow.persistence.types.WorkflowProperty; import org.onap.sdc.workflow.persistence.types.WorkflowVersion; -import org.onap.sdc.workflow.persistence.types.WorkflowVersionStatus; import org.openecomp.sdc.versioning.dao.types.Version; -import org.openecomp.sdc.versioning.dao.types.VersionStatus; @Mapper(componentModel = "spring", uses = VersionStatusMapper.class) public interface VersionMapper { diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/mappers/VersionStatusMapper.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/VersionStatusMapper.java index e9fe0a2e..1cdfd69e 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/mappers/VersionStatusMapper.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/VersionStatusMapper.java @@ -1,4 +1,4 @@ -package org.onap.sdc.workflow.services.mappers; +package org.onap.sdc.workflow.services.impl.mappers; import org.mapstruct.InheritInverseConfiguration; import org.mapstruct.Mapper; diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/mappers/WorkflowMapper.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/WorkflowMapper.java index f89441a7..34327ce7 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/mappers/WorkflowMapper.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/WorkflowMapper.java @@ -1,16 +1,19 @@ -package org.onap.sdc.workflow.services.mappers; +package org.onap.sdc.workflow.services.impl.mappers; import org.mapstruct.InheritInverseConfiguration; import org.mapstruct.Mapper; +import org.mapstruct.Mapping; import org.onap.sdc.workflow.persistence.types.Workflow; +import org.onap.sdc.workflow.services.impl.WorkflowManagerImpl; import org.openecomp.sdc.versioning.types.Item; -@Mapper(componentModel = "spring") +@Mapper(componentModel = "spring", imports = WorkflowManagerImpl.class) public interface WorkflowMapper { Workflow itemToWorkflow(Item item); @InheritInverseConfiguration + @Mapping(expression = "java(WorkflowManagerImpl.WORKFLOW_TYPE)", target = "type") Item workflowToItem(Workflow workflow); } |