summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/pom.xml12
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/AdditionalProperties.java3
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java2
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/AllocateCnNssi.java2
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/AllocateTnNssi.java6
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/AnPerfReq.java50
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java13
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/CnSliceProfile.java94
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/ConnectionLink.java24
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/EndPoint.java17
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/NssiResponse.java18
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/PerfReq.java5
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/PerfReqEmbb.java3
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/PerfReqUrllc.java103
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/PnfErrorList.java5
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/ResponseDescriptor.java1
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/ResponseHistory.java5
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/SliceProfileAdapter.java180
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/SliceTaskInfo.java2
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParamsAdapter.java74
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/TnSliceProfile.java19
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/TransportSliceNetwork.java1
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/VnfErrorList.java5
-rw-r--r--common/src/main/java/org/onap/so/client/AddCacheHeaders.java28
-rw-r--r--common/src/main/java/org/onap/so/client/CacheFactory.java25
-rw-r--r--common/src/main/java/org/onap/so/client/CacheProperties.java13
-rw-r--r--common/src/main/java/org/onap/so/client/RestClient.java20
-rw-r--r--common/src/main/java/org/onap/so/client/RestClientSSL.java2
-rw-r--r--common/src/main/java/org/onap/so/client/RestProperties.java17
-rw-r--r--common/src/test/java/org/onap/so/client/RestClientTest.java63
-rw-r--r--common/src/test/resources/logback-test.xml91
31 files changed, 541 insertions, 362 deletions
diff --git a/common/pom.xml b/common/pom.xml
index 74e51805ad..6e265925c3 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -293,6 +293,16 @@
<artifactId>jaxb-impl</artifactId>
<version>2.3.0</version>
</dependency>
+ <dependency>
+ <groupId>javax.cache</groupId>
+ <artifactId>cache-api</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ehcache</groupId>
+ <artifactId>ehcache</artifactId>
+ <version>3.8.1</version>
+ </dependency>
</dependencies>
<dependencyManagement>
<dependencies>
@@ -366,4 +376,4 @@
</plugin>
</plugins>
</build>
-</project> \ No newline at end of file
+</project>
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AdditionalProperties.java b/common/src/main/java/org/onap/so/beans/nsmf/AdditionalProperties.java
index 5b070bb00f..3b542faf7f 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/AdditionalProperties.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/AdditionalProperties.java
@@ -26,11 +26,12 @@ import java.util.List;
@JsonInclude(JsonInclude.Include.NON_NULL)
@Data
+@Deprecated
public class AdditionalProperties implements Serializable {
private static final long serialVersionUID = -4020397418955518175L;
- private SliceProfile sliceProfile;
+ private TnSliceProfile sliceProfile;
private List<EndPoint> endPoints;
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java
index dc8e69121e..f966098b18 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java
@@ -47,5 +47,5 @@ public class AllocateAnNssi implements Serializable {
private NsiInfo nsiInfo;
- private Map<String, Object> endPoint;
+ private EndPoint endPoint;
}
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AllocateCnNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/AllocateCnNssi.java
index f5b926f627..fdbff2fd42 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/AllocateCnNssi.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/AllocateCnNssi.java
@@ -49,5 +49,5 @@ public class AllocateCnNssi implements Serializable {
private NsiInfo nsiInfo;
- private Map<String, Object> endPoint;
+ private EndPoint endPoint;
}
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AllocateTnNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/AllocateTnNssi.java
index f85cb0cd85..1b0986ca0d 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/AllocateTnNssi.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/AllocateTnNssi.java
@@ -30,7 +30,13 @@ public class AllocateTnNssi implements Serializable {
private static final long serialVersionUID = -7069801712339914746L;
+ private TnSliceProfile sliceProfile;
+
private List<NetworkSliceInfo> networkSliceInfos;
private List<TransportSliceNetwork> transportSliceNetworks;
+
+ private NsiInfo nsiInfo;
+
+ private String scriptName;
}
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AnPerfReq.java b/common/src/main/java/org/onap/so/beans/nsmf/AnPerfReq.java
deleted file mode 100644
index e2c2e999ec..0000000000
--- a/common/src/main/java/org/onap/so/beans/nsmf/AnPerfReq.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.beans.nsmf;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import java.io.Serializable;
-
-@JsonInclude(JsonInclude.Include.NON_NULL)
-public class AnPerfReq implements Serializable {
-
- private static final long serialVersionUID = -7415880702887244040L;
-
- private PerfReqEmbb perfReqEmbb;
-
- private PerfReqUrllc perfReqUrllc;
-
- public PerfReqEmbb getPerfReqEmbb() {
- return perfReqEmbb;
- }
-
- public void setPerfReqEmbb(PerfReqEmbb perfReqEmbb) {
- this.perfReqEmbb = perfReqEmbb;
- }
-
- public PerfReqUrllc getPerfReqUrllc() {
- return perfReqUrllc;
- }
-
- public void setPerfReqUrllc(PerfReqUrllc perfReqUrllc) {
- this.perfReqUrllc = perfReqUrllc;
- }
-}
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java b/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java
index eef0396205..3d0f70805c 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java
@@ -31,24 +31,27 @@ import java.util.List;
@Data
@ToString
public class AnSliceProfile implements Serializable {
+ /*
+ * Reference 3GPP TS 28.541 V16.5.0.
+ */
private static final long serialVersionUID = -3057342171549542794L;
@JsonProperty(value = "sliceProfileId", required = true)
private String sliceProfileId;
- @JsonProperty(value = "sNSSAIList", required = true)
+ @JsonProperty(value = "snssaiList", required = true)
private List<String> sNSSAIList;
- @JsonProperty(value = "pLMNIdList", required = true)
+ @JsonProperty(value = "plmnIdList", required = true)
private List<String> pLMNIdList;
@JsonProperty(value = "perfReq", required = true)
- private AnPerfReq perfReq;
+ private PerfReq perfReq;
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@JsonProperty(value = "maxNumberofUEs")
- private long maxNumberofUEs;
+ private int maxNumberOfUEs;
@JsonProperty(value = "coverageAreaTAList")
private List<Integer> coverageAreaTAList;
@@ -58,7 +61,7 @@ public class AnSliceProfile implements Serializable {
private int latency;
@JsonProperty(value = "uEMobilityLevel")
- private UeMobilityLevel uEMobilityLevel;
+ private UeMobilityLevel ueMobilityLevel;
@JsonProperty(value = "resourceSharingLevel")
private ResourceSharingLevel resourceSharingLevel;
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/CnSliceProfile.java b/common/src/main/java/org/onap/so/beans/nsmf/CnSliceProfile.java
index 3bd155d512..efb447bc00 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/CnSliceProfile.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/CnSliceProfile.java
@@ -21,100 +21,44 @@
package org.onap.so.beans.nsmf;
import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import java.io.Serializable;
import java.util.List;
@JsonInclude(JsonInclude.Include.NON_NULL)
-public class CnSliceProfile {
+@Data
+public class CnSliceProfile implements Serializable {
+ private static final long serialVersionUID = 6627071735572539536L;
+
+ @JsonProperty(value = "snssaiList", required = true)
private List<String> snssaiList;
private String sliceProfileId;
- private List<String> plmnIdList;
+ @JsonProperty(value = "plmnIdList", required = true)
+ private List<String> pLMNIdList;
+ @JsonProperty(value = "perfReq", required = true)
private PerfReq perfReq;
- @JsonInclude(JsonInclude.Include.NON_DEFAULT)
- private int maxNumberofUEs;
+ @JsonProperty(value = "maxNumberofUEs")
+ private int maxNumberOfUEs;
+ @JsonProperty(value = "coverageAreaTAList")
private List<String> coverageAreaTAList;
- @JsonInclude(JsonInclude.Include.NON_DEFAULT)
+ @JsonProperty(value = "latency")
private int latency;
+ @JsonProperty(value = "uEMobilityLevel")
private UeMobilityLevel ueMobilityLevel;
+ @JsonProperty(value = "resourceSharingLevel")
private ResourceSharingLevel resourceSharingLevel;
- public String getSliceProfileId() {
- return sliceProfileId;
- }
-
- public void setSliceProfileId(String sliceProfileId) {
- this.sliceProfileId = sliceProfileId;
- }
-
- public List<String> getPlmnIdList() {
- return plmnIdList;
- }
-
- public void setPlmnIdList(List<String> plmnIdList) {
- this.plmnIdList = plmnIdList;
- }
-
- public PerfReq getPerfReq() {
- return perfReq;
- }
-
- public void setPerfReq(PerfReq perfReq) {
- this.perfReq = perfReq;
- }
-
- public int getMaxNumberofUEs() {
- return maxNumberofUEs;
- }
-
- public void setMaxNumberofUEs(int maxNumberofUEs) {
- this.maxNumberofUEs = maxNumberofUEs;
- }
-
- public List<String> getCoverageAreaTAList() {
- return coverageAreaTAList;
- }
-
- public void setCoverageAreaTAList(List<String> coverageAreaTAList) {
- this.coverageAreaTAList = coverageAreaTAList;
- }
-
- public int getLatency() {
- return latency;
- }
-
- public void setLatency(int latency) {
- this.latency = latency;
- }
-
- public UeMobilityLevel getUeMobilityLevel() {
- return ueMobilityLevel;
- }
-
- public void setUeMobilityLevel(UeMobilityLevel ueMobilityLevel) {
- this.ueMobilityLevel = ueMobilityLevel;
- }
-
- public ResourceSharingLevel getResourceSharingLevel() {
- return resourceSharingLevel;
- }
-
- public void setResourceSharingLevel(ResourceSharingLevel resourceSharingLevel) {
- this.resourceSharingLevel = resourceSharingLevel;
- }
-
- public List<String> getSnssaiList() {
- return snssaiList;
- }
+ @JsonProperty(value = "maxNumberofPDUSession")
+ private int maxNumberOfPDUSession;
- public void setSnssaiList(List<String> snssaiList) {
- this.snssaiList = snssaiList;
- }
}
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/ConnectionLink.java b/common/src/main/java/org/onap/so/beans/nsmf/ConnectionLink.java
index 99a8525974..3bf2ffb8eb 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/ConnectionLink.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/ConnectionLink.java
@@ -20,33 +20,15 @@
package org.onap.so.beans.nsmf;
+import lombok.Data;
import java.io.Serializable;
-
+@Data
public class ConnectionLink implements Serializable {
+
private static final long serialVersionUID = -1834584960407180427L;
private String transportEndpointA;
private String transportEndpointB;
-
- public static long getSerialVersionUID() {
- return serialVersionUID;
- }
-
- public String getTransportEndpointA() {
- return transportEndpointA;
- }
-
- public void setTransportEndpointA(String transportEndpointA) {
- this.transportEndpointA = transportEndpointA;
- }
-
- public String getTransportEndpointB() {
- return transportEndpointB;
- }
-
- public void setTransportEndpointB(String transportEndpointB) {
- this.transportEndpointB = transportEndpointB;
- }
}
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/EndPoint.java b/common/src/main/java/org/onap/so/beans/nsmf/EndPoint.java
index dab9b3a990..90bfc0eae0 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/EndPoint.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/EndPoint.java
@@ -20,17 +20,28 @@
package org.onap.so.beans.nsmf;
import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.AllArgsConstructor;
import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
import java.io.Serializable;
-import java.util.Map;
@JsonInclude(JsonInclude.Include.NON_NULL)
@Data
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
public class EndPoint implements Serializable {
private static final long serialVersionUID = 2479795890807020491L;
- private String nodeId;
+ @JsonProperty(value = "ipAddress")
+ private String ipAddress;
- private Map<String, Object> additionalInfo;
+ @JsonProperty(value = "logicInterfaceId")
+ private String logicInterfaceId;
+
+ @JsonProperty(value = "nextHopInfo")
+ private String nextHopInfo;
}
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NssiResponse.java b/common/src/main/java/org/onap/so/beans/nsmf/NssiResponse.java
index 92acdaa90d..270a55e349 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/NssiResponse.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/NssiResponse.java
@@ -21,9 +21,11 @@
package org.onap.so.beans.nsmf;
import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
import java.io.Serializable;
@JsonInclude(JsonInclude.Include.NON_NULL)
+@Data
public class NssiResponse implements Serializable {
private static final long serialVersionUID = 2723440188640857903L;
@@ -32,19 +34,5 @@ public class NssiResponse implements Serializable {
private String jobId;
- public String getNssiId() {
- return nssiId;
- }
-
- public void setNssiId(String nssiId) {
- this.nssiId = nssiId;
- }
-
- public String getJobId() {
- return jobId;
- }
-
- public void setJobId(String jobId) {
- this.jobId = jobId;
- }
+ private String status;
}
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/PerfReq.java b/common/src/main/java/org/onap/so/beans/nsmf/PerfReq.java
index c67f193a02..6697c8d8a0 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/PerfReq.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/PerfReq.java
@@ -21,10 +21,13 @@
package org.onap.so.beans.nsmf;
import com.fasterxml.jackson.annotation.JsonInclude;
+import java.io.Serializable;
import java.util.List;
@JsonInclude(JsonInclude.Include.NON_NULL)
-public class PerfReq {
+public class PerfReq implements Serializable {
+
+ private static final long serialVersionUID = 8463835350563510267L;
private List<PerfReqEmbb> perfReqEmbbList;
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/PerfReqEmbb.java b/common/src/main/java/org/onap/so/beans/nsmf/PerfReqEmbb.java
index f6e945e368..1db009cdb9 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/PerfReqEmbb.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/PerfReqEmbb.java
@@ -25,6 +25,9 @@ import java.io.Serializable;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PerfReqEmbb implements Serializable {
+ /*
+ * Reference 3GPP TS 28.541 V16.5.0, Section 6.4.1.
+ */
private static final long serialVersionUID = 8886635511695277599L;
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/PerfReqUrllc.java b/common/src/main/java/org/onap/so/beans/nsmf/PerfReqUrllc.java
index 9e4b4edce3..06f97a8484 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/PerfReqUrllc.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/PerfReqUrllc.java
@@ -21,118 +21,31 @@
package org.onap.so.beans.nsmf;
import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
import java.io.Serializable;
@JsonInclude(JsonInclude.Include.NON_NULL)
+@Data
public class PerfReqUrllc implements Serializable {
private static final long serialVersionUID = 3133479142915485943L;
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
- private int e2eLatency;
+ private String survivalTime;
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
- private int jitter;
-
- @JsonInclude(JsonInclude.Include.NON_DEFAULT)
- private int survivalTime;
-
- @JsonInclude(JsonInclude.Include.NON_DEFAULT)
- private float csAvailability;
+ private int expDataRate;
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
- private float reliability;
+ private String transferIntervalTarget;
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
- private int expDataRate;
-
- private String payloadSize;
+ private String msgSizeByte;
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
- private int trafficDensity;
+ private String csReliabilityMeanTime;
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
- private int connDensity;
-
- private String serviceAreaDimension;
-
- public int getE2eLatency() {
- return e2eLatency;
- }
-
- public void setE2eLatency(int e2eLatency) {
- this.e2eLatency = e2eLatency;
- }
-
- public int getJitter() {
- return jitter;
- }
-
- public void setJitter(int jitter) {
- this.jitter = jitter;
- }
-
- public int getSurvivalTime() {
- return survivalTime;
- }
-
- public void setSurvivalTime(int survivalTime) {
- this.survivalTime = survivalTime;
- }
-
- public float getReliability() {
- return reliability;
- }
-
- public void setReliability(float reliability) {
- this.reliability = reliability;
- }
-
- public int getExpDataRate() {
- return expDataRate;
- }
-
- public void setExpDataRate(int expDataRate) {
- this.expDataRate = expDataRate;
- }
-
- public String getPayloadSize() {
- return payloadSize;
- }
-
- public void setPayloadSize(String payloadSize) {
- this.payloadSize = payloadSize;
- }
-
- public int getTrafficDensity() {
- return trafficDensity;
- }
-
- public void setTrafficDensity(int trafficDensity) {
- this.trafficDensity = trafficDensity;
- }
-
- public int getConnDensity() {
- return connDensity;
- }
-
- public void setConnDensity(int connDensity) {
- this.connDensity = connDensity;
- }
-
- public String getServiceAreaDimension() {
- return serviceAreaDimension;
- }
-
- public void setServiceAreaDimension(String serviceAreaDimension) {
- this.serviceAreaDimension = serviceAreaDimension;
- }
-
- public float getCsAvailability() {
- return csAvailability;
- }
+ private float csAvailabilityTarget;
- public void setCsAvailability(float csAvailability) {
- this.csAvailability = csAvailability;
- }
}
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/PnfErrorList.java b/common/src/main/java/org/onap/so/beans/nsmf/PnfErrorList.java
index 66bfbdcea9..4fc593268a 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/PnfErrorList.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/PnfErrorList.java
@@ -21,9 +21,12 @@
package org.onap.so.beans.nsmf;
import com.fasterxml.jackson.annotation.JsonInclude;
+import java.io.Serializable;
@JsonInclude(JsonInclude.Include.NON_NULL)
-public class PnfErrorList {
+public class PnfErrorList implements Serializable {
+
+ private static final long serialVersionUID = 1506455363755909867L;
private String pnfId;
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/ResponseDescriptor.java b/common/src/main/java/org/onap/so/beans/nsmf/ResponseDescriptor.java
index 2456d540ce..17ef210c4e 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/ResponseDescriptor.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/ResponseDescriptor.java
@@ -31,7 +31,6 @@ public class ResponseDescriptor implements Serializable {
private static final long serialVersionUID = 6330527958947215910L;
- @JsonInclude(JsonInclude.Include.NON_DEFAULT)
private int progress;
private String status;
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/ResponseHistory.java b/common/src/main/java/org/onap/so/beans/nsmf/ResponseHistory.java
index c71441a80a..ee027bca13 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/ResponseHistory.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/ResponseHistory.java
@@ -21,10 +21,13 @@
package org.onap.so.beans.nsmf;
import com.fasterxml.jackson.annotation.JsonInclude;
+import java.io.Serializable;
import java.util.List;
@JsonInclude(JsonInclude.Include.NON_NULL)
-public class ResponseHistory {
+public class ResponseHistory implements Serializable {
+
+ private static final long serialVersionUID = -1005342539496792450L;
private int progress;
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/SliceProfileAdapter.java b/common/src/main/java/org/onap/so/beans/nsmf/SliceProfileAdapter.java
new file mode 100644
index 0000000000..90cee2794a
--- /dev/null
+++ b/common/src/main/java/org/onap/so/beans/nsmf/SliceProfileAdapter.java
@@ -0,0 +1,180 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.beans.nsmf;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.ToString;
+import org.springframework.beans.BeanUtils;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+@Data
+@ToString
+public class SliceProfileAdapter implements Serializable {
+
+ private static final long serialVersionUID = -6412175980642584804L;
+
+ @JsonProperty(value = "sliceProfileId")
+ private String sliceProfileId;
+
+ @JsonProperty(value = "sNSSAI")
+ private String sNSSAIList = "";
+
+ @JsonProperty(value = "pLMNIdList")
+ private String pLMNIdList = "";
+
+ @JsonProperty(value = "maxNumberofUEs")
+ private int maxNumberOfUEs;
+
+ @JsonProperty(value = "coverageAreaTAList")
+ private String coverageAreaTAList = "";
+
+ @JsonProperty(value = "latency")
+ private int latency;
+
+ @JsonProperty(value = "uEMobilityLevel")
+ private String ueMobilityLevel;
+
+ @JsonProperty(value = "resourceSharingLevel")
+ private String resourceSharingLevel;
+
+ @JsonProperty(value = "maxBandwidth")
+ private int maxBandwidth;
+
+ @JsonProperty(value = "sST")
+ private String sST;
+
+ @JsonProperty(value = "activityFactor")
+ private int activityFactor;
+
+ @JsonProperty(value = "survivalTime")
+ private String survivalTime;
+
+ @JsonProperty(value = "expDataRateUL")
+ private int expDataRateUL;
+
+ @JsonProperty(value = "expDataRateDL")
+ private int expDataRateDL;
+
+ @JsonProperty(value = "areaTrafficCapUL")
+ private int areaTrafficCapUL;
+
+ @JsonProperty(value = "areaTrafficCapDL")
+ private int areaTrafficCapDL;
+
+ @JsonProperty(value = "jitter")
+ private int jitter;
+
+ @JsonProperty(value = "csAvailabilityTarget")
+ private float csAvailabilityTarget;
+
+ @JsonProperty(value = "expDataRate")
+ private int expDataRate;
+
+ @JsonProperty(value = "maxNumberofPDUSession")
+ private int maxNumberOfPDUSession;
+
+ @JsonProperty(value = "overallUserDensity")
+ private int overallUserDensity;
+
+ @JsonProperty(value = "cSReliabilityMeanTime")
+ private String csReliabilityMeanTime;
+
+ @JsonProperty(value = "msgSizeByte")
+ private String msgSizeByte;
+
+ @JsonProperty(value = "transferIntervalTarget")
+ private String transferIntervalTarget;
+
+ @JsonProperty(value = "ipAddress")
+ private String ipAddress;
+
+ @JsonProperty(value = "logicInterfaceId")
+ private String logicInterfaceId;
+
+ @JsonProperty(value = "nextHopInfo")
+ private String nextHopInfo;
+
+ public AnSliceProfile trans2AnProfile() {
+ AnSliceProfile anSliceProfile = new AnSliceProfile();
+ BeanUtils.copyProperties(this, anSliceProfile);
+ anSliceProfile.setSNSSAIList(Arrays.asList(this.sNSSAIList.split("\\|")));
+ anSliceProfile.setPLMNIdList(Arrays.asList(this.pLMNIdList.split("\\|")));
+
+ String[] areas = this.coverageAreaTAList.split("\\|");
+ Integer[] areasRes = new Integer[areas.length];
+ for (int i = 0; i < areas.length; i++) {
+ areasRes[i] = str2Code(areas[i]);
+ }
+ anSliceProfile.setCoverageAreaTAList(Arrays.asList(areasRes));
+
+ anSliceProfile.setUeMobilityLevel(UeMobilityLevel.fromString(this.ueMobilityLevel));
+ anSliceProfile.setResourceSharingLevel(ResourceSharingLevel.fromString(this.resourceSharingLevel));
+ anSliceProfile.setPerfReq(generatePerfReq());
+
+ return anSliceProfile;
+ }
+
+ private Integer str2Code(String area) {
+ return area.hashCode() >> 16;
+ }
+
+ public CnSliceProfile trans2CnProfile() {
+ CnSliceProfile cnSliceProfile = new CnSliceProfile();
+ BeanUtils.copyProperties(this, cnSliceProfile);
+ cnSliceProfile.setSnssaiList(Arrays.asList(this.sNSSAIList.split("\\|")));
+ cnSliceProfile.setCoverageAreaTAList(Arrays.asList(this.coverageAreaTAList.split("\\|")));
+ cnSliceProfile.setPLMNIdList(Arrays.asList(this.pLMNIdList.split("\\|")));
+ cnSliceProfile.setResourceSharingLevel(ResourceSharingLevel.fromString(this.resourceSharingLevel));
+
+ cnSliceProfile.setPerfReq(generatePerfReq());
+ return cnSliceProfile;
+ }
+
+ private PerfReq generatePerfReq() {
+ PerfReq perfReq = new PerfReq();
+ if ("embb".equalsIgnoreCase(sST)) {
+ List<PerfReqEmbb> perfReqEmbbs = new ArrayList<>();
+ PerfReqEmbb perfReqEmbb = new PerfReqEmbb();
+ BeanUtils.copyProperties(this, perfReqEmbb);
+ perfReqEmbbs.add(perfReqEmbb);
+ perfReq.setPerfReqEmbbList(perfReqEmbbs);
+ } else if ("ullc".equalsIgnoreCase(sST)) {
+ List<PerfReqUrllc> perfReqUrllcs = new ArrayList<>();
+ PerfReqUrllc perfReqUrllc = new PerfReqUrllc();
+ BeanUtils.copyProperties(this, perfReqUrllc);
+ perfReqUrllcs.add(perfReqUrllc);
+ perfReq.setPerfReqUrllcList(perfReqUrllcs);
+ }
+ return perfReq;
+ }
+
+ public TnSliceProfile trans2TnProfile() {
+ TnSliceProfile tnSliceProfile = new TnSliceProfile();
+ BeanUtils.copyProperties(this, tnSliceProfile);
+ tnSliceProfile.setSNSSAIList(Arrays.asList(this.sNSSAIList.split("\\|")));
+ tnSliceProfile.setPLMNIdList(Arrays.asList(this.pLMNIdList.split("\\|")));
+ return tnSliceProfile;
+ }
+}
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskInfo.java
index 9b6406d57f..18d6007176 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskInfo.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskInfo.java
@@ -52,4 +52,6 @@ public class SliceTaskInfo<T> implements Serializable {
private SubnetType subnetType;
+ private String endPointId;
+
}
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParamsAdapter.java b/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParamsAdapter.java
index e97aa704eb..bfd4627b47 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParamsAdapter.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParamsAdapter.java
@@ -19,6 +19,7 @@
*/
package org.onap.so.beans.nsmf;
+import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.JsonObject;
import lombok.*;
@@ -56,15 +57,15 @@ public class SliceTaskParamsAdapter implements Serializable {
private TemplateInfo NSTInfo = new TemplateInfo();
- private SliceTaskInfo<TnSliceProfile> tnBHSliceTaskInfo = new SliceTaskInfo<>();
+ private SliceTaskInfo<SliceProfileAdapter> tnBHSliceTaskInfo = new SliceTaskInfo<>();
- private SliceTaskInfo<TnSliceProfile> tnMHSliceTaskInfo = new SliceTaskInfo<>();
+ private SliceTaskInfo<SliceProfileAdapter> tnMHSliceTaskInfo = new SliceTaskInfo<>();
- private SliceTaskInfo<TnSliceProfile> tnFHSliceTaskInfo = new SliceTaskInfo<>();
+ private SliceTaskInfo<SliceProfileAdapter> tnFHSliceTaskInfo = new SliceTaskInfo<>();
- private SliceTaskInfo<CnSliceProfile> cnSliceTaskInfo = new SliceTaskInfo<>();
+ private SliceTaskInfo<SliceProfileAdapter> cnSliceTaskInfo = new SliceTaskInfo<>();
- private SliceTaskInfo<AnSliceProfile> anSliceTaskInfo = new SliceTaskInfo<>();
+ private SliceTaskInfo<SliceProfileAdapter> anSliceTaskInfo = new SliceTaskInfo<>();
@SuppressWarnings("unchecked")
public void convertFromJson(String jsonString) throws IOException {
@@ -80,24 +81,24 @@ public class SliceTaskParamsAdapter implements Serializable {
this.setServiceProfile(replaceHeader(paramMap, "ServiceProfile."));
- TnSliceProfile tnBHSliceProfile = mapper.readValue(
- mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.TN.BH.")), TnSliceProfile.class);
+ SliceProfileAdapter tnBHSliceProfile = mapper.readValue(
+ mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.TN.BH.")), SliceProfileAdapter.class);
this.tnBHSliceTaskInfo.setSliceProfile(tnBHSliceProfile);
- TnSliceProfile tnMHSliceProfile = mapper.readValue(
- mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.TN.MH.")), TnSliceProfile.class);
+ SliceProfileAdapter tnMHSliceProfile = mapper.readValue(
+ mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.TN.MH.")), SliceProfileAdapter.class);
this.tnMHSliceTaskInfo.setSliceProfile(tnMHSliceProfile);
- TnSliceProfile tnFHSliceProfile = mapper.readValue(
- mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.TN.FH.")), TnSliceProfile.class);
+ SliceProfileAdapter tnFHSliceProfile = mapper.readValue(
+ mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.TN.FH.")), SliceProfileAdapter.class);
this.tnFHSliceTaskInfo.setSliceProfile(tnFHSliceProfile);
- CnSliceProfile cnSliceProfile = mapper.readValue(
- mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.CN.")), CnSliceProfile.class);
+ SliceProfileAdapter cnSliceProfile = mapper.readValue(
+ mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.CN.")), SliceProfileAdapter.class);
this.cnSliceTaskInfo.setSliceProfile(cnSliceProfile);
- AnSliceProfile anSliceProfile = mapper.readValue(
- mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.AN.")), AnSliceProfile.class);
+ SliceProfileAdapter anSliceProfile = mapper.readValue(
+ mapper.writeValueAsString(replaceHeader(paramMap, "SliceProfile.AN.")), SliceProfileAdapter.class);
this.anSliceTaskInfo.setSliceProfile(anSliceProfile);
this.tnBHSliceTaskInfo.setSuggestNssiId(paramMap.get("TN.BH.SuggestNSSIId"));
@@ -148,33 +149,31 @@ public class SliceTaskParamsAdapter implements Serializable {
for (Map.Entry<String, Object> entry : serviceProfile.entrySet()) {
jsonObject.addProperty("ServiceProfile." + entry.getKey(), entry.getValue().toString());
}
-
Map<String, Object> sliceProfileAn = bean2Map(anSliceTaskInfo.getSliceProfile());
-
for (Map.Entry<String, Object> entry : sliceProfileAn.entrySet()) {
- jsonObject.addProperty("SliceProfile.AN." + entry.getKey(), entry.getValue().toString());
+ String value = entry.getValue() == null ? "" : entry.getValue().toString();
+ jsonObject.addProperty("SliceProfile.AN." + entry.getKey(), value);
}
-
Map<String, Object> sliceProfileCn = bean2Map(cnSliceTaskInfo.getSliceProfile());
for (Map.Entry<String, Object> entry : sliceProfileCn.entrySet()) {
- jsonObject.addProperty("SliceProfile.CN." + entry.getKey(), entry.getValue().toString());
+ String value = entry.getValue() == null ? "" : entry.getValue().toString();
+ jsonObject.addProperty("SliceProfile.CN." + entry.getKey(), value);
}
-
Map<String, Object> sliceProfileTnBH = bean2Map(tnBHSliceTaskInfo.getSliceProfile());
for (Map.Entry<String, Object> entry : sliceProfileTnBH.entrySet()) {
- jsonObject.addProperty("SliceProfile.TN.BH." + entry.getKey(), entry.getValue().toString());
+ String value = entry.getValue() == null ? "" : entry.getValue().toString();
+ jsonObject.addProperty("SliceProfile.TN.BH." + entry.getKey(), value);
}
-
Map<String, Object> sliceProfileTnMH = bean2Map(tnMHSliceTaskInfo.getSliceProfile());
for (Map.Entry<String, Object> entry : sliceProfileTnMH.entrySet()) {
- jsonObject.addProperty("SliceProfile.TN.MH." + entry.getKey(), entry.getValue().toString());
+ String value = entry.getValue() == null ? "" : entry.getValue().toString();
+ jsonObject.addProperty("SliceProfile.TN.MH." + entry.getKey(), value);
}
-
Map<String, Object> sliceProfileTnFH = bean2Map(tnFHSliceTaskInfo.getSliceProfile());
for (Map.Entry<String, Object> entry : sliceProfileTnFH.entrySet()) {
- jsonObject.addProperty("SliceProfile.TN.FH." + entry.getKey(), entry.getValue().toString());
+ String value = entry.getValue() == null ? "" : entry.getValue().toString();
+ jsonObject.addProperty("SliceProfile.TN.FH." + entry.getKey(), value);
}
-
jsonObject.addProperty("TN.BH.SuggestNSSIId", tnBHSliceTaskInfo.getSuggestNssiId());
jsonObject.addProperty("TN.BH.SuggestNSSIName", tnBHSliceTaskInfo.getSuggestNssiName());
jsonObject.addProperty("TN.BH.progress", tnBHSliceTaskInfo.getProgress());
@@ -182,7 +181,6 @@ public class SliceTaskParamsAdapter implements Serializable {
jsonObject.addProperty("TN.BH.statusDescription", tnBHSliceTaskInfo.getStatusDescription());
jsonObject.addProperty("TN.BH.ScriptName", tnBHSliceTaskInfo.getScriptName());
-
jsonObject.addProperty("TN.MH.SuggestNSSIId", tnMHSliceTaskInfo.getSuggestNssiId());
jsonObject.addProperty("TN.MH.SuggestNSSIName", tnMHSliceTaskInfo.getSuggestNssiName());
jsonObject.addProperty("TN.MH.progress", tnMHSliceTaskInfo.getProgress());
@@ -190,7 +188,6 @@ public class SliceTaskParamsAdapter implements Serializable {
jsonObject.addProperty("TN.MH.statusDescription", tnMHSliceTaskInfo.getStatusDescription());
jsonObject.addProperty("TN.MH.ScriptName", tnMHSliceTaskInfo.getScriptName());
-
jsonObject.addProperty("TN.FH.SuggestNSSIId", tnFHSliceTaskInfo.getSuggestNssiId());
jsonObject.addProperty("TN.FH.SuggestNSSIName", tnFHSliceTaskInfo.getSuggestNssiName());
jsonObject.addProperty("TN.FH.progress", tnFHSliceTaskInfo.getProgress());
@@ -198,7 +195,6 @@ public class SliceTaskParamsAdapter implements Serializable {
jsonObject.addProperty("TN.FH.statusDescription", tnFHSliceTaskInfo.getStatusDescription());
jsonObject.addProperty("TN.FH.ScriptName", tnFHSliceTaskInfo.getScriptName());
-
jsonObject.addProperty("CN.SuggestNSSIId", cnSliceTaskInfo.getSuggestNssiId());
jsonObject.addProperty("CN.SuggestNSSIName", cnSliceTaskInfo.getSuggestNssiName());
jsonObject.addProperty("CN.progress", cnSliceTaskInfo.getProgress());
@@ -206,7 +202,6 @@ public class SliceTaskParamsAdapter implements Serializable {
jsonObject.addProperty("CN.statusDescription", cnSliceTaskInfo.getStatusDescription());
jsonObject.addProperty("CN.ScriptName", cnSliceTaskInfo.getScriptName());
-
jsonObject.addProperty("AN.SuggestNSSIId", anSliceTaskInfo.getSuggestNssiId());
jsonObject.addProperty("AN.SuggestNSSIName", anSliceTaskInfo.getSuggestNssiName());
jsonObject.addProperty("AN.progress", anSliceTaskInfo.getProgress());
@@ -219,7 +214,7 @@ public class SliceTaskParamsAdapter implements Serializable {
/**
* change T t to {@link Map}
- *
+ *
* @param t input
* @param <T> Object
* @return {@link Map}
@@ -234,9 +229,18 @@ public class SliceTaskParamsAdapter implements Serializable {
Field[] fields = t.getClass().getDeclaredFields();
for (Field field : fields) {
String name = field.getName();
- Method method = t.getClass().getMethod("get" + name);
+ String key = name;
+ if (name == null || "".equals(name) || "serialVersionUID".equalsIgnoreCase(name)) {
+ continue;
+ }
+ JsonProperty annotation = field.getAnnotation(JsonProperty.class);
+ if (annotation != null && !annotation.value().equals(JsonProperty.USE_DEFAULT_NAME)) {
+ key = annotation.value();
+ }
+
+ Method method = t.getClass().getMethod("get" + name.substring(0, 1).toUpperCase() + name.substring(1));
Object value = method.invoke(t);
- resMap.put(name, value);
+ resMap.put(key, value);
}
} catch (Exception e) {
@@ -247,7 +251,7 @@ public class SliceTaskParamsAdapter implements Serializable {
/**
* replace of slice profile
- *
+ *
* @param paramMap params map
* @param header starts of key
* @return Map
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/TnSliceProfile.java b/common/src/main/java/org/onap/so/beans/nsmf/TnSliceProfile.java
index ccd6001957..f904e1c466 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/TnSliceProfile.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/TnSliceProfile.java
@@ -21,16 +21,31 @@
package org.onap.so.beans.nsmf;
import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
+import java.io.Serializable;
+import java.util.List;
@JsonInclude(JsonInclude.Include.NON_NULL)
@Data
-public class TnSliceProfile {
+public class TnSliceProfile implements Serializable {
+
+ private static final long serialVersionUID = 3767943556195823439L;
private String sliceProfileId;
- private String bandwidth;
+ @JsonProperty(value = "maxBandwidth")
+ private int maxBandwidth;
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
private int latency;
+
+ @JsonProperty(value = "snssaiList", required = true)
+ private List<String> sNSSAIList;
+
+ @JsonProperty(value = "plmnIdList", required = true)
+ private List<String> pLMNIdList;
+
+ @JsonProperty(value = "jitter")
+ private int jitter;
}
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/TransportSliceNetwork.java b/common/src/main/java/org/onap/so/beans/nsmf/TransportSliceNetwork.java
index aa2579edf8..c0dd4250b8 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/TransportSliceNetwork.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/TransportSliceNetwork.java
@@ -25,6 +25,7 @@ import java.util.List;
@Data
public class TransportSliceNetwork implements Serializable {
+
private static final long serialVersionUID = 809947462399806990L;
private List<ConnectionLink> connectionLinks;
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/VnfErrorList.java b/common/src/main/java/org/onap/so/beans/nsmf/VnfErrorList.java
index 6388ca6106..a3330e67b4 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/VnfErrorList.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/VnfErrorList.java
@@ -21,9 +21,12 @@
package org.onap.so.beans.nsmf;
import com.fasterxml.jackson.annotation.JsonInclude;
+import java.io.Serializable;
@JsonInclude(JsonInclude.Include.NON_NULL)
-public class VnfErrorList {
+public class VnfErrorList implements Serializable {
+
+ private static final long serialVersionUID = -2907819676875489281L;
private String vnfInstanceId;
diff --git a/common/src/main/java/org/onap/so/client/AddCacheHeaders.java b/common/src/main/java/org/onap/so/client/AddCacheHeaders.java
new file mode 100644
index 0000000000..1a41be1233
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/AddCacheHeaders.java
@@ -0,0 +1,28 @@
+package org.onap.so.client;
+
+import java.io.IOException;
+import java.util.Collections;
+import javax.annotation.Priority;
+import javax.ws.rs.client.ClientRequestContext;
+import javax.ws.rs.client.ClientResponseContext;
+import javax.ws.rs.client.ClientResponseFilter;
+import javax.ws.rs.ext.Provider;
+
+@Provider
+@Priority(1)
+public class AddCacheHeaders implements ClientResponseFilter {
+
+ private final CacheProperties props;
+
+ public AddCacheHeaders(CacheProperties props) {
+ this.props = props;
+ }
+
+ public void filter(ClientRequestContext request, ClientResponseContext response) throws IOException {
+ if (request.getMethod().equalsIgnoreCase("GET")) {
+ response.getHeaders().putIfAbsent("Cache-Control",
+ Collections.singletonList("public, max-age=" + (props.getMaxAge() / 1000)));
+ }
+
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/CacheFactory.java b/common/src/main/java/org/onap/so/client/CacheFactory.java
new file mode 100644
index 0000000000..6bc4858463
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/CacheFactory.java
@@ -0,0 +1,25 @@
+package org.onap.so.client;
+
+
+import java.util.concurrent.TimeUnit;
+import javax.cache.configuration.Factory;
+import javax.cache.expiry.Duration;
+import javax.cache.expiry.ExpiryPolicy;
+import javax.cache.expiry.TouchedExpiryPolicy;
+
+public class CacheFactory implements Factory<ExpiryPolicy> {
+
+ private static final long serialVersionUID = 8948728679233836929L;
+
+ private final CacheProperties props;
+
+ public CacheFactory(CacheProperties props) {
+ this.props = props;
+ }
+
+ @Override
+ public ExpiryPolicy create() {
+ return TouchedExpiryPolicy.factoryOf(new Duration(TimeUnit.MILLISECONDS, props.getMaxAge())).create();
+ }
+
+}
diff --git a/common/src/main/java/org/onap/so/client/CacheProperties.java b/common/src/main/java/org/onap/so/client/CacheProperties.java
new file mode 100644
index 0000000000..4fb2a87a5b
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/CacheProperties.java
@@ -0,0 +1,13 @@
+package org.onap.so.client;
+
+public interface CacheProperties {
+
+
+ default Long getMaxAge() {
+ return 60000L;
+ }
+
+ default String getCacheName() {
+ return "default-http-cache";
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/RestClient.java b/common/src/main/java/org/onap/so/client/RestClient.java
index ece1333f83..be0a0f3f9e 100644
--- a/common/src/main/java/org/onap/so/client/RestClient.java
+++ b/common/src/main/java/org/onap/so/client/RestClient.java
@@ -34,10 +34,12 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
+import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Invocation.Builder;
+import javax.ws.rs.client.ResponseProcessingException;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.MediaType;
@@ -186,8 +188,20 @@ public abstract class RestClient {
return APPLICATION_MERGE_PATCH_JSON;
}
+ protected ClientBuilder getClientBuilder() {
+ ClientBuilder builder = ClientBuilder.newBuilder();
+ if (props.isCachingEnabled()) {
+ enableCaching(builder);
+ }
+ return builder.readTimeout(props.getReadTimeout(), TimeUnit.MILLISECONDS);
+ }
+
+ protected ClientBuilder enableCaching(ClientBuilder builder) {
+ return builder;
+ }
+
protected Client getClient() {
- return ClientBuilder.newBuilder().build();
+ return getClientBuilder().build();
}
protected abstract ONAPComponentsList getTargetEntity();
@@ -201,7 +215,6 @@ public abstract class RestClient {
metricLogClientFilter = new SOMetricLogClientFilter();
mdcSetup.setTargetEntity(getTargetEntity());
client.register(metricLogClientFilter);
-
if (!path.isPresent()) {
webTarget = client.target(host.toString());
} else {
@@ -225,6 +238,9 @@ public abstract class RestClient {
result.add(e -> {
return e.getCause() instanceof ConnectException;
});
+ result.add(e -> {
+ return e.getCause() instanceof ResponseProcessingException;
+ });
return result;
}
diff --git a/common/src/main/java/org/onap/so/client/RestClientSSL.java b/common/src/main/java/org/onap/so/client/RestClientSSL.java
index 1e8953892e..c6252e4652 100644
--- a/common/src/main/java/org/onap/so/client/RestClientSSL.java
+++ b/common/src/main/java/org/onap/so/client/RestClientSSL.java
@@ -56,7 +56,7 @@ public abstract class RestClientSSL extends RestClient {
}
}
// Use default SSL context
- client = ClientBuilder.newBuilder().sslContext(SSLContext.getDefault()).build();
+ client = getClientBuilder().sslContext(SSLContext.getDefault()).build();
logger.info("RestClientSSL using default SSL context!");
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
diff --git a/common/src/main/java/org/onap/so/client/RestProperties.java b/common/src/main/java/org/onap/so/client/RestProperties.java
index 9e4e99cb4e..a7a0ef614c 100644
--- a/common/src/main/java/org/onap/so/client/RestProperties.java
+++ b/common/src/main/java/org/onap/so/client/RestProperties.java
@@ -40,4 +40,21 @@ public interface RestProperties {
public default boolean mapNotFoundToEmpty() {
return false;
}
+
+ /**
+ * Time in milliseconds
+ *
+ * @return
+ */
+ public default Long getReadTimeout() {
+ return Long.valueOf(60000);
+ }
+
+ public default boolean isCachingEnabled() {
+ return false;
+ }
+
+ public default CacheProperties getCacheProperties() {
+ return new CacheProperties() {};
+ }
}
diff --git a/common/src/test/java/org/onap/so/client/RestClientTest.java b/common/src/test/java/org/onap/so/client/RestClientTest.java
index cd00a9e4de..d40576b69f 100644
--- a/common/src/test/java/org/onap/so/client/RestClientTest.java
+++ b/common/src/test/java/org/onap/so/client/RestClientTest.java
@@ -21,6 +21,8 @@
package org.onap.so.client;
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.spy;
@@ -28,7 +30,13 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.net.MalformedURLException;
import java.net.SocketTimeoutException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Map;
+import java.util.Optional;
import javax.ws.rs.NotFoundException;
+import javax.ws.rs.ProcessingException;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriBuilderException;
@@ -37,21 +45,26 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.ArgumentMatchers;
-import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.logging.filter.base.ONAPComponents;
+import org.onap.logging.filter.base.ONAPComponentsList;
+import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
+import com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer;
+import com.github.tomakehurst.wiremock.junit.WireMockRule;
@RunWith(MockitoJUnitRunner.class)
public class RestClientTest {
private final HttpClientFactory httpClientFactory = new HttpClientFactory();
- @Mock
- private RestProperties props;
@Rule
public ExpectedException thrown = ExpectedException.none();
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(
+ WireMockConfiguration.options().dynamicPort().extensions(new ResponseTemplateTransformer(false)));
+
@Test
public void retries() throws Exception {
RestClient spy = buildSpy();
@@ -80,6 +93,50 @@ public class RestClientTest {
}
+ @Test
+ public void timeoutTest() throws URISyntaxException {
+ wireMockRule.stubFor(get("/chunked/delayed")
+ .willReturn(aResponse().withStatus(200).withBody("Hello world!").withChunkedDribbleDelay(2, 300)));
+
+
+ RestProperties props = new RestProperties() {
+
+ @Override
+ public URL getEndpoint() throws MalformedURLException {
+ return new URL(String.format("http://localhost:%s", wireMockRule.port()));
+ }
+
+ @Override
+ public String getSystemName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Long getReadTimeout() {
+ return Long.valueOf(100);
+ }
+ };
+ RestClient client = new RestClient(props, Optional.of(new URI("/chunked/delayed"))) {
+
+ @Override
+ protected void initializeHeaderMap(Map<String, String> headerMap) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected ONAPComponentsList getTargetEntity() {
+ return ONAPComponents.EXTERNAL;
+ }
+
+ };
+
+ thrown.expect(ProcessingException.class);
+ client.get();
+
+ }
+
private RestClient buildSpy() throws MalformedURLException, IllegalArgumentException, UriBuilderException {
RestClient client = httpClientFactory.newJsonClient(UriBuilder.fromUri("http://localhost/test").build().toURL(),
ONAPComponents.BPMN);
diff --git a/common/src/test/resources/logback-test.xml b/common/src/test/resources/logback-test.xml
index b52e6be022..3c5f259817 100644
--- a/common/src/test/resources/logback-test.xml
+++ b/common/src/test/resources/logback-test.xml
@@ -19,61 +19,60 @@
-->
<configuration>
- <property name="p_tim" value="%d{&quot;yyyy-MM-dd'T'HH:mm:ss.SSSXXX&quot;, UTC}"/>
- <property name="p_lvl" value="%level"/>
- <property name="p_log" value="%logger"/>
- <property name="p_mdc" value="%replace(%replace(%mdc){'\t','\\\\t'}){'\n', '\\\\n'}"/>
- <property name="p_msg" value="%replace(%replace(%msg){'\t', '\\\\t'}){'\n','\\\\n'}"/>
- <property name="p_exc" value="%replace(%replace(%rootException){'\t', '\\\\t'}){'\n','\\\\n'}"/>
- <property name="p_mak" value="%replace(%replace(%marker){'\t', '\\\\t'}){'\n','\\\\n'}"/>
- <property name="p_thr" value="%thread"/>
- <property name="pattern" value="%nopexception${p_tim}\t${p_thr}\t${p_lvl}\t${p_log}\t${p_mdc}\t${p_msg}\t${p_exc}\t${p_mak}\t%n"/>
+ <property name="p_tim" value="%d{&quot;yyyy-MM-dd'T'HH:mm:ss.SSSXXX&quot;, UTC}" />
+ <property name="p_lvl" value="%level" />
+ <property name="p_log" value="%logger" />
+ <property name="p_mdc" value="%replace(%replace(%mdc){'\t','\\\\t'}){'\n', '\\\\n'}" />
+ <property name="p_msg" value="%replace(%replace(%msg){'\t', '\\\\t'}){'\n','\\\\n'}" />
+ <property name="p_exc" value="%replace(%replace(%rootException){'\t', '\\\\t'}){'\n','\\\\n'}" />
+ <property name="p_mak" value="%replace(%replace(%marker){'\t', '\\\\t'}){'\n','\\\\n'}" />
+ <property name="p_thr" value="%thread" />
+ <property name="pattern"
+ value="%nopexception${p_tim}\t${p_thr}\t${p_lvl}\t${p_log}\t${p_mdc}\t${p_msg}\t${p_exc}\t${p_mak}\t%n" />
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>${pattern}</pattern>
- </encoder>
- </appender>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>${pattern}</pattern>
+ </encoder>
+ </appender>
- <appender name="test"
- class="org.onap.so.utils.TestAppender" />
+ <appender name="test" class="org.onap.so.utils.TestAppender" />
- <logger name="com.att.ecomp.audit" level="info" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
+ <logger name="com.att.ecomp.audit" level="info" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
- <logger name="com.att.eelf.metrics" level="info" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
+ <logger name="com.att.eelf.metrics" level="info" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
- <logger name="com.att.eelf.error" level="WARN" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
+ <logger name="com.att.eelf.error" level="WARN" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
- <logger name="org.onap" level="${so.log.level:-DEBUG}" additivity="false">
- <appender-ref ref="STDOUT" />
- <appender-ref ref="test" />
- </logger>
-
- <logger name="org.flywaydb" level="DEBUG" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
+ <logger name="org.onap" level="${so.log.level:-DEBUG}" additivity="false">
+ <appender-ref ref="STDOUT" />
+ <appender-ref ref="test" />
+ </logger>
- <logger name="ch.vorburger" level="WARN" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
- <logger name="org.reflections" level="ERROR" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
+ <logger name="org.flywaydb" level="DEBUG" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
- <root level="WARN">
- <appender-ref ref="STDOUT" />
- <appender-ref ref="test" />
- </root>
+
+ <logger name="ch.vorburger" level="WARN" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+
+ <logger name="org.reflections" level="ERROR" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+
+ <root level="WARN">
+ <appender-ref ref="STDOUT" />
+ <appender-ref ref="test" />
+ </root>
</configuration> \ No newline at end of file