aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJerry Flood <jflood@att.com>2019-03-06 17:28:23 -0500
committerJerry Flood <jflood@att.com>2019-03-12 22:36:23 -0400
commit12f42cc3fbd834354bf0ac25aaf970907aed9793 (patch)
tree27aff759115b126ccb7c5c7a3db2f16494ce6514
parentde4d01c9cad1a228946f098a82c3039b572da1f9 (diff)
Commit 7 for TM API definition
Initial commit of Ticket Management simulator Multiple commits required due to commit size limitation. Change-Id: I5dada2f82bfb9081012a13d9c8ea093580aa2a32 Issue-ID: OPTFRA-432 Signed-off-by: Jerry Flood <jflood@att.com>
-rw-r--r--cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/TicketManagement.java138
-rw-r--r--cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/TicketManagementImpl.java180
-rw-r--r--cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/ActiveTicketsRequest.java115
3 files changed, 433 insertions, 0 deletions
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
new file mode 100644
index 0000000..1931296
--- /dev/null
+++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/TicketManagement.java
@@ -0,0 +1,138 @@
+/*
+ * 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.service.rs;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+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.ticketmgt.service.rs.models.TicketData;
+
+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("Ticket Management")
+@Path("/{apiVersion}")
+@Produces({MediaType.APPLICATION_JSON})
+public interface TicketManagement {
+ // ******************************************************************
+ @GET
+ @Path("/ticket/{id}")
+ @Produces({MediaType.APPLICATION_JSON})
+ @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 = 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);
+
+ // ******************************************************************
+ @POST
+ @Path("/ticket/")
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "Create Ticket", notes = "Creates a ticket for the passed data")
+ @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 = 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);
+
+ // ******************************************************************
+ @PUT
+ @Path("/ticket/")
+ @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 = 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);
+
+ // ******************************************************************
+ @DELETE
+ @Path("/ticket/{id}")
+ @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 = 500, message = "Unexpected Runtime error", response = Exception.class)})
+ public Response deleteScheduleRequest(
+ @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion,
+ @ApiParam(value = "Ticket id to uniquely identify the ticket being deleted.") @PathParam("id") String id);
+
+
+
+ // ******************************************************************
+ @GET
+ @Path("/tickets")
+ @Produces({MediaType.APPLICATION_JSON})
+ @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 = 500, message = "Unexpected Runtime error", response = Exception.class)})
+ public Response searchTcikets(
+ @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion,
+ @ApiParam(value = "Ticket identifier",
+ allowMultiple = true) @QueryParam("id") String id,
+ @ApiParam(value = "Element Id",
+ allowMultiple = true) @QueryParam("elementId") String elementId,
+ @ApiParam(value = "Start time <low>,<high>",
+ allowMultiple = true) @QueryParam("startTime") String startTime,
+ @ApiParam(value = "Finish time <low>,<high>",
+ allowMultiple = true) @QueryParam("finishTime") String finishTime,
+ @ApiParam(value = "Maximum number of tickets to return") @QueryParam("maxTickets") Integer maxTickets,
+ @ApiParam(value = "Return tickets > last id") @QueryParam("lastId") String lastId);
+
+}
diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/TicketManagementImpl.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/TicketManagementImpl.java
new file mode 100644
index 0000000..4346f0b
--- /dev/null
+++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/TicketManagementImpl.java
@@ -0,0 +1,180 @@
+/*
+ * 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.service.rs;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+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.ticketmgt.common.LogMessages;
+import org.onap.optf.ticketmgt.service.rs.models.TicketData;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+import org.springframework.stereotype.Controller;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+@Controller
+public class TicketManagementImpl implements TicketManagement {
+ private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();
+
+ @Autowired
+ Environment env;
+
+ @Context
+ UriInfo uri;
+
+ @Context
+ HttpServletRequest request;
+
+ @Override
+ public Response fetchTicket(String apiVersion, String id) {
+ // TODO Auto-generated method stub
+ Observation.report(LogMessages.FETCH_TICKET, "Received", request.getRemoteAddr(), id, "");
+ Response response = null;
+ try
+ {
+ TicketData td = new TicketData();
+ td.setId(id);
+ response = Response.ok(td).build();
+// } catch (CMSException e) {
+// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+// Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage());
+// response = Response.status(e.getStatus()).entity(e.getRequestError()).build();
+ } catch (Exception e) {
+ Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+ response = Response.serverError().build();
+ }
+ Observation.report(LogMessages.FETCH_TICKET, "Returned", request.getRemoteAddr(), id, response.getStatusInfo().toString());
+ return response;
+ }
+
+ @Override
+ public Response createTicket(String apiVersion, TicketData ticketData) {
+ // TODO Auto-generated method stub
+ String id = UUID.randomUUID().toString();
+ Observation.report(LogMessages.CREATE_TICKET, "Received", request.getRemoteAddr(), id, "");
+ Response response = null;
+ try
+ {
+ ticketData.setId(id);
+ response = Response.ok(ticketData).build();
+// } catch (CMSException e) {
+// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+// Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage());
+// response = Response.status(e.getStatus()).entity(e.getRequestError()).build();
+ } catch (Exception e) {
+ Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+ response = Response.serverError().build();
+ }
+ Observation.report(LogMessages.CREATE_TICKET, "Returned", request.getRemoteAddr(), id, response.getStatusInfo().toString());
+ return response;
+ }
+
+ @Override
+ public Response updateTicket(String apiVersion, TicketData ticketData) {
+ // TODO Auto-generated method stub
+ String id = ticketData.getId();
+ Observation.report(LogMessages.UPDATE_TICKET, "Received", request.getRemoteAddr(), id, "");
+ Response response = null;
+ try
+ {
+ response = Response.noContent().build();
+// } catch (CMSException e) {
+// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+// Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage());
+// response = Response.status(e.getStatus()).entity(e.getRequestError()).build();
+ } catch (Exception e) {
+ Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+ response = Response.serverError().build();
+ }
+ Observation.report(LogMessages.UPDATE_TICKET, "Returned", request.getRemoteAddr(), id, response.getStatusInfo().toString());
+ return response;
+ }
+
+
+ @Override
+ public Response searchTcikets(String apiVersion, String id, String elementId, String startTime, String finishTime,
+ Integer maxTickets, String lastId) {
+ // TODO Auto-generated method stub
+ // TODO Auto-generated method stub
+ Observation.report(LogMessages.SEARCH_TICKETS, "Received", request.getRemoteAddr(), uri.getPath(), "");
+ Response response = null;
+ List<TicketData> list = new ArrayList<>();
+ try
+ {
+ response = Response.ok(list).build();
+// } catch (CMSException e) {
+// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+// Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage());
+// response = Response.status(e.getStatus()).entity(e.getRequestError()).build();
+ } catch (Exception e) {
+ Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+ response = Response.serverError().build();
+ }
+ Observation.report(LogMessages.SEARCH_TICKETS, "Returned", request.getRemoteAddr(), uri.getPath(), response.getStatusInfo().toString());
+ return response;
+ }
+
+ @Override
+ public Response deleteScheduleRequest(String apiVersion, String id) {
+ Observation.report(LogMessages.CANCEL_TICKET, "Received", request.getRemoteAddr(), id, "");
+ Response response = null;
+ try
+ {
+ response = Response.noContent().build();
+// } catch (CMSException e) {
+// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+// Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage());
+// response = Response.status(e.getStatus()).entity(e.getRequestError()).build();
+ } catch (Exception e) {
+ Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+ response = Response.serverError().build();
+ }
+ Observation.report(LogMessages.CANCEL_TICKET, "Returned", request.getRemoteAddr(), id, response.getStatusInfo().toString());
+ return response;
+ }
+
+}
diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/ActiveTicketsRequest.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/ActiveTicketsRequest.java
new file mode 100644
index 0000000..9c979de
--- /dev/null
+++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/ActiveTicketsRequest.java
@@ -0,0 +1,115 @@
+/*
+ * 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.service.rs.models;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+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;
+
+@ApiModel(value = "Ticket Management Request", description = "Request to retrieve active tickets for the provided elements.")
+public class ActiveTicketsRequest implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private static EELFLogger log = EELFManager.getInstance().getLogger(ActiveTicketsRequest.class);
+
+ @ApiModelProperty(value = "Unique Id of the request")
+ private String requestId;
+
+ @ApiModelProperty(
+ value = "Implementation specific name value pairs provided to be passed to Ticket Management query .")
+ private List<NameValue> commonData;
+
+ @ApiModelProperty(
+ value = "Lists of desired change windows for which TicketData will be returned.")
+ private List<ChangeWindow> changeWindows = new ArrayList<>();
+
+ @ApiModelProperty(value = "List of the elements for which TicketData will be returned.")
+ private List<ElementCriteria> elements = new ArrayList<>();
+
+ public String getRequestId() {
+ return requestId;
+ }
+
+
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+
+
+ public List<NameValue> getCommonData() {
+ return commonData;
+ }
+
+
+ public void setCommonData(List<NameValue> commonData) {
+ this.commonData = commonData;
+ }
+
+
+ public List<ChangeWindow> getChangeWindows() {
+ return changeWindows;
+ }
+
+
+ public void setChangeWindows(List<ChangeWindow> changeWindows) {
+ this.changeWindows = changeWindows;
+ }
+
+
+ public List<ElementCriteria> getElements() {
+ return elements;
+ }
+
+
+ public void setElements(List<ElementCriteria> elements) {
+ this.elements = elements;
+ }
+
+
+ public String toString() {
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ return mapper.writeValueAsString(this);
+ } catch (JsonProcessingException e) {
+ log.debug("Error in toString()", e);
+ }
+ return "";
+ }
+
+}