diff options
author | Jerry Flood <jflood@att.com> | 2019-03-28 15:41:57 -0400 |
---|---|---|
committer | Jerry Flood <jflood@att.com> | 2019-03-28 16:02:41 -0400 |
commit | fe8c1df09a3c74321831b40f6f953016d746aa61 (patch) | |
tree | eb7be4e995899ff38a385219f37e952f47e48c02 /cmso-topology/src/main | |
parent | b49d93de48e5404b1a17ddb1b2f4c3b432de9506 (diff) |
Merge missing optimizer classes
Implement policy model.
Issue-ID: OPTFRA-458
Change-Id: Ibb7f8535af910dff3ab9ce671b62fb826899058c
Signed-off-by: Jerry Flood <jflood@att.com>
Diffstat (limited to 'cmso-topology/src/main')
5 files changed, 48 insertions, 19 deletions
diff --git a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/common/LogMessages.java b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/common/LogMessages.java index fd15b25..4ce4776 100644 --- a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/common/LogMessages.java +++ b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/common/LogMessages.java @@ -43,7 +43,7 @@ public enum LogMessages implements ObservationInterface { CREATE_TICKET("Create Ticket {0} : {1}: {2} : {3}", Status.OK, Level.INFO), CANCEL_TICKET("Cancel ticket {0} : {1}: {2} : {3}", Status.OK, Level.INFO), UPDATE_TICKET("Update ticket {0} : {1}: {2} : {3}", Status.OK, Level.INFO), - GET_ACTIVE_TICKETS("Get active tickets {0} : {1}: {2} : {3}", Status.OK, Level.INFO), + GET_CURRENT_TOPOLOGY("Get active tickets {0} : {1}: {2} : {3}", Status.OK, Level.INFO), SEARCH_TICKETS("Search tickets {0} : {1}: {2} : {3}", Status.OK, Level.INFO), TICKET_NOT_FOUND("Ticket not found id={0}", Status.NOT_FOUND, Level.INFO), diff --git a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/HealthCheckImpl.java b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/HealthCheckImpl.java index c1dfe81..a1bacb9 100644 --- a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/HealthCheckImpl.java +++ b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/HealthCheckImpl.java @@ -60,7 +60,7 @@ public class HealthCheckImpl implements HealthCheck { HealthCheckMessage hc = new HealthCheckMessage(); hc.setHealthy(true); - addToHealthCheckMessage(hc, this.healthCheckDb()); + //addToHealthCheckMessage(hc, this.healthCheckDb()); if (hc.getHealthy()) { response = Response.ok().entity(hc).build(); @@ -87,7 +87,7 @@ public class HealthCheckImpl implements HealthCheck { */ private HealthCheckComponent healthCheckDb() { HealthCheckComponent hcc = new HealthCheckComponent(); - hcc.setName("Ticket Management Database"); + hcc.setName("Database"); String url = env.getProperty("spring.datasource.url"); hcc.setUrl(url); try { diff --git a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/TopologyInterfaceImpl.java b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/TopologyInterfaceImpl.java index 6ed401f..c824d20 100644 --- a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/TopologyInterfaceImpl.java +++ b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/TopologyInterfaceImpl.java @@ -1,23 +1,23 @@ /* * 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 @@ -28,12 +28,16 @@ package org.onap.optf.cmso.topology.service.rs; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; +import java.util.List; 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.observations.Observation; import org.onap.optf.cmso.topology.common.LogMessages; +import org.onap.optf.cmso.topology.service.rs.models.ElementCriteria; +import org.onap.optf.cmso.topology.service.rs.models.ElementInfo; +import org.onap.optf.cmso.topology.service.rs.models.ElementLocation; import org.onap.optf.cmso.topology.service.rs.models.TopologyRequest; import org.onap.optf.cmso.topology.service.rs.models.TopologyResponse; import org.onap.optf.cmso.topology.service.rs.models.TopologyResponse.TopologyRequestStatus; @@ -60,12 +64,26 @@ public class TopologyInterfaceImpl implements TopologyInterface { public Response retrieveCurrentTopology(String apiVersion, TopologyRequest topologyRequest) { // TODO Auto-generated method stub String id = topologyRequest.getRequestId(); - Observation.report(LogMessages.GET_ACTIVE_TICKETS, "Received", request.getRemoteAddr(), id, ""); + Observation.report(LogMessages.GET_CURRENT_TOPOLOGY, "Received", request.getRemoteAddr(), id, ""); Response response = null; try { + // Only implementing synchronous responses for Dublin TopologyResponse atr = new TopologyResponse(); atr.setRequestId(topologyRequest.getRequestId()); atr.setStatus(TopologyRequestStatus.COMPLETED); + List<ElementCriteria> elements = topologyRequest.getElements(); + // At a minimum, return the requested elements + for (ElementCriteria criteria : elements) + { + ElementInfo element = new ElementInfo(); + element.setElementId(criteria.getElementId()); + ElementLocation loc = new ElementLocation(); + loc.setLat(new Float(-0.00)); + loc.setLon(new Float(0.00)); + element.setElementLocation(loc); + atr.getElements().add(element); + } + response = Response.ok(atr).build(); // } catch (CMSException e) { // TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); @@ -76,7 +94,7 @@ public class TopologyInterfaceImpl implements TopologyInterface { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); response = Response.serverError().build(); } - Observation.report(LogMessages.GET_ACTIVE_TICKETS, "Returned", request.getRemoteAddr(), id, + Observation.report(LogMessages.GET_CURRENT_TOPOLOGY, "Returned", request.getRemoteAddr(), id, response.getStatusInfo().toString()); return response; } @@ -85,7 +103,7 @@ public class TopologyInterfaceImpl implements TopologyInterface { @Override public Response getTopologyRequest(String apiVersion, String id) { // TODO Auto-generated method stub - Observation.report(LogMessages.GET_ACTIVE_TICKETS, "Received", request.getRemoteAddr(), id, ""); + Observation.report(LogMessages.GET_CURRENT_TOPOLOGY, "Received", request.getRemoteAddr(), id, ""); Response response = null; try { TopologyResponse atr = new TopologyResponse(); @@ -101,7 +119,7 @@ public class TopologyInterfaceImpl implements TopologyInterface { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); response = Response.serverError().build(); } - Observation.report(LogMessages.GET_ACTIVE_TICKETS, "Returned", request.getRemoteAddr(), id, + Observation.report(LogMessages.GET_CURRENT_TOPOLOGY, "Returned", request.getRemoteAddr(), id, response.getStatusInfo().toString()); return response; } @@ -110,7 +128,7 @@ public class TopologyInterfaceImpl implements TopologyInterface { @Override public Response deleteTopologyRequest(String apiVersion, String id) { // TODO Auto-generated method stub - Observation.report(LogMessages.GET_ACTIVE_TICKETS, "Received", request.getRemoteAddr(), id, ""); + Observation.report(LogMessages.GET_CURRENT_TOPOLOGY, "Received", request.getRemoteAddr(), id, ""); Response response = null; try { response = Response.noContent().build(); @@ -123,7 +141,7 @@ public class TopologyInterfaceImpl implements TopologyInterface { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); response = Response.serverError().build(); } - Observation.report(LogMessages.GET_ACTIVE_TICKETS, "Returned", request.getRemoteAddr(), id, + Observation.report(LogMessages.GET_CURRENT_TOPOLOGY, "Returned", request.getRemoteAddr(), id, response.getStatusInfo().toString()); return response; } diff --git a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/models/TopologyResponse.java b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/models/TopologyResponse.java index d22b64a..fc4f7df 100644 --- a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/models/TopologyResponse.java +++ b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/models/TopologyResponse.java @@ -42,7 +42,7 @@ public class TopologyResponse implements Serializable { private static EELFLogger log = EELFManager.getInstance().getLogger(TopologyResponse.class); public enum TopologyRequestStatus { - IN_PROGRESS, COMPLETED, + IN_PROGRESS, COMPLETED, FAILED } @ApiModelProperty(value = "Unique Id of the request") @@ -58,6 +58,9 @@ public class TopologyResponse implements Serializable { + "If IN_PROGRESS is returned, the optimizer will enter asynchronous polling mode.") private TopologyRequestStatus status; + @ApiModelProperty(value = "FAILED request error message.") + private String errorMessage; + @ApiModelProperty(value = "If request is asynchronous (IN_PROGRESS), suggested interval to the next poll.") private Integer pollingSeconds; @@ -101,6 +104,14 @@ public class TopologyResponse implements Serializable { this.referencedElements = referencedElements; } + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + /** * To string. * diff --git a/cmso-topology/src/main/resources/logmessages.properties b/cmso-topology/src/main/resources/logmessages.properties index de09032..8e20de6 100644 --- a/cmso-topology/src/main/resources/logmessages.properties +++ b/cmso-topology/src/main/resources/logmessages.properties @@ -1,9 +1,9 @@ -# Generated from org.onap.optf.ticketmgt.common.LogMessages +# Generated from org.onap.optf.cmso.topology.common.LogMessages FETCH_TICKET FETCH_TICKET|Fetch ticket {0} : {1}: {2} : {3}|No resolution needed|No action is required CREATE_TICKET CREATE_TICKET|Create Ticket {0} : {1}: {2} : {3}|No resolution needed|No action is required CANCEL_TICKET CANCEL_TICKET|Cancel ticket {0} : {1}: {2} : {3}|No resolution needed|No action is required UPDATE_TICKET UPDATE_TICKET|Update ticket {0} : {1}: {2} : {3}|No resolution needed|No action is required -GET_ACTIVE_TICKETS GET_ACTIVE_TICKETS|Get active tickets {0} : {1}: {2} : {3}|No resolution needed|No action is required +GET_CURRENT_TOPOLOGY GET_CURRENT_TOPOLOGY|Get active tickets {0} : {1}: {2} : {3}|No resolution needed|No action is required SEARCH_TICKETS SEARCH_TICKETS|Search tickets {0} : {1}: {2} : {3}|No resolution needed|No action is required TICKET_NOT_FOUND TICKET_NOT_FOUND|Ticket not found id={0}|No resolution needed|No action is required INVALID_ATTRIBUTE INVALID_ATTRIBUTE|Invalid attribute {0}={1}|No resolution needed|No action is required |