summaryrefslogtreecommitdiffstats
path: root/cmso-service/src
diff options
context:
space:
mode:
Diffstat (limited to 'cmso-service/src')
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CommonServiceImpl.java423
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheck.java12
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheckImpl.java64
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/ApprovalMessage.java74
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/ChangeWindowMessage.java24
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/CmDetailsMessage.java6
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/CmDomainDataEnum.java35
7 files changed, 558 insertions, 80 deletions
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
new file mode 100644
index 0000000..52a0928
--- /dev/null
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CommonServiceImpl.java
@@ -0,0 +1,423 @@
+/*
+ * 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.service.rs;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+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.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.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.service.rs.models.ApprovalMessage;
+import org.onap.optf.cmso.service.rs.models.v2.ChangeWindow;
+import org.onap.optf.cmso.service.rs.models.v2.ElementInfo;
+import org.onap.optf.cmso.service.rs.models.v2.NameValue;
+import org.onap.optf.cmso.service.rs.models.v2.OptimizedScheduleMessage;
+import org.onap.optf.cmso.service.rs.models.v2.SchedulingData;
+import org.onap.optf.cmso.ticketmgt.TmClient;
+import org.onap.optf.cmso.ticketmgt.bean.BuildCreateRequest;
+import org.onap.optf.cmso.ticketmgt.bean.TmApprovalStatusEnum;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+import org.springframework.stereotype.Controller;
+
+@Controller
+public class CommonServiceImpl extends BaseSchedulerServiceImpl {
+ private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();
+
+ @Autowired
+ CMSQueueJob qqJob;
+
+ @Autowired
+ Environment env;
+
+ @Autowired
+ ChangeManagementScheduleDAO cmScheduleDAO;
+
+ @Autowired
+ ChangeManagementGroupDAO cmGroupDAO;
+
+ @Autowired
+ ChangeManagementChangeWindowDAO cmChangeWindowDAO;
+
+ @Autowired
+ ChangeManagementDetailDAO cmDetailsDAO;
+
+ @Autowired
+ ScheduleQueryDAO scheduleQueryDAO;
+
+ @Autowired
+ ScheduleDAO scheduleDAO;
+
+ @Autowired
+ ElementDataDAO elementDataDAO;
+
+ @Autowired
+ TmClient tmClient;
+
+ @Autowired
+ BuildCreateRequest buildCreateRequest;
+
+
+ protected void createSchedule(OptimizedScheduleMessage scheduleMessage, String scheduleId,
+ HttpServletRequest request) throws CMSException, JsonProcessingException {
+ if (!scheduleMessage.getDomain().equals(DomainsEnum.ChangeManagement.toString())) {
+ throw new CMSException(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",
+ scheduleMessage.getScheduleId());
+ }
+ // Force the name to be = to the ID because there is no way fot the provide a
+ // name
+ scheduleMessage.setScheduleName(scheduleMessage.getScheduleId());
+
+ List<DomainData> domainData = marshallDomainData(scheduleMessage);
+ Map<String, List<ElementInfo>> groups = new HashMap<>();
+ boolean immediate = validate(scheduleMessage, groups);
+ Schedule schedule = validateAndAddScheduleRequest(scheduleMessage, domainData);
+ if (immediate) {
+ createChangeManagementImmediate(schedule, scheduleMessage, groups);
+
+ // Create automatic approval
+ ApprovalMessage am = new ApprovalMessage();
+ am.setApprovalStatus(ApprovalStatusEnum.Accepted);
+ am.setApprovalType(ApprovalTypesEnum.Tier2);
+ am.setApprovalUserId(schedule.getUserId());
+ processApproveScheduleRequest(schedule, am, domainData);
+
+ } else {
+ createChangeManagement(schedule, scheduleMessage, groups);
+ }
+ }
+
+ /**
+ * Returns whether this is an immediate request.
+ */
+ private boolean validate(OptimizedScheduleMessage scheduleMessage, Map<String, List<ElementInfo>> groups)
+ throws CMSException {
+ SchedulingData info = scheduleMessage.getSchedulingData();
+ boolean immediate = true;
+ if (info == null) {
+ throw new CMSException(Status.BAD_REQUEST, LogMessages.UNABLE_TO_PARSE_SCHEDULING_INFO);
+ }
+
+ if (info.getAdditionalDurationInSeconds() == null) {
+ throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE,
+ "additionalDurationInSeconds");
+ }
+ if (info.getNormalDurationInSeconds() == null) {
+ throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE,
+ "normalDurationInSeconds");
+ }
+ if (info.getAdditionalDurationInSeconds() < 0) {
+ throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, "additionalDurationInSeconds",
+ info.getAdditionalDurationInSeconds().toString());
+ }
+ if (info.getNormalDurationInSeconds() < 1) {
+ throw new CMSException(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");
+ }
+ if (cw.getEndTime() == null) {
+ throw new CMSException(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(),
+ end.toString());
+ }
+ }
+ if (info.getConcurrencyLimit() == null) {
+ throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "concurrencyLimit");
+ }
+ if (info.getConcurrencyLimit() < 1) {
+ throw new CMSException(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");
+ }
+
+ for (ElementInfo element : info.getElements()) {
+ if (element.getGroupId() == null || element.getGroupId().equals("")) {
+ element.setElementId("default");
+ }
+ List<ElementInfo> groupedElements = groups.get(element.getGroupId());
+ if (groupedElements == null) {
+ groupedElements = new ArrayList<ElementInfo>();
+ groups.put(element.getGroupId(), groupedElements);
+ }
+
+ groupedElements.add(element);
+ }
+ return immediate;
+ }
+
+ private void createChangeManagement(Schedule schedule, OptimizedScheduleMessage scheduleMessage,
+ Map<String, List<ElementInfo>> groups) throws CMSException {
+ SchedulingData schedulingInfo = scheduleMessage.getSchedulingData();
+ for (String groupId : groups.keySet()) {
+
+ ChangeManagementGroup cmg = new ChangeManagementGroup();
+ cmg.setUuid(UUID.randomUUID());
+ cmg.setSchedulesUuid(schedule.getUuid());
+ cmg.setGroupId(groupId);
+ cmg.setPolicyId(schedulingInfo.getPolicies().toString());
+ cmg.setNormalDurationInSecs(schedulingInfo.getNormalDurationInSeconds());
+ cmg.setAdditionalDurationInSecs(schedulingInfo.getAdditionalDurationInSeconds());
+ cmg.setConcurrencyLimit(schedulingInfo.getConcurrencyLimit());
+ cmGroupDAO.save(cmg);
+ for (ChangeWindow cw : schedulingInfo.getChangeWindows()) {
+ ChangeManagementChangeWindow cmcw = new ChangeManagementChangeWindow();
+ cmcw.setUuid(UUID.randomUUID());
+ cmcw.setChangeManagementGroupUuid(cmg.getUuid());
+ cmcw.setStartTimeMillis(cw.getStartTime().getTime());
+ cmcw.setFinishTimeMillis(cw.getEndTime().getTime());
+ cmChangeWindowDAO.save(cmcw);
+ }
+
+ for (ElementInfo element : groups.get(groupId)) {
+ ChangeManagementSchedule cms = new ChangeManagementSchedule();
+ cms.setUuid(UUID.randomUUID());
+ cms.setChangeManagementGroupUuid(cmg.getUuid());
+ cms.setVnfName(element.getElementId());
+ cms.setStatus(CMSStatusEnum.PendingSchedule.toString());
+ cms.setRequest(element.getRequest().toString());
+ cmScheduleDAO.save(cms);
+ // Save elementData
+ saveElementData(cms, element);
+ }
+ }
+ }
+
+ private void saveElementData(ChangeManagementSchedule cms, ElementInfo element) {
+ List<NameValue> elementData = element.getElementData();
+ if (elementData != null) {
+ for (NameValue nv : elementData) {
+ ElementData ed = new ElementData();
+ ed.setUuid(UUID.randomUUID());
+ ed.setChangeManagementSchedulesUuid(cms.getUuid());
+ ed.setName(nv.getName());
+ // TODO Save as JSON
+ ed.setValue(nv.getValue().toString());
+ elementDataDAO.save(ed);
+ }
+ }
+
+ }
+
+ private void createChangeManagementImmediate(Schedule schedule, OptimizedScheduleMessage scheduleMessage,
+ Map<String, List<ElementInfo>> groups) throws CMSException, JsonProcessingException {
+ SchedulingData schedulingInfo = scheduleMessage.getSchedulingData();
+ for (String groupId : groups.keySet()) {
+ ChangeManagementGroup cmg = new ChangeManagementGroup();
+ cmg.setUuid(UUID.randomUUID());
+ cmg.setSchedulesUuid(schedule.getUuid());
+ cmg.setGroupId(groupId);
+ int duration = schedulingInfo.getNormalDurationInSeconds();
+ int backout = schedulingInfo.getAdditionalDurationInSeconds();
+ cmg.setStartTimeMillis(System.currentTimeMillis());
+ cmg.setFinishTimeMillis(System.currentTimeMillis() + ((duration * 1000) + (backout * 1000)));
+ cmg.setNormalDurationInSecs(duration);
+ cmg.setAdditionalDurationInSecs(backout);
+ cmGroupDAO.save(cmg);
+ for (ElementInfo element : groups.get(groupId)) {
+ ChangeManagementSchedule cms = new ChangeManagementSchedule();
+ cms.setUuid(UUID.randomUUID());
+ cms.setChangeManagementGroupUuid(cmg.getUuid());
+ cms.setVnfName(element.getElementId());
+ cms.setRequest(element.getRequest().toString());
+ cms.setStatus(CMSStatusEnum.PendingApproval.toString());
+ cmScheduleDAO.save(cms);
+ }
+ schedule.setStatus(CMSStatusEnum.PendingApproval.toString());
+ scheduleDAO.save(schedule);
+ }
+ }
+
+ protected void deleteChangeManagement(Schedule schedule) throws CMSException {
+ List<ChangeManagementGroup> cmgs = cmGroupDAO.findBySchedulesID(schedule.getUuid());
+
+ for (ChangeManagementGroup cmg : cmgs) {
+ List<ChangeManagementSchedule> schedules = cmScheduleDAO.findByChangeManagementGroupId(cmg.getUuid());
+ for (ChangeManagementSchedule s : schedules) {
+ CMSStatusEnum currentState = CMSStatusEnum.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());
+ break;
+ case Triggered:
+ // Too late...
+ break;
+ default:
+ s.setStatus(CMSStatusEnum.Deleted.toString());
+ }
+ cmScheduleDAO.save(s);
+ }
+ }
+
+ }
+
+ //
+ // Marshall commonData into DB DomainData
+ // No validation.
+ //
+ private List<DomainData> marshallDomainData(OptimizedScheduleMessage scheduleMessage) throws CMSException {
+ List<NameValue> domainData = scheduleMessage.getCommonData();
+ List<DomainData> domainDataList = new ArrayList<DomainData>();
+ for (NameValue nameValue : domainData) {
+ DomainData dd = new DomainData();
+ dd.setName(nameValue.getName());
+ Object obj = nameValue.getValue();
+ String objString = obj.toString();
+ // TODO: Store as json
+ dd.setValue(objString);
+ domainDataList.add(dd);
+ }
+ return domainDataList;
+ }
+
+
+ protected void processApproveScheduleRequest(Schedule sch, ApprovalMessage approval, List<DomainData> domainData)
+ throws CMSException {
+ sch = scheduleDAO.lockOne(sch.getUuid());
+ String domain = DomainsEnum.ChangeManagement.toString();
+ processApproval(sch, domain, approval);
+ if (sch.getStatus().equals(CMSStatusEnum.Accepted.toString())) {
+ openTickets(sch, domainData);
+ }
+ if (sch.getStatus().equals(CMSStatusEnum.Rejected.toString())) {
+ updateChangeManagementSchedules(sch, CMSStatusEnum.ApprovalRejected);
+ }
+ }
+
+ private void openTickets(Schedule sch, List<DomainData> domainData) throws CMSException {
+ debug.debug("Entered openTickets scheduleId=" + sch.getScheduleId());
+
+ Integer maxvnfsperticket = env.getProperty("tm.vnfs.per.ticket", Integer.class, 1);
+
+ List<ChangeManagementGroup> groups = cmGroupDAO.findBySchedulesID(sch.getUuid());
+ for (ChangeManagementGroup group : groups) {
+
+ List<ChangeManagementSchedule> schedules = cmScheduleDAO.findByChangeManagementGroupId(group.getUuid());
+ List<List<ChangeManagementSchedule>> ticketList = new ArrayList<List<ChangeManagementSchedule>>();
+ List<ChangeManagementSchedule> current = null;
+ for (ChangeManagementSchedule cms : schedules) {
+ if (current == null || current.size() == maxvnfsperticket) {
+ current = new ArrayList<ChangeManagementSchedule>();
+ ticketList.add(current);
+ }
+ current.add(cms);
+ }
+ for (List<ChangeManagementSchedule> list : ticketList) {
+ openTicketForList(sch, group, list, domainData);
+ }
+ }
+ debug.debug("Exited openTickets scheduleId=" + sch.getScheduleId());
+ }
+
+ private void openTicketForList(Schedule schedule, ChangeManagementGroup group, List<ChangeManagementSchedule> list,
+ List<DomainData> domainData) throws CMSException {
+ List<String> vnfNames = new ArrayList<>();
+ for (ChangeManagementSchedule cms : list) {
+ vnfNames.add(cms.getVnfName());
+ }
+
+ debug.debug("Calling createChangeTicket scheduleId=" + schedule.getScheduleId() + ", group="
+ + group.getGroupId(), ", vnfNames=" + vnfNames);
+ String changeId = tmClient.createChangeTicket(schedule, group, vnfNames, domainData);
+
+ // Pre-approve the ticket
+ for (ChangeManagementSchedule cms : list) {
+ cms.getTmApprovalStatus();
+ cms.setTmChangeId(changeId);
+ cms.setTmApprovalStatus(TmApprovalStatusEnum.Approved.toString());
+ // cms.setStatus(CMSStatusEnum.PendingApproval.toString());
+ if (cms.getStartTimeMillis() == null) {
+ cms.setStatus(CMSStatusEnum.ScheduledImmediate.toString());
+ }
+ else {
+ cms.setStatus(CMSStatusEnum.Scheduled.toString());
+ }
+ cmScheduleDAO.save(cms);
+ }
+ schedule.setStatus(CMSStatusEnum.Scheduled.toString());
+ scheduleDAO.save(schedule);
+ }
+
+ private void updateChangeManagementSchedules(Schedule sch, CMSStatusEnum approvalrejected) {
+ debug.debug("Entered updateChangeManagementSchedules");
+ List<ChangeManagementGroup> groups = cmGroupDAO.findBySchedulesID(sch.getUuid());
+ for (ChangeManagementGroup group : groups) {
+ List<ChangeManagementSchedule> schedules = cmScheduleDAO.findByChangeManagementGroupId(group.getUuid());
+ for (ChangeManagementSchedule schedule : schedules) {
+ schedule.setStatus(approvalrejected.toString());
+ cmScheduleDAO.save(schedule);
+ }
+ }
+ debug.debug("Exited updateChangeManagementSchedules");
+ }
+
+}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheck.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheck.java
index fb69e31..981657c 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheck.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheck.java
@@ -31,6 +31,11 @@
package org.onap.optf.cmso.service.rs;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@@ -39,15 +44,8 @@ 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.service.rs.models.HealthCheckMessage;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-
@Api("CMSO Administration")
@Path("/{apiVersion}")
@Produces({MediaType.APPLICATION_JSON})
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 8e6b09e..6f60248 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
@@ -1,27 +1,27 @@
/*
* 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.
@@ -31,16 +31,14 @@
package org.onap.optf.cmso.service.rs;
-import java.util.List;
-
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
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.ApprovalType;
import org.onap.optf.cmso.model.dao.ApprovalTypeDAO;
-import org.onap.optf.cmso.optimizer.CMSOptimizerClient;
+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;
import org.onap.optf.cmso.sostatus.MsoStatusClient;
@@ -49,24 +47,25 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Controller;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
+/**
+ * @author jf9860
+ *
+ */
@Controller
public class HealthCheckImpl implements HealthCheck {
private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();
- @Context
+ @Context
UriInfo uri;
-
+
@Context
HttpServletRequest request;
-
+
@Autowired
TmClient tmClient;
@Autowired
- CMSOptimizerClient optimizerClient;
+ CmsoOptimizerClient optimizerClient;
@Autowired
ApprovalTypeDAO approvalTypeDAO;
@@ -77,6 +76,13 @@ public class HealthCheckImpl implements HealthCheck {
@Autowired
MsoStatusClient msoStatusClient;
+ /**
+ * Health check.
+ *
+ * @param apiVersion the api version
+ * @param checkInterfaces the check interfaces
+ * @return the response
+ */
@Override
public Response healthCheck(String apiVersion, Boolean checkInterfaces) {
debug.debug("Entered healthcheck");
@@ -89,30 +95,38 @@ public class HealthCheckImpl implements HealthCheck {
addToHealthCheckMessage(hc, msoStatusClient.healthCheck());
addToHealthCheckMessage(hc, optimizerClient.healthCheck());
}
- addToHealthCheckMessage(hc, this.healthCheck());
+ addToHealthCheckMessage(hc, this.healthCheckCrap());
- if (hc.getHealthy())
+ if (hc.getHealthy()) {
response = Response.ok().entity(hc).build();
- else
+ }
+ else {
response = Response.status(Response.Status.BAD_REQUEST).entity(hc).build();
+ }
return response;
}
private void addToHealthCheckMessage(HealthCheckMessage hc, HealthCheckComponent hcc) {
- if (!hcc.getHealthy())
+ if (!hcc.getHealthy()) {
hc.setHealthy(false);
+ }
hc.setHostname(System.getenv("HOSTNAME"));
hc.addComponent(hcc);
}
- public HealthCheckComponent healthCheck() {
+ /**
+ * Health check.
+ *
+ * @return the health check component
+ */
+ private HealthCheckComponent healthCheckCrap() {
HealthCheckComponent hcc = new HealthCheckComponent();
hcc.setName("Scheduler Database");
String url = env.getProperty("spring.datasource.url");
hcc.setUrl(url);
try {
- List<ApprovalType> approvalTypes = approvalTypeDAO.findByDomain("HealthCheck");
+ approvalTypeDAO.findByDomain("HealthCheck");
hcc.setHealthy(true);
hcc.setStatus("OK");
} catch (Exception e) {
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/ApprovalMessage.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/ApprovalMessage.java
index 0d43799..f038905 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/ApprovalMessage.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/ApprovalMessage.java
@@ -1,27 +1,27 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
+ * Copyright � 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright � 2018 IBM.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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.
@@ -31,20 +31,20 @@
package org.onap.optf.cmso.service.rs.models;
-import java.io.Serializable;
-import java.sql.Timestamp;
-import org.onap.optf.cmso.common.ApprovalStatusEnum;
-import org.onap.optf.cmso.common.ApprovalTypesEnum;
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.sql.Timestamp;
+import org.onap.optf.cmso.common.ApprovalStatusEnum;
+import org.onap.optf.cmso.common.ApprovalTypesEnum;
/**
* The persistent class for the approval_types database table.
- *
+ *
*/
@ApiModel(value = "Schedule Approval Request", description = "Request to accept or reject an optimized time slot.")
public class ApprovalMessage implements Serializable {
@@ -62,38 +62,84 @@ public class ApprovalMessage implements Serializable {
private Timestamp approvalDateTime;
+ /**
+ * Gets the approval user id.
+ *
+ * @return the approval user id
+ */
public String getApprovalUserId() {
return approvalUserId;
}
+ /**
+ * Sets the approval user id.
+ *
+ * @param approvalUserId the new approval user id
+ */
public void setApprovalUserId(String approvalUserId) {
this.approvalUserId = approvalUserId;
}
+ /**
+ * Gets the approval status.
+ *
+ * @return the approval status
+ */
public ApprovalStatusEnum getApprovalStatus() {
return approvalStatus;
}
+ /**
+ * Sets the approval status.
+ *
+ * @param approvalStatus the new approval status
+ */
public void setApprovalStatus(ApprovalStatusEnum approvalStatus) {
this.approvalStatus = approvalStatus;
}
+ /**
+ * Gets the approval type.
+ *
+ * @return the approval type
+ */
public ApprovalTypesEnum getApprovalType() {
return approvalType;
}
+ /**
+ * Sets the approval type.
+ *
+ * @param approvalType the new approval type
+ */
public void setApprovalType(ApprovalTypesEnum approvalType) {
this.approvalType = approvalType;
}
+ /**
+ * Gets the approval date time.
+ *
+ * @return the approval date time
+ */
public Timestamp getApprovalDateTime() {
return approvalDateTime;
}
+ /**
+ * Sets the approval date time.
+ *
+ * @param approvalDateTime the new approval date time
+ */
public void setApprovalDateTime(Timestamp approvalDateTime) {
this.approvalDateTime = approvalDateTime;
}
+ /**
+ * To string.
+ *
+ * @return the string
+ */
+ @Override
public String toString() {
ObjectMapper mapper = new ObjectMapper();
try {
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/ChangeWindowMessage.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/ChangeWindowMessage.java
index 58aaa2e..071ab8f 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/ChangeWindowMessage.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/ChangeWindowMessage.java
@@ -1,27 +1,27 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
+ * Copyright � 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright � 2018 IBM.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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.
@@ -31,16 +31,17 @@
package org.onap.optf.cmso.service.rs.models;
-import java.io.Serializable;
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;
@ApiModel(value = "Change Window",
- description = "Time window within which the scheduler optimizer can schedule the changes for the group of NVFs")
+ description = "Time window within which the scheduler"
+ + " optimizer can schedule the changes for the group of NVFs")
public class ChangeWindowMessage implements Serializable {
private static final long serialVersionUID = 1L;
private static EELFLogger log = EELFManager.getInstance().getLogger(ChangeWindowMessage.class);
@@ -67,6 +68,7 @@ public class ChangeWindowMessage implements Serializable {
this.endTime = endTime;
}
+ @Override
public String toString() {
ObjectMapper mapper = new ObjectMapper();
try {
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/CmDetailsMessage.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/CmDetailsMessage.java
index b021af9..a526065 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/CmDetailsMessage.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/CmDetailsMessage.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright � 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright � 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,11 +31,11 @@
package org.onap.optf.cmso.service.rs.models;
+import io.swagger.annotations.ApiModel;
import java.io.Serializable;
import java.util.List;
import org.onap.optf.cmso.model.ChangeManagementDetail;
import org.onap.optf.cmso.model.Schedule;
-import io.swagger.annotations.ApiModel;
/**
* The persistent class for the change_management_groups database table.
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/CmDomainDataEnum.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/CmDomainDataEnum.java
index 675a8d9..570fc06 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/CmDomainDataEnum.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/CmDomainDataEnum.java
@@ -1,27 +1,27 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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.
@@ -32,15 +32,10 @@
package org.onap.optf.cmso.service.rs.models;
public enum CmDomainDataEnum {
- WorkflowName(true), CallbackUrl(true), ServiceType(false), VnfType(false), SubscriberName(false), CallbackData(
- true),;
- private final Boolean required;
-
- private CmDomainDataEnum(boolean required) {
- this.required = required;
- }
-
- public boolean isRequired() {
- return required;
- }
+ Scheduler_RequestData,
+ @Deprecated
+ CallbackData,
+ @Deprecated
+ WorkflowName,
+ ;
}