X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=dashboard%2Fwebapp-backend%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fric%2Fportal%2Fdashboard%2Fpolicyagentapi%2FPolicyAgentApiImpl.java;h=b80389cf3e549916a8831824ddf3a36615d98754;hb=c666f5e9ddadbe4ab6064b746189f5ff142f6d83;hp=eb3f836867198966e3b28730043dc537887c583a;hpb=7a4a590fb0ebf8772169625cdda327da43c79c6d;p=nonrtric.git diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/policyagentapi/PolicyAgentApiImpl.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/policyagentapi/PolicyAgentApiImpl.java index eb3f8368..b80389cf 100644 --- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/policyagentapi/PolicyAgentApiImpl.java +++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/policyagentapi/PolicyAgentApiImpl.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,12 +19,27 @@ */ package org.oransc.ric.portal.dashboard.policyagentapi; -import org.oransc.ric.portal.dashboard.DashboardConstants; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.reflect.TypeToken; +import java.lang.invoke.MethodHandles; +import java.lang.reflect.Type; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Vector; +import org.immutables.gson.Gson; +import org.immutables.value.Value; import org.oransc.ric.portal.dashboard.model.ImmutablePolicyInfo; import org.oransc.ric.portal.dashboard.model.PolicyInfo; import org.oransc.ric.portal.dashboard.model.PolicyInstances; import org.oransc.ric.portal.dashboard.model.PolicyType; import org.oransc.ric.portal.dashboard.model.PolicyTypes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -32,26 +47,6 @@ import org.springframework.stereotype.Component; import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestTemplate; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Vector; -import java.lang.invoke.MethodHandles; -import java.lang.reflect.Type; - -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.google.gson.annotations.SerializedName; -import com.google.gson.reflect.TypeToken; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.immutables.gson.Gson; -import org.immutables.value.Value; - @Component("PolicyAgentApi") public class PolicyAgentApiImpl implements PolicyAgentApi { private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @@ -59,14 +54,14 @@ public class PolicyAgentApiImpl implements PolicyAgentApi { RestTemplate restTemplate = new RestTemplate(); private static com.google.gson.Gson gson = new GsonBuilder() // - .serializeNulls() // - .create(); // + .serializeNulls() // + .create(); // private final String urlPrefix; @Autowired public PolicyAgentApiImpl( - @org.springframework.beans.factory.annotation.Value("${policycontroller.url.prefix}") final String urlPrefix) { + @org.springframework.beans.factory.annotation.Value("${policycontroller.url.prefix}") final String urlPrefix) { logger.debug("ctor prefix '{}'", urlPrefix); this.urlPrefix = urlPrefix; } @@ -114,8 +109,7 @@ public class PolicyAgentApiImpl implements PolicyAgentApi { return new ResponseEntity<>(rsp.getStatusCode()); } - Type listType = new TypeToken>() { - }.getType(); + Type listType = new TypeToken>() {}.getType(); List rspParsed = gson.fromJson(rsp.getBody(), listType); PolicyInstances result = new PolicyInstances(); @@ -135,13 +129,13 @@ public class PolicyAgentApiImpl implements PolicyAgentApi { @Override public ResponseEntity putPolicy(String policyTypeIdString, String policyInstanceId, String json, String ric) - throws RestClientException { + throws RestClientException { String url = baseUrl() + "/policy?type={type}&instance={instance}&ric={ric}&service={service}"; Map uriVariables = Map.of( // - "type", policyTypeIdString, // - "instance", policyInstanceId, // - "ric", ric, // - "service", "dashboard"); + "type", policyTypeIdString, // + "instance", policyInstanceId, // + "ric", ric, // + "service", "dashboard"); try { this.restTemplate.put(url, json, uriVariables); @@ -174,8 +168,7 @@ public class PolicyAgentApiImpl implements PolicyAgentApi { Map uriVariables = Map.of("typeName", typeName); String rsp = this.restTemplate.getForObject(url, String.class, uriVariables); - Type listType = new TypeToken>() { - }.getType(); + Type listType = new TypeToken>() {}.getType(); List rspParsed = gson.fromJson(rsp, listType); Collection result = new Vector<>(rspParsed.size());