From 01cde8e3cd095919ba74ac1d5e750e4b6842ae64 Mon Sep 17 00:00:00 2001 From: vasraz Date: Thu, 25 May 2023 12:31:58 +0100 Subject: Remove need for USER_ID header Signed-off-by: Vasyl Razinkov Change-Id: I5dd1e34343bebec8a26786f402dc2b9b818e7f10 Issue-ID: SDC-4508 --- .../model/operations/impl/UserAdminOperation.java | 23 +++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'catalog-model') diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/UserAdminOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/UserAdminOperation.java index 64bc923857..1552aa3faa 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/UserAdminOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/UserAdminOperation.java @@ -21,14 +21,16 @@ package org.openecomp.sdc.be.model.operations.impl; import static org.apache.commons.collections.CollectionUtils.isEmpty; -import fj.data.Either; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.validation.constraints.NotNull; + +import fj.data.Either; import org.apache.commons.lang3.BooleanUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.tinkerpop.gremlin.structure.Direction; import org.apache.tinkerpop.gremlin.structure.Edge; import org.apache.tinkerpop.gremlin.structure.Vertex; @@ -119,14 +121,13 @@ public class UserAdminOperation { } private void validateUserExists(Wrapper> resultWrapper, Wrapper userWrapper, String id) { - if (id == null) { - log.info("User userId is empty"); - resultWrapper.setInnerElement(Either.right(ActionStatus.MISSING_USER_ID)); - return; + if (StringUtils.isBlank(id)) { + log.warn("User userId is empty"); + id = "cs0008"; } id = id.toLowerCase(); Either either = janusGraphGenericDao - .getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.User), id, UserData.class); + .getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.User), id, UserData.class); if (either.isRight()) { resultWrapper.setInnerElement(getUserNotFoundError(id, either.right().value())); } else { @@ -187,7 +188,7 @@ public class UserAdminOperation { public Either deleteUserData(String id) { Either result; Either eitherGet = janusGraphGenericDao - .getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.User), id, UserData.class); + .getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.User), id, UserData.class); if (eitherGet.isRight()) { log.debug("Problem while retriving user with userId {}", id); if (eitherGet.right().value() == JanusGraphOperationStatus.NOT_FOUND) { @@ -247,13 +248,13 @@ public class UserAdminOperation { public @NotNull List getUserPendingTasksList(User user, List states) { JanusGraphVertex userVertex = janusGraphGenericDao.getVertexByProperty(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.User), user.getUserId()) - .left().on(this::handleJanusGraphError); + .left().on(this::handleJanusGraphError); List pendingTasks = new ArrayList<>(); for (Object state : states) { Map property = new HashMap<>(); property.put(GraphPropertiesDictionary.STATE.getProperty(), state); List edges = janusGraphGenericDao.getOutgoingEdgesByCriteria(userVertex, GraphEdgeLabels.STATE, property).left() - .on(this::handleJanusGraphError); + .on(this::handleJanusGraphError); for (Edge edge : edges) { Vertex vertex = edge.inVertex(); if (!isComponentDeleted(vertex)) { @@ -301,7 +302,7 @@ public class UserAdminOperation { Object componentName = edge.inVertex().property(GraphPropertyEnum.NAME.getProperty()).value(); Object componentState = edge.inVertex().property(GraphPropertyEnum.STATE.getProperty()).value(); log.debug("The user userId = {} is working on the component name = {} uid = {} in state {}", user.getUserId(), componentName, - resourceUuid, componentState); + resourceUuid, componentState); } } } @@ -316,7 +317,7 @@ public class UserAdminOperation { propertiesToMatch.put(GraphPropertiesDictionary.USER_STATUS.getProperty(), status); } Either, JanusGraphOperationStatus> userNodes = janusGraphGenericDao - .getByCriteria(NodeTypeEnum.User, propertiesToMatch, UserData.class); + .getByCriteria(NodeTypeEnum.User, propertiesToMatch, UserData.class); janusGraphGenericDao.commit(); return convertToUsers(role, userNodes); } finally { -- cgit 1.2.3-korg