X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=tapi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Ftapi%2Futils%2FTapiContext.java;fp=tapi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Ftapi%2Futils%2FTapiContext.java;h=12ee2b61cef827e5722862bc71fc81265d86dd8a;hb=4bb3743a3214fb481e4cc147914a314c9ff6d1c3;hp=a44e508104b4d07b2bc8316b4420037f9d28f86f;hpb=a3e438d26a071955866bd610928c4fbc63fdc69c;p=transportpce.git diff --git a/tapi/src/main/java/org/opendaylight/transportpce/tapi/utils/TapiContext.java b/tapi/src/main/java/org/opendaylight/transportpce/tapi/utils/TapiContext.java index a44e50810..12ee2b61c 100644 --- a/tapi/src/main/java/org/opendaylight/transportpce/tapi/utils/TapiContext.java +++ b/tapi/src/main/java/org/opendaylight/transportpce/tapi/utils/TapiContext.java @@ -142,7 +142,7 @@ public class TapiContext { LOG.error("Tapi context is not present in datastore"); return null; } - return optionalContext.get(); + return optionalContext.orElseThrow(); } catch (InterruptedException | ExecutionException e) { LOG.error("Couldnt read tapi context from datastore", e); return null; @@ -233,7 +233,7 @@ public class TapiContext { LOG.error("ONEP is not present in datastore"); return; } - OwnedNodeEdgePoint onep = optionalOnep.get(); + OwnedNodeEdgePoint onep = optionalOnep.orElseThrow(); LOG.info("ONEP found = {}", onep); // TODO -> If cep exists -> skip merging to datasore OwnedNodeEdgePoint1 onep1 = onep.augmentation(OwnedNodeEdgePoint1.class); @@ -274,7 +274,7 @@ public class TapiContext { return null; } // TODO -> Need to remove CEPs from NEPs. If not error from get Topology details output - Node node = optNode.get(); + Node node = optNode.orElseThrow(); LOG.debug("NEPs of node before creating map to be returned to the getTapiNode function = {}", node.getOwnedNodeEdgePoint().size()); Map onepMap = new HashMap<>(); @@ -327,7 +327,7 @@ public class TapiContext { LOG.error(NODE_NOT_PRESENT); return null; } - return optNode.get(); + return optNode.orElseThrow(); } catch (InterruptedException | ExecutionException e) { LOG.error("Couldnt read NEP in topology", e); return null; @@ -347,7 +347,7 @@ public class TapiContext { LOG.error(NODE_NOT_PRESENT); return null; } - return optLink.get(); + return optLink.orElseThrow(); } catch (InterruptedException | ExecutionException e) { LOG.error("Couldnt read link in topology", e); return null; @@ -367,7 +367,7 @@ public class TapiContext { LOG.error("Topology context is not present in datastore"); return null; } - return optTopoContext.get().getTopology(); + return optTopoContext.orElseThrow().getTopology(); } catch (InterruptedException | ExecutionException e) { LOG.error("Couldnt read topology context", e); return null; @@ -390,7 +390,7 @@ public class TapiContext { LOG.error("Connectivity service not found in tapi context"); return null; } - return optConnServ.get(); + return optConnServ.orElseThrow(); } catch (InterruptedException | ExecutionException e) { LOG.error("Connectivity service not found in tapi context. Error:", e); return null; @@ -542,7 +542,7 @@ public class TapiContext { LOG.error("Connection not found in tapi context"); return null; } - return optConn.get(); + return optConn.orElseThrow(); } catch (InterruptedException | ExecutionException e) { LOG.error("Connection not found in tapi context. Error:", e); return null; @@ -567,7 +567,7 @@ public class TapiContext { LOG.error("Connectivity context not found in tapi context"); return null; } - return optConnContext.get().getConnectivityService(); + return optConnContext.orElseThrow().getConnectivityService(); } catch (InterruptedException | ExecutionException e) { LOG.error("Connectivity context not found in tapi context. Error:", e); return null; @@ -588,11 +588,11 @@ public class TapiContext { LOG.error(NODE_NOT_PRESENT); return null; } - if (optNode.get().augmentation(OwnedNodeEdgePoint1.class) == null) { + if (optNode.orElseThrow().augmentation(OwnedNodeEdgePoint1.class) == null) { LOG.error("Node doesnt have ceps"); return null; } - return optNode.get().augmentation(OwnedNodeEdgePoint1.class).getCepList().getConnectionEndPoint() + return optNode.orElseThrow().augmentation(OwnedNodeEdgePoint1.class).getCepList().getConnectionEndPoint() .get(new ConnectionEndPointKey(cepUuid)); } catch (InterruptedException | ExecutionException e) { LOG.error("Couldnt read node in topology", e);