diff options
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-action-lib')
5 files changed, 45 insertions, 67 deletions
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 25cd06d3ce..1823b752c8 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 @@ -21,6 +21,8 @@ package org.openecomp.sdc.action; +import org.onap.logging.ref.slf4j.ONAPLogConstants; + public class ActionConstants { // @@ -73,21 +75,21 @@ public class ActionConstants { public static final String ARTIFACT_METADATA_ATTR_UUID = "ARTIFACT_UUID"; public static final String ARTIFACT_METADATA_ATTR_NAME = "ARTIFACT_NAME"; - public static final String REQUEST_ID = "uuid"; + public static final String REQUEST_ID = ONAPLogConstants.MDCs.REQUEST_ID; public static final String SERVICE_INSTANCE_ID = "serviceInstanceID"; - public static final String PARTNER_NAME = "userId"; - public static final String SERVICE_NAME = "ServiceName"; - public static final String INSTANCE_UUID = "InstanceUUID"; + public static final String PARTNER_NAME = ONAPLogConstants.MDCs.PARTNER_NAME; + public static final String SERVICE_NAME = ONAPLogConstants.MDCs.SERVICE_NAME; + public static final String INSTANCE_UUID = ONAPLogConstants.MDCs.INSTANCE_UUID; public static final String REMOTE_HOST = "RemoteHost"; - public static final String CLIENT_IP = "ClientIP"; + public static final String CLIENT_IP = ONAPLogConstants.MDCs.CLIENT_IP_ADDRESS; public static final String CATEGORY_LOG_LEVEL = "level"; - public static final String STATUS_CODE = "StatusCode"; - public static final String RESPONSE_CODE = "ResponseCode"; - public static final String RESPONSE_DESCRIPTION = "ResponseDescription"; + public static final String STATUS_CODE = ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE; + public static final String RESPONSE_CODE = ONAPLogConstants.MDCs.RESPONSE_CODE; + public static final String RESPONSE_DESCRIPTION = ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION; public static final String ELAPSED_TIME = "ElapsedTime"; - public static final String BEGIN_TIMESTAMP = "BeginTimestamp"; - public static final String TARGET_SERVICE_NAME = "TargetServiceName"; - public static final String TARGET_ENTITY = "TargetEntity"; + public static final String BEGIN_TIMESTAMP = ONAPLogConstants.MDCs.ENTRY_TIMESTAMP; + public static final String TARGET_SERVICE_NAME = ONAPLogConstants.MDCs.TARGET_SERVICE_NAME; + public static final String TARGET_ENTITY = ONAPLogConstants.MDCs.TARGET_ENTITY; public static final String TARGET_ENTITY_API = "API"; public static final String TARGET_ENTITY_DB = "DB"; public static final String END_TIMESTAMP = "EndTimestamp"; diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/logging/StatusCode.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/logging/StatusCode.java deleted file mode 100644 index b0d5bab12b..0000000000 --- a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/logging/StatusCode.java +++ /dev/null @@ -1,26 +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.logging; - -public enum StatusCode { - COMPLETE, - ERROR -} 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 5d91a599a9..2fba053b2d 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 @@ -20,8 +20,8 @@ package org.openecomp.sdc.action.util; +import org.onap.logging.ref.slf4j.ONAPLogConstants.ResponseStatus; import org.openecomp.sdc.action.logging.CategoryLogLevel; -import org.openecomp.sdc.action.logging.StatusCode; import org.openecomp.sdc.action.types.ActionLogResponseCode; import org.openecomp.sdc.action.types.ActionSubOperation; import org.slf4j.MDC; @@ -93,15 +93,15 @@ public class ActionUtil { * * @param statusCode Response code for the current operation */ - public static void actionLogPostProcessor(StatusCode statusCode) { + public static void actionLogPostProcessor(ResponseStatus statusCode) { actionLogPostProcessor(statusCode, false); } - public static void actionLogPostProcessor(StatusCode statusCode, boolean isServiceMetricLog) { + public static void actionLogPostProcessor(ResponseStatus statusCode, boolean isServiceMetricLog) { actionLogPostProcessor(statusCode, null, isServiceMetricLog); } - public static void actionLogPostProcessor(StatusCode statusCode, String responseCode, + public static void actionLogPostProcessor(ResponseStatus statusCode, String responseCode, boolean isServiceMetricLog) { actionLogPostProcessor(statusCode, responseCode, null, isServiceMetricLog); } @@ -114,7 +114,7 @@ public class ActionUtil { * @param responseDescription the response description * @param isServiceMetricLog the is service metric log */ - public static void actionLogPostProcessor(StatusCode statusCode, String responseCode, + public static void actionLogPostProcessor(ResponseStatus statusCode, String responseCode, String responseDescription, boolean isServiceMetricLog) { MDC.put(STATUS_CODE, statusCode.name()); diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionArtifactDaoImpl.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionArtifactDaoImpl.java index efac856788..f9e0b00ff8 100644 --- a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionArtifactDaoImpl.java +++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionArtifactDaoImpl.java @@ -32,7 +32,6 @@ import org.openecomp.sdc.action.dao.ActionArtifactDao; import org.openecomp.sdc.action.dao.types.ActionArtifactEntity; import org.openecomp.sdc.action.errors.ActionException; import org.openecomp.sdc.action.logging.CategoryLogLevel; -import org.openecomp.sdc.action.logging.StatusCode; import org.openecomp.sdc.action.types.ActionArtifact; import org.openecomp.sdc.action.types.ActionSubOperation; import org.openecomp.sdc.action.util.ActionUtil; @@ -42,6 +41,8 @@ import org.openecomp.sdc.logging.api.LoggerFactory; import java.util.Collection; import java.util.List; +import static org.onap.logging.ref.slf4j.ONAPLogConstants.ResponseStatus.COMPLETE; +import static org.onap.logging.ref.slf4j.ONAPLogConstants.ResponseStatus.ERROR; import static org.openecomp.sdc.action.ActionConstants.TARGET_ENTITY_DB; import static org.openecomp.sdc.action.errors.ActionErrorConstants.*; @@ -77,7 +78,7 @@ public class ActionArtifactDaoImpl extends CassandraBaseDao<ActionArtifactEntity try { ActionUtil.actionLogPreProcessor(ActionSubOperation.CREATE_ACTION_ARTIFACT, TARGET_ENTITY_DB); this.create(data.toEntity()); - ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false); + ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false); log.metrics(""); } catch (NoHostAvailableException noHostAvailableException) { logGenericException(noHostAvailableException); @@ -96,7 +97,7 @@ public class ActionArtifactDaoImpl extends CassandraBaseDao<ActionArtifactEntity .actionLogPreProcessor(ActionSubOperation.GET_ARTIFACT_BY_ARTIFACTUUID, TARGET_ENTITY_DB); Result<ActionArtifactEntity> result = null; result = accessor.getArtifactByUuId(effectiveVersion, artifactUuId); - ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false); + ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false); log.metrics(""); List<ActionArtifactEntity> artifactEntities = result.all(); if (artifactEntities != null && !artifactEntities.isEmpty()) { @@ -118,7 +119,7 @@ public class ActionArtifactDaoImpl extends CassandraBaseDao<ActionArtifactEntity try { ActionUtil.actionLogPreProcessor(ActionSubOperation.UPDATE_ACTION_ARTIFACT, TARGET_ENTITY_DB); this.update(data.toEntity()); - ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false); + ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false); log.metrics(""); } catch (NoHostAvailableException noHostAvailableException) { logGenericException(noHostAvailableException); @@ -129,7 +130,7 @@ public class ActionArtifactDaoImpl extends CassandraBaseDao<ActionArtifactEntity } private void logGenericException(Exception exception) { - ActionUtil.actionLogPostProcessor(StatusCode.ERROR, ACTION_QUERY_FAILURE_CODE, + ActionUtil.actionLogPostProcessor(ERROR, ACTION_QUERY_FAILURE_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG, false); log.metrics(""); ActionUtil.actionErrorLogProcessor(CategoryLogLevel.FATAL, ACTION_QUERY_FAILURE_CODE, diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionDaoImpl.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionDaoImpl.java index 4562606339..f22fa08ee3 100644 --- a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionDaoImpl.java +++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionDaoImpl.java @@ -19,6 +19,8 @@ package org.openecomp.sdc.action.dao.impl; import static com.datastax.driver.core.querybuilder.QueryBuilder.eq; import static com.datastax.driver.core.querybuilder.QueryBuilder.in; import static com.datastax.driver.core.querybuilder.QueryBuilder.set; +import static org.onap.logging.ref.slf4j.ONAPLogConstants.ResponseStatus.COMPLETE; +import static org.onap.logging.ref.slf4j.ONAPLogConstants.ResponseStatus.ERROR; import static org.openecomp.core.nosqldb.impl.cassandra.CassandraSessionFactory.getSession; import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_CATEGORY; import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_MODEL; @@ -69,7 +71,6 @@ import org.openecomp.sdc.action.dao.types.ActionEntity; import org.openecomp.sdc.action.dao.types.OpenEcompComponentEntity; import org.openecomp.sdc.action.errors.ActionException; import org.openecomp.sdc.action.logging.CategoryLogLevel; -import org.openecomp.sdc.action.logging.StatusCode; import org.openecomp.sdc.action.types.Action; import org.openecomp.sdc.action.types.ActionStatus; import org.openecomp.sdc.action.types.ActionSubOperation; @@ -127,7 +128,7 @@ public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements Act try { ActionUtil.actionLogPreProcessor(ActionSubOperation.CREATE_ACTION_ENTITY, TARGET_ENTITY_DB); this.create(action.toEntity()); - ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false); + ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false); log.metrics(""); return action; } catch (NoHostAvailableException exception) { @@ -142,7 +143,7 @@ public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements Act log.debug(" entering updateAction with actionUUID= " + action.getActionUuId()); ActionUtil.actionLogPreProcessor(ActionSubOperation.UPDATE_ACTION, TARGET_ENTITY_DB); this.update(action.toEntity()); - ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false); + ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false); log.metrics(""); log.debug(" exit updateAction with actionUUID= " + action.getActionUuId()); return action; @@ -159,7 +160,7 @@ public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements Act ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_DB); VersionInfoDeletedEntity activeVersionEntity = versionInfoDeletedDao .get(new VersionInfoDeletedEntity(ActionConstants.ACTION_VERSIONABLE_TYPE, actionInvariantUuId)); - ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false); + ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false); log.metrics(""); Version activeVersion = activeVersionEntity.getActiveVersion(); @@ -170,7 +171,7 @@ public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements Act .and(in(VERSION, activeVersion)); ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_NAME_BY_ACTIONINVID, TARGET_ENTITY_DB); ResultSet results = getSession().execute(getNameFromInvUuId); - ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false); + ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false); log.metrics(""); if (!results.isExhausted()) { @@ -196,37 +197,37 @@ public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements Act case FILTER_TYPE_VENDOR: ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_VENDOR, TARGET_ENTITY_DB); result = accessor.getActionsByVendor(filterId); - ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE); + ActionUtil.actionLogPostProcessor(COMPLETE); log.metrics(""); break; case FILTER_TYPE_CATEGORY: ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_CATEGORY, TARGET_ENTITY_DB); result = accessor.getActionsByCategory(filterId); - ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE); + ActionUtil.actionLogPostProcessor(COMPLETE); log.metrics(""); break; case FILTER_TYPE_MODEL: ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_MODEL, TARGET_ENTITY_DB); result = accessor.getActionsByModel(filterId); - ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE); + ActionUtil.actionLogPostProcessor(COMPLETE); log.metrics(""); break; case FILTER_TYPE_OPEN_ECOMP_COMPONENT: ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_COMPONENT, TARGET_ENTITY_DB); result = accessor.getActionsByOpenEcompComponent(filterId); - ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE); + ActionUtil.actionLogPostProcessor(COMPLETE); log.metrics(""); break; case FILTER_TYPE_NONE: ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ALL_ACTIONS, TARGET_ENTITY_DB); result = accessor.getAllActions(); - ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE); + ActionUtil.actionLogPostProcessor(COMPLETE); log.metrics(""); break; case FILTER_TYPE_NAME: ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONINVID_BY_NAME, TARGET_ENTITY_DB); result = accessor.getInvIdByName(filterId); - ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE); + ActionUtil.actionLogPostProcessor(COMPLETE); log.metrics(""); List<ActionEntity> actionEntities = result.all(); if (actionEntities != null && !actionEntities.isEmpty()) { @@ -262,7 +263,7 @@ public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements Act log.debug(" entering getActionsByActionUuId with actionUUID= " + actionUuId); ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_ACTIONUUID, TARGET_ENTITY_DB); Result<ActionEntity> result = accessor.actionInvariantUuId(actionUuId); - ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false); + ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false); log.metrics(""); if (result != null) { log.debug(" exit getActionsByActionUuId with actionUUID= " + actionUuId); @@ -287,7 +288,7 @@ public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements Act log.debug(" entering getOpenEcompComponents "); ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_OPEN_ECOMP_COMPONENTS_ENTITY, TARGET_ENTITY_DB); result = accessor.getOpenEcompComponents(); - ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false); + ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false); log.metrics(""); if (result != null) { openEcompComponents.addAll(result.all() @@ -342,7 +343,7 @@ public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements Act } MDC.put(TARGET_ENTITY, TARGET_ENTITY_DB); - ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false); + ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false); log.metrics(""); log.debug("Found " + viewableVersions + " viewable version for action with actionInvariantUuId " @@ -353,7 +354,7 @@ public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements Act ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_ACTIONINVID, TARGET_ENTITY_DB); Result<ActionEntity> result = accessor.getActionsByInvId(actionInvariantUuId, new ArrayList<>(viewableVersions)); - ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false); + ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false); log.metrics(""); if (result != null) { actions.addAll(result.all() @@ -377,7 +378,7 @@ public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements Act Action action = null; VersionInfoEntity versionInfoEntity = versionInfoDao .get(new VersionInfoEntity(ActionConstants.ACTION_VERSIONABLE_TYPE, actionInvariantUuId)); - ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false); + ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false); log.metrics(""); if (versionInfoEntity != null) { if (versionInfoEntity.getCandidate() != null) { @@ -391,7 +392,7 @@ public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements Act TARGET_ENTITY_DB); Result<ActionEntity> result = accessor.getActionsByInvId(actionInvariantUuId, new ArrayList<>(versions)); - ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false); + ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false); log.metrics(""); if (result != null) { ActionEntity actionEntity = result.one(); @@ -411,7 +412,7 @@ public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements Act } private void logGenericException(Exception exception) { - ActionUtil.actionLogPostProcessor(StatusCode.ERROR, ACTION_QUERY_FAILURE_CODE, + ActionUtil.actionLogPostProcessor(ERROR, ACTION_QUERY_FAILURE_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG, false); log.metrics(""); ActionUtil.actionErrorLogProcessor(CategoryLogLevel.FATAL, ACTION_QUERY_FAILURE_CODE, ACTION_QUERY_FAILURE_MSG); @@ -444,7 +445,7 @@ public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements Act .where(eq("actioninvariantuuid", actionInvariantUuId)) .and(in(VERSION, versions)); getSession().execute(updateStatusStatement); - ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false); + ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false); log.metrics(""); // Update the status in the data field of action table updateStatusInActionData(actionInvariantUuId, versions, ActionStatus.Deleted); @@ -494,7 +495,7 @@ public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements Act .from("dox", ACTION) .where(eq("name", name)); ResultSet results = getSession().execute(statement); - ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false); + ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false); log.metrics(""); List<Version> versionList = new ArrayList<>(); |