aa397ae1770ec173c3b09008f9230abf4dce173c
[optf/cmso.git] /
1 /*
2  * Copyright © 2017-2019 AT&T Intellectual Property.
3  * Modifications Copyright © 2018 IBM.
4  * 
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
8  * 
9  *         http://www.apache.org/licenses/LICENSE-2.0
10  * 
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.
16  * 
17  * 
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
22  * 
23  *         https://creativecommons.org/licenses/by/4.0/
24  * 
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.
30 */
31
32 package org.onap.optf.cmso.service.rs;
33
34 import javax.servlet.http.HttpServletRequest;
35 import javax.ws.rs.core.Context;
36 import javax.ws.rs.core.Response;
37
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;
56
57 import com.att.eelf.configuration.EELFLogger;
58 import com.att.eelf.configuration.EELFManager;
59
60 @Controller
61 public class CMSOOptimizedScheduleServiceImpl implements CMSOOptimizedScheduleService {
62     private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();
63
64     @Autowired
65     CMSQueueJob qJob;
66
67     @Autowired
68     Environment env;
69
70     @Autowired
71     ChangeManagementScheduleDAO cmScheduleDAO;
72
73     @Autowired
74     ChangeManagementGroupDAO cmGroupDAO;
75
76     @Autowired
77     ChangeManagementChangeWindowDAO cmChangeWindowDAO;
78
79     @Autowired
80     ChangeManagementDetailDAO cmDetailsDAO;
81
82     @Autowired
83     ScheduleQueryDAO scheduleQueryDAO;
84
85     @Autowired
86     ScheduleDAO scheduleDAO;
87
88     @Autowired
89     TmClient tmClient;
90
91     @Autowired
92     BuildCreateRequest buildCreateRequest;
93
94
95     @Context 
96     HttpServletRequest request;
97     
98     @Override
99     @Transactional
100     public Response createScheduleRequest(String apiVersion, String scheduleId, OptimizedScheduleMessage scheduleMessage) 
101     {
102         Observation.report(LogMessages.CREATE_SCHEDULE_REQUEST, "Received", request.getRemoteAddr(), scheduleId,
103                 scheduleMessage.toString());
104         Response response = null;
105         try {
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();
115         }
116         Observation.report(LogMessages.CREATE_SCHEDULE_REQUEST, "Returned", request.getRemoteAddr(), scheduleId,
117                 response.getStatusInfo().toString());
118         return response;
119     }
120
121
122 }