Code Review
/
nonrtric.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge "Add unit tests for AsyncRestClient"
[nonrtric.git]
/
dashboard
/
webapp-backend
/
src
/
main
/
java
/
org
/
oransc
/
ric
/
portal
/
dashboard
/
policyagentapi
/
PolicyAgentApiImpl.java
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
c0dde9b
..
470e2df
100644
(file)
--- 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
@@
-58,14
+58,14
@@
public class PolicyAgentApiImpl implements PolicyAgentApi {
RestTemplate restTemplate = new RestTemplate();
private static com.google.gson.Gson gson = new GsonBuilder() //
RestTemplate restTemplate = new RestTemplate();
private static com.google.gson.Gson gson = new GsonBuilder() //
- .serializeNulls() //
- .create(); //
+
.serializeNulls() //
+
.create(); //
private final String urlPrefix;
@Autowired
public PolicyAgentApiImpl(
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;
}
logger.debug("ctor prefix '{}'", urlPrefix);
this.urlPrefix = urlPrefix;
}
@@
-119,7
+119,8
@@
public class PolicyAgentApiImpl implements PolicyAgentApi {
}
try {
}
try {
- Type listType = new TypeToken<List<ImmutablePolicyInfo>>() {}.getType();
+ Type listType = new TypeToken<List<ImmutablePolicyInfo>>() {
+ }.getType();
List<PolicyInfo> rspParsed = gson.fromJson(rsp.getBody(), listType);
PolicyInstances result = new PolicyInstances();
for (PolicyInfo p : rspParsed) {
List<PolicyInfo> rspParsed = gson.fromJson(rsp.getBody(), listType);
PolicyInstances result = new PolicyInstances();
for (PolicyInfo p : rspParsed) {
@@
-132,22
+133,22
@@
public class PolicyAgentApiImpl implements PolicyAgentApi {
}
@Override
}
@Override
- public ResponseEntity<
String
> getPolicyInstance(String id) {
+ public ResponseEntity<
Object
> getPolicyInstance(String id) {
String url = baseUrl() + "/policy?instance={id}";
Map<String, ?> uriVariables = Map.of("id", id);
String url = baseUrl() + "/policy?instance={id}";
Map<String, ?> uriVariables = Map.of("id", id);
- return this.restTemplate.getForEntity(url,
String
.class, uriVariables);
+ return this.restTemplate.getForEntity(url,
Object
.class, uriVariables);
}
@Override
}
@Override
- public ResponseEntity<String> putPolicy(String policyTypeIdString, String policyInstanceId,
String
json,
- String ric) {
+ public ResponseEntity<String> putPolicy(String policyTypeIdString, String policyInstanceId,
Object
json,
+
String ric) {
String url = baseUrl() + "/policy?type={type}&instance={instance}&ric={ric}&service={service}";
Map<String, ?> uriVariables = Map.of( //
String url = baseUrl() + "/policy?type={type}&instance={instance}&ric={ric}&service={service}";
Map<String, ?> uriVariables = Map.of( //
- "type", policyTypeIdString, //
- "instance", policyInstanceId, //
- "ric", ric, //
- "service", "dashboard");
+
"type", policyTypeIdString, //
+
"instance", policyInstanceId, //
+
"ric", ric, //
+
"service", "dashboard");
try {
this.restTemplate.put(url, createJsonHttpEntity(json), uriVariables);
try {
this.restTemplate.put(url, createJsonHttpEntity(json), uriVariables);
@@
-173,7
+174,7
@@
public class PolicyAgentApiImpl implements PolicyAgentApi {
@Value.Immutable
@Gson.TypeAdapters
interface RicInfo {
@Value.Immutable
@Gson.TypeAdapters
interface RicInfo {
- public String
n
ame();
+ public String
ricN
ame();
public Collection<String> nodeNames();
public Collection<String> nodeNames();
@@
-187,11
+188,12
@@
public class PolicyAgentApiImpl implements PolicyAgentApi {
String rsp = this.restTemplate.getForObject(url, String.class, uriVariables);
try {
String rsp = this.restTemplate.getForObject(url, String.class, uriVariables);
try {
- Type listType = new TypeToken<List<ImmutableRicInfo>>() {}.getType();
+ Type listType = new TypeToken<List<ImmutableRicInfo>>() {
+ }.getType();
List<RicInfo> rspParsed = gson.fromJson(rsp, listType);
Collection<String> result = new Vector<>(rspParsed.size());
for (RicInfo ric : rspParsed) {
List<RicInfo> rspParsed = gson.fromJson(rsp, listType);
Collection<String> result = new Vector<>(rspParsed.size());
for (RicInfo ric : rspParsed) {
- result.add(ric.
n
ame());
+ result.add(ric.
ricN
ame());
}
return new ResponseEntity<>(gson.toJson(result), HttpStatus.OK);
} catch (Exception e) {
}
return new ResponseEntity<>(gson.toJson(result), HttpStatus.OK);
} catch (Exception e) {
@@
-199,10
+201,10
@@
public class PolicyAgentApiImpl implements PolicyAgentApi {
}
}
}
}
- private HttpEntity<
String> createJsonHttpEntity(String
content) {
+ private HttpEntity<
Object> createJsonHttpEntity(Object
content) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
- return new HttpEntity<
String
>(content, headers);
+ return new HttpEntity<
Object
>(content, headers);
}
}
}
}