remove unused code 46/70646/2
authorLukasz Muszkieta <lukasz.muszkieta@nokia.com>
Wed, 10 Oct 2018 14:08:53 +0000 (16:08 +0200)
committerLukasz Muszkieta <lukasz.muszkieta@nokia.com>
Wed, 17 Oct 2018 14:14:06 +0000 (16:14 +0200)
UUID parameter in AAIRestClientI interface is redundant - part 1

Issue-ID: SO-729

Change-Id: I7db331098911e6e183d921175f3109f62b7aedbd
Signed-off-by: Lukasz Muszkieta <lukasz.muszkieta@nokia.com>
bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/aai/AaiConnectionImpl.java
bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscription.java
bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java
common/src/main/java/org/onap/so/client/aai/AAIClient.java
common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java
common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java
common/src/main/java/org/onap/so/client/aai/AAIValidatorImpl.java
common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUriFactory.java
common/src/test/java/org/onap/so/client/aai/AAIPServerTest.java
common/src/test/java/org/onap/so/client/aai/AAIValidatorTest.java

index fa40e86..a92fad2 100644 (file)
 
 package org.onap.so.bpmn.infrastructure.pnf.aai;
 
-import java.io.IOException;
 import java.util.Optional;
 import java.util.UUID;
-
 import org.onap.aai.domain.yang.Pnf;
 import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiConnection;
 import org.onap.so.client.aai.AAIRestClientImpl;
@@ -31,13 +29,13 @@ import org.onap.so.client.aai.AAIRestClientImpl;
 public class AaiConnectionImpl implements AaiConnection {
 
     @Override
-    public Optional<Pnf> getEntryFor(String correlationId) throws IOException {
+    public Optional<Pnf> getEntryFor(String correlationId) {
         AAIRestClientImpl restClient = new AAIRestClientImpl();
         return restClient.getPnfByName(correlationId, UUID.randomUUID().toString());
     }
 
     @Override
-    public void createEntry(String correlationId, Pnf entry) throws IOException {
+    public void createEntry(String correlationId, Pnf entry) {
         AAIRestClientImpl restClient = new AAIRestClientImpl();
         restClient.createPnf(correlationId, UUID.randomUUID().toString(), entry);
     }
index 85cbe2b..a10267e 100644 (file)
@@ -30,7 +30,7 @@ public class CancelDmaapSubscription implements JavaDelegate {
     private DmaapClient dmaapClient;
 
     @Override
-    public void execute(DelegateExecution execution) throws Exception {
+    public void execute(DelegateExecution execution) {
         String correlationId = (String) execution.getVariable(ExecutionVariableNames.CORRELATION_ID);
         dmaapClient.unregister(correlationId);
     }
index e4866f5..d210e5e 100644 (file)
@@ -35,7 +35,7 @@ public class PnfCheckInputs implements JavaDelegate {
     private String defaultTimeout;
 
     @Override
-    public void execute(DelegateExecution execution) throws Exception {
+    public void execute(DelegateExecution execution) {
         String correlationId = (String) execution.getVariable(CORRELATION_ID);
         if (correlationId == null) {
             new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, "correlationId variable not defined");
index 3d2410e..be55342 100644 (file)
@@ -40,15 +40,13 @@ public abstract class AAIClient extends GraphInventoryClient {
        public AAIClient() {
                super(AAIProperties.class);
        }
-       
-       public AAIClient(AAIVersion version) {
-               super(AAIProperties.class);
-       }
+
        @Override
        protected URI constructPath(GraphInventoryUri uri) {
                
                return UriBuilder.fromUri(AAI_ROOT + "/" + this.getVersion().toString() + uri.build().toString()).build();
        }
+
        @Override
        protected RestClient createClient(GraphInventoryUri uri) {
                try {
index 16d80c4..831e438 100644 (file)
 package org.onap.so.client.aai;
 
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
 import java.util.List;
 import java.util.Optional;
-
 import org.onap.aai.domain.yang.GenericVnf;
 import org.onap.aai.domain.yang.Pnf;
 import org.onap.aai.domain.yang.Pserver;
-import org.onap.aai.domain.yang.Pservers;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
 
 public interface AAIRestClientI {
-       
-       Pservers getPhysicalServers(String hostName, String uuid);
-       
-       List<Pserver> getPhysicalServerByVnfId(String vnfId, String transactionLoggingUuid) throws UnsupportedEncodingException, JsonParseException, JsonMappingException, IOException;
+
+       List<Pserver> getPhysicalServerByVnfId(String vnfId) throws IOException;
        
        void updateMaintenceFlagVnfId(String vnfId, boolean inMaint, String transactionLoggingUuid) throws Exception;
        
index 251ca7f..bcc7d8b 100644 (file)
@@ -20,7 +20,6 @@
 
 package org.onap.so.client.aai;
 
-
 import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import java.io.IOException;
@@ -28,72 +27,23 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
-import java.util.UUID;
 import javax.ws.rs.core.Response;
 import org.onap.aai.domain.yang.GenericVnf;
-import org.onap.aai.domain.yang.GenericVnfs;
 import org.onap.aai.domain.yang.Pnf;
 import org.onap.aai.domain.yang.Pserver;
-import org.onap.aai.domain.yang.Pservers;
 import org.onap.so.client.aai.entities.CustomQuery;
 import org.onap.so.client.aai.entities.Results;
 import org.onap.so.client.aai.entities.uri.AAIResourceUri;
 import org.onap.so.client.aai.entities.uri.AAIUriFactory;
 import org.onap.so.client.graphinventory.Format;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Service;
-
-
 
 public class AAIRestClientImpl implements AAIRestClientI {
 
-       private static Logger logger = LoggerFactory.getLogger(AAIClient.class);
     private static final AAIVersion ENDPOINT_VERSION = AAIVersion.V10;
-    private static final String ENDPOINT_GET_ALL = ENDPOINT_VERSION + "/cloud-infrastructure/pservers";
-    private static final String ENDPOINT_GET_ALL_VNFS = ENDPOINT_VERSION + "/network/generic-vnfs";
-    private static final String ENDPOINT_CUSTOM_QUERY = ENDPOINT_VERSION + "/query";
     private static final String PSERVER_VNF_QUERY = "pservers-fromVnf";
-    private static final String GENERIC_VNF_PATH = ENDPOINT_VERSION + "/network/generic-vnfs/generic-vnf";
-    private static final String SERVICE_TOPOLOGY_BY_SERVICE_INSTANCE_ID =
-            "store(‘x’).union(__.in(‘subscribesTo’).has(‘aai-node-type’,’customer’).store(‘x’),__.out(‘uses’).has(‘aai-node-type’,’allotted-resource’).store(‘x’),__.in(‘hasInstance’).has(‘aai-node-type’,’generic-vnf’).store(‘x’).union("
-                    + ".out(‘has’).has(‘aai-node-type’,’vf-module’).store(‘x’),out(‘uses’).has(‘aai-node-type’,’volume-group’).store(‘x’),"
-                    + ".out(‘hasLInterface’).has(‘aai-node-type’,’l-interface’).union("
-                    + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv4-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’),"
-                    + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv6-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’)"
-                    + ")," + ".out(‘runsOnVserver’).has(‘aai-node-type’,’vserver’).store(‘x’).union("
-                    + ".in(‘owns’).has(‘aai-node-type’,’tenant’).store(‘x’).in(‘has’).has(‘aai-node-type’,’cloud-region’).store(‘x’),"
-                    + ".out(‘runsOnPserver’).has(‘aai-node-type’,’pserver’).store(‘x’),"
-                    + ".out(‘hasLInterface’).has(‘aai-node-type’,’l-interface’).union("
-                    + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv4-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’),"
-                    + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv6-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’)"
-                    + ")" + ")" + ")" + ").cap(‘x’).unfold().dedup()";
-
-    public AAIRestClientImpl() {
-    }
 
     @Override
-    public Pservers getPhysicalServers(String hostName, String uuid) {
-        UUID requestId;
-        try {
-            requestId = UUID.fromString(uuid);
-        } catch (IllegalArgumentException e) {
-            logger.warn("could not parse uuid: " + uuid + " creating valid uuid automatically");
-            requestId = UUID.randomUUID();
-        }
-        return new AAIResourcesClient(ENDPOINT_VERSION)
-                .get(Pservers.class, AAIUriFactory.createResourceUri(AAIObjectPlurals.PSERVER)).orElse(null);
-    }
-
-    @Override
-    public List<Pserver> getPhysicalServerByVnfId(String vnfId, String transactionLoggingUuid) throws IOException {
-        UUID requestId;
-        try {
-            requestId = UUID.fromString(transactionLoggingUuid);
-        } catch (IllegalArgumentException e) {
-            logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically");
-            requestId = UUID.randomUUID();
-        }
+    public List<Pserver> getPhysicalServerByVnfId(String vnfId) throws IOException {
         List<AAIResourceUri> startNodes = new ArrayList<>();
         startNodes.add(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId));
         String jsonInput = new AAIQueryClient(ENDPOINT_VERSION)
@@ -116,15 +66,7 @@ public class AAIRestClientImpl implements AAIRestClientI {
     }
 
     @Override
-    public void updateMaintenceFlagVnfId(String vnfId, boolean inMaint, String transactionLoggingUuid)
-            throws IOException {
-        UUID requestId;
-        try {
-            requestId = UUID.fromString(transactionLoggingUuid);
-        } catch (IllegalArgumentException e) {
-            logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically");
-            requestId = UUID.randomUUID();
-        }
+    public void updateMaintenceFlagVnfId(String vnfId, boolean inMaint, String transactionLoggingUuid) {
         GenericVnf genericVnf = new GenericVnf();
         genericVnf.setInMaint(inMaint);
         new AAIResourcesClient(ENDPOINT_VERSION)
@@ -133,27 +75,13 @@ public class AAIRestClientImpl implements AAIRestClientI {
     }
 
     @Override
-    public GenericVnf getVnfByName(String vnfId, String transactionLoggingUuid) throws IOException {
-        UUID requestId;
-        try {
-            requestId = UUID.fromString(transactionLoggingUuid);
-        } catch (IllegalArgumentException e) {
-            logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically");
-            requestId = UUID.randomUUID();
-        }
+    public GenericVnf getVnfByName(String vnfId, String transactionLoggingUuid) {
         return new AAIResourcesClient(ENDPOINT_VERSION)
                 .get(GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)).orElse(null);
     }
 
     @Override
-    public Optional<Pnf> getPnfByName(String pnfId, String transactionLoggingUuid) throws IOException {
-        UUID requestId;
-        try {
-            requestId = UUID.fromString(transactionLoggingUuid);
-        } catch (IllegalArgumentException e) {
-            logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically", e);
-            requestId = UUID.randomUUID();
-        }
+    public Optional<Pnf> getPnfByName(String pnfId, String transactionLoggingUuid) {
         Response response = new AAIResourcesClient(ENDPOINT_VERSION)
                 .getFullResponse(AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfId));
         if (response.getStatus() != 200) {
@@ -164,14 +92,7 @@ public class AAIRestClientImpl implements AAIRestClientI {
     }
 
     @Override
-    public void createPnf(String pnfId, String transactionLoggingUuid, Pnf pnf) throws IOException {
-        UUID requestId;
-        try {
-            requestId = UUID.fromString(transactionLoggingUuid);
-        } catch (IllegalArgumentException e) {
-            logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically", e);
-            requestId = UUID.randomUUID();
-        }
+    public void createPnf(String pnfId, String transactionLoggingUuid, Pnf pnf) {
         new AAIResourcesClient(ENDPOINT_VERSION)
                 .createIfNotExists(AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfId), Optional.of(pnf));
     }
index fb6d122..e416da1 100644 (file)
@@ -26,7 +26,6 @@ import java.util.List;
 import org.onap.aai.domain.yang.GenericVnf;
 import org.onap.aai.domain.yang.Pserver;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
 
 
 
@@ -50,7 +49,7 @@ public class AAIValidatorImpl implements AAIValidator {
        public boolean isPhysicalServerLocked(String vnfId, String transactionLoggingUuid) throws IOException {
                List<Pserver> pservers;
                boolean isLocked = false;
-               pservers = client.getPhysicalServerByVnfId(vnfId, transactionLoggingUuid);
+               pservers = client.getPhysicalServerByVnfId(vnfId);
                for (Pserver pserver : pservers)
                        if (pserver.isInMaint())
                                isLocked = true;
index 1f819ca..3589075 100644 (file)
@@ -25,7 +25,6 @@ import java.net.URI;
 import org.onap.so.client.aai.AAIObjectPlurals;
 import org.onap.so.client.aai.AAIObjectType;
 
-
 public class AAIUriFactory {
        
        /**
@@ -54,12 +53,7 @@ public class AAIUriFactory {
                return new NodesUri(type, values);
                
        }
-       
-       public static AAIResourceUri createNodesUri(AAIObjectPlurals type) {
-               return new NodesUri(type);
-               
-       }
-       
+
        /**
         * This method should only be used to wrap a URI retrieved from A&AI contained within an object response
         * 
@@ -70,21 +64,7 @@ public class AAIUriFactory {
        public static AAIResourceUri createResourceFromExistingURI(AAIObjectType type, URI uri) {
                return new AAISimpleUri(type, uri);
        }
-       
-       
-       /**
-        * creates an AAIResourceUri from a parentUri
-        * 
-        * @param parentUri
-        * @param childType
-        * @param childValues
-        * @return
-        */
-       public static AAIResourceUri createResourceFromParentURI(AAIResourceUri parentUri, AAIObjectType childType, Object... childValues) {
-               
-               return new AAISimpleUri(parentUri, childType, childValues);
-       }
-       
+
        /**
         * Creates a uri for a plural type e.g. /cloud-infrastructure/pservers
         * 
index 37188bc..ba48e43 100644 (file)
@@ -25,20 +25,14 @@ import static org.junit.Assert.assertEquals;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Paths;
-import java.security.NoSuchAlgorithmException;
 import java.util.List;
-import java.util.UUID;
-
 import org.junit.Ignore;
 import org.junit.Test;
 import org.onap.aai.domain.yang.Pserver;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
 public class AAIPServerTest {
 
        @Test
-       public void pserverTest() throws JsonParseException, JsonMappingException, IOException, NoSuchAlgorithmException {
+       public void pserverTest() throws IOException {
                AAIRestClientImpl client = new AAIRestClientImpl();
                String json = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/aai/pserver.json")));
                List<Pserver> list = client.getListOfPservers(json);
@@ -49,9 +43,9 @@ public class AAIPServerTest {
        
        @Test
        @Ignore // IGNORED FOR 1710 MERGE TO ONAP
-       public void pserverActualTest() throws JsonParseException, JsonMappingException, IOException, NoSuchAlgorithmException {
+       public void pserverActualTest() throws IOException {
                AAIRestClientImpl client = new AAIRestClientImpl();
-               List<Pserver> list = client.getPhysicalServerByVnfId("d946afed-8ebe-4c5d-9665-54fcc043b8e7", UUID.randomUUID().toString());
+               List<Pserver> list = client.getPhysicalServerByVnfId("d946afed-8ebe-4c5d-9665-54fcc043b8e7");
                assertEquals("", list.size(), 0);
        }
 
index 04c8b15..a2de528 100644 (file)
@@ -24,10 +24,8 @@ import static org.junit.Assert.assertEquals;
 import static org.mockito.Mockito.when;
 
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import java.util.List;
-
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -36,9 +34,6 @@ import org.mockito.runners.MockitoJUnitRunner;
 import org.onap.aai.domain.yang.GenericVnf;
 import org.onap.aai.domain.yang.Pserver;
 
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-
 @RunWith(MockitoJUnitRunner.class) 
 public class AAIValidatorTest {
        
@@ -70,14 +65,14 @@ public class AAIValidatorTest {
 
        @Test
        public void test_IsPhysicalServerLocked_True() throws IOException{              
-               when(client.getPhysicalServerByVnfId(vnfName,uuid)).thenReturn(getPservers(true));      
+               when(client.getPhysicalServerByVnfId(vnfName)).thenReturn(getPservers(true));
                boolean locked = validator.isPhysicalServerLocked(vnfName, uuid);
                assertEquals(true, locked);
        }
        
        @Test
-       public void test_IsPhysicalServerLocked_False() throws JsonParseException, JsonMappingException, UnsupportedEncodingException, IOException {
-               when(client.getPhysicalServerByVnfId(vnfName,uuid)).thenReturn(getPservers(false));     
+       public void test_IsPhysicalServerLocked_False() throws IOException {
+               when(client.getPhysicalServerByVnfId(vnfName)).thenReturn(getPservers(false));
                boolean locked = validator.isPhysicalServerLocked(vnfName, uuid);
                assertEquals(false, locked);
        }