From c8b1cab6c010509386a266560850325db0065649 Mon Sep 17 00:00:00 2001 From: Jerry Flood Date: Wed, 20 Feb 2019 16:01:49 -0500 Subject: Added AAF filters and Observations AAF profile not configured Issue-ID: OPTFRA-390 Change-Id: I38a72951507ae768eeace2c67c2632812bf4f8aa Signed-off-by: Jerry Flood --- cmso-service/etc/config/cadi.properties | 4 + cmso-service/etc/config/cmso.properties | 10 +- cmso-service/pom.xml | 188 ++++++------- .../src/main/docker/assembly/cmso-files.xml | 44 +-- .../src/main/docker/extra-files/startService.sh | 3 + .../main/docker/extra-files/startService.sh.bak | 4 + .../src/main/java/org/onap/observations/Mdc.java | 248 +++++++++++++++++ .../java/org/onap/observations/Observation.java | 126 +++++++++ .../onap/observations/ObservationInterface.java | 48 ++++ .../org/onap/observations/ObservationObject.java | 109 ++++++++ .../main/java/org/onap/optf/cmso/AuthProvider.java | 3 + .../java/org/onap/optf/cmso/SecurityConfig.java | 2 + .../java/org/onap/optf/cmso/SpringProfiles.java | 29 ++ .../onap/optf/cmso/aaf/AafAuthorizationFilter.java | 91 +++++++ .../java/org/onap/optf/cmso/aaf/AafFilter.java | 71 +++++ .../main/java/org/onap/optf/cmso/aaf/AafPerm.java | 78 ++++++ .../org/onap/optf/cmso/aaf/AafSecurityConfig.java | 59 +++++ .../java/org/onap/optf/cmso/aaf/AafUserRole.java | 127 +++++++++ .../onap/optf/cmso/aaf/AafUserRoleProperties.java | 128 +++++++++ .../org/onap/optf/cmso/aaf/FilterPriority.java | 35 +++ .../org/onap/optf/cmso/aaf/ResponseFormatter.java | 42 +++ .../org/onap/optf/cmso/common/LogMessages.java | 294 +++++++++++++-------- .../java/org/onap/optf/cmso/dispatcher/CmJob.java | 13 +- .../cmso/dispatcher/rs/DispatcherServiceImpl.java | 27 +- .../org/onap/optf/cmso/eventq/CmQuartzJob.java | 6 +- .../onap/optf/cmso/filters/CMSOClientFilters.java | 28 +- .../optf/cmso/filters/CMSOContainerFilters.java | 37 ++- .../optf/cmso/optimizer/CMSOptimizerClient.java | 46 ++-- .../optf/cmso/optimizer/OptimizerQuartzJob.java | 12 +- .../onap/optf/cmso/service/rs/AdminToolImpl.java | 10 +- .../onap/optf/cmso/service/rs/CMSCallbackImpl.java | 14 +- .../onap/optf/cmso/service/rs/CMSOServiceImpl.java | 139 +++------- .../onap/optf/cmso/service/rs/HealthCheckImpl.java | 13 +- .../onap/optf/cmso/sostatus/MsoStatusClient.java | 37 ++- .../org/onap/optf/cmso/sostatus/MsoStatusJob.java | 6 +- .../onap/optf/cmso/sostatus/ScheduleStatusJob.java | 42 ++- .../org/onap/optf/cmso/ticketmgt/TmClient.java | 63 ++--- .../src/main/resources/aaf/AAFUserRoles.properties | 1 + .../src/main/resources/aaf/org.onap.oof.cred.props | 11 + .../src/main/resources/aaf/org.onap.oof.keyfile | 27 ++ .../main/resources/aaf/org.onap.oof.location.props | 8 + .../src/main/resources/aaf/org.onap.oof.props | 14 + .../src/main/resources/aaf/truststoreONAPall.jks | Bin 0 -> 117990 bytes .../src/main/resources/application.properties | 1 + .../src/main/resources/logmessages.properties | 142 +++++----- 45 files changed, 1847 insertions(+), 593 deletions(-) create mode 100644 cmso-service/etc/config/cadi.properties create mode 100644 cmso-service/src/main/docker/extra-files/startService.sh.bak create mode 100644 cmso-service/src/main/java/org/onap/observations/Mdc.java create mode 100644 cmso-service/src/main/java/org/onap/observations/Observation.java create mode 100644 cmso-service/src/main/java/org/onap/observations/ObservationInterface.java create mode 100644 cmso-service/src/main/java/org/onap/observations/ObservationObject.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/SpringProfiles.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafAuthorizationFilter.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafFilter.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafPerm.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafSecurityConfig.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafUserRole.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafUserRoleProperties.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/aaf/FilterPriority.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/aaf/ResponseFormatter.java create mode 100644 cmso-service/src/main/resources/aaf/AAFUserRoles.properties create mode 100644 cmso-service/src/main/resources/aaf/org.onap.oof.cred.props create mode 100644 cmso-service/src/main/resources/aaf/org.onap.oof.keyfile create mode 100644 cmso-service/src/main/resources/aaf/org.onap.oof.location.props create mode 100644 cmso-service/src/main/resources/aaf/org.onap.oof.props create mode 100644 cmso-service/src/main/resources/aaf/truststoreONAPall.jks (limited to 'cmso-service') diff --git a/cmso-service/etc/config/cadi.properties b/cmso-service/etc/config/cadi.properties new file mode 100644 index 0000000..5135d1d --- /dev/null +++ b/cmso-service/etc/config/cadi.properties @@ -0,0 +1,4 @@ + +cadi_loglevel=DEBUG +cadi_prop_files=src/main/resources/aaf/org.onap.oof.props + diff --git a/cmso-service/etc/config/cmso.properties b/cmso-service/etc/config/cmso.properties index f103c57..d4a78e8 100644 --- a/cmso-service/etc/config/cmso.properties +++ b/cmso-service/etc/config/cmso.properties @@ -90,15 +90,13 @@ org.quartz.jobStore.class=org.quartz.simpl.RAMJobStore loopback.mso.requestId=dummy123 so.polling.interval.ms=10000 -#mso.user=cmso@onap.org -#mso.pass=enc:bfodXf8qRfCqMvlxVBYNWQ== ## loopback settings so.url=http://localhost:8080/cmso/v1/loopbacktest/onap/so/infra/orchestrationRequests/v7 -so.user=cmso@onap.org -so.pass=enc:bfodXf8qRfCqMvlxVBYNWQ== +so.user=oof@oof.onap.org +so.pass=enc:vfxQdJ1mgdcI7S6SPrzNaw== -mechid.user=cmso@onap.org -mechid.pass=enc:bfodXf8qRfCqMvlxVBYNWQ== +mechid.user=oof@oof.onap.org +mechid.pass=enc:vfxQdJ1mgdcI7S6SPrzNaw== cmso.dispatch.url=http://localhost:8089 diff --git a/cmso-service/pom.xml b/cmso-service/pom.xml index 42ec87e..d03a3ac 100644 --- a/cmso-service/pom.xml +++ b/cmso-service/pom.xml @@ -1,45 +1,37 @@ - + 4.0.0 - - org.onap.optf.cmso - cmso - 1.0.1-SNAPSHOT - + + org.onap.optf.cmso + cmso + 1.0.1-SNAPSHOT + org.onap.optf.cmso cmso-service @@ -50,10 +42,10 @@ yyyyMMdd'T'HHmmss'Z' - + ${project.version} ${maven.build.timestamp} - + cmso Casablanca org.onap.optf.cmso @@ -74,6 +66,7 @@ yyyyMMdd'T'HHmmss'Z' 2.2.1 ${basedir}/src/main/resources/swagger-ui/dist + 2.1.4 2.0.7 @@ -246,8 +239,6 @@ springfox-swagger-ui ${springfox.swagger2.version} - org.quartz-scheduler quartz @@ -260,14 +251,13 @@ - joda-time - joda-time - 2.8.1 - + joda-time + joda-time + - org.apache.commons - commons-lang3 - 3.8.1 + org.apache.commons + commons-text + 1.6 + data /data + + ${project.basedir}/src/main/resources + ./resources + + **/* + + + + ${project.basedir}/etc/config + ./ + + **/* + + + diff --git a/cmso-service/src/main/docker/extra-files/startService.sh b/cmso-service/src/main/docker/extra-files/startService.sh index dbd111f..199c637 100644 --- a/cmso-service/src/main/docker/extra-files/startService.sh +++ b/cmso-service/src/main/docker/extra-files/startService.sh @@ -1,4 +1,7 @@ #!/bin/sh + +VM_ARGS="${VM_ARGS} -Dserver.local.startpath=${RESOURCES_HOME}" + echo "VM_ARGS="${VM_ARGS} java -Djava.security.egd=file:/dev/./urandom ${VM_ARGS} -Xms256m -Xmx1024m -jar ./app.jar diff --git a/cmso-service/src/main/docker/extra-files/startService.sh.bak b/cmso-service/src/main/docker/extra-files/startService.sh.bak new file mode 100644 index 0000000..dbd111f --- /dev/null +++ b/cmso-service/src/main/docker/extra-files/startService.sh.bak @@ -0,0 +1,4 @@ +#!/bin/sh +echo "VM_ARGS="${VM_ARGS} + +java -Djava.security.egd=file:/dev/./urandom ${VM_ARGS} -Xms256m -Xmx1024m -jar ./app.jar diff --git a/cmso-service/src/main/java/org/onap/observations/Mdc.java b/cmso-service/src/main/java/org/onap/observations/Mdc.java new file mode 100644 index 0000000..b00bed3 --- /dev/null +++ b/cmso-service/src/main/java/org/onap/observations/Mdc.java @@ -0,0 +1,248 @@ +/* + * Copyright © 2019 AT&T Intellectual Property. + * + * 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. + * + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. +*/ +package org.onap.observations; + +import static com.att.eelf.configuration.Configuration.MDC_BEGIN_TIMESTAMP; +import static com.att.eelf.configuration.Configuration.MDC_END_TIMESTAMP; +import static com.att.eelf.configuration.Configuration.MDC_INSTANCE_UUID; +import static com.att.eelf.configuration.Configuration.MDC_KEY_REQUEST_ID; +import static com.att.eelf.configuration.Configuration.MDC_PARTNER_NAME; +import static com.att.eelf.configuration.Configuration.MDC_REMOTE_HOST; +import static com.att.eelf.configuration.Configuration.MDC_RESPONSE_CODE; +import static com.att.eelf.configuration.Configuration.MDC_RESPONSE_DESC; +import static com.att.eelf.configuration.Configuration.MDC_SERVER_FQDN; +import static com.att.eelf.configuration.Configuration.MDC_SERVER_IP_ADDRESS; +import static com.att.eelf.configuration.Configuration.MDC_SERVICE_INSTANCE_ID; +import static com.att.eelf.configuration.Configuration.MDC_SERVICE_NAME; +import static com.att.eelf.configuration.Configuration.MDC_STATUS_CODE; +import static com.att.eelf.configuration.Configuration.MDC_TARGET_ENTITY; +import static com.att.eelf.configuration.Configuration.MDC_TARGET_SERVICE_NAME; + +import java.net.InetAddress; +import java.net.URI; +import java.util.Date; +import java.util.Map; +import java.util.UUID; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.client.ClientRequestContext; +import javax.ws.rs.client.ClientResponseContext; +import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.container.ContainerResponseContext; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response.StatusType; + +import org.onap.optf.cmso.filters.MessageHeaders.HeadersEnum; +import org.quartz.JobExecutionContext; +import org.slf4j.MDC; + +import com.att.eelf.utils.Stopwatch; + +/** + * ECOMP EELF logging MDC fields not defined in the MDC Configuration (i.e. + * MDC_ALERT_SEVERITY) + **/ +public class Mdc { + public static final String SERVICE_NAME = "CSS-Scheduler"; + public enum Enum { + // BeginTimestamp, + // EndTimeStamp, + // RequestId, + // ServiceInstanceId, + VirtualServerName, + // ServiceName, + // PartnerName, + // StatusCOde, + // ResponseCode, + // ResponseDescription, + // InstanceUUID, + // AlertSeverity, + // ServerIPAddress, + // ElapsedTime, + // ServerFQDN, + // RemoteHost, + ClassName, Unused, + // ProcessKey, + CustomField1, CustomField2, CustomField3, CustomField4, + // TargetVirtualEntity, + // TargetEntity, + // TargetServiceName, + ErrorCode, ErrorDescription, Timer, + } + + public static String getCaller(int back) + { + StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); + return stackTraceElements[back].getClassName() + "." + stackTraceElements[back].getMethodName(); + } + + public static void setCaller(int back) + { + String caller = MDC.get(Enum.ClassName.name()); + if (caller == null) + MDC.put(Enum.ClassName.name(), getCaller(back)); + } + + public static void setObservation(ObservationInterface o) + { + MDC.put(Enum.CustomField4.name(), o.name()); + } + + public static void clearCaller() + { + MDC.remove(Enum.ClassName.name()); + } + + public static void quartzJobBegin(JobExecutionContext context) + { + MDC.clear(); + MDC.put(MDC_BEGIN_TIMESTAMP, Stopwatch.isoFormatter.format(new Date())); + MDC.put(MDC_INSTANCE_UUID, UUID.randomUUID().toString()); + try{ MDC.put(MDC_SERVER_FQDN, InetAddress.getLocalHost().getHostName()); } catch (Exception e){ MDC.put(MDC_SERVER_FQDN, e.getMessage());} + try{ MDC.put(MDC_SERVER_IP_ADDRESS, InetAddress.getLocalHost().getHostAddress()); } catch (Exception e){ MDC.put(MDC_SERVER_FQDN, e.getMessage());} + MDC.put(MDC_SERVICE_INSTANCE_ID, "UNKNOWN"); + MDC.put(MDC_SERVICE_NAME, SERVICE_NAME); + MDC.put(Enum.ClassName.name(), getCaller(3)); + } + + public static void quartzJobEnd(JobExecutionContext context) + { + MDC.put(MDC_END_TIMESTAMP, Stopwatch.isoFormatter.format(new Date())); + MDC.put(Enum.ClassName.name(), getCaller(3)); + } + + public static Map save() + { + Map save = MDC.getCopyOfContextMap(); + return save; + } + + public static void restore(Map mdcSave) + { + MDC.clear(); + for (String name : mdcSave.keySet()) + MDC.put(name, mdcSave.get(name)); + } + + + + public static void setRequestIdIfNotSet(String requestId) { + if (MDC.get(MDC_KEY_REQUEST_ID) == null || MDC.get(MDC_KEY_REQUEST_ID).equals("")) + { + setRequestId(requestId); + } + } + + public static void setRequestId(String requestId) { + MDC.put(MDC_KEY_REQUEST_ID, requestId); + } + + public static void metricStart(ClientRequestContext requestContext) { + MDC.put(MDC_BEGIN_TIMESTAMP, Stopwatch.isoFormatter.format(new Date())); + MDC.put(MDC_END_TIMESTAMP, MDC.get(MDC_BEGIN_TIMESTAMP)); + setPartnerTargetFromUri(requestContext.getUri()); + } + + public static void metricEnd(ClientResponseContext response) + { + + Date now = new Date(); + //MDC.put(MDC_BEGIN_TIMESTAMP, Stopwatch.isoFormatter.format(now)); + MDC.put(MDC_END_TIMESTAMP, Stopwatch.isoFormatter.format(now)); + setResponseInfo(response.getStatusInfo()); + + } + public static void auditStart(ContainerRequestContext requestContext, HttpServletRequest servletRequest) + { + MDC.put(MDC_BEGIN_TIMESTAMP, Stopwatch.isoFormatter.format(new Date())); + MDC.put(MDC_END_TIMESTAMP, MDC.get(MDC_BEGIN_TIMESTAMP)); + MDC.put(MDC_REMOTE_HOST, servletRequest.getRemoteHost()); + MDC.put(Enum.ClassName.name(), getCaller(4)); + MultivaluedMap headers = requestContext.getHeaders(); + String transactionId = (String) headers.getFirst(HeadersEnum.TransactionID.toString()); + if (transactionId != null) + { + setRequestId(transactionId); + } + else + { + setRequestId(UUID.randomUUID().toString()); + } + + } + + public static void auditEnd(ContainerRequestContext requestContext, ContainerResponseContext response) + { + Date now = new Date(); + //MDC.put(MDC_BEGIN_TIMESTAMP, Stopwatch.isoFormatter.format(now)); + MDC.put(MDC_END_TIMESTAMP, Stopwatch.isoFormatter.format(now)); + MDC.put(Enum.ClassName.name(), getCaller(4)); + + setResponseInfo(response.getStatusInfo()); + + } + + private static void setResponseInfo(StatusType statusInfo) + { + Integer status = statusInfo.getStatusCode(); + String completed = "ERROR"; + if (status >=200 && status < 300) + { + completed = "COMPLETE"; + } + MDC.put(MDC_RESPONSE_CODE, status.toString()); + MDC.put(MDC_RESPONSE_DESC, statusInfo.getReasonPhrase()); + MDC.put(MDC_STATUS_CODE, completed); + } + + public static void setEvent(String requestID) { + MDC.put(MDC_BEGIN_TIMESTAMP, Stopwatch.isoFormatter.format(new Date())); + MDC.put(MDC_END_TIMESTAMP, MDC.get(MDC_BEGIN_TIMESTAMP)); + setRequestId(requestID); + } + + private static void setPartnerTargetFromUri(URI uri) + { + try + { + MDC.put(MDC_PARTNER_NAME, uri.getHost()); + MDC.put(MDC_TARGET_ENTITY, uri.getScheme() + "://" + uri.getHost() + ":" + uri.getPort()); + MDC.put(MDC_TARGET_SERVICE_NAME, uri.getPath()); + } + catch (Exception e) + { + MDC.put(MDC_PARTNER_NAME, "UNKNOWN"); + MDC.put(MDC_TARGET_ENTITY, "UNKNOWN"); + MDC.put(MDC_TARGET_SERVICE_NAME, "UNKNOWN"); + } + } + + +} \ No newline at end of file diff --git a/cmso-service/src/main/java/org/onap/observations/Observation.java b/cmso-service/src/main/java/org/onap/observations/Observation.java new file mode 100644 index 0000000..39bc3ca --- /dev/null +++ b/cmso-service/src/main/java/org/onap/observations/Observation.java @@ -0,0 +1,126 @@ +/* + * Copyright © 2019 AT&T Intellectual Property. + * + * 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. + * + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. +*/ +package org.onap.observations; + +import org.apache.log4j.Level; +import org.onap.optf.cmso.Application; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + + +public class Observation +{ + private static EELFLogger log = EELFManager.getInstance().getLogger(Application.class); + private static EELFLogger metrics = EELFManager.getInstance().getMetricsLogger(); + private static EELFLogger audit = EELFManager.getInstance().getAuditLogger(); + private static EELFLogger errors = EELFManager.getInstance().getErrorLogger(); + private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); + + //************************************************************************************************* + public static void report(ObservationInterface o, Exception e, String ...arguments) + { + Mdc.setCaller(4); + Mdc.setObservation(o); + if (o.getAudit()) + { + audit.info(o, e, arguments); + } + if (o.getMetric()) + { + metrics.info(o, e, arguments); + } + Level l = o.getLevel(); + switch (l.toInt()) + { + case Level.WARN_INT: + errors.warn(o, arguments); + debug.debug(o, e, arguments); + break; + case Level.INFO_INT: + log.info(o, e, arguments); + debug.debug(o, e, arguments); + break; + case Level.ERROR_INT: + errors.error(o, arguments); + debug.debug(o, e, arguments); + break; + case Level.TRACE_INT: + debug.trace(o, e, arguments); + break; + case Level.DEBUG_INT: + debug.debug(o, e, arguments); + break; + default: + log.info(o, e, arguments); + } + Mdc.clearCaller(); + } + + public static void report(ObservationInterface o, String ...arguments) + { + Mdc.setCaller(4); + Mdc.setObservation(o); + if (o.getAudit()) + { + audit.info(o, arguments); + } + if (o.getMetric()) + { + metrics.info(o, arguments); + } + Level l = o.getLevel(); + switch (l.toInt()) + { + case Level.WARN_INT: + errors.warn(o, arguments); + debug.debug(o, arguments); + break; + case Level.INFO_INT: + log.info(o, arguments); + debug.debug(o, arguments); + break; + case Level.ERROR_INT: + errors.error(o, arguments); + debug.debug(o, arguments); + break; + case Level.TRACE_INT: + debug.debug(o, arguments); + break; + case Level.DEBUG_INT: + debug.debug(o, arguments); + break; + default: + log.info(o, arguments); + } + Mdc.clearCaller(); + } + +} diff --git a/cmso-service/src/main/java/org/onap/observations/ObservationInterface.java b/cmso-service/src/main/java/org/onap/observations/ObservationInterface.java new file mode 100644 index 0000000..16305bc --- /dev/null +++ b/cmso-service/src/main/java/org/onap/observations/ObservationInterface.java @@ -0,0 +1,48 @@ +/* + * Copyright © 2019 AT&T Intellectual Property. + * + * 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. + * + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. +*/ +package org.onap.observations; + +import javax.ws.rs.core.Response.Status; + +import org.apache.log4j.Level; + +import com.att.eelf.i18n.EELFResolvableErrorEnum; + +public interface ObservationInterface extends EELFResolvableErrorEnum +{ + public Enum getValue(); + public Level getLevel(); + public String getMessage(); + public Status getStatus(); + public String getDomain(); + public String name(); + public Boolean getAudit(); + public Boolean getMetric(); +} \ No newline at end of file diff --git a/cmso-service/src/main/java/org/onap/observations/ObservationObject.java b/cmso-service/src/main/java/org/onap/observations/ObservationObject.java new file mode 100644 index 0000000..639db76 --- /dev/null +++ b/cmso-service/src/main/java/org/onap/observations/ObservationObject.java @@ -0,0 +1,109 @@ +/* + * Copyright © 2019 AT&T Intellectual Property. + * + * 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. + * + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. +*/ +package org.onap.observations; + +import javax.ws.rs.core.Response.Status; + +import org.apache.log4j.Level; + +import com.att.eelf.i18n.EELFResolvableErrorEnum; +import com.att.eelf.i18n.EELFResourceManager; + + +public class ObservationObject implements ObservationInterface +{ + + //************************************************************************************************* + // Interface class that matches the ObservationInteface pattern + // This will be used in case we decide to provide external overrides and we need to instantiate + // For now, we'll just use the Enum itself. + // + // + private Enum value = null; + private Level level = null;; + private String message = null; + private Status status = null; + private String domain = null; + private Boolean metric = false; + private Boolean audit = false; + public ObservationObject(ObservationInterface o) + { + this.value = o.getValue(); + this.level = o.getLevel(); + this.message = o.getMessage(); + this.status = o.getStatus(); + this.domain = o.getDomain(); + this.metric = o.getMetric(); + this.audit = o.getAudit(); + + } + public Enum getValue() {return value;} + @Override + public String getMessage() {return message;} + @Override + public Status getStatus() {return status;} + @Override + public String getDomain() {return domain;} + + @Override + public Level getLevel() { + return level; + } + @Override + public String name() { + return value.name(); + } + @Override + public Boolean getAudit() { + return audit; + } + @Override + public Boolean getMetric() { + return metric; + } + + public String getMessage(String ...arguments) { + return EELFResourceManager.format((EELFResolvableErrorEnum)value, arguments); + } + public void setValue(Enum value) { + this.value = value; + } + public void setLevel(Level level) { + this.level = level; + } + public void setMessage(String message) { + this.message = message; + } + public void setStatus(Status status) { + this.status = status; + } + + +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/AuthProvider.java b/cmso-service/src/main/java/org/onap/optf/cmso/AuthProvider.java index 0f497b7..3d98897 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/AuthProvider.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/AuthProvider.java @@ -31,6 +31,7 @@ package org.onap.optf.cmso; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Profile; import org.springframework.core.env.Environment; import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; @@ -40,6 +41,8 @@ import org.springframework.stereotype.Component; import java.util.ArrayList; @Component +@Profile(SpringProfiles.PROPRIETARY__AUTHENTICATION) + public class AuthProvider implements AuthenticationProvider { diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/SecurityConfig.java b/cmso-service/src/main/java/org/onap/optf/cmso/SecurityConfig.java index a4802d2..ef12a6d 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/SecurityConfig.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/SecurityConfig.java @@ -33,6 +33,7 @@ package org.onap.optf.cmso; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; @@ -41,6 +42,7 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur @Configuration @EnableWebSecurity @ComponentScan("org.onap.optf") +@Profile(SpringProfiles.PROPRIETARY__AUTHENTICATION) public class SecurityConfig extends WebSecurityConfigurerAdapter { @Autowired diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/SpringProfiles.java b/cmso-service/src/main/java/org/onap/optf/cmso/SpringProfiles.java new file mode 100644 index 0000000..a2fdc69 --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/SpringProfiles.java @@ -0,0 +1,29 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.optf.cmso + * ================================================================================ + * Copyright © 2019 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.onap.optf.cmso; + +public class SpringProfiles +{ + + public static final String AAF_AUTHENTICATION = "aaf-auth"; + public static final String PROPRIETARY__AUTHENTICATION = "proprietary-auth"; + + private SpringProfiles(){} +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafAuthorizationFilter.java b/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafAuthorizationFilter.java new file mode 100644 index 0000000..25a1e77 --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafAuthorizationFilter.java @@ -0,0 +1,91 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.optf.cmso + * ================================================================================ + * Copyright © 2019 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.onap.optf.cmso.aaf; + +import java.io.IOException; +import java.util.List; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.onap.aaf.cadi.CadiWrap; +import org.onap.aaf.cadi.Permission; +import org.onap.observations.Observation; +import org.onap.optf.cmso.SpringProfiles; +import org.onap.optf.cmso.common.LogMessages; +import org.onap.optf.cmso.common.exceptions.CMSException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter; +import org.springframework.context.annotation.Profile; +import org.springframework.stereotype.Component; + +/** + * AAF authorization filter + */ + +@Component +@Profile(SpringProfiles.AAF_AUTHENTICATION) +public class AafAuthorizationFilter extends OrderedRequestContextFilter { + + @Autowired + AafUserRoleProperties userRoleProperties; + + public AafAuthorizationFilter() { + this.setOrder(FilterPriority.AAF_AUTHORIZATION.getPriority()); + + + } + + @Override + protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException { + try + { + if (request instanceof CadiWrap) + { + CadiWrap cw = (CadiWrap)request; + List perms = cw.getPermissions(cw.getUserPrincipal()); + if (userRoleProperties.processPermissions(request, perms)) + { + filterChain.doFilter(request,response); + } + else + { + Observation.report(LogMessages.UNAUTHORIZED); + ResponseFormatter.errorResponse(request, response, + new CMSException(LogMessages.UNAUTHORIZED.getStatus(), + LogMessages.UNAUTHORIZED, "")); + } + } + else + { + throw new Exception(); + } + } + catch (Exception e) + { + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + ResponseFormatter.errorResponse(request, response, + new CMSException(LogMessages.UNAUTHORIZED.getStatus(), + LogMessages.UNAUTHORIZED, "")); + } + } +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafFilter.java b/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafFilter.java new file mode 100644 index 0000000..1bdebdd --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafFilter.java @@ -0,0 +1,71 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.optf.cmso + * ================================================================================ + * Copyright © 2019 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.onap.optf.cmso.aaf; + + +import java.io.IOException; +import java.util.Properties; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.onap.aaf.cadi.PropAccess; +import org.onap.aaf.cadi.filter.CadiFilter; +import org.onap.observations.Observation; +import org.onap.optf.cmso.Application; +import org.onap.optf.cmso.SpringProfiles; +import org.onap.optf.cmso.common.LogMessages; +import org.onap.optf.cmso.common.exceptions.CMSException; +import org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter; +import org.springframework.context.annotation.Profile; +import org.springframework.stereotype.Component; + +/** + * AAF authentication filter + */ + +@Component +@Profile(SpringProfiles.AAF_AUTHENTICATION) +public class AafFilter extends OrderedRequestContextFilter { + + private final CadiFilter cadiFilter; + + public AafFilter() throws IOException, ServletException { + Properties cadiProperties = new Properties(); + cadiProperties.load(Application.class.getClassLoader().getResourceAsStream("cadi.properties")); + cadiFilter = new CadiFilter(new PropAccess(cadiProperties)); + this.setOrder(FilterPriority.AAF_AUTHENTICATION.getPriority()); + } + + @Override + protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException { + cadiFilter.doFilter(request, response, filterChain); + if(response.getStatus() ==401){ + Observation.report(LogMessages.UNAUTHENTICATED); + ResponseFormatter.errorResponse(request, response, + new CMSException(LogMessages.UNAUTHENTICATED.getStatus(), + LogMessages.UNAUTHENTICATED, "")); + } + } + + +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafPerm.java b/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafPerm.java new file mode 100644 index 0000000..ea9d324 --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafPerm.java @@ -0,0 +1,78 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.optf.cmso + * ================================================================================ + * Copyright © 2019 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.onap.optf.cmso.aaf; + +import java.util.HashSet; +import java.util.Set; + +import org.onap.aaf.cadi.aaf.AAFPermission; + + +public class AafPerm +{ + private String type; + private String instance; + private String action; + private Set actions = new HashSet<>(); + + public String getAction() { + return action; + } + public void setAction(String action) { + this.action = action; + String list[] = action.split(","); + for (String a : list) + actions.add(a); + } + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + public String getInstance() { + return instance; + } + public void setInstance(String instance) { + this.instance = instance; + } + + public Set getActions() { + return actions; + } + public void setActions(Set actions) { + this.actions = actions; + } + public boolean matches(AAFPermission userPerm) + { + if (type.equals(userPerm.getType())) + { + if (userPerm.getInstance().equals("*") || instance.equals("*") || userPerm.getInstance().equals(instance)) + { + for (String userAction : userPerm.getAction().split(",")) + { + if (userAction.equals("*") || actions.contains("*") || actions.contains(userAction)) + return true; + } + } + } + return false; + } +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafSecurityConfig.java b/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafSecurityConfig.java new file mode 100644 index 0000000..cb00a90 --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafSecurityConfig.java @@ -0,0 +1,59 @@ +/* + * Copyright © 2019 AT&T Intellectual Property. + * + * 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. + * + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. +*/ +package org.onap.optf.cmso.aaf; + +import org.onap.optf.cmso.SpringProfiles; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; + +@Configuration +@EnableWebSecurity +@ComponentScan("org.onap.optf") +@Profile(SpringProfiles.AAF_AUTHENTICATION) +public class AafSecurityConfig extends WebSecurityConfigurerAdapter { + + + @Override + protected void configure(AuthenticationManagerBuilder auth) throws Exception { + + } + + @Override + protected void configure(HttpSecurity http) throws Exception { + + http.csrf().disable(); + + } +} \ No newline at end of file diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafUserRole.java b/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafUserRole.java new file mode 100644 index 0000000..762cf3c --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafUserRole.java @@ -0,0 +1,127 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.optf.cmso + * ================================================================================ + * Copyright © 2019 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.onap.optf.cmso.aaf; + +import java.util.ArrayList; +import java.util.List; + +public class AafUserRole +{ + private String url = ""; + private String pathParts[] = {}; + private String perm = ""; + private String method = ""; + private List aafPerms = new ArrayList<>(); + + public AafUserRole(String url, String perm) + { + this.setUrl(url); + this.setPerm(perm); + pathParts = url.split("\\/"); + + String[] perms = perm.split(","); + for (String p : perms) + { + String parts[] = p.split(" "); + if (parts.length == 2) + method = parts[1]; + else + method = "ALL"; + + String[] list = parts[0].split("\\|"); + if (list.length == 3) + { + AafPerm aafPerm = new AafPerm(); + aafPerm.setAction(list[2]); + aafPerm.setInstance(list[1]); + aafPerm.setType(list[0]); + aafPerms.add(aafPerm); + } + } + } + public String getUrl() { + return url; + } + public void setUrl(String url) { + this.url = url; + } + public String getPerm() { + return perm; + } + public void setPerm(String perm) { + this.perm = perm; + } + public List getAafPerms() { + return aafPerms; + } + public void setAafPerms(List aafPerms) { + this.aafPerms = aafPerms; + } + + public boolean matches(String path, String matchMethod) + { + if (!this.method.equalsIgnoreCase("ALL") + && !this.method.equals("*") + && !this.method.equals(matchMethod)) + return false; + List inNodes = new ArrayList<>(); + List matchNodes = new ArrayList<>(); + String[] pathList = path.split("\\/"); + for (String n : pathList) + { + inNodes.add(n); + } + for (String n : pathParts) + { + matchNodes.add(n); + } + + while (!inNodes.isEmpty() && !matchNodes.isEmpty()) + { + String inNode = inNodes.remove(0); + String matchNode = matchNodes.get(0); + if (matchNode.equals(inNode) || matchNode.equals("*")) + { + matchNodes.remove(0); + } + else + { + if (!matchNode.equals("**")) + { + return false; + } + } + } + + // + if (inNodes.isEmpty() && matchNodes.isEmpty()) + return true; + + // We have incoming nodes remaining, see if we can wildcard them + if (matchNodes.size() == 1) + { + if (matchNodes.get(0).equals("**")) + return true; + if (inNodes.size() == 1 && matchNodes.get(0).equals("*")) + return true; + } + return false; + } +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafUserRoleProperties.java b/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafUserRoleProperties.java new file mode 100644 index 0000000..7a7598d --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafUserRoleProperties.java @@ -0,0 +1,128 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.optf.cmso + * ================================================================================ + * Copyright © 2019 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.onap.optf.cmso.aaf; + +import java.io.File; +import java.io.FileInputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +import javax.annotation.PostConstruct; +import javax.servlet.http.HttpServletRequest; + +import org.onap.aaf.cadi.Permission; +import org.onap.aaf.cadi.aaf.AAFPermission; +import org.onap.observations.Observation; +import org.onap.optf.cmso.SpringProfiles; +import org.onap.optf.cmso.common.LogMessages; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Profile; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.databind.ObjectMapper; +/** + * + * This class uses a properties file to map URL patterns/method to AAF Permissions (AafPerm) + * @author jf9860 + * + */ +@Component +@Profile(SpringProfiles.AAF_AUTHENTICATION) +public class AafUserRoleProperties +{ + @Autowired + Environment env; + + private List list = new ArrayList<>(); + + @PostConstruct + public void initializePermissions() + { + String userRolePropertiesName = env.getProperty("aaf.user.roles", "src/main/resources/aaf/AAFUserRoles.properties"); + Properties props = new Properties(); + try + { + props.load(new FileInputStream(new File(userRolePropertiesName))); + } + catch (Exception e) + { + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + } + for (Object url : props.keySet()) + { + Object value = props.get(url); + list.add(new AafUserRole((String)url, (String)value)); + } + } + + public List getForUrlMethod(String url, String method) + { + List userRoleList = new ArrayList<>(); + for (AafUserRole aur : list) + { + if (aur.matches(url, method)) + { + userRoleList.add(aur); + } + } + return userRoleList; + } + + public boolean processPermissions(HttpServletRequest request, List userPerms) + { + try + { + // Get list of perms that match incoming URL. May be more than 1... + // Users perms must match all that match URL + List perms = getForUrlMethod(request.getRequestURI(), request.getMethod()); + ObjectMapper om = new ObjectMapper(); + int tested = 0; + int passed = 0; + for (AafUserRole perm : perms) + { + for (AafPerm test : perm.getAafPerms()) + { + tested++; + for (Permission userPerm: userPerms) + { + + if (test.matches((AAFPermission)userPerm)) + { + passed++; + break; + } + } + } + } + // All permissions must be OK + if (tested > 0 && tested == passed) + return true; + else + return false; + } + catch (Exception e) + { + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + } + return false; + } +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/aaf/FilterPriority.java b/cmso-service/src/main/java/org/onap/optf/cmso/aaf/FilterPriority.java new file mode 100644 index 0000000..39981c7 --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/aaf/FilterPriority.java @@ -0,0 +1,35 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.optf.cmso + * ================================================================================ + * Copyright © 2019 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.onap.optf.cmso.aaf; + +import org.springframework.core.Ordered; + +public enum FilterPriority { + AAF_AUTHENTICATION(Ordered.HIGHEST_PRECEDENCE), + AAF_AUTHORIZATION(Ordered.HIGHEST_PRECEDENCE + 1); //higher number = lower priority + + private final int priority; + + FilterPriority(final int p) { + priority = p; + } + + public int getPriority() { return priority; } +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/aaf/ResponseFormatter.java b/cmso-service/src/main/java/org/onap/optf/cmso/aaf/ResponseFormatter.java new file mode 100644 index 0000000..769262b --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/aaf/ResponseFormatter.java @@ -0,0 +1,42 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.optf.cmso + * ================================================================================ + * Copyright © 2019 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.onap.optf.cmso.aaf; + +import java.io.IOException; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.core.MediaType; + +import org.onap.optf.cmso.common.exceptions.CMSException; + +class ResponseFormatter { + + private static final String ACCEPT_HEADER = "accept"; + + static void errorResponse(HttpServletRequest request, HttpServletResponse response, CMSException error) throws IOException { + String accept = request.getHeader(ACCEPT_HEADER) == null ? MediaType.APPLICATION_JSON : request.getHeader(ACCEPT_HEADER); + response.setStatus(error.getStatus().getStatusCode()); + response.getWriter().write(error.getRequestError().toString()); + response.getWriter().flush(); + response.getWriter().close(); + } + +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/common/LogMessages.java b/cmso-service/src/main/java/org/onap/optf/cmso/common/LogMessages.java index 6026bc4..efb4dd0 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/common/LogMessages.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/common/LogMessages.java @@ -1,6 +1,6 @@ /* - * Copyright 2017-2018 AT&T Intellectual Property. - * Modifications Copyright 2018 IBM. + * Copyright © 2017-2019 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,118 +34,204 @@ package org.onap.optf.cmso.common; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; + +import javax.ws.rs.core.Response.Status; + +import org.apache.log4j.Level; +import org.onap.observations.ObservationInterface; + import com.att.eelf.configuration.EELFManager; -import com.att.eelf.i18n.EELFResolvableErrorEnum; import com.att.eelf.i18n.EELFResourceManager; -public enum LogMessages implements EELFResolvableErrorEnum { - - // Let developer provide the initial properties here. - // We can merge them to logmessages.properties when we need to. - SEARCH_SCHEDULE_REQUEST_DETAILS("Search Schedule Request Details {0} from {1}: {2}"), SEARCH_SCHEDULE_REQUEST( - "Search Schedule Request {0} from {1}: {2} : {3}"), CREATE_SCHEDULE_REQUEST( - "Create Schedule Request {0} from {1}: {2} : {3}"), DELETE_SCHEDULE_REQUEST( - "Delete Schedule Request {0} from {1}: {2} : {3}"), GET_SCHEDULE_REQUEST_INFO( - "Get Schedule Request Info {0} from {1}: {2} : {3}"), PROCESS_OPTIMIZER_CALLBACK( - "Change management optimizer callback {0} from {1}: {2} "), APPROVE_SCHEDULE_REQUEST( - "Approve Schedule Request {0} from {1}: {2} : {3}"), SCHEDULE_ALREADY_EXISTS( - "Schedule already exists domain={0} schedule id={1}"), SCHEDULE_NOT_FOUND( - "Schedule not found domain={0} schedule id={1}"), INVALID_ATTRIBUTE( - "Invalid attribute {0}={1}"), MISSING_REQUIRED_ATTRIBUTE( - "Missing required attribute '{0}'"), INVALID_REQUEST( - "The input data structure is incorrect"), REQUEST_TIMED_OUT( - "Request timed out."), UNEXPECTED_EXCEPTION( - "Unexpected exception encountered during processing. Please contact support : {0}"), AUTHORIZATION_FAILED( - "Authorization Failed"), UNDEFINED_DOMAIN_DATA_ATTRIBUTE( - "Domain data attribute not defined domain={0} name={1} value={2}"), UNDEFINED_FILTER_ATTRIBUTE( - "Undefined filter attribute {0}"), INVALID_DATE_FILTER( - "Invalid date filter provided {0}=(1}"), OPTIMIZER_QUARTZ_JOB( - "Quartz scheduling of OptimizerQuartzJob: {0}"), OPTIMIZER_EXCEPTION( - "Exception making client call to optimizer {0}"), OPTIMIZER_CALLBACK_STATE_ERROR( - "Optimizer callback on schedule in invalid state. Should be {0} but was {1}."), CHANGE_MANAGEMENT_GROUP_NOT_FOUND( - "ChangeManagementGroup not found on optimizer callback scheduleId={0} groupId={1}"), UNABLE_TO_ALLOCATE_VNF_TIMESLOTS( - "Unable to allocate VNF timeslots with Optimizer results startTime={0}, latestStartTime={1}, totalDuration={2}, concurrency={3} nvfs={4}"), UNABLE_TO_LOCATE_SCHEDULE_DETAIL( - "Unable to locate ChangeManagementSchedule for VNF. scheduleId={0}, groupId={1}, vnfName={2}"), CM_JOB( - "Quartz scheduling of CmJob: {0}"), CM_QUARTZ_JOB( - "Quartz scheduling of CmQuartzJob: {0}"), NOT_PENDING_APPROVAL( - "Approval request received for schedule that is not in Pending Approval state: domain={0} scheduleId={1} state={3}"), SCHEDULE_PAST_DUE( - "Attempt to dispatch an event that is Past due scheduleId={0}, vnf={1}, now={2}, startTime={3}"), MSO_POLLING_MISSING_SCHEDULE( - "Attempt to poll MSO for request id {1} for missing ChangeManagementSchedule id={0}"), MSO_STATUS_JOB( - "Polling MSO {0} for requestId={1} for id={2}"), UNEXPECTED_RESPONSE( - "Unexpected response from {0} HTTP Status={1} : {2}"), SCHEDULE_STATUS_JOB( - "Quartz scheduling of ScheduleStatusJob: {0}"), CM_TICKET_NOT_APPROVED( - "Attempt to dispatch a change management event that has no TM Ticket approved. scheduleId={0} VNF Name={1} TM ChangeId={2} Status={3} Approval Status={4}"), MULTIPLE_GROUPS_NOT_SUPPORTED( - "Multiple groups not supported on immediate requests"), TM_CREATE_CHANGE_RECORD( - "TM Create Change Record:{0} : Schedule ID: {1}"), TM_LIST( - "TM list:{0} : URL : {1}"), TM_API( - "TM API Call: URL : {0}"), UNABLE_TO_CREATE_CHANGE_TICKET( - "Unable to create change ticket in TM: Schedule ID: {0} : Reason : {1}"), TM_UPDATE_CHECKLIST( - "TM Fetch Checklist:{0} : Schedule ID: {1} : Change Id : {2} : URL : {3}"), OPTIMIZER_REQUEST( - "Optimi Request:{0} : Schedule ID: {1} : URL : {2}"), TM_CLOSE_CHANGE_RECORD( - "TM Close Change Record:{0} : Schedule ID: {1} : Change Id : {2}"), UNABLE_TO_CLOSE_CHANGE_TICKET( - "Unable to close change ticket in TM: Schedule ID: {0} : changeid: {1} : Reason: {2}"), CANNOT_CANCEL_IN_PROGRESS( - "Cannot delete/cancel a schedule with events in progress."), UNABLE_TO_PARSE_SCHEDULING_INFO( - "Cannot parse scheduling info."), UNABLE_TO_LOCATE_CHANGE_RECORD( - "Unable to locate TM change record {2} to check status before displacth of {1} for schedulId={0}"), INVALID_CHANGE_WINDOW( - "Change window end time {1} must be after start time {0}"), NODE_LIST_CONTAINS_EMTPY_NODE( - "vnfDetails node list contains at least one empty node."), SO_API( - "SO Poll Request {0}"), EXPECTED_EXCEPTION( - "Expected exception encountered during processing. Make Sonar happy: {0}"), TM_UPDATE_CHANGE_RECORD( - "TM Update Change Record:{0} : Schedule ID: {1} : Change Id : {2} : URL : {3}"), UNABLE_TO_UPDATE_CHANGE_TICKET( - "Unable to update change ticket in TM: Schedule ID: {0} : changeid: {1} : Reason: {2}"),; +public enum LogMessages implements ObservationInterface { - private final String defaultId; - private final String defaultMessage; - private final String defaultResolution; - private final String defaultAction; + SEARCH_SCHEDULE_REQUEST_DETAILS("Search Schedule Request Details {0} from {1}: {2}", Status.OK, Level.INFO), + SEARCH_SCHEDULE_REQUEST("Search Schedule Request {0} from {1}: {2} : {3}", Status.OK, Level.INFO), + CREATE_SCHEDULE_REQUEST("Create Schedule Request {0} from {1}: {2} : {3}", Status.OK, Level.INFO), + DELETE_SCHEDULE_REQUEST("Delete Schedule Request {0} from {1}: {2} : {3}", Status.OK, Level.INFO), + GET_SCHEDULE_REQUEST_INFO("Get Schedule Request Info {0} from {1}: {2} : {3}", Status.OK, Level.INFO), + PROCESS_OPTIMIZER_CALLBACK("Change management optimizer callback {0} from {1}: {2} ", Status.OK, Level.INFO), + APPROVE_SCHEDULE_REQUEST("Approve Schedule Request {0} from {1}: {2} : {3}", Status.OK, Level.INFO), + SCHEDULE_ALREADY_EXISTS("Schedule already exists domain={0} schedule id={1}", Status.OK, Level.INFO), + SCHEDULE_NOT_FOUND("Schedule not found domain={0} schedule id={1}", Status.BAD_REQUEST, Level.INFO), + INVALID_ATTRIBUTE("Invalid attribute {0}={1}", Status.BAD_REQUEST, Level.INFO), + MISSING_REQUIRED_ATTRIBUTE("Missing required attribute '{0}'", Status.BAD_REQUEST, Level.INFO), + INVALID_REQUEST("The input data structure is incorrect", Status.BAD_REQUEST, Level.INFO), + REQUEST_TIMED_OUT("Request timed out.", Status.INTERNAL_SERVER_ERROR, Level.ERROR), + UNEXPECTED_EXCEPTION("Unexpected exception encountered during processing. Please contact support : {0}", Status.INTERNAL_SERVER_ERROR, Level.ERROR), + UNDEFINED_DOMAIN_DATA_ATTRIBUTE("Domain data attribute not defined domain={0} name={1} value={2}", Status.BAD_REQUEST, Level.INFO), + UNDEFINED_FILTER_ATTRIBUTE("Undefined filter attribute {0}", Status.BAD_REQUEST, Level.INFO), + INVALID_DATE_FILTER("Invalid date filter provided {0}=(1}", Status.BAD_REQUEST, Level.INFO), + OPTIMIZER_QUARTZ_JOB("Quartz scheduling of OptimizerQuartzJob: {0}", Status.OK, Level.INFO), + OPTIMIZER_EXCEPTION("Exception making client call to optimizer {0}", Status.INTERNAL_SERVER_ERROR, Level.ERROR), + OPTIMIZER_CALLBACK_STATE_ERROR("Optimizer callback on schedule in invalid state. Should be {0} but was {1}.", Status.INTERNAL_SERVER_ERROR, Level.ERROR), + CHANGE_MANAGEMENT_GROUP_NOT_FOUND("ChangeManagementGroup not found on optimizer callback scheduleId={0} groupId={1}", Status.NOT_FOUND, Level.INFO), + INCOMING_MESSAGE("Incoming message method={0} path={1}", Status.OK, Level.INFO, true, false), + INCOMING_MESSAGE_RESPONSE("Message response method={0} path={1} status={2}", Status.OK, Level.INFO, true, false), + OUTGOING_MESSAGE("Outgoing message method={0} path={1}", Status.OK, Level.INFO, true, false), + OUTGOING_MESSAGE_RETURNED("Outgoing message returned method={0} path={1} status={2}", Status.OK, Level.INFO, true, false), - private LogMessages(String message) { - defaultMessage = message; - this.defaultId = this.name(); - this.defaultResolution = "No resolution needed"; - this.defaultAction = "No action is required"; - } + // TODO: Review the status and level of the remaining enums + UNABLE_TO_ALLOCATE_VNF_TIMESLOTS("Unable to allocate VNF timeslots with Optimizer results startTime={0}, latestStartTime={1}, totalDuration={2}, concurrency={3} nvfs={4}", Status.OK, Level.INFO), + UNABLE_TO_LOCATE_SCHEDULE_DETAIL("Unable to locate ChangeManagementSchedule for VNF. scheduleId={0}, groupId={1}, vnfName={2}", Status.OK, Level.INFO), + CM_JOB("Quartz scheduling of CmJob: {0}", Status.OK, Level.INFO), + CM_QUARTZ_JOB("Quartz scheduling of CmQuartzJob: {0}", Status.OK, Level.INFO), + NOT_PENDING_APPROVAL("Approval request received for schedule that is not in Pending Approval state: domain={0} scheduleId={1} state={3}", Status.OK, Level.INFO), + SCHEDULE_PAST_DUE("Attempt to dispatch an event that is Past due scheduleId={0}, vnf={1}, now={2}, startTime={3}", Status.OK, Level.INFO), + MSO_POLLING_MISSING_SCHEDULE("Attempt to poll MSO for request id {1} for missing ChangeManagementSchedule id={0}", Status.OK, Level.INFO), + MSO_STATUS_JOB("Polling MSO {0} for requestId={1} for id={2}", Status.OK, Level.INFO), + UNEXPECTED_RESPONSE("Unexpected response from {0} HTTP Status={1} : {2}", Status.OK, Level.INFO), + SCHEDULE_STATUS_JOB("Quartz scheduling of ScheduleStatusJob: {0}", Status.OK, Level.INFO), + CM_TICKET_NOT_APPROVED("Attempt to dispatch a change management event that has no TM Ticket approved. scheduleId={0} VNF Name={1} TM ChangeId={2} Status={3} Approval Status={4}", Status.OK, Level.INFO), + MULTIPLE_GROUPS_NOT_SUPPORTED("Multiple groups not supported on immediate requests", Status.OK, Level.INFO), + TM_CREATE_CHANGE_RECORD("TM Create Change Record:{0} : Schedule ID: {1}", Status.OK, Level.INFO), + TM_LIST("TM list:{0} : URL : {1}", Status.OK, Level.INFO), + TM_API("TM API Call: URL : {0}", Status.OK, Level.INFO), + UNABLE_TO_CREATE_CHANGE_TICKET("Unable to create change ticket in TM: Schedule ID: {0} : Reason : {1}", Status.OK, Level.INFO), + TM_UPDATE_CHECKLIST("TM Fetch Checklist:{0} : Schedule ID: {1} : Change Id : {2} : URL : {3}", Status.OK, Level.INFO), + OPTIMIZER_REQUEST("Optimi Request:{0} : Schedule ID: {1} : URL : {2}", Status.OK, Level.INFO), + TM_CLOSE_CHANGE_RECORD("TM Close Change Record:{0} : Schedule ID: {1} : Change Id : {2}", Status.OK, Level.INFO), + UNABLE_TO_CLOSE_CHANGE_TICKET("Unable to close change ticket in TM: Schedule ID: {0} : changeid: {1} : Reason: {2}", Status.OK, Level.INFO), + CANNOT_CANCEL_IN_PROGRESS("Cannot delete/cancel a schedule with events in progress.", Status.OK, Level.INFO), + UNABLE_TO_PARSE_SCHEDULING_INFO("Cannot parse scheduling info.", Status.OK, Level.INFO), + UNABLE_TO_LOCATE_CHANGE_RECORD("Unable to locate TM change record {2} to check status before displacth of {1} for schedulId={0}", Status.OK, Level.INFO), + INVALID_CHANGE_WINDOW("Change window end time {1} must be after start time {0}", Status.OK, Level.INFO), + NODE_LIST_CONTAINS_EMTPY_NODE("vnfDetails node list contains at least one empty node.", Status.OK, Level.INFO), + SO_API("SO Poll Request {0}", Status.OK, Level.INFO), + EXPECTED_EXCEPTION("Expected exception encountered during processing. {0}", Status.OK, Level.INFO), + TM_UPDATE_CHANGE_RECORD("TM Update Change Record:{0} : Schedule ID: {1} : Change Id : {2} : URL : {3}", Status.OK, Level.INFO), + UNABLE_TO_UPDATE_CHANGE_TICKET("Unable to update change ticket in TM: Schedule ID: {0} : changeid: {1} : Reason: {2}", Status.OK, Level.INFO), + UNAUTHORIZED("Authorization failed.", Status.FORBIDDEN, Level.INFO), + UNAUTHENTICATED("Authentication failed.", Status.UNAUTHORIZED, Level.INFO), + UNRECOGNIZED_MSO_STATUS("Unrecognized status returned by MSO {0}", Status.INTERNAL_SERVER_ERROR, Level.ERROR), + UNABLE_TO_PARSE_MSO_RESPONSE("Unable to parse status message from MSO {0} : {1}", Status.INTERNAL_SERVER_ERROR, Level.ERROR), + ; + private final String defaultId; + private final String defaultMessage; + private final String defaultResolution; + private final String defaultAction; - private LogMessages(String message, String id, String resolution, String action) { - defaultMessage = message; - this.defaultId = id; - this.defaultResolution = resolution; - this.defaultAction = action; - } + private final Status status; + private final Level level; + private final Boolean audit; + private final Boolean metric; - static { - EELFResourceManager.loadMessageBundle("logmessages"); - } + + private LogMessages(String message, Status code, Level l) + { + defaultMessage = message; + level=l; + status = code; + this.defaultId = this.name(); + this.defaultResolution = "No resolution needed"; + this.defaultAction = "No action is required"; + this.audit = false; + this.metric = false; + } - public String genProperties() { - // Use this to regenerate properties file. The desire to change messages without - // updating code is - // well understood, but the developer should be able to code the defaults - // without having to update 2 different files and - // get it wrong. - StringBuilder sb = new StringBuilder(); - sb.append("# Generated from ").append(this.getClass().getName()).append("\n"); - for (LogMessages lm : values()) { - sb.append(lm.name()); - sb.append(" ").append(lm.defaultId); - sb.append("|").append(lm.defaultMessage); - sb.append("|").append(lm.defaultResolution); - sb.append("|").append(lm.defaultAction); - sb.append("\n"); - } - return sb.toString(); - } + private LogMessages(String message, Status code, Level l, Boolean audit, Boolean metric) + { + defaultMessage = message; + level=l; + status = code; + this.audit = audit; + this.metric = metric; + this.defaultId = this.name(); + this.defaultResolution = "No resolution needed"; + this.defaultAction = "No action is required"; + } + + private LogMessages(String message, Status code, Level l, String id, String resolution, String action) + { + level=l; + status = code; + defaultMessage = message; + this.defaultId = id; + this.defaultResolution = resolution; + this.defaultAction = action; + this.audit = false; + this.metric = false; + } + + static { + EELFResourceManager.loadMessageBundle("logmessages"); + } + + public String genProperties() + { + // Use this to regenerate properties file. The desire to change messages without updating code is + // well understood, but the developer should be able to code the defaults without having to update 2 different files and + // get it wrong. + StringBuilder sb = new StringBuilder(); + sb.append("# Generated from ").append(this.getClass().getName()).append("\n"); + for (LogMessages lm : values()) + { + sb.append(lm.name()); + sb.append(" ").append(lm.defaultId); + sb.append("|").append(lm.defaultMessage); + sb.append("|").append(lm.defaultResolution); + sb.append("|").append(lm.defaultAction); + sb.append("\n"); + } + return sb.toString(); + } - public static void main(String argv[]) { - System.out.println(LogMessages.CREATE_SCHEDULE_REQUEST.genProperties()); - try { - Files.write(Paths.get("src/main/resources/logmessages.properties"), - LogMessages.CREATE_SCHEDULE_REQUEST.genProperties().getBytes()); - } catch (IOException e) { - EELFManager.getInstance().getDebugLogger().debug("Failed to update properties file.", e); + + // interface methods + @Override + public Level getLevel() {return level;} + @Override + public String getMessage() {return defaultMessage;} + @Override + public Status getStatus() {return status;} + @Override + public Enum getValue() {return this;} + @Override + public String getDomain() {return this.getClass().getSimpleName();} + @Override + public Boolean getAudit() { return audit; } + @Override + public Boolean getMetric() { return metric; } + + public static void main(String argv[]) + { + System.out.println(LogMessages.UNEXPECTED_EXCEPTION.genProperties()); + try + { + Files.write(Paths.get("src/main/resources/logmessages.properties"), LogMessages.UNEXPECTED_EXCEPTION.genProperties().getBytes()); + } + catch (IOException e) + { + EELFManager.getInstance().getDebugLogger().debug("Failed to update properties file.", e); - } + } + StringBuilder sb = new StringBuilder(); + sb.append("

Cell Site Selection Scheduler mS Observations

\n\n"); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("\n"); + for (LogMessages m : LogMessages.values()) + { + if (m.level == Level.ERROR || m.level == Level.WARN || m.level == Level.FATAL) + { + sb.append(""); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("\n"); + } + } + try + { + Files.write(Paths.get("logmessages.html"), sb.toString().getBytes()); + } + catch (IOException e) + { + EELFManager.getInstance().getDebugLogger().debug("Failed to update properties html file.", e); - } + } + + } } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CmJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CmJob.java index de78385..880566a 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CmJob.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CmJob.java @@ -1,6 +1,6 @@ /* - * Copyright 2017-2018 AT&T Intellectual Property. - * Modifications Copyright 2018 IBM. + * Copyright © 2017-2019 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,17 +32,20 @@ package org.onap.optf.cmso.dispatcher; import java.util.Map; + import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.Invocation; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; + +import org.onap.observations.Mdc; import org.onap.optf.cmso.common.BasicAuthenticatorFilter; import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.common.Mdc; import org.onap.optf.cmso.common.PropertiesManagement; import org.onap.optf.cmso.eventq.DispatchedEventList; +import org.onap.optf.cmso.filters.CMSOClientFilters; import org.onap.optf.cmso.model.dao.ChangeManagementGroupDAO; import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO; import org.onap.optf.cmso.model.dao.ScheduleDAO; @@ -55,6 +58,7 @@ import org.quartz.SchedulerException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; + import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; @@ -121,13 +125,12 @@ public class CmJob implements Job { String pass = pm.getProperty("mechid.pass", ""); Client client = ClientBuilder.newClient(); client.register(new BasicAuthenticatorFilter(user, pass)); + client.register(new CMSOClientFilters()); WebTarget target = client.target(url); Invocation.Builder invocationBuilder = target.request(MediaType.APPLICATION_JSON); Response response = null; try { - Mdc.metricStart(id.toString(), url); response = invocationBuilder.get(); - Mdc.metricEnd(response); metrics.info(LogMessages.CM_JOB, id.toString()); switch (response.getStatus()) { case 200: diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispatcherServiceImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispatcherServiceImpl.java index 1e8a937..3aab301 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispatcherServiceImpl.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispatcherServiceImpl.java @@ -1,6 +1,6 @@ /* - * Copyright 2017-2018 AT&T Intellectual Property. - * Modifications Copyright 2018 IBM. + * Copyright © 2017-2019 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,12 +31,11 @@ package org.onap.optf.cmso.dispatcher.rs; -import java.util.UUID; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; + import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.common.Mdc; import org.onap.optf.cmso.dispatcher.DispatchJob; import org.onap.optf.cmso.optimizer.CMSOptimizerClient; import org.onap.optf.cmso.sostatus.MsoStatusClient; @@ -44,6 +43,7 @@ import org.onap.optf.cmso.ticketmgt.TmStatusClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.transaction.annotation.Transactional; + import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; @@ -69,8 +69,7 @@ public class DispatcherServiceImpl implements DispacherService { @Override @Transactional public Response dispatchSchedule(Integer id, UriInfo uri, HttpServletRequest request) { - Mdc.begin(request, UUID.randomUUID().toString()); - log.info("dispatchVID entered {}", id); + debug.debug("dispatchSchedule entered {}" , id); try { dispatchJob.execute(id); } catch (Exception e) { @@ -78,16 +77,13 @@ public class DispatcherServiceImpl implements DispacherService { debug.error(e.getMessage(), e); } Response response = Response.ok().build(); - Mdc.end(response); - audit.info("dispatchVID"); return response; } @Override @Transactional public Response dispatchOptimizer(Integer id, UriInfo uri, HttpServletRequest request) { - Mdc.begin(request, UUID.randomUUID().toString()); - log.info("Dispatch.exec entered {}", id); + debug.debug("dispatchOptimizer entered {}", id); try { sniroClient.scheduleSniroOptimization(id); } catch (Exception e) { @@ -95,7 +91,6 @@ public class DispatcherServiceImpl implements DispacherService { debug.error(e.getMessage(), e); } Response response = Response.ok().build(); - Mdc.end(response); audit.info("dispatchSNIRO"); return response; } @@ -103,8 +98,7 @@ public class DispatcherServiceImpl implements DispacherService { @Override @Transactional public Response dispatchScheduleStatus(Integer id, UriInfo uri, HttpServletRequest request) { - Mdc.begin(request, UUID.randomUUID().toString()); - log.info("Dispatch.exec entered {}", id); + debug.debug("dispatchScheduleStatus entered {}", id); try { tmStatusClient.checkStatus(id); } catch (Exception e) { @@ -112,16 +106,13 @@ public class DispatcherServiceImpl implements DispacherService { debug.error(e.getMessage(), e); } Response response = Response.ok().build(); - Mdc.end(response); - audit.info("dispatchScheduleStatus"); return response; } @Override @Transactional public Response dispatchSoStatus(Integer id, UriInfo uri, HttpServletRequest request) { - Mdc.begin(request, UUID.randomUUID().toString()); - log.info("Dispatch.exec entered {}", id); + debug.debug("dispatchSoStatus entered {}", id); try { msoStatusClient.execute(id); } catch (Exception e) { @@ -129,8 +120,6 @@ public class DispatcherServiceImpl implements DispacherService { debug.error(e.getMessage(), e); } Response response = Response.ok().build(); - Mdc.end(response); - audit.info("dispatchMsoStatus"); return response; } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CmQuartzJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CmQuartzJob.java index 08017cf..f3d98b3 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CmQuartzJob.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CmQuartzJob.java @@ -1,6 +1,6 @@ /* - * Copyright 2017-2018 AT&T Intellectual Property. - * Modifications Copyright 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,8 +31,8 @@ package org.onap.optf.cmso.eventq; +import org.onap.observations.Mdc; import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.common.Mdc; import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO; import org.quartz.DisallowConcurrentExecution; import org.quartz.JobExecutionContext; diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/filters/CMSOClientFilters.java b/cmso-service/src/main/java/org/onap/optf/cmso/filters/CMSOClientFilters.java index 6396dca..5e29607 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/filters/CMSOClientFilters.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/filters/CMSOClientFilters.java @@ -1,6 +1,6 @@ /* - * Copyright 2017-2018 AT&T Intellectual Property. - * Modifications Copyright 2018 IBM. + * Copyright © 2017-2019 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,16 +32,23 @@ package org.onap.optf.cmso.filters; import static com.att.eelf.configuration.Configuration.MDC_KEY_REQUEST_ID; + import java.io.IOException; + import javax.ws.rs.client.ClientRequestContext; import javax.ws.rs.client.ClientRequestFilter; import javax.ws.rs.client.ClientResponseContext; import javax.ws.rs.client.ClientResponseFilter; import javax.ws.rs.core.MultivaluedMap; + +import org.onap.observations.Mdc; +import org.onap.observations.Observation; +import org.onap.optf.cmso.common.LogMessages; import org.onap.optf.cmso.filters.MessageHeaders.HeadersEnum; import org.onap.optf.cmso.service.rs.CMSOServiceImpl; import org.slf4j.MDC; import org.springframework.stereotype.Component; + import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; @@ -54,14 +61,23 @@ public class CMSOClientFilters implements ClientRequestFilter, ClientResponseFil @Override public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException { - // On the way back - log.info("SchedulerClientFilters.filter(r,r)"); + // On the way back + Mdc.metricEnd(responseContext); + Mdc.setCaller(17); + Observation.report(LogMessages.OUTGOING_MESSAGE_RETURNED, + requestContext.getMethod(), + requestContext.getUri().getPath().toString(), + responseContext.getStatusInfo().toString()); } @Override public void filter(ClientRequestContext requestContext) throws IOException { - // On the way out - log.info("SchedulerClientFilters.filter(r)" + requestContext.getUri().getPath()); + // On the way out + Mdc.metricStart(requestContext); + Mdc.setCaller(17); + Observation.report(LogMessages.OUTGOING_MESSAGE, + requestContext.getMethod(), + requestContext.getUri().getPath().toString()); MultivaluedMap headers = requestContext.getHeaders(); String transactionId = (String) headers.getFirst(MessageHeaders.HeadersEnum.TransactionID.toString()); diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/filters/CMSOContainerFilters.java b/cmso-service/src/main/java/org/onap/optf/cmso/filters/CMSOContainerFilters.java index 784ab5a..8b37a71 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/filters/CMSOContainerFilters.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/filters/CMSOContainerFilters.java @@ -1,6 +1,6 @@ /* - * Copyright 2017-2018 AT&T Intellectual Property. - * Modifications Copyright 2018 IBM. + * Copyright © 2017-2019 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,34 +33,44 @@ package org.onap.optf.cmso.filters; import java.io.IOException; import java.util.UUID; + import javax.annotation.Priority; +import javax.servlet.http.HttpServletRequest; import javax.ws.rs.WebApplicationException; import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.container.ContainerRequestFilter; import javax.ws.rs.container.ContainerResponseContext; import javax.ws.rs.container.ContainerResponseFilter; +import javax.ws.rs.core.Context; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.ResponseBuilder; import javax.ws.rs.ext.Provider; + +import org.onap.observations.Mdc; +import org.onap.observations.Observation; import org.onap.optf.cmso.common.LogMessages; import org.onap.optf.cmso.filters.MessageHeaders.HeadersEnum; -import org.onap.optf.cmso.service.rs.CMSOServiceImpl; import org.springframework.stereotype.Component; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; @Priority(1) @Provider @Component public class CMSOContainerFilters implements ContainerRequestFilter, ContainerResponseFilter { - private static EELFLogger log = EELFManager.getInstance().getLogger(CMSOServiceImpl.class); + + + @Context + private HttpServletRequest servletRequest; @Override public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException { try { - log.info("SchedulerContainerFilters.filter(r,r)"); + Mdc.auditEnd(requestContext, responseContext); + Observation.report(LogMessages.INCOMING_MESSAGE_RESPONSE, + requestContext.getMethod(), + requestContext.getUriInfo().getPath().toString(), + responseContext.getStatusInfo().toString()); MultivaluedMap reqHeaders = requestContext.getHeaders(); MultivaluedMap respHeaders = responseContext.getHeaders(); String minorVersion = (String) reqHeaders.getFirst(HeadersEnum.MinorVersion.toString()); @@ -70,9 +80,9 @@ public class CMSOContainerFilters implements ContainerRequestFilter, ContainerRe } catch (Exception e) { if (e instanceof WebApplicationException) { - log.info(LogMessages.EXPECTED_EXCEPTION, e.getMessage()); + Observation.report(LogMessages.EXPECTED_EXCEPTION, e.getMessage()); } else { - log.info(LogMessages.UNEXPECTED_EXCEPTION, e.getMessage()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e.getMessage()); } } } @@ -81,7 +91,10 @@ public class CMSOContainerFilters implements ContainerRequestFilter, ContainerRe public void filter(ContainerRequestContext requestContext) throws IOException { try { // On the way in - log.info("SchedulerContainerFilters.filter(r) path={} ", requestContext.getUriInfo().getPath().toString()); + Mdc.auditStart(requestContext, servletRequest); + Observation.report(LogMessages.INCOMING_MESSAGE, + requestContext.getMethod(), + requestContext.getUriInfo().getPath().toString()); String majorVersion = requestContext.getUriInfo().getPath(); if (majorVersion != null) { @@ -116,10 +129,10 @@ public class CMSOContainerFilters implements ContainerRequestFilter, ContainerRe } } catch (Exception e) { if (e instanceof WebApplicationException) { - log.info(LogMessages.EXPECTED_EXCEPTION, e.getMessage()); + Observation.report(LogMessages.EXPECTED_EXCEPTION, e.getMessage()); throw e; } else { - log.info(LogMessages.UNEXPECTED_EXCEPTION, e.getMessage()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e.getMessage()); } } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CMSOptimizerClient.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CMSOptimizerClient.java index 153e4a8..5d500d2 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CMSOptimizerClient.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CMSOptimizerClient.java @@ -1,6 +1,6 @@ /* - * Copyright 2017-2018 AT&T Intellectual Property. - * Modifications Copyright 2018 IBM. + * Copyright © 2017-2019 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.UUID; + import javax.ws.rs.ProcessingException; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; @@ -44,10 +45,12 @@ import javax.ws.rs.client.ResponseProcessingException; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; + +import org.onap.observations.Mdc; +import org.onap.observations.Observation; import org.onap.optf.cmso.common.BasicAuthenticatorFilter; import org.onap.optf.cmso.common.CMSStatusEnum; import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.common.Mdc; import org.onap.optf.cmso.common.PropertiesManagement; import org.onap.optf.cmso.filters.CMSOClientFilters; import org.onap.optf.cmso.model.Schedule; @@ -64,15 +67,13 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; + import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.databind.ObjectMapper; @Component public class CMSOptimizerClient { - private static EELFLogger log = EELFManager.getInstance().getLogger(CMSOptimizerClient.class); - private static EELFLogger metrics = EELFManager.getInstance().getMetricsLogger(); - private static EELFLogger errors = EELFManager.getInstance().getErrorLogger(); private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); @Autowired @@ -117,7 +118,7 @@ public class CMSOptimizerClient { } buildRequest(cmReq, info, schedule, snirocallbackurl); } catch (Exception e) { - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString()); schedule.setOptimizerMessage("Unexpected exception: " + e.getMessage()); updateScheduleStatus(schedule); @@ -146,13 +147,9 @@ public class CMSOptimizerClient { updateScheduleStatus(schedule); debug.debug("SNIRO url / user: " + snirourl + " / " + username); debug.debug("SNIRO Request: " + new ObjectMapper().writeValueAsString(cmReq)); - log.info(LogMessages.OPTIMIZER_REQUEST, "Begin", schedule.getScheduleId(), snirourl); - Mdc.metricStart(schedule.getScheduleId(), snirourl); + Observation.report(LogMessages.OPTIMIZER_REQUEST, "Begin", schedule.getScheduleId(), snirourl); Response response = invocationBuilder.post(Entity.json(cmReq)); - - Mdc.metricEnd(response); - metrics.info(LogMessages.OPTIMIZER_REQUEST, "End", schedule.getScheduleId(), snirourl); - log.info(LogMessages.OPTIMIZER_REQUEST, "End", schedule.getScheduleId(), snirourl); + Observation.report(LogMessages.OPTIMIZER_REQUEST, "End", schedule.getScheduleId(), snirourl); switch (response.getStatus()) { case 202: debug.debug("Successfully scheduled optimization: " + schedule.getScheduleId()); @@ -171,7 +168,7 @@ public class CMSOptimizerClient { tries++; schedule.setOptimizerAttemptsToSchedule(tries); updateScheduleStatus(schedule); - errors.error(LogMessages.OPTIMIZER_EXCEPTION, message); + Observation.report(LogMessages.OPTIMIZER_EXCEPTION, message); return true; } @@ -188,7 +185,7 @@ public class CMSOptimizerClient { updateScheduleStatus(schedule); /// Got processing error response // may be transient, wait for next cycle. - errors.error(LogMessages.OPTIMIZER_EXCEPTION, message); + Observation.report(LogMessages.OPTIMIZER_EXCEPTION, message); // Wait until next cycle and try again. return false; } @@ -207,7 +204,7 @@ public class CMSOptimizerClient { updateScheduleStatus(schedule); // Getting invalid response from SNIRO. // May be data related. - errors.error(LogMessages.OPTIMIZER_EXCEPTION, e, e.getMessage()); + Observation.report(LogMessages.OPTIMIZER_EXCEPTION, e, e.getMessage()); return false; } catch (ProcessingException e) { @@ -216,12 +213,12 @@ public class CMSOptimizerClient { schedule.setStatus(CMSStatusEnum.PendingSchedule.toString()); updateScheduleStatus(schedule); /// Cannot connect to SNIRO - errors.error(LogMessages.OPTIMIZER_EXCEPTION, e, e.getMessage()); + Observation.report(LogMessages.OPTIMIZER_EXCEPTION, e, e.getMessage()); // Wait until next cycle return false; } } catch (Exception e) { - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); } finally { Mdc.restore(mdcSave); @@ -285,7 +282,7 @@ public class CMSOptimizerClient { // We may have an issue when upgrading.... // Perhaps We create ChangeManagementSchedulingInfoV1, ...V2, etc. // ANd try them one after another.... - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, "Unable to parse message. Format changed?"); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, "Unable to parse message. Format changed?"); schedule.setOptimizerStatus("Failed to parse SNIRO request"); schedule.setOptimizerDateTimeMillis(System.currentTimeMillis()); schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString()); @@ -336,15 +333,14 @@ public class CMSOptimizerClient { Client client = ClientBuilder.newClient(); client.register(new BasicAuthenticatorFilter(username, password)); + client.register(new CMSOClientFilters()); + WebTarget sniroTarget = client.target(snirourl); Invocation.Builder invocationBuilder = sniroTarget.request(MediaType.APPLICATION_JSON); debug.debug("SNIRO url / user: " + snirourl + " / " + username); - log.info(LogMessages.OPTIMIZER_REQUEST, "Begin", "healthcheck", snirourl); - Mdc.metricStart("healthcjeck", snirourl); + Observation.report(LogMessages.OPTIMIZER_REQUEST, "Begin", "healthcheck", snirourl); Response response = invocationBuilder.post(Entity.json(cmReq)); - Mdc.metricEnd(response); - metrics.info(LogMessages.OPTIMIZER_REQUEST, "End", "healthcheck", snirourl); - log.info(LogMessages.OPTIMIZER_REQUEST, "End", "healthcheck", snirourl); + Observation.report(LogMessages.OPTIMIZER_REQUEST, "End", "healthcheck", snirourl); String message = response.getStatus() + ":" + response.readEntity(String.class); switch (response.getStatus()) { case 202: @@ -366,7 +362,7 @@ public class CMSOptimizerClient { break; } } catch (Exception e) { - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e.toString()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e.toString()); hcc.setStatus(e.toString()); } finally { Mdc.restore(mdcSave); diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/OptimizerQuartzJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/OptimizerQuartzJob.java index 064566c..39d590b 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/OptimizerQuartzJob.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/OptimizerQuartzJob.java @@ -1,6 +1,6 @@ /* - * Copyright 2017-2018 AT&T Intellectual Property. - * Modifications Copyright 2018 IBM. + * Copyright © 2017-2019 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,12 +39,14 @@ import javax.ws.rs.client.Invocation; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; + +import org.onap.observations.Mdc; import org.onap.optf.cmso.common.BasicAuthenticatorFilter; import org.onap.optf.cmso.common.CMSStatusEnum; import org.onap.optf.cmso.common.DomainsEnum; import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.common.Mdc; import org.onap.optf.cmso.common.PropertiesManagement; +import org.onap.optf.cmso.filters.CMSOClientFilters; import org.onap.optf.cmso.model.Schedule; import org.onap.optf.cmso.model.dao.ScheduleDAO; import org.quartz.DisallowConcurrentExecution; @@ -115,13 +117,11 @@ public class OptimizerQuartzJob extends QuartzJobBean { String pass = pm.getProperty("mechid.pass", ""); Client client = ClientBuilder.newClient(); client.register(new BasicAuthenticatorFilter(user, pass)); + client.register(new CMSOClientFilters()); WebTarget target = client.target(url); Invocation.Builder invocationBuilder = target.request(MediaType.APPLICATION_JSON); Response response = null; - Mdc.metricStart(id.toString(), url); response = invocationBuilder.get(); - Mdc.metricEnd(response); - metrics.info(LogMessages.OPTIMIZER_QUARTZ_JOB, id.toString()); switch (response.getStatus()) { case 200: log.info("Returned from dispatch call"); diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminToolImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminToolImpl.java index 9f1a4d5..b878d31 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminToolImpl.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminToolImpl.java @@ -1,6 +1,6 @@ /* - * Copyright 2017-2018 AT&T Intellectual Property. - * Modifications Copyright 2018 IBM. + * Copyright © 2017-2019 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,8 @@ import java.util.UUID; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; -import org.onap.optf.cmso.common.Mdc; + +import org.onap.observations.Mdc; import org.onap.optf.cmso.common.PropertiesManagement; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -52,14 +53,11 @@ public class AdminToolImpl implements AdminTool { @Override public Response exec(String apiVersion, String id, UriInfo uri, HttpServletRequest request) { - Mdc.begin(request, UUID.randomUUID().toString()); log.info("AdminTool.exec entered"); if (id.length() < 4) return Response.ok("").build(); String encrypted = pm.getEncryptedValue(id); Response response = Response.ok(encrypted).build(); - Mdc.end(response); - audit.info("AdminTool"); return response; } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSCallbackImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSCallbackImpl.java index 9fb8a96..5d11225 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSCallbackImpl.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSCallbackImpl.java @@ -1,6 +1,6 @@ /* - * Copyright 2017-2018 AT&T Intellectual Property. - * Modifications Copyright 2018 IBM. + * Copyright © 2017-2019 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,10 +42,10 @@ import javax.ws.rs.core.UriInfo; import org.joda.time.DateTime; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.ISODateTimeFormat; +import org.onap.observations.Mdc; import org.onap.optf.cmso.common.CMSStatusEnum; import org.onap.optf.cmso.common.DomainsEnum; import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.common.Mdc; import org.onap.optf.cmso.common.exceptions.CMSException; import org.onap.optf.cmso.common.exceptions.CMSNotFoundException; import org.onap.optf.cmso.model.ChangeManagementGroup; @@ -88,7 +88,6 @@ public class CMSCallbackImpl extends BaseSchedulerServiceImpl implements CMSOpti public Response sniroCallback(String apiVersion, CMOptimizerResponse sniroResponse, UriInfo uri, HttpServletRequest request) { Response response = null; - Mdc.begin(request, sniroResponse.getTransactionId()); log.info(LogMessages.PROCESS_OPTIMIZER_CALLBACK, "Received", request.getRemoteAddr(), ""); log.info(LogMessages.OPTIMIZER_REQUEST, "Callback received", sniroResponse.getTransactionId(), uri.getAbsolutePath().toString()); @@ -138,13 +137,6 @@ public class CMSCallbackImpl extends BaseSchedulerServiceImpl implements CMSOpti response = Response.serverError().entity(e.getMessage()).build(); } finally { } - Mdc.end(response); - log.info(LogMessages.OPTIMIZER_REQUEST, "Callback completed", sniroResponse.getTransactionId(), - uri.getAbsolutePath().toString()); - audit.info(LogMessages.PROCESS_OPTIMIZER_CALLBACK, "Returned", request.getRemoteAddr(), - response.getStatusInfo().toString()); - metrics.info(LogMessages.PROCESS_OPTIMIZER_CALLBACK, "Returned", request.getRemoteAddr(), - response.getStatusInfo().toString()); return response; } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOServiceImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOServiceImpl.java index 26d0fe5..c3d61da 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOServiceImpl.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOServiceImpl.java @@ -1,6 +1,6 @@ /* - * Copyright 2017-2018 AT&T Intellectual Property. - * Modifications Copyright 2018 IBM. + * Copyright © 2017-2019 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,19 +39,20 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.TimeZone; -import java.util.UUID; + import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.UriInfo; + import org.joda.time.DateTime; +import org.onap.observations.Observation; import org.onap.optf.cmso.common.ApprovalStatusEnum; import org.onap.optf.cmso.common.ApprovalTypesEnum; import org.onap.optf.cmso.common.CMSStatusEnum; import org.onap.optf.cmso.common.DomainsEnum; import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.common.Mdc; import org.onap.optf.cmso.common.exceptions.CMSException; import org.onap.optf.cmso.common.exceptions.CMSNotFoundException; import org.onap.optf.cmso.eventq.CMSQueueJob; @@ -83,15 +84,12 @@ import org.springframework.core.env.Environment; import org.springframework.stereotype.Controller; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.interceptor.TransactionAspectSupport; + import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; @Controller public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOService { - private static EELFLogger log = EELFManager.getInstance().getLogger(CMSOServiceImpl.class); - private static EELFLogger metrics = EELFManager.getInstance().getMetricsLogger(); - private static EELFLogger audit = EELFManager.getInstance().getAuditLogger(); - private static EELFLogger errors = EELFManager.getInstance().getErrorLogger(); private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); @Autowired @@ -129,15 +127,14 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer String scheduleName, String userId, String status, String createDateTime, String optimizerStatus, String workflowName, UriInfo uri, HttpServletRequest request) { - Mdc.begin(request, UUID.randomUUID().toString()); - log.info(LogMessages.SEARCH_SCHEDULE_REQUEST, "Received", request.getRemoteAddr(), uri.toString(), ""); + Observation.report(LogMessages.SEARCH_SCHEDULE_REQUEST, "Received", request.getRemoteAddr(), uri.toString(), ""); Response response = null; List schedules = new ArrayList(); try { - log.info("Timezone=" + TimeZone.getDefault()); - MultivaluedMap qp = uri.getQueryParameters(); + debug.debug("Timezone={}", TimeZone.getDefault()); StringBuilder where = new StringBuilder(); int maxRows = 0; + //MultivaluedMap qp = uri.getQueryParameters(); // buildWhere(qp, where); List list = scheduleQueryDAO.searchSchedules(where.toString(), maxRows); if (list == null || !list.iterator().hasNext()) { @@ -162,21 +159,14 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer } response = Response.ok(schedules.toArray(new Schedule[schedules.size()])).build(); } catch (CMSException e) { - debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - log.info(e.getMessage()); + Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage()); response = Response.status(e.getStatus()).entity(e.getRequestError()).build(); } catch (Exception e) { - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); response = Response.serverError().build(); } - Mdc.end(response); - log.info(LogMessages.SEARCH_SCHEDULE_REQUEST, "Returned", request.getRemoteAddr(), schedules.toString(), - response.getStatusInfo().toString()); - audit.info(LogMessages.SEARCH_SCHEDULE_REQUEST, "Returned", request.getRemoteAddr(), schedules.toString(), - response.getStatusInfo().toString()); - metrics.info(LogMessages.SEARCH_SCHEDULE_REQUEST, "Returned", request.getRemoteAddr(), schedules.toString(), + Observation.report(LogMessages.SEARCH_SCHEDULE_REQUEST, "Returned", request.getRemoteAddr(), schedules.toString(), response.getStatusInfo().toString()); return response; } @@ -185,8 +175,7 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer @Transactional public Response createScheduleRequest(String apiVersion, String scheduleId, CMSMessage scheduleMessage, HttpServletRequest request) { - Mdc.begin(request, scheduleId); - log.info(LogMessages.CREATE_SCHEDULE_REQUEST, "Received", request.getRemoteAddr(), scheduleId, + Observation.report(LogMessages.CREATE_SCHEDULE_REQUEST, "Received", request.getRemoteAddr(), scheduleId, scheduleMessage.toString()); Response response = null; try { @@ -208,25 +197,6 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer if (immediate) { createChangeManagementImmediate(schedule, scheduleMessage); - // ******************************************************************************************* - // This flush does nothing because JPA is expecting - // JtaTransactionCoordinatorImpl - // rather than - // JdbcResourceLocalTransactionCoordinatorImpl - // (it does an instance of and JdbcResourceLocalTransactionCoordinatorImpl - // fails) - // SO the automatic approval and creation of tickets cannot - // rely retrieving the entities from the Schedule entity as the SQL has not yet - // executed. - // Under future flow, they can because the data is committed in a separate - // transaction - // Three choices - // 1. Pass domainData through all of the methods. *** - // 2. Re-structre the code to have @Transactionals which would break the top - // level rollback strategy - // 3. Debug JPA (Still worth doing, maybe some kind of goofy parameter.) - TransactionAspectSupport.currentTransactionStatus().flush(); - // Create automatic approval ApprovalMessage am = new ApprovalMessage(); am.setApprovalStatus(ApprovalStatusEnum.Accepted); @@ -239,25 +209,15 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer } response = Response.accepted().build(); } catch (CMSException e) { - debug.debug(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage()); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - log.info(e.getMessage()); + Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage()); response = Response.status(e.getStatus()).entity(e.getRequestError()).build(); - Mdc.end(response); - audit.info(LogMessages.CREATE_SCHEDULE_REQUEST, "Returned", request.getRemoteAddr(), scheduleId, ""); } catch (Exception e) { - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); response = Response.serverError().build(); - Mdc.end(response); - audit.info(LogMessages.CREATE_SCHEDULE_REQUEST, "Returned", request.getRemoteAddr(), scheduleId, ""); } - Mdc.end(response); - log.info(LogMessages.CREATE_SCHEDULE_REQUEST, "Returned", request.getRemoteAddr(), scheduleId, - response.getStatusInfo().toString()); - audit.info(LogMessages.CREATE_SCHEDULE_REQUEST, "Returned", request.getRemoteAddr(), scheduleId, - response.getStatusInfo().toString()); - metrics.info(LogMessages.CREATE_SCHEDULE_REQUEST, "Returned", request.getRemoteAddr(), scheduleId, + Observation.report(LogMessages.CREATE_SCHEDULE_REQUEST, "Returned", request.getRemoteAddr(), scheduleId, response.getStatusInfo().toString()); return response; } @@ -326,7 +286,7 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer } catch (CMSException e) { throw e; } catch (Exception e) { - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); throw new CMSException(Status.INTERNAL_SERVER_ERROR, LogMessages.UNEXPECTED_EXCEPTION, e.getMessage()); } // If we got here, there are no change windows.... @@ -440,7 +400,7 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer try { CmDomainDataEnum.valueOf(name); } catch (Exception e) { - log.warn(LogMessages.UNDEFINED_DOMAIN_DATA_ATTRIBUTE, DomainsEnum.ChangeManagement.name(), name, + Observation.report(LogMessages.UNDEFINED_DOMAIN_DATA_ATTRIBUTE, DomainsEnum.ChangeManagement.name(), name, value); } } @@ -456,9 +416,8 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer @Override @Transactional public Response deleteScheduleRequest(String apiVersion, String scheduleId, HttpServletRequest request) { - Mdc.begin(request, scheduleId); Response response = null; - log.info(LogMessages.DELETE_SCHEDULE_REQUEST, "Received", request.getRemoteAddr(), scheduleId, ""); + Observation.report(LogMessages.DELETE_SCHEDULE_REQUEST, "Received", request.getRemoteAddr(), scheduleId, ""); try { Schedule schedule = scheduleDAO.findByDomainScheduleID(DomainsEnum.ChangeManagement.toString(), scheduleId); if (schedule == null) { @@ -469,20 +428,14 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer response = Response.noContent().build(); } catch (CMSException e) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - log.info(e.getMessage()); + Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage()); response = Response.status(e.getStatus()).entity(e.getRequestError()).build(); } catch (Exception e) { - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); response = Response.serverError().build(); } - Mdc.end(response); - log.info(LogMessages.DELETE_SCHEDULE_REQUEST, "Returned", request.getRemoteAddr(), scheduleId, - response.getStatusInfo().toString()); - audit.info(LogMessages.DELETE_SCHEDULE_REQUEST, "Returned", request.getRemoteAddr(), scheduleId, - response.getStatusInfo().toString()); - metrics.info(LogMessages.DELETE_SCHEDULE_REQUEST, "Returned", request.getRemoteAddr(), scheduleId, + Observation.report(LogMessages.DELETE_SCHEDULE_REQUEST, "Returned", request.getRemoteAddr(), scheduleId, response.getStatusInfo().toString()); return response; } @@ -490,8 +443,7 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer @Override public Response getScheduleRequestInfo(String apiVersion, String scheduleId, HttpServletRequest request) { Response response = null; - Mdc.begin(request, scheduleId); - log.info(LogMessages.GET_SCHEDULE_REQUEST_INFO, "Received", request.getRemoteAddr(), scheduleId, ""); + Observation.report(LogMessages.GET_SCHEDULE_REQUEST_INFO, "Received", request.getRemoteAddr(), scheduleId, ""); Schedule schedule = null; try { schedule = scheduleDAO.findByDomainScheduleID(DomainsEnum.ChangeManagement.toString(), scheduleId); @@ -501,20 +453,13 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer } response = Response.ok().entity(schedule).build(); } catch (CMSException e) { - log.info(e.getMessage()); - debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage()); response = Response.status(e.getStatus()).entity(e.getRequestError()).build(); } catch (Exception e) { - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); response = Response.serverError().build(); } - Mdc.end(response); - audit.info(LogMessages.GET_SCHEDULE_REQUEST_INFO, "Returned", request.getRemoteAddr(), scheduleId, - response.getStatusInfo().toString()); - metrics.info(LogMessages.GET_SCHEDULE_REQUEST_INFO, "Returned", request.getRemoteAddr(), scheduleId, - response.getStatusInfo().toString()); - log.info(LogMessages.GET_SCHEDULE_REQUEST_INFO, "Returned", request.getRemoteAddr(), scheduleId, + Observation.report(LogMessages.GET_SCHEDULE_REQUEST_INFO, "Returned", request.getRemoteAddr(), scheduleId, response.getStatusInfo().toString()); return response; } @@ -524,8 +469,7 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer public Response approveScheduleRequest(String apiVersion, String scheduleId, ApprovalMessage approval, HttpServletRequest request) { Response response = null; - Mdc.begin(request, scheduleId); - log.info(LogMessages.APPROVE_SCHEDULE_REQUEST, "Received", request.getRemoteAddr(), scheduleId, + Observation.report(LogMessages.APPROVE_SCHEDULE_REQUEST, "Received", request.getRemoteAddr(), scheduleId, approval.toString()); try { String domain = DomainsEnum.ChangeManagement.toString(); @@ -537,19 +481,14 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer response = Response.noContent().build(); } catch (CMSException e) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - log.info(e.getMessage()); + Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage()); response = Response.status(e.getStatus()).entity(e.getRequestError()).build(); } catch (Exception e) { - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); response = Response.serverError().build(); } - Mdc.end(response); - log.info(LogMessages.APPROVE_SCHEDULE_REQUEST, "Returned", request.getRemoteAddr(), scheduleId, ""); - audit.info(LogMessages.APPROVE_SCHEDULE_REQUEST, "Returned", request.getRemoteAddr(), scheduleId, - response.getStatusInfo().toString()); - metrics.info(LogMessages.APPROVE_SCHEDULE_REQUEST, "Returned", request.getRemoteAddr(), scheduleId, - response.getStatusInfo().toString()); + Observation.report(LogMessages.APPROVE_SCHEDULE_REQUEST, "Returned", request.getRemoteAddr(), scheduleId, ""); return response; } @@ -645,14 +584,13 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer Integer maxSchedules, String lastScheduleId, Integer concurrencyLimit, UriInfo uri, HttpServletRequest request) { - Mdc.begin(request, UUID.randomUUID().toString()); Response response = null; - log.info(LogMessages.SEARCH_SCHEDULE_REQUEST_DETAILS, "Received", request.getRemoteAddr(), + Observation.report(LogMessages.SEARCH_SCHEDULE_REQUEST_DETAILS, "Received", request.getRemoteAddr(), uri.getRequestUri().getQuery()); List schedules = new ArrayList(); try { - log.info("Timezone=" + TimeZone.getDefault()); + debug.debug("Timezone={}" , TimeZone.getDefault()); MultivaluedMap qp = uri.getQueryParameters(); StringBuilder where = new StringBuilder(); int maxRows = 0; @@ -673,20 +611,13 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer } response = Response.ok(schedules.toArray(new CmDetailsMessage[schedules.size()])).build(); } catch (CMSException e) { - debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - log.info(e.getMessage()); + Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage()); response = Response.status(e.getStatus()).entity(e.getRequestError()).build(); } catch (Exception e) { - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); response = Response.serverError().build(); } - Mdc.end(response); - log.info(LogMessages.SEARCH_SCHEDULE_REQUEST_DETAILS, "Returned", request.getRemoteAddr(), - response.getStatusInfo().toString()); - audit.info(LogMessages.SEARCH_SCHEDULE_REQUEST_DETAILS, "Returned", request.getRemoteAddr(), - response.getStatusInfo().toString()); - metrics.info(LogMessages.SEARCH_SCHEDULE_REQUEST_DETAILS, "Returned", request.getRemoteAddr(), + Observation.report(LogMessages.SEARCH_SCHEDULE_REQUEST_DETAILS, "Returned", request.getRemoteAddr(), response.getStatusInfo().toString()); return response; diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheckImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheckImpl.java index a3a4ae8..0877a6b 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheckImpl.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheckImpl.java @@ -32,11 +32,11 @@ package org.onap.optf.cmso.service.rs; import java.util.List; -import java.util.UUID; + import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; -import org.onap.optf.cmso.common.Mdc; + import org.onap.optf.cmso.model.ApprovalType; import org.onap.optf.cmso.model.dao.ApprovalTypeDAO; import org.onap.optf.cmso.optimizer.CMSOptimizerClient; @@ -47,13 +47,13 @@ import org.onap.optf.cmso.ticketmgt.TmClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Controller; + import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; @Controller public class HealthCheckImpl implements HealthCheck { - private static EELFLogger log = EELFManager.getInstance().getLogger(HealthCheckImpl.class); - private static EELFLogger audit = EELFManager.getInstance().getAuditLogger(); + private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); @Autowired TmClient tmClient; @@ -72,8 +72,7 @@ public class HealthCheckImpl implements HealthCheck { @Override public Response healthCheck(String apiVersion, Boolean checkInterfaces, UriInfo uri, HttpServletRequest request) { - Mdc.begin(request, UUID.randomUUID().toString()); - log.info("Entered healthcheck"); + debug.debug("Entered healthcheck"); Response response = null; HealthCheckMessage hc = new HealthCheckMessage(); hc.setHealthy(true); @@ -89,8 +88,6 @@ public class HealthCheckImpl implements HealthCheck { response = Response.ok().entity(hc).build(); else response = Response.status(Response.Status.BAD_REQUEST).entity(hc).build(); - Mdc.end(response); - audit.info("Healthcheck healthy={0}", hc.getHealthy().toString()); return response; } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusClient.java b/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusClient.java index 8cbe459..7a7821e 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusClient.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusClient.java @@ -1,5 +1,5 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. + * Copyright © 2017-2019 AT&T Intellectual Property. * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,6 +34,7 @@ package org.onap.optf.cmso.sostatus; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Map; + import javax.ws.rs.ProcessingException; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; @@ -41,10 +42,12 @@ import javax.ws.rs.client.Invocation; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; + +import org.onap.observations.Mdc; +import org.onap.observations.Observation; import org.onap.optf.cmso.common.BasicAuthenticatorFilter; import org.onap.optf.cmso.common.CMSStatusEnum; import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.common.Mdc; import org.onap.optf.cmso.common.PropertiesManagement; import org.onap.optf.cmso.filters.CMSOClientFilters; import org.onap.optf.cmso.model.ChangeManagementSchedule; @@ -59,6 +62,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; + import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.databind.ObjectMapper; @@ -66,10 +70,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; @Component public class MsoStatusClient { - private static EELFLogger log = EELFManager.getInstance().getLogger(MsoStatusClient.class); - private static EELFLogger errors = EELFManager.getInstance().getErrorLogger(); private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); - private static EELFLogger metrics = EELFManager.getInstance().getMetricsLogger(); @Autowired ChangeManagementScheduleDAO cmScheduleDAO; @@ -91,12 +92,12 @@ public class MsoStatusClient { try { ChangeManagementSchedule cmSchedule = cmScheduleDAO.lockOne(id); if (cmSchedule == null) { - log.warn(LogMessages.MSO_POLLING_MISSING_SCHEDULE, id.toString()); + Observation.report(LogMessages.MSO_POLLING_MISSING_SCHEDULE, id.toString()); return; } poll(cmSchedule); } catch (Exception e) { - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); } debug.debug(LogMessages.MSO_STATUS_JOB, "Exited", id.toString()); } @@ -120,10 +121,7 @@ public class MsoStatusClient { Invocation.Builder invocationBuilder = target.request(MediaType.APPLICATION_JSON); Response response = null; cmSchedule.setMsoTimeMillis(System.currentTimeMillis()); - Mdc.metricStart(requestId, url); response = invocationBuilder.get(); - Mdc.metricEnd(response); - metrics.info(LogMessages.SO_API, requestId); switch (response.getStatus()) { case 200: { String respString = response.readEntity(String.class); @@ -136,7 +134,7 @@ public class MsoStatusClient { try { msoStatus = MSO_STATUS.valueOf(resp.getRequestState()); } catch (Exception e) { - errors.error("Unregcognized status from MSO: " + resp.getRequestState()); + Observation.report(LogMessages.UNRECOGNIZED_MSO_STATUS, resp.getRequestState()); } long finishTime = getFinishTime(resp); switch (msoStatus) { @@ -185,15 +183,13 @@ public class MsoStatusClient { } } } catch (ProcessingException e) { - debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); // Probably a transient error... Keep polling cmSchedule.setMsoTimeMillis(System.currentTimeMillis()); cmSchedule.setMsoStatus("ConnectionException"); cmSchedule.setMsoMessage("Could not call MSO:" + e.getMessage()); } catch (Exception e) { - debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); // Probably a transient error... Keep polling cmSchedule.setMsoTimeMillis(System.currentTimeMillis()); cmSchedule.setMsoStatus("Exception"); @@ -216,8 +212,7 @@ public class MsoStatusClient { Date dateTime = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z").parse(timestr); finishTime = dateTime.getTime(); } catch (Exception e) { - debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, "Unable to parse MSO fisnish timestamp: " + timestr); - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, "Unable to parse MSO fisnish timestamp: " + timestr); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, "Unable to parse MSO finish timestamp: " + timestr); } } return finishTime; @@ -238,8 +233,7 @@ public class MsoStatusClient { om.treeToValue(requestStatus, MsoOrchestrationQueryResponse.class); return msoResponse; } catch (Exception e) { - log.warn("Exception parsing MSO response", e); - log.warn("MSO response:\n" + resp); + Observation.report(LogMessages.UNABLE_TO_PARSE_MSO_RESPONSE, e, e.getMessage(), resp); } return null; } @@ -260,14 +254,13 @@ public class MsoStatusClient { Client client = ClientBuilder.newClient(); client.register(new BasicAuthenticatorFilter(user, pass)); + client.register(new CMSOClientFilters()); + WebTarget target = client.target(url); Invocation.Builder invocationBuilder = target.request(MediaType.APPLICATION_JSON); Response response = null; try { - Mdc.metricStart(requestId, url); response = invocationBuilder.get(); - Mdc.metricEnd(response); - metrics.info(LogMessages.SO_API, requestId); switch (response.getStatus()) { case 200: case 204: diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusJob.java index 29853d1..df9f361 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusJob.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusJob.java @@ -1,6 +1,6 @@ /* - * Copyright 2017-2018 AT&T Intellectual Property. - * Modifications Copyright 2018 IBM. + * Copyright © 2017-2019 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,8 +31,8 @@ package org.onap.optf.cmso.sostatus; +import org.onap.observations.Mdc; import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.common.Mdc; import org.onap.optf.cmso.model.ChangeManagementSchedule; import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO; import org.quartz.DisallowConcurrentExecution; diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/ScheduleStatusJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/ScheduleStatusJob.java index cd74bc4..c3254aa 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/ScheduleStatusJob.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/ScheduleStatusJob.java @@ -1,6 +1,6 @@ /* - * Copyright 2017-2018 AT&T Intellectual Property. - * Modifications Copyright 2018 IBM. + * Copyright © 2017-2019 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,17 +33,21 @@ package org.onap.optf.cmso.sostatus; import java.util.List; import java.util.Map; + import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.Invocation; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; + +import org.onap.observations.Mdc; +import org.onap.observations.Observation; import org.onap.optf.cmso.common.BasicAuthenticatorFilter; import org.onap.optf.cmso.common.DomainsEnum; import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.common.Mdc; import org.onap.optf.cmso.common.PropertiesManagement; +import org.onap.optf.cmso.filters.CMSOClientFilters; import org.onap.optf.cmso.model.ChangeManagementSchedule; import org.onap.optf.cmso.model.Schedule; import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO; @@ -56,6 +60,7 @@ import org.quartz.SchedulerException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; + import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; @@ -67,10 +72,7 @@ import com.att.eelf.configuration.EELFManager; @Component @DisallowConcurrentExecution public class ScheduleStatusJob implements Job { - private static EELFLogger log = EELFManager.getInstance().getLogger(ScheduleStatusJob.class); - private static EELFLogger errors = EELFManager.getInstance().getErrorLogger(); private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); - private static EELFLogger metrics = EELFManager.getInstance().getMetricsLogger(); @Autowired ScheduleDAO scheduleDAO; @@ -95,7 +97,7 @@ public class ScheduleStatusJob implements Job { dispatchMso(s.getId()); } } catch (Exception e) { - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); } try { @@ -107,7 +109,7 @@ public class ScheduleStatusJob implements Job { dispatchScheduleStatusChecker(s.getId()); } } catch (Exception e) { - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); } debug.debug(LogMessages.SCHEDULE_STATUS_JOB, "Exited"); } @@ -122,17 +124,15 @@ public class ScheduleStatusJob implements Job { String pass = pm.getProperty("mechid.pass", ""); Client client = ClientBuilder.newClient(); client.register(new BasicAuthenticatorFilter(user, pass)); + client.register(CMSOClientFilters.class); WebTarget target = client.target(url); Invocation.Builder invocationBuilder = target.request(MediaType.APPLICATION_JSON); Response response = null; try { - Mdc.metricStart(id.toString(), url); response = invocationBuilder.get(); - Mdc.metricEnd(response); - metrics.info(LogMessages.SCHEDULE_STATUS_JOB, id.toString()); switch (response.getStatus()) { case 200: - log.info("Returned from dispatch call"); + debug.debug("Returned from dispatch call"); break; case 400: // Bad request default: { @@ -142,12 +142,10 @@ public class ScheduleStatusJob implements Job { } } } catch (Exception e) { - debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); } } catch (Exception e) { - debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); } finally { Mdc.restore(mdcSave); } @@ -164,17 +162,15 @@ public class ScheduleStatusJob implements Job { String pass = pm.getProperty("mechid.pass", ""); Client client = ClientBuilder.newClient(); client.register(new BasicAuthenticatorFilter(user, pass)); + client.register(CMSOClientFilters.class); WebTarget target = client.target(url); Invocation.Builder invocationBuilder = target.request(MediaType.APPLICATION_JSON); Response response = null; try { - Mdc.metricStart(id.toString(), url); response = invocationBuilder.get(); - Mdc.metricEnd(response); - metrics.info(LogMessages.SCHEDULE_STATUS_JOB, id.toString()); switch (response.getStatus()) { case 200: - log.info("Returned from dispatch call"); + debug.debug("Returned from dispatch call"); break; case 400: // Bad request default: { @@ -184,12 +180,10 @@ public class ScheduleStatusJob implements Job { } } } catch (Exception e) { - debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); } } catch (Exception e) { - debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); } finally { Mdc.restore(mdcSave); } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmClient.java b/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmClient.java index b8aed57..c3b9be8 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmClient.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmClient.java @@ -1,6 +1,6 @@ /* - * Copyright 2017-2018 AT&T Intellectual Property. - * Modifications Copyright 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,6 +38,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.UUID; + import javax.ws.rs.ProcessingException; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; @@ -47,12 +48,14 @@ import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; -import org.apache.commons.lang3.text.StrSubstitutor; + +import org.apache.commons.text.StringSubstitutor; import org.joda.time.format.ISODateTimeFormat; +import org.onap.observations.Mdc; +import org.onap.observations.Observation; import org.onap.optf.cmso.common.BasicAuthenticatorFilter; import org.onap.optf.cmso.common.CmHelpers; import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.common.Mdc; import org.onap.optf.cmso.common.PropertiesManagement; import org.onap.optf.cmso.common.exceptions.CMSException; import org.onap.optf.cmso.filters.CMSOClientFilters; @@ -72,6 +75,7 @@ import org.onap.optf.cmso.ticketmgt.bean.TmChangeInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; + import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.databind.JsonNode; @@ -81,9 +85,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode; @Component public class TmClient { - private static EELFLogger log = EELFManager.getInstance().getLogger(TmClient.class); - private static EELFLogger metrics = EELFManager.getInstance().getMetricsLogger(); - private static EELFLogger errors = EELFManager.getInstance().getErrorLogger(); private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); @Autowired @@ -153,12 +154,12 @@ public class TmClient { } break; default: { - errors.error(LogMessages.UNEXPECTED_RESPONSE, "TM", String.valueOf(response.getStatus()), + Observation.report(LogMessages.UNEXPECTED_RESPONSE, "TM", String.valueOf(response.getStatus()), response.toString()); } } } catch (Exception e) { - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e.toString()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e.toString()); } finally { Mdc.restore(mdcSave); } @@ -225,10 +226,10 @@ public class TmClient { try { Response response = null; debug.debug("postCloseChangeTicket {}", closeChangeRecord.asText()); - log.info(LogMessages.TM_CLOSE_CHANGE_RECORD, "Begin", scheduleId, changeId); + Observation.report(LogMessages.TM_CLOSE_CHANGE_RECORD, "Begin", scheduleId, changeId); // response = vtmPost(url, closeChangeRecord, scheduleId); response = tmPost(Endpoint.CLOSE, closeChangeRecord, scheduleId); - log.info(LogMessages.TM_CLOSE_CHANGE_RECORD, "End", scheduleId, changeId); + Observation.report(LogMessages.TM_CLOSE_CHANGE_RECORD, "End", scheduleId, changeId); switch (response.getStatus()) { case 200: { String resp = response.readEntity(String.class); @@ -239,7 +240,7 @@ public class TmClient { String respString = response.readEntity(String.class); debug.debug("response=" + respString); if (!isAlreadyClosed(respString)) { - errors.error(LogMessages.UNEXPECTED_RESPONSE, "vTM", String.valueOf(response.getStatus()), + Observation.report(LogMessages.UNEXPECTED_RESPONSE, "vTM", String.valueOf(response.getStatus()), response.toString() + " : " + respString); throw new CMSException(Status.PRECONDITION_FAILED, LogMessages.UNABLE_TO_CLOSE_CHANGE_TICKET, scheduleId, changeId, respString); @@ -248,14 +249,14 @@ public class TmClient { break; default: { String message = response.readEntity(String.class); - errors.error(LogMessages.UNEXPECTED_RESPONSE, "vTM", String.valueOf(response.getStatus()), + Observation.report(LogMessages.UNEXPECTED_RESPONSE, "vTM", String.valueOf(response.getStatus()), response.toString() + " : " + message); throw new CMSException(Status.PRECONDITION_FAILED, LogMessages.UNABLE_TO_CLOSE_CHANGE_TICKET, scheduleId, changeId, message); } } } catch (ProcessingException e) { - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); throw new CMSException(Status.PRECONDITION_FAILED, LogMessages.UNABLE_TO_CLOSE_CHANGE_TICKET, scheduleId, changeId, e.toString()); } finally { @@ -283,7 +284,7 @@ public class TmClient { } } } catch (Exception e) { - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); } return false; } @@ -351,7 +352,7 @@ public class TmClient { for (String name : variables.keySet()) { Object value = variables.get(name); if (value instanceof String) { - StrSubstitutor sub = new StrSubstitutor(variables); + StringSubstitutor sub = new StringSubstitutor(variables); value = sub.replace(value.toString()); variables.put(name, value); } @@ -366,10 +367,10 @@ public class TmClient { try { Response response = null; debug.debug("postCreateChangeTicket {}", createChangeRecord.toString()); - log.info(LogMessages.TM_CREATE_CHANGE_RECORD, "Begin", scheduleId); + Observation.report(LogMessages.TM_CREATE_CHANGE_RECORD, "Begin", scheduleId); // response = vtmPost(url, createChangeRecord, scheduleId); response = tmPost(Endpoint.CREATE, createChangeRecord, scheduleId); - log.info(LogMessages.TM_CREATE_CHANGE_RECORD, "End", scheduleId); + Observation.report(LogMessages.TM_CREATE_CHANGE_RECORD, "End", scheduleId); switch (response.getStatus()) { case 200: { ObjectNode json = response.readEntity(ObjectNode.class); @@ -382,7 +383,7 @@ public class TmClient { debug.debug("ChangeId=" + changeId); } } else { - errors.error(LogMessages.UNEXPECTED_RESPONSE, "vTM", String.valueOf(response.getStatus()), + Observation.report(LogMessages.UNEXPECTED_RESPONSE, "vTM", String.valueOf(response.getStatus()), response.toString() + " : " + "Response is empty"); throw new CMSException(Status.EXPECTATION_FAILED, LogMessages.UNABLE_TO_CREATE_CHANGE_TICKET, scheduleId, "Response is empty"); @@ -391,14 +392,14 @@ public class TmClient { break; default: { String message = response.readEntity(String.class); - errors.error(LogMessages.UNEXPECTED_RESPONSE, "vTM", String.valueOf(response.getStatus()), + Observation.report(LogMessages.UNEXPECTED_RESPONSE, "vTM", String.valueOf(response.getStatus()), response.toString() + " : " + message); throw new CMSException(Status.EXPECTATION_FAILED, LogMessages.UNABLE_TO_CREATE_CHANGE_TICKET, scheduleId, message); } } } catch (ProcessingException e) { - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); throw new CMSException(Status.EXPECTATION_FAILED, LogMessages.UNABLE_TO_CREATE_CHANGE_TICKET, scheduleId, e.toString()); } finally { @@ -415,10 +416,10 @@ public class TmClient { Response response = null; debug.debug("postUpdateChangeTicket {}", updateChangeRecord.toString()); - log.info(LogMessages.TM_UPDATE_CHANGE_RECORD, "Begin", scheduleId, changeId, url); + Observation.report(LogMessages.TM_UPDATE_CHANGE_RECORD, "Begin", scheduleId, changeId, url); // response = vtmPost(url, updateChangeRecord, scheduleId); response = tmPost(Endpoint.UPDATE, updateChangeRecord, scheduleId); - log.info(LogMessages.TM_UPDATE_CHANGE_RECORD, "End", scheduleId, changeId, url); + Observation.report(LogMessages.TM_UPDATE_CHANGE_RECORD, "End", scheduleId, changeId, url); switch (response.getStatus()) { case 200: { String resp = response.readEntity(String.class); @@ -427,14 +428,14 @@ public class TmClient { break; default: { String message = response.readEntity(String.class); - errors.error(LogMessages.UNEXPECTED_RESPONSE, "vTM", String.valueOf(response.getStatus()), + Observation.report(LogMessages.UNEXPECTED_RESPONSE, "vTM", String.valueOf(response.getStatus()), response.toString() + " : " + message); throw new CMSException(Status.PRECONDITION_FAILED, LogMessages.UNABLE_TO_UPDATE_CHANGE_TICKET, scheduleId, changeId, message); } } } catch (ProcessingException e) { - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); throw new CMSException(Status.PRECONDITION_FAILED, LogMessages.UNABLE_TO_UPDATE_CHANGE_TICKET, scheduleId, changeId, e.toString()); } finally { @@ -460,16 +461,13 @@ public class TmClient { ObjectMapper mapper = new ObjectMapper(); String jsonRequest = mapper.writeValueAsString(request); debug.debug("vTM URL = " + url + " user=" + user + " : " + jsonRequest); - Mdc.metricStart(scheduleId, url); response = invocationBuilder.post(Entity.json(request)); - Mdc.metricEnd(response); - metrics.info(LogMessages.TM_API, url); // String message = response.readEntity(String.class); // debug.debug("Return from " + url + " : " + response.toString() + "\n" + // message); debug.debug("Return from " + url + " : " + response.toString()); } catch (Exception e) { - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.toString()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.toString()); throw new CMSException(Status.INTERNAL_SERVER_ERROR, LogMessages.UNABLE_TO_CREATE_CHANGE_TICKET, scheduleId, e.getMessage()); } @@ -496,24 +494,21 @@ public class TmClient { ObjectMapper mapper = new ObjectMapper(); String jsonRequest = mapper.writeValueAsString(request); debug.debug("TM URL = " + url + " user=" + user + " : " + jsonRequest); - Mdc.metricStart(scheduleId, url); response = invocationBuilder.post(Entity.json(request)); - Mdc.metricEnd(response); - metrics.info(LogMessages.TM_API, url); // String message = response.readEntity(String.class); // debug.debug("Return from " + url + " : " + response.toString() + "\n" + // message); debug.debug("Return from " + url + " : " + response.toString()); return response; } catch (ProcessingException e) { - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.toString()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.toString()); url = tmEndpoints.getNextEndpoint(ep, endpoints); if (url == null || !tryNextURL(e)) { throw new CMSException(Status.INTERNAL_SERVER_ERROR, LogMessages.UNABLE_TO_CREATE_CHANGE_TICKET, scheduleId, e.getMessage()); } } catch (Exception e) { - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.toString()); + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.toString()); throw new CMSException(Status.INTERNAL_SERVER_ERROR, LogMessages.UNABLE_TO_CREATE_CHANGE_TICKET, scheduleId, e.getMessage()); } diff --git a/cmso-service/src/main/resources/aaf/AAFUserRoles.properties b/cmso-service/src/main/resources/aaf/AAFUserRoles.properties new file mode 100644 index 0000000..e7fc221 --- /dev/null +++ b/cmso-service/src/main/resources/aaf/AAFUserRoles.properties @@ -0,0 +1 @@ +/**=org.onap.oof.access|*|get ALL \ No newline at end of file diff --git a/cmso-service/src/main/resources/aaf/org.onap.oof.cred.props b/cmso-service/src/main/resources/aaf/org.onap.oof.cred.props new file mode 100644 index 0000000..21945b8 --- /dev/null +++ b/cmso-service/src/main/resources/aaf/org.onap.oof.cred.props @@ -0,0 +1,11 @@ +############################################################ +# Properties Generated by AT&T Certificate Manager +# by root +# on 2019-02-15T21:01:19.868+0000 +# @copyright 2016, AT&T +############################################################ +aaf_id=oof@oof.onap.org +aaf_password=demo123456! +cadi_keyfile=src/main/resources/aaf/org.onap.oof.keyfile +cadi_truststore=src/main/resources/aaf/truststoreONAPall.jks +#cadi_truststore_password=enc:erNqS33_5xn_bwcaroba7NvYfPLpPUYxqzw3rdwGTY7jbnygOTyQ-R6dpSC_3iPOomp-rqZkHgMGImiUk9DFPr diff --git a/cmso-service/src/main/resources/aaf/org.onap.oof.keyfile b/cmso-service/src/main/resources/aaf/org.onap.oof.keyfile new file mode 100644 index 0000000..f85a567 --- /dev/null +++ b/cmso-service/src/main/resources/aaf/org.onap.oof.keyfile @@ -0,0 +1,27 @@ +liD-IR8Y1MHqPDTUqq3AaTtqnWn5jCpfIRBlyi6xY4A0fbQz8ZPlTZPHkshRt0dHdST3R7TIvTyQ +JpTCeBNBu2df3vBbUzsN0rIpPG9TGjzmE7cRu4V4kfefSqsIj-S7OTAaWaWpwGWJYLLCB2sQALkS +f68VWdupUEw3g9jqCU1QzjKOnLGvhlp6Qrc1xG4Z5Ar8WERw-C3DqTWUKANoEvjWkvH2rAywzj93 +pmspvd5fQfH1rp1ACNvnPrRb_oYNfwPrNpE7Sb4LvM1muoiKMDF64IDO0TkxhjHZ9wpJgVsnowby +qmokqf39dMRRk3S1IEpOiBGyLS_885JDj_XJKYRQsjvkTzjpFJ7wE2-HDZEVWCITvtS9-Xorm5TI +3iU4rjMDew5fkBnjoKuSOS7Lksva4ouZOCiUkDos1jAJ5XMDEQm4BcPHtcW6PpC602-qRcgnNjjP +wOPdF7hCm27ZTai3lAtNGByR7oBr9r5Uma-soORFvg8drV8Rgh0lax-poFVhoEH7RhKPIzYpSco9 +jnpURzi_epTjAhjjup-erTv2GAIllKsSEHZLbfsFWlNUZTOx58PSB0jBN5m_8HxTyNm0zsm0Cb7U +KsjPduQ5ZblsfRIJwqpOBXoof7WerKReMZSOdgjZUNueiuEImVH9_SYOdKZhkluSi4yfEtme7CCP +kZ2JhdiT5km3SeonalhU2MUsx60krxyQ1mnjI4jS9QagUME4mujdvM_L7mtjcPZVSfXUn49whakE +J-NQV6q2iZgN2IxsT_uCnlZYwnE5i-IbQkQAEu13m6ETsMmf0cwPnKaSwRhb8G48EkJhTL-GP9Z0 +-EsIKT7lQt7kfX-mmNoEirTg9gQAaN3uxLmdHvXpeJdlETnnaLYYJJ3h-SL0e_5Yz2SpdsEwZ3Bk +PtR-QvlYKDhG1nhPOna65ctCzn81PZOUP3lsO6MSTOK6D6Taxfh1TYEBAvzCP0BfFBodw4lSglFP +I5IfdiJmomTGARa36nC_O5YzH_jBWLQrgd2gxI5H5bB-5zqzu79SGX9o2_LRVY_LVV0BmI3xSYOI +vziYYC1XyTY6blfdiOM5a5KjraErxSTEFZVFrsx4OQ_dLA0woVtixawrIy1rgfQr49U1oIRe8BgN +j3eis_UQAbPbmdbEe1qtXnvi6T7trHskzt6K-vTgo5ITJkr-F2Sds_QgNdaFBGuES6X5RwRGlbHT +Tl_M8Ja_1K-RMNKJRssoRTKstpwnrhk9IcoSwYcLykbDLgeC0mhSMHOOuWv1RGRaZdzObc5YA1eB +idQmzy5xAHzNxPHHrB-fpjFJRYv_QZY9qZcGvP58d6bHO0upxbj-BBt9zfc7Qt0JLU6EAdYbW5TI +2v4JImikrx6KvtoK8vcjJMTDAanTVB31J65tat0rq9wYKxUdjBJLzkT3psYs_DRtYQc0i02YTD7t +dWya0-3p1Yrt0em3XGb8JAh2PA3BsQKmvKAOc054wf_B8n8saxSFw1WQL30vU5c4-Z_p53HfaUYd +Qg7DZskzgwBRy48sLJNCrn81RtxXfQP1XtPEZs-AAlTUslHoUdoQ1cwrYEgkNT1cjk6sLI_oKSK- +dDICBnlYLrZRBS3sH8K38WaIh1WRY6vbGVDs1tUectUpng_-Khavd0Crw7D_CE6T7Rnfcn0pnTV- +HW1PIXejFsONQn-2c3a9HZ-v6Hg4JL6UWm-qgBPC5118ymO0LfmrviAFAC6Wt3WFiNzrvx9Jggus +lE0qvLVfkQVZXAy-hSPHlYZmtxk5voVsf60qPoDN2-NdpWz62M9PrXd_A03YGxzt0G6J4VXExRES +xqLeGNGB496AfX_vEub97sR8xcbbUXsyt12uVnygifGyND60coikaKrMktv2OLOLEl8AudLp0ZNA +oOoYJZqfUnQqaLt0dNmNa5OtzYjf7f6bYX0V8XLTHlFqZ6QzqYGFMPNhDYjqtet6d--Q8t7_5S5C +RfXP8Wh8CjbEh2_rsr9rvy1nhM_Cptxc0BFXcS5Dt_R4vjd2G4B_LEC4Hy1s_rZThzUVxRCl \ No newline at end of file diff --git a/cmso-service/src/main/resources/aaf/org.onap.oof.location.props b/cmso-service/src/main/resources/aaf/org.onap.oof.location.props new file mode 100644 index 0000000..d4a48df --- /dev/null +++ b/cmso-service/src/main/resources/aaf/org.onap.oof.location.props @@ -0,0 +1,8 @@ +############################################################ +# Properties Generated by AT&T Certificate Manager +# by root +# on 2019-02-15T21:01:19.861+0000 +# @copyright 2016, AT&T +############################################################ +cadi_latitude=0.00 +cadi_longitude=0.00 diff --git a/cmso-service/src/main/resources/aaf/org.onap.oof.props b/cmso-service/src/main/resources/aaf/org.onap.oof.props new file mode 100644 index 0000000..766c354 --- /dev/null +++ b/cmso-service/src/main/resources/aaf/org.onap.oof.props @@ -0,0 +1,14 @@ +############################################################ +# Properties Generated by AT&T Certificate Manager +# by root +# on 2019-02-15T21:01:19.866+0000 +# @copyright 2016, AT&T +############################################################ +aaf_id=oof@oof.onap.org +aaf_locate_url=https://aaf-onap-test.osaaf.org:8095 +aaf_url=https://AAF_LOCATE_URL/AAF_NS.service:2.1 +cadi_etc_dir=etc/config +cadi_latitude=0.00 +cadi_longitude=0.00 +cadi_prop_files=src/main/resources/aaf/org.onap.oof.location.props;src/main/resources/aaf/org.onap.oof.cred.props +cm_url=https://AAF_LOCATE_URL/AAF_NS.cm:2.1 diff --git a/cmso-service/src/main/resources/aaf/truststoreONAPall.jks b/cmso-service/src/main/resources/aaf/truststoreONAPall.jks new file mode 100644 index 0000000..ff844b1 Binary files /dev/null and b/cmso-service/src/main/resources/aaf/truststoreONAPall.jks differ diff --git a/cmso-service/src/main/resources/application.properties b/cmso-service/src/main/resources/application.properties index fb3ee01..0cdbf57 100644 --- a/cmso-service/src/main/resources/application.properties +++ b/cmso-service/src/main/resources/application.properties @@ -60,3 +60,4 @@ com.att.eelf.logging.file=logback.xml com.att.eelf.logging.path= logging.config= +spring.profiles.active=proprietary-auth \ No newline at end of file diff --git a/cmso-service/src/main/resources/logmessages.properties b/cmso-service/src/main/resources/logmessages.properties index 09d9312..e339117 100644 --- a/cmso-service/src/main/resources/logmessages.properties +++ b/cmso-service/src/main/resources/logmessages.properties @@ -1,83 +1,59 @@ -#------------------------------------------------------------------------------- -# Copyright 2017-2018 AT&T Intellectual Property. -# Modifications Copyright 2018 IBM. -# -# 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. -# -# -# Unless otherwise specified, all documentation contained herein is licensed -# under the Creative Commons License, Attribution 4.0 Intl. (the ??License?); -# you may not use this documentation except in compliance with the License. -# You may obtain a copy of the License at -# -# https://creativecommons.org/licenses/by/4.0/ -# -# Unless required by applicable law or agreed to in writing, documentation -# 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. -#------------------------------------------------------------------------------- - -# Generated from org.onap.optf.cmso.common.LogMessages -SEARCH_SCHEDULE_REQUEST_DETAILS SEARCH_SCHEDULE_REQUEST_DETAILS|Search Schedule Request Details {0} from {1}: {2}|No resolution needed|No action is required -SEARCH_SCHEDULE_REQUEST SEARCH_SCHEDULE_REQUEST|Search Schedule Request {0} from {1}: {2} : {3}|No resolution needed|No action is required -CREATE_SCHEDULE_REQUEST CREATE_SCHEDULE_REQUEST|Create Schedule Request {0} from {1}: {2} : {3}|No resolution needed|No action is required -DELETE_SCHEDULE_REQUEST DELETE_SCHEDULE_REQUEST|Delete Schedule Request {0} from {1}: {2} : {3}|No resolution needed|No action is required -GET_SCHEDULE_REQUEST_INFO GET_SCHEDULE_REQUEST_INFO|Get Schedule Request Info {0} from {1}: {2} : {3}|No resolution needed|No action is required -PROCESS_OPTIMIZER_CALLBACK PROCESS_OPTIMIZER_CALLBACK|Change management optimizer callback {0} from {1}: {2} |No resolution needed|No action is required -APPROVE_SCHEDULE_REQUEST APPROVE_SCHEDULE_REQUEST|Approve Schedule Request {0} from {1}: {2} : {3}|No resolution needed|No action is required -SCHEDULE_ALREADY_EXISTS SCHEDULE_ALREADY_EXISTS|Schedule already exists domain={0} schedule id={1}|No resolution needed|No action is required -SCHEDULE_NOT_FOUND SCHEDULE_NOT_FOUND|Schedule not found domain={0} schedule id={1}|No resolution needed|No action is required -INVALID_ATTRIBUTE INVALID_ATTRIBUTE|Invalid attribute {0}={1}|No resolution needed|No action is required -MISSING_REQUIRED_ATTRIBUTE MISSING_REQUIRED_ATTRIBUTE|Missing required attribute '{0}'|No resolution needed|No action is required -INVALID_REQUEST INVALID_REQUEST|The input data structure is incorrect|No resolution needed|No action is required -REQUEST_TIMED_OUT REQUEST_TIMED_OUT|Request timed out.|No resolution needed|No action is required -UNEXPECTED_EXCEPTION UNEXPECTED_EXCEPTION|Unexpected exception encountered during processing. Please contact support : {0}|No resolution needed|No action is required -AUTHORIZATION_FAILED AUTHORIZATION_FAILED|Authorization Failed|No resolution needed|No action is required -UNDEFINED_DOMAIN_DATA_ATTRIBUTE UNDEFINED_DOMAIN_DATA_ATTRIBUTE|Domain data attribute not defined domain={0} name={1} value={2}|No resolution needed|No action is required -UNDEFINED_FILTER_ATTRIBUTE UNDEFINED_FILTER_ATTRIBUTE|Undefined filter attribute {0}|No resolution needed|No action is required -INVALID_DATE_FILTER INVALID_DATE_FILTER|Invalid date filter provided {0}=(1}|No resolution needed|No action is required -OPTIMIZER_QUARTZ_JOB OPTIMIZER_QUARTZ_JOB|Quartz scheduling of OptimizerQuartzJob: {0}|No resolution needed|No action is required -OPTIMIZER_EXCEPTION OPTIMIZER_EXCEPTION|Exception making client call to optimizer {0}|No resolution needed|No action is required -OPTIMIZER_CALLBACK_STATE_ERROR OPTIMIZER_CALLBACK_STATE_ERROR|Optimizer callback on schedule in invalid state. Should be {0} but was {1}.|No resolution needed|No action is required -CHANGE_MANAGEMENT_GROUP_NOT_FOUND CHANGE_MANAGEMENT_GROUP_NOT_FOUND|ChangeManagementGroup not found on optimizer callback scheduleId={0} groupId={1}|No resolution needed|No action is required -UNABLE_TO_ALLOCATE_VNF_TIMESLOTS UNABLE_TO_ALLOCATE_VNF_TIMESLOTS|Unable to allocate VNF timeslots with Optimizer results startTime={0}, latestStartTime={1}, totalDuration={2}, concurrency={3} nvfs={4}|No resolution needed|No action is required -UNABLE_TO_LOCATE_SCHEDULE_DETAIL UNABLE_TO_LOCATE_SCHEDULE_DETAIL|Unable to locate ChangeManagementSchedule for VNF. scheduleId={0}, groupId={1}, vnfName={2}|No resolution needed|No action is required -CM_JOB CM_JOB|Quartz scheduling of CmJob: {0}|No resolution needed|No action is required -CM_QUARTZ_JOB CM_QUARTZ_JOB|Quartz scheduling of CmQuartzJob: {0}|No resolution needed|No action is required -NOT_PENDING_APPROVAL NOT_PENDING_APPROVAL|Approval request received for schedule that is not in Pending Approval state: domain={0} scheduleId={1} state={3}|No resolution needed|No action is required -SCHEDULE_PAST_DUE SCHEDULE_PAST_DUE|Attempt to dispatch an event that is Past due scheduleId={0}, vnf={1}, now={2}, startTime={3}|No resolution needed|No action is required -MSO_POLLING_MISSING_SCHEDULE MSO_POLLING_MISSING_SCHEDULE|Attempt to poll MSO for request id {1} for missing ChangeManagementSchedule id={0}|No resolution needed|No action is required -MSO_STATUS_JOB MSO_STATUS_JOB|Polling MSO {0} for requestId={1} for id={2}|No resolution needed|No action is required -UNEXPECTED_RESPONSE UNEXPECTED_RESPONSE|Unexpected response from {0} HTTP Status={1} : {2}|No resolution needed|No action is required -SCHEDULE_STATUS_JOB SCHEDULE_STATUS_JOB|Quartz scheduling of ScheduleStatusJob: {0}|No resolution needed|No action is required -CM_TICKET_NOT_APPROVED CM_TICKET_NOT_APPROVED|Attempt to dispatch a change management event that has no TM Ticket approved. scheduleId={0} VNF Name={1} TM ChangeId={2} Status={3} Approval Status={4}|No resolution needed|No action is required -MULTIPLE_GROUPS_NOT_SUPPORTED MULTIPLE_GROUPS_NOT_SUPPORTED|Multiple groups not supported on immediate requests|No resolution needed|No action is required -TM_CREATE_CHANGE_RECORD TM_CREATE_CHANGE_RECORD|TM Create Change Record:{0} : Schedule ID: {1}|No resolution needed|No action is required -TM_LIST TM_LIST|TM list:{0} : URL : {1}|No resolution needed|No action is required -TM_API TM_API|TM API Call: URL : {0}|No resolution needed|No action is required -UNABLE_TO_CREATE_CHANGE_TICKET UNABLE_TO_CREATE_CHANGE_TICKET|Unable to create change ticket in TM: Schedule ID: {0} : Reason : {1}|No resolution needed|No action is required -TM_UPDATE_CHECKLIST TM_UPDATE_CHECKLIST|TM Fetch Checklist:{0} : Schedule ID: {1} : Change Id : {2} : URL : {3}|No resolution needed|No action is required -OPTIMIZER_REQUEST OPTIMIZER_REQUEST|Optimi Request:{0} : Schedule ID: {1} : URL : {2}|No resolution needed|No action is required -TM_CLOSE_CHANGE_RECORD TM_CLOSE_CHANGE_RECORD|TM Close Change Record:{0} : Schedule ID: {1} : Change Id : {2}|No resolution needed|No action is required -UNABLE_TO_CLOSE_CHANGE_TICKET UNABLE_TO_CLOSE_CHANGE_TICKET|Unable to close change ticket in TM: Schedule ID: {0} : changeid: {1} : Reason: {2}|No resolution needed|No action is required -CANNOT_CANCEL_IN_PROGRESS CANNOT_CANCEL_IN_PROGRESS|Cannot delete/cancel a schedule with events in progress.|No resolution needed|No action is required -UNABLE_TO_PARSE_SCHEDULING_INFO UNABLE_TO_PARSE_SCHEDULING_INFO|Cannot parse scheduling info.|No resolution needed|No action is required -UNABLE_TO_LOCATE_CHANGE_RECORD UNABLE_TO_LOCATE_CHANGE_RECORD|Unable to locate TM change record {2} to check status before displacth of {1} for schedulId={0}|No resolution needed|No action is required -INVALID_CHANGE_WINDOW INVALID_CHANGE_WINDOW|Change window end time {1} must be after start time {0}|No resolution needed|No action is required -NODE_LIST_CONTAINS_EMTPY_NODE NODE_LIST_CONTAINS_EMTPY_NODE|vnfDetails node list contains at least one empty node.|No resolution needed|No action is required -SO_API SO_API|SO Poll Request {0}|No resolution needed|No action is required -EXPECTED_EXCEPTION EXPECTED_EXCEPTION|Expected exception encountered during processing. Make Sonar happy: {0}|No resolution needed|No action is required -TM_UPDATE_CHANGE_RECORD TM_UPDATE_CHANGE_RECORD|TM Update Change Record:{0} : Schedule ID: {1} : Change Id : {2} : URL : {3}|No resolution needed|No action is required -UNABLE_TO_UPDATE_CHANGE_TICKET UNABLE_TO_UPDATE_CHANGE_TICKET|Unable to update change ticket in TM: Schedule ID: {0} : changeid: {1} : Reason: {2}|No resolution needed|No action is required +# Generated from org.onap.optf.cmso.common.LogMessages +SEARCH_SCHEDULE_REQUEST_DETAILS SEARCH_SCHEDULE_REQUEST_DETAILS|Search Schedule Request Details {0} from {1}: {2}|No resolution needed|No action is required +SEARCH_SCHEDULE_REQUEST SEARCH_SCHEDULE_REQUEST|Search Schedule Request {0} from {1}: {2} : {3}|No resolution needed|No action is required +CREATE_SCHEDULE_REQUEST CREATE_SCHEDULE_REQUEST|Create Schedule Request {0} from {1}: {2} : {3}|No resolution needed|No action is required +DELETE_SCHEDULE_REQUEST DELETE_SCHEDULE_REQUEST|Delete Schedule Request {0} from {1}: {2} : {3}|No resolution needed|No action is required +GET_SCHEDULE_REQUEST_INFO GET_SCHEDULE_REQUEST_INFO|Get Schedule Request Info {0} from {1}: {2} : {3}|No resolution needed|No action is required +PROCESS_OPTIMIZER_CALLBACK PROCESS_OPTIMIZER_CALLBACK|Change management optimizer callback {0} from {1}: {2} |No resolution needed|No action is required +APPROVE_SCHEDULE_REQUEST APPROVE_SCHEDULE_REQUEST|Approve Schedule Request {0} from {1}: {2} : {3}|No resolution needed|No action is required +SCHEDULE_ALREADY_EXISTS SCHEDULE_ALREADY_EXISTS|Schedule already exists domain={0} schedule id={1}|No resolution needed|No action is required +SCHEDULE_NOT_FOUND SCHEDULE_NOT_FOUND|Schedule not found domain={0} schedule id={1}|No resolution needed|No action is required +INVALID_ATTRIBUTE INVALID_ATTRIBUTE|Invalid attribute {0}={1}|No resolution needed|No action is required +MISSING_REQUIRED_ATTRIBUTE MISSING_REQUIRED_ATTRIBUTE|Missing required attribute '{0}'|No resolution needed|No action is required +INVALID_REQUEST INVALID_REQUEST|The input data structure is incorrect|No resolution needed|No action is required +REQUEST_TIMED_OUT REQUEST_TIMED_OUT|Request timed out.|No resolution needed|No action is required +UNEXPECTED_EXCEPTION UNEXPECTED_EXCEPTION|Unexpected exception encountered during processing. Please contact support : {0}|No resolution needed|No action is required +UNDEFINED_DOMAIN_DATA_ATTRIBUTE UNDEFINED_DOMAIN_DATA_ATTRIBUTE|Domain data attribute not defined domain={0} name={1} value={2}|No resolution needed|No action is required +UNDEFINED_FILTER_ATTRIBUTE UNDEFINED_FILTER_ATTRIBUTE|Undefined filter attribute {0}|No resolution needed|No action is required +INVALID_DATE_FILTER INVALID_DATE_FILTER|Invalid date filter provided {0}=(1}|No resolution needed|No action is required +OPTIMIZER_QUARTZ_JOB OPTIMIZER_QUARTZ_JOB|Quartz scheduling of OptimizerQuartzJob: {0}|No resolution needed|No action is required +OPTIMIZER_EXCEPTION OPTIMIZER_EXCEPTION|Exception making client call to optimizer {0}|No resolution needed|No action is required +OPTIMIZER_CALLBACK_STATE_ERROR OPTIMIZER_CALLBACK_STATE_ERROR|Optimizer callback on schedule in invalid state. Should be {0} but was {1}.|No resolution needed|No action is required +CHANGE_MANAGEMENT_GROUP_NOT_FOUND CHANGE_MANAGEMENT_GROUP_NOT_FOUND|ChangeManagementGroup not found on optimizer callback scheduleId={0} groupId={1}|No resolution needed|No action is required +INCOMING_MESSAGE INCOMING_MESSAGE|Incoming message method={0} path={1}|No resolution needed|No action is required +INCOMING_MESSAGE_RESPONSE INCOMING_MESSAGE_RESPONSE|Message response method={0} path={1} status={2}|No resolution needed|No action is required +OUTGOING_MESSAGE OUTGOING_MESSAGE|Outgoing message method={0} path={1}|No resolution needed|No action is required +OUTGOING_MESSAGE_RETURNED OUTGOING_MESSAGE_RETURNED|Outgoing message returned method={0} path={1} status={2}|No resolution needed|No action is required +UNABLE_TO_ALLOCATE_VNF_TIMESLOTS UNABLE_TO_ALLOCATE_VNF_TIMESLOTS|Unable to allocate VNF timeslots with Optimizer results startTime={0}, latestStartTime={1}, totalDuration={2}, concurrency={3} nvfs={4}|No resolution needed|No action is required +UNABLE_TO_LOCATE_SCHEDULE_DETAIL UNABLE_TO_LOCATE_SCHEDULE_DETAIL|Unable to locate ChangeManagementSchedule for VNF. scheduleId={0}, groupId={1}, vnfName={2}|No resolution needed|No action is required +CM_JOB CM_JOB|Quartz scheduling of CmJob: {0}|No resolution needed|No action is required +CM_QUARTZ_JOB CM_QUARTZ_JOB|Quartz scheduling of CmQuartzJob: {0}|No resolution needed|No action is required +NOT_PENDING_APPROVAL NOT_PENDING_APPROVAL|Approval request received for schedule that is not in Pending Approval state: domain={0} scheduleId={1} state={3}|No resolution needed|No action is required +SCHEDULE_PAST_DUE SCHEDULE_PAST_DUE|Attempt to dispatch an event that is Past due scheduleId={0}, vnf={1}, now={2}, startTime={3}|No resolution needed|No action is required +MSO_POLLING_MISSING_SCHEDULE MSO_POLLING_MISSING_SCHEDULE|Attempt to poll MSO for request id {1} for missing ChangeManagementSchedule id={0}|No resolution needed|No action is required +MSO_STATUS_JOB MSO_STATUS_JOB|Polling MSO {0} for requestId={1} for id={2}|No resolution needed|No action is required +UNEXPECTED_RESPONSE UNEXPECTED_RESPONSE|Unexpected response from {0} HTTP Status={1} : {2}|No resolution needed|No action is required +SCHEDULE_STATUS_JOB SCHEDULE_STATUS_JOB|Quartz scheduling of ScheduleStatusJob: {0}|No resolution needed|No action is required +CM_TICKET_NOT_APPROVED CM_TICKET_NOT_APPROVED|Attempt to dispatch a change management event that has no TM Ticket approved. scheduleId={0} VNF Name={1} TM ChangeId={2} Status={3} Approval Status={4}|No resolution needed|No action is required +MULTIPLE_GROUPS_NOT_SUPPORTED MULTIPLE_GROUPS_NOT_SUPPORTED|Multiple groups not supported on immediate requests|No resolution needed|No action is required +TM_CREATE_CHANGE_RECORD TM_CREATE_CHANGE_RECORD|TM Create Change Record:{0} : Schedule ID: {1}|No resolution needed|No action is required +TM_LIST TM_LIST|TM list:{0} : URL : {1}|No resolution needed|No action is required +TM_API TM_API|TM API Call: URL : {0}|No resolution needed|No action is required +UNABLE_TO_CREATE_CHANGE_TICKET UNABLE_TO_CREATE_CHANGE_TICKET|Unable to create change ticket in TM: Schedule ID: {0} : Reason : {1}|No resolution needed|No action is required +TM_UPDATE_CHECKLIST TM_UPDATE_CHECKLIST|TM Fetch Checklist:{0} : Schedule ID: {1} : Change Id : {2} : URL : {3}|No resolution needed|No action is required +OPTIMIZER_REQUEST OPTIMIZER_REQUEST|Optimi Request:{0} : Schedule ID: {1} : URL : {2}|No resolution needed|No action is required +TM_CLOSE_CHANGE_RECORD TM_CLOSE_CHANGE_RECORD|TM Close Change Record:{0} : Schedule ID: {1} : Change Id : {2}|No resolution needed|No action is required +UNABLE_TO_CLOSE_CHANGE_TICKET UNABLE_TO_CLOSE_CHANGE_TICKET|Unable to close change ticket in TM: Schedule ID: {0} : changeid: {1} : Reason: {2}|No resolution needed|No action is required +CANNOT_CANCEL_IN_PROGRESS CANNOT_CANCEL_IN_PROGRESS|Cannot delete/cancel a schedule with events in progress.|No resolution needed|No action is required +UNABLE_TO_PARSE_SCHEDULING_INFO UNABLE_TO_PARSE_SCHEDULING_INFO|Cannot parse scheduling info.|No resolution needed|No action is required +UNABLE_TO_LOCATE_CHANGE_RECORD UNABLE_TO_LOCATE_CHANGE_RECORD|Unable to locate TM change record {2} to check status before displacth of {1} for schedulId={0}|No resolution needed|No action is required +INVALID_CHANGE_WINDOW INVALID_CHANGE_WINDOW|Change window end time {1} must be after start time {0}|No resolution needed|No action is required +NODE_LIST_CONTAINS_EMTPY_NODE NODE_LIST_CONTAINS_EMTPY_NODE|vnfDetails node list contains at least one empty node.|No resolution needed|No action is required +SO_API SO_API|SO Poll Request {0}|No resolution needed|No action is required +EXPECTED_EXCEPTION EXPECTED_EXCEPTION|Expected exception encountered during processing. {0}|No resolution needed|No action is required +TM_UPDATE_CHANGE_RECORD TM_UPDATE_CHANGE_RECORD|TM Update Change Record:{0} : Schedule ID: {1} : Change Id : {2} : URL : {3}|No resolution needed|No action is required +UNABLE_TO_UPDATE_CHANGE_TICKET UNABLE_TO_UPDATE_CHANGE_TICKET|Unable to update change ticket in TM: Schedule ID: {0} : changeid: {1} : Reason: {2}|No resolution needed|No action is required +UNAUTHORIZED UNAUTHORIZED|Authorization failed.|No resolution needed|No action is required +UNAUTHENTICATED UNAUTHENTICATED|Authentication failed.|No resolution needed|No action is required +UNRECOGNIZED_MSO_STATUS UNRECOGNIZED_MSO_STATUS|Unrecognized status returned by MSO {0}|No resolution needed|No action is required +UNABLE_TO_PARSE_MSO_RESPONSE UNABLE_TO_PARSE_MSO_RESPONSE|Unable to parse status message from MSO {0} : {1}|No resolution needed|No action is required -- cgit 1.2.3-korg
CodeLog LevelMessage
").append(m.name()).append("").append(m.level).append("").append(m.defaultMessage).append("