2 * Copyright © 2017-2019 AT&T Intellectual Property.
3 * Modifications Copyright © 2018 IBM.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a 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 or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 * Unless otherwise specified, all documentation contained herein is licensed
19 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
20 * you may not use this documentation except in compliance with the License.
21 * You may obtain a copy of the License at
23 * https://creativecommons.org/licenses/by/4.0/
25 * Unless required by applicable law or agreed to in writing, documentation
26 * distributed under the License is distributed on an "AS IS" BASIS,
27 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28 * See the License for the specific language governing permissions and
29 * limitations under the License.
32 package org.onap.optf.cmso.service.rs;
34 import javax.servlet.http.HttpServletRequest;
35 import javax.ws.rs.core.Context;
36 import javax.ws.rs.core.Response;
38 import org.onap.observations.Observation;
39 import org.onap.optf.cmso.common.LogMessages;
40 import org.onap.optf.cmso.common.exceptions.CMSException;
41 import org.onap.optf.cmso.eventq.CMSQueueJob;
42 import org.onap.optf.cmso.model.dao.ChangeManagementChangeWindowDAO;
43 import org.onap.optf.cmso.model.dao.ChangeManagementDetailDAO;
44 import org.onap.optf.cmso.model.dao.ChangeManagementGroupDAO;
45 import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO;
46 import org.onap.optf.cmso.model.dao.ScheduleDAO;
47 import org.onap.optf.cmso.model.dao.ScheduleQueryDAO;
48 import org.onap.optf.cmso.service.rs.models.v2.OptimizedScheduleMessage;
49 import org.onap.optf.cmso.ticketmgt.TmClient;
50 import org.onap.optf.cmso.ticketmgt.bean.BuildCreateRequest;
51 import org.springframework.beans.factory.annotation.Autowired;
52 import org.springframework.core.env.Environment;
53 import org.springframework.stereotype.Controller;
54 import org.springframework.transaction.annotation.Transactional;
55 import org.springframework.transaction.interceptor.TransactionAspectSupport;
57 import com.att.eelf.configuration.EELFLogger;
58 import com.att.eelf.configuration.EELFManager;
61 public class CMSOOptimizedScheduleServiceImpl implements CMSOOptimizedScheduleService {
62 private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();
71 ChangeManagementScheduleDAO cmScheduleDAO;
74 ChangeManagementGroupDAO cmGroupDAO;
77 ChangeManagementChangeWindowDAO cmChangeWindowDAO;
80 ChangeManagementDetailDAO cmDetailsDAO;
83 ScheduleQueryDAO scheduleQueryDAO;
86 ScheduleDAO scheduleDAO;
92 BuildCreateRequest buildCreateRequest;
96 HttpServletRequest request;
100 public Response createScheduleRequest(String apiVersion, String scheduleId, OptimizedScheduleMessage scheduleMessage)
102 Observation.report(LogMessages.CREATE_SCHEDULE_REQUEST, "Received", request.getRemoteAddr(), scheduleId,
103 scheduleMessage.toString());
104 Response response = null;
106 response = Response.accepted().build();
107 // } catch (CMSException e) {
108 // TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
109 // Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage());
110 // response = Response.status(e.getStatus()).entity(e.getRequestError()).build();
111 } catch (Exception e) {
112 Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
113 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
114 response = Response.serverError().build();
116 Observation.report(LogMessages.CREATE_SCHEDULE_REQUEST, "Returned", request.getRemoteAddr(), scheduleId,
117 response.getStatusInfo().toString());