aboutsummaryrefslogtreecommitdiffstats
path: root/cmso-service
diff options
context:
space:
mode:
authorShankaranarayanan Puzhavakath Narayanan <snarayanan@research.att.com>2019-03-26 01:18:51 +0000
committerGerrit Code Review <gerrit@onap.org>2019-03-26 01:18:51 +0000
commit0cdbed256bdcbebc79553f652e73fda0546b1e10 (patch)
treeba672e4d0a94a49ddcb32f52b36c74239bb67e6a /cmso-service
parent6bafd191888694191183afb6ecc8a2a5ec346b18 (diff)
parent42232be81bfd5cddabc42af9a79ec0abdb89e6be (diff)
Merge "Commit 9 for Create Optimized Sched API"
Diffstat (limited to 'cmso-service')
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/OptimizerRequest.java164
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/OptimizerResponse.java105
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/OptimizerScheduleInfo.java82
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/ScheduledElement.java127
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/UnScheduledElement.java103
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminTool.java11
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminToolImpl.java29
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/BaseSchedulerServiceImpl.java169
8 files changed, 681 insertions, 109 deletions
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/OptimizerRequest.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/OptimizerRequest.java
new file mode 100644
index 0000000..058d8c1
--- /dev/null
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/OptimizerRequest.java
@@ -0,0 +1,164 @@
+/*
+ * 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.optimizer.model;
+
+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.ArrayList;
+import java.util.List;
+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.PolicyInfo;
+
+@ApiModel(value = "Optimizer Request",
+ description = "Request to provide an \"conflict free\" schedule for passed elements.")
+public class OptimizerRequest implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private static EELFLogger log = EELFManager.getInstance().getLogger(OptimizerRequest.class);
+
+ @ApiModelProperty(value = "Unique Id of the request")
+ private String requestId;
+
+ @ApiModelProperty(value = "Concurrency limit for this request")
+ private Integer concurrencyLimit;
+
+ @ApiModelProperty(value = "Expected duration of normal change")
+ private Integer normalDuration;
+
+ @ApiModelProperty(value = "Additional duration for failed change")
+ private Integer additionalDuration;
+
+ @ApiModelProperty(value = "Implementation specific name value pairs.")
+ private List<NameValue> commonData;
+
+ @ApiModelProperty(value = "Lists of desired change windows to schedule the elements.")
+ private List<ChangeWindow> changeWindows = new ArrayList<>();
+
+ @ApiModelProperty(value = "List of the elements to schedule.")
+ private List<ElementInfo> elements = new ArrayList<>();
+
+ @ApiModelProperty(value = "List of the policies to control optimization.")
+ private List<PolicyInfo> policies = new ArrayList<>();
+
+ public String getRequestId() {
+ return requestId;
+ }
+
+
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+
+
+ public List<PolicyInfo> getPolicies() {
+ return policies;
+ }
+
+
+ public void setPolicies(List<PolicyInfo> policies) {
+ this.policies = policies;
+ }
+
+
+ public List<NameValue> getCommonData() {
+ return commonData;
+ }
+
+
+ public void setCommonData(List<NameValue> commonData) {
+ this.commonData = commonData;
+ }
+
+
+ public List<ElementInfo> getElements() {
+ return elements;
+ }
+
+
+ public void setElements(List<ElementInfo> elements) {
+ this.elements = elements;
+ }
+
+
+ public List<ChangeWindow> getChangeWindows() {
+ return changeWindows;
+ }
+
+
+ public void setChangeWindows(List<ChangeWindow> changeWindows) {
+ this.changeWindows = changeWindows;
+ }
+
+
+ public Integer getConcurrencyLimit() {
+ return concurrencyLimit;
+ }
+
+
+ public void setConcurrencyLimit(Integer concurrencyLimit) {
+ this.concurrencyLimit = concurrencyLimit;
+ }
+
+
+ public Integer getNormalDuration() {
+ return normalDuration;
+ }
+
+
+ public void setNormalDuration(Integer normalDuration) {
+ this.normalDuration = normalDuration;
+ }
+
+
+ public Integer getAdditionalDuration() {
+ return additionalDuration;
+ }
+
+
+ public void setAdditionalDuration(Integer additionalDuration) {
+ this.additionalDuration = additionalDuration;
+ }
+
+
+ @Override
+ public String toString() {
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ return mapper.writeValueAsString(this);
+ } catch (JsonProcessingException e) {
+ log.debug("Error in toString()", e);
+ }
+ return "";
+ }
+
+}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/OptimizerResponse.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/OptimizerResponse.java
new file mode 100644
index 0000000..9971595
--- /dev/null
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/OptimizerResponse.java
@@ -0,0 +1,105 @@
+/*
+ * 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.model;
+
+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.ArrayList;
+import java.util.List;
+
+@ApiModel(value = "Optimizer Response", description = "Response to optimizer request for the requested elements.")
+public class OptimizerResponse implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private static EELFLogger log = EELFManager.getInstance().getLogger(OptimizerResponse.class);
+
+ public enum OptimizeScheduleStatus {
+ CREATED, PENDING_TOPOLOGY, PENDING_TICKETS, PENDING_OPTIMIZER, COMPLETED, FAILED, DELETED,
+ }
+
+ @ApiModelProperty(value = "Unique Id of the request")
+ private String requestId;
+
+ @ApiModelProperty(value = "Status of the optimization")
+ private OptimizeScheduleStatus status;
+
+ @ApiModelProperty(value = "Message for failed optimization")
+ private String errorMessage;
+
+
+ @ApiModelProperty(value = "List of schedules returned by the optimizer.")
+ private List<OptimizerScheduleInfo> schedules = new ArrayList<>();
+
+ public String getRequestId() {
+ return requestId;
+ }
+
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+
+
+ public List<OptimizerScheduleInfo> getSchedules() {
+ return schedules;
+ }
+
+ public void setSchedules(List<OptimizerScheduleInfo> schedules) {
+ this.schedules = schedules;
+ }
+
+ public OptimizeScheduleStatus getStatus() {
+ return status;
+ }
+
+ public void setStatus(OptimizeScheduleStatus status) {
+ this.status = status;
+ }
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ @Override
+ public String toString() {
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ return mapper.writeValueAsString(this);
+ } catch (JsonProcessingException e) {
+ log.debug("Error in toString()", e);
+ }
+ return "";
+ }
+
+}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/OptimizerScheduleInfo.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/OptimizerScheduleInfo.java
new file mode 100644
index 0000000..92ce981
--- /dev/null
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/OptimizerScheduleInfo.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ *
+ * Copyright © 2019 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ *
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed under the Creative
+ * Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+package org.onap.optf.cmso.optimizer.model;
+
+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.ArrayList;
+import java.util.List;
+
+@ApiModel(value = "Optimizer Schedule Info", description = "Schedule Information returned from optimizer request.")
+public class OptimizerScheduleInfo implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private static EELFLogger log = EELFManager.getInstance().getLogger(OptimizerScheduleInfo.class);
+
+ @ApiModelProperty(value = "Lists of elements with start times.")
+ private List<ScheduledElement> scheduledElements = new ArrayList<>();
+
+ @ApiModelProperty(value = "Lists of elements that were not able to be scheduled.")
+ private List<UnScheduledElement> unScheduledElements = new ArrayList<>();
+
+
+ public List<ScheduledElement> getScheduledElements() {
+ return scheduledElements;
+ }
+
+
+ public void setScheduledElements(List<ScheduledElement> scheduledElements) {
+ this.scheduledElements = scheduledElements;
+ }
+
+
+ public List<UnScheduledElement> getUnScheduledElements() {
+ return unScheduledElements;
+ }
+
+
+ public void setUnScheduledElements(List<UnScheduledElement> unScheduledElements) {
+ this.unScheduledElements = unScheduledElements;
+ }
+
+
+ @Override
+ public String toString() {
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ return mapper.writeValueAsString(this);
+ } catch (JsonProcessingException e) {
+ log.debug("Error in toString()", e);
+ }
+ return "";
+ }
+}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/ScheduledElement.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/ScheduledElement.java
new file mode 100644
index 0000000..db92863
--- /dev/null
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/ScheduledElement.java
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ *
+ * Copyright © 2019 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ *
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed under the Creative
+ * Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+package org.onap.optf.cmso.optimizer.model;
+
+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.Date;
+import org.springframework.format.annotation.DateTimeFormat;
+
+@ApiModel(value = "Scheduled Element", description = "Scheduled element returned by the optimizer.")
+public class ScheduledElement implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private static EELFLogger log = EELFManager.getInstance().getLogger(ScheduledElement.class);
+
+ public enum ScheduleType {
+ UNKNOWN, GROUP_DISPATCH, INDIVIDUAL,
+ }
+
+ @ApiModelProperty(value = "Element identifier")
+ private String elementId;
+
+ @ApiModelProperty(value = "Group identifier")
+ private String groupId;
+
+ private ScheduleType scheduleType = ScheduleType.UNKNOWN;
+
+ @ApiModelProperty(value = "Earliest time for which changes may begin.")
+ @DateTimeFormat(pattern = "yyyy-MM-dd'T'hh:mm:ss'Z'")
+ private Date startTime;
+
+ @ApiModelProperty(value = "Latest time by which all changes must be completed.")
+ @DateTimeFormat(pattern = "yyyy-MM-dd'T'hh:mm:ss'Z'")
+ private Date endTime;
+
+ @ApiModelProperty(value = "Expected duration of change in seconds.")
+ private Long durationSeconds;
+
+ public String getElementId() {
+ return elementId;
+ }
+
+ public void setElementId(String elementId) {
+ this.elementId = elementId;
+ }
+
+
+ public String getGroupId() {
+ return groupId;
+ }
+
+ public void setGroupId(String groupId) {
+ this.groupId = groupId;
+ }
+
+ public ScheduleType getScheduleType() {
+ return scheduleType;
+ }
+
+ public void setScheduleType(ScheduleType scheduleType) {
+ this.scheduleType = scheduleType;
+ }
+
+ public Date getStartTime() {
+ return startTime;
+ }
+
+ public void setStartTime(Date startTime) {
+ this.startTime = startTime;
+ }
+
+ public Date getEndTime() {
+ return endTime;
+ }
+
+ public void setEndTime(Date endTime) {
+ this.endTime = endTime;
+ }
+
+ public Long getDurationSeconds() {
+ return durationSeconds;
+ }
+
+ public void setDurationSeconds(Long durationSeconds) {
+ this.durationSeconds = durationSeconds;
+ }
+
+ @Override
+ public String toString() {
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ return mapper.writeValueAsString(this);
+ } catch (JsonProcessingException e) {
+ log.debug("Error in toString()", e);
+ }
+ return "";
+ }
+}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/UnScheduledElement.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/UnScheduledElement.java
new file mode 100644
index 0000000..be6e89d
--- /dev/null
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/model/UnScheduledElement.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ *
+ * Copyright © 2019 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ *
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed under the Creative
+ * Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+package org.onap.optf.cmso.optimizer.model;
+
+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.ArrayList;
+import java.util.List;
+
+@ApiModel(value = "Unscheduled Element", description = "Scheduled element returned by the optimizer.")
+public class UnScheduledElement implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private static EELFLogger log = EELFManager.getInstance().getLogger(UnScheduledElement.class);
+
+ public enum NotScheduledReason {
+ ConcurrencyConstraint, AvailabilityConstraint, Other,
+ }
+
+ @ApiModelProperty(value = "Element identifier")
+ private String elementId;
+
+ @ApiModelProperty(value = "Group identifier")
+ private String groupId;
+
+ @ApiModelProperty(value = "List of reasons not able to schedule this element.")
+ private List<NotScheduledReason> notScheduledReaons = new ArrayList<>();
+
+ @ApiModelProperty(value = "List of messages not able to schedule this element.")
+ private List<String> notScheduledMessages = new ArrayList<>();
+
+ public String getElementId() {
+ return elementId;
+ }
+
+ public void setElementId(String elementId) {
+ this.elementId = elementId;
+ }
+
+ public List<NotScheduledReason> getNotScheduledReaons() {
+ return notScheduledReaons;
+ }
+
+ public void setNotScheduledReaons(List<NotScheduledReason> notScheduledReaons) {
+ this.notScheduledReaons = notScheduledReaons;
+ }
+
+ public List<String> getNotScheduledMessages() {
+ return notScheduledMessages;
+ }
+
+ public void setNotScheduledMessages(List<String> notScheduledMessages) {
+ this.notScheduledMessages = notScheduledMessages;
+ }
+
+ public String getGroupId() {
+ return groupId;
+ }
+
+ public void setGroupId(String groupId) {
+ this.groupId = groupId;
+ }
+
+ @Override
+ public String toString() {
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ return mapper.writeValueAsString(this);
+ } catch (JsonProcessingException e) {
+ log.debug("Error in toString()", e);
+ }
+ return "";
+ }
+}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminTool.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminTool.java
index 10eedf8..6be8159 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminTool.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminTool.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,12 +44,6 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-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/AdminToolImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminToolImpl.java
index 8ec4f4f..fa182b4 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminToolImpl.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminToolImpl.java
@@ -1,27 +1,27 @@
/*
* 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.
@@ -31,28 +31,26 @@
package org.onap.optf.cmso.service.rs;
+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.common.PropertiesManagement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
@Controller
public class AdminToolImpl implements AdminTool {
private static EELFLogger log = EELFManager.getInstance().getLogger(AdminToolImpl.class);
- @Context
+ @Context
UriInfo uri;
-
+
@Context
HttpServletRequest request;
-
+
@Autowired
PropertiesManagement pm;
@@ -60,8 +58,9 @@ public class AdminToolImpl implements AdminTool {
@Override
public Response exec(String apiVersion, String id) {
log.info("AdminTool.exec entered");
- if (id.length() < 4)
+ if (id.length() < 4) {
return Response.ok("").build();
+ }
String encrypted = PropertiesManagement.getEncryptedValue(id);
Response response = Response.ok(encrypted).build();
return response;
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 787bd60..18678ff 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
@@ -1,44 +1,39 @@
/*
- * 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
+ * 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.
- *
- *
- * 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 java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
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.LogMessages;
@@ -54,13 +49,10 @@ 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.ScheduleMessage;
+import org.onap.optf.cmso.service.rs.models.v2.OptimizedScheduleMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
@Controller
public class BaseSchedulerServiceImpl {
private static EELFLogger log = EELFManager.getInstance().getLogger(BaseSchedulerServiceImpl.class);
@@ -77,39 +69,39 @@ public class BaseSchedulerServiceImpl {
@Autowired
ScheduleApprovalDAO scheduleApprovalDAO;
- protected Schedule validateAndAddScheduleRequest(ScheduleMessage scheduleMessage, List<DomainData> domainData)
- throws CMSException {
+ protected Schedule validateAndAddScheduleRequest(OptimizedScheduleMessage scheduleMessage,
+ List<DomainData> domainData) throws CMSException {
messageValidations(scheduleMessage);
- Schedule s = scheduleDAO.findByDomainScheduleID(scheduleMessage.getDomain(), scheduleMessage.getScheduleId());
+ Schedule sch = scheduleDAO.findByDomainScheduleID(scheduleMessage.getDomain(), scheduleMessage.getScheduleId());
- if (s != null) {
+ if (sch != null) {
throw new CMSAlreadyExistsException(scheduleMessage.getDomain(), scheduleMessage.getScheduleId());
}
- s = new Schedule();
- s.setUuid(UUID.randomUUID());
- s.setUserId(scheduleMessage.getUserId());
- s.setCreateDateTimeMillis(System.currentTimeMillis());
- s.setDomain(scheduleMessage.getDomain());
- s.setScheduleId(scheduleMessage.getScheduleId());
- s.setOptimizerTransactionId(s.getScheduleId()); // No reason these cannot be the same as
- // these
- // are 1<=>1 at this
- // point.
- s.setScheduleName(scheduleMessage.getScheduleName());
- s.setOptimizerAttemptsToSchedule(0);
- s.setScheduleInfo(scheduleMessage.getSchedulingInfo().toString());
- s.setStatus(CMSStatusEnum.PendingSchedule.toString());
- scheduleDAO.save(s);
+ sch = new Schedule();
+ sch.setUuid(UUID.randomUUID());
+ sch.setUserId(scheduleMessage.getUserId());
+ sch.setCreateDateTimeMillis(System.currentTimeMillis());
+ sch.setDomain(scheduleMessage.getDomain());
+ sch.setScheduleId(scheduleMessage.getScheduleId());
+ sch.setOptimizerTransactionId(sch.getScheduleId()); // No reason these cannot be the same as
+ // these
+ // are 1<=>1 at this
+ // point.
+ sch.setScheduleName(scheduleMessage.getScheduleName());
+ sch.setOptimizerAttemptsToSchedule(0);
+ sch.setScheduleInfo(scheduleMessage.getSchedulingData().toString());
+ sch.setStatus(CMSStatusEnum.PendingSchedule.toString());
+ scheduleDAO.save(sch);
for (DomainData dd : domainData) {
- dd.setUuid(UUID.randomUUID());
- s.addDomainData(dd);
+ dd.setUuid(UUID.randomUUID());
+ sch.addDomainData(dd);
domainDataDAO.save(dd);
}
- scheduleDAO.save(s);
- return s;
+ scheduleDAO.save(sch);
+ return sch;
}
- private void messageValidations(ScheduleMessage scheduleMessage) throws CMSException {
+ private void messageValidations(OptimizedScheduleMessage scheduleMessage) throws CMSException {
if (scheduleMessage.getScheduleName() == null || scheduleMessage.getScheduleName().equals("")) {
throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "schedulerName", "");
}
@@ -119,47 +111,48 @@ public class BaseSchedulerServiceImpl {
}
protected void deleteScheduleRequest(String domain, String scheduleId) throws CMSException {
- Schedule s = scheduleDAO.findByDomainScheduleID(domain, scheduleId);
- if (s == null) {
+ Schedule sch = scheduleDAO.findByDomainScheduleID(domain, scheduleId);
+ if (sch == null) {
throw new CMSNotFoundException(domain, scheduleId);
}
- CMSStatusEnum currentStatus = CMSStatusEnum.Completed.fromString(s.getStatus());
- s.setDeleteDateTimeMillis(System.currentTimeMillis());
+ CMSStatusEnum currentStatus = CMSStatusEnum.Completed.fromString(sch.getStatus());
+ sch.setDeleteDateTimeMillis(System.currentTimeMillis());
switch (currentStatus) {
case Scheduled:
// TODO CLose all tickets....
- s.setStatus(CMSStatusEnum.Cancelled.toString());
+ sch.setStatus(CMSStatusEnum.Cancelled.toString());
break;
case NotificationsInitiated:
throw new CMSException(Status.NOT_ACCEPTABLE, LogMessages.CANNOT_CANCEL_IN_PROGRESS);
default:
- s.setStatus(CMSStatusEnum.Deleted.toString());
+ sch.setStatus(CMSStatusEnum.Deleted.toString());
}
- scheduleDAO.save(s);
+ scheduleDAO.save(sch);
}
- protected Schedule processApproval(Schedule s, String domain, ApprovalMessage approvalMessage) throws CMSException {
- String scheduleId = s.getScheduleId();
+ protected Schedule processApproval(Schedule sch, String domain, ApprovalMessage approvalMessage)
+ throws CMSException {
+ String scheduleId = sch.getScheduleId();
ApprovalType approvalType =
- approvalTypeDAO.findByDomainAndType(domain, approvalMessage.getApprovalType().toString());
+ approvalTypeDAO.findByDomainAndType(domain, approvalMessage.getApprovalType().toString());
if (approvalType == null) {
throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, "approvalType",
- approvalMessage.getApprovalType().toString());
+ approvalMessage.getApprovalType().toString());
}
- if (!s.getStatus().equals(CMSStatusEnum.PendingApproval.toString())) {
+ if (!sch.getStatus().equals(CMSStatusEnum.PendingApproval.toString())) {
throw new CMSException(Status.PRECONDITION_FAILED, LogMessages.NOT_PENDING_APPROVAL, domain, scheduleId,
- s.getStatus());
+ sch.getStatus());
}
if (approvalMessage.getApprovalUserId() == null || approvalMessage.getApprovalUserId().equals("")) {
throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "userId");
}
ScheduleApproval sa = null;
// only 1 approval per user....
- if (s.getScheduleApprovals() != null) {
- for (ScheduleApproval scheduleApproval : s.getScheduleApprovals()) {
+ if (sch.getScheduleApprovals() != null) {
+ for (ScheduleApproval scheduleApproval : sch.getScheduleApprovals()) {
if (scheduleApproval.getUserId().equals(approvalMessage.getApprovalUserId())
- && scheduleApproval.getApprovalTypesUuid().equals(approvalType.getUuid())) {
+ && scheduleApproval.getApprovalTypesUuid().equals(approvalType.getUuid())) {
sa = scheduleApproval;
}
}
@@ -167,32 +160,33 @@ public class BaseSchedulerServiceImpl {
if (sa == null) {
sa = new ScheduleApproval();
sa.setUuid(UUID.randomUUID());
- sa.setSchedule(s);
+ sa.setSchedule(sch);
sa.setApprovalTypesUuid(approvalType.getUuid());
sa.setUserId(approvalMessage.getApprovalUserId());
}
// Ignore what time is on the message
sa.setApprovalDateTimeMillis(System.currentTimeMillis());
sa.setStatus(approvalMessage.getApprovalStatus().toString());
- sa.setSchedule(s);
- s.addScheduleApproval(sa);
- scheduleDAO.save(s);
+ sa.setSchedule(sch);
+ sch.addScheduleApproval(sa);
+ scheduleDAO.save(sch);
if (sa.getStatus().equals(ApprovalStatusEnum.Rejected.toString())) {
- s.setStatus(CMSStatusEnum.Rejected.toString());
+ sch.setStatus(CMSStatusEnum.Rejected.toString());
} else {
- if (allApprovalsReceived(s, sa))
- s.setStatus(CMSStatusEnum.Accepted.toString());
+ if (allApprovalsReceived(sch, sa)) {
+ sch.setStatus(CMSStatusEnum.Accepted.toString());
+ }
}
- scheduleDAO.save(s);
- return s;
+ scheduleDAO.save(sch);
+ return sch;
}
private boolean allApprovalsReceived(Schedule schedule, ScheduleApproval sa) {
Map<UUID, Integer> requiredApprovalsByType = new HashMap<>(); // Approval
- // countdown
+ // countdown
Map<UUID, ApprovalType> approvalsByType = new HashMap<>(); // Just
- // for
- // logging
+ // for
+ // logging
List<ApprovalType> approvalTypes = approvalTypeDAO.findByDomain(schedule.getDomain());
for (ApprovalType at : approvalTypes) {
@@ -218,7 +212,7 @@ public class BaseSchedulerServiceImpl {
requiredApprovalsByType.put(approval.getApprovalTypesUuid(), remaining);
} else {
log.warn("Ignored Unidentified approval type {0} for domain {1}", approval.getApprovalTypesUuid(),
- schedule.getDomain());
+ schedule.getDomain());
}
}
}
@@ -230,5 +224,4 @@ public class BaseSchedulerServiceImpl {
}
return true;
}
-
}