From b1ba8ef51edabee26acaf74e226eeb269297aec7 Mon Sep 17 00:00:00 2001 From: Jerry Flood Date: Tue, 16 Apr 2019 09:06:17 -0400 Subject: More checkstyle changes for Dublin Issue-ID: OPTFRA-466 Change-Id: Ied602196284bf3aed56ff491a749f14503395c88 Signed-off-by: Jerry Flood --- .../onap/optf/cmso/liquibase/LiquibaseData.java | 49 ++--- .../src/main/docker/extra-files/startService.sh | 21 +- .../java/org/onap/observations/MessageHeaders.java | 24 ++- .../clients/optimizer/OptimizerClient.java | 2 +- .../clients/optimizer/OptimizerRequestManager.java | 15 +- .../optimizer/clients/topology/TopologyClient.java | 2 +- .../optimizer/filters/CmsoContainerFilters.java | 6 +- .../optimizer/service/rs/models/ChangeWindow.java | 2 +- .../java/org/onap/optf/cmso/AuthProviderTest.java | 1 + .../availability/policies/PolicyManagerTest.java | 2 +- .../cmso/service/rs/MockHttpServletRequest.java | 17 +- cmso-service/etc/config/cmso.properties | 2 +- .../optf/cmso/CMSEnvironmentPostProcessor.java | 47 ---- .../org/onap/optf/cmso/CMSQuartzConfiguration.java | 171 --------------- .../optf/cmso/CmsoEnvironmentPostProcessor.java | 47 ++++ .../onap/optf/cmso/CmsoQuartzConfiguration.java | 171 +++++++++++++++ .../onap/optf/cmso/aaf/AafAuthorizationFilter.java | 6 +- .../java/org/onap/optf/cmso/aaf/AafFilter.java | 5 +- .../org/onap/optf/cmso/aaf/ResponseFormatter.java | 4 +- .../org/onap/optf/cmso/common/CMSRequestError.java | 82 ------- .../org/onap/optf/cmso/common/CMSStatusEnum.java | 110 ---------- .../onap/optf/cmso/common/CmsoRequestError.java | 82 +++++++ .../org/onap/optf/cmso/common/CmsoStatusEnum.java | 110 ++++++++++ .../exceptions/CMSAlreadyExistsException.java | 43 ---- .../optf/cmso/common/exceptions/CMSException.java | 81 ------- .../common/exceptions/CMSNotFoundException.java | 44 ---- .../exceptions/CmsoAlreadyExistsException.java | 43 ++++ .../optf/cmso/common/exceptions/CmsoException.java | 81 +++++++ .../common/exceptions/CmsoNotFoundException.java | 44 ++++ .../org/onap/optf/cmso/dispatcher/CMSOClient.java | 239 --------------------- .../java/org/onap/optf/cmso/dispatcher/CmJob.java | 14 +- .../org/onap/optf/cmso/dispatcher/CmsoClient.java | 239 +++++++++++++++++++++ .../org/onap/optf/cmso/dispatcher/DispatchJob.java | 28 +-- .../org/onap/optf/cmso/eventq/CMSQueueJob.java | 160 -------------- .../org/onap/optf/cmso/eventq/CmQuartzJob.java | 7 +- .../onap/optf/cmso/eventq/CmQuartzJobStartup.java | 4 +- .../org/onap/optf/cmso/eventq/CmsoQueueJob.java | 160 ++++++++++++++ .../optf/cmso/filters/CmsoContainerFilters.java | 6 +- .../org/onap/optf/cmso/filters/MessageHeaders.java | 24 ++- .../onap/optf/cmso/model/dao/ApprovalTypeDAO.java | 54 ----- .../onap/optf/cmso/model/dao/ApprovalTypeDao.java | 54 +++++ .../model/dao/ChangeManagementChangeWindowDAO.java | 58 ----- .../model/dao/ChangeManagementChangeWindowDao.java | 58 +++++ .../cmso/model/dao/ChangeManagementDetailDAO.java | 41 ---- .../model/dao/ChangeManagementDetailDAOImpl.java | 77 ------- .../cmso/model/dao/ChangeManagementDetailDao.java | 41 ++++ .../model/dao/ChangeManagementDetailDaoImpl.java | 77 +++++++ .../cmso/model/dao/ChangeManagementGroupDAO.java | 55 ----- .../cmso/model/dao/ChangeManagementGroupDao.java | 55 +++++ .../model/dao/ChangeManagementScheduleDAO.java | 93 -------- .../model/dao/ChangeManagementScheduleDao.java | 93 ++++++++ .../onap/optf/cmso/model/dao/DomainDataDAO.java | 47 ---- .../onap/optf/cmso/model/dao/DomainDataDao.java | 47 ++++ .../onap/optf/cmso/model/dao/ElementDataDAO.java | 49 ----- .../onap/optf/cmso/model/dao/ElementDataDao.java | 49 +++++ .../optf/cmso/model/dao/ScheduleApprovalDAO.java | 47 ---- .../optf/cmso/model/dao/ScheduleApprovalDao.java | 47 ++++ .../org/onap/optf/cmso/model/dao/ScheduleDAO.java | 72 ------- .../org/onap/optf/cmso/model/dao/ScheduleDao.java | 72 +++++++ .../onap/optf/cmso/model/dao/ScheduleQueryDAO.java | 41 ---- .../optf/cmso/model/dao/ScheduleQueryDAOImpl.java | 65 ------ .../onap/optf/cmso/model/dao/ScheduleQueryDao.java | 41 ++++ .../optf/cmso/model/dao/ScheduleQueryDaoImpl.java | 65 ++++++ .../optf/cmso/optimizer/CmsoOptimizerClient.java | 32 +-- .../optf/cmso/optimizer/CmsoOptimizerHandler.java | 52 ++--- .../optf/cmso/optimizer/OptimizerQuartzJob.java | 10 +- .../cmso/optimizer/bean/CMOptimizerRequest.java | 74 ------- .../cmso/optimizer/bean/CMOptimizerResponse.java | 124 ----------- .../optf/cmso/optimizer/bean/CMRequestInfo.java | 83 ------- .../onap/optf/cmso/optimizer/bean/CMSchedule.java | 88 -------- .../optf/cmso/optimizer/bean/CMSchedulingInfo.java | 110 ---------- .../optf/cmso/optimizer/bean/CMVnfDetails.java | 60 ------ .../cmso/optimizer/bean/CmsoOptimizerRequest.java | 74 +++++++ .../cmso/optimizer/bean/CmsoOptimizerResponse.java | 124 +++++++++++ .../optf/cmso/optimizer/bean/CmsoRequestInfo.java | 83 +++++++ .../optf/cmso/optimizer/bean/CmsoSchedule.java | 88 ++++++++ .../cmso/optimizer/bean/CmsoSchedulingInfo.java | 110 ++++++++++ .../optf/cmso/optimizer/bean/CmsoVnfDetails.java | 60 ++++++ .../cmso/service/rs/BaseSchedulerServiceImpl.java | 62 +++--- .../optf/cmso/service/rs/CmQueryParameters.java | 18 +- .../service/rs/CmsoOptimizedScheduleService.java | 4 +- .../rs/CmsoOptimizedScheduleServiceImpl.java | 4 +- .../cmso/service/rs/CmsoOptimizerCallback.java | 4 +- .../cmso/service/rs/CmsoOptimizerCallbackImpl.java | 80 +++---- .../org/onap/optf/cmso/service/rs/CmsoService.java | 10 +- .../onap/optf/cmso/service/rs/CmsoServiceImpl.java | 70 +++--- .../optf/cmso/service/rs/CommonServiceImpl.java | 106 ++++----- .../onap/optf/cmso/service/rs/HealthCheckImpl.java | 4 +- .../onap/optf/cmso/service/rs/models/CMSInfo.java | 121 ----------- .../optf/cmso/service/rs/models/CMSMessage.java | 73 ------- .../onap/optf/cmso/sostatus/MsoStatusClient.java | 26 +-- .../org/onap/optf/cmso/sostatus/MsoStatusJob.java | 4 +- .../onap/optf/cmso/sostatus/ScheduleStatusJob.java | 8 +- .../org/onap/optf/cmso/ticketmgt/TmClient.java | 50 ++--- .../onap/optf/cmso/ticketmgt/TmStatusClient.java | 34 +-- cmso-ticketmgt/pom.xml | 2 +- .../java/org/onap/observations/MessageHeaders.java | 24 ++- .../optf/cmso/CMSEnvironmentPostProcessor.java | 61 ------ .../optf/cmso/CmsoEnvironmentPostProcessor.java | 61 ++++++ .../org/onap/optf/cmso/common/CMSRequestError.java | 79 ------- .../onap/optf/cmso/common/CmsoRequestError.java | 79 +++++++ .../optf/cmso/common/exceptions/CMSException.java | 81 ------- .../optf/cmso/common/exceptions/CmsoException.java | 81 +++++++ .../ticketmgt/CMSEnvironmentPostProcessor.java | 61 ------ .../ticketmgt/CmsoEnvironmentPostProcessor.java | 61 ++++++ .../onap/optf/ticketmgt/JerseyConfiguration.java | 4 +- .../optf/ticketmgt/aaf/AafAuthorizationFilter.java | 4 +- .../org/onap/optf/ticketmgt/aaf/AafFilter.java | 4 +- .../onap/optf/ticketmgt/aaf/ResponseFormatter.java | 4 +- .../optf/ticketmgt/filters/CMSOClientFilters.java | 84 -------- .../ticketmgt/filters/CMSOContainerFilters.java | 139 ------------ .../optf/ticketmgt/filters/CmsoClientFilters.java | 84 ++++++++ .../ticketmgt/filters/CmsoContainerFilters.java | 139 ++++++++++++ .../service/rs/AvailabilityInterface.java | 8 +- .../ticketmgt/service/rs/TicketManagement.java | 14 +- .../java/org/onap/observations/MessageHeaders.java | 24 ++- .../topology/filters/CmsoContainerFilters.java | 6 +- 117 files changed, 3215 insertions(+), 3332 deletions(-) delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/CMSEnvironmentPostProcessor.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/CMSQuartzConfiguration.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/CmsoEnvironmentPostProcessor.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/CmsoQuartzConfiguration.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/common/CMSRequestError.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/common/CMSStatusEnum.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/common/CmsoRequestError.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/common/CmsoStatusEnum.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CMSAlreadyExistsException.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CMSException.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CMSNotFoundException.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CmsoAlreadyExistsException.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CmsoException.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CmsoNotFoundException.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CMSOClient.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CmsoClient.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/eventq/CMSQueueJob.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/eventq/CmsoQueueJob.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ApprovalTypeDAO.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ApprovalTypeDao.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementChangeWindowDAO.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementChangeWindowDao.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDAO.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDAOImpl.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDao.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDaoImpl.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementGroupDAO.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementGroupDao.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementScheduleDAO.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementScheduleDao.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/model/dao/DomainDataDAO.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/model/dao/DomainDataDao.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ElementDataDAO.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ElementDataDao.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleApprovalDAO.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleApprovalDao.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleDAO.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleDao.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDAO.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDAOImpl.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDao.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDaoImpl.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMOptimizerRequest.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMOptimizerResponse.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMRequestInfo.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMSchedule.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMSchedulingInfo.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMVnfDetails.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoOptimizerRequest.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoOptimizerResponse.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoRequestInfo.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoSchedule.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoSchedulingInfo.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoVnfDetails.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/CMSInfo.java delete mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/CMSMessage.java delete mode 100644 cmso-ticketmgt/src/main/java/org/onap/optf/cmso/CMSEnvironmentPostProcessor.java create mode 100644 cmso-ticketmgt/src/main/java/org/onap/optf/cmso/CmsoEnvironmentPostProcessor.java delete mode 100644 cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/CMSRequestError.java create mode 100644 cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/CmsoRequestError.java delete mode 100644 cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/exceptions/CMSException.java create mode 100644 cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/exceptions/CmsoException.java delete mode 100644 cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/CMSEnvironmentPostProcessor.java create mode 100644 cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/CmsoEnvironmentPostProcessor.java delete mode 100644 cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/filters/CMSOClientFilters.java delete mode 100644 cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/filters/CMSOContainerFilters.java create mode 100644 cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/filters/CmsoClientFilters.java create mode 100644 cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/filters/CmsoContainerFilters.java diff --git a/cmso-database/src/main/java/org/onap/optf/cmso/liquibase/LiquibaseData.java b/cmso-database/src/main/java/org/onap/optf/cmso/liquibase/LiquibaseData.java index 842c70c..58a2850 100644 --- a/cmso-database/src/main/java/org/onap/optf/cmso/liquibase/LiquibaseData.java +++ b/cmso-database/src/main/java/org/onap/optf/cmso/liquibase/LiquibaseData.java @@ -1,44 +1,30 @@ /* - * 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 + * ============LICENSE_START======================================================================================= + * Copyright (c) 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. -*/ + * ============LICENSE_END========================================================================================= + * + */ package org.onap.optf.cmso.liquibase; import javax.sql.DataSource; +import liquibase.integration.spring.SpringLiquibase; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.stereotype.Component; -import liquibase.integration.spring.SpringLiquibase; /* * Make sure following exceptions before build: @@ -60,6 +46,11 @@ public class LiquibaseData { @Value("${changeLogFile}") private String changeLogFile; + /** + * Liquibase. + * + * @return the spring liquibase + */ @Bean public SpringLiquibase liquibase() { SpringLiquibase liquibase = new SpringLiquibase(); diff --git a/cmso-optimizer/src/main/docker/extra-files/startService.sh b/cmso-optimizer/src/main/docker/extra-files/startService.sh index 6efd912..0549dfd 100644 --- a/cmso-optimizer/src/main/docker/extra-files/startService.sh +++ b/cmso-optimizer/src/main/docker/extra-files/startService.sh @@ -1,11 +1,28 @@ #!/bin/sh AUTHENTICATION=${AUTHENTICATION:-proprietary-auth} -JAVA_TRUSTSTORE=${JAVA_TRUSTSTORE:-etc/config/truststoreONAPall.jks} VM_ARGS="${VM_ARGS} -Dserver.local.startpath=${RESOURCES_HOME}" -VM_ARGS="${VM_ARGS} -Djavax.net.ssl.trustStore==${JAVA_TRUSTSTORE}" +if [ "${JAVA_TRUSTSTORE}" != ''] +then + VM_ARGS="${VM_ARGS} -Djavax.net.ssl.trustStore=${JAVA_TRUSTSTORE}" +fi + +if [ "${JAVA_TRUSTSTORE_PASSWORD}" != ''] +then + VM_ARGS="${VM_ARGS} -Djavax.net.ssl.trustStorePassword=${JAVA_TRUSTSTORE_PASSWORD}" +fi + +if [ "${SSL_KEYSTORE}" != '' ] +then + VM_ARGS="${VM_ARGS} -Dserver.ssl.key-store=${SSL_KEYSTORE}" +fi + +if [ "${SSL_KEYSTORE_PASSWORD}" != '' ] +then + VM_ARGS="${VM_ARGS} -Dserver.ssl.key-password=${SSL_KEYSTORE_PASSWORD}" +fi echo "VM_ARGS="${VM_ARGS} diff --git a/cmso-optimizer/src/main/java/org/onap/observations/MessageHeaders.java b/cmso-optimizer/src/main/java/org/onap/observations/MessageHeaders.java index fe6cea2..ccb7e56 100644 --- a/cmso-optimizer/src/main/java/org/onap/observations/MessageHeaders.java +++ b/cmso-optimizer/src/main/java/org/onap/observations/MessageHeaders.java @@ -65,7 +65,7 @@ public class MessageHeaders { } /** The Constant supportedMajorVersions. */ - public static final Map supportedMajorVersions = new HashMap(); + private static final Map supportedMajorVersions = new HashMap(); static { supportedMajorVersions.put("v1", "0"); @@ -73,7 +73,7 @@ public class MessageHeaders { } /** The Constant supportedMajorMinorVersions. */ - public static final Set supportedMajorMinorVersions = new HashSet(); + private static final Set supportedMajorMinorVersions = new HashSet(); static { supportedMajorMinorVersions.add("v1.0"); @@ -81,10 +81,10 @@ public class MessageHeaders { } /** The Constant latestVersion. */ - public static final String latestVersion = "2.0.0"; + private static final String latestVersion = "2.0.0"; /** The Constant patchVersion. */ - public static final String patchVersion = "0"; + private static final String patchVersion = "0"; /** * From string. @@ -152,4 +152,20 @@ public class MessageHeaders { } return true; } + + public static Map getSupportedmajorversions() { + return supportedMajorVersions; + } + + public static Set getSupportedmajorminorversions() { + return supportedMajorMinorVersions; + } + + public static String getLatestversion() { + return latestVersion; + } + + public static String getPatchversion() { + return patchVersion; + } } diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/OptimizerClient.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/OptimizerClient.java index 7c6db2a..b42ff9c 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/OptimizerClient.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/OptimizerClient.java @@ -230,7 +230,7 @@ public class OptimizerClient { apiResponse.setErrorMessage(LogMessages.UNEXPECTED_EXCEPTION.format(e.getMessage())); Observation.report(LogMessages.UNEXPECTED_RESPONSE, e, e.getMessage()); } finally { - if (process.isAlive()) { + if (process != null && process.isAlive()) { process.destroyForcibly(); } if (workingFolder.exists()) { diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/OptimizerRequestManager.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/OptimizerRequestManager.java index 6724551..cfe23ba 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/OptimizerRequestManager.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/OptimizerRequestManager.java @@ -76,7 +76,7 @@ public class OptimizerRequestManager { */ public OptimizerEngineResponse createOptimizerRequest(Request requestRow) { // - if (okToDispatch()) { + if (okToDispatch(false)) { Optimizer optimizer = getExistingOptmizer(requestRow.getUuid()); if (optimizer == null) { optimizer = new Optimizer(); @@ -146,11 +146,14 @@ public class OptimizerRequestManager { - private boolean okToDispatch() { - // TODO Auto-generated method stub - - // Will probably change to @Async on makeRequest to queue requests in a different thread. - return true; + private boolean okToDispatch(boolean checkDispatchability) { + if (checkDispatchability) { + // not yet implemented + return false; + } + else { + return true; + } } diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/topology/TopologyClient.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/topology/TopologyClient.java index c333651..ca6bdb3 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/topology/TopologyClient.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/topology/TopologyClient.java @@ -21,7 +21,6 @@ package org.onap.optf.cmso.optimizer.clients.topology; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; -import com.att.eelf.i18n.EELFResourceManager; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import java.util.ArrayList; @@ -102,6 +101,7 @@ public class TopologyClient { topologyResponse.setStatus(TopologyRequestStatus.FAILED); topologyResponse.setErrorMessage(LogMessages.UNEXPECTED_EXCEPTION.format(e.getMessage())); Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + return topologyResponse; } topologyRequest = new TopologyRequest(); topologyRequest.setRequestId(optimizerRequest.getRequestId()); diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/filters/CmsoContainerFilters.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/filters/CmsoContainerFilters.java index e8fe5f0..3a13805 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/filters/CmsoContainerFilters.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/filters/CmsoContainerFilters.java @@ -68,8 +68,8 @@ public class CmsoContainerFilters implements ContainerRequestFilter, ContainerRe MultivaluedMap respHeaders = responseContext.getHeaders(); String minorVersion = reqHeaders.getFirst(HeadersEnum.MinorVersion.toString()); respHeaders.add(HeadersEnum.MinorVersion.toString(), minorVersion); - respHeaders.add(HeadersEnum.LatestVersion.toString(), MessageHeaders.latestVersion); - respHeaders.add(HeadersEnum.PatchVersion.toString(), MessageHeaders.patchVersion); + respHeaders.add(HeadersEnum.LatestVersion.toString(), MessageHeaders.getLatestversion()); + respHeaders.add(HeadersEnum.PatchVersion.toString(), MessageHeaders.getPatchversion()); } catch (Exception e) { if (e instanceof WebApplicationException) { @@ -110,7 +110,7 @@ public class CmsoContainerFilters implements ContainerRequestFilter, ContainerRe } String minorVersion = headers.getFirst(HeadersEnum.MinorVersion.toString()); if (minorVersion == null) { - minorVersion = MessageHeaders.supportedMajorVersions.get(majorVersion); + minorVersion = MessageHeaders.getSupportedmajorversions().get(majorVersion); headers.add(HeadersEnum.MinorVersion.toString(), minorVersion); } if (!MessageHeaders.validateMajorMinorVersion(majorVersion, minorVersion)) { diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/ChangeWindow.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/ChangeWindow.java index 0e8b758..bec1de7 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/ChangeWindow.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/ChangeWindow.java @@ -107,7 +107,7 @@ public class ChangeWindow implements Serializable { return true; } // end is before start or start is before end, cannot overlap - if (endstart == -1 || startend == 1) { + if (endstart < 0 || startend > 0) { return false; } return true; diff --git a/cmso-optimizer/src/test/java/org/onap/optf/cmso/AuthProviderTest.java b/cmso-optimizer/src/test/java/org/onap/optf/cmso/AuthProviderTest.java index d2852d2..112b3a1 100644 --- a/cmso-optimizer/src/test/java/org/onap/optf/cmso/AuthProviderTest.java +++ b/cmso-optimizer/src/test/java/org/onap/optf/cmso/AuthProviderTest.java @@ -36,6 +36,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; + import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.runners.MockitoJUnitRunner; diff --git a/cmso-optimizer/src/test/java/org/onap/optf/cmso/optimizer/availability/policies/PolicyManagerTest.java b/cmso-optimizer/src/test/java/org/onap/optf/cmso/optimizer/availability/policies/PolicyManagerTest.java index 817c8de..50c9969 100644 --- a/cmso-optimizer/src/test/java/org/onap/optf/cmso/optimizer/availability/policies/PolicyManagerTest.java +++ b/cmso-optimizer/src/test/java/org/onap/optf/cmso/optimizer/availability/policies/PolicyManagerTest.java @@ -50,7 +50,6 @@ public class PolicyManagerTest { @Test public void getPolicyByName() { - String policyName = "Weekday_00_06"; String result = "CMSO.Weekday_00_06,CMSO.Weekday_00_06,CMSO.Weekday_00_06,CMSO.Weekday_00_06,"; List policies = policyManager.getSupportedPolicies(); @@ -60,6 +59,7 @@ public class PolicyManagerTest { } System.out.println(" String result = \"" + sb.toString() + "\";"); Assert.assertTrue(result.equals(sb.toString())); + String policyName = "Weekday_00_06"; Policy policy = policyManager.getPolicyForName(policyName); Assert.assertTrue(policy != null); TimeLimitAndVerticalTopology top = policyManager.getTimeLimitAndVerticalTopologyByName(policyName); diff --git a/cmso-optimizer/src/test/java/org/onap/optf/cmso/service/rs/MockHttpServletRequest.java b/cmso-optimizer/src/test/java/org/onap/optf/cmso/service/rs/MockHttpServletRequest.java index f7d0939..84dbf54 100644 --- a/cmso-optimizer/src/test/java/org/onap/optf/cmso/service/rs/MockHttpServletRequest.java +++ b/cmso-optimizer/src/test/java/org/onap/optf/cmso/service/rs/MockHttpServletRequest.java @@ -3,24 +3,25 @@ * Copyright (c) 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 + * 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 + * + * 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.service.rs; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; + import javax.servlet.http.HttpServletRequest; public class MockHttpServletRequest { diff --git a/cmso-service/etc/config/cmso.properties b/cmso-service/etc/config/cmso.properties index e9bec86..c28783a 100644 --- a/cmso-service/etc/config/cmso.properties +++ b/cmso-service/etc/config/cmso.properties @@ -44,7 +44,7 @@ spring.datasource.tomcat.initialSize=5 spring.datasource.tomcat.max-active=25 spring.datasource.tomcat.test-on-borrow=true -spring.jpa.show-sql=true +spring.jpa.show-sql=false spring.jpa.hibernate.ddl-auto=none spring.jpa.hibernate.naming.strategy=org.hibernate.cfg.EJB3NamingStrategy spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/CMSEnvironmentPostProcessor.java b/cmso-service/src/main/java/org/onap/optf/cmso/CMSEnvironmentPostProcessor.java deleted file mode 100644 index d77886e..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/CMSEnvironmentPostProcessor.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================================= - * Copyright (c) 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. - * ============LICENSE_END========================================================================================= - * - ******************************************************************************/ - -package org.onap.optf.cmso; - -import java.util.HashMap; -import java.util.Map; -import org.onap.optf.cmso.common.PropertiesManagement; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.env.EnvironmentPostProcessor; -import org.springframework.core.env.ConfigurableEnvironment; -import org.springframework.core.env.MapPropertySource; -import org.springframework.core.env.MutablePropertySources; - -public class CMSEnvironmentPostProcessor implements EnvironmentPostProcessor { - // TODO tested in ONAP springboot and this is called before all of the properties files have been - // loaded... - // perhaps there is a post post processor? Until this works. DB password will be in the clear in the - // proeprties files. - @Override - public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { - String pwd = environment.getProperty("cmso.database.password"); - if (pwd != null) { - pwd = PropertiesManagement.getDecryptedValue(pwd); - Map map = new HashMap<>(); - map.put("spring.datasource.password", pwd); - MapPropertySource propertySource = new MapPropertySource("abc", map); - MutablePropertySources proeprtySources = environment.getPropertySources(); - proeprtySources.addLast(propertySource); - } - } - -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/CMSQuartzConfiguration.java b/cmso-service/src/main/java/org/onap/optf/cmso/CMSQuartzConfiguration.java deleted file mode 100644 index 6a8b0ca..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/CMSQuartzConfiguration.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso; - -import org.onap.optf.cmso.eventq.CmQuartzJob; -import org.onap.optf.cmso.optimizer.OptimizerQuartzJob; -import org.onap.optf.cmso.sostatus.ScheduleStatusJob; -import org.quartz.spi.JobFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.env.Environment; -import org.springframework.scheduling.quartz.JobDetailFactoryBean; -import org.springframework.scheduling.quartz.SchedulerFactoryBean; -import org.springframework.scheduling.quartz.SimpleTriggerFactoryBean; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -@Configuration -@ComponentScan({"org.onap.optf.cmso"}) -@EnableTransactionManagement -public class CMSQuartzConfiguration { - - @Autowired - Environment env; - - /** - * Eventq trigger factory bean. - * - * @return the simple trigger factory bean - */ - @Bean - public SimpleTriggerFactoryBean eventqTriggerFactoryBean() { - - Integer interval = env.getProperty("cmso.cm.polling.job.interval.ms", Integer.class, 60000); - SimpleTriggerFactoryBean stFactory = new SimpleTriggerFactoryBean(); - stFactory.setJobDetail(eventqDetailFactoryBean().getObject()); - stFactory.setStartDelay(3000); - stFactory.setRepeatInterval(interval); - // Indefinitely - return stFactory; - } - - /** - * Eventq detail factory bean. - * - * @return the job detail factory bean - */ - @Bean - public JobDetailFactoryBean eventqDetailFactoryBean() { - JobDetailFactoryBean factory = new JobDetailFactoryBean(); - factory.setJobClass(CmQuartzJob.class); - return factory; - } - - /** - * Status trigger factory bean. - * - * @return the simple trigger factory bean - */ - @Bean - public SimpleTriggerFactoryBean statusTriggerFactoryBean() { - - Integer interval = env.getProperty("cmso.status.job.interval.ms", Integer.class, 60000); - SimpleTriggerFactoryBean stFactory = new SimpleTriggerFactoryBean(); - stFactory.setJobDetail(statusDetailFactoryBean().getObject()); - stFactory.setStartDelay(3000); - stFactory.setRepeatInterval(interval); - // Indefinitely - return stFactory; - } - - /** - * Status detail factory bean. - * - * @return the job detail factory bean - */ - @Bean - public JobDetailFactoryBean statusDetailFactoryBean() { - JobDetailFactoryBean factory = new JobDetailFactoryBean(); - factory.setJobClass(ScheduleStatusJob.class); - return factory; - } - - /** - * Optimizer trigger factory bean. - * - * @return the simple trigger factory bean - */ - @Bean - public SimpleTriggerFactoryBean optimizerTriggerFactoryBean() { - - Integer interval = env.getProperty("cmso.optimizer.job.interval.ms", Integer.class, 60000); - SimpleTriggerFactoryBean stFactory = new SimpleTriggerFactoryBean(); - stFactory.setJobDetail(optimizerDetailFactoryBean().getObject()); - stFactory.setStartDelay(3000); - stFactory.setRepeatInterval(interval); - // Indefinitely - return stFactory; - } - - /** - * Optimizer detail factory bean. - * - * @return the job detail factory bean - */ - @Bean - public JobDetailFactoryBean optimizerDetailFactoryBean() { - JobDetailFactoryBean factory = new JobDetailFactoryBean(); - factory.setJobClass(OptimizerQuartzJob.class); - return factory; - } - - /** - * Job factory. - * - * @param applicationContext the application context - * @return the job factory - */ - @Bean - public JobFactory jobFactory(ApplicationContext applicationContext) { - AutowiringSpringBeanJobFactory jobFactory = new AutowiringSpringBeanJobFactory(); - jobFactory.setApplicationContext(applicationContext); - return jobFactory; - } - - /** - * Cmso factory bean. - * - * @param jobFactory the job factory - * @return the scheduler factory bean - */ - @Bean - public SchedulerFactoryBean cmsoFactoryBean(JobFactory jobFactory) { - SchedulerFactoryBean cmso = new SchedulerFactoryBean(); - cmso.setJobFactory(jobFactory); - cmso.setTriggers(eventqTriggerFactoryBean().getObject(), optimizerTriggerFactoryBean().getObject(), - statusTriggerFactoryBean().getObject()); - return cmso; - } -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/CmsoEnvironmentPostProcessor.java b/cmso-service/src/main/java/org/onap/optf/cmso/CmsoEnvironmentPostProcessor.java new file mode 100644 index 0000000..c26abec --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/CmsoEnvironmentPostProcessor.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================================= + * Copyright (c) 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. + * ============LICENSE_END========================================================================================= + * + ******************************************************************************/ + +package org.onap.optf.cmso; + +import java.util.HashMap; +import java.util.Map; +import org.onap.optf.cmso.common.PropertiesManagement; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.env.EnvironmentPostProcessor; +import org.springframework.core.env.ConfigurableEnvironment; +import org.springframework.core.env.MapPropertySource; +import org.springframework.core.env.MutablePropertySources; + +public class CmsoEnvironmentPostProcessor implements EnvironmentPostProcessor { + // TODO tested in ONAP springboot and this is called before all of the properties files have been + // loaded... + // perhaps there is a post post processor? Until this works. DB password will be in the clear in the + // proeprties files. + @Override + public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { + String pwd = environment.getProperty("cmso.database.password"); + if (pwd != null) { + pwd = PropertiesManagement.getDecryptedValue(pwd); + Map map = new HashMap<>(); + map.put("spring.datasource.password", pwd); + MapPropertySource propertySource = new MapPropertySource("abc", map); + MutablePropertySources proeprtySources = environment.getPropertySources(); + proeprtySources.addLast(propertySource); + } + } + +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/CmsoQuartzConfiguration.java b/cmso-service/src/main/java/org/onap/optf/cmso/CmsoQuartzConfiguration.java new file mode 100644 index 0000000..e0cbeea --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/CmsoQuartzConfiguration.java @@ -0,0 +1,171 @@ +/* + * 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. +*/ + +package org.onap.optf.cmso; + +import org.onap.optf.cmso.eventq.CmQuartzJob; +import org.onap.optf.cmso.optimizer.OptimizerQuartzJob; +import org.onap.optf.cmso.sostatus.ScheduleStatusJob; +import org.quartz.spi.JobFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.env.Environment; +import org.springframework.scheduling.quartz.JobDetailFactoryBean; +import org.springframework.scheduling.quartz.SchedulerFactoryBean; +import org.springframework.scheduling.quartz.SimpleTriggerFactoryBean; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +@Configuration +@ComponentScan({"org.onap.optf.cmso"}) +@EnableTransactionManagement +public class CmsoQuartzConfiguration { + + @Autowired + Environment env; + + /** + * Eventq trigger factory bean. + * + * @return the simple trigger factory bean + */ + @Bean + public SimpleTriggerFactoryBean eventqTriggerFactoryBean() { + + Integer interval = env.getProperty("cmso.cm.polling.job.interval.ms", Integer.class, 60000); + SimpleTriggerFactoryBean stFactory = new SimpleTriggerFactoryBean(); + stFactory.setJobDetail(eventqDetailFactoryBean().getObject()); + stFactory.setStartDelay(3000); + stFactory.setRepeatInterval(interval); + // Indefinitely + return stFactory; + } + + /** + * Eventq detail factory bean. + * + * @return the job detail factory bean + */ + @Bean + public JobDetailFactoryBean eventqDetailFactoryBean() { + JobDetailFactoryBean factory = new JobDetailFactoryBean(); + factory.setJobClass(CmQuartzJob.class); + return factory; + } + + /** + * Status trigger factory bean. + * + * @return the simple trigger factory bean + */ + @Bean + public SimpleTriggerFactoryBean statusTriggerFactoryBean() { + + Integer interval = env.getProperty("cmso.status.job.interval.ms", Integer.class, 60000); + SimpleTriggerFactoryBean stFactory = new SimpleTriggerFactoryBean(); + stFactory.setJobDetail(statusDetailFactoryBean().getObject()); + stFactory.setStartDelay(3000); + stFactory.setRepeatInterval(interval); + // Indefinitely + return stFactory; + } + + /** + * Status detail factory bean. + * + * @return the job detail factory bean + */ + @Bean + public JobDetailFactoryBean statusDetailFactoryBean() { + JobDetailFactoryBean factory = new JobDetailFactoryBean(); + factory.setJobClass(ScheduleStatusJob.class); + return factory; + } + + /** + * Optimizer trigger factory bean. + * + * @return the simple trigger factory bean + */ + @Bean + public SimpleTriggerFactoryBean optimizerTriggerFactoryBean() { + + Integer interval = env.getProperty("cmso.optimizer.job.interval.ms", Integer.class, 60000); + SimpleTriggerFactoryBean stFactory = new SimpleTriggerFactoryBean(); + stFactory.setJobDetail(optimizerDetailFactoryBean().getObject()); + stFactory.setStartDelay(3000); + stFactory.setRepeatInterval(interval); + // Indefinitely + return stFactory; + } + + /** + * Optimizer detail factory bean. + * + * @return the job detail factory bean + */ + @Bean + public JobDetailFactoryBean optimizerDetailFactoryBean() { + JobDetailFactoryBean factory = new JobDetailFactoryBean(); + factory.setJobClass(OptimizerQuartzJob.class); + return factory; + } + + /** + * Job factory. + * + * @param applicationContext the application context + * @return the job factory + */ + @Bean + public JobFactory jobFactory(ApplicationContext applicationContext) { + AutowiringSpringBeanJobFactory jobFactory = new AutowiringSpringBeanJobFactory(); + jobFactory.setApplicationContext(applicationContext); + return jobFactory; + } + + /** + * Cmso factory bean. + * + * @param jobFactory the job factory + * @return the scheduler factory bean + */ + @Bean + public SchedulerFactoryBean cmsoFactoryBean(JobFactory jobFactory) { + SchedulerFactoryBean cmso = new SchedulerFactoryBean(); + cmso.setJobFactory(jobFactory); + cmso.setTriggers(eventqTriggerFactoryBean().getObject(), optimizerTriggerFactoryBean().getObject(), + statusTriggerFactoryBean().getObject()); + return cmso; + } +} 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 index e632a6d..ac4b726 100644 --- 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 @@ -41,7 +41,7 @@ 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.onap.optf.cmso.common.exceptions.CmsoException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter; import org.springframework.context.annotation.Profile; @@ -78,7 +78,7 @@ public class AafAuthorizationFilter extends OrderedRequestContextFilter { filterChain.doFilter(request, response); } else { Observation.report(LogMessages.UNAUTHORIZED); - ResponseFormatter.errorResponse(request, response, new CMSException( + ResponseFormatter.errorResponse(request, response, new CmsoException( LogMessages.UNAUTHORIZED.getStatus(), LogMessages.UNAUTHORIZED, "")); } } else { @@ -87,7 +87,7 @@ public class AafAuthorizationFilter extends OrderedRequestContextFilter { } catch (Exception e) { Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); ResponseFormatter.errorResponse(request, response, - new CMSException(LogMessages.UNAUTHORIZED.getStatus(), LogMessages.UNAUTHORIZED, "")); + new CmsoException(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 index 586822f..5a93481 100644 --- 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 @@ -42,7 +42,7 @@ 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.onap.optf.cmso.common.exceptions.CmsoException; import org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; @@ -77,7 +77,8 @@ public class AafFilter extends OrderedRequestContextFilter { if (response.getStatus() == 401) { Observation.report(LogMessages.UNAUTHENTICATED); ResponseFormatter.errorResponse(request, response, - new CMSException(LogMessages.UNAUTHENTICATED.getStatus(), LogMessages.UNAUTHENTICATED, "")); + new CmsoException(LogMessages.UNAUTHENTICATED.getStatus(), + LogMessages.UNAUTHENTICATED, "")); } } 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 index e7ddcdf..b9c287f 100644 --- 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 @@ -33,12 +33,12 @@ package org.onap.optf.cmso.aaf; import java.io.IOException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.onap.optf.cmso.common.exceptions.CMSException; +import org.onap.optf.cmso.common.exceptions.CmsoException; class ResponseFormatter { - static void errorResponse(HttpServletRequest request, HttpServletResponse response, CMSException error) + static void errorResponse(HttpServletRequest request, HttpServletResponse response, CmsoException error) throws IOException { response.setStatus(error.getStatus().getStatusCode()); response.getWriter().write(error.getRequestError().toString()); diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/common/CMSRequestError.java b/cmso-service/src/main/java/org/onap/optf/cmso/common/CMSRequestError.java deleted file mode 100644 index ec3804a..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/common/CMSRequestError.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso.common; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -public class CMSRequestError implements Serializable { - private static final long serialVersionUID = 1L; - private static EELFLogger log = EELFManager.getInstance().getLogger(CMSRequestError.class); - @JsonProperty - RequestError requestError; - - public CMSRequestError(String messageId, String text, List variables) { - requestError = new RequestError(messageId, text, variables); - } - - public CMSRequestError(String messageId, String text) { - requestError = new RequestError(messageId, text, new ArrayList()); - } - - public class RequestError { - @JsonProperty - private String messageId; - @JsonProperty - private String text; - @JsonProperty - private List variables; - - private RequestError(String messageId, String text, List variables) { - this.messageId = "Scheduler." + messageId; - this.text = text; - this.variables = variables; - } - - @Override - public String toString() { - StringBuffer sb = new StringBuffer(); - sb.append(messageId).append(":").append(text).append(":").append(variables); - return sb.toString(); - - } - } - - @Override - public String toString() { - return requestError.toString(); - } -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/common/CMSStatusEnum.java b/cmso-service/src/main/java/org/onap/optf/cmso/common/CMSStatusEnum.java deleted file mode 100644 index d560f50..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/common/CMSStatusEnum.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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. - */ - -package org.onap.optf.cmso.common; - -/** - * The Enum CMSStatusEnum. - */ -public enum CMSStatusEnum { - PendingSchedule("Pending Schedule", - "Schedule request as been accepted. Pending determination of recommended schedule."), - SchedulingFailed("Scheduling Failed", "Failed to determine recommended schedule."), - ScheduleFailed("Schedule Failed", "Determination of recommended schedule failed."), - OptimizationInProgress("Optimization In Progress", "Determination of recommended schedule is in progress."), - PendingApproval("Pending Approval", "Pending approval of the recommended schedule."), - OptimizationFailed("Optimization Failed", "Unable to determine recommended schedule."), - Accepted("Accepted", "Recommended schedule has been accepted."), - Scheduled("Scheduled", "All approvals received. Recommended schedule is pending execution."), - ScheduledImmediate("Scheduled Immediate", "All approvals received. Event is scheduled for immediate execution."), - Triggered("Triggered", "Scheduled event has been triggered."), - ApprovalRejected("Approval Rejected", "Recommended schedule has been rejected."), - PastDue("Past due", "Scheduled event time has passed. Queued event was not dispatched."), - Error("Error", "Attempt to displatch event failed."), - Failed("Failed", "Triggered event reported a failure."), - Rejected("Rejected", "Recommended schedule has been rejected."), - NotificationsInitiated("Notifications Initiated", "Notifications of scheduled events has been initiated."), - Completed("Completed", "Notification of all scheduled events have been sent."), - CompletedWithError("Completed with error(s)", "All scheduled events have completed, some with errors."), - Deleted("Deleted", "Schedule deleted prior to acceptance or after execution."), - Cancelled("Cancelled", "Scheduled event cancelled before execution."), - NotScheduled("Not scheduled by optimizer", "Element not included in the schedule by optimizer."),; - - private final String text; - private final String description; - - private CMSStatusEnum(String text, String description) { - this.text = text; - this.description = description; - } - - /** - * To string. - * - * @return the string - */ - @Override - public String toString() { - return text; - } - - /** - * From string. - * - * @param text the text - * @return the CMS status enum - */ - public CMSStatusEnum fromString(String text) { - for (CMSStatusEnum e : CMSStatusEnum.values()) { - if (e.text.equals(text)) { - return e; - } - } - return null; - } - - /** - * The main method. - * - * @param argv the arguments - */ - // To include in the AID. - public static void main(String[] argv) { - StringBuilder sb = new StringBuilder(); - sb.append("\n"); - for (CMSStatusEnum v : CMSStatusEnum.values()) { - sb.append("\n"); - } - sb.append("
").append(v.text).append("").append(v.description) - .append("
\n"); - System.out.println(sb.toString()); - } -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/common/CmsoRequestError.java b/cmso-service/src/main/java/org/onap/optf/cmso/common/CmsoRequestError.java new file mode 100644 index 0000000..403178b --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/common/CmsoRequestError.java @@ -0,0 +1,82 @@ +/* + * 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. +*/ + +package org.onap.optf.cmso.common; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +public class CmsoRequestError implements Serializable { + private static final long serialVersionUID = 1L; + private static EELFLogger log = EELFManager.getInstance().getLogger(CmsoRequestError.class); + @JsonProperty + RequestError requestError; + + public CmsoRequestError(String messageId, String text, List variables) { + requestError = new RequestError(messageId, text, variables); + } + + public CmsoRequestError(String messageId, String text) { + requestError = new RequestError(messageId, text, new ArrayList()); + } + + public class RequestError { + @JsonProperty + private String messageId; + @JsonProperty + private String text; + @JsonProperty + private List variables; + + private RequestError(String messageId, String text, List variables) { + this.messageId = "Scheduler." + messageId; + this.text = text; + this.variables = variables; + } + + @Override + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append(messageId).append(":").append(text).append(":").append(variables); + return sb.toString(); + + } + } + + @Override + public String toString() { + return requestError.toString(); + } +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/common/CmsoStatusEnum.java b/cmso-service/src/main/java/org/onap/optf/cmso/common/CmsoStatusEnum.java new file mode 100644 index 0000000..135e1f1 --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/common/CmsoStatusEnum.java @@ -0,0 +1,110 @@ +/* + * 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. + */ + +package org.onap.optf.cmso.common; + +/** + * The Enum CMSStatusEnum. + */ +public enum CmsoStatusEnum { + PendingSchedule("Pending Schedule", + "Schedule request as been accepted. Pending determination of recommended schedule."), + SchedulingFailed("Scheduling Failed", "Failed to determine recommended schedule."), + ScheduleFailed("Schedule Failed", "Determination of recommended schedule failed."), + OptimizationInProgress("Optimization In Progress", "Determination of recommended schedule is in progress."), + PendingApproval("Pending Approval", "Pending approval of the recommended schedule."), + OptimizationFailed("Optimization Failed", "Unable to determine recommended schedule."), + Accepted("Accepted", "Recommended schedule has been accepted."), + Scheduled("Scheduled", "All approvals received. Recommended schedule is pending execution."), + ScheduledImmediate("Scheduled Immediate", "All approvals received. Event is scheduled for immediate execution."), + Triggered("Triggered", "Scheduled event has been triggered."), + ApprovalRejected("Approval Rejected", "Recommended schedule has been rejected."), + PastDue("Past due", "Scheduled event time has passed. Queued event was not dispatched."), + Error("Error", "Attempt to displatch event failed."), + Failed("Failed", "Triggered event reported a failure."), + Rejected("Rejected", "Recommended schedule has been rejected."), + NotificationsInitiated("Notifications Initiated", "Notifications of scheduled events has been initiated."), + Completed("Completed", "Notification of all scheduled events have been sent."), + CompletedWithError("Completed with error(s)", "All scheduled events have completed, some with errors."), + Deleted("Deleted", "Schedule deleted prior to acceptance or after execution."), + Cancelled("Cancelled", "Scheduled event cancelled before execution."), + NotScheduled("Not scheduled by optimizer", "Element not included in the schedule by optimizer."),; + + private final String text; + private final String description; + + private CmsoStatusEnum(String text, String description) { + this.text = text; + this.description = description; + } + + /** + * To string. + * + * @return the string + */ + @Override + public String toString() { + return text; + } + + /** + * From string. + * + * @param text the text + * @return the CMS status enum + */ + public CmsoStatusEnum fromString(String text) { + for (CmsoStatusEnum e : CmsoStatusEnum.values()) { + if (e.text.equals(text)) { + return e; + } + } + return null; + } + + /** + * The main method. + * + * @param argv the arguments + */ + // To include in the AID. + public static void main(String[] argv) { + StringBuilder sb = new StringBuilder(); + sb.append("\n"); + for (CmsoStatusEnum v : CmsoStatusEnum.values()) { + sb.append("\n"); + } + sb.append("
").append(v.text).append("").append(v.description) + .append("
\n"); + System.out.println(sb.toString()); + } +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CMSAlreadyExistsException.java b/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CMSAlreadyExistsException.java deleted file mode 100644 index d461e4f..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CMSAlreadyExistsException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso.common.exceptions; - -import javax.ws.rs.core.Response.Status; -import org.onap.optf.cmso.common.LogMessages; - -public class CMSAlreadyExistsException extends CMSException { - private static final long serialVersionUID = 1L; - - public CMSAlreadyExistsException(String... args) { - super(Status.CONFLICT, LogMessages.SCHEDULE_ALREADY_EXISTS, args); - } -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CMSException.java b/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CMSException.java deleted file mode 100644 index d59177f..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CMSException.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso.common.exceptions; - -import com.att.eelf.i18n.EELFResourceManager; -import java.util.ArrayList; -import java.util.List; -import javax.ws.rs.core.Response.Status; -import org.onap.optf.cmso.common.CMSRequestError; -import org.onap.optf.cmso.common.LogMessages; - -public class CMSException extends Exception { - private static final long serialVersionUID = 1L; - - protected CMSRequestError requestError = null; - private List variables = new ArrayList(); - protected LogMessages messageCode; - protected Status status; - - /** - * Instantiates a new CMS exception. - * - * @param status the status - * @param messageCode the message code - * @param args the args - */ - public CMSException(Status status, LogMessages messageCode, String... args) { - super(EELFResourceManager.format(messageCode, args)); - this.status = status; - this.messageCode = messageCode; - for (String arg : args) { - variables.add(arg); - } - requestError = new CMSRequestError(messageCode.name(), getMessage(), variables); - } - - public Status getStatus() { - return status; - } - - public LogMessages getMessageCode() { - return messageCode; - } - - public String[] getVariables() { - return variables.toArray(new String[variables.size()]); - } - - public CMSRequestError getRequestError() { - return requestError; - } -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CMSNotFoundException.java b/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CMSNotFoundException.java deleted file mode 100644 index 2a46e21..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CMSNotFoundException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso.common.exceptions; - -import javax.ws.rs.core.Response.Status; -import org.onap.optf.cmso.common.LogMessages; - -public class CMSNotFoundException extends CMSException { - private static final long serialVersionUID = 1L; - - public CMSNotFoundException(String... args) { - super(Status.NOT_FOUND, LogMessages.SCHEDULE_NOT_FOUND, args); - } - -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CmsoAlreadyExistsException.java b/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CmsoAlreadyExistsException.java new file mode 100644 index 0000000..f668a72 --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CmsoAlreadyExistsException.java @@ -0,0 +1,43 @@ +/* + * 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. +*/ + +package org.onap.optf.cmso.common.exceptions; + +import javax.ws.rs.core.Response.Status; +import org.onap.optf.cmso.common.LogMessages; + +public class CmsoAlreadyExistsException extends CmsoException { + private static final long serialVersionUID = 1L; + + public CmsoAlreadyExistsException(String... args) { + super(Status.CONFLICT, LogMessages.SCHEDULE_ALREADY_EXISTS, args); + } +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CmsoException.java b/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CmsoException.java new file mode 100644 index 0000000..b604b94 --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CmsoException.java @@ -0,0 +1,81 @@ +/* + * 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. +*/ + +package org.onap.optf.cmso.common.exceptions; + +import com.att.eelf.i18n.EELFResourceManager; +import java.util.ArrayList; +import java.util.List; +import javax.ws.rs.core.Response.Status; +import org.onap.optf.cmso.common.CmsoRequestError; +import org.onap.optf.cmso.common.LogMessages; + +public class CmsoException extends Exception { + private static final long serialVersionUID = 1L; + + protected CmsoRequestError requestError = null; + private List variables = new ArrayList(); + protected LogMessages messageCode; + protected Status status; + + /** + * Instantiates a new CMS exception. + * + * @param status the status + * @param messageCode the message code + * @param args the args + */ + public CmsoException(Status status, LogMessages messageCode, String... args) { + super(EELFResourceManager.format(messageCode, args)); + this.status = status; + this.messageCode = messageCode; + for (String arg : args) { + variables.add(arg); + } + requestError = new CmsoRequestError(messageCode.name(), getMessage(), variables); + } + + public Status getStatus() { + return status; + } + + public LogMessages getMessageCode() { + return messageCode; + } + + public String[] getVariables() { + return variables.toArray(new String[variables.size()]); + } + + public CmsoRequestError getRequestError() { + return requestError; + } +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CmsoNotFoundException.java b/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CmsoNotFoundException.java new file mode 100644 index 0000000..39cb82f --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CmsoNotFoundException.java @@ -0,0 +1,44 @@ +/* + * 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. +*/ + +package org.onap.optf.cmso.common.exceptions; + +import javax.ws.rs.core.Response.Status; +import org.onap.optf.cmso.common.LogMessages; + +public class CmsoNotFoundException extends CmsoException { + private static final long serialVersionUID = 1L; + + public CmsoNotFoundException(String... args) { + super(Status.NOT_FOUND, LogMessages.SCHEDULE_NOT_FOUND, args); + } + +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CMSOClient.java b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CMSOClient.java deleted file mode 100644 index 2835b2f..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CMSOClient.java +++ /dev/null @@ -1,239 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso.dispatcher; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import javax.ws.rs.ProcessingException; -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.Entity; -import javax.ws.rs.client.Invocation; -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.optf.cmso.common.BasicAuthenticatorFilter; -import org.onap.optf.cmso.common.CMSStatusEnum; -import org.onap.optf.cmso.common.LogMessages; -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.ChangeManagementGroupDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO; -import org.onap.optf.cmso.model.dao.ScheduleDAO; -import org.onap.optf.cmso.ticketmgt.TmClient; -import org.onap.optf.cmso.wf.bean.WfChangeManagementResponse; -import org.onap.optf.cmso.wf.bean.WfVidCmResponse; -import org.quartz.SchedulerException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; - -@Component -public class CMSOClient { - private static EELFLogger log = EELFManager.getInstance().getLogger(CMSOClient.class); - private static EELFLogger metrics = EELFManager.getInstance().getMetricsLogger(); - private static EELFLogger errors = EELFManager.getInstance().getErrorLogger(); - private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); - - @Autowired - ChangeManagementScheduleDAO cmScheduleDao; - - @Autowired - ChangeManagementGroupDAO cmGroupDao; - - @Autowired - ScheduleDAO scheduleDao; - - - @Autowired - Environment env; - - @Autowired - PropertiesManagement pm; - - @Autowired - TmClient tmClient; - - /** - * Dispatch. - * - * @param cmSchedule the cm schedule - * @param schedule the schedule - */ - public void dispatch(ChangeManagementSchedule cmSchedule, Schedule schedule) { - try { - - String url = env.getProperty("so.url"); - if (!url.endsWith("/")) { - url += "/"; - } - url = url + "schedule/" + cmSchedule.getVnfName(); - String callbackData = cmSchedule.getRequest(); - String user = env.getProperty("so.user", ""); - String pass = pm.getProperty("so.pass", ""); - Client client = ClientBuilder.newClient(); - if (!user.equals("")) { - client.register(new BasicAuthenticatorFilter(user, pass)); - } - client.register(new CmsoClientFilters()); - WebTarget target = client.target(url); - ObjectMapper om = new ObjectMapper(); - JsonNode jsonEntity = om.readTree(callbackData); - Invocation.Builder invocationBuilder = target.request(MediaType.APPLICATION_JSON); - try { - Response response = invocationBuilder.post(Entity.json(jsonEntity)); - switch (response.getStatus()) { - case 201: { - debug.debug("Response status=" + response.getStatus()); - // Push the state up to the schedule. - processScheduleResponse(cmSchedule, schedule, response); - break; - } - case 200: { - debug.debug("Response status=" + response.getStatus()); - // Push the state up to the schedule. - processScheduleResponse200(cmSchedule, schedule, response); - break; - } - case 400: // Bad request - case 500: - default: { - errors.error(LogMessages.UNEXPECTED_RESPONSE.toString(), "VID", response.getStatus(), - response.toString()); - cmSchedule.setStatus(CMSStatusEnum.SchedulingFailed.toString()); - cmSchedule.setStatusMessage(response.toString()); - updateScheduleStatus(cmSchedule, schedule); - return; - } - } - } - // No sense in retrying. These are time sensitive actions - catch (ResponseProcessingException e) { - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - cmSchedule.setStatus(CMSStatusEnum.SchedulingFailed.toString()); - cmSchedule.setStatusMessage(e.toString()); - updateScheduleStatus(cmSchedule, schedule); - - } catch (ProcessingException e) { - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - cmSchedule.setStatus(CMSStatusEnum.SchedulingFailed.toString()); - cmSchedule.setStatusMessage(e.toString()); - updateScheduleStatus(cmSchedule, schedule); - } - } catch (Exception e) { - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - cmSchedule.setStatus(CMSStatusEnum.SchedulingFailed.toString()); - cmSchedule.setStatusMessage(e.toString()); - updateScheduleStatus(cmSchedule, schedule); - } - } - - private void processScheduleResponse(ChangeManagementSchedule cmSchedule, Schedule schedule, Response response) - throws SchedulerException { - WfChangeManagementResponse resp = response.readEntity(WfChangeManagementResponse.class); - for (WfVidCmResponse cmResponse : resp.getCmResponses()) { - if (cmResponse.getVnfName().equals(cmSchedule.getVnfName())) { - cmSchedule.setStatus(CMSStatusEnum.Triggered.toString()); - cmSchedule.setDispatchTimeMillis(System.currentTimeMillis()); - cmSchedule.setMsoRequestId(cmResponse.getOrchestratorRequestId()); - // Push the state up to the schedule. - updateTicket(cmSchedule, schedule); - updateScheduleStatus(cmSchedule, schedule); - return; - } - } - cmSchedule.setStatus(CMSStatusEnum.SchedulingFailed.toString()); - cmSchedule.setStatusMessage("Response did not contain vnfName=" + cmSchedule.getVnfName()); - updateScheduleStatus(cmSchedule, schedule); - } - - private void processScheduleResponse200(ChangeManagementSchedule cmSchedule, Schedule schedule, Response response) - throws SchedulerException { - - JsonNode node = response.readEntity(JsonNode.class); - log.info("Message returned from VID callback: " + node.toString()); - JsonNode status = node.get("status"); - Integer msoStatus = status.asInt(); - JsonNode entity = node.get("entity"); - if (msoStatus == 202) { - JsonNode rr = entity.get("requestReferences"); - if (rr != null) { - JsonNode requestId = rr.get("requestId"); - if (requestId != null) { - cmSchedule.setStatus(CMSStatusEnum.Triggered.toString()); - cmSchedule.setDispatchTimeMillis(System.currentTimeMillis()); - cmSchedule.setMsoRequestId(requestId.asText()); - // Push the state up to the schedule. - updateTicket(cmSchedule, schedule); - updateScheduleStatus(cmSchedule, schedule); - return; - } - } - } - cmSchedule.setStatus(CMSStatusEnum.SchedulingFailed.toString()); - cmSchedule.setStatusMessage(node.toString()); - updateScheduleStatus(cmSchedule, schedule); - } - - private void updateTicket(ChangeManagementSchedule cmSchedule, Schedule schedule) { - try { - String changeId = cmSchedule.getTmChangeId(); - if (changeId != null && !changeId.equals("")) { - tmClient.updateTicket(schedule, cmSchedule, changeId); - } - } catch (Exception e) { - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - } - } - - /** - * Update schedule status. - * - * @param cmSchedule the cm schedule - * @param schedule the schedule - */ - @Transactional - public void updateScheduleStatus(ChangeManagementSchedule cmSchedule, Schedule schedule) { - cmScheduleDao.save(cmSchedule); - if (schedule != null) { - scheduleDao.save(schedule); - } - - } -} 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 435f11a..192258e 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 @@ -47,9 +47,9 @@ import org.onap.optf.cmso.common.LogMessages; 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; +import org.onap.optf.cmso.model.dao.ChangeManagementGroupDao; +import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao; +import org.onap.optf.cmso.model.dao.ScheduleDao; import org.onap.optf.cmso.ticketmgt.TmClient; import org.quartz.DisallowConcurrentExecution; import org.quartz.Job; @@ -74,16 +74,16 @@ public class CmJob implements Job { private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); @Autowired - CMSOClient vidClient; + CmsoClient vidClient; @Autowired - ChangeManagementScheduleDAO cmScheduleDao; + ChangeManagementScheduleDao cmScheduleDao; @Autowired - ChangeManagementGroupDAO cmGroupDao; + ChangeManagementGroupDao cmGroupDao; @Autowired - ScheduleDAO scheduleDao; + ScheduleDao scheduleDao; @Autowired TmClient tmClient; diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CmsoClient.java b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CmsoClient.java new file mode 100644 index 0000000..c31c275 --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CmsoClient.java @@ -0,0 +1,239 @@ +/* + * 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. +*/ + +package org.onap.optf.cmso.dispatcher; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import javax.ws.rs.ProcessingException; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.Entity; +import javax.ws.rs.client.Invocation; +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.optf.cmso.common.BasicAuthenticatorFilter; +import org.onap.optf.cmso.common.CmsoStatusEnum; +import org.onap.optf.cmso.common.LogMessages; +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.ChangeManagementGroupDao; +import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao; +import org.onap.optf.cmso.model.dao.ScheduleDao; +import org.onap.optf.cmso.ticketmgt.TmClient; +import org.onap.optf.cmso.wf.bean.WfChangeManagementResponse; +import org.onap.optf.cmso.wf.bean.WfVidCmResponse; +import org.quartz.SchedulerException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +@Component +public class CmsoClient { + private static EELFLogger log = EELFManager.getInstance().getLogger(CmsoClient.class); + private static EELFLogger metrics = EELFManager.getInstance().getMetricsLogger(); + private static EELFLogger errors = EELFManager.getInstance().getErrorLogger(); + private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); + + @Autowired + ChangeManagementScheduleDao cmScheduleDao; + + @Autowired + ChangeManagementGroupDao cmGroupDao; + + @Autowired + ScheduleDao scheduleDao; + + + @Autowired + Environment env; + + @Autowired + PropertiesManagement pm; + + @Autowired + TmClient tmClient; + + /** + * Dispatch. + * + * @param cmSchedule the cm schedule + * @param schedule the schedule + */ + public void dispatch(ChangeManagementSchedule cmSchedule, Schedule schedule) { + try { + + String url = env.getProperty("so.url"); + if (!url.endsWith("/")) { + url += "/"; + } + url = url + "schedule/" + cmSchedule.getVnfName(); + String callbackData = cmSchedule.getRequest(); + String user = env.getProperty("so.user", ""); + String pass = pm.getProperty("so.pass", ""); + Client client = ClientBuilder.newClient(); + if (!user.equals("")) { + client.register(new BasicAuthenticatorFilter(user, pass)); + } + client.register(new CmsoClientFilters()); + WebTarget target = client.target(url); + ObjectMapper om = new ObjectMapper(); + JsonNode jsonEntity = om.readTree(callbackData); + Invocation.Builder invocationBuilder = target.request(MediaType.APPLICATION_JSON); + try { + Response response = invocationBuilder.post(Entity.json(jsonEntity)); + switch (response.getStatus()) { + case 201: { + debug.debug("Response status=" + response.getStatus()); + // Push the state up to the schedule. + processScheduleResponse(cmSchedule, schedule, response); + break; + } + case 200: { + debug.debug("Response status=" + response.getStatus()); + // Push the state up to the schedule. + processScheduleResponse200(cmSchedule, schedule, response); + break; + } + case 400: // Bad request + case 500: + default: { + errors.error(LogMessages.UNEXPECTED_RESPONSE.toString(), "VID", response.getStatus(), + response.toString()); + cmSchedule.setStatus(CmsoStatusEnum.SchedulingFailed.toString()); + cmSchedule.setStatusMessage(response.toString()); + updateScheduleStatus(cmSchedule, schedule); + return; + } + } + } + // No sense in retrying. These are time sensitive actions + catch (ResponseProcessingException e) { + errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + cmSchedule.setStatus(CmsoStatusEnum.SchedulingFailed.toString()); + cmSchedule.setStatusMessage(e.toString()); + updateScheduleStatus(cmSchedule, schedule); + + } catch (ProcessingException e) { + errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + cmSchedule.setStatus(CmsoStatusEnum.SchedulingFailed.toString()); + cmSchedule.setStatusMessage(e.toString()); + updateScheduleStatus(cmSchedule, schedule); + } + } catch (Exception e) { + errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + cmSchedule.setStatus(CmsoStatusEnum.SchedulingFailed.toString()); + cmSchedule.setStatusMessage(e.toString()); + updateScheduleStatus(cmSchedule, schedule); + } + } + + private void processScheduleResponse(ChangeManagementSchedule cmSchedule, Schedule schedule, Response response) + throws SchedulerException { + WfChangeManagementResponse resp = response.readEntity(WfChangeManagementResponse.class); + for (WfVidCmResponse cmResponse : resp.getCmResponses()) { + if (cmResponse.getVnfName().equals(cmSchedule.getVnfName())) { + cmSchedule.setStatus(CmsoStatusEnum.Triggered.toString()); + cmSchedule.setDispatchTimeMillis(System.currentTimeMillis()); + cmSchedule.setMsoRequestId(cmResponse.getOrchestratorRequestId()); + // Push the state up to the schedule. + updateTicket(cmSchedule, schedule); + updateScheduleStatus(cmSchedule, schedule); + return; + } + } + cmSchedule.setStatus(CmsoStatusEnum.SchedulingFailed.toString()); + cmSchedule.setStatusMessage("Response did not contain vnfName=" + cmSchedule.getVnfName()); + updateScheduleStatus(cmSchedule, schedule); + } + + private void processScheduleResponse200(ChangeManagementSchedule cmSchedule, Schedule schedule, Response response) + throws SchedulerException { + + JsonNode node = response.readEntity(JsonNode.class); + log.info("Message returned from VID callback: " + node.toString()); + JsonNode status = node.get("status"); + Integer msoStatus = status.asInt(); + JsonNode entity = node.get("entity"); + if (msoStatus == 202) { + JsonNode rr = entity.get("requestReferences"); + if (rr != null) { + JsonNode requestId = rr.get("requestId"); + if (requestId != null) { + cmSchedule.setStatus(CmsoStatusEnum.Triggered.toString()); + cmSchedule.setDispatchTimeMillis(System.currentTimeMillis()); + cmSchedule.setMsoRequestId(requestId.asText()); + // Push the state up to the schedule. + updateTicket(cmSchedule, schedule); + updateScheduleStatus(cmSchedule, schedule); + return; + } + } + } + cmSchedule.setStatus(CmsoStatusEnum.SchedulingFailed.toString()); + cmSchedule.setStatusMessage(node.toString()); + updateScheduleStatus(cmSchedule, schedule); + } + + private void updateTicket(ChangeManagementSchedule cmSchedule, Schedule schedule) { + try { + String changeId = cmSchedule.getTmChangeId(); + if (changeId != null && !changeId.equals("")) { + tmClient.updateTicket(schedule, cmSchedule, changeId); + } + } catch (Exception e) { + errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + } + } + + /** + * Update schedule status. + * + * @param cmSchedule the cm schedule + * @param schedule the schedule + */ + @Transactional + public void updateScheduleStatus(ChangeManagementSchedule cmSchedule, Schedule schedule) { + cmScheduleDao.save(cmSchedule); + if (schedule != null) { + scheduleDao.save(schedule); + } + + } +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/DispatchJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/DispatchJob.java index 3d987b1..ccbc430 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/DispatchJob.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/DispatchJob.java @@ -39,14 +39,14 @@ import java.util.Date; import java.util.HashSet; import java.util.Set; import java.util.UUID; -import org.onap.optf.cmso.common.CMSStatusEnum; +import org.onap.optf.cmso.common.CmsoStatusEnum; import org.onap.optf.cmso.common.LogMessages; import org.onap.optf.cmso.model.ChangeManagementGroup; import org.onap.optf.cmso.model.ChangeManagementSchedule; import org.onap.optf.cmso.model.Schedule; -import org.onap.optf.cmso.model.dao.ChangeManagementGroupDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO; -import org.onap.optf.cmso.model.dao.ScheduleDAO; +import org.onap.optf.cmso.model.dao.ChangeManagementGroupDao; +import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao; +import org.onap.optf.cmso.model.dao.ScheduleDao; import org.onap.optf.cmso.ticketmgt.TmClient; import org.onap.optf.cmso.ticketmgt.bean.TmApprovalStatusEnum; import org.onap.optf.cmso.ticketmgt.bean.TmChangeInfo; @@ -69,16 +69,16 @@ public class DispatchJob { private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); @Autowired - CMSOClient vidClient; + CmsoClient vidClient; @Autowired - ChangeManagementScheduleDAO cmScheduleDao; + ChangeManagementScheduleDao cmScheduleDao; @Autowired - ChangeManagementGroupDAO cmGroupDao; + ChangeManagementGroupDao cmGroupDao; @Autowired - ScheduleDAO scheduleDao; + ScheduleDao scheduleDao; @Autowired TmClient tmClient; @@ -102,7 +102,7 @@ public class DispatchJob { if (group != null) { Schedule schedule = scheduleDao.findById(group.getSchedulesUuid()).orElse(null); if (schedule != null) { - schedule.setStatus(CMSStatusEnum.NotificationsInitiated.toString()); + schedule.setStatus(CmsoStatusEnum.NotificationsInitiated.toString()); if (safeToDispatch(cmSchedule, schedule)) { vidClient.dispatch(cmSchedule, schedule); } @@ -128,8 +128,8 @@ public class DispatchJob { // ******************************************************************* // Validate that the state is accurate. // Another instance may have dispatched - if (!cmSchedule.getStatus().equals(CMSStatusEnum.Scheduled.toString()) - && !cmSchedule.getStatus().equals(CMSStatusEnum.ScheduledImmediate.toString())) { + if (!cmSchedule.getStatus().equals(CmsoStatusEnum.Scheduled.toString()) + && !cmSchedule.getStatus().equals(CmsoStatusEnum.ScheduledImmediate.toString())) { log.info("Attempt to dispatch an event that is in the incorrect state scheduleId={0}, vnf={1}, status={2}", schedule.getScheduleId(), cmSchedule.getVnfName(), cmSchedule.getStatus()); return false; @@ -161,7 +161,7 @@ public class DispatchJob { String message = "Attempt to schedule immediate when immmediate scheduling is disabled: " + cmSchedule.getVnfName(); log.info(message); - cmSchedule.setStatus(CMSStatusEnum.SchedulingFailed.toString()); + cmSchedule.setStatus(CmsoStatusEnum.SchedulingFailed.toString()); cmSchedule.setStatusMessage(message); updateScheduleStatus(cmSchedule, schedule); return false; @@ -182,7 +182,7 @@ public class DispatchJob { cmSchedule.getVnfName(), new Date(now).toString(), new Date(startMillis).toString()); log.info(message); - cmSchedule.setStatus(CMSStatusEnum.PastDue.toString()); + cmSchedule.setStatus(CmsoStatusEnum.PastDue.toString()); cmSchedule.setStatusMessage(message); updateScheduleStatus(cmSchedule, schedule); return false; @@ -243,7 +243,7 @@ public class DispatchJob { cmSchedule.getVnfName(), cmSchedule.getTmChangeId()); errors.error(message); } - cmSchedule.setStatus(CMSStatusEnum.SchedulingFailed.toString()); + cmSchedule.setStatus(CmsoStatusEnum.SchedulingFailed.toString()); cmSchedule.setStatusMessage(message); updateScheduleStatus(cmSchedule, schedule); return false; diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CMSQueueJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CMSQueueJob.java deleted file mode 100644 index cb0ca87..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CMSQueueJob.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso.eventq; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import java.util.Date; -import java.util.List; -import org.onap.optf.cmso.common.CMSStatusEnum; -import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.dispatcher.CmJob; -import org.onap.optf.cmso.model.ChangeManagementSchedule; -import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO; -import org.quartz.JobBuilder; -import org.quartz.JobDetail; -import org.quartz.Trigger; -import org.quartz.TriggerBuilder; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; -import org.springframework.scheduling.quartz.SchedulerFactoryBean; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; - -/** - * This job will look for ChangeManagementSchedule approved jobs that are due - * within the next n intervals of this job and schedule them in as a Quartz - * CmJob to be dispatched. These ChangeManagementSchedule rows will be - * status=Queued The CmJob will confirm that the job is OK to be dispatched and - * set status=.... The next N intervals should be enough to ensure sluggish - * performance of this process does not miss events but does not exhaust - * memory.... - */ -@Component -public class CMSQueueJob { - private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); - - @Autowired - ChangeManagementScheduleDAO cmScheduleDao; - - @Autowired - SchedulerFactoryBean qsScheduler; - - @Autowired - Environment env; - - @Autowired - DispatchedEventList dispatchedEventList; - - /** - * Queue imminent jobs. - * - * @return true, if successful - */ - public boolean queueImminentJobs() { - Integer interval = env.getProperty("cmso.cm.polling.job.interval.ms", Integer.class, 10000); - Integer lookahead = env.getProperty("cmso.cm.polling.job.lookahead.intervals", Integer.class, 5); - long now = System.currentTimeMillis(); - Long endTime = now + (interval * lookahead); - List schedules = - cmScheduleDao.findByStatusAndEndTime(CMSStatusEnum.Scheduled.toString(), endTime); - if (schedules.size() == 0) { - return false; - } - for (ChangeManagementSchedule schedule : schedules) { - try { - if (!dispatchedEventList.isAlreadyDispatched(schedule.getUuid())) { - scheduleCmJob(schedule); - dispatchedEventList.addToDispathcedEventList(schedule.getUuid()); - } - } catch (org.quartz.SchedulerException e) { - debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - // WIll keep trying until it goes Past due - schedule.setStatus(CMSStatusEnum.Scheduled.toString()); - schedule.setDispatcherInstance(""); - updateScheduleStatus(schedule); - } catch (Exception e) { - debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - schedule.setStatus(CMSStatusEnum.Scheduled.toString()); - schedule.setDispatcherInstance(""); - updateScheduleStatus(schedule); - } - } - return false; - } - - /** - * Schedule cm job. - * - * @param schedule the schedule - * @throws Exception the scheduler exception - */ - public void scheduleCmJob(ChangeManagementSchedule schedule) throws org.quartz.SchedulerException { - // - Integer dispatherLeadTime = env.getProperty("cmso.cm.dispatcher.lead.time.ms", Integer.class, 5000); - long dispatchTime = 0; - Long startTime = schedule.getStartTimeMillis(); - - /// If startTIme is null, it is an immediate start - if (startTime != null) { - dispatchTime = startTime - dispatherLeadTime; - } - - JobDetail jobDetail = JobBuilder.newJob(CmJob.class).build(); - jobDetail.getJobDataMap().put("key", schedule.getUuid().toString()); - - TriggerBuilder tb = TriggerBuilder.newTrigger().forJob(jobDetail); - - long now = System.currentTimeMillis(); - if (now > dispatchTime) { - tb.startNow(); - } - else { - tb.startAt(new Date(dispatchTime)); - } - Trigger trigger = tb.build(); - qsScheduler.getScheduler().scheduleJob(jobDetail, trigger); - - } - - /** - * Update schedule status. - * - * @param cmSchedule the cm schedule - */ - @Transactional - public void updateScheduleStatus(ChangeManagementSchedule cmSchedule) { - cmScheduleDao.save(cmSchedule); - - } - -} 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 7816f72..2ae0913 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 @@ -35,7 +35,7 @@ import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import org.onap.observations.Mdc; import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO; +import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao; import org.quartz.DisallowConcurrentExecution; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; @@ -55,7 +55,7 @@ public class CmQuartzJob extends QuartzJobBean { private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); @Autowired - CMSQueueJob qqJob; + CmsoQueueJob qqJob; // This is not called directly. Using @Autowired to ensure that startup // Runs before the fist invocation of executeInternal @@ -63,10 +63,9 @@ public class CmQuartzJob extends QuartzJobBean { CmQuartzJobStartup startup; @Autowired - ChangeManagementScheduleDAO cmScheduleDao; + ChangeManagementScheduleDao cmScheduleDao; @Override - @Transactional protected void executeInternal(JobExecutionContext context) throws JobExecutionException { Mdc.quartzJobBegin(context); debug.debug(LogMessages.CM_QUARTZ_JOB, "Entered"); diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CmQuartzJobStartup.java b/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CmQuartzJobStartup.java index add1478..dfb9fc5 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CmQuartzJobStartup.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CmQuartzJobStartup.java @@ -35,7 +35,7 @@ import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import java.net.InetAddress; import java.util.concurrent.atomic.AtomicBoolean; -import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO; +import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @@ -55,7 +55,7 @@ public class CmQuartzJobStartup { private static EELFLogger log = EELFManager.getInstance().getLogger(CmQuartzJobStartup.class); @Autowired - ChangeManagementScheduleDAO cmScheduleDao; + ChangeManagementScheduleDao cmScheduleDao; private AtomicBoolean started = new AtomicBoolean(false); diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CmsoQueueJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CmsoQueueJob.java new file mode 100644 index 0000000..de85e2c --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CmsoQueueJob.java @@ -0,0 +1,160 @@ +/* + * 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. +*/ + +package org.onap.optf.cmso.eventq; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import java.util.Date; +import java.util.List; +import org.onap.optf.cmso.common.CmsoStatusEnum; +import org.onap.optf.cmso.common.LogMessages; +import org.onap.optf.cmso.dispatcher.CmJob; +import org.onap.optf.cmso.model.ChangeManagementSchedule; +import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao; +import org.quartz.JobBuilder; +import org.quartz.JobDetail; +import org.quartz.Trigger; +import org.quartz.TriggerBuilder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.scheduling.quartz.SchedulerFactoryBean; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +/** + * This job will look for ChangeManagementSchedule approved jobs that are due + * within the next n intervals of this job and schedule them in as a Quartz + * CmJob to be dispatched. These ChangeManagementSchedule rows will be + * status=Queued The CmJob will confirm that the job is OK to be dispatched and + * set status=.... The next N intervals should be enough to ensure sluggish + * performance of this process does not miss events but does not exhaust + * memory.... + */ +@Component +public class CmsoQueueJob { + private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); + + @Autowired + ChangeManagementScheduleDao cmScheduleDao; + + @Autowired + SchedulerFactoryBean qsScheduler; + + @Autowired + Environment env; + + @Autowired + DispatchedEventList dispatchedEventList; + + /** + * Queue imminent jobs. + * + * @return true, if successful + */ + public boolean queueImminentJobs() { + Integer interval = env.getProperty("cmso.cm.polling.job.interval.ms", Integer.class, 10000); + Integer lookahead = env.getProperty("cmso.cm.polling.job.lookahead.intervals", Integer.class, 5); + long now = System.currentTimeMillis(); + Long endTime = now + (interval * lookahead); + List schedules = + cmScheduleDao.findByStatusAndEndTime(CmsoStatusEnum.Scheduled.toString(), endTime); + if (schedules.size() == 0) { + return false; + } + for (ChangeManagementSchedule schedule : schedules) { + try { + if (!dispatchedEventList.isAlreadyDispatched(schedule.getUuid())) { + scheduleCmJob(schedule); + dispatchedEventList.addToDispathcedEventList(schedule.getUuid()); + } + } catch (org.quartz.SchedulerException e) { + debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + // WIll keep trying until it goes Past due + schedule.setStatus(CmsoStatusEnum.Scheduled.toString()); + schedule.setDispatcherInstance(""); + updateScheduleStatus(schedule); + } catch (Exception e) { + debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + schedule.setStatus(CmsoStatusEnum.Scheduled.toString()); + schedule.setDispatcherInstance(""); + updateScheduleStatus(schedule); + } + } + return false; + } + + /** + * Schedule cm job. + * + * @param schedule the schedule + * @throws Exception the scheduler exception + */ + public void scheduleCmJob(ChangeManagementSchedule schedule) throws org.quartz.SchedulerException { + // + Integer dispatherLeadTime = env.getProperty("cmso.cm.dispatcher.lead.time.ms", Integer.class, 5000); + long dispatchTime = 0; + Long startTime = schedule.getStartTimeMillis(); + + /// If startTIme is null, it is an immediate start + if (startTime != null) { + dispatchTime = startTime - dispatherLeadTime; + } + + JobDetail jobDetail = JobBuilder.newJob(CmJob.class).build(); + jobDetail.getJobDataMap().put("key", schedule.getUuid().toString()); + + TriggerBuilder tb = TriggerBuilder.newTrigger().forJob(jobDetail); + + long now = System.currentTimeMillis(); + if (now > dispatchTime) { + tb.startNow(); + } + else { + tb.startAt(new Date(dispatchTime)); + } + Trigger trigger = tb.build(); + qsScheduler.getScheduler().scheduleJob(jobDetail, trigger); + + } + + /** + * Update schedule status. + * + * @param cmSchedule the cm schedule + */ + @Transactional + public void updateScheduleStatus(ChangeManagementSchedule cmSchedule) { + cmScheduleDao.save(cmSchedule); + + } + +} 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 d62f5c2..e52df57 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 @@ -72,8 +72,8 @@ public class CmsoContainerFilters implements ContainerRequestFilter, ContainerRe MultivaluedMap respHeaders = responseContext.getHeaders(); String minorVersion = reqHeaders.getFirst(HeadersEnum.MinorVersion.toString()); respHeaders.add(HeadersEnum.MinorVersion.toString(), minorVersion); - respHeaders.add(HeadersEnum.LatestVersion.toString(), MessageHeaders.latestVersion); - respHeaders.add(HeadersEnum.PatchVersion.toString(), MessageHeaders.patchVersion); + respHeaders.add(HeadersEnum.LatestVersion.toString(), MessageHeaders.getLatestversion()); + respHeaders.add(HeadersEnum.PatchVersion.toString(), MessageHeaders.getPatchversion()); } catch (Exception e) { if (e instanceof WebApplicationException) { @@ -114,7 +114,7 @@ public class CmsoContainerFilters implements ContainerRequestFilter, ContainerRe } String minorVersion = headers.getFirst(HeadersEnum.MinorVersion.toString()); if (minorVersion == null) { - minorVersion = MessageHeaders.supportedMajorVersions.get(majorVersion); + minorVersion = MessageHeaders.getSupportedmajorversions().get(majorVersion); headers.add(HeadersEnum.MinorVersion.toString(), minorVersion); } if (!MessageHeaders.validateMajorMinorVersion(majorVersion, minorVersion)) { diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/filters/MessageHeaders.java b/cmso-service/src/main/java/org/onap/optf/cmso/filters/MessageHeaders.java index b62cce2..d671768 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/filters/MessageHeaders.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/filters/MessageHeaders.java @@ -69,7 +69,7 @@ public class MessageHeaders { } /** The Constant supportedMajorVersions. */ - public static final Map supportedMajorVersions = new HashMap(); + private static final Map supportedMajorVersions = new HashMap(); static { supportedMajorVersions.put("v1", "0"); @@ -77,7 +77,7 @@ public class MessageHeaders { } /** The Constant supportedMajorMinorVersions. */ - public static final Set supportedMajorMinorVersions = new HashSet(); + private static final Set supportedMajorMinorVersions = new HashSet(); static { supportedMajorMinorVersions.add("v1.0"); @@ -85,10 +85,10 @@ public class MessageHeaders { } /** The Constant latestVersion. */ - public static final String latestVersion = "2.0.0"; + private static final String latestVersion = "2.0.0"; /** The Constant patchVersion. */ - public static final String patchVersion = "0"; + private static final String patchVersion = "0"; /** * From string. @@ -156,4 +156,20 @@ public class MessageHeaders { } return true; } + + public static Map getSupportedmajorversions() { + return supportedMajorVersions; + } + + public static Set getSupportedmajorminorversions() { + return supportedMajorMinorVersions; + } + + public static String getLatestversion() { + return latestVersion; + } + + public static String getPatchversion() { + return patchVersion; + } } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ApprovalTypeDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ApprovalTypeDAO.java deleted file mode 100644 index 9e4b546..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ApprovalTypeDAO.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso.model.dao; - -import java.util.List; -import java.util.Optional; -import java.util.UUID; - -import org.onap.optf.cmso.model.ApprovalType; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.PagingAndSortingRepository; - -public interface ApprovalTypeDAO extends PagingAndSortingRepository { - Optional findById(UUID id); - - ApprovalType save(ApprovalType persisted); - - void delete(ApprovalType toDelete); - - @Query(value = "SELECT d FROM ApprovalType d WHERE d.domain = ?1 AND d.approvalType = ?2") - ApprovalType findByDomainAndType(String domain, String type); - - @Query(value = "SELECT d FROM ApprovalType d WHERE d.domain = ?1") - List findByDomain(String domain); -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ApprovalTypeDao.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ApprovalTypeDao.java new file mode 100644 index 0000000..48d489d --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ApprovalTypeDao.java @@ -0,0 +1,54 @@ +/* + * 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. +*/ + +package org.onap.optf.cmso.model.dao; + +import java.util.List; +import java.util.Optional; +import java.util.UUID; + +import org.onap.optf.cmso.model.ApprovalType; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.PagingAndSortingRepository; + +public interface ApprovalTypeDao extends PagingAndSortingRepository { + Optional findById(UUID id); + + ApprovalType save(ApprovalType persisted); + + void delete(ApprovalType toDelete); + + @Query(value = "SELECT d FROM ApprovalType d WHERE d.domain = ?1 AND d.approvalType = ?2") + ApprovalType findByDomainAndType(String domain, String type); + + @Query(value = "SELECT d FROM ApprovalType d WHERE d.domain = ?1") + List findByDomain(String domain); +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementChangeWindowDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementChangeWindowDAO.java deleted file mode 100644 index 976a57f..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementChangeWindowDAO.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso.model.dao; - -import java.util.List; -import java.util.Optional; -import java.util.UUID; - -import org.onap.optf.cmso.model.ChangeManagementChangeWindow; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.PagingAndSortingRepository; - -public interface ChangeManagementChangeWindowDAO - extends PagingAndSortingRepository { - Optional findById(UUID id); - - ChangeManagementChangeWindow save(ChangeManagementChangeWindow persisted); - - void delete(ChangeManagementChangeWindow toDelete); - - @Query(value = "SELECT d FROM ChangeManagementChangeWindow d WHERE d.changeManagementGroupUuid = ?1") - List findByGroupsUuid(UUID id); - - @Modifying - @Query(value = "DELETE FROM ChangeManagementChangeWindow d WHERE d.changeManagementGroupUuid = ?1") - int deleteByChangeManagementGroupUuid(UUID id); - -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementChangeWindowDao.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementChangeWindowDao.java new file mode 100644 index 0000000..945d9ed --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementChangeWindowDao.java @@ -0,0 +1,58 @@ +/* + * 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. +*/ + +package org.onap.optf.cmso.model.dao; + +import java.util.List; +import java.util.Optional; +import java.util.UUID; + +import org.onap.optf.cmso.model.ChangeManagementChangeWindow; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.PagingAndSortingRepository; + +public interface ChangeManagementChangeWindowDao + extends PagingAndSortingRepository { + Optional findById(UUID id); + + ChangeManagementChangeWindow save(ChangeManagementChangeWindow persisted); + + void delete(ChangeManagementChangeWindow toDelete); + + @Query(value = "SELECT d FROM ChangeManagementChangeWindow d WHERE d.changeManagementGroupUuid = ?1") + List findByGroupsUuid(UUID id); + + @Modifying + @Query(value = "DELETE FROM ChangeManagementChangeWindow d WHERE d.changeManagementGroupUuid = ?1") + int deleteByChangeManagementGroupUuid(UUID id); + +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDAO.java deleted file mode 100644 index 7dabf5e..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDAO.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso.model.dao; - -import java.util.List; -import org.onap.optf.cmso.model.ChangeManagementDetail; - -public interface ChangeManagementDetailDAO { - - List searchScheduleDetails(String where, int limit); - -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDAOImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDAOImpl.java deleted file mode 100644 index 2543c77..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDAOImpl.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso.model.dao; - -import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.persistence.Query; -import org.onap.optf.cmso.model.ChangeManagementDetail; -import org.springframework.stereotype.Repository; - -@Repository -public class ChangeManagementDetailDAOImpl implements ChangeManagementDetailDAO { - @PersistenceContext - private EntityManager manager; - - @Override - public List searchScheduleDetails(String where, int limit) { - StringBuilder sql = new StringBuilder(); - sql.append("select distinct" + " s.uuid as uuid," + " s.vnf_name as vnf_name," + " s.vnf_id as vnf_id," - + " s.status as status," + " s.tm_change_id as tm_change_Id," + " s.start_time as start_time," - + " s.finish_time as finish_time," + " s.mso_request_id as mso_request_id," - + " s.mso_status as mso_status," + " s.mso_message as mso_message," + " s.mso_time as mso_time," - + " s.dispatch_time as dispatch_time," + " s.execution_completed_time as execution_completed_time," - + " s.status_message as status_message," + " s.tm_approval_status as tm_approval_status," - + " s.tm_status as tm_status," + " g.group_id as group_id," - + " g.last_instance_start_time as last_instance_start_time," + " g.policy_id as policy_id," - + " g.schedules_uuid as schedules_uuid" - // + " ss.schedule_id as scheduleId," - // + " dd.name" - + " from" + " CHANGE_MANAGEMENT_SCHEDULES s" - + " inner join CHANGE_MANAGEMENT_GROUPS g on s.change_management_group_uuid = g.uuid" - + " inner join SCHEDULES ss on g.schedules_uuid = ss.uuid " - + " left outer join DOMAIN_DATA dd on ss.uuid = dd.schedules_uuid" - + " left outer join SCHEDULE_APPROVALS sa on ss.uuid = sa.schedules_uuid" - + " left outer join APPROVAL_TYPES at on sa.approval_types_uuid = at.uuid "); - sql.append(where); - sql.append(" order by uuid "); - if (limit > 0) { - sql.append("LIMIT " + limit); - } - - Query query = manager.createNativeQuery(sql.toString(), ChangeManagementDetail.class); - @SuppressWarnings("unchecked") - List list = query.getResultList(); - return list; - } -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDao.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDao.java new file mode 100644 index 0000000..9fae8bf --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDao.java @@ -0,0 +1,41 @@ +/* + * 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. +*/ + +package org.onap.optf.cmso.model.dao; + +import java.util.List; +import org.onap.optf.cmso.model.ChangeManagementDetail; + +public interface ChangeManagementDetailDao { + + List searchScheduleDetails(String where, int limit); + +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDaoImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDaoImpl.java new file mode 100644 index 0000000..03b05d4 --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDaoImpl.java @@ -0,0 +1,77 @@ +/* + * 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. +*/ + +package org.onap.optf.cmso.model.dao; + +import java.util.List; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; +import org.onap.optf.cmso.model.ChangeManagementDetail; +import org.springframework.stereotype.Repository; + +@Repository +public class ChangeManagementDetailDaoImpl implements ChangeManagementDetailDao { + @PersistenceContext + private EntityManager manager; + + @Override + public List searchScheduleDetails(String where, int limit) { + StringBuilder sql = new StringBuilder(); + sql.append("select distinct" + " s.uuid as uuid," + " s.vnf_name as vnf_name," + " s.vnf_id as vnf_id," + + " s.status as status," + " s.tm_change_id as tm_change_Id," + " s.start_time as start_time," + + " s.finish_time as finish_time," + " s.mso_request_id as mso_request_id," + + " s.mso_status as mso_status," + " s.mso_message as mso_message," + " s.mso_time as mso_time," + + " s.dispatch_time as dispatch_time," + " s.execution_completed_time as execution_completed_time," + + " s.status_message as status_message," + " s.tm_approval_status as tm_approval_status," + + " s.tm_status as tm_status," + " g.group_id as group_id," + + " g.last_instance_start_time as last_instance_start_time," + " g.policy_id as policy_id," + + " g.schedules_uuid as schedules_uuid" + // + " ss.schedule_id as scheduleId," + // + " dd.name" + + " from" + " CHANGE_MANAGEMENT_SCHEDULES s" + + " inner join CHANGE_MANAGEMENT_GROUPS g on s.change_management_group_uuid = g.uuid" + + " inner join SCHEDULES ss on g.schedules_uuid = ss.uuid " + + " left outer join DOMAIN_DATA dd on ss.uuid = dd.schedules_uuid" + + " left outer join SCHEDULE_APPROVALS sa on ss.uuid = sa.schedules_uuid" + + " left outer join APPROVAL_TYPES at on sa.approval_types_uuid = at.uuid "); + sql.append(where); + sql.append(" order by uuid "); + if (limit > 0) { + sql.append("LIMIT " + limit); + } + + Query query = manager.createNativeQuery(sql.toString(), ChangeManagementDetail.class); + @SuppressWarnings("unchecked") + List list = query.getResultList(); + return list; + } +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementGroupDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementGroupDAO.java deleted file mode 100644 index 7694d8d..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementGroupDAO.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso.model.dao; - -import java.util.List; -import java.util.Optional; -import java.util.UUID; - -import org.onap.optf.cmso.model.ChangeManagementGroup; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.PagingAndSortingRepository; - -public interface ChangeManagementGroupDAO extends PagingAndSortingRepository { - Optional findById(UUID id); - - ChangeManagementGroup save(ChangeManagementGroup persisted); - - void delete(ChangeManagementGroup toDelete); - - @Query(value = "SELECT d FROM ChangeManagementGroup d WHERE d.schedulesUuid = ?1") - List findBySchedulesId(UUID id); - - @Query(value = "SELECT d FROM ChangeManagementGroup d WHERE d.schedulesUuid = ?1 AND d.groupId = ?2") - ChangeManagementGroup findOneBySchedulesIdGroupId(UUID id, String groupId); - -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementGroupDao.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementGroupDao.java new file mode 100644 index 0000000..b4bcaf0 --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementGroupDao.java @@ -0,0 +1,55 @@ +/* + * 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. +*/ + +package org.onap.optf.cmso.model.dao; + +import java.util.List; +import java.util.Optional; +import java.util.UUID; + +import org.onap.optf.cmso.model.ChangeManagementGroup; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.PagingAndSortingRepository; + +public interface ChangeManagementGroupDao extends PagingAndSortingRepository { + Optional findById(UUID id); + + ChangeManagementGroup save(ChangeManagementGroup persisted); + + void delete(ChangeManagementGroup toDelete); + + @Query(value = "SELECT d FROM ChangeManagementGroup d WHERE d.schedulesUuid = ?1") + List findBySchedulesId(UUID id); + + @Query(value = "SELECT d FROM ChangeManagementGroup d WHERE d.schedulesUuid = ?1 AND d.groupId = ?2") + ChangeManagementGroup findOneBySchedulesIdGroupId(UUID id, String groupId); + +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementScheduleDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementScheduleDAO.java deleted file mode 100644 index 8741587..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementScheduleDAO.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso.model.dao; - -import java.util.List; -import java.util.Optional; -import java.util.UUID; -import javax.persistence.LockModeType; -import org.onap.optf.cmso.model.ChangeManagementSchedule; -import org.springframework.data.jpa.repository.Lock; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.PagingAndSortingRepository; - -public interface ChangeManagementScheduleDAO extends PagingAndSortingRepository { - @Override - Optional findById(UUID id); - - @Override - ChangeManagementSchedule save(ChangeManagementSchedule persisted); - - @Override - void delete(ChangeManagementSchedule toDelete); - - @Query(value = "SELECT d FROM ChangeManagementSchedule d WHERE d.changeManagementGroupUuid = ?1") - List findByChangeManagementGroupId(UUID id); - - @Modifying - @Query(value = "DELETE FROM ChangeManagementSchedule d WHERE d.changeManagementGroupUuid = ?1") - public int deleteByChangeManagementGroupsId(UUID id); - - @Query(value = "SELECT d FROM ChangeManagementSchedule d WHERE d.changeManagementGroupUuid = ?1 AND d.vnfName = ?2") - ChangeManagementSchedule findOneByGroupUuidAndVnfName(UUID id, String vnfName); - - @Query(value = "SELECT d FROM ChangeManagementSchedule d, ChangeManagementGroup g" - + " WHERE g.schedulesUuid = ?1" - + " AND g.groupId = ?2" - + " AND d.changeManagementGroupUuid = g.uuid" - + " AND d.vnfName = ?3") - ChangeManagementSchedule findOneByScheduleUuidGroupIdAndVnfName(UUID id, String groupId, String vnfName); - - - @Query(value = "SELECT d FROM ChangeManagementSchedule d" - + " WHERE (d.status = ?1 AND d.startTimeMillis <= ?2)" - + " or d.status = 'Scheduled Immediate' order by d.startTimeMillis") - List findByStatusAndEndTime(String status, Long date); - - @Modifying - @Query(value = "Update ChangeManagementSchedule d set d.status = 'Scheduled'," - + " d.dispatcherInstance = ''" - + " WHERE d.status = 'Queued for Dispatch' AND d.dispatcherInstance = ?1") - public int requeueQueuedForDispatch(String dispatcherInstance); - - @Query(value = "SELECT d FROM ChangeManagementSchedule d WHERE d.status = 'Triggered'") - List findAllTriggered(); - - @Query(value = "SELECT d FROM ChangeManagementSchedule d WHERE d.tmApprovalStatus = 'Pending Approval'") - List findAllAwaitingTmApproval(); - - @Query(value = "SELECT d FROM ChangeManagementSchedule d WHERE d.uuid = ?1") - @Lock(LockModeType.PESSIMISTIC_WRITE) - ChangeManagementSchedule lockOne(UUID id); - -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementScheduleDao.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementScheduleDao.java new file mode 100644 index 0000000..172221a --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementScheduleDao.java @@ -0,0 +1,93 @@ +/* + * 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. +*/ + +package org.onap.optf.cmso.model.dao; + +import java.util.List; +import java.util.Optional; +import java.util.UUID; +import javax.persistence.LockModeType; +import org.onap.optf.cmso.model.ChangeManagementSchedule; +import org.springframework.data.jpa.repository.Lock; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.PagingAndSortingRepository; + +public interface ChangeManagementScheduleDao extends PagingAndSortingRepository { + @Override + Optional findById(UUID id); + + @Override + ChangeManagementSchedule save(ChangeManagementSchedule persisted); + + @Override + void delete(ChangeManagementSchedule toDelete); + + @Query(value = "SELECT d FROM ChangeManagementSchedule d WHERE d.changeManagementGroupUuid = ?1") + List findByChangeManagementGroupId(UUID id); + + @Modifying + @Query(value = "DELETE FROM ChangeManagementSchedule d WHERE d.changeManagementGroupUuid = ?1") + public int deleteByChangeManagementGroupsId(UUID id); + + @Query(value = "SELECT d FROM ChangeManagementSchedule d WHERE d.changeManagementGroupUuid = ?1 AND d.vnfName = ?2") + ChangeManagementSchedule findOneByGroupUuidAndVnfName(UUID id, String vnfName); + + @Query(value = "SELECT d FROM ChangeManagementSchedule d, ChangeManagementGroup g" + + " WHERE g.schedulesUuid = ?1" + + " AND g.groupId = ?2" + + " AND d.changeManagementGroupUuid = g.uuid" + + " AND d.vnfName = ?3") + ChangeManagementSchedule findOneByScheduleUuidGroupIdAndVnfName(UUID id, String groupId, String vnfName); + + + @Query(value = "SELECT d FROM ChangeManagementSchedule d" + + " WHERE (d.status = ?1 AND d.startTimeMillis <= ?2)" + + " or d.status = 'Scheduled Immediate' order by d.startTimeMillis") + List findByStatusAndEndTime(String status, Long date); + + @Modifying + @Query(value = "Update ChangeManagementSchedule d set d.status = 'Scheduled'," + + " d.dispatcherInstance = ''" + + " WHERE d.status = 'Queued for Dispatch' AND d.dispatcherInstance = ?1") + public int requeueQueuedForDispatch(String dispatcherInstance); + + @Query(value = "SELECT d FROM ChangeManagementSchedule d WHERE d.status = 'Triggered'") + List findAllTriggered(); + + @Query(value = "SELECT d FROM ChangeManagementSchedule d WHERE d.tmApprovalStatus = 'Pending Approval'") + List findAllAwaitingTmApproval(); + + @Query(value = "SELECT d FROM ChangeManagementSchedule d WHERE d.uuid = ?1") + @Lock(LockModeType.PESSIMISTIC_WRITE) + ChangeManagementSchedule lockOne(UUID id); + +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/DomainDataDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/DomainDataDAO.java deleted file mode 100644 index 75299a1..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/DomainDataDAO.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso.model.dao; - -import java.util.Optional; -import java.util.UUID; - -import org.onap.optf.cmso.model.DomainData; -import org.springframework.data.repository.PagingAndSortingRepository; - -public interface DomainDataDAO extends PagingAndSortingRepository { - Optional findById(UUID id); - - DomainData save(DomainData persisted); - - void delete(DomainData toDelete); - -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/DomainDataDao.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/DomainDataDao.java new file mode 100644 index 0000000..e9d7e1e --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/DomainDataDao.java @@ -0,0 +1,47 @@ +/* + * 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. +*/ + +package org.onap.optf.cmso.model.dao; + +import java.util.Optional; +import java.util.UUID; + +import org.onap.optf.cmso.model.DomainData; +import org.springframework.data.repository.PagingAndSortingRepository; + +public interface DomainDataDao extends PagingAndSortingRepository { + Optional findById(UUID id); + + DomainData save(DomainData persisted); + + void delete(DomainData toDelete); + +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ElementDataDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ElementDataDAO.java deleted file mode 100644 index dada4e1..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ElementDataDAO.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso.model.dao; - -import java.util.Optional; -import java.util.UUID; -import org.onap.optf.cmso.model.ElementData; -import org.springframework.data.repository.PagingAndSortingRepository; - -public interface ElementDataDAO extends PagingAndSortingRepository { - @Override - Optional findById(UUID id); - - @Override - ElementData save(ElementData persisted); - - @Override - void delete(ElementData toDelete); - -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ElementDataDao.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ElementDataDao.java new file mode 100644 index 0000000..8a05a4c --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ElementDataDao.java @@ -0,0 +1,49 @@ +/* + * 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. +*/ + +package org.onap.optf.cmso.model.dao; + +import java.util.Optional; +import java.util.UUID; +import org.onap.optf.cmso.model.ElementData; +import org.springframework.data.repository.PagingAndSortingRepository; + +public interface ElementDataDao extends PagingAndSortingRepository { + @Override + Optional findById(UUID id); + + @Override + ElementData save(ElementData persisted); + + @Override + void delete(ElementData toDelete); + +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleApprovalDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleApprovalDAO.java deleted file mode 100644 index 3fabd63..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleApprovalDAO.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso.model.dao; - -import java.util.Optional; -import java.util.UUID; - -import org.onap.optf.cmso.model.ScheduleApproval; -import org.springframework.data.repository.PagingAndSortingRepository; - -public interface ScheduleApprovalDAO extends PagingAndSortingRepository { - Optional findById(UUID id); - - ScheduleApproval save(ScheduleApproval persisted); - - void delete(ScheduleApproval toDelete); - -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleApprovalDao.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleApprovalDao.java new file mode 100644 index 0000000..8d62256 --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleApprovalDao.java @@ -0,0 +1,47 @@ +/* + * 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. +*/ + +package org.onap.optf.cmso.model.dao; + +import java.util.Optional; +import java.util.UUID; + +import org.onap.optf.cmso.model.ScheduleApproval; +import org.springframework.data.repository.PagingAndSortingRepository; + +public interface ScheduleApprovalDao extends PagingAndSortingRepository { + Optional findById(UUID id); + + ScheduleApproval save(ScheduleApproval persisted); + + void delete(ScheduleApproval toDelete); + +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleDAO.java deleted file mode 100644 index 14d3143..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleDAO.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso.model.dao; - -import java.util.List; -import java.util.Optional; -import java.util.UUID; - -import javax.persistence.LockModeType; - -import org.onap.optf.cmso.model.Schedule; -import org.springframework.data.jpa.repository.Lock; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.PagingAndSortingRepository; - -public interface ScheduleDAO extends PagingAndSortingRepository { - Optional findById(UUID id); - - Schedule save(Schedule persited); - - void delete(Schedule toDelete); - - @Query(value = "SELECT s FROM Schedule s WHERE s.domain = ?1 AND s.scheduleId= ?2 ") - Schedule findByDomainScheduleId(String domain, String scheduleId); - - @Query(value = "SELECT s FROM Schedule s WHERE s.domain = ?1 AND s.status = ?2 ") - List findByDomainStatus(String domain, String status); - - @Query(value = "SELECT s FROM Schedule s WHERE s.optimizerTransactionId= ?1") - Schedule findOneByTransactionId(String transactionId); - - @Query(value = "SELECT s FROM Schedule s WHERE s.domain = ?1 AND s.status = 'Notifications Initiated'") - List findAllInProgress(String string); - - @Query(value = "SELECT d FROM Schedule d WHERE d.uuid = ?1") - @Lock(LockModeType.PESSIMISTIC_WRITE) - Schedule lockOne(UUID id); - - @Query(value = "SELECT s FROM Schedule s WHERE s.optimizerTransactionId= ?1") - @Lock(LockModeType.PESSIMISTIC_WRITE) - Schedule lockOneByTransactionId(String transactionId); - -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleDao.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleDao.java new file mode 100644 index 0000000..f73ed96 --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleDao.java @@ -0,0 +1,72 @@ +/* + * 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. +*/ + +package org.onap.optf.cmso.model.dao; + +import java.util.List; +import java.util.Optional; +import java.util.UUID; + +import javax.persistence.LockModeType; + +import org.onap.optf.cmso.model.Schedule; +import org.springframework.data.jpa.repository.Lock; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.PagingAndSortingRepository; + +public interface ScheduleDao extends PagingAndSortingRepository { + Optional findById(UUID id); + + Schedule save(Schedule persited); + + void delete(Schedule toDelete); + + @Query(value = "SELECT s FROM Schedule s WHERE s.domain = ?1 AND s.scheduleId= ?2 ") + Schedule findByDomainScheduleId(String domain, String scheduleId); + + @Query(value = "SELECT s FROM Schedule s WHERE s.domain = ?1 AND s.status = ?2 ") + List findByDomainStatus(String domain, String status); + + @Query(value = "SELECT s FROM Schedule s WHERE s.optimizerTransactionId= ?1") + Schedule findOneByTransactionId(String transactionId); + + @Query(value = "SELECT s FROM Schedule s WHERE s.domain = ?1 AND s.status = 'Notifications Initiated'") + List findAllInProgress(String string); + + @Query(value = "SELECT d FROM Schedule d WHERE d.uuid = ?1") + @Lock(LockModeType.PESSIMISTIC_WRITE) + Schedule lockOne(UUID id); + + @Query(value = "SELECT s FROM Schedule s WHERE s.optimizerTransactionId= ?1") + @Lock(LockModeType.PESSIMISTIC_WRITE) + Schedule lockOneByTransactionId(String transactionId); + +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDAO.java deleted file mode 100644 index f974eb5..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDAO.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso.model.dao; - -import java.util.List; -import org.onap.optf.cmso.model.ScheduleQuery; - -public interface ScheduleQueryDAO { - - List searchSchedules(String where, int limit); - -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDAOImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDAOImpl.java deleted file mode 100644 index b5a6e57..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDAOImpl.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso.model.dao; - -import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.persistence.Query; -import org.onap.optf.cmso.model.ScheduleQuery; -import org.springframework.stereotype.Repository; - -@Repository -public class ScheduleQueryDAOImpl implements ScheduleQueryDAO { - @PersistenceContext - private EntityManager manager; - - @Override - public List searchSchedules(String where, int limit) { - StringBuilder sql = new StringBuilder(); - sql.append("select distinct" + " ss.uuid as uuid" + " from" + " SCHEDULES ss" - + " left outer join CHANGE_MANAGEMENT_GROUPS g on ss.uuid = g.schedules_uuid" - + " left outer join CHANGE_MANAGEMENT_SCHEDULES s on g.uuid = s.change_management_group_uuid" - + " left outer join DOMAIN_DATA dd on ss.uuid = dd.schedules_uuid" - + " left outer join SCHEDULE_APPROVALS sa on ss.uuid = sa.schedules_uuid" - + " left outer join APPROVAL_TYPES at on sa.approval_types_uuid = at.uuid "); - sql.append(where); - sql.append(" order by uuid "); - if (limit > 0) { - sql.append("LIMIT " + limit); - } - - Query qry = manager.createNativeQuery(sql.toString(), ScheduleQuery.class); - List list = qry.getResultList(); - return list; - } -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDao.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDao.java new file mode 100644 index 0000000..14a9a13 --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDao.java @@ -0,0 +1,41 @@ +/* + * 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. +*/ + +package org.onap.optf.cmso.model.dao; + +import java.util.List; +import org.onap.optf.cmso.model.ScheduleQuery; + +public interface ScheduleQueryDao { + + List searchSchedules(String where, int limit); + +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDaoImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDaoImpl.java new file mode 100644 index 0000000..7b2def6 --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDaoImpl.java @@ -0,0 +1,65 @@ +/* + * 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. +*/ + +package org.onap.optf.cmso.model.dao; + +import java.util.List; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; +import org.onap.optf.cmso.model.ScheduleQuery; +import org.springframework.stereotype.Repository; + +@Repository +public class ScheduleQueryDaoImpl implements ScheduleQueryDao { + @PersistenceContext + private EntityManager manager; + + @Override + public List searchSchedules(String where, int limit) { + StringBuilder sql = new StringBuilder(); + sql.append("select distinct" + " ss.uuid as uuid" + " from" + " SCHEDULES ss" + + " left outer join CHANGE_MANAGEMENT_GROUPS g on ss.uuid = g.schedules_uuid" + + " left outer join CHANGE_MANAGEMENT_SCHEDULES s on g.uuid = s.change_management_group_uuid" + + " left outer join DOMAIN_DATA dd on ss.uuid = dd.schedules_uuid" + + " left outer join SCHEDULE_APPROVALS sa on ss.uuid = sa.schedules_uuid" + + " left outer join APPROVAL_TYPES at on sa.approval_types_uuid = at.uuid "); + sql.append(where); + sql.append(" order by uuid "); + if (limit > 0) { + sql.append("LIMIT " + limit); + } + + Query qry = manager.createNativeQuery(sql.toString(), ScheduleQuery.class); + List list = qry.getResultList(); + return list; + } +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CmsoOptimizerClient.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CmsoOptimizerClient.java index 898339a..269c4b5 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CmsoOptimizerClient.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CmsoOptimizerClient.java @@ -45,13 +45,13 @@ 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.CmsoStatusEnum; import org.onap.optf.cmso.common.LogMessages; import org.onap.optf.cmso.common.PropertiesManagement; import org.onap.optf.cmso.filters.CmsoClientFilters; import org.onap.optf.cmso.model.DomainData; import org.onap.optf.cmso.model.Schedule; -import org.onap.optf.cmso.model.dao.ScheduleDAO; +import org.onap.optf.cmso.model.dao.ScheduleDao; import org.onap.optf.cmso.optimizer.model.OptimizerElementInfo; import org.onap.optf.cmso.optimizer.model.OptimizerRequest; import org.onap.optf.cmso.optimizer.model.OptimizerResponse; @@ -72,7 +72,7 @@ public class CmsoOptimizerClient { private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); @Autowired - ScheduleDAO scheduleDao; + ScheduleDao scheduleDao; @Autowired Environment env; @@ -93,10 +93,10 @@ public class CmsoOptimizerClient { try { // Ensure that only one cmso is requsting this call to optimizer Schedule schedule = scheduleDao.lockOne(uuid); - if (schedule.getStatus().equals(CMSStatusEnum.PendingSchedule.toString())) { + if (schedule.getStatus().equals(CmsoStatusEnum.PendingSchedule.toString())) { scheduleNewOptimization(schedule); } - if (schedule.getStatus().equals(CMSStatusEnum.OptimizationInProgress.toString())) { + if (schedule.getStatus().equals(CmsoStatusEnum.OptimizationInProgress.toString())) { pollOptimizer(schedule); } return; @@ -121,7 +121,7 @@ public class CmsoOptimizerClient { // message, try the next one. We don't want bad data to // if (schedule.getOptimizerAttemptsToSchedule() >= maxAttempts) { - schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString()); + schedule.setStatus(CmsoStatusEnum.OptimizationFailed.toString()); schedule.setOptimizerMessage("Maximum number of attempts exceeded " + maxAttempts); updateScheduleStatus(schedule); return; @@ -134,7 +134,7 @@ public class CmsoOptimizerClient { } } catch (Exception e) { Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString()); + schedule.setStatus(CmsoStatusEnum.OptimizationFailed.toString()); schedule.setOptimizerMessage("Unexpected exception: " + e.getMessage()); updateScheduleStatus(schedule); return; @@ -168,7 +168,7 @@ public class CmsoOptimizerClient { // schedule.setOptimizerTransactionId(cmReq.getRequestId()); schedule.setOptimizerDateTimeMillis(System.currentTimeMillis()); - schedule.setStatus(CMSStatusEnum.OptimizationInProgress.toString()); + schedule.setStatus(CmsoStatusEnum.OptimizationInProgress.toString()); updateScheduleStatus(schedule); debug.debug("optimizer url / user: " + optimizerurl + " / " + username); debug.debug("optimizer Request: " + new ObjectMapper().writeValueAsString(cmReq)); @@ -193,7 +193,7 @@ public class CmsoOptimizerClient { schedule.setOptimizerStatus("HTTP Status: " + response.getStatus()); String message = response.readEntity(String.class); schedule.setOptimizerMessage(message); - schedule.setStatus(CMSStatusEnum.ScheduleFailed.toString()); + schedule.setStatus(CmsoStatusEnum.ScheduleFailed.toString()); // Need to understand the cause of this error. May be teh same as optimizer // down. int tries = schedule.getOptimizerAttemptsToSchedule(); @@ -209,7 +209,7 @@ public class CmsoOptimizerClient { schedule.setOptimizerDateTimeMillis(System.currentTimeMillis()); int tries = schedule.getOptimizerAttemptsToSchedule(); tries++; - schedule.setStatus(CMSStatusEnum.ScheduleFailed.toString()); + schedule.setStatus(CmsoStatusEnum.ScheduleFailed.toString()); schedule.setOptimizerAttemptsToSchedule(tries); String message = response.readEntity(String.class); schedule.setOptimizerMessage(message); @@ -223,7 +223,7 @@ public class CmsoOptimizerClient { } catch (ResponseProcessingException e) { schedule.setOptimizerDateTimeMillis(System.currentTimeMillis()); schedule.setOptimizerStatus("Failed to parse optimizer response"); - schedule.setStatus(CMSStatusEnum.ScheduleFailed.toString()); + schedule.setStatus(CmsoStatusEnum.ScheduleFailed.toString()); // Need to understand the cause of this error. May be teh same as optimizer down. int tries = schedule.getOptimizerAttemptsToSchedule(); tries++; @@ -235,7 +235,7 @@ public class CmsoOptimizerClient { } catch (ProcessingException e) { // Don't track number of retries on IO error (optimizer is down) schedule.setOptimizerDateTimeMillis(System.currentTimeMillis()); - schedule.setStatus(CMSStatusEnum.PendingSchedule.toString()); + schedule.setStatus(CmsoStatusEnum.PendingSchedule.toString()); updateScheduleStatus(schedule); /// Cannot connect to optimizer Observation.report(LogMessages.OPTIMIZER_EXCEPTION, e, e.getMessage()); @@ -264,7 +264,7 @@ public class CmsoOptimizerClient { } Long now = System.currentTimeMillis(); if (now > schedule.getOptimizerDateTimeMillis() + (timeout * 1000)) { - schedule.setStatus(CMSStatusEnum.ScheduleFailed.toString()); + schedule.setStatus(CmsoStatusEnum.ScheduleFailed.toString()); updateScheduleStatus(schedule); return; } @@ -299,7 +299,7 @@ public class CmsoOptimizerClient { schedule.setOptimizerStatus("HTTP Status: " + response.getStatus()); String message = response.readEntity(String.class); schedule.setOptimizerMessage(message); - schedule.setStatus(CMSStatusEnum.ScheduleFailed.toString()); + schedule.setStatus(CmsoStatusEnum.ScheduleFailed.toString()); updateScheduleStatus(schedule); Observation.report(LogMessages.OPTIMIZER_EXCEPTION, message); } @@ -308,7 +308,7 @@ public class CmsoOptimizerClient { Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); schedule.setOptimizerDateTimeMillis(System.currentTimeMillis()); schedule.setOptimizerMessage(e.getMessage()); - schedule.setStatus(CMSStatusEnum.ScheduleFailed.toString()); + schedule.setStatus(CmsoStatusEnum.ScheduleFailed.toString()); updateScheduleStatus(schedule); } } @@ -336,7 +336,7 @@ public class CmsoOptimizerClient { Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, "Unable to parse message. Format changed?"); schedule.setOptimizerStatus("Failed to parse optimizer request"); schedule.setOptimizerDateTimeMillis(System.currentTimeMillis()); - schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString()); + schedule.setStatus(CmsoStatusEnum.OptimizationFailed.toString()); scheduleDao.save(schedule); } return null; diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CmsoOptimizerHandler.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CmsoOptimizerHandler.java index cb658bb..7b1dd58 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CmsoOptimizerHandler.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CmsoOptimizerHandler.java @@ -33,17 +33,17 @@ import java.util.List; import java.util.Map; import javax.ws.rs.core.Response.Status; import org.onap.observations.Observation; -import org.onap.optf.cmso.common.CMSStatusEnum; +import org.onap.optf.cmso.common.CmsoStatusEnum; import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.common.exceptions.CMSException; +import org.onap.optf.cmso.common.exceptions.CmsoException; import org.onap.optf.cmso.model.ChangeManagementGroup; import org.onap.optf.cmso.model.ChangeManagementSchedule; import org.onap.optf.cmso.model.Schedule; -import org.onap.optf.cmso.model.dao.ChangeManagementChangeWindowDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementDetailDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementGroupDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO; -import org.onap.optf.cmso.model.dao.ScheduleDAO; +import org.onap.optf.cmso.model.dao.ChangeManagementChangeWindowDao; +import org.onap.optf.cmso.model.dao.ChangeManagementDetailDao; +import org.onap.optf.cmso.model.dao.ChangeManagementGroupDao; +import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao; +import org.onap.optf.cmso.model.dao.ScheduleDao; import org.onap.optf.cmso.optimizer.model.OptimizerResponse; import org.onap.optf.cmso.optimizer.model.OptimizerScheduleInfo; import org.onap.optf.cmso.optimizer.model.ScheduledElement; @@ -63,19 +63,19 @@ public class CmsoOptimizerHandler { Environment env; @Autowired - ChangeManagementScheduleDAO cmScheduleDao; + ChangeManagementScheduleDao cmScheduleDao; @Autowired - ScheduleDAO scheduleDao; + ScheduleDao scheduleDao; @Autowired - ChangeManagementGroupDAO cmGroupDao; + ChangeManagementGroupDao cmGroupDao; @Autowired - ChangeManagementChangeWindowDAO cmChangeWindowDao; + ChangeManagementChangeWindowDao cmChangeWindowDao; @Autowired - ChangeManagementDetailDAO cmDetailsDao; + ChangeManagementDetailDao cmDetailsDao; /** * Handle optimizer response. @@ -88,7 +88,7 @@ public class CmsoOptimizerHandler { // Note that transaction ID and schedule ID are currently the same value. String id = response.getRequestId(); - CMSStatusEnum status = CMSStatusEnum.PendingApproval.fromString(schedule.getStatus()); + CmsoStatusEnum status = CmsoStatusEnum.PendingApproval.fromString(schedule.getStatus()); debug.debug("Status at time of optimizer status is " + status.toString() + " for " + id); switch (status) { // PendingSchedule may be a valid status in the cases where SNIRO async call @@ -100,8 +100,8 @@ public class CmsoOptimizerHandler { scheduleDao.save(schedule); break; default: - throw new CMSException(Status.PRECONDITION_FAILED, LogMessages.OPTIMIZER_CALLBACK_STATE_ERROR, - CMSStatusEnum.OptimizationInProgress.toString(), schedule.getStatus().toString()); + throw new CmsoException(Status.PRECONDITION_FAILED, LogMessages.OPTIMIZER_CALLBACK_STATE_ERROR, + CmsoStatusEnum.OptimizationInProgress.toString(), schedule.getStatus().toString()); } } catch (Exception e) { Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); @@ -118,7 +118,7 @@ public class CmsoOptimizerHandler { saveSchedules(response, schedule); break; case FAILED: - schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString()); + schedule.setStatus(CmsoStatusEnum.OptimizationFailed.toString()); break; case PENDING_OPTIMIZER: case PENDING_TICKETS: @@ -129,20 +129,20 @@ public class CmsoOptimizerHandler { break; } scheduleDao.save(schedule); - } catch (CMSException e) { + } catch (CmsoException e) { Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString()); + schedule.setStatus(CmsoStatusEnum.OptimizationFailed.toString()); schedule.setOptimizerStatus(e.getStatus().toString()); schedule.setOptimizerMessage(e.getLocalizedMessage()); } catch (Exception e) { Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString()); + schedule.setStatus(CmsoStatusEnum.OptimizationFailed.toString()); schedule.setOptimizerStatus("Exception"); schedule.setOptimizerMessage(e.getLocalizedMessage()); } } - private void saveSchedules(OptimizerResponse response, Schedule schedule) throws CMSException { + private void saveSchedules(OptimizerResponse response, Schedule schedule) throws CmsoException { // TODO: Persist the list of schedules in the DB @@ -153,12 +153,12 @@ public class CmsoOptimizerHandler { OptimizerScheduleInfo osi = chooseSchedule(schedules); if (osi == null) { - schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString()); + schedule.setStatus(CmsoStatusEnum.OptimizationFailed.toString()); schedule.setOptimizerMessage("No schedules returned for COMPLETED status"); return; } if (osi.getScheduledElements().size() == 0) { - schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString()); + schedule.setStatus(CmsoStatusEnum.OptimizationFailed.toString()); schedule.setOptimizerMessage("No elements scheduled for COMPLETED status"); return; } @@ -174,7 +174,7 @@ public class CmsoOptimizerHandler { cmScheduleDao.findOneByScheduleUuidGroupIdAndVnfName(schedule.getUuid(), groupId, vnfName); cms.setStartTimeMillis(element.getStartTime().getTime()); cms.setFinishTimeMillis(element.getEndTime().getTime()); - cms.setStatus(CMSStatusEnum.PendingApproval.toString()); + cms.setStatus(CmsoStatusEnum.PendingApproval.toString()); cmScheduleDao.save(cms); } if (osi.getUnScheduledElements() != null) { @@ -183,7 +183,7 @@ public class CmsoOptimizerHandler { String vnfName = element.getElementId(); ChangeManagementSchedule cms = cmScheduleDao.findOneByScheduleUuidGroupIdAndVnfName(schedule.getUuid(), groupId, vnfName); - cms.setStatus(CMSStatusEnum.NotScheduled.toString()); + cms.setStatus(CmsoStatusEnum.NotScheduled.toString()); cmScheduleDao.save(cms); } @@ -193,7 +193,7 @@ public class CmsoOptimizerHandler { for (ChangeManagementGroup cmg : updatedGroups.values()) { cmGroupDao.save(cmg); } - schedule.setStatus(CMSStatusEnum.PendingApproval.toString()); + schedule.setStatus(CmsoStatusEnum.PendingApproval.toString()); } private void updateGroup(ScheduledElement element, List groups, @@ -214,7 +214,7 @@ public class CmsoOptimizerHandler { } } if (cmg == null) { - throw new CMSException(Status.INTERNAL_SERVER_ERROR, LogMessages.MISSING_VALID_GROUP_FOR_ELEMENT, + throw new CmsoException(Status.INTERNAL_SERVER_ERROR, LogMessages.MISSING_VALID_GROUP_FOR_ELEMENT, element.getElementId()); } Long elementStartTime = element.getStartTime().getTime(); 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 0021c0d..e5bbd52 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 @@ -44,13 +44,13 @@ 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.CmsoStatusEnum; import org.onap.optf.cmso.common.DomainsEnum; import org.onap.optf.cmso.common.LogMessages; 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.onap.optf.cmso.model.dao.ScheduleDao; import org.quartz.DisallowConcurrentExecution; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; @@ -71,7 +71,7 @@ public class OptimizerQuartzJob extends QuartzJobBean { private static EELFLogger errors = EELFManager.getInstance().getErrorLogger(); @Autowired - ScheduleDAO scheduleDao; + ScheduleDao scheduleDao; @Autowired PropertiesManagement pm; @@ -96,12 +96,12 @@ public class OptimizerQuartzJob extends QuartzJobBean { // schedule the request and update the status to PendingSchedule // and update the state to OptimizationInProgress List schedules = scheduleDao.findByDomainStatus(DomainsEnum.ChangeManagement.toString(), - CMSStatusEnum.PendingSchedule.toString()); + CmsoStatusEnum.PendingSchedule.toString()); for (Schedule s : schedules) { scheduleOptimization(s); } List inProgressSchedules = scheduleDao.findByDomainStatus(DomainsEnum.ChangeManagement.toString(), - CMSStatusEnum.OptimizationInProgress.toString()); + CmsoStatusEnum.OptimizationInProgress.toString()); for (Schedule s : inProgressSchedules) { scheduleOptimization(s); } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMOptimizerRequest.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMOptimizerRequest.java deleted file mode 100644 index e9e80c4..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMOptimizerRequest.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso.optimizer.bean; - -public class CMOptimizerRequest { - - /* - * - * { "schedulingInfo": { "scheduleId": "CM-<__SCHEDULE ID__>", "startTime": - * "2017-02-15T00:00:00+05:00", "endTime": "2017-02-18T23:59:00+05:00", - * "normalDurationInSecs": 60, "additionalDurationInSecs": 0, // for backout - * "concurrencyLimit": 10, "policyId": ["SNIRO.TimeLimitAndVerticalTopology"], - * "vnfDetails": [{ “nodeâ€?: "satmo415vbc", “groupIdâ€?: “group1â€?//optional }, { - * “nodeâ€?: "satmo415vbc", “groupIdâ€?: “group1â€?//optional }] }, "requestInfo": { - * “transactionIdâ€?: â€?__TRANSACTIONID__â€?, //logging "requestId": - * "CM-<__SCHEDULE ID__>", "sourceId": "cm-portal", “optimizerâ€?: [“schedulingâ€?], - * "callbackUrl": "http://callbackurl.onap.org:8080/callback" } } - * - */ - - private CMSchedulingInfo schedulingInfo; - private CMRequestInfo requestInfo; - - public CMOptimizerRequest() { - schedulingInfo = new CMSchedulingInfo(); - requestInfo = new CMRequestInfo(); - } - - public CMSchedulingInfo getSchedulingInfo() { - return schedulingInfo; - } - - public void setSchedulingInfo(CMSchedulingInfo schedulingInfo) { - this.schedulingInfo = schedulingInfo; - } - - public CMRequestInfo getRequestInfo() { - return requestInfo; - } - - public void setRequestInfo(CMRequestInfo requestInfo) { - this.requestInfo = requestInfo; - } - -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMOptimizerResponse.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMOptimizerResponse.java deleted file mode 100644 index 6dd7bdf..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMOptimizerResponse.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso.optimizer.bean; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -@ApiModel(value = "Response from schedule optimizer", - description = "Asynchronous response to schedule oprimizer request.") -public class CMOptimizerResponse { - - /* - * - * { "transactionId": "dummy-transaction-id", - * "scheduleId":"CM-<__SCHEDULE ID__>", "requestState": "complete", "status": - * "Optimal", // diagnostic code "description": "Optimal solution found", // - * diagnostic code "schedule": [ { "groupId": "grp06", "startTime": - * "2016-10-01T00:30:00+05:00", // starting time for this group (In 1707, - * seconds will always be zero but there is no reason to hardcode that decision) - * "finishTime": "2016-10-01T00:40:00+05:00", // endtime for this group - * (including failover) "latestInstanceStartTime": "2016-10-01T00:38:00Z", // - * latest time when an instance of this group can be started "node": [ "up01", - * "up03", "up09" ] // list of instances for this group. } ] } - * - */ - - @ApiModelProperty(value = "Unique id of optimization request.") - private String transactionId; - - @ApiModelProperty(value = "Schedule id for which the optimization request was executed.") - private String scheduleId; - - @ApiModelProperty(value = "State of the request as reported by the optimizer.") - private String requestState; - - @ApiModelProperty(value = "Status of the request.") - private String status; - - @ApiModelProperty(value = "Description of the request status.") - private String description; - - @ApiModelProperty(value = "List of schedules returned, one per group. Only 1 group supported at this time.") - private CMSchedule[] schedule; - - public CMOptimizerResponse() {} - - public String getTransactionId() { - return transactionId; - } - - public void setTransactionId(String transactionId) { - this.transactionId = transactionId; - } - - public String getScheduleId() { - return scheduleId; - } - - public void setScheduleId(String scheduleId) { - this.scheduleId = scheduleId; - } - - public String getRequestState() { - return requestState; - } - - public void setRequestState(String requestState) { - this.requestState = requestState; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public CMSchedule[] getSchedule() { - return schedule; - } - - public void setSchedule(CMSchedule[] schedule) { - this.schedule = schedule; - } - -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMRequestInfo.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMRequestInfo.java deleted file mode 100644 index 5d8ee69..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMRequestInfo.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso.optimizer.bean; - -public class CMRequestInfo { - private String transactionId; - private String requestId; - private String sourceId; - private String[] optimizer; - private String callbackUrl; - - public CMRequestInfo() {} - - public String getTransactionId() { - return transactionId; - } - - public void setTransactionId(String transactionId) { - this.transactionId = transactionId; - } - - public String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public String getSourceId() { - return sourceId; - } - - public void setSourceId(String sourceId) { - this.sourceId = sourceId; - } - - public String[] getOptimizer() { - return optimizer; - } - - public void setOptimizer(String[] optimizer) { - this.optimizer = optimizer; - } - - public String getCallbackUrl() { - return callbackUrl; - } - - public void setCallbackUrl(String callbackUrl) { - this.callbackUrl = callbackUrl; - } - -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMSchedule.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMSchedule.java deleted file mode 100644 index 184e782..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMSchedule.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso.optimizer.bean; - -import java.util.ArrayList; -import java.util.List; - -public class CMSchedule { - private String groupId; - private String startTime; - private String finishTime; - private String latestInstanceStartTime; - private List node; - - public CMSchedule() { - node = new ArrayList(); - } - - public String getGroupId() { - return groupId; - } - - public void setGroupId(String groupId) { - this.groupId = groupId; - } - - public String getStartTime() { - return startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getFinishTime() { - return finishTime; - } - - public void setFinishTime(String finishTime) { - this.finishTime = finishTime; - } - - public String getLatestInstanceStartTime() { - return latestInstanceStartTime; - } - - public void setLatestInstanceStartTime(String latestInstanceStartTime) { - this.latestInstanceStartTime = latestInstanceStartTime; - } - - public List getNode() { - return node; - } - - public void setNode(List node) { - this.node = node; - } - -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMSchedulingInfo.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMSchedulingInfo.java deleted file mode 100644 index 5e86dd7..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMSchedulingInfo.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso.optimizer.bean; - -public class CMSchedulingInfo { - private String scheduleId; - private String startTime; - private String endTime; - private int normalDurationInSecs; - private int additionalDurationInSecs; - private int concurrencyLimit; - private String[] policyId; - private CMVnfDetails[] vnfDetails; - - public CMSchedulingInfo() {} - - public String getScheduleId() { - return scheduleId; - } - - public void setScheduleId(String scheduleId) { - this.scheduleId = scheduleId; - } - - public String getStartTime() { - return startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public int getNormalDurationInSecs() { - return normalDurationInSecs; - } - - public void setNormalDurationInSecs(int normalDurationInSecs) { - this.normalDurationInSecs = normalDurationInSecs; - } - - public int getAdditionalDurationInSecs() { - return additionalDurationInSecs; - } - - public void setAdditionalDurationInSecs(int additionalDurationInSecs) { - this.additionalDurationInSecs = additionalDurationInSecs; - } - - public int getConcurrencyLimit() { - return concurrencyLimit; - } - - public void setConcurrencyLimit(int concurrencyLimit) { - this.concurrencyLimit = concurrencyLimit; - } - - public String[] getPolicyId() { - return policyId; - } - - public void setPolicyId(String[] policyId) { - this.policyId = policyId; - } - - public CMVnfDetails[] getVnfDetails() { - return vnfDetails; - } - - public void setVnfDetails(CMVnfDetails[] vnfDetails) { - this.vnfDetails = vnfDetails; - } - -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMVnfDetails.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMVnfDetails.java deleted file mode 100644 index 4da1ab1..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMVnfDetails.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso.optimizer.bean; - -public class CMVnfDetails { - private String node; - private String groupId; - - public CMVnfDetails() {} - - public CMVnfDetails(String groupId) { - this.groupId = groupId; - } - - public String getNode() { - return node; - } - - public void setNode(String node) { - this.node = node; - } - - public String getGroupId() { - return groupId; - } - - public void setGroupId(String groupId) { - this.groupId = groupId; - } - -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoOptimizerRequest.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoOptimizerRequest.java new file mode 100644 index 0000000..05ab753 --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoOptimizerRequest.java @@ -0,0 +1,74 @@ +/* + * 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. +*/ + +package org.onap.optf.cmso.optimizer.bean; + +public class CmsoOptimizerRequest { + + /* + * + * { "schedulingInfo": { "scheduleId": "CM-<__SCHEDULE ID__>", "startTime": + * "2017-02-15T00:00:00+05:00", "endTime": "2017-02-18T23:59:00+05:00", + * "normalDurationInSecs": 60, "additionalDurationInSecs": 0, // for backout + * "concurrencyLimit": 10, "policyId": ["SNIRO.TimeLimitAndVerticalTopology"], + * "vnfDetails": [{ “node�?: "satmo415vbc", “groupId�?: “group1�?//optional }, { + * “node�?: "satmo415vbc", “groupId�?: “group1�?//optional }] }, "requestInfo": { + * “transactionId�?: �?__TRANSACTIONID__�?, //logging "requestId": + * "CM-<__SCHEDULE ID__>", "sourceId": "cm-portal", “optimizer�?: [“scheduling�?], + * "callbackUrl": "http://callbackurl.onap.org:8080/callback" } } + * + */ + + private CmsoSchedulingInfo schedulingInfo; + private CmsoRequestInfo requestInfo; + + public CmsoOptimizerRequest() { + schedulingInfo = new CmsoSchedulingInfo(); + requestInfo = new CmsoRequestInfo(); + } + + public CmsoSchedulingInfo getSchedulingInfo() { + return schedulingInfo; + } + + public void setSchedulingInfo(CmsoSchedulingInfo schedulingInfo) { + this.schedulingInfo = schedulingInfo; + } + + public CmsoRequestInfo getRequestInfo() { + return requestInfo; + } + + public void setRequestInfo(CmsoRequestInfo requestInfo) { + this.requestInfo = requestInfo; + } + +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoOptimizerResponse.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoOptimizerResponse.java new file mode 100644 index 0000000..1660866 --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoOptimizerResponse.java @@ -0,0 +1,124 @@ +/* + * 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. +*/ + +package org.onap.optf.cmso.optimizer.bean; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@ApiModel(value = "Response from schedule optimizer", + description = "Asynchronous response to schedule oprimizer request.") +public class CmsoOptimizerResponse { + + /* + * + * { "transactionId": "dummy-transaction-id", + * "scheduleId":"CM-<__SCHEDULE ID__>", "requestState": "complete", "status": + * "Optimal", // diagnostic code "description": "Optimal solution found", // + * diagnostic code "schedule": [ { "groupId": "grp06", "startTime": + * "2016-10-01T00:30:00+05:00", // starting time for this group (In 1707, + * seconds will always be zero but there is no reason to hardcode that decision) + * "finishTime": "2016-10-01T00:40:00+05:00", // endtime for this group + * (including failover) "latestInstanceStartTime": "2016-10-01T00:38:00Z", // + * latest time when an instance of this group can be started "node": [ "up01", + * "up03", "up09" ] // list of instances for this group. } ] } + * + */ + + @ApiModelProperty(value = "Unique id of optimization request.") + private String transactionId; + + @ApiModelProperty(value = "Schedule id for which the optimization request was executed.") + private String scheduleId; + + @ApiModelProperty(value = "State of the request as reported by the optimizer.") + private String requestState; + + @ApiModelProperty(value = "Status of the request.") + private String status; + + @ApiModelProperty(value = "Description of the request status.") + private String description; + + @ApiModelProperty(value = "List of schedules returned, one per group. Only 1 group supported at this time.") + private CmsoSchedule[] schedule; + + public CmsoOptimizerResponse() {} + + public String getTransactionId() { + return transactionId; + } + + public void setTransactionId(String transactionId) { + this.transactionId = transactionId; + } + + public String getScheduleId() { + return scheduleId; + } + + public void setScheduleId(String scheduleId) { + this.scheduleId = scheduleId; + } + + public String getRequestState() { + return requestState; + } + + public void setRequestState(String requestState) { + this.requestState = requestState; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public CmsoSchedule[] getSchedule() { + return schedule; + } + + public void setSchedule(CmsoSchedule[] schedule) { + this.schedule = schedule; + } + +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoRequestInfo.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoRequestInfo.java new file mode 100644 index 0000000..dd74db2 --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoRequestInfo.java @@ -0,0 +1,83 @@ +/* + * 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. +*/ + +package org.onap.optf.cmso.optimizer.bean; + +public class CmsoRequestInfo { + private String transactionId; + private String requestId; + private String sourceId; + private String[] optimizer; + private String callbackUrl; + + public CmsoRequestInfo() {} + + public String getTransactionId() { + return transactionId; + } + + public void setTransactionId(String transactionId) { + this.transactionId = transactionId; + } + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public String getSourceId() { + return sourceId; + } + + public void setSourceId(String sourceId) { + this.sourceId = sourceId; + } + + public String[] getOptimizer() { + return optimizer; + } + + public void setOptimizer(String[] optimizer) { + this.optimizer = optimizer; + } + + public String getCallbackUrl() { + return callbackUrl; + } + + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoSchedule.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoSchedule.java new file mode 100644 index 0000000..0d56fbd --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoSchedule.java @@ -0,0 +1,88 @@ +/* + * 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. +*/ + +package org.onap.optf.cmso.optimizer.bean; + +import java.util.ArrayList; +import java.util.List; + +public class CmsoSchedule { + private String groupId; + private String startTime; + private String finishTime; + private String latestInstanceStartTime; + private List node; + + public CmsoSchedule() { + node = new ArrayList(); + } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getFinishTime() { + return finishTime; + } + + public void setFinishTime(String finishTime) { + this.finishTime = finishTime; + } + + public String getLatestInstanceStartTime() { + return latestInstanceStartTime; + } + + public void setLatestInstanceStartTime(String latestInstanceStartTime) { + this.latestInstanceStartTime = latestInstanceStartTime; + } + + public List getNode() { + return node; + } + + public void setNode(List node) { + this.node = node; + } + +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoSchedulingInfo.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoSchedulingInfo.java new file mode 100644 index 0000000..840cbb7 --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoSchedulingInfo.java @@ -0,0 +1,110 @@ +/* + * 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. +*/ + +package org.onap.optf.cmso.optimizer.bean; + +public class CmsoSchedulingInfo { + private String scheduleId; + private String startTime; + private String endTime; + private int normalDurationInSecs; + private int additionalDurationInSecs; + private int concurrencyLimit; + private String[] policyId; + private CmsoVnfDetails[] vnfDetails; + + public CmsoSchedulingInfo() {} + + public String getScheduleId() { + return scheduleId; + } + + public void setScheduleId(String scheduleId) { + this.scheduleId = scheduleId; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public int getNormalDurationInSecs() { + return normalDurationInSecs; + } + + public void setNormalDurationInSecs(int normalDurationInSecs) { + this.normalDurationInSecs = normalDurationInSecs; + } + + public int getAdditionalDurationInSecs() { + return additionalDurationInSecs; + } + + public void setAdditionalDurationInSecs(int additionalDurationInSecs) { + this.additionalDurationInSecs = additionalDurationInSecs; + } + + public int getConcurrencyLimit() { + return concurrencyLimit; + } + + public void setConcurrencyLimit(int concurrencyLimit) { + this.concurrencyLimit = concurrencyLimit; + } + + public String[] getPolicyId() { + return policyId; + } + + public void setPolicyId(String[] policyId) { + this.policyId = policyId; + } + + public CmsoVnfDetails[] getVnfDetails() { + return vnfDetails; + } + + public void setVnfDetails(CmsoVnfDetails[] vnfDetails) { + this.vnfDetails = vnfDetails; + } + +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoVnfDetails.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoVnfDetails.java new file mode 100644 index 0000000..4ee6053 --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoVnfDetails.java @@ -0,0 +1,60 @@ +/* + * 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. +*/ + +package org.onap.optf.cmso.optimizer.bean; + +public class CmsoVnfDetails { + private String node; + private String groupId; + + public CmsoVnfDetails() {} + + public CmsoVnfDetails(String groupId) { + this.groupId = groupId; + } + + public String getNode() { + return node; + } + + public void setNode(String node) { + this.node = node; + } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/BaseSchedulerServiceImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/BaseSchedulerServiceImpl.java index 816a80e..faea625 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/BaseSchedulerServiceImpl.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/BaseSchedulerServiceImpl.java @@ -35,19 +35,19 @@ import java.util.Map; import java.util.UUID; import javax.ws.rs.core.Response.Status; import org.onap.optf.cmso.common.ApprovalStatusEnum; -import org.onap.optf.cmso.common.CMSStatusEnum; +import org.onap.optf.cmso.common.CmsoStatusEnum; import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.common.exceptions.CMSAlreadyExistsException; -import org.onap.optf.cmso.common.exceptions.CMSException; -import org.onap.optf.cmso.common.exceptions.CMSNotFoundException; +import org.onap.optf.cmso.common.exceptions.CmsoAlreadyExistsException; +import org.onap.optf.cmso.common.exceptions.CmsoException; +import org.onap.optf.cmso.common.exceptions.CmsoNotFoundException; import org.onap.optf.cmso.model.ApprovalType; import org.onap.optf.cmso.model.DomainData; import org.onap.optf.cmso.model.Schedule; import org.onap.optf.cmso.model.ScheduleApproval; -import org.onap.optf.cmso.model.dao.ApprovalTypeDAO; -import org.onap.optf.cmso.model.dao.DomainDataDAO; -import org.onap.optf.cmso.model.dao.ScheduleApprovalDAO; -import org.onap.optf.cmso.model.dao.ScheduleDAO; +import org.onap.optf.cmso.model.dao.ApprovalTypeDao; +import org.onap.optf.cmso.model.dao.DomainDataDao; +import org.onap.optf.cmso.model.dao.ScheduleApprovalDao; +import org.onap.optf.cmso.model.dao.ScheduleDao; import org.onap.optf.cmso.service.rs.models.ApprovalMessage; import org.onap.optf.cmso.service.rs.models.v2.OptimizedScheduleMessage; import org.springframework.beans.factory.annotation.Autowired; @@ -58,24 +58,24 @@ public class BaseSchedulerServiceImpl { private static EELFLogger log = EELFManager.getInstance().getLogger(BaseSchedulerServiceImpl.class); @Autowired - protected ScheduleDAO scheduleDao; + protected ScheduleDao scheduleDao; @Autowired - DomainDataDAO domainDataDao; + DomainDataDao domainDataDao; @Autowired - ApprovalTypeDAO approvalTypeDao; + ApprovalTypeDao approvalTypeDao; @Autowired - ScheduleApprovalDAO scheduleApprovalDao; + ScheduleApprovalDao scheduleApprovalDao; protected Schedule validateAndAddScheduleRequest(OptimizedScheduleMessage scheduleMessage, - List domainData) throws CMSException { + List domainData) throws CmsoException { messageValidations(scheduleMessage); Schedule sch = scheduleDao.findByDomainScheduleId(scheduleMessage.getDomain(), scheduleMessage.getScheduleId()); if (sch != null) { - throw new CMSAlreadyExistsException(scheduleMessage.getDomain(), scheduleMessage.getScheduleId()); + throw new CmsoAlreadyExistsException(scheduleMessage.getDomain(), scheduleMessage.getScheduleId()); } sch = new Schedule(); sch.setUuid(UUID.randomUUID()); @@ -90,7 +90,7 @@ public class BaseSchedulerServiceImpl { sch.setScheduleName(scheduleMessage.getScheduleName()); sch.setOptimizerAttemptsToSchedule(0); sch.setScheduleInfo(scheduleMessage.getSchedulingData().toString()); - sch.setStatus(CMSStatusEnum.PendingSchedule.toString()); + sch.setStatus(CmsoStatusEnum.PendingSchedule.toString()); scheduleDao.save(sch); for (DomainData dd : domainData) { dd.setUuid(UUID.randomUUID()); @@ -101,51 +101,51 @@ public class BaseSchedulerServiceImpl { return sch; } - private void messageValidations(OptimizedScheduleMessage scheduleMessage) throws CMSException { + private void messageValidations(OptimizedScheduleMessage scheduleMessage) throws CmsoException { if (scheduleMessage.getScheduleName() == null || scheduleMessage.getScheduleName().equals("")) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "schedulerName", ""); + throw new CmsoException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "schedulerName", ""); } if (scheduleMessage.getUserId() == null || scheduleMessage.getUserId().equals("")) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "userId", ""); + throw new CmsoException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "userId", ""); } } - protected void deleteScheduleRequest(String domain, String scheduleId) throws CMSException { + protected void deleteScheduleRequest(String domain, String scheduleId) throws CmsoException { Schedule sch = scheduleDao.findByDomainScheduleId(domain, scheduleId); if (sch == null) { - throw new CMSNotFoundException(domain, scheduleId); + throw new CmsoNotFoundException(domain, scheduleId); } - CMSStatusEnum currentStatus = CMSStatusEnum.Completed.fromString(sch.getStatus()); + CmsoStatusEnum currentStatus = CmsoStatusEnum.Completed.fromString(sch.getStatus()); sch.setDeleteDateTimeMillis(System.currentTimeMillis()); switch (currentStatus) { case Scheduled: // TODO CLose all tickets.... - sch.setStatus(CMSStatusEnum.Cancelled.toString()); + sch.setStatus(CmsoStatusEnum.Cancelled.toString()); break; case NotificationsInitiated: - throw new CMSException(Status.NOT_ACCEPTABLE, LogMessages.CANNOT_CANCEL_IN_PROGRESS); + throw new CmsoException(Status.NOT_ACCEPTABLE, LogMessages.CANNOT_CANCEL_IN_PROGRESS); default: - sch.setStatus(CMSStatusEnum.Deleted.toString()); + sch.setStatus(CmsoStatusEnum.Deleted.toString()); } scheduleDao.save(sch); } protected Schedule processApproval(Schedule sch, String domain, ApprovalMessage approvalMessage) - throws CMSException { + throws CmsoException { String scheduleId = sch.getScheduleId(); ApprovalType approvalType = approvalTypeDao.findByDomainAndType(domain, approvalMessage.getApprovalType().toString()); if (approvalType == null) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, "approvalType", + throw new CmsoException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, "approvalType", approvalMessage.getApprovalType().toString()); } - if (!sch.getStatus().equals(CMSStatusEnum.PendingApproval.toString())) { - throw new CMSException(Status.PRECONDITION_FAILED, LogMessages.NOT_PENDING_APPROVAL, domain, scheduleId, + if (!sch.getStatus().equals(CmsoStatusEnum.PendingApproval.toString())) { + throw new CmsoException(Status.PRECONDITION_FAILED, LogMessages.NOT_PENDING_APPROVAL, domain, scheduleId, sch.getStatus()); } if (approvalMessage.getApprovalUserId() == null || approvalMessage.getApprovalUserId().equals("")) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "userId"); + throw new CmsoException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "userId"); } ScheduleApproval sa = null; // only 1 approval per user.... @@ -171,10 +171,10 @@ public class BaseSchedulerServiceImpl { sch.addScheduleApproval(sa); scheduleDao.save(sch); if (sa.getStatus().equals(ApprovalStatusEnum.Rejected.toString())) { - sch.setStatus(CMSStatusEnum.Rejected.toString()); + sch.setStatus(CmsoStatusEnum.Rejected.toString()); } else { if (allApprovalsReceived(sch, sa)) { - sch.setStatus(CMSStatusEnum.Accepted.toString()); + sch.setStatus(CmsoStatusEnum.Accepted.toString()); } } scheduleDao.save(sch); diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmQueryParameters.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmQueryParameters.java index 2e9ade3..442abe3 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmQueryParameters.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmQueryParameters.java @@ -33,7 +33,7 @@ import javax.ws.rs.core.Response.Status; import org.joda.time.DateTime; import org.joda.time.format.ISODateTimeFormat; import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.common.exceptions.CMSException; +import org.onap.optf.cmso.common.exceptions.CmsoException; import org.onap.optf.cmso.model.DomainData; /** @@ -102,12 +102,12 @@ public class CmQueryParameters { * @param urlName the url name * @param values the values * @return the string - * @throws CMSException the CMS exception + * @throws CmsoException the CMS exception */ - public static String buildClause(String urlName, List values) throws CMSException { + public static String buildClause(String urlName, List values) throws CmsoException { QueryColumns qc = getQueryColumn(urlName); if (qc == null) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.UNDEFINED_FILTER_ATTRIBUTE, urlName); + throw new CmsoException(Status.BAD_REQUEST, LogMessages.UNDEFINED_FILTER_ATTRIBUTE, urlName); } if (qc.type == Date.class) { return formatDate(urlName, values, qc); @@ -169,7 +169,7 @@ public class CmQueryParameters { return clause.toString(); } - private static String formatDate(String urlName, List values, QueryColumns qc) throws CMSException { + private static String formatDate(String urlName, List values, QueryColumns qc) throws CmsoException { List clauses = new ArrayList(); for (String value : values) { String[] dates = value.split(","); @@ -181,7 +181,7 @@ public class CmQueryParameters { formatDatePair(qc, dates[0].trim(), "", clauses); break; default: - throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_DATE_FILTER, urlName, value); + throw new CmsoException(Status.BAD_REQUEST, LogMessages.INVALID_DATE_FILTER, urlName, value); } } StringBuilder clause = new StringBuilder(); @@ -197,7 +197,7 @@ public class CmQueryParameters { } private static void formatDatePair(QueryColumns qc, String lowDate, String highDate, List clauses) - throws CMSException { + throws CmsoException { StringBuilder clause = new StringBuilder(); DateTime date1 = null; DateTime date2 = null; @@ -222,12 +222,12 @@ public class CmQueryParameters { } } - private static DateTime convertDate(String utcDate, String urlName) throws CMSException { + private static DateTime convertDate(String utcDate, String urlName) throws CmsoException { DateTime dateTime = ISODateTimeFormat.dateTimeParser().parseDateTime(utcDate); if (dateTime != null) { return dateTime; } - throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_DATE_FILTER, urlName, utcDate); + throw new CmsoException(Status.BAD_REQUEST, LogMessages.INVALID_DATE_FILTER, urlName, utcDate); } // public static void main(String argv[]) diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizedScheduleService.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizedScheduleService.java index 9874ea8..6236adb 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizedScheduleService.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizedScheduleService.java @@ -43,7 +43,7 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import org.onap.optf.cmso.common.CMSRequestError; +import org.onap.optf.cmso.common.CmsoRequestError; import org.onap.optf.cmso.service.rs.models.v2.OptimizedScheduleMessage; @Api("CMSO Optimized Schedule API") @@ -59,7 +59,7 @@ public interface CmsoOptimizedScheduleService { @ApiResponses( value = {@ApiResponse(code = 202, message = "Schedule request accepted for optimization."), @ApiResponse(code = 409, message = "Schedule request already exists for this schedule id.", - response = CMSRequestError.class), + response = CmsoRequestError.class), @ApiResponse(code = 500, message = "Unexpected Runtime error")}) public Response createScheduleRequest( @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion, diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizedScheduleServiceImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizedScheduleServiceImpl.java index 290d21e..2b6a928 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizedScheduleServiceImpl.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizedScheduleServiceImpl.java @@ -33,7 +33,7 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; import org.onap.observations.Observation; import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.common.exceptions.CMSException; +import org.onap.optf.cmso.common.exceptions.CmsoException; import org.onap.optf.cmso.service.rs.models.v2.OptimizedScheduleMessage; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; @@ -63,7 +63,7 @@ public class CmsoOptimizedScheduleServiceImpl extends CommonServiceImpl implemen try { createSchedule(scheduleMessage, scheduleId, request); response = Response.accepted().build(); - } catch (CMSException e) { + } catch (CmsoException e) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage()); response = Response.status(e.getStatus()).entity(e.getRequestError()).build(); diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizerCallback.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizerCallback.java index d6cefb6..b6b81e6 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizerCallback.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizerCallback.java @@ -43,7 +43,7 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import org.onap.optf.cmso.optimizer.bean.CMOptimizerResponse; +import org.onap.optf.cmso.optimizer.bean.CmsoOptimizerResponse; @Api("CMSO Optimized Schedule API") @Path("/{apiVersion}") @@ -59,6 +59,6 @@ public interface CmsoOptimizerCallback { @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)}) public Response sniroCallback( @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion, - @ApiParam(value = "Return schedules > lastScheduleId") CMOptimizerResponse reponse); + @ApiParam(value = "Return schedules > lastScheduleId") CmsoOptimizerResponse reponse); } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizerCallbackImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizerCallbackImpl.java index 6a7b1b3..ffe00c5 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizerCallbackImpl.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizerCallbackImpl.java @@ -46,20 +46,20 @@ 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.optf.cmso.common.CMSStatusEnum; +import org.onap.optf.cmso.common.CmsoStatusEnum; import org.onap.optf.cmso.common.DomainsEnum; import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.common.exceptions.CMSException; -import org.onap.optf.cmso.common.exceptions.CMSNotFoundException; +import org.onap.optf.cmso.common.exceptions.CmsoException; +import org.onap.optf.cmso.common.exceptions.CmsoNotFoundException; import org.onap.optf.cmso.model.ChangeManagementGroup; import org.onap.optf.cmso.model.ChangeManagementSchedule; import org.onap.optf.cmso.model.Schedule; -import org.onap.optf.cmso.model.dao.ChangeManagementChangeWindowDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementDetailDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementGroupDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO; -import org.onap.optf.cmso.optimizer.bean.CMOptimizerResponse; -import org.onap.optf.cmso.optimizer.bean.CMSchedule; +import org.onap.optf.cmso.model.dao.ChangeManagementChangeWindowDao; +import org.onap.optf.cmso.model.dao.ChangeManagementDetailDao; +import org.onap.optf.cmso.model.dao.ChangeManagementGroupDao; +import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao; +import org.onap.optf.cmso.optimizer.bean.CmsoOptimizerResponse; +import org.onap.optf.cmso.optimizer.bean.CmsoSchedule; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -80,16 +80,16 @@ public class CmsoOptimizerCallbackImpl extends BaseSchedulerServiceImpl implemen @Autowired - ChangeManagementScheduleDAO cmScheduleDao; + ChangeManagementScheduleDao cmScheduleDao; @Autowired - ChangeManagementGroupDAO cmGroupDao; + ChangeManagementGroupDao cmGroupDao; @Autowired - ChangeManagementChangeWindowDAO cmChangeWindowDao; + ChangeManagementChangeWindowDao cmChangeWindowDao; @Autowired - ChangeManagementDetailDAO cmDetailsDaoO; + ChangeManagementDetailDao cmDetailsDaoO; /** * Sniro callback. @@ -100,7 +100,7 @@ public class CmsoOptimizerCallbackImpl extends BaseSchedulerServiceImpl implemen */ @Override @Transactional - public Response sniroCallback(String apiVersion, CMOptimizerResponse sniroResponse) { + public Response sniroCallback(String apiVersion, CmsoOptimizerResponse sniroResponse) { Response response = null; log.info(LogMessages.PROCESS_OPTIMIZER_CALLBACK, "Received", request.getRemoteAddr(), ""); log.info(LogMessages.OPTIMIZER_REQUEST, "Callback received", sniroResponse.getTransactionId(), @@ -123,11 +123,11 @@ public class CmsoOptimizerCallbackImpl extends BaseSchedulerServiceImpl implemen Schedule schedule = scheduleDao.lockOneByTransactionId(transactionId); if (schedule == null) { - throw new CMSNotFoundException(DomainsEnum.ChangeManagement.toString(), + throw new CmsoNotFoundException(DomainsEnum.ChangeManagement.toString(), "(OptimizerTransactionID=" + transactionId + ")"); } - CMSStatusEnum status = CMSStatusEnum.PendingApproval.fromString(schedule.getStatus()); + CmsoStatusEnum status = CmsoStatusEnum.PendingApproval.fromString(schedule.getStatus()); debug.debug("Status at time of SNIRO callback is " + status.toString()); switch (status) { // PendingSchedule may be a valid status in the cases where SNIRO async call @@ -140,10 +140,10 @@ public class CmsoOptimizerCallbackImpl extends BaseSchedulerServiceImpl implemen response = Response.ok().build(); break; default: - throw new CMSException(Status.PRECONDITION_FAILED, LogMessages.OPTIMIZER_CALLBACK_STATE_ERROR, - CMSStatusEnum.OptimizationInProgress.toString(), schedule.getStatus().toString()); + throw new CmsoException(Status.PRECONDITION_FAILED, LogMessages.OPTIMIZER_CALLBACK_STATE_ERROR, + CmsoStatusEnum.OptimizationInProgress.toString(), schedule.getStatus().toString()); } - } catch (CMSException e) { + } catch (CmsoException e) { errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); response = Response.status(e.getStatus()).entity(e.getRequestError()).build(); } catch (Exception e) { @@ -153,25 +153,25 @@ public class CmsoOptimizerCallbackImpl extends BaseSchedulerServiceImpl implemen return response; } - private void processSniroResponse(CMOptimizerResponse sniroResponse, Schedule schedule) { + private void processSniroResponse(CmsoOptimizerResponse sniroResponse, Schedule schedule) { try { schedule.setOptimizerReturnDateTimeMillis(System.currentTimeMillis()); schedule.setOptimizerStatus(sniroResponse.getRequestState()); schedule.setOptimizerMessage(sniroResponse.getDescription()); String scheduleId = sniroResponse.getScheduleId(); ObjectMapper om = new ObjectMapper(); - CMSchedule[] scheduleArray = sniroResponse.getSchedule(); + CmsoSchedule[] scheduleArray = sniroResponse.getSchedule(); if (scheduleArray != null && scheduleArray.length > 0) { String scheduleString = om.writeValueAsString(scheduleArray); schedule.setSchedule(scheduleString); log.debug("scheduleId={0} schedule={1}", scheduleId, scheduleString); - for (CMSchedule sniroSchedule : sniroResponse.getSchedule()) { + for (CmsoSchedule sniroSchedule : sniroResponse.getSchedule()) { String groupId = sniroSchedule.getGroupId(); DateTime finishTime = convertDate(sniroSchedule.getFinishTime(), "finishTime"); DateTime startTime = convertDate(sniroSchedule.getStartTime(), "startTime"); ChangeManagementGroup group = cmGroupDao.findOneBySchedulesIdGroupId(schedule.getUuid(), groupId); if (group == null) { - throw new CMSException(Status.PRECONDITION_FAILED, + throw new CmsoException(Status.PRECONDITION_FAILED, LogMessages.CHANGE_MANAGEMENT_GROUP_NOT_FOUND, schedule.getScheduleId(), groupId); } group.setStartTimeMillis(startTime.getMillis()); @@ -189,19 +189,19 @@ public class CmsoOptimizerCallbackImpl extends BaseSchedulerServiceImpl implemen processNode(schedule, group, node, startAndFinishTimeMap); } } - schedule.setStatus(CMSStatusEnum.PendingApproval.toString()); + schedule.setStatus(CmsoStatusEnum.PendingApproval.toString()); } else { debug.debug("scheduleId={0} schedule=null status={1} ", scheduleId, schedule.getOptimizerStatus()); - schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString()); + schedule.setStatus(CmsoStatusEnum.OptimizationFailed.toString()); } - } catch (CMSException e) { + } catch (CmsoException e) { errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString()); + schedule.setStatus(CmsoStatusEnum.OptimizationFailed.toString()); schedule.setOptimizerStatus(e.getStatus().toString()); schedule.setOptimizerMessage(e.getLocalizedMessage()); } catch (Exception e) { errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString()); + schedule.setStatus(CmsoStatusEnum.OptimizationFailed.toString()); schedule.setOptimizerStatus("Exception"); schedule.setOptimizerMessage(e.getLocalizedMessage()); } @@ -216,10 +216,10 @@ public class CmsoOptimizerCallbackImpl extends BaseSchedulerServiceImpl implemen * @param totalDuration the total duration * @param nodeList the node list * @param startAndFinishTimeMap the start and finish time map - * @throws CMSException the CMS exception + * @throws CmsoException the CMS exception */ public static void makeMap(Long startTime, Long latestInstanceStartTime, int concurrencyLimit, long totalDuration, - List nodeList, Map> startAndFinishTimeMap) throws CMSException { + List nodeList, Map> startAndFinishTimeMap) throws CmsoException { Long nextStartTime = null; Long nextFinishTime = null; for (int nodeNumber = 0; nodeNumber < nodeList.size(); nodeNumber++) { @@ -231,7 +231,7 @@ public class CmsoOptimizerCallbackImpl extends BaseSchedulerServiceImpl implemen nextStartTime = nextStartTime + totalDuration; } if (nextStartTime > latestInstanceStartTime) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.UNABLE_TO_ALLOCATE_VNF_TIMESLOTS, + throw new CmsoException(Status.BAD_REQUEST, LogMessages.UNABLE_TO_ALLOCATE_VNF_TIMESLOTS, startTime.toString(), latestInstanceStartTime.toString(), String.valueOf(totalDuration), String.valueOf(concurrencyLimit), String.valueOf(nodeList.size())); } @@ -247,17 +247,17 @@ public class CmsoOptimizerCallbackImpl extends BaseSchedulerServiceImpl implemen } private void processNode(Schedule schedule, ChangeManagementGroup group, String node, - Map> startAndFinishTimeMap) throws CMSException { + Map> startAndFinishTimeMap) throws CmsoException { Map map = startAndFinishTimeMap.get(node); ChangeManagementSchedule detail = cmScheduleDao.findOneByGroupUuidAndVnfName(group.getUuid(), node); if (detail == null) { - throw new CMSException(Status.NOT_FOUND, LogMessages.UNABLE_TO_LOCATE_SCHEDULE_DETAIL, + throw new CmsoException(Status.NOT_FOUND, LogMessages.UNABLE_TO_LOCATE_SCHEDULE_DETAIL, schedule.getScheduleId(), group.getGroupId(), node); } detail.setStartTimeMillis(map.get("startTime")); detail.setFinishTimeMillis(map.get("finishTime")); detail.setVnfId(""); - detail.setStatus(CMSStatusEnum.PendingApproval.toString()); + detail.setStatus(CmsoStatusEnum.PendingApproval.toString()); cmScheduleDao.save(detail); } @@ -267,9 +267,9 @@ public class CmsoOptimizerCallbackImpl extends BaseSchedulerServiceImpl implemen * @param utcDate the utc date * @param attrName the attr name * @return the date time - * @throws CMSException the CMS exception + * @throws CmsoException the CMS exception */ - public static DateTime convertDate(String utcDate, String attrName) throws CMSException { + public static DateTime convertDate(String utcDate, String attrName) throws CmsoException { try { DateTime dateTime = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").withZoneUTC().parseDateTime(utcDate); if (dateTime != null) { @@ -278,7 +278,7 @@ public class CmsoOptimizerCallbackImpl extends BaseSchedulerServiceImpl implemen } catch (Exception e) { debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); } - throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, attrName, utcDate); + throw new CmsoException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, attrName, utcDate); } /** @@ -287,9 +287,9 @@ public class CmsoOptimizerCallbackImpl extends BaseSchedulerServiceImpl implemen * @param utcDate the utc date * @param attrName the attr name * @return the date time - * @throws CMSException the CMS exception + * @throws CmsoException the CMS exception */ - public static DateTime convertIsoDate(String utcDate, String attrName) throws CMSException { + public static DateTime convertIsoDate(String utcDate, String attrName) throws CmsoException { try { DateTime dateTime = ISODateTimeFormat.dateTimeParser().parseDateTime(utcDate); if (dateTime != null) { @@ -298,7 +298,7 @@ public class CmsoOptimizerCallbackImpl extends BaseSchedulerServiceImpl implemen } catch (Exception e) { debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); } - throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, attrName, utcDate); + throw new CmsoException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, attrName, utcDate); } } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoService.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoService.java index d9b338e..bf28b1c 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoService.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoService.java @@ -49,7 +49,7 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; -import org.onap.optf.cmso.common.CMSRequestError; +import org.onap.optf.cmso.common.CmsoRequestError; import org.onap.optf.cmso.model.Schedule; import org.onap.optf.cmso.service.rs.models.ApprovalMessage; import org.onap.optf.cmso.service.rs.models.CmDetailsMessage; @@ -66,7 +66,7 @@ public interface CmsoService { @ApiOperation(value = "", notes = "Returns a list of Scheduler Requests based upon the filter criteria.", response = Schedule.class, responseContainer = "List") @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"), - @ApiResponse(code = 404, message = "No records found", response = CMSRequestError.class), + @ApiResponse(code = 404, message = "No records found", response = CmsoRequestError.class), @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)}) public Response searchScheduleRequests( @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion, @@ -92,7 +92,7 @@ public interface CmsoService { @ApiResponses( value = {@ApiResponse(code = 202, message = "Schedule request accepted for optimization."), @ApiResponse(code = 409, message = "Schedule request already exists for this schedule id.", - response = CMSRequestError.class), + response = CmsoRequestError.class), @ApiResponse(code = 500, message = "Unexpected Runtime error")}) public Response createScheduleRequest( @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion, @@ -108,7 +108,7 @@ public interface CmsoService { @Produces({MediaType.APPLICATION_JSON}) @ApiOperation(value = "", notes = "Cancels the schedule request for scheduleId") @ApiResponses(value = {@ApiResponse(code = 204, message = "Delete successful"), - @ApiResponse(code = 404, message = "No record found", response = CMSRequestError.class), + @ApiResponse(code = 404, message = "No record found", response = CmsoRequestError.class), @ApiResponse(code = 500, message = "Unexpected Runtime error")}) public Response deleteScheduleRequest( @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion, @@ -153,7 +153,7 @@ public interface CmsoService { @ApiOperation(value = "", notes = "Returns a list of Schedule request details based upon the filter criteria.", response = CmDetailsMessage.class, responseContainer = "List") @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"), - @ApiResponse(code = 404, message = "No records found", response = CMSRequestError.class), + @ApiResponse(code = 404, message = "No records found", response = CmsoRequestError.class), @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)}) public Response searchScheduleRequestDetails( @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion, 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 7ffd606..b9d0b60 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 @@ -49,21 +49,21 @@ import org.joda.time.DateTime; import org.onap.observations.Observation; import org.onap.optf.cmso.common.DomainsEnum; import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.common.exceptions.CMSException; -import org.onap.optf.cmso.common.exceptions.CMSNotFoundException; -import org.onap.optf.cmso.eventq.CMSQueueJob; +import org.onap.optf.cmso.common.exceptions.CmsoException; +import org.onap.optf.cmso.common.exceptions.CmsoNotFoundException; +import org.onap.optf.cmso.eventq.CmsoQueueJob; import org.onap.optf.cmso.model.ChangeManagementDetail; import org.onap.optf.cmso.model.ChangeManagementGroup; import org.onap.optf.cmso.model.ChangeManagementSchedule; import org.onap.optf.cmso.model.Schedule; import org.onap.optf.cmso.model.ScheduleQuery; -import org.onap.optf.cmso.model.dao.ChangeManagementChangeWindowDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementDetailDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementGroupDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO; -import org.onap.optf.cmso.model.dao.ElementDataDAO; -import org.onap.optf.cmso.model.dao.ScheduleDAO; -import org.onap.optf.cmso.model.dao.ScheduleQueryDAO; +import org.onap.optf.cmso.model.dao.ChangeManagementChangeWindowDao; +import org.onap.optf.cmso.model.dao.ChangeManagementDetailDao; +import org.onap.optf.cmso.model.dao.ChangeManagementGroupDao; +import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao; +import org.onap.optf.cmso.model.dao.ElementDataDao; +import org.onap.optf.cmso.model.dao.ScheduleDao; +import org.onap.optf.cmso.model.dao.ScheduleQueryDao; import org.onap.optf.cmso.service.rs.models.ApprovalMessage; import org.onap.optf.cmso.service.rs.models.ChangeWindowMessage; import org.onap.optf.cmso.service.rs.models.CmDetailsMessage; @@ -90,31 +90,31 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); @Autowired - CMSQueueJob qqJob; + CmsoQueueJob qqJob; @Autowired Environment env; @Autowired - ChangeManagementScheduleDAO cmScheduleDao; + ChangeManagementScheduleDao cmScheduleDao; @Autowired - ChangeManagementGroupDAO cmGroupDao; + ChangeManagementGroupDao cmGroupDao; @Autowired - ChangeManagementChangeWindowDAO cmChangeWindowDao; + ChangeManagementChangeWindowDao cmChangeWindowDao; @Autowired - ChangeManagementDetailDAO cmDetailsDao; + ChangeManagementDetailDao cmDetailsDao; @Autowired - ScheduleQueryDAO scheduleQueryDao; + ScheduleQueryDao scheduleQueryDao; @Autowired - ScheduleDAO scheduleDao; + ScheduleDao scheduleDao; @Autowired - ElementDataDAO elementDataDao; + ElementDataDao elementDataDao; @Autowired TmClient tmClient; @@ -139,7 +139,7 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { // buildWhere(qp, where); List list = scheduleQueryDao.searchSchedules(where.toString(), maxRows); if (list == null || !list.iterator().hasNext()) { - throw new CMSException(Status.NOT_FOUND, LogMessages.SCHEDULE_NOT_FOUND, + throw new CmsoException(Status.NOT_FOUND, LogMessages.SCHEDULE_NOT_FOUND, DomainsEnum.ChangeManagement.toString(), scheduleId); } Iterator iter = list.iterator(); @@ -159,7 +159,7 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { } } response = Response.ok(schedules.toArray(new Schedule[schedules.size()])).build(); - } catch (CMSException e) { + } catch (CmsoException e) { Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage()); response = Response.status(e.getStatus()).entity(e.getRequestError()).build(); } catch (Exception e) { @@ -183,7 +183,7 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { OptimizedScheduleMessage osm = adaptScheduleMessage(scheduleMessage); createSchedule(osm, scheduleId, request); response = Response.accepted().build(); - } catch (CMSException e) { + } catch (CmsoException e) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage()); response = Response.status(e.getStatus()).entity(e.getRequestError()).build(); @@ -198,7 +198,7 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { } private OptimizedScheduleMessage adaptScheduleMessage(CmsoMessage sm) - throws CMSException, JsonParseException, JsonMappingException, IOException { + throws CmsoException, JsonParseException, JsonMappingException, IOException { OptimizedScheduleMessage osm = new OptimizedScheduleMessage(); osm.setScheduleId(sm.getScheduleId()); osm.setDomain(sm.getDomain()); @@ -220,7 +220,7 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { osm.setCommonData(dd); CmsoInfo sinfo = sm.getSchedulingInfo(); if (sinfo == null) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "schedulingInfo"); + throw new CmsoException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "schedulingInfo"); } SchedulingData sd = new SchedulingData(); osm.setSchedulingData(sd); @@ -236,7 +236,7 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { List details = sinfo.getVnfDetails(); if (details == null) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "vnfDetails"); + throw new CmsoException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "vnfDetails"); } List windows = new ArrayList<>(); List elements = new ArrayList<>(); @@ -265,7 +265,7 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { } private Object getRequestFromCallbackData(String node, String value) - throws CMSException, JsonParseException, JsonMappingException, IOException { + throws CmsoException, JsonParseException, JsonMappingException, IOException { ObjectMapper om = new ObjectMapper(); JsonNode json = om.readValue(value, JsonNode.class); JsonNode details = json.get("requestDetails"); @@ -277,7 +277,7 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { return request; } } - throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "CallbackData", ""); + throw new CmsoException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "CallbackData", ""); } @Override @@ -288,12 +288,12 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { try { Schedule schedule = scheduleDao.findByDomainScheduleId(DomainsEnum.ChangeManagement.toString(), scheduleId); if (schedule == null) { - throw new CMSNotFoundException(DomainsEnum.ChangeManagement.toString(), scheduleId); + throw new CmsoNotFoundException(DomainsEnum.ChangeManagement.toString(), scheduleId); } deleteChangeManagement(schedule); deleteScheduleRequest(DomainsEnum.ChangeManagement.toString(), scheduleId); response = Response.noContent().build(); - } catch (CMSException e) { + } catch (CmsoException e) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage()); response = Response.status(e.getStatus()).entity(e.getRequestError()).build(); @@ -315,11 +315,11 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { try { schedule = scheduleDao.findByDomainScheduleId(DomainsEnum.ChangeManagement.toString(), scheduleId); if (schedule == null) { - throw new CMSException(Status.NOT_FOUND, LogMessages.SCHEDULE_NOT_FOUND, + throw new CmsoException(Status.NOT_FOUND, LogMessages.SCHEDULE_NOT_FOUND, DomainsEnum.ChangeManagement.toString(), scheduleId); } response = Response.ok().entity(schedule).build(); - } catch (CMSException e) { + } catch (CmsoException e) { Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage()); response = Response.status(e.getStatus()).entity(e.getRequestError()).build(); } catch (Exception e) { @@ -342,11 +342,11 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { String domain = DomainsEnum.ChangeManagement.toString(); Schedule sch = scheduleDao.findByDomainScheduleId(domain, scheduleId); if (sch == null) { - throw new CMSNotFoundException(domain, scheduleId); + throw new CmsoNotFoundException(domain, scheduleId); } processApproveScheduleRequest(sch, approval, sch.getDomainData()); response = Response.noContent().build(); - } catch (CMSException e) { + } catch (CmsoException e) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage()); response = Response.status(e.getStatus()).entity(e.getRequestError()).build(); @@ -388,7 +388,7 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { buildWhere(qp, where); List list = cmDetailsDao.searchScheduleDetails(where.toString(), maxRows); if (list == null || !list.iterator().hasNext()) { - throw new CMSException(Status.NOT_FOUND, LogMessages.SCHEDULE_NOT_FOUND, + throw new CmsoException(Status.NOT_FOUND, LogMessages.SCHEDULE_NOT_FOUND, DomainsEnum.ChangeManagement.toString(), scheduleId); } Iterator iter = list.iterator(); @@ -399,7 +399,7 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { schedules.add(msg); } response = Response.ok(schedules.toArray(new CmDetailsMessage[schedules.size()])).build(); - } catch (CMSException e) { + } catch (CmsoException e) { Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage()); response = Response.status(e.getStatus()).entity(e.getRequestError()).build(); } catch (Exception e) { @@ -411,7 +411,7 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { return response; } - private void buildWhere(MultivaluedMap qp, StringBuilder where) throws CMSException { + private void buildWhere(MultivaluedMap qp, StringBuilder where) throws CmsoException { String delim = " where "; for (String urlName : qp.keySet()) { List values = qp.get(urlName); diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CommonServiceImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CommonServiceImpl.java index 750d0a7..e4dec7c 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CommonServiceImpl.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CommonServiceImpl.java @@ -39,24 +39,24 @@ import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Response.Status; 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.CmsoStatusEnum; import org.onap.optf.cmso.common.DomainsEnum; import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.common.exceptions.CMSException; -import org.onap.optf.cmso.eventq.CMSQueueJob; +import org.onap.optf.cmso.common.exceptions.CmsoException; +import org.onap.optf.cmso.eventq.CmsoQueueJob; import org.onap.optf.cmso.model.ChangeManagementChangeWindow; import org.onap.optf.cmso.model.ChangeManagementGroup; import org.onap.optf.cmso.model.ChangeManagementSchedule; import org.onap.optf.cmso.model.DomainData; import org.onap.optf.cmso.model.ElementData; import org.onap.optf.cmso.model.Schedule; -import org.onap.optf.cmso.model.dao.ChangeManagementChangeWindowDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementDetailDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementGroupDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO; -import org.onap.optf.cmso.model.dao.ElementDataDAO; -import org.onap.optf.cmso.model.dao.ScheduleDAO; -import org.onap.optf.cmso.model.dao.ScheduleQueryDAO; +import org.onap.optf.cmso.model.dao.ChangeManagementChangeWindowDao; +import org.onap.optf.cmso.model.dao.ChangeManagementDetailDao; +import org.onap.optf.cmso.model.dao.ChangeManagementGroupDao; +import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao; +import org.onap.optf.cmso.model.dao.ElementDataDao; +import org.onap.optf.cmso.model.dao.ScheduleDao; +import org.onap.optf.cmso.model.dao.ScheduleQueryDao; import org.onap.optf.cmso.service.rs.models.ApprovalMessage; import org.onap.optf.cmso.service.rs.models.v2.ChangeWindow; import org.onap.optf.cmso.service.rs.models.v2.ElementInfo; @@ -75,31 +75,31 @@ public class CommonServiceImpl extends BaseSchedulerServiceImpl { private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); @Autowired - CMSQueueJob qqJob; + CmsoQueueJob qqJob; @Autowired Environment env; @Autowired - ChangeManagementScheduleDAO cmScheduleDao; + ChangeManagementScheduleDao cmScheduleDao; @Autowired - ChangeManagementGroupDAO cmGroupDao; + ChangeManagementGroupDao cmGroupDao; @Autowired - ChangeManagementChangeWindowDAO cmChangeWindowDao; + ChangeManagementChangeWindowDao cmChangeWindowDao; @Autowired - ChangeManagementDetailDAO cmDetailsDao; + ChangeManagementDetailDao cmDetailsDao; @Autowired - ScheduleQueryDAO scheduleQueryDao; + ScheduleQueryDao scheduleQueryDao; @Autowired - ScheduleDAO scheduleDao; + ScheduleDao scheduleDao; @Autowired - ElementDataDAO elementDataDao; + ElementDataDao elementDataDao; @Autowired TmClient tmClient; @@ -109,13 +109,13 @@ public class CommonServiceImpl extends BaseSchedulerServiceImpl { protected void createSchedule(OptimizedScheduleMessage scheduleMessage, String scheduleId, - HttpServletRequest request) throws CMSException, JsonProcessingException { + HttpServletRequest request) throws CmsoException, JsonProcessingException { if (!scheduleMessage.getDomain().equals(DomainsEnum.ChangeManagement.toString())) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, "domain", + throw new CmsoException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, "domain", scheduleMessage.getDomain()); } if (scheduleMessage.getScheduleId() == null || !scheduleMessage.getScheduleId().equals(scheduleId)) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, "schedulerId", + throw new CmsoException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, "schedulerId", scheduleMessage.getScheduleId()); } // Force the name to be = to the ID because there is no way fot the provide a @@ -145,56 +145,56 @@ public class CommonServiceImpl extends BaseSchedulerServiceImpl { * Returns whether this is an immediate request. */ private boolean validate(OptimizedScheduleMessage scheduleMessage, Map> groups) - throws CMSException { + throws CmsoException { SchedulingData info = scheduleMessage.getSchedulingData(); boolean immediate = true; if (info == null) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.UNABLE_TO_PARSE_SCHEDULING_INFO); + throw new CmsoException(Status.BAD_REQUEST, LogMessages.UNABLE_TO_PARSE_SCHEDULING_INFO); } if (info.getAdditionalDurationInSeconds() == null) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, + throw new CmsoException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "additionalDurationInSeconds"); } if (info.getNormalDurationInSeconds() == null) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, + throw new CmsoException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "normalDurationInSeconds"); } if (info.getAdditionalDurationInSeconds() < 0) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, "additionalDurationInSeconds", + throw new CmsoException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, "additionalDurationInSeconds", info.getAdditionalDurationInSeconds().toString()); } if (info.getNormalDurationInSeconds() < 1) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, "normalDurationInSeconds", + throw new CmsoException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, "normalDurationInSeconds", info.getNormalDurationInSeconds().toString()); } if (info.getChangeWindows() != null && info.getChangeWindows().size() > 0) { for (ChangeWindow cw : info.getChangeWindows()) { immediate = false; if (cw.getStartTime() == null) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "startTime"); + throw new CmsoException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "startTime"); } if (cw.getEndTime() == null) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "endTime"); + throw new CmsoException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "endTime"); } Date start = cw.getStartTime(); Date end = cw.getEndTime(); if (!end.after(start)) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_CHANGE_WINDOW, start.toString(), + throw new CmsoException(Status.BAD_REQUEST, LogMessages.INVALID_CHANGE_WINDOW, start.toString(), end.toString()); } } if (info.getConcurrencyLimit() == null) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "concurrencyLimit"); + throw new CmsoException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "concurrencyLimit"); } if (info.getConcurrencyLimit() < 1) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, "concurrencyLimit", + throw new CmsoException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, "concurrencyLimit", info.getConcurrencyLimit().toString()); } } if (info.getElements() == null || info.getElements().size() == 0) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "elements"); + throw new CmsoException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "elements"); } for (ElementInfo element : info.getElements()) { @@ -213,7 +213,7 @@ public class CommonServiceImpl extends BaseSchedulerServiceImpl { } private void createChangeManagement(Schedule schedule, OptimizedScheduleMessage scheduleMessage, - Map> groups) throws CMSException { + Map> groups) throws CmsoException { SchedulingData schedulingInfo = scheduleMessage.getSchedulingData(); for (String groupId : groups.keySet()) { @@ -240,7 +240,7 @@ public class CommonServiceImpl extends BaseSchedulerServiceImpl { cms.setUuid(UUID.randomUUID()); cms.setChangeManagementGroupUuid(cmg.getUuid()); cms.setVnfName(element.getElementId()); - cms.setStatus(CMSStatusEnum.PendingSchedule.toString()); + cms.setStatus(CmsoStatusEnum.PendingSchedule.toString()); cms.setRequest(element.getRequest().toString()); cmScheduleDao.save(cms); // Save elementData @@ -266,7 +266,7 @@ public class CommonServiceImpl extends BaseSchedulerServiceImpl { } private void createChangeManagementImmediate(Schedule schedule, OptimizedScheduleMessage scheduleMessage, - Map> groups) throws CMSException, JsonProcessingException { + Map> groups) throws CmsoException, JsonProcessingException { SchedulingData schedulingInfo = scheduleMessage.getSchedulingData(); for (String groupId : groups.keySet()) { ChangeManagementGroup cmg = new ChangeManagementGroup(); @@ -286,33 +286,33 @@ public class CommonServiceImpl extends BaseSchedulerServiceImpl { cms.setChangeManagementGroupUuid(cmg.getUuid()); cms.setVnfName(element.getElementId()); cms.setRequest(element.getRequest().toString()); - cms.setStatus(CMSStatusEnum.PendingApproval.toString()); + cms.setStatus(CmsoStatusEnum.PendingApproval.toString()); cmScheduleDao.save(cms); } - schedule.setStatus(CMSStatusEnum.PendingApproval.toString()); + schedule.setStatus(CmsoStatusEnum.PendingApproval.toString()); scheduleDao.save(schedule); } } - protected void deleteChangeManagement(Schedule schedule) throws CMSException { + protected void deleteChangeManagement(Schedule schedule) throws CmsoException { List cmgs = cmGroupDao.findBySchedulesId(schedule.getUuid()); for (ChangeManagementGroup cmg : cmgs) { List schedules = cmScheduleDao.findByChangeManagementGroupId(cmg.getUuid()); for (ChangeManagementSchedule s : schedules) { - CMSStatusEnum currentState = CMSStatusEnum.Completed.fromString(s.getStatus()); + CmsoStatusEnum currentState = CmsoStatusEnum.Completed.fromString(s.getStatus()); switch (currentState) { case Scheduled: if (s.getTmChangeId() != null && !s.getTmChangeId().equals("")) { tmClient.cancelTicket(schedule, s, s.getTmChangeId()); } - s.setStatus(CMSStatusEnum.Cancelled.toString()); + s.setStatus(CmsoStatusEnum.Cancelled.toString()); break; case Triggered: // Too late... break; default: - s.setStatus(CMSStatusEnum.Deleted.toString()); + s.setStatus(CmsoStatusEnum.Deleted.toString()); } cmScheduleDao.save(s); } @@ -324,7 +324,7 @@ public class CommonServiceImpl extends BaseSchedulerServiceImpl { // Marshall commonData into DB DomainData // No validation. // - private List marshallDomainData(OptimizedScheduleMessage scheduleMessage) throws CMSException { + private List marshallDomainData(OptimizedScheduleMessage scheduleMessage) throws CmsoException { List domainData = scheduleMessage.getCommonData(); List domainDataList = new ArrayList(); for (NameValue nameValue : domainData) { @@ -341,19 +341,19 @@ public class CommonServiceImpl extends BaseSchedulerServiceImpl { protected void processApproveScheduleRequest(Schedule sch, ApprovalMessage approval, List domainData) - throws CMSException { + throws CmsoException { sch = scheduleDao.lockOne(sch.getUuid()); String domain = DomainsEnum.ChangeManagement.toString(); processApproval(sch, domain, approval); - if (sch.getStatus().equals(CMSStatusEnum.Accepted.toString())) { + if (sch.getStatus().equals(CmsoStatusEnum.Accepted.toString())) { openTickets(sch, domainData); } - if (sch.getStatus().equals(CMSStatusEnum.Rejected.toString())) { - updateChangeManagementSchedules(sch, CMSStatusEnum.ApprovalRejected); + if (sch.getStatus().equals(CmsoStatusEnum.Rejected.toString())) { + updateChangeManagementSchedules(sch, CmsoStatusEnum.ApprovalRejected); } } - private void openTickets(Schedule sch, List domainData) throws CMSException { + private void openTickets(Schedule sch, List domainData) throws CmsoException { debug.debug("Entered openTickets scheduleId=" + sch.getScheduleId()); Integer maxvnfsperticket = env.getProperty("tm.vnfs.per.ticket", Integer.class, 1); @@ -379,7 +379,7 @@ public class CommonServiceImpl extends BaseSchedulerServiceImpl { } private void openTicketForList(Schedule schedule, ChangeManagementGroup group, List list, - List domainData) throws CMSException { + List domainData) throws CmsoException { List vnfNames = new ArrayList<>(); for (ChangeManagementSchedule cms : list) { vnfNames.add(cms.getVnfName()); @@ -396,18 +396,18 @@ public class CommonServiceImpl extends BaseSchedulerServiceImpl { cms.setTmApprovalStatus(TmApprovalStatusEnum.Approved.toString()); // cms.setStatus(CMSStatusEnum.PendingApproval.toString()); if (cms.getStartTimeMillis() == null) { - cms.setStatus(CMSStatusEnum.ScheduledImmediate.toString()); + cms.setStatus(CmsoStatusEnum.ScheduledImmediate.toString()); } else { - cms.setStatus(CMSStatusEnum.Scheduled.toString()); + cms.setStatus(CmsoStatusEnum.Scheduled.toString()); } cmScheduleDao.save(cms); } - schedule.setStatus(CMSStatusEnum.Scheduled.toString()); + schedule.setStatus(CmsoStatusEnum.Scheduled.toString()); scheduleDao.save(schedule); } - private void updateChangeManagementSchedules(Schedule sch, CMSStatusEnum approvalrejected) { + private void updateChangeManagementSchedules(Schedule sch, CmsoStatusEnum approvalrejected) { debug.debug("Entered updateChangeManagementSchedules"); List groups = cmGroupDao.findBySchedulesId(sch.getUuid()); for (ChangeManagementGroup group : groups) { 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 79094d3..c6728fd 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 @@ -37,7 +37,7 @@ import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; -import org.onap.optf.cmso.model.dao.ApprovalTypeDAO; +import org.onap.optf.cmso.model.dao.ApprovalTypeDao; import org.onap.optf.cmso.optimizer.CmsoOptimizerClient; import org.onap.optf.cmso.service.rs.models.HealthCheckComponent; import org.onap.optf.cmso.service.rs.models.HealthCheckMessage; @@ -69,7 +69,7 @@ public class HealthCheckImpl implements HealthCheck { CmsoOptimizerClient optimizerClient; @Autowired - ApprovalTypeDAO approvalTypeDao; + ApprovalTypeDao approvalTypeDao; @Autowired Environment env; diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/CMSInfo.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/CMSInfo.java deleted file mode 100644 index d39798f..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/CMSInfo.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso.service.rs.models; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import java.io.Serializable; -import java.util.List; - -/** - * The persistent class for the approval_types database table. - * - */ -@ApiModel(value = "Change Management Scheduling Info", description = "Details of schedule being requested") -public class CMSInfo implements Serializable { - private static EELFLogger log = EELFManager.getInstance().getLogger(CMSInfo.class); - - private static final long serialVersionUID = 1L; - - @ApiModelProperty(value = "Expected duration (in seconds) of a successful execution of a single VNF change.") - private Integer normalDurationInSeconds; - - @ApiModelProperty( - value = "Additional duration (in seconds) to be added to support backout of an unsuccessful VNF change.") - private Integer additionalDurationInSeconds; - - @ApiModelProperty(value = "Maximum number of VNF changes to schedule concurrently") - private Integer concurrencyLimit; - - @ApiModelProperty( - value = "Name of schedule optimization policy used by the" - + " change management cmso optimizer to determine available time slot") - private String policyId; - - @ApiModelProperty(value = "Lists of the VNFs to be changed and the desired change windows") - private List vnfDetails; - - @Override - public String toString() { - ObjectMapper mapper = new ObjectMapper(); - try { - return mapper.writeValueAsString(this); - } catch (JsonProcessingException e) { - log.debug("Error in toString()", e); - } - return ""; - } - - public Integer getNormalDurationInSeconds() { - return normalDurationInSeconds; - } - - public void setNormalDurationInSeconds(Integer normalDurationInSeconds) { - this.normalDurationInSeconds = normalDurationInSeconds; - } - - public Integer getAdditionalDurationInSeconds() { - return additionalDurationInSeconds; - } - - public void setAdditionalDurationInSeconds(Integer additionalDurationInSeconds) { - this.additionalDurationInSeconds = additionalDurationInSeconds; - } - - public Integer getConcurrencyLimit() { - return concurrencyLimit; - } - - public void setConcurrencyLimit(Integer concurrencyLimit) { - this.concurrencyLimit = concurrencyLimit; - } - - public String getPolicyId() { - return policyId; - } - - public void setPolicyId(String policyId) { - this.policyId = policyId; - } - - public List getVnfDetails() { - return vnfDetails; - } - - public void setVnfDetails(List vnfDetails) { - this.vnfDetails = vnfDetails; - } -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/CMSMessage.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/CMSMessage.java deleted file mode 100644 index 9e236e2..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/CMSMessage.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso.service.rs.models; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.ObjectMapper; -import io.swagger.annotations.ApiModel; -import java.io.Serializable; -import org.onap.optf.cmso.common.LogMessages; - -/** - * The persistent class for the approval_types database table. - * - */ -@ApiModel -public class CMSMessage extends ScheduleMessage implements Serializable { - private static final long serialVersionUID = 1L; - - private static EELFLogger errors = EELFManager.getInstance().getErrorLogger(); - private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); - - private CMSInfo schedulingInfo; - - @Override - public CMSInfo getSchedulingInfo() { - // TODO Auto-generated method stub - return schedulingInfo; - } - - @Override - public void setSchedulingInfo(Object info) { - ObjectMapper mapper = new ObjectMapper(); - try { - String jsonString = mapper.writeValueAsString(info); - schedulingInfo = mapper.readValue(jsonString, CMSInfo.class); - } catch (Exception e) { - debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - } - - } - -} 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 e760b85..a5960f5 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 @@ -44,14 +44,14 @@ 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.CmsoStatusEnum; import org.onap.optf.cmso.common.LogMessages; 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.dao.ChangeManagementGroupDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO; -import org.onap.optf.cmso.model.dao.ScheduleDAO; +import org.onap.optf.cmso.model.dao.ChangeManagementGroupDao; +import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao; +import org.onap.optf.cmso.model.dao.ScheduleDao; import org.onap.optf.cmso.service.rs.models.HealthCheckComponent; import org.onap.optf.cmso.so.bean.MsoOrchestrationQueryResponse; import org.onap.optf.cmso.so.bean.MsoOrchestrationQueryResponse.MsoStatus; @@ -66,13 +66,13 @@ public class MsoStatusClient { private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); @Autowired - ChangeManagementScheduleDAO cmScheduleDao; + ChangeManagementScheduleDao cmScheduleDao; @Autowired - ChangeManagementGroupDAO cmGroupdao; + ChangeManagementGroupDao cmGroupdao; @Autowired - ScheduleDAO scheduleDao; + ScheduleDao scheduleDao; @Autowired Environment env; @@ -146,18 +146,18 @@ public class MsoStatusClient { switch (msoStatus) { case COMPLETE: cmSchedule.setExecutionCompletedTimeMillis(finishTime); - cmSchedule.setStatus(CMSStatusEnum.Completed.toString()); + cmSchedule.setStatus(CmsoStatusEnum.Completed.toString()); break; case FAILED: cmSchedule.setExecutionCompletedTimeMillis(finishTime); - cmSchedule.setStatus(CMSStatusEnum.Failed.toString()); + cmSchedule.setStatus(CmsoStatusEnum.Failed.toString()); break; case UNKNOWN: default: } } else { // Do not keep polling... - cmSchedule.setStatus(CMSStatusEnum.Error.toString()); + cmSchedule.setStatus(CmsoStatusEnum.Error.toString()); cmSchedule.setMsoStatus("Bad Response"); cmSchedule.setMsoMessage("Unable to parse :" + respString); @@ -167,21 +167,21 @@ public class MsoStatusClient { break; case 404: { // Not found // Do not keep polling... - cmSchedule.setStatus(CMSStatusEnum.Failed.toString()); + cmSchedule.setStatus(CmsoStatusEnum.Failed.toString()); cmSchedule.setMsoStatus("Not found"); cmSchedule.setMsoMessage("Call to MSO Failed :" + response.toString()); } break; case 400: { // Bad request // Do not keep polling... - cmSchedule.setStatus(CMSStatusEnum.Error.toString()); + cmSchedule.setStatus(CmsoStatusEnum.Error.toString()); cmSchedule.setMsoStatus("Bad Request"); cmSchedule.setMsoMessage("Call to MSO Failed :" + response.toString()); } break; case 500: default: { - cmSchedule.setStatus(CMSStatusEnum.Error.toString()); + cmSchedule.setStatus(CmsoStatusEnum.Error.toString()); cmSchedule.setMsoStatus("Failed"); cmSchedule.setMsoMessage("Call to MSO Failed :" + response.toString()); } 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 0a4c2f2..bfb7bb6 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 @@ -32,7 +32,7 @@ import java.util.UUID; import org.onap.observations.Mdc; import org.onap.optf.cmso.common.LogMessages; import org.onap.optf.cmso.model.ChangeManagementSchedule; -import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO; +import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao; import org.quartz.DisallowConcurrentExecution; import org.quartz.Job; import org.quartz.JobExecutionContext; @@ -57,7 +57,7 @@ public class MsoStatusJob implements Job { MsoStatusClient mso; @Autowired - ChangeManagementScheduleDAO cmScheduleDao; + ChangeManagementScheduleDao cmScheduleDao; @Autowired Environment env; 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 9eacfd1..3de62e0 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 @@ -51,8 +51,8 @@ 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; -import org.onap.optf.cmso.model.dao.ScheduleDAO; +import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao; +import org.onap.optf.cmso.model.dao.ScheduleDao; import org.quartz.DisallowConcurrentExecution; import org.quartz.Job; import org.quartz.JobExecutionContext; @@ -73,10 +73,10 @@ public class ScheduleStatusJob implements Job { private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); @Autowired - ScheduleDAO scheduleDao; + ScheduleDao scheduleDao; @Autowired - ChangeManagementScheduleDAO cmScheduleDao; + ChangeManagementScheduleDao cmScheduleDao; @Autowired PropertiesManagement pm; 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 c8cae12..1864da7 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 @@ -56,13 +56,13 @@ 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.PropertiesManagement; -import org.onap.optf.cmso.common.exceptions.CMSException; +import org.onap.optf.cmso.common.exceptions.CmsoException; import org.onap.optf.cmso.filters.CmsoClientFilters; import org.onap.optf.cmso.model.ChangeManagementGroup; import org.onap.optf.cmso.model.ChangeManagementSchedule; import org.onap.optf.cmso.model.DomainData; import org.onap.optf.cmso.model.Schedule; -import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO; +import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao; import org.onap.optf.cmso.service.rs.models.CmDomainDataEnum; import org.onap.optf.cmso.service.rs.models.HealthCheckComponent; import org.onap.optf.cmso.ticketmgt.TmEndpoints.Endpoint; @@ -89,7 +89,7 @@ public class TmClient { PropertiesManagement pm; @Autowired - ChangeManagementScheduleDAO cmScheduleDao; + ChangeManagementScheduleDao cmScheduleDao; @Autowired BuildCreateRequest buildCreateRequest; @@ -105,10 +105,10 @@ public class TmClient { * @param vnfNames the vnf names * @param domainData the domain data * @return the string - * @throws CMSException the CMS exception + * @throws CmsoException the CMS exception */ public String createChangeTicket(Schedule schedule, ChangeManagementGroup group, List vnfNames, - List domainData) throws CMSException { + List domainData) throws CmsoException { String changeId = ""; String workflowName = CmHelpers.getDomainData(domainData, CmDomainDataEnum.WorkflowName); @@ -129,10 +129,10 @@ public class TmClient { * @param changeId the change id * @param closureCode the closure code * @param closingComments the closing comments - * @throws CMSException the CMS exception + * @throws CmsoException the CMS exception */ public void closeTicket(Schedule schedule, ChangeManagementGroup group, List cmSchedules, - String changeId, ClosureCode closureCode, String closingComments) throws CMSException { + String changeId, ClosureCode closureCode, String closingComments) throws CmsoException { Map variables = getCloseVariables(schedule, group, cmSchedules, changeId, closureCode, closingComments); JsonNode closeChangeRecord = buildCreateRequest.createCloseCancelChangeRecord(variables); @@ -146,9 +146,9 @@ public class TmClient { * @param schedule the schedule * @param cms the cms * @param changeId the change id - * @throws CMSException the CMS exception + * @throws CmsoException the CMS exception */ - public void cancelTicket(Schedule schedule, ChangeManagementSchedule cms, String changeId) throws CMSException { + public void cancelTicket(Schedule schedule, ChangeManagementSchedule cms, String changeId) throws CmsoException { Map variables = getCancelVariables(schedule, changeId); JsonNode cancelChangeRecord = buildCreateRequest.createCancelChangeRecord(variables); debug.debug("cancelChangeRecord=" + cancelChangeRecord.toString()); @@ -161,9 +161,9 @@ public class TmClient { * @param schedule the schedule * @param cms the cms * @param changeId the change id - * @throws CMSException the CMS exception + * @throws CmsoException the CMS exception */ - public void updateTicket(Schedule schedule, ChangeManagementSchedule cms, String changeId) throws CMSException { + public void updateTicket(Schedule schedule, ChangeManagementSchedule cms, String changeId) throws CmsoException { Map variables = getUpdateVariables(schedule, changeId); JsonNode updateChangeRecord = buildCreateRequest.createUpdateChangeRecord(variables); debug.debug("updateChangeRecord=" + updateChangeRecord.toString()); @@ -269,7 +269,7 @@ public class TmClient { } private void postCloseChangeTicket(JsonNode closeChangeRecord, String scheduleId, String changeId) - throws CMSException { + throws CmsoException { Map mdcSave = Mdc.save(); try { Response response = null; @@ -290,7 +290,7 @@ public class TmClient { if (!isAlreadyClosed(respString)) { 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, + throw new CmsoException(Status.PRECONDITION_FAILED, LogMessages.UNABLE_TO_CLOSE_CHANGE_TICKET, scheduleId, changeId, respString); } } @@ -299,13 +299,13 @@ public class TmClient { String message = response.readEntity(String.class); 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, + throw new CmsoException(Status.PRECONDITION_FAILED, LogMessages.UNABLE_TO_CLOSE_CHANGE_TICKET, scheduleId, changeId, message); } } } catch (ProcessingException e) { Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - throw new CMSException(Status.PRECONDITION_FAILED, LogMessages.UNABLE_TO_CLOSE_CHANGE_TICKET, scheduleId, + throw new CmsoException(Status.PRECONDITION_FAILED, LogMessages.UNABLE_TO_CLOSE_CHANGE_TICKET, scheduleId, changeId, e.toString()); } finally { Mdc.restore(mdcSave); @@ -411,7 +411,7 @@ public class TmClient { } - private String postCreateChangeTicket(JsonNode createChangeRecord, String scheduleId) throws CMSException { + private String postCreateChangeTicket(JsonNode createChangeRecord, String scheduleId) throws CmsoException { String changeId = null; Map mdcSave = Mdc.save(); try { @@ -435,7 +435,7 @@ public class TmClient { } else { 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, + throw new CmsoException(Status.EXPECTATION_FAILED, LogMessages.UNABLE_TO_CREATE_CHANGE_TICKET, scheduleId, "Response is empty"); } } @@ -444,13 +444,13 @@ public class TmClient { String message = response.readEntity(String.class); 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, + throw new CmsoException(Status.EXPECTATION_FAILED, LogMessages.UNABLE_TO_CREATE_CHANGE_TICKET, scheduleId, message); } } } catch (ProcessingException e) { Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - throw new CMSException(Status.EXPECTATION_FAILED, LogMessages.UNABLE_TO_CREATE_CHANGE_TICKET, scheduleId, + throw new CmsoException(Status.EXPECTATION_FAILED, LogMessages.UNABLE_TO_CREATE_CHANGE_TICKET, scheduleId, e.toString()); } finally { Mdc.restore(mdcSave); @@ -459,7 +459,7 @@ public class TmClient { } private String postUpdateChangeTicket(JsonNode updateChangeRecord, String scheduleId, String changeId) - throws CMSException { + throws CmsoException { Map mdcSave = Mdc.save(); try { String url = env.getProperty("vtm.url") + env.getProperty("vtm.updatePath"); @@ -480,13 +480,13 @@ public class TmClient { String message = response.readEntity(String.class); 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, + throw new CmsoException(Status.PRECONDITION_FAILED, LogMessages.UNABLE_TO_UPDATE_CHANGE_TICKET, scheduleId, changeId, message); } } } catch (ProcessingException e) { Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - throw new CMSException(Status.PRECONDITION_FAILED, LogMessages.UNABLE_TO_UPDATE_CHANGE_TICKET, scheduleId, + throw new CmsoException(Status.PRECONDITION_FAILED, LogMessages.UNABLE_TO_UPDATE_CHANGE_TICKET, scheduleId, changeId, e.toString()); } finally { Mdc.restore(mdcSave); @@ -495,7 +495,7 @@ public class TmClient { } - private Response tmPost(Endpoint ep, Object request, String scheduleId) throws CMSException { + private Response tmPost(Endpoint ep, Object request, String scheduleId) throws CmsoException { Response response = null; List endpoints = new ArrayList<>(); String url = tmEndpoints.getEndpoint(ep, endpoints); @@ -525,12 +525,12 @@ public class TmClient { 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, + throw new CmsoException(Status.INTERNAL_SERVER_ERROR, LogMessages.UNABLE_TO_CREATE_CHANGE_TICKET, scheduleId, e.getMessage()); } } catch (Exception e) { Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.toString()); - throw new CMSException(Status.INTERNAL_SERVER_ERROR, LogMessages.UNABLE_TO_CREATE_CHANGE_TICKET, + throw new CmsoException(Status.INTERNAL_SERVER_ERROR, LogMessages.UNABLE_TO_CREATE_CHANGE_TICKET, scheduleId, e.getMessage()); } } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmStatusClient.java b/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmStatusClient.java index a7ae5ed..4ace561 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmStatusClient.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmStatusClient.java @@ -37,15 +37,15 @@ import java.util.Map; import java.util.Set; import java.util.UUID; import javax.transaction.Transactional; -import org.onap.optf.cmso.common.CMSStatusEnum; +import org.onap.optf.cmso.common.CmsoStatusEnum; import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.common.exceptions.CMSException; +import org.onap.optf.cmso.common.exceptions.CmsoException; import org.onap.optf.cmso.model.ChangeManagementGroup; import org.onap.optf.cmso.model.ChangeManagementSchedule; import org.onap.optf.cmso.model.Schedule; -import org.onap.optf.cmso.model.dao.ChangeManagementGroupDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO; -import org.onap.optf.cmso.model.dao.ScheduleDAO; +import org.onap.optf.cmso.model.dao.ChangeManagementGroupDao; +import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao; +import org.onap.optf.cmso.model.dao.ScheduleDao; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @@ -80,13 +80,13 @@ public class TmStatusClient { Environment env; @Autowired - ScheduleDAO scheduleDao; + ScheduleDao scheduleDao; @Autowired - ChangeManagementScheduleDAO cmScheduleDao; + ChangeManagementScheduleDao cmScheduleDao; @Autowired - ChangeManagementGroupDAO cmGroupDao; + ChangeManagementGroupDao cmGroupDao; @Autowired TmClient tmClient; @@ -103,8 +103,8 @@ public class TmStatusClient { // Multiple cmso instance support - re-get the record with a Schedule lock UUID uuid = UUID.fromString(id); Schedule sch = scheduleDao.lockOne(uuid); - if (!sch.getStatus().equals(CMSStatusEnum.NotificationsInitiated.toString())) { - debug.debug(sch.getScheduleId() + " is no longer in " + CMSStatusEnum.NotificationsInitiated.toString() + if (!sch.getStatus().equals(CmsoStatusEnum.NotificationsInitiated.toString())) { + debug.debug(sch.getScheduleId() + " is no longer in " + CmsoStatusEnum.NotificationsInitiated.toString() + " : it is " + sch.getStatus()); // Attempt at avoiding race condition in a load balance env. ? return; @@ -135,10 +135,10 @@ public class TmStatusClient { } // if (groupStatus.containsKey(GroupAuditStatus.CompletedWithErrors)) { - sch.setStatus(CMSStatusEnum.CompletedWithError.toString()); + sch.setStatus(CmsoStatusEnum.CompletedWithError.toString()); } if (groupStatus.containsKey(GroupAuditStatus.Completed)) { - sch.setStatus(CMSStatusEnum.Completed.toString()); + sch.setStatus(CmsoStatusEnum.Completed.toString()); } scheduleDao.save(sch); } catch (Exception e) { @@ -149,7 +149,7 @@ public class TmStatusClient { } } - private void processGroup(Schedule sch, ChangeManagementGroup group) throws CMSException { + private void processGroup(Schedule sch, ChangeManagementGroup group) throws CmsoException { debug.debug("{Processing status of " + sch.getScheduleId() + " group=" + group.getGroupId()); // Get status of all VNFs within a ticket within the group (Tickets will not // span groups) @@ -161,7 +161,7 @@ public class TmStatusClient { for (ChangeManagementSchedule cmSchedule : cmSchedules) { String status = cmSchedule.getStatus(); String tmStatus = cmSchedule.getTmStatus(); - CMSStatusEnum cmsStatus = CMSStatusEnum.Completed.fromString(status); + CmsoStatusEnum cmsStatus = CmsoStatusEnum.Completed.fromString(status); switch (cmsStatus) { case Scheduled: case Triggered: @@ -241,7 +241,7 @@ public class TmStatusClient { allNames.add(vnfName); String status = cmSchedule.getStatus(); String tmStatus = cmSchedule.getTmStatus(); - CMSStatusEnum cmsStatus = CMSStatusEnum.Completed.fromString(status); + CmsoStatusEnum cmsStatus = CmsoStatusEnum.Completed.fromString(status); switch (cmsStatus) { case Scheduled: case Triggered: @@ -307,7 +307,7 @@ public class TmStatusClient { private void closeTheTicket(Schedule sch, ChangeManagementGroup group, String changeId, List list, ClosureCode closureCode, String closingComments) - throws CMSException { + throws CmsoException { debug.debug("Closing ticket " + changeId + ":" + closureCode); try { tmClient.closeTicket(sch, group, list, changeId, closureCode, closingComments); @@ -315,7 +315,7 @@ public class TmStatusClient { cms.setTmStatus("Closed"); cmScheduleDao.save(cms); } - } catch (CMSException e) { + } catch (CmsoException e) { throw e; } diff --git a/cmso-ticketmgt/pom.xml b/cmso-ticketmgt/pom.xml index 1274360..88dce59 100644 --- a/cmso-ticketmgt/pom.xml +++ b/cmso-ticketmgt/pom.xml @@ -22,7 +22,7 @@ 1.0.1-SNAPSHOT - org.onap.optf.cmso.tcketmgt + org.onap.optf.cmso.ticketmgt cmso-ticketmgt jar diff --git a/cmso-ticketmgt/src/main/java/org/onap/observations/MessageHeaders.java b/cmso-ticketmgt/src/main/java/org/onap/observations/MessageHeaders.java index f140aec..e968728 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/observations/MessageHeaders.java +++ b/cmso-ticketmgt/src/main/java/org/onap/observations/MessageHeaders.java @@ -69,7 +69,7 @@ public class MessageHeaders { } /** The Constant supportedMajorVersions. */ - public static final Map supportedMajorVersions = new HashMap(); + private static final Map supportedMajorVersions = new HashMap(); static { supportedMajorVersions.put("v1", "0"); @@ -77,7 +77,7 @@ public class MessageHeaders { } /** The Constant supportedMajorMinorVersions. */ - public static final Set supportedMajorMinorVersions = new HashSet(); + private static final Set supportedMajorMinorVersions = new HashSet(); static { supportedMajorMinorVersions.add("v1.0"); @@ -85,10 +85,10 @@ public class MessageHeaders { } /** The Constant latestVersion. */ - public static final String latestVersion = "2.0.0"; + private static final String latestVersion = "2.0.0"; /** The Constant patchVersion. */ - public static final String patchVersion = "0"; + private static final String patchVersion = "0"; /** * From string. @@ -156,4 +156,20 @@ public class MessageHeaders { } return true; } + + public static Map getSupportedmajorversions() { + return supportedMajorVersions; + } + + public static Set getSupportedmajorminorversions() { + return supportedMajorMinorVersions; + } + + public static String getLatestversion() { + return latestVersion; + } + + public static String getPatchversion() { + return patchVersion; + } } diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/CMSEnvironmentPostProcessor.java b/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/CMSEnvironmentPostProcessor.java deleted file mode 100644 index eb9ddad..0000000 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/CMSEnvironmentPostProcessor.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso; - -import java.util.HashMap; -import java.util.Map; -import org.onap.optf.cmso.common.PropertiesManagement; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.env.EnvironmentPostProcessor; -import org.springframework.core.env.ConfigurableEnvironment; -import org.springframework.core.env.MapPropertySource; -import org.springframework.core.env.MutablePropertySources; - -public class CMSEnvironmentPostProcessor implements EnvironmentPostProcessor { - // TODO tested in ONAP springboot and this is called before all of the properties files have been - // loaded... - // perhaps there is a post post processor? Until this works. DB password will be in the clear in the - // proeprties files. - @Override - public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { - String pwd = environment.getProperty("cmso.database.password"); - if (pwd != null) { - pwd = PropertiesManagement.getDecryptedValue(pwd); - Map map = new HashMap(); - map.put("spring.datasource.password", pwd); - MapPropertySource propertySource = new MapPropertySource("abc", map); - MutablePropertySources proeprtySources = environment.getPropertySources(); - proeprtySources.addLast(propertySource); - } - } - -} diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/CmsoEnvironmentPostProcessor.java b/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/CmsoEnvironmentPostProcessor.java new file mode 100644 index 0000000..2426a5c --- /dev/null +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/CmsoEnvironmentPostProcessor.java @@ -0,0 +1,61 @@ +/* + * 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. +*/ + +package org.onap.optf.cmso; + +import java.util.HashMap; +import java.util.Map; +import org.onap.optf.cmso.common.PropertiesManagement; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.env.EnvironmentPostProcessor; +import org.springframework.core.env.ConfigurableEnvironment; +import org.springframework.core.env.MapPropertySource; +import org.springframework.core.env.MutablePropertySources; + +public class CmsoEnvironmentPostProcessor implements EnvironmentPostProcessor { + // TODO tested in ONAP springboot and this is called before all of the properties files have been + // loaded... + // perhaps there is a post post processor? Until this works. DB password will be in the clear in the + // proeprties files. + @Override + public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { + String pwd = environment.getProperty("cmso.database.password"); + if (pwd != null) { + pwd = PropertiesManagement.getDecryptedValue(pwd); + Map map = new HashMap(); + map.put("spring.datasource.password", pwd); + MapPropertySource propertySource = new MapPropertySource("abc", map); + MutablePropertySources proeprtySources = environment.getPropertySources(); + proeprtySources.addLast(propertySource); + } + } + +} diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/CMSRequestError.java b/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/CMSRequestError.java deleted file mode 100644 index 4ba7d48..0000000 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/CMSRequestError.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.cmso.common; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -public class CMSRequestError implements Serializable { - private static final long serialVersionUID = 1L; - @JsonProperty - RequestError requestError; - - public CMSRequestError(String messageId, String text, List variables) { - requestError = new RequestError(messageId, text, variables); - } - - public CMSRequestError(String messageId, String text) { - requestError = new RequestError(messageId, text, new ArrayList()); - } - - public class RequestError { - @JsonProperty - private String messageId; - @JsonProperty - private String text; - @JsonProperty - private List variables; - - private RequestError(String messageId, String text, List variables) { - this.messageId = "Scheduler." + messageId; - this.text = text; - this.variables = variables; - } - - @Override - public String toString() { - StringBuffer sb = new StringBuffer(); - sb.append(messageId).append(":").append(text).append(":").append(variables); - return sb.toString(); - - } - } - - @Override - public String toString() { - return requestError.toString(); - } -} diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/CmsoRequestError.java b/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/CmsoRequestError.java new file mode 100644 index 0000000..ba28a2d --- /dev/null +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/CmsoRequestError.java @@ -0,0 +1,79 @@ +/* + * 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. +*/ + +package org.onap.optf.cmso.common; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +public class CmsoRequestError implements Serializable { + private static final long serialVersionUID = 1L; + @JsonProperty + RequestError requestError; + + public CmsoRequestError(String messageId, String text, List variables) { + requestError = new RequestError(messageId, text, variables); + } + + public CmsoRequestError(String messageId, String text) { + requestError = new RequestError(messageId, text, new ArrayList()); + } + + public class RequestError { + @JsonProperty + private String messageId; + @JsonProperty + private String text; + @JsonProperty + private List variables; + + private RequestError(String messageId, String text, List variables) { + this.messageId = "Scheduler." + messageId; + this.text = text; + this.variables = variables; + } + + @Override + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append(messageId).append(":").append(text).append(":").append(variables); + return sb.toString(); + + } + } + + @Override + public String toString() { + return requestError.toString(); + } +} diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/exceptions/CMSException.java b/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/exceptions/CMSException.java deleted file mode 100644 index e8b5e03..0000000 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/exceptions/CMSException.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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. - * 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.common.exceptions; - -import com.att.eelf.i18n.EELFResourceManager; -import java.util.ArrayList; -import java.util.List; -import javax.ws.rs.core.Response.Status; -import org.onap.observations.ObservationInterface; -import org.onap.optf.cmso.common.CMSRequestError; - -public class CMSException extends Exception { - private static final long serialVersionUID = 1L; - - protected CMSRequestError requestError = null; - private List variables = new ArrayList(); - protected ObservationInterface messageCode; - protected Status status; - - /** - * Instantiates a new CMS exception. - * - * @param status the status - * @param messageCode the message code - * @param args the args - */ - public CMSException(Status status, ObservationInterface messageCode, String... args) { - super(EELFResourceManager.format(messageCode, args)); - this.status = status; - this.messageCode = messageCode; - for (String arg : args) { - variables.add(arg); - } - requestError = new CMSRequestError(messageCode.name(), getMessage(), variables); - } - - public Status getStatus() { - return status; - } - - public ObservationInterface getMessageCode() { - return messageCode; - } - - public String[] getVariables() { - return variables.toArray(new String[variables.size()]); - } - - public CMSRequestError getRequestError() { - return requestError; - } -} diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/exceptions/CmsoException.java b/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/exceptions/CmsoException.java new file mode 100644 index 0000000..c80cd56 --- /dev/null +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/exceptions/CmsoException.java @@ -0,0 +1,81 @@ +/* + * 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. + * 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.common.exceptions; + +import com.att.eelf.i18n.EELFResourceManager; +import java.util.ArrayList; +import java.util.List; +import javax.ws.rs.core.Response.Status; +import org.onap.observations.ObservationInterface; +import org.onap.optf.cmso.common.CmsoRequestError; + +public class CmsoException extends Exception { + private static final long serialVersionUID = 1L; + + protected CmsoRequestError requestError = null; + private List variables = new ArrayList(); + protected ObservationInterface messageCode; + protected Status status; + + /** + * Instantiates a new CMS exception. + * + * @param status the status + * @param messageCode the message code + * @param args the args + */ + public CmsoException(Status status, ObservationInterface messageCode, String... args) { + super(EELFResourceManager.format(messageCode, args)); + this.status = status; + this.messageCode = messageCode; + for (String arg : args) { + variables.add(arg); + } + requestError = new CmsoRequestError(messageCode.name(), getMessage(), variables); + } + + public Status getStatus() { + return status; + } + + public ObservationInterface getMessageCode() { + return messageCode; + } + + public String[] getVariables() { + return variables.toArray(new String[variables.size()]); + } + + public CmsoRequestError getRequestError() { + return requestError; + } +} diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/CMSEnvironmentPostProcessor.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/CMSEnvironmentPostProcessor.java deleted file mode 100644 index d955e75..0000000 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/CMSEnvironmentPostProcessor.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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. -*/ - -package org.onap.optf.ticketmgt; - -import java.util.HashMap; -import java.util.Map; -import org.onap.optf.cmso.common.PropertiesManagement; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.env.EnvironmentPostProcessor; -import org.springframework.core.env.ConfigurableEnvironment; -import org.springframework.core.env.MapPropertySource; -import org.springframework.core.env.MutablePropertySources; - -public class CMSEnvironmentPostProcessor implements EnvironmentPostProcessor { - // TODO tested in ONAP springboot and this is called before all of the properties files have been - // loaded... - // perhaps there is a post post processor? Until this works. DB password will be in the clear in the - // proeprties files. - @Override - public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { - String pwd = environment.getProperty("cmso.database.password"); - if (pwd != null) { - pwd = PropertiesManagement.getDecryptedValue(pwd); - Map map = new HashMap(); - map.put("spring.datasource.password", pwd); - MapPropertySource propertySource = new MapPropertySource("abc", map); - MutablePropertySources proeprtySources = environment.getPropertySources(); - proeprtySources.addLast(propertySource); - } - } - -} diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/CmsoEnvironmentPostProcessor.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/CmsoEnvironmentPostProcessor.java new file mode 100644 index 0000000..1230591 --- /dev/null +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/CmsoEnvironmentPostProcessor.java @@ -0,0 +1,61 @@ +/* + * 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. +*/ + +package org.onap.optf.ticketmgt; + +import java.util.HashMap; +import java.util.Map; +import org.onap.optf.cmso.common.PropertiesManagement; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.env.EnvironmentPostProcessor; +import org.springframework.core.env.ConfigurableEnvironment; +import org.springframework.core.env.MapPropertySource; +import org.springframework.core.env.MutablePropertySources; + +public class CmsoEnvironmentPostProcessor implements EnvironmentPostProcessor { + // TODO tested in ONAP springboot and this is called before all of the properties files have been + // loaded... + // perhaps there is a post post processor? Until this works. DB password will be in the clear in the + // proeprties files. + @Override + public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { + String pwd = environment.getProperty("cmso.database.password"); + if (pwd != null) { + pwd = PropertiesManagement.getDecryptedValue(pwd); + Map map = new HashMap(); + map.put("spring.datasource.password", pwd); + MapPropertySource propertySource = new MapPropertySource("abc", map); + MutablePropertySources proeprtySources = environment.getPropertySources(); + proeprtySources.addLast(propertySource); + } + } + +} diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/JerseyConfiguration.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/JerseyConfiguration.java index c4fe51a..1cbf19c 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/JerseyConfiguration.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/JerseyConfiguration.java @@ -44,7 +44,7 @@ import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.logging.LoggingFeature; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.servlet.ServletProperties; -import org.onap.optf.ticketmgt.filters.CMSOContainerFilters; +import org.onap.optf.ticketmgt.filters.CmsoContainerFilters; import org.onap.optf.ticketmgt.service.rs.AdminToolImpl; import org.onap.optf.ticketmgt.service.rs.AvailabilityInterfaceImpl; import org.onap.optf.ticketmgt.service.rs.HealthCheckImpl; @@ -91,7 +91,7 @@ public class JerseyConfiguration extends ResourceConfig { // TODO: Examine which logging features to enable register(new LoggingFeature(log)); - register(CMSOContainerFilters.class); + register(CmsoContainerFilters.class); } /** diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/aaf/AafAuthorizationFilter.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/aaf/AafAuthorizationFilter.java index ffbd94e..ea044a4 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/aaf/AafAuthorizationFilter.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/aaf/AafAuthorizationFilter.java @@ -26,7 +26,7 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.onap.observations.Observation; -import org.onap.optf.cmso.common.exceptions.CMSException; +import org.onap.optf.cmso.common.exceptions.CmsoException; import org.onap.optf.ticketmgt.SpringProfiles; import org.onap.optf.ticketmgt.common.LogMessages; import org.springframework.beans.factory.annotation.Value; @@ -69,7 +69,7 @@ public class AafAuthorizationFilter extends OrderedRequestContextFilter { if (!request.isUserInRole(permission)) { Observation.report(LogMessages.UNAUTHORIZED); ResponseFormatter.errorResponse(request, response, - new CMSException(LogMessages.UNAUTHORIZED.getStatus(), LogMessages.UNAUTHORIZED, "")); + new CmsoException(LogMessages.UNAUTHORIZED.getStatus(), LogMessages.UNAUTHORIZED, "")); } else { filterChain.doFilter(request, response); } diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/aaf/AafFilter.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/aaf/AafFilter.java index c0c8106..1f27fee 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/aaf/AafFilter.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/aaf/AafFilter.java @@ -29,7 +29,7 @@ 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.common.exceptions.CMSException; +import org.onap.optf.cmso.common.exceptions.CmsoException; import org.onap.optf.ticketmgt.Application; import org.onap.optf.ticketmgt.SpringProfiles; import org.onap.optf.ticketmgt.common.LogMessages; @@ -67,7 +67,7 @@ public class AafFilter extends OrderedRequestContextFilter { cadiFilter.doFilter(request, response, filterChain); if (response.getStatus() >= 400 && response.getStatus() < 500) { Observation.report(LogMessages.UNAUTHENTICATED); - ResponseFormatter.errorResponse(request, response, new CMSException( + ResponseFormatter.errorResponse(request, response, new CmsoException( LogMessages.UNAUTHENTICATED.getStatus(), LogMessages.UNAUTHENTICATED, "")); } } else { diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/aaf/ResponseFormatter.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/aaf/ResponseFormatter.java index b9b222c..156b3ce 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/aaf/ResponseFormatter.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/aaf/ResponseFormatter.java @@ -23,12 +23,12 @@ package org.onap.optf.ticketmgt.aaf; import java.io.IOException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.onap.optf.cmso.common.exceptions.CMSException; +import org.onap.optf.cmso.common.exceptions.CmsoException; class ResponseFormatter { - static void errorResponse(HttpServletRequest request, HttpServletResponse response, CMSException error) + static void errorResponse(HttpServletRequest request, HttpServletResponse response, CmsoException error) throws IOException { response.setStatus(error.getStatus().getStatusCode()); response.getWriter().write(error.getRequestError().toString()); diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/filters/CMSOClientFilters.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/filters/CMSOClientFilters.java deleted file mode 100644 index 54b1b38..0000000 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/filters/CMSOClientFilters.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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. - * 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.ticketmgt.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.MessageHeaders; -import org.onap.observations.MessageHeaders.HeadersEnum; -import org.onap.observations.Observation; -import org.onap.optf.ticketmgt.common.LogMessages; -import org.slf4j.MDC; -import org.springframework.stereotype.Component; - -// @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") -@Component -public class CMSOClientFilters implements ClientRequestFilter, ClientResponseFilter { - - private static String appId = "cmso"; - - @Override - public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException { - // 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 - 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()); - String mdcId = MDC.get(MDC_KEY_REQUEST_ID); - if (transactionId == null || transactionId.equals("")) { - if (mdcId != null) { - headers.add(HeadersEnum.TransactionID.toString(), mdcId); - } - } - headers.add(HeadersEnum.FromAppID.toString(), appId); - } - -} diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/filters/CMSOContainerFilters.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/filters/CMSOContainerFilters.java deleted file mode 100644 index 4f6b8e7..0000000 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/filters/CMSOContainerFilters.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * 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. - * 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.ticketmgt.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.MessageHeaders; -import org.onap.observations.MessageHeaders.HeadersEnum; -import org.onap.observations.Observation; -import org.onap.optf.ticketmgt.common.LogMessages; -import org.springframework.stereotype.Component; - -@Priority(1) -@Provider -@Component -public class CMSOContainerFilters implements ContainerRequestFilter, ContainerResponseFilter { - - - @Context - private HttpServletRequest servletRequest; - - @Override - public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) - throws IOException { - try { - 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 = reqHeaders.getFirst(HeadersEnum.MinorVersion.toString()); - respHeaders.add(HeadersEnum.MinorVersion.toString(), minorVersion); - respHeaders.add(HeadersEnum.LatestVersion.toString(), MessageHeaders.latestVersion); - respHeaders.add(HeadersEnum.PatchVersion.toString(), MessageHeaders.patchVersion); - - } catch (Exception e) { - if (e instanceof WebApplicationException) { - Observation.report(LogMessages.EXPECTED_EXCEPTION, e.getMessage()); - } else { - Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e.getMessage()); - } - } - } - - @Override - public void filter(ContainerRequestContext requestContext) throws IOException { - try { - // On the way in - Mdc.auditStart(requestContext, servletRequest); - Observation.report(LogMessages.INCOMING_MESSAGE, requestContext.getMethod(), - requestContext.getUriInfo().getPath().toString()); - - String majorVersion = requestContext.getUriInfo().getPath(); - if (majorVersion != null) { - - if (majorVersion.startsWith("dispatch/")) { - return; - } - majorVersion = majorVersion.replaceAll("/.*$", ""); - } - if (!MessageHeaders.validateMajorVersion(majorVersion)) { - ResponseBuilder builder = null; - String response = "Unsupported Major version"; - builder = Response.status(Response.Status.NOT_FOUND).entity(response); - throw new WebApplicationException(builder.build()); - } - MultivaluedMap headers = requestContext.getHeaders(); - String transactionId = headers.getFirst(HeadersEnum.TransactionID.toString()); - if (transactionId == null) { - transactionId = UUID.randomUUID().toString(); - headers.add(HeadersEnum.TransactionID.toString(), transactionId); - } - String minorVersion = headers.getFirst(HeadersEnum.MinorVersion.toString()); - if (minorVersion == null) { - minorVersion = MessageHeaders.supportedMajorVersions.get(majorVersion); - headers.add(HeadersEnum.MinorVersion.toString(), minorVersion); - } - if (!MessageHeaders.validateMajorMinorVersion(majorVersion, minorVersion)) { - ResponseBuilder builder = null; - String response = "Unsupported API version"; - builder = Response.status(Response.Status.NOT_FOUND).entity(response); - throw new WebApplicationException(builder.build()); - - } - } catch (Exception e) { - if (e instanceof WebApplicationException) { - Observation.report(LogMessages.EXPECTED_EXCEPTION, e.getMessage()); - throw e; - } else { - Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e.getMessage()); - } - } - - } - -} diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/filters/CmsoClientFilters.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/filters/CmsoClientFilters.java new file mode 100644 index 0000000..ac1569c --- /dev/null +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/filters/CmsoClientFilters.java @@ -0,0 +1,84 @@ +/* + * 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. + * 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.ticketmgt.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.MessageHeaders; +import org.onap.observations.MessageHeaders.HeadersEnum; +import org.onap.observations.Observation; +import org.onap.optf.ticketmgt.common.LogMessages; +import org.slf4j.MDC; +import org.springframework.stereotype.Component; + +// @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") +@Component +public class CmsoClientFilters implements ClientRequestFilter, ClientResponseFilter { + + private static String appId = "cmso"; + + @Override + public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException { + // 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 + 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()); + String mdcId = MDC.get(MDC_KEY_REQUEST_ID); + if (transactionId == null || transactionId.equals("")) { + if (mdcId != null) { + headers.add(HeadersEnum.TransactionID.toString(), mdcId); + } + } + headers.add(HeadersEnum.FromAppID.toString(), appId); + } + +} diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/filters/CmsoContainerFilters.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/filters/CmsoContainerFilters.java new file mode 100644 index 0000000..5b73a85 --- /dev/null +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/filters/CmsoContainerFilters.java @@ -0,0 +1,139 @@ +/* + * 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. + * 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.ticketmgt.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.MessageHeaders; +import org.onap.observations.MessageHeaders.HeadersEnum; +import org.onap.observations.Observation; +import org.onap.optf.ticketmgt.common.LogMessages; +import org.springframework.stereotype.Component; + +@Priority(1) +@Provider +@Component +public class CmsoContainerFilters implements ContainerRequestFilter, ContainerResponseFilter { + + + @Context + private HttpServletRequest servletRequest; + + @Override + public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) + throws IOException { + try { + 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 = reqHeaders.getFirst(HeadersEnum.MinorVersion.toString()); + respHeaders.add(HeadersEnum.MinorVersion.toString(), minorVersion); + respHeaders.add(HeadersEnum.LatestVersion.toString(), MessageHeaders.getLatestversion()); + respHeaders.add(HeadersEnum.PatchVersion.toString(), MessageHeaders.getPatchversion()); + + } catch (Exception e) { + if (e instanceof WebApplicationException) { + Observation.report(LogMessages.EXPECTED_EXCEPTION, e.getMessage()); + } else { + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e.getMessage()); + } + } + } + + @Override + public void filter(ContainerRequestContext requestContext) throws IOException { + try { + // On the way in + Mdc.auditStart(requestContext, servletRequest); + Observation.report(LogMessages.INCOMING_MESSAGE, requestContext.getMethod(), + requestContext.getUriInfo().getPath().toString()); + + String majorVersion = requestContext.getUriInfo().getPath(); + if (majorVersion != null) { + + if (majorVersion.startsWith("dispatch/")) { + return; + } + majorVersion = majorVersion.replaceAll("/.*$", ""); + } + if (!MessageHeaders.validateMajorVersion(majorVersion)) { + ResponseBuilder builder = null; + String response = "Unsupported Major version"; + builder = Response.status(Response.Status.NOT_FOUND).entity(response); + throw new WebApplicationException(builder.build()); + } + MultivaluedMap headers = requestContext.getHeaders(); + String transactionId = headers.getFirst(HeadersEnum.TransactionID.toString()); + if (transactionId == null) { + transactionId = UUID.randomUUID().toString(); + headers.add(HeadersEnum.TransactionID.toString(), transactionId); + } + String minorVersion = headers.getFirst(HeadersEnum.MinorVersion.toString()); + if (minorVersion == null) { + minorVersion = MessageHeaders.getSupportedmajorversions().get(majorVersion); + headers.add(HeadersEnum.MinorVersion.toString(), minorVersion); + } + if (!MessageHeaders.validateMajorMinorVersion(majorVersion, minorVersion)) { + ResponseBuilder builder = null; + String response = "Unsupported API version"; + builder = Response.status(Response.Status.NOT_FOUND).entity(response); + throw new WebApplicationException(builder.build()); + + } + } catch (Exception e) { + if (e instanceof WebApplicationException) { + Observation.report(LogMessages.EXPECTED_EXCEPTION, e.getMessage()); + throw e; + } else { + Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e.getMessage()); + } + } + + } + +} diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/AvailabilityInterface.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/AvailabilityInterface.java index 3360927..df23f7d 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/AvailabilityInterface.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/AvailabilityInterface.java @@ -45,7 +45,7 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import org.onap.optf.cmso.common.CMSRequestError; +import org.onap.optf.cmso.common.CmsoRequestError; import org.onap.optf.ticketmgt.service.rs.models.ActiveTicketsRequest; import org.onap.optf.ticketmgt.service.rs.models.ActiveTicketsResponse; import org.springframework.web.bind.annotation.PathVariable; @@ -72,7 +72,7 @@ public interface AvailabilityInterface { + "optimizer will begin to poll the request until COMPLETED.", response = ActiveTicketsResponse.class) @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"), - @ApiResponse(code = 400, message = "Bad request", response = CMSRequestError.class), + @ApiResponse(code = 400, message = "Bad request", response = CmsoRequestError.class), @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)}) public Response getActiveTickets( @ApiParam(value = "v1") @PathParam("apiVersion") @PathVariable( @@ -92,7 +92,7 @@ public interface AvailabilityInterface { + "receipt of the response.", response = ActiveTicketsResponse.class) @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"), - @ApiResponse(code = 404, message = "Not found.", response = CMSRequestError.class), + @ApiResponse(code = 404, message = "Not found.", response = CmsoRequestError.class), @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)}) public Response pollActiveTickets( @ApiParam(value = "v1") @PathParam("apiVersion") @PathVariable( @@ -111,7 +111,7 @@ public interface AvailabilityInterface { + " treat Not found reponse on as normal.", response = ActiveTicketsResponse.class) @ApiResponses(value = {@ApiResponse(code = 204, message = "OK"), - @ApiResponse(code = 404, message = "Not found", response = CMSRequestError.class), + @ApiResponse(code = 404, message = "Not found", response = CmsoRequestError.class), @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)}) public Response deleteActiveTicketsRequest( @ApiParam(value = "v1") @PathParam("apiVersion") @PathVariable( diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/TicketManagement.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/TicketManagement.java index 16346bf..60a517b 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/TicketManagement.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/TicketManagement.java @@ -47,7 +47,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import org.onap.optf.cmso.common.CMSRequestError; +import org.onap.optf.cmso.common.CmsoRequestError; import org.onap.optf.ticketmgt.service.rs.models.TicketData; @Api("Ticket Management") @@ -61,7 +61,7 @@ public interface TicketManagement { @ApiOperation(value = "Fetch Ticket", notes = "Returns ticket information for the provided ticket id.", response = TicketData.class) @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"), - @ApiResponse(code = 404, message = "No record found", response = CMSRequestError.class), + @ApiResponse(code = 404, message = "No record found", response = CmsoRequestError.class), @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)}) public Response fetchTicket(@ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion, @ApiParam(value = "Unique ticket identifier") @PathParam("id") String id); @@ -74,7 +74,7 @@ public interface TicketManagement { @ApiResponses(value = { @ApiResponse(code = 200, message = "Ticket Created. Ticket Id returned.", response = TicketData.class), - @ApiResponse(code = 400, message = "Bad request.", response = CMSRequestError.class), + @ApiResponse(code = 400, message = "Bad request.", response = CmsoRequestError.class), @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)}) public Response createTicket(@ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion, @ApiParam(value = "Data for creating a ticket") TicketData ticketData); @@ -85,7 +85,7 @@ public interface TicketManagement { @Produces({MediaType.APPLICATION_JSON}) @ApiOperation(value = "Update Ticket", notes = "Updates a ticket to the passed data") @ApiResponses(value = {@ApiResponse(code = 204, message = "Ticket Updated."), - @ApiResponse(code = 400, message = "Bad request.", response = CMSRequestError.class), + @ApiResponse(code = 400, message = "Bad request.", response = CmsoRequestError.class), @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)}) public Response updateTicket(@ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion, @ApiParam(value = "Data for updating a ticket") TicketData ticketData); @@ -96,8 +96,8 @@ public interface TicketManagement { @Produces({MediaType.APPLICATION_JSON}) @ApiOperation(value = "Cancel the ticket", notes = "Cancels the ticket.") @ApiResponses(value = {@ApiResponse(code = 204, message = "Delete successful"), - @ApiResponse(code = 404, message = "No record found", response = CMSRequestError.class), - @ApiResponse(code = 400, message = "Bad request", response = CMSRequestError.class), + @ApiResponse(code = 404, message = "No record found", response = CmsoRequestError.class), + @ApiResponse(code = 400, message = "Bad request", response = CmsoRequestError.class), @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)}) public Response deleteScheduleRequest( @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion, @@ -113,7 +113,7 @@ public interface TicketManagement { @ApiOperation(value = "Search Tickets", notes = "Returns a list of based upon the filter criteria.", response = TicketData.class, responseContainer = "List") @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"), - @ApiResponse(code = 400, message = "Bad request", response = CMSRequestError.class), + @ApiResponse(code = 400, message = "Bad request", response = CmsoRequestError.class), @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)}) public Response searchTcikets( @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion, diff --git a/cmso-topology/src/main/java/org/onap/observations/MessageHeaders.java b/cmso-topology/src/main/java/org/onap/observations/MessageHeaders.java index fe6cea2..ccb7e56 100644 --- a/cmso-topology/src/main/java/org/onap/observations/MessageHeaders.java +++ b/cmso-topology/src/main/java/org/onap/observations/MessageHeaders.java @@ -65,7 +65,7 @@ public class MessageHeaders { } /** The Constant supportedMajorVersions. */ - public static final Map supportedMajorVersions = new HashMap(); + private static final Map supportedMajorVersions = new HashMap(); static { supportedMajorVersions.put("v1", "0"); @@ -73,7 +73,7 @@ public class MessageHeaders { } /** The Constant supportedMajorMinorVersions. */ - public static final Set supportedMajorMinorVersions = new HashSet(); + private static final Set supportedMajorMinorVersions = new HashSet(); static { supportedMajorMinorVersions.add("v1.0"); @@ -81,10 +81,10 @@ public class MessageHeaders { } /** The Constant latestVersion. */ - public static final String latestVersion = "2.0.0"; + private static final String latestVersion = "2.0.0"; /** The Constant patchVersion. */ - public static final String patchVersion = "0"; + private static final String patchVersion = "0"; /** * From string. @@ -152,4 +152,20 @@ public class MessageHeaders { } return true; } + + public static Map getSupportedmajorversions() { + return supportedMajorVersions; + } + + public static Set getSupportedmajorminorversions() { + return supportedMajorMinorVersions; + } + + public static String getLatestversion() { + return latestVersion; + } + + public static String getPatchversion() { + return patchVersion; + } } diff --git a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/filters/CmsoContainerFilters.java b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/filters/CmsoContainerFilters.java index 2418aec..2729613 100644 --- a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/filters/CmsoContainerFilters.java +++ b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/filters/CmsoContainerFilters.java @@ -68,8 +68,8 @@ public class CmsoContainerFilters implements ContainerRequestFilter, ContainerRe MultivaluedMap respHeaders = responseContext.getHeaders(); String minorVersion = reqHeaders.getFirst(HeadersEnum.MinorVersion.toString()); respHeaders.add(HeadersEnum.MinorVersion.toString(), minorVersion); - respHeaders.add(HeadersEnum.LatestVersion.toString(), MessageHeaders.latestVersion); - respHeaders.add(HeadersEnum.PatchVersion.toString(), MessageHeaders.patchVersion); + respHeaders.add(HeadersEnum.LatestVersion.toString(), MessageHeaders.getLatestversion()); + respHeaders.add(HeadersEnum.PatchVersion.toString(), MessageHeaders.getPatchVersion()); } catch (Exception e) { if (e instanceof WebApplicationException) { @@ -110,7 +110,7 @@ public class CmsoContainerFilters implements ContainerRequestFilter, ContainerRe } String minorVersion = headers.getFirst(HeadersEnum.MinorVersion.toString()); if (minorVersion == null) { - minorVersion = MessageHeaders.supportedMajorVersions.get(majorVersion); + minorVersion = MessageHeaders.getSupportedmajorversions().get(majorVersion); headers.add(HeadersEnum.MinorVersion.toString(), minorVersion); } if (!MessageHeaders.validateMajorMinorVersion(majorVersion, minorVersion)) { -- cgit 1.2.3-korg