From 280f8015d06af1f41a3ef12e8300801c7a5e0d54 Mon Sep 17 00:00:00 2001 From: AviZi Date: Fri, 9 Jun 2017 02:39:56 +0300 Subject: [SDC-29] Amdocs OnBoard 1707 initial commit. Change-Id: Ie4d12a3f574008b792899b368a0902a8b46b5370 Signed-off-by: AviZi --- .../org/openecomp/sdc/action/ActionConstants.java | 7 +- .../sdc/action/dao/ActionArtifactDao.java | 7 +- .../sdc/action/dao/ActionArtifactDaoFactory.java | 1 + .../org/openecomp/sdc/action/dao/ActionDao.java | 18 +-- .../sdc/action/dao/types/ActionEntity.java | 22 +--- .../sdc/action/dao/types/EcompComponentEntity.java | 73 ----------- .../action/dao/types/OpenEcompComponentEntity.java | 73 +++++++++++ .../sdc/action/errors/ActionErrorConstants.java | 22 ++-- .../sdc/action/errors/ActionException.java | 21 ++++ .../sdc/action/errors/ActionExceptionMapper.java | 134 +++++++++++++-------- .../org/openecomp/sdc/action/types/Action.java | 18 +-- .../openecomp/sdc/action/types/ActionArtifact.java | 1 + .../openecomp/sdc/action/types/ActionRequest.java | 2 +- .../sdc/action/types/ActionSubOperation.java | 2 +- .../openecomp/sdc/action/types/EcompComponent.java | 104 ---------------- .../sdc/action/types/OpenEcompComponent.java | 104 ++++++++++++++++ .../org/openecomp/sdc/action/util/ActionUtil.java | 39 +++--- 17 files changed, 348 insertions(+), 300 deletions(-) delete mode 100644 openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/types/EcompComponentEntity.java create mode 100644 openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/types/OpenEcompComponentEntity.java delete mode 100644 openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/EcompComponent.java create mode 100644 openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/OpenEcompComponent.java (limited to 'openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java') diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/ActionConstants.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/ActionConstants.java index 625ce7efe8..fd6c76c92c 100644 --- a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/ActionConstants.java +++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/ActionConstants.java @@ -20,13 +20,14 @@ package org.openecomp.sdc.action; + public class ActionConstants { // public static final long MAX_ACTION_ARTIFACT_SIZE = 20 * 1024 * 1024; //20 MB //REST layer constants - public static final String X_ECOMP_INSTANCE_ID_HEADER_PARAM = "X-ECOMP-InstanceID"; - public static final String X_ECOMP_REQUEST_ID_HEADER_PARAM = "X-ECOMP-RequestID"; + public static final String X_OPEN_ECOMP_INSTANCE_ID_HEADER_PARAM = "X-OPEN-ECOMP-InstanceID"; + public static final String X_OPEN_ECOMP_REQUEST_ID_HEADER_PARAM = "X-OPEN-ECOMP-RequestID"; public static final String WWW_AUTHENTICATE_HEADER_PARAM = "WWW-Authenticate"; public static final String ACTION_REQUEST_PARAM_NAME = "name"; @@ -66,7 +67,7 @@ public class ActionConstants { public static final String FILTER_TYPE_CATEGORY = "CATEGORY"; public static final String FILTER_TYPE_NAME = "NAME"; public static final String FILTER_TYPE_MODEL = "MODEL"; - public static final String FILTER_TYPE_ECOMP_COMPONENT = "ECOMP_COMPONENT"; + public static final String FILTER_TYPE_OPEN_ECOMP_COMPONENT = "OPEN_ECOMP_COMPONENT"; public static final String FILTER_TYPE_NONE = "NONE"; public static final String ARTIFACT_METADATA_ATTR_UUID = "ARTIFACT_UUID"; diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/ActionArtifactDao.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/ActionArtifactDao.java index a120645512..746a3b654d 100644 --- a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/ActionArtifactDao.java +++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/ActionArtifactDao.java @@ -24,11 +24,12 @@ import org.openecomp.core.dao.BaseDao; import org.openecomp.sdc.action.dao.types.ActionArtifactEntity; import org.openecomp.sdc.action.types.ActionArtifact; + public interface ActionArtifactDao extends BaseDao { - void uploadArtifact(ActionArtifact data); + public void uploadArtifact(ActionArtifact data); - ActionArtifact downloadArtifact(int effectiveVersion, String artifactUuId); + public ActionArtifact downloadArtifact(int effectiveVersion, String artifactUuId); - void updateArtifact(ActionArtifact data); + public void updateArtifact(ActionArtifact data); } diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/ActionArtifactDaoFactory.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/ActionArtifactDaoFactory.java index f0936976ba..51377a18f1 100644 --- a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/ActionArtifactDaoFactory.java +++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/ActionArtifactDaoFactory.java @@ -23,6 +23,7 @@ package org.openecomp.sdc.action.dao; import org.openecomp.core.factory.api.AbstractComponentFactory; import org.openecomp.core.factory.api.AbstractFactory; + public abstract class ActionArtifactDaoFactory extends AbstractComponentFactory { public static ActionArtifactDaoFactory getInstance() { diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/ActionDao.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/ActionDao.java index 01f5014ad4..ed6dfcca52 100644 --- a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/ActionDao.java +++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/ActionDao.java @@ -24,28 +24,28 @@ import org.openecomp.core.dao.BaseDao; import org.openecomp.sdc.action.dao.types.ActionEntity; import org.openecomp.sdc.action.errors.ActionException; import org.openecomp.sdc.action.types.Action; -import org.openecomp.sdc.action.types.EcompComponent; +import org.openecomp.sdc.action.types.OpenEcompComponent; import org.openecomp.sdc.versioning.dao.VersionableDao; import java.util.List; public interface ActionDao extends VersionableDao, BaseDao { - Action createAction(Action actionDto) throws ActionException; + public Action createAction(Action actionDto) throws ActionException; - Action updateAction(Action actionDto) throws ActionException; + public Action updateAction(Action actionDto) throws ActionException; - void deleteAction(String actionInvariantUuId) throws ActionException; + public void deleteAction(String actionInvariantUuId) throws ActionException; - List getFilteredActions(String filterType, String filterId) throws ActionException; + public List getFilteredActions(String filterType, String filterId) throws ActionException; - Action getActionsByActionUuId(String uniqueId) throws ActionException; + public Action getActionsByActionUuId(String uniqueId) throws ActionException; - List getEcompComponents() throws ActionException; + public List getOpenEcompComponents() throws ActionException; - List getActionsByActionInvariantUuId(String actionInvariantUuId) + public List getActionsByActionInvariantUuId(String actionInvariantUuId) throws ActionException; - Action getLockedAction(String actionInvariantUuId, String user) throws ActionException; + public Action getLockedAction(String actionInvariantUuId, String user) throws ActionException; } diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/types/ActionEntity.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/types/ActionEntity.java index 9aa9e8d375..2c2bfe3ae9 100644 --- a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/types/ActionEntity.java +++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/types/ActionEntity.java @@ -28,19 +28,19 @@ import org.openecomp.core.utilities.json.JsonUtil; import org.openecomp.sdc.action.types.Action; import org.openecomp.sdc.versioning.dao.types.Version; - import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.stream.Collectors; + @Table(keyspace = "dox", name = "Action") public class ActionEntity { - @Column(name = "actionUUID") + @Column(name = "actionUuId") private String actionUuId; @PartitionKey(value = 0) - @Column(name = "actionInvariantUUID") + @Column(name = "actionInvariantUuId") private String actionInvariantUuId; @PartitionKey(value = 1) @Frozen @@ -124,7 +124,7 @@ public class ActionEntity { */ public void setVendorList(List vendorList) { if (vendorList != null && !vendorList.isEmpty()) { - List lowerCaseVendorList = new ArrayList<>(); + List lowerCaseVendorList = new ArrayList(); lowerCaseVendorList .addAll(vendorList.stream().map(String::toLowerCase).collect(Collectors.toList())); this.vendorList = lowerCaseVendorList; @@ -144,7 +144,7 @@ public class ActionEntity { */ public void setCategoryList(List categoryList) { if (categoryList != null && !categoryList.isEmpty()) { - List lowerCaseCategoryList = new ArrayList<>(); + List lowerCaseCategoryList = new ArrayList(); lowerCaseCategoryList .addAll(categoryList.stream().map(String::toLowerCase).collect(Collectors.toList())); this.categoryList = lowerCaseCategoryList; @@ -209,16 +209,4 @@ public class ActionEntity { return destination; } - /*private List> createMapFromList(List list, String idName){ - List> keyValueList = new ArrayList<>(); - if(list != null && !list.isEmpty()){ - for(String attributeId : list){ - HashMap attributeIdMap = new HashMap<>(); - attributeIdMap.put(idName,attributeId); - keyValueList.add(attributeIdMap); - } - return keyValueList; - } - return null; - }*/ } diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/types/EcompComponentEntity.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/types/EcompComponentEntity.java deleted file mode 100644 index 9a71023629..0000000000 --- a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/types/EcompComponentEntity.java +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.action.dao.types; - -import com.datastax.driver.mapping.annotations.Column; -import com.datastax.driver.mapping.annotations.PartitionKey; -import com.datastax.driver.mapping.annotations.Table; -import org.openecomp.sdc.action.types.EcompComponent; - -@Table(keyspace = "dox", name = "ECOMPComponent") -public class EcompComponentEntity { - - @PartitionKey - @Column(name = "id") - private String id; - - @Column(name = "name") - private String name; - - public EcompComponentEntity() { - } - - public EcompComponentEntity(String id, String name) { - this.id = id; - this.name = name; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - /** - * To dto ecomp component. - * - * @return the ecomp component - */ - public EcompComponent toDto() { - EcompComponent destination = new EcompComponent(); - destination.setId(this.getId()); - destination.setName(this.getName()); - return destination; - } -} diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/types/OpenEcompComponentEntity.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/types/OpenEcompComponentEntity.java new file mode 100644 index 0000000000..326da718dd --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/types/OpenEcompComponentEntity.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.action.dao.types; + +import com.datastax.driver.mapping.annotations.Column; +import com.datastax.driver.mapping.annotations.PartitionKey; +import com.datastax.driver.mapping.annotations.Table; +import org.openecomp.sdc.action.types.OpenEcompComponent; + +@Table(keyspace = "dox", name = "EcompComponent") +public class OpenEcompComponentEntity { + + @PartitionKey + @Column(name = "id") + private String id; + + @Column(name = "name") + private String name; + + public OpenEcompComponentEntity() { + } + + public OpenEcompComponentEntity(String id, String name) { + this.id = id; + this.name = name; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * To dto OPENECOMP component. + * + * @return the OPENECOMP component + */ + public OpenEcompComponent toDto() { + OpenEcompComponent destination = new OpenEcompComponent(); + destination.setId(this.getId()); + destination.setName(this.getName()); + return destination; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionErrorConstants.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionErrorConstants.java index 092d9abee5..9eff8a7050 100644 --- a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionErrorConstants.java +++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionErrorConstants.java @@ -20,6 +20,9 @@ package org.openecomp.sdc.action.errors; +/** + * Action Library Error Constants for Error codes and user-friendly detailed error messages. + */ public class ActionErrorConstants { //Error Codes @@ -65,6 +68,7 @@ public class ActionErrorConstants { public static final String ACTION_DELETE_ON_LOCKED_ENTITY_CODE = "ACT1048"; public static final String ACTION_INTERNAL_SERVER_ERR_CODE = "ACT1060"; + //Logging Query failure Response code public static final String ACTION_QUERY_FAILURE_CODE = "QUERY_FAILURE"; public static final String ACTION_QUERY_FAILURE_MSG = "Query Failure"; @@ -74,10 +78,10 @@ public class ActionErrorConstants { //"The API failed due to missing body"; public static final String ACTION_REQUEST_MISSING_MANDATORY_PARAM = "Missing mandatory parameter(s) : "; - public static final String ACTION_REQUEST_ECOMP_INSTANCE_ID_INVALID = - "X-ECOMP-InstanceID HTTP header missing or empty"; - public static final String ACTION_REQUEST_ECOMP_REQUEST_ID_INVALID = - "X-ECOMP-RequestID HTTP header missing or empty"; + public static final String ACTION_REQUEST_OPEN_ECOMP_INSTANCE_ID_INVALID = + "X-OPEN-ECOMP-InstanceID HTTP header missing or empty"; + public static final String ACTION_REQUEST_OPEN_ECOMP_REQUEST_ID_INVALID = + "X-OPEN-ECOMP-RequestID HTTP header missing or empty"; public static final String ACTION_REQUEST_CONTENT_TYPE_INVALID = "Content-Type HTTP header missing or empty"; public static final String ACTION_REQUEST_AUTHORIZATION_HEADER_INVALID = @@ -95,8 +99,8 @@ public class ActionErrorConstants { "Invalid artifact protection value"; public static final String ACTION_ARTIFACT_INVALID_NAME = - "Artifact name cannot contain any of the following characters : #<>$+%!`&*'|{}?=/:@ " - + "including whitespaces, double quotes and back-slash"; + "Artifact name cannot contain any of the following characters : #<>$+%!`&*'|{}?=/:@ including" + + " whitespaces, double quotes and back-slash"; public static final String ACTION_ARTIFACT_READ_FILE_ERROR = "Error Occurred while reading file"; public static final String ACTION_REQUEST_ARTIFACT_OPERATION_ALLOWED = "Artifacts cannot be created/updated using this operation"; @@ -116,7 +120,7 @@ public class ActionErrorConstants { public static final String ACTION_ARTIFACT_ALREADY_EXISTS = "Artifact name already exists for Action with id %s. Please use another name."; public static final String ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG = - "The request failed due to an internal ASDC problem. ECOMP Component should continue the " + "The request failed due to an internal ASDC problem. Open ECOMP Component should continue the " + "attempts, with corrected data if required, to create the resource."; public static final String ACTION_ARTIFACT_DELETE_READ_ONLY_MSG = "Cannot delete read only artifact."; @@ -131,6 +135,6 @@ public class ActionErrorConstants { public static final String UNDO_CHECKOUT_ON_UNLOCKED_ENTITY_MSG = "Can not undo checkout on versionable entity %s with id %s since it is not checked out."; public static final String UNDO_CHECKOUT_ON_ENTITY_LOCKED_BY_OTHER_USER_MSG = - "Can not undo checkout on versionable entity %s with id" - + " %s since it is checked out by other user: %s."; + "Can not undo checkout on versionable entity %s with id %s since it is checked out by other " + + "user: %s."; } diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionException.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionException.java index fff88d6f84..08db9e241a 100644 --- a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionException.java +++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionException.java @@ -20,18 +20,31 @@ package org.openecomp.sdc.action.errors; +import org.openecomp.sdc.action.util.ActionUtil; + +/** + * Custom Exception class for handling Action Library error scenarios. + */ public class ActionException extends RuntimeException { private String errorCode; private String description; + private int logResponseCode; public ActionException() { } + /** + * Instantiates a new Action exception. + * + * @param errorCode the error code + * @param description the description + */ public ActionException(String errorCode, String description) { this.errorCode = errorCode; this.description = description; + this.logResponseCode = ActionUtil.getLogResponseCode(this.errorCode); } public String getErrorCode() { @@ -49,4 +62,12 @@ public class ActionException extends RuntimeException { public void setDescription(String description) { this.description = description; } + + public int getLogResponseCode() { + return logResponseCode; + } + + public void setLogResponseCode(int logResponseCode) { + this.logResponseCode = logResponseCode; + } } diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionExceptionMapper.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionExceptionMapper.java index 23c14aaaa2..98e1c6938a 100644 --- a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionExceptionMapper.java +++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionExceptionMapper.java @@ -20,92 +20,132 @@ package org.openecomp.sdc.action.errors; -import org.openecomp.sdc.action.ActionConstants; +import static org.openecomp.sdc.action.ActionConstants.WWW_AUTHENTICATE_HEADER_PARAM; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_ALREADY_EXISTS_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_CHECKSUM_ERROR_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_DELETE_READ_ONLY; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_DEL_LOCKED_OTHER_USER_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_INVALID_NAME_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_INVALID_PROTECTION_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_TOO_BIG_ERROR_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_UPDATE_READ_ONLY; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_AUTHENTICATION_ERR_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_AUTHORIZATION_ERR_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_CHECKIN_ON_ENTITY_LOCKED_BY_OTHER_USER; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_CHECKIN_ON_UNLOCKED_ENTITY; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_CHECKOUT_ON_LOCKED_ENTITY; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_CHECKOUT_ON_LOCKED_ENTITY_OTHER_USER; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_DELETE_ON_LOCKED_ENTITY_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_EDIT_ON_ENTITY_LOCKED_BY_OTHER_USER; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_NOT_EXIST_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_UNIQUE_VALUE_ERROR; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INTERNAL_SERVER_ERR_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_INSTANCE_ID_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_PARAM_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_REQUEST_BODY_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_REQUEST_ID_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_SEARCH_CRITERIA; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_MULT_SEARCH_CRITERIA; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_NOT_LOCKED_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_AUTHORIZATION_HEADER_INVALID; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_INVALID_GENERIC_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_SUBMIT_FINALIZED_ENTITY_NOT_ALLOWED; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_SUBMIT_LOCKED_ENTITY_NOT_ALLOWED; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_UNDO_CHECKOUT_ON_ENTITY_LOCKED_BY_OTHER_USER; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_UNDO_CHECKOUT_ON_UNLOCKED_ENTITY; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_UPDATE_INVALID_VERSION; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_UPDATE_NOT_ALLOWED_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_UPDATE_NOT_ALLOWED_CODE_NAME; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_UPDATE_NOT_ALLOWED_FOR_NAME; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_UPDATE_ON_UNLOCKED_ENTITY; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.ext.ExceptionMapper; +/** + * Mapper class to map Action Library exceptions to corresponding HTTP Response objects. + */ public class ActionExceptionMapper implements ExceptionMapper { @Override - public Response toResponse(ActionException actionException) { + public Response toResponse(ActionException exception) { Response response; - String errorCode = actionException.getErrorCode(); + String errorCode = exception.getErrorCode(); switch (errorCode) { - case ActionErrorConstants.ACTION_REQUEST_INVALID_GENERIC_CODE: - case ActionErrorConstants.ACTION_INVALID_INSTANCE_ID_CODE: - case ActionErrorConstants.ACTION_INVALID_REQUEST_ID_CODE: - case ActionErrorConstants.ACTION_INVALID_REQUEST_BODY_CODE: - case ActionErrorConstants.ACTION_INVALID_PARAM_CODE: - case ActionErrorConstants.ACTION_UPDATE_NOT_ALLOWED_FOR_NAME: - case ActionErrorConstants.ACTION_CHECKOUT_ON_LOCKED_ENTITY: - case ActionErrorConstants.ACTION_ENTITY_UNIQUE_VALUE_ERROR: - case ActionErrorConstants.ACTION_INVALID_SEARCH_CRITERIA: - case ActionErrorConstants.ACTION_MULT_SEARCH_CRITERIA: - case ActionErrorConstants.ACTION_UPDATE_ON_UNLOCKED_ENTITY: - case ActionErrorConstants.ACTION_UPDATE_INVALID_VERSION: - case ActionErrorConstants.ACTION_UPDATE_NOT_ALLOWED_CODE: - case ActionErrorConstants.ACTION_CHECKIN_ON_UNLOCKED_ENTITY: - case ActionErrorConstants.ACTION_SUBMIT_FINALIZED_ENTITY_NOT_ALLOWED: - case ActionErrorConstants.ACTION_SUBMIT_LOCKED_ENTITY_NOT_ALLOWED: - case ActionErrorConstants.ACTION_UNDO_CHECKOUT_ON_UNLOCKED_ENTITY: - case ActionErrorConstants.ACTION_UPDATE_NOT_ALLOWED_CODE_NAME: - case ActionErrorConstants.ACTION_ARTIFACT_CHECKSUM_ERROR_CODE: - case ActionErrorConstants.ACTION_ARTIFACT_ALREADY_EXISTS_CODE: - case ActionErrorConstants.ACTION_ARTIFACT_INVALID_NAME_CODE: - case ActionErrorConstants.ACTION_ARTIFACT_TOO_BIG_ERROR_CODE: - case ActionErrorConstants.ACTION_ARTIFACT_INVALID_PROTECTION_CODE: - case ActionErrorConstants.ACTION_ARTIFACT_DELETE_READ_ONLY: - case ActionErrorConstants.ACTION_NOT_LOCKED_CODE: + case ACTION_REQUEST_INVALID_GENERIC_CODE: + case ACTION_INVALID_INSTANCE_ID_CODE: + case ACTION_INVALID_REQUEST_ID_CODE: + case ACTION_INVALID_REQUEST_BODY_CODE: + case ACTION_INVALID_PARAM_CODE: + case ACTION_UPDATE_NOT_ALLOWED_FOR_NAME: + case ACTION_CHECKOUT_ON_LOCKED_ENTITY: + case ACTION_ENTITY_UNIQUE_VALUE_ERROR: + case ACTION_INVALID_SEARCH_CRITERIA: + case ACTION_MULT_SEARCH_CRITERIA: + case ACTION_UPDATE_ON_UNLOCKED_ENTITY: + case ACTION_UPDATE_INVALID_VERSION: + case ACTION_UPDATE_NOT_ALLOWED_CODE: + case ACTION_CHECKIN_ON_UNLOCKED_ENTITY: + case ACTION_SUBMIT_FINALIZED_ENTITY_NOT_ALLOWED: + case ACTION_SUBMIT_LOCKED_ENTITY_NOT_ALLOWED: + case ACTION_UNDO_CHECKOUT_ON_UNLOCKED_ENTITY: + case ACTION_UPDATE_NOT_ALLOWED_CODE_NAME: + case ACTION_ARTIFACT_CHECKSUM_ERROR_CODE: + case ACTION_ARTIFACT_ALREADY_EXISTS_CODE: + case ACTION_ARTIFACT_INVALID_NAME_CODE: + case ACTION_ARTIFACT_TOO_BIG_ERROR_CODE: + case ACTION_ARTIFACT_INVALID_PROTECTION_CODE: + case ACTION_ARTIFACT_DELETE_READ_ONLY: + case ACTION_NOT_LOCKED_CODE: response = Response .status(Response.Status.BAD_REQUEST) .entity(new ActionExceptionResponse(errorCode, - Response.Status.BAD_REQUEST.getReasonPhrase(), actionException.getDescription())) + Response.Status.BAD_REQUEST.getReasonPhrase(), exception.getDescription())) .type(MediaType.APPLICATION_JSON) .build(); break; - case ActionErrorConstants.ACTION_AUTHENTICATION_ERR_CODE: + case ACTION_AUTHENTICATION_ERR_CODE: response = Response .status(Response.Status.UNAUTHORIZED) - .header(ActionConstants.WWW_AUTHENTICATE_HEADER_PARAM, - ActionErrorConstants.ACTION_REQUEST_AUTHORIZATION_HEADER_INVALID) + .header(WWW_AUTHENTICATE_HEADER_PARAM, ACTION_REQUEST_AUTHORIZATION_HEADER_INVALID) .entity(new ActionExceptionResponse(errorCode, - Response.Status.UNAUTHORIZED.getReasonPhrase(), actionException.getDescription())) + Response.Status.UNAUTHORIZED.getReasonPhrase(), exception.getDescription())) .type(MediaType.APPLICATION_JSON) .build(); break; - case ActionErrorConstants.ACTION_AUTHORIZATION_ERR_CODE: - case ActionErrorConstants.ACTION_EDIT_ON_ENTITY_LOCKED_BY_OTHER_USER: - case ActionErrorConstants.ACTION_CHECKIN_ON_ENTITY_LOCKED_BY_OTHER_USER: - case ActionErrorConstants.ACTION_CHECKOUT_ON_LOCKED_ENTITY_OTHER_USER: - case ActionErrorConstants.ACTION_UNDO_CHECKOUT_ON_ENTITY_LOCKED_BY_OTHER_USER: - case ActionErrorConstants.ACTION_DELETE_ON_LOCKED_ENTITY_CODE: - case ActionErrorConstants.ACTION_ARTIFACT_DEL_LOCKED_OTHER_USER_CODE: - case ActionErrorConstants.ACTION_ARTIFACT_UPDATE_READ_ONLY: + case ACTION_AUTHORIZATION_ERR_CODE: + case ACTION_EDIT_ON_ENTITY_LOCKED_BY_OTHER_USER: + case ACTION_CHECKIN_ON_ENTITY_LOCKED_BY_OTHER_USER: + case ACTION_CHECKOUT_ON_LOCKED_ENTITY_OTHER_USER: + case ACTION_UNDO_CHECKOUT_ON_ENTITY_LOCKED_BY_OTHER_USER: + case ACTION_DELETE_ON_LOCKED_ENTITY_CODE: + case ACTION_ARTIFACT_DEL_LOCKED_OTHER_USER_CODE: + case ACTION_ARTIFACT_UPDATE_READ_ONLY: response = Response .status(Response.Status.FORBIDDEN) .entity( new ActionExceptionResponse(errorCode, Response.Status.FORBIDDEN.getReasonPhrase(), - actionException.getDescription())).type(MediaType.APPLICATION_JSON) + exception.getDescription())).type(MediaType.APPLICATION_JSON) .build(); break; - case ActionErrorConstants.ACTION_ENTITY_NOT_EXIST_CODE: - case ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST_CODE: + case ACTION_ENTITY_NOT_EXIST_CODE: + case ACTION_ARTIFACT_ENTITY_NOT_EXIST_CODE: response = Response .status(Response.Status.NOT_FOUND) .entity( new ActionExceptionResponse(errorCode, Response.Status.NOT_FOUND.getReasonPhrase(), - actionException.getDescription())).type(MediaType.APPLICATION_JSON) + exception.getDescription())).type(MediaType.APPLICATION_JSON) .build(); break; - case ActionErrorConstants.ACTION_INTERNAL_SERVER_ERR_CODE: + case ACTION_INTERNAL_SERVER_ERR_CODE: default: response = Response .status(Response.Status.INTERNAL_SERVER_ERROR) .entity(new ActionExceptionResponse(errorCode, Response.Status.INTERNAL_SERVER_ERROR.getReasonPhrase(), - actionException.getDescription())) + exception.getDescription())) .type(MediaType.APPLICATION_JSON) .build(); } diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/Action.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/Action.java index 176d443a81..b7672644d2 100644 --- a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/Action.java +++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/Action.java @@ -36,7 +36,6 @@ public class Action implements Comparable { private ActionStatus status; private String name; private String displayName; - private String endpointUri; private List vendorList; private List categoryList; private Date timestamp; @@ -120,14 +119,6 @@ public class Action implements Comparable { this.displayName = displayName; } - public String getEndpointUri() { - return endpointUri; - } - - public void setEndpointUri(String endpointUri) { - this.endpointUri = endpointUri; - } - public List getVendorList() { return vendorList; } @@ -176,6 +167,7 @@ public class Action implements Comparable { this.supportedComponents = supportedComponents; } + public List getArtifacts() { return artifacts; } @@ -213,8 +205,8 @@ public class Action implements Comparable { if (this.getStatus() != null) { destination.setStatus(this.getStatus().name()); } - destination.setSupportedComponents( - getIdFromMap(this.getSupportedComponents(), ActionConstants.SUPPORTED_COMPONENTS_ID)); + destination.setSupportedComponents(getIdFromMap(this.getSupportedComponents(), + ActionConstants.SUPPORTED_COMPONENTS_ID)); destination.setSupportedModels( getIdFromMap(this.getSupportedModels(), ActionConstants.SUPPORTED_MODELS_VERSION_ID)); destination.setData(this.getData()); @@ -224,11 +216,11 @@ public class Action implements Comparable { private List getIdFromMap(List> map, String idName) { List list = new ArrayList<>(); if (map != null && !map.isEmpty()) { - map.forEach(entry -> { + for (HashMap entry : map) { if (entry.containsKey(idName)) { list.add(entry.get(idName) != null ? entry.get(idName).toLowerCase() : null); } - }); + } return list; } return null; diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionArtifact.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionArtifact.java index ef41673541..1c354e0f41 100644 --- a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionArtifact.java +++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionArtifact.java @@ -26,6 +26,7 @@ import org.openecomp.sdc.action.dao.types.ActionArtifactEntity; import java.nio.ByteBuffer; import java.util.Date; + public class ActionArtifact { private String artifactUuId; diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionRequest.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionRequest.java index 1a20f9ecb7..6ba70b08ee 100644 --- a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionRequest.java +++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionRequest.java @@ -26,7 +26,7 @@ public enum ActionRequest { DELETE_ACTION, GET_FILTERED_ACTIONS, GET_ACTIONS_INVARIANT_ID, - GET_ECOMP_COMPONENTS, + GET_OPEN_ECOMP_COMPONENTS, ACTION_VERSIONING, CHECKOUT_ACTION, CHECKIN_ACTION, diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionSubOperation.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionSubOperation.java index 0dd97e6646..3298be7179 100644 --- a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionSubOperation.java +++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionSubOperation.java @@ -36,7 +36,7 @@ public enum ActionSubOperation { GET_ACTIONENTITY_BY_VERSION, GET_ALL_ACTIONS, GET_ACTIONINVID_BY_NAME, - GET_ECOMP_COMPONENTS_ENTITY, + GET_OPEN_ECOMP_COMPONENTS_ENTITY, GET_VERSIONINFO_FOR_ALL_ACTIONS, GET_NAME_BY_ACTIONINVID, CHECKOUT_ACTION, diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/EcompComponent.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/EcompComponent.java deleted file mode 100644 index cbcebb13ef..0000000000 --- a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/EcompComponent.java +++ /dev/null @@ -1,104 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.action.types; - -import org.openecomp.sdc.action.dao.types.EcompComponentEntity; - -public class EcompComponent { - - private String id; - private String name; - - public EcompComponent() { - //Default constructor - } - - public EcompComponent(String name, String id) { - this.name = name; - this.id = id; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - /** - * To entity ecomp component entity. - * - * @return the ecomp component entity - */ - public EcompComponentEntity toEntity() { - EcompComponentEntity destination = new EcompComponentEntity(); - destination.setId(this.getId()); - destination.setName(this.getName()); - return destination; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((id == null) ? 0 : id.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; - } - - @Override - public boolean equals(Object object) { - if (this == object) { - return true; - } - if (object == null) { - return false; - } - if (this.getClass() != object.getClass()) { - return false; - } - EcompComponent obj = (EcompComponent) object; - if (id == null) { - if (obj.id != null) { - return false; - } - } else if (!id.equals(obj.id)) { - return false; - } - if (name == null) { - if (obj.name != null) { - return false; - } - } else if (!name.equals(obj.name)) { - return false; - } - return true; - } -} diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/OpenEcompComponent.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/OpenEcompComponent.java new file mode 100644 index 0000000000..bf3f0c54f9 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/OpenEcompComponent.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.action.types; + +import org.openecomp.sdc.action.dao.types.OpenEcompComponentEntity; + +public class OpenEcompComponent { + + private String id; + private String name; + + public OpenEcompComponent() { + //Default constructor + } + + public OpenEcompComponent(String name, String id) { + this.name = name; + this.id = id; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * To entity OPENECOMP component entity. + * + * @return the OPENECOMP component entity + */ + public OpenEcompComponentEntity toEntity() { + OpenEcompComponentEntity destination = new OpenEcompComponentEntity(); + destination.setId(this.getId()); + destination.setName(this.getName()); + return destination; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(Object object) { + if (this == object) { + return true; + } + if (object == null) { + return false; + } + if (this.getClass() != object.getClass()) { + return false; + } + OpenEcompComponent obj = (OpenEcompComponent) object; + if (id == null) { + if (obj.id != null) { + return false; + } + } else if (!id.equals(obj.id)) { + return false; + } + if (name == null) { + if (obj.name != null) { + return false; + } + } else if (!name.equals(obj.name)) { + return false; + } + return true; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/util/ActionUtil.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/util/ActionUtil.java index 787f6abc26..0315a31a70 100644 --- a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/util/ActionUtil.java +++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/util/ActionUtil.java @@ -116,7 +116,6 @@ import java.time.ZoneOffset; import java.util.Date; import java.util.TimeZone; - public class ActionUtil { private static final String UTC_DATE_FORMAT = "dd MMM yyyy kk:mm:ss z"; @@ -125,7 +124,7 @@ public class ActionUtil { /** * Get Current Timestamp in UTC format. * - * @return Current Timestamp in UTC format. + * @return Current Timestamp in UTC format */ public static Date getCurrentTimeStampUtc() { return Date.from(java.time.ZonedDateTime.now(ZoneOffset.UTC).toInstant()); @@ -134,8 +133,8 @@ public class ActionUtil { /** * Convert timestamp to UTC format date string. * - * @param timeStamp UTC timestamp to be converted to the UTC Date format. - * @return UTC formatted Date string from timestamp. + * @param timeStamp UTC timestamp to be converted to the UTC Date format + * @return UTC formatted Date string from timestamp */ public static String getUtcDateStringFromTimestamp(Date timeStamp) { DateFormat df = new SimpleDateFormat(UTC_DATE_FORMAT); @@ -146,8 +145,8 @@ public class ActionUtil { /** * Convert timestamp to UTC format date string. * - * @param timeStamp UTC timestamp to be converted to the UTC Date format. - * @return UTC formatted Date string from timestamp. + * @param timeStamp UTC timestamp to be converted to the UTC Date format + * @return UTC formatted Date string from timestamp */ public static String getLogUtcDateStringFromTimestamp(Date timeStamp) { DateFormat df = new SimpleDateFormat(LOG_UTC_DATE_FORMAT); @@ -158,7 +157,7 @@ public class ActionUtil { /** * Method to set up specific attributes MDC for the current logging operation. * - * @param subOperation Request Name. + * @param subOperation Request Name */ public static void actionLogPreProcessor(ActionSubOperation subOperation, String targetEntity) { MDC.put(BEGIN_TIMESTAMP, String.valueOf(System.currentTimeMillis())); @@ -172,7 +171,7 @@ public class ActionUtil { /** * Method to enhance the MDC after the logging operation for Metrics and Audit logs. * - * @param statusCode Response code for the current operation. + * @param statusCode Response code for the current operation */ public static void actionLogPostProcessor(StatusCode statusCode) { actionLogPostProcessor(statusCode, false); @@ -188,11 +187,13 @@ public class ActionUtil { } /** - * Method to enhance the MDC after the logging operation for Metrics and Audit logs. + * Action log post processor. * - * @param statusCode Response code for the current operation. + * @param statusCode the status code + * @param responseCode the response code + * @param responseDescription the response description + * @param isServiceMetricLog the is service metric log */ - public static void actionLogPostProcessor(StatusCode statusCode, String responseCode, String responseDescription, boolean isServiceMetricLog) { @@ -217,9 +218,9 @@ public class ActionUtil { /** * Action Library Error logging Helper. * - * @param errorCategory WARN or ERROR. - * @param errorCode Action Library exception code. - * @param errorDescription Description of the error. + * @param errorCategory WARN or ERROR + * @param errorCode Action Library exception code + * @param errorDescription Description of the error */ public static void actionErrorLogProcessor(CategoryLogLevel errorCategory, String errorCode, String errorDescription) { @@ -237,7 +238,6 @@ public class ActionUtil { errorType = "F"; break; default: - break; } MDC.put(ERROR_CODE, getLogResponseCode(errorCode) + errorType); } @@ -245,11 +245,11 @@ public class ActionUtil { } /** - * Method to convert Action Library exception codes to OPENECOMP Audit codes in {@link. - * ActionLogResponseCode} e.g: ACT1060 --> 201. + * Method to convert Action Library exception codes to OPENECOMP Audit codes in {@link + * ActionLogResponseCode} e.g: ACT1060 --> 201 * - * @param errorCode Action library exception code. - * @return Audit log code corresponding to the Action Library exception. + * @param errorCode Action library exception code + * @return Audit log code corresponding to the Action Library exception */ public static int getLogResponseCode(String errorCode) { ActionLogResponseCode responseCode = INTERNAL_SERVER_ERROR; @@ -365,7 +365,6 @@ public class ActionUtil { responseCode = QUERY_FAILURE; break; default: - break; } return responseCode.getValue(); } -- cgit 1.2.3-korg