Merge "remove dead code pointed out by sonar"
[transportpce.git] / renderer / src / main / java / org / opendaylight / transportpce / renderer / provisiondevice / tasks / OlmPowerSetupTask.java
1 /*
2  * Copyright © 2017 AT&T 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.renderer.provisiondevice.tasks;
9
10 import java.util.concurrent.Callable;
11 import java.util.concurrent.Future;
12
13 import org.opendaylight.transportpce.common.ResponseCodes;
14 import org.opendaylight.transportpce.renderer.provisiondevice.OLMRenderingResult;
15 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerSetupInput;
16 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerSetupOutput;
17 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.TransportpceOlmService;
18 import org.opendaylight.yangtools.yang.common.RpcResult;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
21
22 public class OlmPowerSetupTask implements Callable<OLMRenderingResult> {
23
24     private static final Logger LOG = LoggerFactory.getLogger(OlmPowerSetupTask.class);
25
26     private final TransportpceOlmService olmService;
27     private final ServicePowerSetupInput input;
28
29     public OlmPowerSetupTask(TransportpceOlmService olmService, ServicePowerSetupInput input) {
30         this.olmService = olmService;
31         this.input = input;
32     }
33
34     @Override
35     public OLMRenderingResult call() throws Exception {
36         Future<RpcResult<ServicePowerSetupOutput>> fr = this.olmService.servicePowerSetup(this.input);
37         RpcResult<ServicePowerSetupOutput> result = fr.get();
38         if (result == null) {
39             LOG.warn("Result is NULL");
40             return OLMRenderingResult.failed("Operation Failed");
41         }
42
43         LOG.debug("Result: {}", result.getResult());
44         if (ResponseCodes.SUCCESS_RESULT.equals(result.getResult().getResult())) {
45             LOG.info("OLM power setup finished successfully");
46             return OLMRenderingResult.ok();
47         } else {
48             LOG.warn("OLM power setup not successfully finished");
49             return OLMRenderingResult.failed("Operation Failed");
50         }
51     }
52
53 }