Code Review
/
nonrtric.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Renamed things to fit with namechange of RicSynchronizationTask
[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
..
a2d8c3e
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
@@
-2,7
+2,7
@@
* ========================LICENSE_START=================================
* O-RAN-SC
* %%
* ========================LICENSE_START=================================
* O-RAN-SC
* %%
- * Copyright (C) 2019
AT&T Intellectual Property
+ * Copyright (C) 2019
Nordix Foundation
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-28,10
+28,10
@@
import com.google.gson.reflect.TypeToken;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Type;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Type;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
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.immutables.gson.Gson;
import org.immutables.value.Value;
@@
-55,7
+55,7
@@
import org.springframework.web.client.RestTemplate;
public class PolicyAgentApiImpl implements PolicyAgentApi {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
public class PolicyAgentApiImpl implements PolicyAgentApi {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- RestTemplate restTemplate
= new RestTemplate()
;
+ RestTemplate restTemplate;
private static com.google.gson.Gson gson = new GsonBuilder() //
.serializeNulls() //
private static com.google.gson.Gson gson = new GsonBuilder() //
.serializeNulls() //
@@
-66,8
+66,13
@@
public class PolicyAgentApiImpl implements PolicyAgentApi {
@Autowired
public PolicyAgentApiImpl(
@org.springframework.beans.factory.annotation.Value("${policycontroller.url.prefix}") final String urlPrefix) {
@Autowired
public PolicyAgentApiImpl(
@org.springframework.beans.factory.annotation.Value("${policycontroller.url.prefix}") final String urlPrefix) {
+ this(urlPrefix, new RestTemplate());
logger.debug("ctor prefix '{}'", urlPrefix);
logger.debug("ctor prefix '{}'", urlPrefix);
+ }
+
+ public PolicyAgentApiImpl(String urlPrefix, RestTemplate restTemplate) {
this.urlPrefix = urlPrefix;
this.urlPrefix = urlPrefix;
+ this.restTemplate = restTemplate;
}
private String baseUrl() {
}
private String baseUrl() {
@@
-132,15
+137,15
@@
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,
+ 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 ric) {
String url = baseUrl() + "/policy?type={type}&instance={instance}&ric={ric}&service={service}";
Map<String, ?> uriVariables = Map.of( //
@@
-173,7
+178,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();
@@
-189,9
+194,9
@@
public class PolicyAgentApiImpl implements PolicyAgentApi {
try {
Type listType = new TypeToken<List<ImmutableRicInfo>>() {}.getType();
List<RicInfo> rspParsed = gson.fromJson(rsp, listType);
try {
Type listType = new TypeToken<List<ImmutableRicInfo>>() {}.getType();
List<RicInfo> rspParsed = gson.fromJson(rsp, listType);
- Collection<String> result = new
Vector
<>(rspParsed.size());
+ Collection<String> result = new
ArrayList
<>(rspParsed.size());
for (RicInfo ric : rspParsed) {
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
+204,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<>(content, headers);
}
}
}
}