diff options
author | Arthur Martella <amartell@research.att.com> | 2017-09-08 13:27:46 -0400 |
---|---|---|
committer | Arthur Martella <amartell@research.att.com> | 2017-09-08 13:32:24 -0400 |
commit | 62cd6aaaf74aa91ee0037c0e155c8e7284f07567 (patch) | |
tree | 68c0c53c9156f5aa3c6b3599ac940770f986633d /common/src/main/java/org/openecomp | |
parent | fa1a211d28a912892fcd888569df033900eb01ee (diff) |
1710 Rebase - Second Attempt
This commit rebases changes from openecomp-mso/internal-staging-1710 up to and including this codecloud commit:
54483fc6606ddb1591a2e9da61bff8712325f924
Wed Sep 6 18:12:56 2017 -0400
Rebasing was done on a branch on top of this commit in so/master in ONAP:
93fbdfbe46104f8859d4754040f979cb7997c157
Thu Sep 7 16:42:59 2017 +0000
Change-Id: I4ad9abf40da32bf5bdca43e868b8fa2dbcd9dc59
Issue-id: SO-107
Signed-off-by: Arthur Martella <amartell@research.att.com>
Diffstat (limited to 'common/src/main/java/org/openecomp')
7 files changed, 181 insertions, 104 deletions
diff --git a/common/src/main/java/org/openecomp/mso/db/AbstractSessionFactoryManager.java b/common/src/main/java/org/openecomp/mso/db/AbstractSessionFactoryManager.java new file mode 100644 index 0000000000..3efd6e2435 --- /dev/null +++ b/common/src/main/java/org/openecomp/mso/db/AbstractSessionFactoryManager.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.db; + +import org.hibernate.cfg.Configuration; +import org.hibernate.SessionFactory; +import org.hibernate.service.ServiceRegistry; +import org.openecomp.mso.properties.MsoDatabaseException; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import java.net.URL; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +public abstract class AbstractSessionFactoryManager { + + protected static Map<String, SessionFactory> sessionFactories = new ConcurrentHashMap<String, SessionFactory>(); + + protected synchronized SessionFactory initializeSessionFactory(URL hibernateConfigFile) + throws MsoDatabaseException { + try { + if (hibernateConfigFile != null) { + SessionFactory tempFactory = sessionFactories.get(hibernateConfigFile.getPath()); + // Already initialized, skip + if (tempFactory != null) { + return tempFactory; + } + + Configuration conf = new Configuration().configure(hibernateConfigFile); + ServiceRegistry sr = new StandardServiceRegistryBuilder().applySettings(conf.getProperties()).build(); + tempFactory = conf.buildSessionFactory(sr); + if (tempFactory == null) { + throw new MsoDatabaseException( + "SessionFactory can't be initialized, method buildSessionFactory returned null !"); + } + sessionFactories.put(hibernateConfigFile.getPath(), tempFactory); + return tempFactory; + } else { + throw new MsoDatabaseException( + "HibernateConfigFile provided is null, therefore Hibernate can't be initialized !"); + } + } catch (Exception e) { + throw new MsoDatabaseException("Exception occurred during the SessionFactory Build", e); + } + } + + public SessionFactory getSessionFactory() throws MsoDatabaseException { + URL hibernateConfigFile = getHibernateConfigFile(); + SessionFactory factory = sessionFactories.get(hibernateConfigFile.getPath()); + if (factory == null) { + factory = initializeSessionFactory(hibernateConfigFile); + } + return factory; + } + + protected abstract URL getHibernateConfigFile(); +} diff --git a/common/src/main/java/org/openecomp/mso/db/HibernateUtils.java b/common/src/main/java/org/openecomp/mso/db/HibernateUtils.java deleted file mode 100644 index ba452fff44..0000000000 --- a/common/src/main/java/org/openecomp/mso/db/HibernateUtils.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db; - -import org.hibernate.cfg.Configuration; -import org.hibernate.SessionFactory; -import org.hibernate.service.ServiceRegistry; -import org.hibernate.boot.registry.StandardServiceRegistryBuilder; -import java.net.URL; - -public abstract class HibernateUtils { - - protected SessionFactory sessionFactory; - - protected synchronized void initializeHibernate(URL hibernateConfigFile) { - // Can be null, in that case, we skip the loading - if (hibernateConfigFile != null) { - // Already initialized, skip - if (sessionFactory != null) { - return; - } - - Configuration conf = new Configuration().configure(hibernateConfigFile); - ServiceRegistry sr = new StandardServiceRegistryBuilder().applySettings(conf.getProperties()).build(); - sessionFactory = conf.buildSessionFactory(sr); - } - } - - public SessionFactory getSessionFactory() { - if (sessionFactory == null) { - initializeHibernate(getHibernateConfigFile()); - } - return sessionFactory; - } - - protected abstract URL getHibernateConfigFile(); -} diff --git a/common/src/main/java/org/openecomp/mso/logger/MessageEnum.java b/common/src/main/java/org/openecomp/mso/logger/MessageEnum.java index 521aa50435..ee0e294f84 100644 --- a/common/src/main/java/org/openecomp/mso/logger/MessageEnum.java +++ b/common/src/main/java/org/openecomp/mso/logger/MessageEnum.java @@ -167,7 +167,6 @@ public enum MessageEnum implements EELFResolvableErrorEnum{ BPMN_GENERAL_METRICS,
BPMN_URN_MAPPING_FAIL,
BPMN_VARIABLE_NULL,
- BPMN_SDNC_CALLBACK_EXCEPTION,
BPMN_CALLBACK_EXCEPTION,
// ASDC Messages
ASDC_GENERAL_EXCEPTION_ARG,
diff --git a/common/src/main/java/org/openecomp/mso/logger/MsoLogger.java b/common/src/main/java/org/openecomp/mso/logger/MsoLogger.java index e9b6fb1225..a0fc765e44 100644 --- a/common/src/main/java/org/openecomp/mso/logger/MsoLogger.java +++ b/common/src/main/java/org/openecomp/mso/logger/MsoLogger.java @@ -106,7 +106,7 @@ public class MsoLogger { public enum ResponseCode { Suc(0), PermissionError(100), DataError(300), DataNotFound(301), BadRequest(302), SchemaError( 400), BusinessProcesssError(500), ServiceNotAvailable(501), InternalError( - 502), Conflict(503), DBAccessError(504), CommunicationError(505), UnknownError(900); + 502), Conflict(503), DBAccessError(504), CommunicationError(505), UnknownError(900); private int value; @@ -144,8 +144,8 @@ public class MsoLogger { private static final Logger LOGGER = Logger.getLogger(MsoLogger.class.getName()); private MsoLogger(MsoLogger.Catalog cat) { - this.debugLogger = EELFManager.getInstance().getDebugLogger(); - this.errorLogger = EELFManager.getInstance().getErrorLogger(); + this.debugLogger = EELFManager.getInstance().getDebugLogger(); + this.errorLogger = EELFManager.getInstance().getErrorLogger(); this.auditLogger = EELFManager.getInstance().getAuditLogger(); this.metricsLogger = EELFManager.getInstance().getMetricsLogger(); MsoLogger.initialization(); @@ -172,7 +172,7 @@ public class MsoLogger { /** * Get the MsoLogger based on the catalog - * + * * @param cat * Catalog of the logger * @return the MsoLogger @@ -183,7 +183,7 @@ public class MsoLogger { /** * Record the Metrics event with no argument - * + * * @param startTime * Transaction starting time in millieseconds * @param statusCode @@ -200,7 +200,7 @@ public class MsoLogger { * Target VNF or VM acted opon by the component, if available */ public void recordMetricEvent(Long startTime, StatusCode statusCode, ResponseCode responseCode, String responseDesc, - String targetEntity, String targetServiceName, String targetVEntity) { + String targetEntity, String targetServiceName, String targetVEntity) { prepareMetricMsg(startTime, statusCode, responseCode.getValue(), responseDesc, targetEntity, targetServiceName, targetVEntity); metricsLogger.info(""); @@ -222,7 +222,7 @@ public class MsoLogger { * Human redable description of the application response code */ public void recordAuditEvent(Long startTime, StatusCode statusCode, ResponseCode responseCode, - String responseDesc) { + String responseDesc) { prepareAuditMsg(startTime, statusCode, responseCode.getValue(), responseDesc); auditLogger.info(""); MDC.remove(TIMER); @@ -293,7 +293,7 @@ public class MsoLogger { * The arguments used in the log message */ public void info(EELFResolvableErrorEnum msg, String arg0, String arg1, String targetEntity, - String targetServiceName) { + String targetServiceName) { prepareErrorMsg(INFO_LEVEL, targetEntity, targetServiceName, null, ""); debugLogger.info(msg, normalize(arg0), normalize(arg1)); @@ -310,7 +310,7 @@ public class MsoLogger { * The arguments used in the log message */ public void info(EELFResolvableErrorEnum msg, String arg0, String arg1, String arg2, String targetEntity, - String targetServiceName) { + String targetServiceName) { prepareErrorMsg(INFO_LEVEL, targetEntity, targetServiceName, null, ""); debugLogger.info(msg, normalize(arg0), normalize(arg1), normalize(arg2)); @@ -327,7 +327,7 @@ public class MsoLogger { * The arguments used in the log message */ public void info(EELFResolvableErrorEnum msg, String arg0, String arg1, String arg2, String arg3, - String targetEntity, String targetServiceName) { + String targetEntity, String targetServiceName) { prepareErrorMsg(INFO_LEVEL, targetEntity, targetServiceName, null, ""); debugLogger.info(msg, normalize(arg0), normalize(arg1), normalize(arg2), normalize(arg3)); @@ -344,7 +344,7 @@ public class MsoLogger { * The arguments used in the log message */ public void info(EELFResolvableErrorEnum msg, String arg0, String arg1, String arg2, String arg3, String arg4, - String targetEntity, String targetServiceName) { + String targetEntity, String targetServiceName) { prepareErrorMsg(INFO_LEVEL, targetEntity, targetServiceName, null, ""); debugLogger.info(msg, normalize(arg0), normalize(arg1), normalize(arg2), normalize(arg3), normalize(arg4)); @@ -361,7 +361,7 @@ public class MsoLogger { * The arguments used in the log message */ public void info(EELFResolvableErrorEnum msg, String arg0, String arg1, String arg2, String arg3, String arg4, - String arg5, String targetEntity, String targetServiceName) { + String arg5, String targetEntity, String targetServiceName) { prepareErrorMsg(INFO_LEVEL, targetEntity, targetServiceName, null, ""); debugLogger.info(msg, normalize(arg0), normalize(arg1), normalize(arg2), normalize(arg3), normalize(arg4), @@ -378,7 +378,7 @@ public class MsoLogger { * The log message to put */ public void warn(EELFResolvableErrorEnum msg, String targetEntity, String targetServiceName, ErrorCode errorCode, - String errorDesc) { + String errorDesc) { prepareErrorMsg(WARN_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); errorLogger.warn(msg); @@ -395,7 +395,7 @@ public class MsoLogger { * The exception info */ public void warn(EELFResolvableErrorEnum msg, String targetEntity, String targetServiceName, ErrorCode errorCode, - String errorDesc, Throwable t) { + String errorDesc, Throwable t) { prepareErrorMsg(WARN_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); errorLogger.warn(msg); errorLogger.warn("Exception raised: " + getNormalizedStackTrace(t)); @@ -413,7 +413,7 @@ public class MsoLogger { * The argument used in the log message */ public void warn(EELFResolvableErrorEnum msg, String arg, String targetEntity, String targetServiceName, - ErrorCode errorCode, String errorDesc) { + ErrorCode errorCode, String errorDesc) { prepareErrorMsg(WARN_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); errorLogger.warn(msg, arg); MDC.remove(TARGETENTITY); @@ -431,7 +431,7 @@ public class MsoLogger { * The exception info */ public void warn(EELFResolvableErrorEnum msg, String arg, String targetEntity, String targetServiceName, - ErrorCode errorCode, String errorDesc, Throwable t) { + ErrorCode errorCode, String errorDesc, Throwable t) { prepareErrorMsg(WARN_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); errorLogger.warn(msg, arg); errorLogger.warn("Exception raised: " + getNormalizedStackTrace(t)); @@ -449,7 +449,7 @@ public class MsoLogger { * The arguments used in the log message */ public void warn(EELFResolvableErrorEnum msg, String arg0, String arg1, String targetEntity, - String targetServiceName, ErrorCode errorCode, String errorDesc) { + String targetServiceName, ErrorCode errorCode, String errorDesc) { prepareErrorMsg(WARN_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); errorLogger.warn(msg, normalize(arg0), normalize(arg1)); MDC.remove(TARGETENTITY); @@ -467,7 +467,7 @@ public class MsoLogger { * The exception info */ public void warn(EELFResolvableErrorEnum msg, String arg0, String arg1, String targetEntity, - String targetServiceName, ErrorCode errorCode, String errorDesc, Throwable t) { + String targetServiceName, ErrorCode errorCode, String errorDesc, Throwable t) { prepareErrorMsg(WARN_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); errorLogger.warn(msg, normalize(arg0), normalize(arg1)); errorLogger.warn("Exception raised: " + getNormalizedStackTrace(t)); @@ -485,7 +485,7 @@ public class MsoLogger { * The arguments used in the log message */ public void warn(EELFResolvableErrorEnum msg, String arg0, String arg1, String arg2, String targetEntity, - String targetServiceName, ErrorCode errorCode, String errorDesc) { + String targetServiceName, ErrorCode errorCode, String errorDesc) { prepareErrorMsg(WARN_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); errorLogger.warn(msg, normalize(arg0), normalize(arg1), normalize(arg2)); MDC.remove(TARGETENTITY); @@ -503,7 +503,7 @@ public class MsoLogger { * The exception info */ public void warn(EELFResolvableErrorEnum msg, String arg0, String arg1, String arg2, String targetEntity, - String targetServiceName, ErrorCode errorCode, String errorDesc, Throwable t) { + String targetServiceName, ErrorCode errorCode, String errorDesc, Throwable t) { prepareErrorMsg(WARN_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); errorLogger.warn(msg, normalize(arg0), normalize(arg1), normalize(arg2)); errorLogger.warn("Exception raised: " + getNormalizedStackTrace(t)); @@ -521,7 +521,7 @@ public class MsoLogger { * The arguments used in the log message */ public void warn(EELFResolvableErrorEnum msg, String arg0, String arg1, String arg2, String arg3, - String targetEntity, String targetServiceName, ErrorCode errorCode, String errorDesc) { + String targetEntity, String targetServiceName, ErrorCode errorCode, String errorDesc) { prepareErrorMsg(WARN_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); errorLogger.warn(msg, normalize(arg0), normalize(arg1), normalize(arg2), normalize(arg3)); MDC.remove(TARGETENTITY); @@ -539,7 +539,7 @@ public class MsoLogger { * The exception info */ public void warn(EELFResolvableErrorEnum msg, String arg0, String arg1, String arg2, String arg3, - String targetEntity, String targetServiceName, ErrorCode errorCode, String errorDesc, Throwable t) { + String targetEntity, String targetServiceName, ErrorCode errorCode, String errorDesc, Throwable t) { prepareErrorMsg(WARN_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); errorLogger.warn(msg, normalize(arg0), normalize(arg1), normalize(arg2), normalize(arg3)); errorLogger.warn("Exception raised: " + getNormalizedStackTrace(t)); @@ -557,7 +557,7 @@ public class MsoLogger { * The arguments used in the log message */ public void warn(EELFResolvableErrorEnum msg, String arg0, String arg1, String arg2, String arg3, String arg4, - String targetEntity, String targetServiceName, ErrorCode errorCode, String errorDesc) { + String targetEntity, String targetServiceName, ErrorCode errorCode, String errorDesc) { prepareErrorMsg(WARN_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); errorLogger.warn(msg, normalize(arg0), normalize(arg1), normalize(arg2), normalize(arg3), normalize(arg4)); MDC.remove(TARGETENTITY); @@ -575,7 +575,7 @@ public class MsoLogger { * The exception info */ public void warn(EELFResolvableErrorEnum msg, String arg0, String arg1, String arg2, String arg3, String arg4, - String targetEntity, String targetServiceName, ErrorCode errorCode, String errorDesc, Throwable t) { + String targetEntity, String targetServiceName, ErrorCode errorCode, String errorDesc, Throwable t) { prepareErrorMsg(WARN_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); errorLogger.warn(msg, normalize(arg0), normalize(arg1), normalize(arg2), normalize(arg3), normalize(arg4)); errorLogger.warn("Exception raised: " + getNormalizedStackTrace(t)); @@ -592,7 +592,7 @@ public class MsoLogger { * The log message to put */ public void error(EELFResolvableErrorEnum msg, String targetEntity, String targetServiceName, ErrorCode errorCode, - String errorDesc) { + String errorDesc) { prepareErrorMsg(ERROR_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); errorLogger.error(msg); MDC.remove(TARGETENTITY); @@ -608,7 +608,7 @@ public class MsoLogger { * The exception info */ public void error(EELFResolvableErrorEnum msg, String targetEntity, String targetServiceName, ErrorCode errorCode, - String errorDesc, Throwable t) { + String errorDesc, Throwable t) { prepareErrorMsg(ERROR_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); errorLogger.error(msg); errorLogger.error(exceptionArg, getNormalizedStackTrace(t)); @@ -626,7 +626,7 @@ public class MsoLogger { * The arguments used in the log message */ public void error(EELFResolvableErrorEnum msg, String arg0, String targetEntity, String targetServiceName, - ErrorCode errorCode, String errorDesc) { + ErrorCode errorCode, String errorDesc) { prepareErrorMsg(ERROR_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); errorLogger.error(msg, normalize(arg0)); MDC.remove(TARGETENTITY); @@ -644,7 +644,7 @@ public class MsoLogger { * The exception info */ public void error(EELFResolvableErrorEnum msg, String arg0, String targetEntity, String targetServiceName, - ErrorCode errorCode, String errorDesc, Throwable t) { + ErrorCode errorCode, String errorDesc, Throwable t) { prepareErrorMsg(ERROR_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); errorLogger.error(msg, normalize(arg0)); errorLogger.error(exceptionArg, getNormalizedStackTrace(t)); @@ -662,7 +662,7 @@ public class MsoLogger { * The arguments used in the log message */ public void error(EELFResolvableErrorEnum msg, String arg0, String arg1, String targetEntity, - String targetServiceName, ErrorCode errorCode, String errorDesc) { + String targetServiceName, ErrorCode errorCode, String errorDesc) { prepareErrorMsg(ERROR_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); errorLogger.error(msg, normalize(arg0), normalize(arg1)); MDC.remove(TARGETENTITY); @@ -680,7 +680,7 @@ public class MsoLogger { * The exception info */ public void error(EELFResolvableErrorEnum msg, String arg0, String arg1, String targetEntity, - String targetServiceName, ErrorCode errorCode, String errorDesc, Throwable t) { + String targetServiceName, ErrorCode errorCode, String errorDesc, Throwable t) { prepareErrorMsg(ERROR_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); errorLogger.error(msg, normalize(arg0), normalize(arg1)); errorLogger.error(exceptionArg, getNormalizedStackTrace(t)); @@ -698,7 +698,7 @@ public class MsoLogger { * The arguments used in the log message */ public void error(EELFResolvableErrorEnum msg, String arg0, String arg1, String arg2, String targetEntity, - String targetServiceName, ErrorCode errorCode, String errorDesc) { + String targetServiceName, ErrorCode errorCode, String errorDesc) { prepareErrorMsg(ERROR_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); errorLogger.error(msg, normalize(arg0), normalize(arg1), normalize(arg2)); MDC.remove(TARGETENTITY); @@ -716,7 +716,7 @@ public class MsoLogger { * The exception info */ public void error(EELFResolvableErrorEnum msg, String arg0, String arg1, String arg2, String targetEntity, - String targetServiceName, ErrorCode errorCode, String errorDesc, Throwable t) { + String targetServiceName, ErrorCode errorCode, String errorDesc, Throwable t) { prepareErrorMsg(ERROR_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); errorLogger.error(msg, normalize(arg0), normalize(arg1), normalize(arg2)); errorLogger.error(exceptionArg, getNormalizedStackTrace(t)); @@ -734,7 +734,7 @@ public class MsoLogger { * The arguments used in the log message */ public void error(EELFResolvableErrorEnum msg, String arg0, String arg1, String arg2, String arg3, - String targetEntity, String targetServiceName, ErrorCode errorCode, String errorDesc) { + String targetEntity, String targetServiceName, ErrorCode errorCode, String errorDesc) { prepareErrorMsg(ERROR_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); errorLogger.error(msg, normalize(arg0), normalize(arg1), normalize(arg2), normalize(arg3)); MDC.remove(TARGETENTITY); @@ -752,7 +752,7 @@ public class MsoLogger { * The exception info */ public void error(EELFResolvableErrorEnum msg, String arg0, String arg1, String arg2, String arg3, - String targetEntity, String targetServiceName, ErrorCode errorCode, String errorDesc, Throwable t) { + String targetEntity, String targetServiceName, ErrorCode errorCode, String errorDesc, Throwable t) { prepareErrorMsg(ERROR_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); errorLogger.error(msg, normalize(arg0), normalize(arg1), normalize(arg2), normalize(arg3)); errorLogger.error(exceptionArg, getNormalizedStackTrace(t)); @@ -770,7 +770,7 @@ public class MsoLogger { * The arguments used in the log message */ public void error(EELFResolvableErrorEnum msg, String arg0, String arg1, String arg2, String arg3, String arg4, - String targetEntity, String targetServiceName, ErrorCode errorCode, String errorDesc) { + String targetEntity, String targetServiceName, ErrorCode errorCode, String errorDesc) { prepareErrorMsg(ERROR_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); errorLogger.error(msg, normalize(arg0), normalize(arg1), normalize(arg2), normalize(arg3), normalize(arg4)); MDC.remove(TARGETENTITY); @@ -788,7 +788,7 @@ public class MsoLogger { * The exception info */ public void error(EELFResolvableErrorEnum msg, String arg0, String arg1, String arg2, String arg3, String arg4, - String targetEntity, String targetServiceName, ErrorCode errorCode, String errorDesc, Throwable t) { + String targetEntity, String targetServiceName, ErrorCode errorCode, String errorDesc, Throwable t) { prepareErrorMsg(ERROR_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); errorLogger.error(msg, normalize(arg0), normalize(arg1), normalize(arg2), normalize(arg3), normalize(arg4)); errorLogger.error(exceptionArg, getNormalizedStackTrace(t)); @@ -839,7 +839,7 @@ public class MsoLogger { } private void prepareAuditMetricMsg(long startTime, long endTime, StatusCode statusCode, int responseCode, - String responseDesc) { + String responseDesc) { Date startDate = new Date(startTime); Date endDate = new Date(endTime); DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); @@ -852,7 +852,7 @@ public class MsoLogger { } private void prepareErrorMsg(String loggingLevel, String targetEntity, String targetServiceName, - ErrorCode errorCode, String errorDesc) { + ErrorCode errorCode, String errorDesc) { MDC.put(ALERT_SEVERITY, getSeverityLevel(loggingLevel)); MDC.put(ERRORCODE, String.valueOf(errorCode)); MDC.put(ERRORDESC, errorDesc); @@ -862,7 +862,7 @@ public class MsoLogger { } private void prepareMetricMsg(long startTime, StatusCode statusCode, int responseCode, String responseDesc, - String targetEntity, String targetServiceName, String targetVEntity) { + String targetEntity, String targetServiceName, String targetVEntity) { long endTime = System.currentTimeMillis(); prepareMsg(INFO_LEVEL, null, String.valueOf(endTime - startTime)); prepareAuditMetricMsg(startTime, endTime, statusCode, responseCode, responseDesc); @@ -1000,7 +1000,7 @@ public class MsoLogger { /** * Set the requestId and serviceInstanceId - * + * * @param reqId * The requestId * @param svcId @@ -1018,7 +1018,7 @@ public class MsoLogger { /** * Set the remoteIp and the basic HTTP Authentication user - * + * * @param remoteIpp * The remote ip address * @param userp @@ -1035,7 +1035,7 @@ public class MsoLogger { /** * Set the serviceName - * + * * @param serviceNamep * The service name */ @@ -1048,7 +1048,7 @@ public class MsoLogger { /** * Get the serviceName - * + * * @return The service name */ public static String getServiceName() { @@ -1064,7 +1064,7 @@ public class MsoLogger { /** * Set the requestId and serviceInstanceId based on the mso request - * + * * @param msoRequest * The mso request */ diff --git a/common/src/main/java/org/openecomp/mso/logger/MsoLoggingServlet.java b/common/src/main/java/org/openecomp/mso/logger/MsoLoggingServlet.java index 568ab22447..c1de64b390 100644 --- a/common/src/main/java/org/openecomp/mso/logger/MsoLoggingServlet.java +++ b/common/src/main/java/org/openecomp/mso/logger/MsoLoggingServlet.java @@ -39,7 +39,11 @@ import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.joran.JoranConfigurator; import ch.qos.logback.core.Appender; +import com.wordnik.swagger.annotations.Api; +import com.wordnik.swagger.annotations.ApiOperation; + @Path("/logging") +@Api(value="/logging",description="logging") public class MsoLoggingServlet { private static final String DEBUGLOG = "asyncEELFDebug"; @@ -51,6 +55,7 @@ public class MsoLoggingServlet { @GET @Path("/setLevel/{logContext}/{level}") @Produces("text/plain") + @ApiOperation(value="message print",response=Response.class) public Response setLogLevel (@PathParam("logContext") String logContext, @PathParam("level") String level) { logger.info (MessageEnum.LOGGER_SETUP, "", ""); @@ -81,6 +86,7 @@ public class MsoLoggingServlet { @Path("/loggers") @Produces("text/plain") @SuppressWarnings("rawtypes") + @ApiOperation(value="message print",response=Response.class) public Response getLoggers () { StringBuilder response = new StringBuilder (); LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); @@ -99,6 +105,7 @@ public class MsoLoggingServlet { @GET @Path("/debug") @Produces("text/plain") + @ApiOperation(value="message print",response=Response.class) @SuppressWarnings("rawtypes") /* * Debug log is used as a general log to store all the logs events, including events generated by MSO code or by diff --git a/common/src/main/java/org/openecomp/mso/properties/MsoDatabaseException.java b/common/src/main/java/org/openecomp/mso/properties/MsoDatabaseException.java new file mode 100644 index 0000000000..f38495eb7a --- /dev/null +++ b/common/src/main/java/org/openecomp/mso/properties/MsoDatabaseException.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.properties; + + +/** + * Exception during artifact installation. + */ +public class MsoDatabaseException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = -7048331652191419371L; + + /** + * @param message The message to dump + * @param cause The Throwable cause object + */ + public MsoDatabaseException (final String message) { + super (message); + + } + + /** + * @param message The message to dump + * @param cause The Throwable cause object + */ + public MsoDatabaseException (final String message, final Throwable cause) { + super (message, cause); + + } +} diff --git a/common/src/main/java/org/openecomp/mso/properties/MsoJsonProperties.java b/common/src/main/java/org/openecomp/mso/properties/MsoJsonProperties.java index 976b579fcf..cfc9c7dd0e 100644 --- a/common/src/main/java/org/openecomp/mso/properties/MsoJsonProperties.java +++ b/common/src/main/java/org/openecomp/mso/properties/MsoJsonProperties.java @@ -25,12 +25,13 @@ import java.io.FileReader; import java.io.IOException; import java.security.GeneralSecurityException; -import org.codehaus.jackson.JsonNode; -import org.codehaus.jackson.JsonParseException; -import org.codehaus.jackson.map.JsonMappingException; -import org.codehaus.jackson.map.ObjectMapper; import org.openecomp.mso.utils.CryptoUtils; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + public class MsoJsonProperties extends AbstractMsoProperties { |