2 * ============LICENSE_START==============================================
3 * Copyright (c) 2019 AT&T Intellectual Property.
4 * =======================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 * not use this file except in compliance with the License. You may obtain a
7 * copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing
15 * permissions and limitations under the License.
16 * ============LICENSE_END=================================================
20 package org.onap.optf.cmso.optimizer.clients.ticketmgt;
22 import java.util.Optional;
23 import org.onap.observations.Observation;
24 import org.onap.optf.cmso.optimizer.clients.ticketmgt.models.ActiveTicketsResponse;
25 import org.onap.optf.cmso.optimizer.common.LogMessages;
26 import org.onap.optf.cmso.optimizer.model.Request;
27 import org.onap.optf.cmso.optimizer.model.Ticket;
28 import org.onap.optf.cmso.optimizer.model.dao.RequestDao;
29 import org.onap.optf.cmso.optimizer.model.dao.TicketDao;
30 import org.springframework.beans.factory.annotation.Autowired;
31 import org.springframework.core.env.Environment;
32 import org.springframework.stereotype.Component;
35 * Ticket Mgt request manager.
41 public class TicketMgtRequestManager {
47 RequestDao requestDao;
53 TicketMgtClient ticketmgtClient;
56 * Creates the topology request.
58 * @param requestRow the uuid
59 * @return the active tickets response
61 public ActiveTicketsResponse createTicketsRequest(Request requestRow) {
64 Optional<Ticket> rowOpt = ticketDao.findById(requestRow.getUuid());
65 if (rowOpt.isPresent()) {
71 row.setUuid(requestRow.getUuid());
72 row.setTicketsRetries(0);
74 ActiveTicketsResponse apiResponse = ticketmgtClient.makeRequest(requestRow, row);
75 switch (apiResponse.getStatus()) {
86 } catch (Exception e) {
87 Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());