Merge "ROADM To ROADM Path Calculation"
[transportpce.git] / servicehandler / src / main / java / org / opendaylight / transportpce / servicehandler / stub / StubrendererImpl.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
9
10 package org.opendaylight.transportpce.servicehandler.stub;
11
12 import com.google.common.util.concurrent.ListenableFuture;
13 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteInput;
14 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteOutput;
15 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteOutputBuilder;
16 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceImplementationRequestInput;
17 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceImplementationRequestOutput;
18 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceImplementationRequestOutputBuilder;
19 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommonBuilder;
20 import org.opendaylight.yangtools.yang.common.RpcResult;
21 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
24
25
26
27 /**
28  * Class to implement StubrendererService.
29  * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
30  *
31  */
32 public final class StubrendererImpl {
33     /** Logging. */
34     private static final Logger LOG = LoggerFactory.getLogger(StubrendererImpl.class);
35     /** check service sdnc-request-header compliancy. */
36
37     private StubrendererImpl() {
38
39     }
40
41
42     public static ListenableFuture<RpcResult<ServiceDeleteOutput>> serviceDelete(ServiceDeleteInput input) {
43         LOG.info("ServiceDelete request ...");
44         String message = "";
45         String responseCode = null;
46         try {
47             LOG.info("Wait for 1s til beginning the Renderer serviceDelete request");
48             Thread.sleep(1000); //sleep for 1s
49         } catch (InterruptedException e) {
50             message = "deleting service failed !";
51             LOG.error("deleting service failed !", e);
52             responseCode = "500";
53         }
54         ConfigurationResponseCommonBuilder configurationResponseCommon = new ConfigurationResponseCommonBuilder()
55                 .setAckFinalIndicator("yes")
56                 .setRequestId(input.getServiceHandlerHeader().getRequestId())
57                 .setResponseCode(responseCode)
58                 .setResponseMessage(message);
59         ServiceDeleteOutput output =  new ServiceDeleteOutputBuilder()
60                 .setConfigurationResponseCommon(configurationResponseCommon.build())
61                 .build();
62         return RpcResultBuilder.success(output).buildFuture();
63     }
64
65     public static ListenableFuture<RpcResult<ServiceImplementationRequestOutput>>
66         serviceImplementation(ServiceImplementationRequestInput input) {
67         LOG.info("serviceImplementation request ...");
68         String message = "";
69         String responseCode = null;
70         try {
71             LOG.info("Wait for 1s til beginning the Renderer serviceDelete request");
72             Thread.sleep(1000); //sleep for 1s
73         } catch (InterruptedException e) {
74             message = "implementing service failed !";
75             LOG.error(message);
76             responseCode = "500";
77         }
78         ConfigurationResponseCommonBuilder configurationResponseCommon = new ConfigurationResponseCommonBuilder()
79                 .setAckFinalIndicator("yes")
80                 .setRequestId(input.getServiceHandlerHeader().getRequestId())
81                 .setResponseCode(responseCode)
82                 .setResponseMessage(message);
83         ServiceImplementationRequestOutput output =  new ServiceImplementationRequestOutputBuilder()
84                 .setConfigurationResponseCommon(configurationResponseCommon.build())
85                 .build();
86         return RpcResultBuilder.success(output).buildFuture();
87     }
88 }