diff options
author | 2018-01-26 03:12:10 +0000 | |
---|---|---|
committer | 2018-01-26 03:17:03 +0000 | |
commit | f7e256387f9995d1d08adf5d8f7534c332432f87 (patch) | |
tree | 1338855365eebbf759ee8ba9c4f072c843359138 /aai-service/provider/src/main/java/org | |
parent | 6f3e3e30405fc12a8800771dc54826e837ee6abe (diff) |
Fixed as per Java Code Conventions
Changes made:
* corrected sonar related issues in AAIClient, AAIDeclarations and AAIRequest
Change-Id: Iaad7a0db060bbba81e23d3f63f1ef6c023431102
Issue-ID: CCSDK-151
Signed-off-by: Rich Tabedzki <richard.tabedzki@att.com>
Diffstat (limited to 'aai-service/provider/src/main/java/org')
3 files changed, 49 insertions, 101 deletions
diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClient.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClient.java index 712ea2a6..3684cf21 100755 --- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClient.java +++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClient.java @@ -39,7 +39,7 @@ import com.fasterxml.jackson.databind.JsonMappingException; public interface AAIClient extends SvcLogicResource, SvcLogicJavaPlugin { - public SearchResults requestServiceInstanceURL(String svc_instanceId) throws AAIServiceException; + public SearchResults requestServiceInstanceURL(String svcInstanceId) throws AAIServiceException; // VServers public Vserver requestVServerData(String tenantId, String vserverId, String cloudOwner, String cloudRegionId) throws AAIServiceException; @@ -69,7 +69,7 @@ public interface AAIClient extends SvcLogicResource, SvcLogicJavaPlugin { // Node Query - 1602 public SearchResults requestNodeQuery(String type, String entityIdentifier, String entityName) throws AAIServiceException; public String requestDataByURL(URL url) throws AAIServiceException; - public GenericVnf requestGenericVnfeNodeQuery(String vnfName) throws AAIServiceException; + public GenericVnf requestGenericVnfeNodeQuery(String vnfName) throws AAIServiceException; public QueryStatus backup(Map<String, String> params, SvcLogicContext ctx) throws SvcLogicException; public QueryStatus restore(Map<String, String> params, SvcLogicContext ctx) throws SvcLogicException; @@ -83,6 +83,6 @@ public interface AAIClient extends SvcLogicResource, SvcLogicJavaPlugin { String query(AAIRequest request) throws AAIServiceException; String save(AAIRequest request) throws AAIServiceException; boolean delete(AAIRequest request, String resourceVersion) throws AAIServiceException; - boolean update(AAIRequest request, String resourceVersion) throws AAIServiceException; + boolean update(AAIRequest request, String resourceVersion) throws AAIServiceException; } diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIDeclarations.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIDeclarations.java index e262df04..7966fa97 100755 --- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIDeclarations.java +++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIDeclarations.java @@ -47,11 +47,18 @@ import java.util.regex.Pattern; import javax.xml.bind.annotation.XmlType; import org.apache.commons.lang.StringUtils; +import org.onap.ccsdk.sli.adaptors.aai.data.AAIDatum; +import org.onap.ccsdk.sli.adaptors.aai.query.FormattedQueryResultList; +import org.onap.ccsdk.sli.adaptors.aai.query.InstanceFilter; +import org.onap.ccsdk.sli.adaptors.aai.query.InstanceFilters; +import org.onap.ccsdk.sli.adaptors.aai.query.NamedQuery; +import org.onap.ccsdk.sli.adaptors.aai.query.NamedQueryData; +import org.onap.ccsdk.sli.adaptors.aai.query.QueryParameters; +import org.onap.ccsdk.sli.adaptors.aai.query.Result; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus; -import org.openecomp.aai.inventory.v11.Image; import org.openecomp.aai.inventory.v11.GenericVnf; +import org.openecomp.aai.inventory.v11.Image; import org.openecomp.aai.inventory.v11.InventoryResponseItem; import org.openecomp.aai.inventory.v11.InventoryResponseItems; import org.openecomp.aai.inventory.v11.L3Network; @@ -69,14 +76,6 @@ import org.openecomp.aai.inventory.v11.ServiceInstance; import org.openecomp.aai.inventory.v11.Vlan; import org.openecomp.aai.inventory.v11.Vlans; import org.openecomp.aai.inventory.v11.Vserver; -import org.onap.ccsdk.sli.adaptors.aai.data.AAIDatum; -import org.onap.ccsdk.sli.adaptors.aai.query.FormattedQueryResultList; -import org.onap.ccsdk.sli.adaptors.aai.query.InstanceFilter; -import org.onap.ccsdk.sli.adaptors.aai.query.InstanceFilters; -import org.onap.ccsdk.sli.adaptors.aai.query.NamedQuery; -import org.onap.ccsdk.sli.adaptors.aai.query.NamedQueryData; -import org.onap.ccsdk.sli.adaptors.aai.query.QueryParameters; -import org.onap.ccsdk.sli.adaptors.aai.query.Result; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -392,8 +391,6 @@ public abstract class AAIDeclarations implements AAIClient { getLogger().warn("Failed query - returning FAILURE", exc); return QueryStatus.FAILURE; } - -// return QueryStatus.SUCCESS; } @@ -483,7 +480,6 @@ public abstract class AAIDeclarations implements AAIClient { path = request.getRequestUrl("GET", null); params.put("vserver-selflink", path.toString()); } catch (UnsupportedEncodingException | MalformedURLException | URISyntaxException e) { - // TODO : Fix this params.put("vserver-selflink", "/vserver"); } } @@ -519,8 +515,8 @@ public abstract class AAIDeclarations implements AAIClient { request.processRequestPathValues(nameValues); getExecutor().post(request); - getLogger().debug("Save relationship list - returning SUCCESS"); - return QueryStatus.SUCCESS; + getLogger().debug("Save relationship list - returning SUCCESS"); + return QueryStatus.SUCCESS; } } catch (Exception exc) { ctx.setAttribute(prefix + ".error.message", exc.getMessage()); @@ -538,45 +534,9 @@ public abstract class AAIDeclarations implements AAIClient { return QueryStatus.FAILURE; } } else { - String reSource = resource.toLowerCase().replace("-", "_"); - String vnfId; - - try { - switch(reSource) { - case "generic_vnf": - case "generic-vnf": - vnfId = nameValues.get("vnf_id"); - if(vnfId == null) { - getLogger().debug("Save(generic-vnf) with no vnf-id specified. Returning FAILURE"); - return QueryStatus.FAILURE; - } - vnfId = vnfId.trim().replace("'", "").replace("$", "").replace("'", ""); - GenericVnf vnf = this.requestGenericVnfData(vnfId); - String status = params.get("prov-status"); - boolean updated = false; - if(status != null && !status.isEmpty()) { - vnf.setProvStatus(status); - } - if(updated) { - this.postGenericVnfData(vnfId, vnf); - } - break; - case "vpe": - return update( resource, key, params, prefix, ctx) ; - - default: - getLogger().debug("Save() executing default path - returning FAILURE"); - return QueryStatus.FAILURE; - } - } catch (Exception exc) { - getLogger().warn("Failed save - returning FAILURE", exc); - ctx.setAttribute(prefix + ".error.message", exc.getMessage()); - return QueryStatus.FAILURE; - } + getLogger().debug("Save() request for {} is not supported- returning FAILURE", resource); + return QueryStatus.FAILURE; } - - getLogger().debug("Save - returning SUCCESS"); - return QueryStatus.SUCCESS; } @Override @@ -797,20 +757,17 @@ public abstract class AAIDeclarations implements AAIClient { @Override public QueryStatus isAvailable(String arg0, String arg1, String arg2, SvcLogicContext arg3) throws SvcLogicException { - // TODO Auto-generated method stub throw new SvcLogicException("Method AAIService.isAvailable() has not been implemented yet"); } @Override public QueryStatus notify(String resource, String action, String key, SvcLogicContext ctx) throws SvcLogicException { - // TODO Auto-generated method stub throw new SvcLogicException("Method AAIService.notify() has not been implemented yet"); } // @Override public QueryStatus newModelQuery(String resource, boolean localOnly, String select, String key, String prefix, String orderBy, SvcLogicContext ctx) { - Object response = null; QueryStatus retval = QueryStatus.SUCCESS; String modifier = null; @@ -1092,14 +1049,12 @@ public abstract class AAIDeclarations implements AAIClient { @Override public QueryStatus release(String arg0, String arg1, SvcLogicContext arg2) throws SvcLogicException { - // TODO Auto-generated method stub throw new SvcLogicException("Method AAIService.release() has not been implemented yet"); } @Override public QueryStatus reserve(String arg0, String arg1, String arg2, String arg3, SvcLogicContext arg4) throws SvcLogicException { - // TODO Auto-generated method stub throw new SvcLogicException("Method AAIService.reserve() has not been implemented yet"); } @@ -1153,7 +1108,7 @@ public abstract class AAIDeclarations implements AAIClient { arglist[0] = valueOf(type, params.get(id)); } } - Object o = setter.invoke(instance, arglist); + Object obj = setter.invoke(instance, arglist); } set.remove(id); @@ -1161,7 +1116,7 @@ public abstract class AAIDeclarations implements AAIClient { Throwable cause = x.getCause(); getLogger().warn("Failed process for " + resourceClass.getName(), x); } - } else if(type.getName().equals("java.util.List")) { + } else if("java.util.List".equals(type.getName())) { List<String> newValues = new ArrayList<>(); String length = id+"_length"; if(!params.isEmpty() && params.containsKey(length)) { @@ -1445,10 +1400,6 @@ public abstract class AAIDeclarations implements AAIClient { } } - if(metadataList.getMetadatum() == null) { -// metadataList.setMetadatum(new ArrayList<Metadatum>()); - } - // process data int i = 0; while(true){ @@ -1758,10 +1709,7 @@ public abstract class AAIDeclarations implements AAIClient { try { retval = newModelBackupRequest(resource, params, "tmpRestore", ctx); if(retval == QueryStatus.SUCCESS) { - String current_json = ctx.getAttribute("tmpRestore"); - ctx. setAttribute("tmpRestore", null); - - String snapshot_json = ctx.getAttribute(prefix); + ctx.setAttribute("tmpRestore", null); } } catch (Exception exc) { getLogger().warn("Failed restore - returning FAILURE", exc); @@ -1821,8 +1769,8 @@ public abstract class AAIDeclarations implements AAIClient { Object object = getResourceVersionMethod.invoke(instance); if(object != null) resourceVersion = object.toString(); - } catch (InvocationTargetException x) { - Throwable cause = x.getCause(); + } catch (InvocationTargetException exc) { + getLogger().warn("Retrieving resource version", exc); } } @@ -1926,7 +1874,7 @@ public abstract class AAIDeclarations implements AAIClient { request.processRequestPathValues(nameValues); URL url = request.getRequestUrl("GET", null); - Class resourceClass = request.getModelClass(); + Class<?> resourceClass = request.getModelClass(); Object instance = getResource(url.toString(), resourceClass); // get resource version @@ -2017,7 +1965,7 @@ public abstract class AAIDeclarations implements AAIClient { Map<String, String> prefixMap = new HashMap<>(); Pattern p = Pattern.compile(".*\\[\\d\\]"); - SortedSet<String> keys = new TreeSet(tmpPrefixMap.keySet () ); + SortedSet<String> keys = new TreeSet<String>(tmpPrefixMap.keySet () ); for(String key : keys) { Matcher m = p.matcher(key); if(m.matches()) { diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java index 21f8859d..2e2620a3 100755 --- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java +++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java @@ -81,28 +81,28 @@ public abstract class AAIRequest { public static AAIRequest createRequest(String resoourceName, Map<String, String> nameValues){ String resoource = resoourceName; - String masterResource = null; + String masterResource = null; if(resoource == null) return null; if(resoource.contains(":")) { String[] tokens = resoource.split(":"); - if(tokens != null && tokens.length == 2) { - resoource = tokens[1]; - masterResource = tokens[0]; - // - Class<? extends AAIDatum> clazz = null; - try { - clazz = getClassFromResource(resoource) ; - } catch (ClassNotFoundException e) { - LOG.warn("AAIRequest does not support class: " + e.getMessage()); - return null; - } - - if(clazz == null) { - return null; - } + if(tokens != null && tokens.length == 2) { + resoource = tokens[1]; + masterResource = tokens[0]; + // + Class<? extends AAIDatum> clazz = null; + try { + clazz = getClassFromResource(resoource) ; + } catch (ClassNotFoundException e) { + LOG.warn("AAIRequest does not support class: ()", e.getMessage()); + return null; + } + + if(clazz == null) { + return null; + } } } @@ -139,13 +139,13 @@ public abstract class AAIRequest { case "l2-bridge-sbg": case "l2-bridge-bgf": { - resoource = "l-interface"; + resoource = "l-interface"; return getRequestFromResource("l-interface"); } - case "relationship-list": - return new RelationshipListRequest(AAIRequest.createRequest(masterResource, nameValues)); - case "relationship": - return new RelationshipRequest(AAIRequest.createRequest(masterResource, nameValues)); + case "relationship-list": + return new RelationshipListRequest(AAIRequest.createRequest(masterResource, nameValues)); + case "relationship": + return new RelationshipRequest(AAIRequest.createRequest(masterResource, nameValues)); default: return getRequestFromResource(resoource); } @@ -251,7 +251,7 @@ public abstract class AAIRequest { aaiService.getLogger().warn("Could not deserialize object of type " + lInterfaceRequest.getClass().getSimpleName(), exc) ; } - public URL getRequestUrl(String method, String resourceVersion) throws UnsupportedEncodingException, MalformedURLException, URISyntaxException { + public URL getRequestUrl(String method, String resourceVersion) throws UnsupportedEncodingException, MalformedURLException, URISyntaxException { String request_url = null; @@ -295,9 +295,9 @@ public abstract class AAIRequest { } protected String getRequestPath(String resource) throws MalformedURLException { - if(requestProperties.containsKey("resource-path")) { - return requestProperties.getProperty("resource-path"); - } + if(requestProperties.containsKey("resource-path")) { + return requestProperties.getProperty("resource-path"); + } Set<String> uniqueResources = extractUniqueResourceSetFromKeys(requestProperties.stringPropertyNames()); if(resource != null) { @@ -344,7 +344,7 @@ public abstract class AAIRequest { return path; } - public abstract URL getRequestQueryUrl(String method) throws UnsupportedEncodingException, MalformedURLException, URISyntaxException; + public abstract URL getRequestQueryUrl(String method) throws UnsupportedEncodingException, MalformedURLException, URISyntaxException; public abstract String toJSONString(); |