Skip the temp-service-create if already exists
[transportpce.git] / servicehandler / src / main / java / org / opendaylight / transportpce / servicehandler / impl / ServicehandlerImpl.java
1 /*
2  * Copyright © 2017 Orange, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.transportpce.servicehandler.impl;
9
10 import com.google.common.util.concurrent.ListenableFuture;
11 import java.time.OffsetDateTime;
12 import java.time.ZoneOffset;
13 import java.time.format.DateTimeFormatter;
14 import java.util.Map;
15 import java.util.Optional;
16 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
17 import org.opendaylight.transportpce.common.OperationResult;
18 import org.opendaylight.transportpce.common.ResponseCodes;
19 import org.opendaylight.transportpce.pce.service.PathComputationService;
20 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
21 import org.opendaylight.transportpce.servicehandler.CatalogInput;
22 import org.opendaylight.transportpce.servicehandler.DowngradeConstraints;
23 import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
24 import org.opendaylight.transportpce.servicehandler.ServiceInput;
25 import org.opendaylight.transportpce.servicehandler.catalog.CatalogDataStoreOperations;
26 import org.opendaylight.transportpce.servicehandler.catalog.CatalogMapper;
27 import org.opendaylight.transportpce.servicehandler.listeners.NetworkListener;
28 import org.opendaylight.transportpce.servicehandler.listeners.PceListener;
29 import org.opendaylight.transportpce.servicehandler.listeners.RendererListener;
30 import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
31 import org.opendaylight.transportpce.servicehandler.service.RendererServiceWrapper;
32 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
33 import org.opendaylight.transportpce.servicehandler.validation.CatalogValidation;
34 import org.opendaylight.transportpce.servicehandler.validation.ServiceCreateValidation;
35 import org.opendaylight.transportpce.servicehandler.validation.checks.ComplianceCheckResult;
36 import org.opendaylight.transportpce.servicehandler.validation.checks.ServicehandlerComplianceCheck;
37 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRequestOutput;
38 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRerouteRequestOutput;
39 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.path.computation.reroute.request.input.EndpointsBuilder;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.RpcActions;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.ServiceNotificationTypes;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.configuration.response.common.ConfigurationResponseCommon;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.sdnc.request.header.SdncRequestHeaderBuilder;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.operational.mode.catalog.rev211210.operational.mode.catalog.OpenroadmOperationalModes;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.operational.mode.catalog.rev211210.operational.mode.catalog.SpecificOperationalModes;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.routing.constraints.HardConstraints;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.routing.constraints.SoftConstraints;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddOpenroadmOperationalModesToCatalogInput;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddOpenroadmOperationalModesToCatalogOutput;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddSpecificOperationalModesToCatalogInput;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.AddSpecificOperationalModesToCatalogOutput;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.EquipmentNotificationInput;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.EquipmentNotificationOutput;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.NetworkReOptimizationInput;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.NetworkReOptimizationOutput;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OpticalTunnelCreateInput;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OpticalTunnelCreateOutput;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OpticalTunnelRequestCancelInput;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OpticalTunnelRequestCancelOutput;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OrgOpenroadmServiceService;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateBulkInput;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateBulkOutput;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateComplexResultNotificationRequestInput;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateComplexResultNotificationRequestOutput;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInput;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateOutput;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateResultNotificationRequestInput;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateResultNotificationRequestOutput;
70 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteComplexResultNotificationRequestInput;
71 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteComplexResultNotificationRequestOutput;
72 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInput;
73 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInputBuilder;
74 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteOutput;
75 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteResultNotificationRequestInput;
76 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteResultNotificationRequestOutput;
77 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckBulkInput;
78 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckBulkOutput;
79 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckInput;
80 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckOutput;
81 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureBulkInput;
82 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureBulkOutput;
83 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureInput;
84 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureOutput;
85 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureResultNotificationRequestInput;
86 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureResultNotificationRequestOutput;
87 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteConfirmInput;
88 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteConfirmOutput;
89 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteConfirmResultNotificationRequestInput;
90 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteConfirmResultNotificationRequestOutput;
91 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteInput;
92 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRerouteOutput;
93 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationInput;
94 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationOutput;
95 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationResultNotificationRequestInput;
96 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRestorationResultNotificationRequestOutput;
97 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReversionInput;
98 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReversionOutput;
99 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReversionResultNotificationRequestInput;
100 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReversionResultNotificationRequestOutput;
101 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRollInput;
102 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRollOutput;
103 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRollResultNotificationRequestInput;
104 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceRollResultNotificationRequestOutput;
105 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceSrlgGetInput;
106 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceSrlgGetOutput;
107 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateBulkInput;
108 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateBulkOutput;
109 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateInput;
110 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateOutput;
111 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteInput;
112 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteOutput;
113 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.delete.input.ServiceDeleteReqInfo.TailRetention;
114 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.delete.input.ServiceDeleteReqInfoBuilder;
115 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.list.Services;
116 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZ;
117 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZKey;
118 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.resource.resource.TerminationPoint;
119 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePaths;
120 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessService;
121 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessServiceBuilder;
122 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceAEndBuilder;
123 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.process.service.ServiceZEndBuilder;
124 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
125 import org.opendaylight.yangtools.yang.common.RpcResult;
126 import org.osgi.service.component.annotations.Activate;
127 import org.osgi.service.component.annotations.Component;
128 import org.osgi.service.component.annotations.Reference;
129 import org.slf4j.Logger;
130 import org.slf4j.LoggerFactory;
131
132
133 /**
134  * Top level service interface providing main OpenROADM controller services.
135  */
136 @Component
137 public class ServicehandlerImpl implements OrgOpenroadmServiceService {
138     private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerImpl.class);
139     private static final String PUBLISHER = "ServiceHandler";
140     private static final String TEMP_SERVICE_CREATE_MSG = "tempServiceCreate: {}";
141     private static final String TEMP_SERVICE_DELETE_MSG = "tempServiceDelete: {}";
142     private static final String SERVICE_RESTORATION_MSG = "serviceRestoration: {}";
143     private static final String SERVICE_RECONFIGURE_MSG = "serviceReconfigure: {}";
144     private static final String SERVICE_FEASIBILITY_CHECK_MSG = "serviceFeasibilityCheck: {}";
145     private static final String SERVICE_DELETE_MSG = "serviceDelete: {}";
146     private static final String SERVICE_CREATE_MSG = "serviceCreate: {}";
147     private static final String ADD_OR_TO_CATALOG_MSG = "addORToCatalog: {}";
148     private static final String ADD_SPECIFIC_TO_CATALOG_MSG = "addSpecificToCatalog: {}";
149
150     private ServiceDataStoreOperations serviceDataStoreOperations;
151     private PCEServiceWrapper pceServiceWrapper;
152     private RendererServiceWrapper rendererServiceWrapper;
153     private PceListener pceListenerImpl;
154     private RendererListener rendererListenerImpl;
155     private NetworkListener networkModelListenerImpl;
156     private NotificationPublishService notificationPublishService;
157     private CatalogDataStoreOperations catalogDataStoreOperations;
158
159     @Activate
160     public ServicehandlerImpl(@Reference PathComputationService pathComputationService,
161             @Reference RendererServiceOperations rendererServiceOperations,
162             @Reference NotificationPublishService notificationPublishService,
163             @Reference PceListener pceListenerImpl,
164             @Reference RendererListener rendererListenerImpl,
165             @Reference NetworkListener networkModelListenerImpl,
166             @Reference ServiceDataStoreOperations serviceDataStoreOperations,
167             @Reference CatalogDataStoreOperations catalogDataStoreOperations) {
168         this.catalogDataStoreOperations = catalogDataStoreOperations;
169         this.serviceDataStoreOperations = serviceDataStoreOperations;
170         this.notificationPublishService =  notificationPublishService;
171         this.pceServiceWrapper = new PCEServiceWrapper(pathComputationService, notificationPublishService);
172         this.rendererServiceWrapper = new RendererServiceWrapper(rendererServiceOperations, notificationPublishService);
173         this.pceListenerImpl = pceListenerImpl;
174         this.rendererListenerImpl = rendererListenerImpl;
175         this.networkModelListenerImpl = networkModelListenerImpl;
176         LOG.info("ServicehandlerImpl Initiated");
177     }
178
179
180     // This is class is public so that these messages can be accessed from Junit (avoid duplications).
181     public static final class LogMessages {
182
183         public static final String PCE_CALLING;
184         public static final String ABORT_PCE_FAILED;
185         public static final String PCE_FAILED;
186         public static final String ABORT_SERVICE_NON_COMPLIANT;
187         public static final String SERVICE_NON_COMPLIANT;
188         public static final String RENDERER_DELETE_FAILED;
189         public static final String ABORT_VALID_FAILED;
190         public static final String ABORT_OR_TO_CATALOG_FAILED;
191         public static final String ABORT_SPECIFIC_TO_CATALOG_FAILED;
192
193         // Static blocks are generated once and spare memory.
194         static {
195             PCE_CALLING = "Calling PCE";
196             ABORT_PCE_FAILED = "Aborting: PCE calculation failed ";
197             PCE_FAILED = "PCE calculation failed";
198             ABORT_SERVICE_NON_COMPLIANT = "Aborting: non-compliant service ";
199             SERVICE_NON_COMPLIANT = "non-compliant service";
200             RENDERER_DELETE_FAILED = "Renderer service delete failed";
201             ABORT_VALID_FAILED = "Aborting: validation of service create request failed";
202             ABORT_OR_TO_CATALOG_FAILED = "Aborting: validation of add OR to catalog request failed";
203             ABORT_SPECIFIC_TO_CATALOG_FAILED = "Aborting: validation of add Specific to catalog request failed";
204         }
205
206         public static String serviceInDS(String serviceName) {
207             return "Service '" + serviceName + "' already exists in datastore";
208         }
209
210         public static String serviceNotInDS(String serviceName) {
211             return "Service '" + serviceName + "' does not exist in datastore";
212         }
213
214         public static String servicePathNotInDS(String serviceName) {
215             return "Service Path from '" + serviceName + "' does not exist in datastore";
216         }
217
218         public static String serviceInService(String serviceName) {
219             return "Service '" + serviceName + "' is in 'inService' state";
220         }
221
222         private LogMessages() {
223         }
224     }
225
226     @Override
227     public ListenableFuture<RpcResult<ServiceCreateOutput>> serviceCreate(ServiceCreateInput input) {
228         LOG.info("RPC serviceCreate received");
229         // Validation
230         OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
231                 new ServiceInput(input), RpcActions.ServiceCreate);
232         if (!validationResult.isSuccess()) {
233             LOG.warn(SERVICE_CREATE_MSG, LogMessages.ABORT_VALID_FAILED);
234             return ModelMappingUtils.createCreateServiceReply(
235                     input, ResponseCodes.FINAL_ACK_YES,
236                     validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
237         }
238         //Check any presence of services with the same name
239         String serviceName = input.getServiceName();
240         if (this.serviceDataStoreOperations.getService(serviceName).isPresent()) {
241             LOG.warn(SERVICE_CREATE_MSG, LogMessages.serviceInDS(serviceName));
242             return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
243                     LogMessages.serviceInDS(serviceName), ResponseCodes.RESPONSE_FAILED);
244         }
245         // TODO: Here we also have to check if there is an associated temp-service.
246         // TODO: If there is one, delete it from the temp-service-list??
247         this.pceListenerImpl.setInput(new ServiceInput(input));
248         this.pceListenerImpl.setServiceReconfigure(false);
249         this.pceListenerImpl.setTempService(false);
250         this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
251         this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
252         this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
253         // This ensures that the temp-service boolean is false, especially, when
254         // service-create is initiated after the temp-service-create
255         this.rendererListenerImpl.setTempService(false);
256         this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
257         LOG.debug(SERVICE_CREATE_MSG, LogMessages.PCE_CALLING);
258         PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
259         if (output == null) {
260             LOG.warn(SERVICE_CREATE_MSG, LogMessages.ABORT_PCE_FAILED);
261             sendNbiNotification(new PublishNotificationProcessServiceBuilder()
262                     .setServiceName(serviceName)
263                     .setServiceAEnd(new ServiceAEndBuilder(input.getServiceAEnd()).build())
264                     .setServiceZEnd(new ServiceZEndBuilder(input.getServiceZEnd()).build())
265                     .setCommonId(input.getCommonId())
266                     .setConnectionType(input.getConnectionType())
267                     .setResponseFailed(LogMessages.ABORT_PCE_FAILED)
268                     .setMessage("ServiceCreate request failed ...")
269                     .setOperationalState(State.Degraded)
270                     .setPublisherName(PUBLISHER)
271                     .build());
272             return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
273                     LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
274         }
275         LOG.info("RPC serviceCreate in progress...");
276         ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
277         return ModelMappingUtils.createCreateServiceReply(
278                 input, common.getAckFinalIndicator(),
279                 common.getResponseMessage(), common.getResponseCode());
280     }
281
282     @Override
283     public ListenableFuture<RpcResult<ServiceDeleteOutput>> serviceDelete(ServiceDeleteInput input) {
284         String serviceName = input.getServiceDeleteReqInfo().getServiceName();
285         LOG.info("RPC serviceDelete request received for {}", serviceName);
286
287         /*
288          * Upon receipt of service-deleteService RPC, service header and sdnc-request
289          * header compliance are verified.
290          */
291         ComplianceCheckResult serviceHandlerCheckResult =
292             ServicehandlerComplianceCheck.check(
293                 input.getServiceDeleteReqInfo().getServiceName(),
294                 input.getSdncRequestHeader(), null, RpcActions.ServiceDelete, false, true);
295         if (!serviceHandlerCheckResult.hasPassed()) {
296             LOG.warn(SERVICE_DELETE_MSG, LogMessages.ABORT_SERVICE_NON_COMPLIANT);
297             return ModelMappingUtils.createDeleteServiceReply(
298                     input, ResponseCodes.FINAL_ACK_YES,
299                     LogMessages.SERVICE_NON_COMPLIANT, ResponseCodes.RESPONSE_FAILED);
300         }
301
302         //Check presence of service to be deleted
303         Optional<Services> serviceOpt = this.serviceDataStoreOperations.getService(serviceName);
304         Services service;
305         if (serviceOpt.isEmpty()) {
306             LOG.warn(SERVICE_DELETE_MSG, LogMessages.serviceNotInDS(serviceName));
307             return ModelMappingUtils.createDeleteServiceReply(
308                     input, ResponseCodes.FINAL_ACK_YES,
309                     LogMessages.serviceNotInDS(serviceName), ResponseCodes.RESPONSE_FAILED);
310         }
311         service = serviceOpt.orElseThrow();
312         LOG.debug("serviceDelete: Service '{}' found in datastore", serviceName);
313         this.pceListenerImpl.setInput(new ServiceInput(input));
314         this.pceListenerImpl.setServiceReconfigure(false);
315         this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
316         this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
317         this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
318         this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
319         org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteInput
320                 serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(new ServiceInput(input));
321         org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteOutput output =
322             this.rendererServiceWrapper.performRenderer(
323                 serviceDeleteInput, ServiceNotificationTypes.ServiceDeleteResult, service);
324
325         if (output == null) {
326             LOG.error(SERVICE_DELETE_MSG, LogMessages.RENDERER_DELETE_FAILED);
327             sendNbiNotification(new PublishNotificationProcessServiceBuilder()
328                     .setServiceName(service.getServiceName())
329                     .setServiceAEnd(new ServiceAEndBuilder(service.getServiceAEnd()).build())
330                     .setServiceZEnd(new ServiceZEndBuilder(service.getServiceZEnd()).build())
331                     .setCommonId(service.getCommonId())
332                     .setConnectionType(service.getConnectionType())
333                     .setMessage("ServiceDelete request failed ...")
334                     .setOperationalState(State.InService)
335                     .setResponseFailed(LogMessages.RENDERER_DELETE_FAILED)
336                     .setPublisherName(PUBLISHER)
337                     .build());
338             return ModelMappingUtils.createDeleteServiceReply(
339                     input, ResponseCodes.FINAL_ACK_YES,
340                     LogMessages.RENDERER_DELETE_FAILED, ResponseCodes.RESPONSE_FAILED);
341         }
342
343         LOG.debug("RPC serviceDelete in progress...");
344         ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
345         return ModelMappingUtils.createDeleteServiceReply(
346                 input, common.getAckFinalIndicator(),
347                 common.getResponseMessage(), common.getResponseCode());
348     }
349
350     @Override
351     public ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> serviceFeasibilityCheck(
352             ServiceFeasibilityCheckInput input) {
353         LOG.info("RPC serviceFeasibilityCheck received");
354         // Validation
355         ServiceInput serviceInput = new ServiceInput(input);
356         OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(serviceInput,
357                 RpcActions.ServiceFeasibilityCheck);
358         if (! validationResult.isSuccess()) {
359             LOG.warn(SERVICE_FEASIBILITY_CHECK_MSG, LogMessages.ABORT_VALID_FAILED);
360             return ModelMappingUtils.createCreateServiceReply(
361                     input, ResponseCodes.FINAL_ACK_YES,
362                     validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
363         }
364         this.pceListenerImpl.setInput(new ServiceInput(input));
365         this.pceListenerImpl.setServiceReconfigure(false);
366         this.pceListenerImpl.setServiceFeasiblity(true);
367         this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
368         this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
369         this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
370         this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
371         LOG.debug(SERVICE_FEASIBILITY_CHECK_MSG, LogMessages.PCE_CALLING);
372         PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
373         if (output == null) {
374             LOG.warn(SERVICE_FEASIBILITY_CHECK_MSG, LogMessages.ABORT_PCE_FAILED);
375             return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
376                     LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
377         }
378         LOG.info("RPC serviceFeasibilityCheck in progress...");
379         ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
380         return ModelMappingUtils.createCreateServiceReply(
381                 input, common.getAckFinalIndicator(),
382                 common.getResponseMessage(), common.getResponseCode());
383     }
384
385     @Override
386     public ListenableFuture<RpcResult<ServiceReconfigureOutput>> serviceReconfigure(ServiceReconfigureInput input) {
387         String serviceName = input.getServiceName();
388         LOG.info("RPC serviceReconfigure received for {}", serviceName);
389         Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
390         if (servicesObject.isEmpty()) {
391             LOG.warn(SERVICE_RECONFIGURE_MSG, LogMessages.serviceNotInDS(serviceName));
392             return ModelMappingUtils.createCreateServiceReply(
393                 input,
394                 LogMessages.serviceNotInDS(serviceName));
395         }
396         LOG.debug("Service '{}' found in datastore", serviceName);
397         OperationResult validationResult = ServiceCreateValidation
398                 .validateServiceCreateRequest(new ServiceInput(input), RpcActions.ServiceReconfigure);
399         if (!validationResult.isSuccess()) {
400             LOG.warn(SERVICE_RECONFIGURE_MSG, LogMessages.ABORT_VALID_FAILED);
401             return ModelMappingUtils.createCreateServiceReply(
402                     input,
403                     validationResult.getResultMessage());
404         }
405         this.pceListenerImpl.setInput(new ServiceInput(input));
406         this.pceListenerImpl.setServiceReconfigure(true);
407         this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
408         this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
409         this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
410         this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
411         org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915
412                 .ServiceDeleteInput serviceDeleteInput =
413                         ModelMappingUtils.createServiceDeleteInput(new ServiceInput(input));
414         org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915
415                 .ServiceDeleteOutput output = this.rendererServiceWrapper.performRenderer(serviceDeleteInput,
416                         ServiceNotificationTypes.ServiceDeleteResult, null);
417         if (output == null) {
418             LOG.error(SERVICE_RECONFIGURE_MSG, LogMessages.RENDERER_DELETE_FAILED);
419             return ModelMappingUtils.createCreateServiceReply(
420                     input,
421                     LogMessages.RENDERER_DELETE_FAILED);
422                     //TODO check if RpcStatus.Successful is really expected here
423         }
424         LOG.info("RPC serviceReconfigure in progress...");
425         ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
426         return ModelMappingUtils.createCreateServiceReply(
427                 input,
428                 common.getResponseMessage());
429     }
430
431     @Override
432     public ListenableFuture<RpcResult<ServiceRestorationOutput>> serviceRestoration(ServiceRestorationInput input) {
433         String serviceName = input.getServiceName();
434         LOG.info("RPC serviceRestoration received for {}", serviceName);
435         Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
436
437         if (!servicesObject.isPresent()) {
438             LOG.warn(SERVICE_RESTORATION_MSG, LogMessages.serviceNotInDS(serviceName));
439             return ModelMappingUtils.createRestoreServiceReply(
440                     LogMessages.serviceNotInDS(serviceName));
441         }
442
443         Services service = servicesObject.orElseThrow();
444         State state = service.getOperationalState();
445
446         if (state == State.InService) {
447             LOG.error(SERVICE_RESTORATION_MSG, LogMessages.serviceInService(serviceName));
448             return ModelMappingUtils.createRestoreServiceReply(
449                     LogMessages.serviceInService(serviceName));
450         }
451
452         DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssxxx");
453         OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneOffset.UTC);
454         DateAndTime datetime = new DateAndTime(dtf.format(offsetDateTime));
455         SdncRequestHeaderBuilder sdncBuilder = new SdncRequestHeaderBuilder()
456                 .setNotificationUrl(service.getSdncRequestHeader().getNotificationUrl())
457                 .setRequestId(service.getSdncRequestHeader().getRequestId())
458                 .setRequestSystemId(service.getSdncRequestHeader().getRequestSystemId())
459                 .setRpcAction(RpcActions.ServiceDelete);
460         ServiceDeleteInputBuilder deleteInputBldr = new ServiceDeleteInputBuilder()
461                 .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder()
462                     .setServiceName(serviceName)
463                     .setDueDate(datetime)
464                     .setTailRetention(TailRetention.No).build())
465                 .setSdncRequestHeader(sdncBuilder.build());
466         ServiceInput serviceInput = new ServiceInput(deleteInputBldr.build());
467         serviceInput.setServiceAEnd(service.getServiceAEnd());
468         serviceInput.setServiceZEnd(service.getServiceZEnd());
469         serviceInput.setConnectionType(service.getConnectionType());
470         HardConstraints hardConstraints = service.getHardConstraints();
471         if (hardConstraints == null) {
472             LOG.warn("service '{}' HardConstraints is not set !", serviceName);
473         } else {
474             SoftConstraints softConstraints = service.getSoftConstraints();
475             if (softConstraints == null) {
476                 LOG.warn("service '{}' SoftConstraints is not set !", serviceName);
477                 serviceInput.setSoftConstraints(DowngradeConstraints.convertToSoftConstraints(hardConstraints));
478             } else {
479                 LOG.info("converting hard constraints to soft constraints ...");
480                 serviceInput.setSoftConstraints(
481                         DowngradeConstraints.updateSoftConstraints(hardConstraints, softConstraints));
482             }
483             serviceInput.setHardConstraints(DowngradeConstraints.downgradeHardConstraints(hardConstraints));
484         }
485         this.pceListenerImpl.setInput(serviceInput);
486         this.pceListenerImpl.setServiceReconfigure(true);
487         this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
488         this.rendererListenerImpl.setServiceInput(serviceInput);
489         this.rendererListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
490         this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
491         org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915
492             .ServiceDeleteInput serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(
493                     new ServiceInput(deleteInputBldr.build()));
494         org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915
495             .ServiceDeleteOutput output = this.rendererServiceWrapper.performRenderer(serviceDeleteInput,
496                 ServiceNotificationTypes.ServiceDeleteResult, null);
497         if (output == null) {
498             LOG.error(SERVICE_RESTORATION_MSG, LogMessages.RENDERER_DELETE_FAILED);
499             return ModelMappingUtils.createRestoreServiceReply(LogMessages.RENDERER_DELETE_FAILED);
500         }
501         LOG.info("RPC serviceRestore in progress...");
502         ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
503         return ModelMappingUtils.createRestoreServiceReply(common.getResponseMessage());
504
505     }
506
507     @Override
508     public ListenableFuture<RpcResult<EquipmentNotificationOutput>>
509             equipmentNotification(EquipmentNotificationInput input) {
510         // TODO Auto-generated method stub
511         return null;
512     }
513
514     @Override
515     public ListenableFuture<RpcResult<ServiceRerouteConfirmOutput>>
516             serviceRerouteConfirm(ServiceRerouteConfirmInput input) {
517         // TODO Auto-generated method stub
518         return null;
519     }
520
521     @Override
522     public ListenableFuture<RpcResult<ServiceRerouteOutput>> serviceReroute(ServiceRerouteInput input) {
523         String serviceName = input.getServiceName();
524         LOG.info("RPC serviceReroute received for {}", serviceName);
525         Optional<Services> servicesObject = this.serviceDataStoreOperations.getService(serviceName);
526         if (servicesObject.isEmpty()) {
527             LOG.warn("serviceReroute: {}", LogMessages.serviceNotInDS(serviceName));
528             return ModelMappingUtils.createRerouteServiceReply(
529                     input, ResponseCodes.FINAL_ACK_YES,
530                     LogMessages.serviceNotInDS(serviceName),
531                     ResponseCodes.RESPONSE_FAILED);
532         }
533         Services service = servicesObject.orElseThrow();
534         Optional<ServicePaths> servicePathsObject = this.serviceDataStoreOperations.getServicePath(serviceName);
535         if (servicePathsObject.isEmpty()) {
536             LOG.warn("serviceReroute: {}", LogMessages.servicePathNotInDS(serviceName));
537             return ModelMappingUtils.createRerouteServiceReply(
538                     input, ResponseCodes.FINAL_ACK_YES,
539                     LogMessages.servicePathNotInDS(serviceName),
540                     ResponseCodes.RESPONSE_FAILED);
541         }
542         ServicePaths servicePaths = servicePathsObject.orElseThrow();
543         // serviceInput for later use maybe...
544         ServiceInput serviceInput = new ServiceInput(input);
545         serviceInput.setServiceAEnd(service.getServiceAEnd());
546         serviceInput.setServiceZEnd(service.getServiceZEnd());
547         serviceInput.setConnectionType(service.getConnectionType());
548         serviceInput.setCommonId(service.getCommonId());
549         serviceInput.setHardConstraints(service.getHardConstraints());
550         serviceInput.setSoftConstraints(service.getSoftConstraints());
551         serviceInput.setCustomer(service.getCustomer());
552         serviceInput.setCustomerContact(service.getCustomerContact());
553
554         // Get the network xpdr termination points
555         Map<AToZKey, AToZ> mapaToz = servicePaths.getPathDescription().getAToZDirection().getAToZ();
556         String aendtp = ((TerminationPoint) mapaToz.get(new AToZKey(String.valueOf(mapaToz.size() - 3)))
557                 .getResource()
558                 .getResource())
559                 .getTpId();
560         String zendtp = ((TerminationPoint) mapaToz.get(new AToZKey("2"))
561                 .getResource()
562                 .getResource())
563                 .getTpId();
564
565         PathComputationRerouteRequestOutput output = this.pceServiceWrapper.performPCEReroute(
566                 service.getHardConstraints(), service.getSoftConstraints(), input.getSdncRequestHeader(),
567                 service.getServiceAEnd(), service.getServiceZEnd(),
568                 new EndpointsBuilder().setAEndTp(aendtp).setZEndTp(zendtp).build());
569
570         if (output == null) {
571             LOG.error("serviceReroute: {}", LogMessages.PCE_FAILED);
572             return ModelMappingUtils.createRerouteServiceReply(
573                     input, ResponseCodes.FINAL_ACK_YES,
574                     LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
575         }
576         LOG.info("RPC ServiceReroute is done");
577         ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
578         return ModelMappingUtils.createRerouteServiceReply(input, common.getAckFinalIndicator(),
579                 common.getResponseMessage(), common.getResponseCode());
580     }
581
582     @Override
583     public ListenableFuture<RpcResult<ServiceReversionOutput>> serviceReversion(ServiceReversionInput input) {
584         // TODO Auto-generated method stub
585         return null;
586     }
587
588     @Override
589     public ListenableFuture<RpcResult<ServiceRollOutput>> serviceRoll(ServiceRollInput input) {
590         // TODO Auto-generated method stub
591         return null;
592     }
593
594     @Override
595     public ListenableFuture<RpcResult<NetworkReOptimizationOutput>>
596             networkReOptimization(NetworkReOptimizationInput input) {
597         // TODO Auto-generated method stub
598         return null;
599     }
600
601     @Override
602     public ListenableFuture<RpcResult<TempServiceDeleteOutput>> tempServiceDelete(TempServiceDeleteInput input) {
603         String commonId = input.getCommonId();
604         LOG.info("RPC temp serviceDelete request received for {}", commonId);
605
606         /*
607          * Upon receipt of service-deleteService RPC, service header and sdnc-request
608          * header compliance are verified.
609          */
610         LOG.debug("checking Service Compliance ...");
611         ComplianceCheckResult serviceHandlerCheckResult = ServicehandlerComplianceCheck.check(
612                 commonId, null, null, RpcActions.ServiceDelete, false, false
613             );
614         if (!serviceHandlerCheckResult.hasPassed()) {
615             LOG.warn(TEMP_SERVICE_DELETE_MSG, LogMessages.ABORT_SERVICE_NON_COMPLIANT);
616             return ModelMappingUtils.createDeleteServiceReply(
617                     input, ResponseCodes.FINAL_ACK_YES,
618                     LogMessages.SERVICE_NON_COMPLIANT, ResponseCodes.RESPONSE_FAILED);
619         }
620
621         //Check presence of service to be deleted
622         LOG.debug("service common-id '{}' is compliant", commonId);
623         Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.temp.service.list.Services>
624                 service =
625             this.serviceDataStoreOperations.getTempService(commonId);
626         if (service.isEmpty()) {
627             LOG.error(TEMP_SERVICE_DELETE_MSG, LogMessages.serviceNotInDS(commonId));
628             return ModelMappingUtils.createDeleteServiceReply(
629                     input, ResponseCodes.FINAL_ACK_YES,
630                     LogMessages.serviceNotInDS(commonId), ResponseCodes.RESPONSE_FAILED);
631         }
632
633         LOG.info("Service '{}' present in datastore !", commonId);
634         this.pceListenerImpl.setInput(new ServiceInput(input));
635         this.pceListenerImpl.setServiceReconfigure(false);
636         this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
637         this.rendererListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
638         this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
639         this.rendererListenerImpl.setTempService(true);
640         this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
641         org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteOutput output =
642                 this.rendererServiceWrapper.performRenderer(input, ServiceNotificationTypes.ServiceDeleteResult);
643         if (output == null) {
644             LOG.error(TEMP_SERVICE_DELETE_MSG, LogMessages.RENDERER_DELETE_FAILED);
645             return ModelMappingUtils.createDeleteServiceReply(
646                     input, ResponseCodes.FINAL_ACK_YES,
647                     LogMessages.RENDERER_DELETE_FAILED, ResponseCodes.RESPONSE_FAILED);
648         }
649         LOG.info("RPC tempServiceDelete in progress...");
650         ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
651         return ModelMappingUtils.createDeleteServiceReply(
652                 input, common.getAckFinalIndicator(),
653                 common.getResponseMessage(), common.getResponseCode());
654     }
655
656     @Override
657     public ListenableFuture<RpcResult<TempServiceCreateOutput>> tempServiceCreate(TempServiceCreateInput input) {
658         LOG.info("RPC tempServiceCreate received");
659         // Validation
660         OperationResult validationResult = ServiceCreateValidation.validateServiceCreateRequest(
661                 new ServiceInput(input), RpcActions.TempServiceCreate);
662         if (! validationResult.isSuccess()) {
663             LOG.warn(TEMP_SERVICE_CREATE_MSG, LogMessages.ABORT_VALID_FAILED);
664             return ModelMappingUtils.createCreateServiceReply(
665                     input, ResponseCodes.FINAL_ACK_YES,
666                     validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
667         }
668
669         //Check any presence of temp-service with the same commonId
670         String commonId = input.getCommonId();
671         if (this.serviceDataStoreOperations.getTempService(commonId).isPresent()) {
672             LOG.warn(TEMP_SERVICE_CREATE_MSG, LogMessages.serviceInDS("Temp (" + commonId + ")"));
673             return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
674                     LogMessages.serviceInDS("Temp (" + commonId + ")"), ResponseCodes.RESPONSE_FAILED);
675         }
676
677         // Starting service create operation
678         LOG.debug(TEMP_SERVICE_CREATE_MSG, LogMessages.PCE_CALLING);
679         this.pceListenerImpl.setInput(new ServiceInput(input));
680         this.pceListenerImpl.setServiceReconfigure(false);
681         this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
682         this.pceListenerImpl.setTempService(true);
683         this.rendererListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
684         this.rendererListenerImpl.setServiceInput(new ServiceInput(input));
685         this.rendererListenerImpl.setTempService(true);
686         this.networkModelListenerImpl.setserviceDataStoreOperations(serviceDataStoreOperations);
687         PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
688         if (output == null) {
689             LOG.warn(TEMP_SERVICE_CREATE_MSG, LogMessages.ABORT_PCE_FAILED);
690             return ModelMappingUtils.createCreateServiceReply(
691                     input, ResponseCodes.FINAL_ACK_YES,
692                     LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
693         }
694         LOG.info("RPC tempServiceCreate in progress...");
695         ConfigurationResponseCommon common = output.getConfigurationResponseCommon();
696         return ModelMappingUtils.createCreateServiceReply(
697                 input, common.getAckFinalIndicator(),
698                 common.getResponseMessage(), common.getResponseCode());
699     }
700
701     @Override
702     public ListenableFuture<RpcResult<
703         ServiceDeleteComplexResultNotificationRequestOutput>> serviceDeleteComplexResultNotificationRequest(
704             ServiceDeleteComplexResultNotificationRequestInput input) {
705         // TODO Auto-generated method stub
706         return null;
707     }
708
709     @Override
710     public ListenableFuture<RpcResult<
711         ServiceCreateResultNotificationRequestOutput>> serviceCreateResultNotificationRequest(
712             ServiceCreateResultNotificationRequestInput input) {
713         // TODO Auto-generated method stub
714         return null;
715     }
716
717     @Override
718     public ListenableFuture<RpcResult<
719         ServiceDeleteResultNotificationRequestOutput>> serviceDeleteResultNotificationRequest(
720             ServiceDeleteResultNotificationRequestInput input) {
721         // TODO Auto-generated method stub
722         return null;
723     }
724
725     @Override
726     public ListenableFuture<RpcResult<
727         ServiceCreateComplexResultNotificationRequestOutput>> serviceCreateComplexResultNotificationRequest(
728             ServiceCreateComplexResultNotificationRequestInput input) {
729         // TODO Auto-generated method stub
730         return null;
731     }
732
733     @Override
734     public ListenableFuture<RpcResult<ServiceFeasibilityCheckBulkOutput>> serviceFeasibilityCheckBulk(
735         ServiceFeasibilityCheckBulkInput input) {
736         // TODO Auto-generated method stub
737         return null;
738     }
739
740     /**
741      * Send notification to NBI notification in order to publish message.
742      * @param service PublishNotificationService
743      */
744     private void sendNbiNotification(PublishNotificationProcessService service) {
745         try {
746             notificationPublishService.putNotification(service);
747         } catch (InterruptedException e) {
748             LOG.warn("Cannot send notification to nbi", e);
749             Thread.currentThread().interrupt();
750         }
751     }
752
753
754     @Override
755     public ListenableFuture<RpcResult<ServiceCreateBulkOutput>> serviceCreateBulk(ServiceCreateBulkInput input) {
756         // TODO Auto-generated method stub
757         return null;
758     }
759
760     @Override
761     public ListenableFuture<RpcResult<TempServiceCreateBulkOutput>> tempServiceCreateBulk(
762         TempServiceCreateBulkInput input) {
763         // TODO Auto-generated method stub
764         return null;
765     }
766
767     @Override
768     public ListenableFuture<RpcResult<ServiceRollResultNotificationRequestOutput>> serviceRollResultNotificationRequest(
769         ServiceRollResultNotificationRequestInput input) {
770         // TODO Auto-generated method stub
771         return null;
772     }
773
774     @Override
775     public ListenableFuture<RpcResult<ServiceReconfigureBulkOutput>> serviceReconfigureBulk(
776         ServiceReconfigureBulkInput input) {
777         // TODO Auto-generated method stub
778         return null;
779     }
780
781     @Override
782     public ListenableFuture<RpcResult<ServiceReconfigureResultNotificationRequestOutput>>
783             serviceReconfigureResultNotificationRequest(ServiceReconfigureResultNotificationRequestInput input) {
784         // TODO Auto-generated method stub
785         return null;
786     }
787
788     @Override
789     public ListenableFuture<RpcResult<ServiceRestorationResultNotificationRequestOutput>>
790             serviceRestorationResultNotificationRequest(ServiceRestorationResultNotificationRequestInput input) {
791         // TODO Auto-generated method stub
792         return null;
793     }
794
795     @Override
796     public ListenableFuture<RpcResult<ServiceReversionResultNotificationRequestOutput>>
797             serviceReversionResultNotificationRequest(ServiceReversionResultNotificationRequestInput input) {
798         // TODO Auto-generated method stub
799         return null;
800     }
801
802     @Override
803     public ListenableFuture<RpcResult<ServiceRerouteConfirmResultNotificationRequestOutput>>
804             serviceRerouteConfirmResultNotificationRequest(ServiceRerouteConfirmResultNotificationRequestInput input) {
805         // TODO Auto-generated method stub
806         return null;
807     }
808
809     @Override
810     public ListenableFuture<RpcResult<OpticalTunnelCreateOutput>> opticalTunnelCreate(OpticalTunnelCreateInput input) {
811         // TODO Auto-generated method stub
812         return null;
813     }
814
815     @Override
816     public ListenableFuture<RpcResult<OpticalTunnelRequestCancelOutput>> opticalTunnelRequestCancel(
817             OpticalTunnelRequestCancelInput input) {
818         // TODO Auto-generated method stub
819         return null;
820     }
821
822     @Override
823     /**
824      * Implementation of the RPC to set OR  operational modes in the catalog of the controller.
825      * Semantics of the RPC is such that the information in the input replaces the full content
826      * of the OR operational modes catalog in the config data store. Incremental changes to the
827      * catalog, if required, must be done via individual PUT/POST/DELETE RESTconf APIs.
828      *
829      * @param input AddOpenroadmOperationalModesToCatalogInput to be added to Catalog
830      * @return Result of the request
831      */
832     public ListenableFuture<RpcResult<AddOpenroadmOperationalModesToCatalogOutput>>
833         addOpenroadmOperationalModesToCatalog(AddOpenroadmOperationalModesToCatalogInput input) {
834
835         LOG.info("RPC addOpenroadmOperationalModesToCatalog in progress");
836         LOG.debug(" Input openRoadm {}", input);
837         // Validation
838         OperationResult validationResult = CatalogValidation.validateORCatalogRequest(
839                 new CatalogInput(input), RpcActions.FillCatalogWithOrOperationalModes);
840         if (! validationResult.isSuccess()) {
841             LOG.warn(ADD_OR_TO_CATALOG_MSG, LogMessages.ABORT_OR_TO_CATALOG_FAILED);
842             return ModelMappingUtils.addOpenroadmServiceReply(
843                     input, ResponseCodes.FINAL_ACK_YES,
844                     validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
845         }
846         LOG.info(" Request System Id {} " ,input.getSdncRequestHeader().getRequestSystemId());
847         LOG.info(" Rpc Action {} " ,input.getSdncRequestHeader().getRpcAction());
848
849         OpenroadmOperationalModes objToSave = CatalogMapper.createORModesToSave(input);
850         catalogDataStoreOperations.addOpenroadmOperationalModesToCatalog(objToSave);
851         LOG.info("RPC addOpenroadmOperationalModesToCatalog Completed");
852         return ModelMappingUtils.addOpenroadmServiceReply(input, ResponseCodes.FINAL_ACK_YES,
853                 validationResult.getResultMessage(), ResponseCodes.RESPONSE_OK);
854     }
855
856     @Override
857     /**
858      * Implementation of the RPC to set specific operational modes in the catalog of the controller.
859      * Semantics of the RPC is such that the information in the input replaces the full content
860      * of the specific operational modes catalog in the config data store. Incremental changes to the
861      * catalog, if required, must be done via individual PUT/POST/DELETE RESTconf APIs.
862      *
863      * @param input AddSpecificOperationalModesToCatalogInput to be added to Catalog
864      * @return Result of the request
865      */
866     public ListenableFuture<RpcResult<AddSpecificOperationalModesToCatalogOutput>> addSpecificOperationalModesToCatalog(
867             AddSpecificOperationalModesToCatalogInput input) {
868
869         LOG.info("RPC addSpecificOperationalModesToCatalog in progress");
870         LOG.debug(" Input openSpecificRoadm {}", input);
871         // Validation
872         OperationResult validationResult = CatalogValidation.validateSpecificCatalogRequest(
873                 new CatalogInput(input), RpcActions.FillCatalogWithSpecificOperationalModes);
874         if (! validationResult.isSuccess()) {
875             LOG.warn(ADD_SPECIFIC_TO_CATALOG_MSG, LogMessages.ABORT_SPECIFIC_TO_CATALOG_FAILED);
876             return ModelMappingUtils.addSpecificOpenroadmServiceReply(
877                     input, ResponseCodes.FINAL_ACK_YES,
878                     validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
879         }
880         LOG.info(" Request System Id {} " ,input.getSdncRequestHeader().getRequestSystemId());
881         LOG.info(" Rpc Action {} " ,input.getSdncRequestHeader().getRpcAction());
882
883         SpecificOperationalModes objToSave = CatalogMapper.createSpecificModesToSave(input);
884         catalogDataStoreOperations.addSpecificOperationalModesToCatalog(objToSave);
885         LOG.info("RPC addSpecificOperationalModesToCatalog Completed");
886         return ModelMappingUtils.addSpecificOpenroadmServiceReply(input, ResponseCodes.FINAL_ACK_YES,
887                 validationResult.getResultMessage(), ResponseCodes.RESPONSE_OK);
888     }
889
890     @Override
891     public ListenableFuture<RpcResult<ServiceSrlgGetOutput>> serviceSrlgGet(ServiceSrlgGetInput input) {
892         // TODO Auto-generated method stub
893         return null;
894     }
895 }
896