diff options
Diffstat (limited to 'common')
106 files changed, 4376 insertions, 915 deletions
diff --git a/common/pom.xml b/common/pom.xml index 04deacf129..e36001833d 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>so</artifactId> - <version>1.4.0-SNAPSHOT</version> + <version>1.6.0-SNAPSHOT</version> </parent> <artifactId>common</artifactId> <name>MSO Common classes</name> @@ -16,7 +16,7 @@ <protobuf.version>3.6.1</protobuf.version> <grpc.netty.version>4.1.30.Final</grpc.netty.version> <ccsdk.version>0.4.2</ccsdk.version> - <appc.client.version>1.6.0-SNAPSHOT</appc.client.version> + <appc.client.version>1.7.1-SNAPSHOT</appc.client.version> </properties> <dependencies> @@ -59,7 +59,7 @@ <dependency> <groupId>org.onap.aai.schema-service</groupId> <artifactId>aai-schema</artifactId> - <version>1.6.3</version> + <version>1.6.4-SNAPSHOT</version> </dependency> <dependency> <groupId>org.modelmapper</groupId> diff --git a/common/src/main/java/org/onap/so/beans/nsmf/ActDeActNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/ActDeActNssi.java new file mode 100644 index 0000000000..8d45048ee4 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/ActDeActNssi.java @@ -0,0 +1,51 @@ +/*- + * ============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; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ActDeActNssi { + + public final static String ACT_URL = "/api/rest/provMns/v1/NSS/%s" + "/activation"; + + public final static String DE_ACT_URL = "/api/rest/provMns/v1/NSS/%s" + "/deactivation"; + + private String nsiId; + + private String nssiId; + + public String getNsiId() { + return nsiId; + } + + public void setNsiId(String nsiId) { + this.nsiId = nsiId; + } + + public String getNssiId() { + return nssiId; + } + + public void setNssiId(String nssiId) { + this.nssiId = nssiId; + } +} 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 new file mode 100644 index 0000000000..484f5b42b1 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java @@ -0,0 +1,109 @@ +/*- + * ============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; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class AllocateAnNssi { + + public final static String URL = "/api/rest/provMns/v1/an/NSS" + "/SliceProfiles"; + + private String nsstId; + + private String flavorId; + + private String nssiId; + + private String nssiName; + + private AnSliceProfile sliceProfile; + + private String scriptName; + + private Object extension; + + private NsiInfo nsiInfo; + + public String getNsstId() { + return nsstId; + } + + public void setNsstId(String nsstId) { + this.nsstId = nsstId; + } + + public String getFlavorId() { + return flavorId; + } + + public void setFlavorId(String flavorId) { + this.flavorId = flavorId; + } + + public String getNssiId() { + return nssiId; + } + + public void setNssiId(String nssiId) { + this.nssiId = nssiId; + } + + public String getNssiName() { + return nssiName; + } + + public void setNssiName(String nssiName) { + this.nssiName = nssiName; + } + + public AnSliceProfile getSliceProfile() { + return sliceProfile; + } + + public void setSliceProfile(AnSliceProfile sliceProfile) { + this.sliceProfile = sliceProfile; + } + + public String getScriptName() { + return scriptName; + } + + public void setScriptName(String scriptName) { + this.scriptName = scriptName; + } + + public Object getExtension() { + return extension; + } + + public void setExtension(Object extension) { + this.extension = extension; + } + + public NsiInfo getNsiInfo() { + return nsiInfo; + } + + public void setNsiInfo(NsiInfo nsiInfo) { + this.nsiInfo = nsiInfo; + } +} 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 new file mode 100644 index 0000000000..d03673368c --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/AllocateCnNssi.java @@ -0,0 +1,110 @@ +/*- + * ============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 AllocateCnNssi implements Serializable { + + public final static String URL = "/api/rest/provMns/v1/NSS/SliceProfiles"; + + private String nsstId; + + private String flavorId; + + private String nssiId; + + private String nssiName; + + private CnSliceProfile sliceProfile; + + private String scriptName; + + private Object extension; + + private NsiInfo nsiInfo; + + public NsiInfo getNsiInfo() { + return nsiInfo; + } + + public void setNsiInfo(NsiInfo nsiInfo) { + this.nsiInfo = nsiInfo; + } + + public String getNsstId() { + return nsstId; + } + + public void setNsstId(String nsstId) { + this.nsstId = nsstId; + } + + public String getScriptName() { + return scriptName; + } + + public void setScriptName(String scriptName) { + this.scriptName = scriptName; + } + + public CnSliceProfile getSliceProfile() { + return sliceProfile; + } + + public void setSliceProfile(CnSliceProfile sliceProfile) { + this.sliceProfile = sliceProfile; + } + + public String getFlavorId() { + return flavorId; + } + + public void setFlavorId(String flavorId) { + this.flavorId = flavorId; + } + + public String getNssiId() { + return nssiId; + } + + public void setNssiId(String nssiId) { + this.nssiId = nssiId; + } + + public String getNssiName() { + return nssiName; + } + + public void setNssiName(String nssiName) { + this.nssiName = nssiName; + } + + public void setExtension(Object extension) { + this.extension = extension; + } + + public Object getExtension() { + return extension; + } +} 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 new file mode 100644 index 0000000000..b66fb133d2 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/AllocateTnNssi.java @@ -0,0 +1,109 @@ +/*- + * ============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; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class AllocateTnNssi { + + public final static String URL = "/api/rest/provMns/v1/tn/NSS" + "/SliceProfiles"; + + private String nsstId; + + private String flavorId; + + private String nssiId; + + private String nssiName; + + private TnSliceProfile sliceProfile; + + private String scriptName; + + private Object extension; + + private NsiInfo nsiInfo; + + public String getNsstId() { + return nsstId; + } + + public void setNsstId(String nsstId) { + this.nsstId = nsstId; + } + + public String getFlavorId() { + return flavorId; + } + + public void setFlavorId(String flavorId) { + this.flavorId = flavorId; + } + + public String getNssiId() { + return nssiId; + } + + public void setNssiId(String nssiId) { + this.nssiId = nssiId; + } + + public String getNssiName() { + return nssiName; + } + + public void setNssiName(String nssiName) { + this.nssiName = nssiName; + } + + public TnSliceProfile getSliceProfile() { + return sliceProfile; + } + + public void setSliceProfile(TnSliceProfile sliceProfile) { + this.sliceProfile = sliceProfile; + } + + public String getScriptName() { + return scriptName; + } + + public void setScriptName(String scriptName) { + this.scriptName = scriptName; + } + + public Object getExtension() { + return extension; + } + + public void setExtension(Object extension) { + this.extension = extension; + } + + public NsiInfo getNsiInfo() { + return nsiInfo; + } + + public void setNsiInfo(NsiInfo nsiInfo) { + this.nsiInfo = nsiInfo; + } +} 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 new file mode 100644 index 0000000000..3d60949385 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java @@ -0,0 +1,61 @@ +/*- + * ============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 com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class AnSliceProfile { + + @JsonProperty("5QI") + private String qi; + + private List<String> coverageAreaTAList; + + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + private int latency; + + public String getQi() { + return qi; + } + + public void setQi(String qi) { + this.qi = qi; + } + + 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; + } +} 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 new file mode 100644 index 0000000000..3bd155d512 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/CnSliceProfile.java @@ -0,0 +1,120 @@ +/*- + * ============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.util.List; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CnSliceProfile { + + private List<String> snssaiList; + + private String sliceProfileId; + + private List<String> plmnIdList; + + private PerfReq perfReq; + + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + private int maxNumberofUEs; + + private List<String> coverageAreaTAList; + + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + private int latency; + + private UeMobilityLevel ueMobilityLevel; + + 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; + } + + public void setSnssaiList(List<String> snssaiList) { + this.snssaiList = snssaiList; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/CreateCnNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/CreateCnNssi.java new file mode 100644 index 0000000000..424966948e --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/CreateCnNssi.java @@ -0,0 +1,89 @@ +/*- + * ============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; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateCnNssi { + + public final static String URL = "/api/rest/provMns/v1/NSS/nssi"; + + private String nsstId; + + private String flavorId; + + private String nssiName; + + private String scriptName; + + private String extension; + + private NsiInfo nsiInfo; + + public String getNsstId() { + return nsstId; + } + + public void setNsstId(String nsstId) { + this.nsstId = nsstId; + } + + public String getFlavorId() { + return flavorId; + } + + public void setFlavorId(String flavorId) { + this.flavorId = flavorId; + } + + public String getNssiName() { + return nssiName; + } + + public void setNssiName(String nssiName) { + this.nssiName = nssiName; + } + + public String getScriptName() { + return scriptName; + } + + public void setScriptName(String scriptName) { + this.scriptName = scriptName; + } + + public String getExtension() { + return extension; + } + + public void setExtension(String extension) { + this.extension = extension; + } + + public NsiInfo getNsiInfo() { + return nsiInfo; + } + + public void setNsiInfo(NsiInfo nsiInfo) { + this.nsiInfo = nsiInfo; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/DeAllocateNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/DeAllocateNssi.java new file mode 100644 index 0000000000..648fd4985f --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/DeAllocateNssi.java @@ -0,0 +1,91 @@ +/*- + * ============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.util.List; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class DeAllocateNssi { + + public final static String URL = "/api/rest/provMns/v1/NSS" + "/SliceProfiles/%s"; + + private String nsiId; + + private String nssiId; + + private List<String> snssaiList; + + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + private int terminateNssiOption; + + private String scriptName; + + private String extension; + + public String getNsiId() { + return nsiId; + } + + public void setNsiId(String nsiId) { + this.nsiId = nsiId; + } + + public String getNssiId() { + return nssiId; + } + + public void setNssiId(String nssiId) { + this.nssiId = nssiId; + } + + public List<String> getSnssaiList() { + return snssaiList; + } + + public void setSnssaiList(List<String> snssaiList) { + this.snssaiList = snssaiList; + } + + public int getTerminateNssiOption() { + return terminateNssiOption; + } + + public void setTerminateNssiOption(int terminateNssiOption) { + this.terminateNssiOption = terminateNssiOption; + } + + public String getScriptName() { + return scriptName; + } + + public void setScriptName(String scriptName) { + this.scriptName = scriptName; + } + + public String getExtension() { + return extension; + } + + public void setExtension(String extension) { + this.extension = extension; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/EsrInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/EsrInfo.java new file mode 100644 index 0000000000..d720399293 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/EsrInfo.java @@ -0,0 +1,48 @@ +/*- + * ============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 EsrInfo implements Serializable { + + private String vendor; + + private NetworkType networkType; + + public String getVendor() { + return vendor; + } + + public void setVendor(String vendor) { + this.vendor = vendor; + } + + public NetworkType getNetworkType() { + return networkType; + } + + public void setNetworkType(NetworkType networkType) { + this.networkType = networkType; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/JobStatusRequest.java b/common/src/main/java/org/onap/so/beans/nsmf/JobStatusRequest.java new file mode 100644 index 0000000000..cc8503c250 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/JobStatusRequest.java @@ -0,0 +1,70 @@ +/*- + * ============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; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class JobStatusRequest { + + public final static String URL = "/api/rest/provMns/v1/NSS/jobs/%s"; + + private String nsiId; + + private String nssiId; + + private String responseId; + + private EsrInfo esrInfo; + + public String getNsiId() { + return nsiId; + } + + public void setNsiId(String nsiId) { + this.nsiId = nsiId; + } + + public String getNssiId() { + return nssiId; + } + + public void setNssiId(String nssiId) { + this.nssiId = nssiId; + } + + + public String getResponseId() { + return responseId; + } + + public void setResponseId(String responseId) { + this.responseId = responseId; + } + + public EsrInfo getEsrInfo() { + return esrInfo; + } + + public void setEsrInfo(EsrInfo esrInfo) { + this.esrInfo = esrInfo; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/JobStatusResponse.java b/common/src/main/java/org/onap/so/beans/nsmf/JobStatusResponse.java new file mode 100644 index 0000000000..9259d51591 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/JobStatusResponse.java @@ -0,0 +1,37 @@ +/*- + * ============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; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class JobStatusResponse { + + private ResponseDescriptor responseDescriptor; + + public ResponseDescriptor getResponseDescriptor() { + return responseDescriptor; + } + + public void setResponseDescriptor(ResponseDescriptor responseDescriptor) { + this.responseDescriptor = responseDescriptor; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NSSI.java b/common/src/main/java/org/onap/so/beans/nsmf/NSSI.java new file mode 100644 index 0000000000..a57458f2cf --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/NSSI.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # 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; + +public class NSSI { + + private String nssiId; + + private String modelInvariantId; + + private String modelVersionId; + + public NSSI(String nssiId, String modelInvariantId, String modelVersionId) { + this.nssiId = nssiId; + this.modelInvariantId = modelInvariantId; + this.modelVersionId = modelVersionId; + } + + public String getNssiId() { + return nssiId; + } + + public void setNssiId(String nssiId) { + this.nssiId = nssiId; + } + + public String getModelInvariantId() { + return modelInvariantId; + } + + public void setModelInvariantId(String modelInvariantId) { + this.modelInvariantId = modelInvariantId; + } + + public String getModelVersionId() { + return modelVersionId; + } + + public void setModelVersionId(String modelVersionId) { + this.modelVersionId = modelVersionId; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NetworkType.java b/common/src/main/java/org/onap/so/beans/nsmf/NetworkType.java new file mode 100644 index 0000000000..2e10fe5746 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/NetworkType.java @@ -0,0 +1,58 @@ +/*- + * ============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.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public enum NetworkType { + + ACCESS("an"), + + CORE("cn"), + + TRANSPORT("tn"); + + private String networkType; + + NetworkType(String networkType) { + this.networkType = networkType; + } + + @JsonValue + public String getNetworkType() { + return networkType; + } + + @JsonCreator + public NetworkType forValue(String value) { + return valueOf(value); + } + + public static NetworkType fromString(String value) { + for (NetworkType nType : NetworkType.values()) { + if (nType.networkType.equalsIgnoreCase(value)) { + return nType; + } + } + return null; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NewNsst.java b/common/src/main/java/org/onap/so/beans/nsmf/NewNsst.java new file mode 100644 index 0000000000..68aebf2df2 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/NewNsst.java @@ -0,0 +1,47 @@ +/*- + * ============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; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class NewNsst { + + private String nsstId; + + private String flavorId; + + public String getNsstId() { + return nsstId; + } + + public void setNsstId(String nsstId) { + this.nsstId = nsstId; + } + + public String getFlavorId() { + return flavorId; + } + + public void setFlavorId(String flavorId) { + this.flavorId = flavorId; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NsiInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/NsiInfo.java new file mode 100644 index 0000000000..0ff554d10d --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/NsiInfo.java @@ -0,0 +1,47 @@ +/*- + * ============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; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class NsiInfo { + + private String nsiName; + + private String nsiId; + + public String getNsiName() { + return nsiName; + } + + public void setNsiName(String nsiName) { + this.nsiName = nsiName; + } + + public void setNsiId(String nsiId) { + this.nsiId = nsiId; + } + + public String getNsiId() { + return nsiId; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NssiActDeActRequest.java b/common/src/main/java/org/onap/so/beans/nsmf/NssiActDeActRequest.java new file mode 100644 index 0000000000..fbba8c77b1 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/NssiActDeActRequest.java @@ -0,0 +1,47 @@ +/*- + * ============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; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class NssiActDeActRequest { + + private EsrInfo esrInfo; + + private ActDeActNssi actDeActNssi; + + public ActDeActNssi getActDeActNssi() { + return actDeActNssi; + } + + public void setActDeActNssi(ActDeActNssi actDeActNssi) { + this.actDeActNssi = actDeActNssi; + } + + public EsrInfo getEsrInfo() { + return esrInfo; + } + + public void setEsrInfo(EsrInfo esrInfo) { + this.esrInfo = esrInfo; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NssiAllocateRequest.java b/common/src/main/java/org/onap/so/beans/nsmf/NssiAllocateRequest.java new file mode 100644 index 0000000000..f72a74a063 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/NssiAllocateRequest.java @@ -0,0 +1,67 @@ +/*- + * ============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; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class NssiAllocateRequest { + + private EsrInfo esrInfo; + + private AllocateCnNssi allocateCnNssi; + + private AllocateTnNssi allocateTnNssi; + + private AllocateAnNssi allocateAnNssi; + + public EsrInfo getEsrInfo() { + return esrInfo; + } + + public void setEsrInfo(EsrInfo esrInfo) { + this.esrInfo = esrInfo; + } + + public AllocateCnNssi getAllocateCnNssi() { + return allocateCnNssi; + } + + public void setAllocateCnNssi(AllocateCnNssi allocateCnNssi) { + this.allocateCnNssi = allocateCnNssi; + } + + public AllocateTnNssi getAllocateTnNssi() { + return allocateTnNssi; + } + + public void setAllocateTnNssi(AllocateTnNssi allocateTnNssi) { + this.allocateTnNssi = allocateTnNssi; + } + + public AllocateAnNssi getAllocateAnNssi() { + return allocateAnNssi; + } + + public void setAllocateAnNssi(AllocateAnNssi allocateAnNssi) { + this.allocateAnNssi = allocateAnNssi; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NssiCreateRequest.java b/common/src/main/java/org/onap/so/beans/nsmf/NssiCreateRequest.java new file mode 100644 index 0000000000..ca26e9f0cb --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/NssiCreateRequest.java @@ -0,0 +1,47 @@ +/*- + * ============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; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class NssiCreateRequest { + + private EsrInfo esrInfo; + + private CreateCnNssi createCnNssi; + + public EsrInfo getEsrInfo() { + return esrInfo; + } + + public void setEsrInfo(EsrInfo esrInfo) { + this.esrInfo = esrInfo; + } + + public CreateCnNssi getCreateCnNssi() { + return createCnNssi; + } + + public void setCreateCnNssi(CreateCnNssi createCnNssi) { + this.createCnNssi = createCnNssi; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NssiDeAllocateRequest.java b/common/src/main/java/org/onap/so/beans/nsmf/NssiDeAllocateRequest.java new file mode 100644 index 0000000000..bbfc30c37a --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/NssiDeAllocateRequest.java @@ -0,0 +1,47 @@ +/*- + * ============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; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class NssiDeAllocateRequest { + + private DeAllocateNssi deAllocateNssi; + + private EsrInfo esrInfo; + + public DeAllocateNssi getDeAllocateNssi() { + return deAllocateNssi; + } + + public void setDeAllocateNssi(DeAllocateNssi deAllocateNssi) { + this.deAllocateNssi = deAllocateNssi; + } + + public EsrInfo getEsrInfo() { + return esrInfo; + } + + public void setEsrInfo(EsrInfo esrInfo) { + this.esrInfo = esrInfo; + } +} 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 new file mode 100644 index 0000000000..66368be6b8 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/NssiResponse.java @@ -0,0 +1,47 @@ +/*- + * ============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; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class NssiResponse { + + private String nssiId; + + 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; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NssiTerminateRequest.java b/common/src/main/java/org/onap/so/beans/nsmf/NssiTerminateRequest.java new file mode 100644 index 0000000000..df0a463584 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/NssiTerminateRequest.java @@ -0,0 +1,47 @@ +/*- + * ============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; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class NssiTerminateRequest { + + private TerminateNssi terminateNssi; + + private EsrInfo esrInfo; + + public TerminateNssi getTerminateNssi() { + return terminateNssi; + } + + public void setTerminateNssi(TerminateNssi terminateNssi) { + this.terminateNssi = terminateNssi; + } + + public EsrInfo getEsrInfo() { + return esrInfo; + } + + public void setEsrInfo(EsrInfo esrInfo) { + this.esrInfo = esrInfo; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NssiUpdateRequest.java b/common/src/main/java/org/onap/so/beans/nsmf/NssiUpdateRequest.java new file mode 100644 index 0000000000..6642734b7f --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/NssiUpdateRequest.java @@ -0,0 +1,47 @@ +/*- + * ============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; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class NssiUpdateRequest { + + private UpdateCnNssi updateCnNssi; + + private EsrInfo esrInfo; + + public EsrInfo getEsrInfo() { + return esrInfo; + } + + public void setEsrInfo(EsrInfo esrInfo) { + this.esrInfo = esrInfo; + } + + public UpdateCnNssi getUpdateCnNssi() { + return updateCnNssi; + } + + public void setUpdateCnNssi(UpdateCnNssi updateCnNssi) { + this.updateCnNssi = updateCnNssi; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NssiUpdateRequestById.java b/common/src/main/java/org/onap/so/beans/nsmf/NssiUpdateRequestById.java new file mode 100644 index 0000000000..0554d2fcfd --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/NssiUpdateRequestById.java @@ -0,0 +1,47 @@ +/*- + * ============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; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class NssiUpdateRequestById { + + private UpdateCnNssiById updateCnNssiById; + + private EsrInfo esrInfo; + + public EsrInfo getEsrInfo() { + return esrInfo; + } + + public void setEsrInfo(EsrInfo esrInfo) { + this.esrInfo = esrInfo; + } + + public UpdateCnNssiById getUpdateCnNssiById() { + return updateCnNssiById; + } + + public void setUpdateCnNssiById(UpdateCnNssiById updateCnNssiById) { + this.updateCnNssiById = updateCnNssiById; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NssmiReqInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/NssmiReqInfo.java new file mode 100644 index 0000000000..093825f0ff --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/NssmiReqInfo.java @@ -0,0 +1,57 @@ +/*- + * ============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; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class NssmiReqInfo { + + private String nsiId; + + private String nssiId; + + private EsrInfo esrInfo; + + public String getNsiId() { + return nsiId; + } + + public void setNsiId(String nsiId) { + this.nsiId = nsiId; + } + + public String getNssiId() { + return nssiId; + } + + public void setNssiId(String nssiId) { + this.nssiId = nssiId; + } + + public EsrInfo getEsrInfo() { + return esrInfo; + } + + public void setEsrInfo(EsrInfo esrInfo) { + this.esrInfo = esrInfo; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NssmiResInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/NssmiResInfo.java new file mode 100644 index 0000000000..e75934a7a9 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/NssmiResInfo.java @@ -0,0 +1,47 @@ +/*- + * ============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; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class NssmiResInfo { + + private String jobId; + + private String status; + + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + this.jobId = jobId; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = 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 new file mode 100644 index 0000000000..4aabc3f26f --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/PerfReq.java @@ -0,0 +1,48 @@ +/*- + * ============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.util.List; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class PerfReq { + + private List<PerfReqEmbbList> perfReqEmbbList; + + private List<PerfReqUrllcList> perfReqUrllcList; + + public List<PerfReqEmbbList> getPerfReqEmbbList() { + return perfReqEmbbList; + } + + public void setPerfReqEmbbList(List<PerfReqEmbbList> perfReqEmbbList) { + this.perfReqEmbbList = perfReqEmbbList; + } + + public List<PerfReqUrllcList> getPerfReqUrllcList() { + return perfReqUrllcList; + } + + public void setPerfReqUrllcList(List<PerfReqUrllcList> perfReqUrllcList) { + this.perfReqUrllcList = perfReqUrllcList; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/PerfReqEmbbList.java b/common/src/main/java/org/onap/so/beans/nsmf/PerfReqEmbbList.java new file mode 100644 index 0000000000..9e9fcaa19e --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/PerfReqEmbbList.java @@ -0,0 +1,82 @@ +/*- + * ============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; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class PerfReqEmbbList { + + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + private int expDataRateDL; + + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + private int expDataRateUL; + + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + private int areaTrafficCapDL; + + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + private int areaTrafficCapUL; + + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + private int activityFactor; + + public int getExpDataRateDL() { + return expDataRateDL; + } + + public void setExpDataRateDL(int expDataRateDL) { + this.expDataRateDL = expDataRateDL; + } + + public int getExpDataRateUL() { + return expDataRateUL; + } + + public void setExpDataRateUL(int expDataRateUL) { + this.expDataRateUL = expDataRateUL; + } + + public int getAreaTrafficCapDL() { + return areaTrafficCapDL; + } + + public void setAreaTrafficCapDL(int areaTrafficCapDL) { + this.areaTrafficCapDL = areaTrafficCapDL; + } + + public int getAreaTrafficCapUL() { + return areaTrafficCapUL; + } + + public void setAreaTrafficCapUL(int areaTrafficCapUL) { + this.areaTrafficCapUL = areaTrafficCapUL; + } + + public int getActivityFactor() { + return activityFactor; + } + + public void setActivityFactor(int activityFactor) { + this.activityFactor = activityFactor; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/PerfReqUrllcList.java b/common/src/main/java/org/onap/so/beans/nsmf/PerfReqUrllcList.java new file mode 100644 index 0000000000..00f0a917aa --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/PerfReqUrllcList.java @@ -0,0 +1,135 @@ +/*- + * ============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; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class PerfReqUrllcList { + + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + private int e2eLatency; + + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + private int jitter; + + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + private int survivalTime; + + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + private float csAvailability; + + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + private float reliability; + + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + private int expDataRate; + + private String payloadSize; + + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + private int trafficDensity; + + @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; + } + + 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 new file mode 100644 index 0000000000..66bfbdcea9 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/PnfErrorList.java @@ -0,0 +1,47 @@ +/*- + * ============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; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class PnfErrorList { + + private String pnfId; + + private String pnfErrorDesc; + + public String getPnfId() { + return pnfId; + } + + public void setPnfId(String pnfId) { + this.pnfId = pnfId; + } + + public String getPnfErrorDesc() { + return pnfErrorDesc; + } + + public void setPnfErrorDesc(String pnfErrorDesc) { + this.pnfErrorDesc = pnfErrorDesc; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/ResourceSharingLevel.java b/common/src/main/java/org/onap/so/beans/nsmf/ResourceSharingLevel.java new file mode 100644 index 0000000000..405429c34d --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/ResourceSharingLevel.java @@ -0,0 +1,56 @@ +/*- + * ============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.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public enum ResourceSharingLevel { + + SHARED("shared"), + + NON_SHARED("non-shared"); + + private String resourceSharingLevel; + + ResourceSharingLevel(String resourceSharingLevel) { + this.resourceSharingLevel = resourceSharingLevel; + } + + @JsonValue + public String getResourceSharingLevel() { + return resourceSharingLevel; + } + + @JsonCreator + public ResourceSharingLevel forValue(String value) { + return valueOf(value); + } + + public static ResourceSharingLevel fromString(String value) { + for (ResourceSharingLevel rscLvl : ResourceSharingLevel.values()) { + if (rscLvl.resourceSharingLevel.equalsIgnoreCase(value)) { + return rscLvl; + } + } + return null; + } +} 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 new file mode 100644 index 0000000000..469d212ef9 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/ResponseDescriptor.java @@ -0,0 +1,85 @@ +/*- + * ============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.util.List; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ResponseDescriptor { + + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + private int progress; + + private String status; + + private String statusDescription; + + private String errorCode; + + private List<VnfErrorList> vnfErrorList; + + private List<PnfErrorList> pnfErrorList; + + private String responseId; + + private List<ResponseHistory> responseHistoryList; + + public int getProgress() { + return progress; + } + + public void setProgress(int progress) { + this.progress = progress; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getStatusDescription() { + return statusDescription; + } + + public void setStatusDescription(String statusDescription) { + this.statusDescription = statusDescription; + } + + public String getResponseId() { + return responseId; + } + + public void setResponseId(String responseId) { + this.responseId = responseId; + } + + public List<ResponseHistory> getResponseHistoryList() { + return responseHistoryList; + } + + public void setResponseHistoryList(List<ResponseHistory> responseHistoryList) { + this.responseHistoryList = responseHistoryList; + } +} 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 new file mode 100644 index 0000000000..c71441a80a --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/ResponseHistory.java @@ -0,0 +1,94 @@ +/*- + * ============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.util.List; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ResponseHistory { + + private int progress; + + private String status; + + private String errorCode; + + private String statusDescription; + + private String responseId; + + private List<VnfErrorList> vnfErrorList; + + private List<PnfErrorList> pnfErrorList; + + public int getProgress() { + return progress; + } + + public void setProgress(int progress) { + this.progress = progress; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getStatusDescription() { + return statusDescription; + } + + public void setStatusDescription(String statusDescription) { + this.statusDescription = statusDescription; + } + + public String getResponseId() { + return responseId; + } + + public void setResponseId(String responseId) { + this.responseId = responseId; + } + + public String getErrorCode() { + return errorCode; + } + + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + } + + public List<VnfErrorList> getVnfErrorList() { + return vnfErrorList; + } + + public List<PnfErrorList> getPnfErrorList() { + return pnfErrorList; + } + + public void setPnfErrorList(List<PnfErrorList> pnfErrorList) { + this.pnfErrorList = pnfErrorList; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/ServiceProfile.java b/common/src/main/java/org/onap/so/beans/nsmf/ServiceProfile.java new file mode 100644 index 0000000000..cc6c9bbb82 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/ServiceProfile.java @@ -0,0 +1,50 @@ +/*- + * ============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 java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"service-profile"}) +public class ServiceProfile implements Serializable { + + @JsonProperty("service-profile") + private Map<String, Object> serviceProfile; + + @JsonProperty("service-profile") + public Map<String, Object> getServiceProfile() { + return serviceProfile; + } + + @JsonProperty("service-profile") + public void setServiceProfile(Map<String, Object> serviceProfile) { + this.serviceProfile = serviceProfile; + } +} + diff --git a/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParams.java b/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParams.java new file mode 100644 index 0000000000..bf881c0f19 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParams.java @@ -0,0 +1,413 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 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.databind.ObjectMapper; +import com.google.gson.JsonObject; +import java.io.IOException; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +public class SliceTaskParams implements Serializable { + + private static final long serialVersionUID = -4389946152970978423L; + + private String serviceId; + + private String serviceName; + + private String nstId; + + private String nstName; + + private String tnScriptName; + + private String anScriptName; + + private String cnScriptName; + + private Map<String, Object> serviceProfile; + + private String suggestNsiId; + + private String suggestNsiName; + + private Map<String, Object> sliceProfileTn; + + private Map<String, Object> sliceProfileCn; + + private Map<String, Object> sliceProfileAn; + + private String tnSuggestNssiId; + + private String tnSuggestNssiName; + + private String tnProgress; + + private String tnStatus; + + private String tnStatusDescription; + + private String cnSuggestNssiId; + + private String cnSuggestNssiName; + + private String cnProgress; + + private String cnStatus; + + private String cnStatusDescription; + + private String anSuggestNssiId; + + private String anSuggestNssiName; + + private String anProgress; + + private String anStatus; + + private String anStatusDescription; + + public String getNstId() { + return nstId; + } + + public void setNstId(String nstId) { + this.nstId = nstId; + } + + public String getNstName() { + return nstName; + } + + public void setNstName(String nstName) { + this.nstName = nstName; + } + + public String getTnScriptName() { + return tnScriptName; + } + + public void setTnScriptName(String tnScriptName) { + this.tnScriptName = tnScriptName; + } + + public String getAnScriptName() { + return anScriptName; + } + + public void setAnScriptName(String anScriptName) { + this.anScriptName = anScriptName; + } + + public String getCnScriptName() { + return cnScriptName; + } + + public void setCnScriptName(String cnScriptName) { + this.cnScriptName = cnScriptName; + } + + public String getServiceId() { + return serviceId; + } + + public void setServiceId(String serviceId) { + this.serviceId = serviceId; + } + + public String getServiceName() { + return serviceName; + } + + public void setServiceName(String serviceName) { + this.serviceName = serviceName; + } + + public Map<String, Object> getServiceProfile() { + return serviceProfile; + } + + public void setServiceProfile(Map<String, Object> serviceProfile) { + this.serviceProfile = serviceProfile; + } + + public String getSuggestNsiId() { + return suggestNsiId; + } + + public void setSuggestNsiId(String suggestNsiId) { + this.suggestNsiId = suggestNsiId; + } + + public String getSuggestNsiName() { + return suggestNsiName; + } + + public void setSuggestNsiName(String suggestNsiName) { + this.suggestNsiName = suggestNsiName; + } + + public Map<String, Object> getSliceProfileTn() { + return sliceProfileTn; + } + + public void setSliceProfileTn(Map<String, Object> sliceProfileTn) { + this.sliceProfileTn = sliceProfileTn; + } + + public Map<String, Object> getSliceProfileCn() { + return sliceProfileCn; + } + + public void setSliceProfileCn(Map<String, Object> sliceProfileCn) { + this.sliceProfileCn = sliceProfileCn; + } + + public Map<String, Object> getSliceProfileAn() { + return sliceProfileAn; + } + + public void setSliceProfileAn(Map<String, Object> sliceProfileAn) { + this.sliceProfileAn = sliceProfileAn; + } + + public String getTnSuggestNssiId() { + return tnSuggestNssiId; + } + + public void setTnSuggestNssiId(String tnSuggestNssiId) { + this.tnSuggestNssiId = tnSuggestNssiId; + } + + public String getTnSuggestNssiName() { + return tnSuggestNssiName; + } + + public void setTnSuggestNssiName(String tnSuggestNssiName) { + this.tnSuggestNssiName = tnSuggestNssiName; + } + + public String getTnProgress() { + return tnProgress; + } + + public void setTnProgress(String tnProgress) { + this.tnProgress = tnProgress; + } + + public String getTnStatus() { + return tnStatus; + } + + public void setTnStatus(String tnStatus) { + this.tnStatus = tnStatus; + } + + public String getTnStatusDescription() { + return tnStatusDescription; + } + + public void setTnStatusDescription(String tnStatusDescription) { + this.tnStatusDescription = tnStatusDescription; + } + + public String getCnSuggestNssiId() { + return cnSuggestNssiId; + } + + public void setCnSuggestNssiId(String cnSuggestNssiId) { + this.cnSuggestNssiId = cnSuggestNssiId; + } + + public String getCnSuggestNssiName() { + return cnSuggestNssiName; + } + + public void setCnSuggestNssiName(String cnSuggestNssiName) { + this.cnSuggestNssiName = cnSuggestNssiName; + } + + public String getCnProgress() { + return cnProgress; + } + + public void setCnProgress(String cnProgress) { + this.cnProgress = cnProgress; + } + + public String getCnStatus() { + return cnStatus; + } + + public void setCnStatus(String cnStatus) { + this.cnStatus = cnStatus; + } + + public String getCnStatusDescription() { + return cnStatusDescription; + } + + public void setCnStatusDescription(String cnStatusDescription) { + this.cnStatusDescription = cnStatusDescription; + } + + public String getAnSuggestNssiId() { + return anSuggestNssiId; + } + + public void setAnSuggestNssiId(String anSuggestNssiId) { + this.anSuggestNssiId = anSuggestNssiId; + } + + public String getAnSuggestNssiName() { + return anSuggestNssiName; + } + + public void setAnSuggestNssiName(String anSuggestNssiName) { + this.anSuggestNssiName = anSuggestNssiName; + } + + public String getAnProgress() { + return anProgress; + } + + public void setAnProgress(String anProgress) { + this.anProgress = anProgress; + } + + public String getAnStatus() { + return anStatus; + } + + public void setAnStatus(String anStatus) { + this.anStatus = anStatus; + } + + public String getAnStatusDescription() { + return anStatusDescription; + } + + public void setAnStatusDescription(String anStatusDescription) { + this.anStatusDescription = anStatusDescription; + } + + public String convertToJson() { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("ServiceId", serviceId); + jsonObject.addProperty("ServiceName", serviceName); + jsonObject.addProperty("NSTId", nstId); + jsonObject.addProperty("NSTName", nstName); + jsonObject.addProperty("TN.ScriptName", tnScriptName); + jsonObject.addProperty("AN.ScriptName", anScriptName); + jsonObject.addProperty("CN.ScriptName", cnScriptName); + for (Map.Entry<String, Object> entry : serviceProfile.entrySet()) { + jsonObject.addProperty("ServiceProfile." + entry.getKey(), entry.getValue().toString()); + } + jsonObject.addProperty("suggestNSIId", suggestNsiId); + jsonObject.addProperty("suggestNSIName", suggestNsiName); + for (Map.Entry<String, Object> entry : sliceProfileTn.entrySet()) { + jsonObject.addProperty("SliceProfile.TN." + entry.getKey(), entry.getValue().toString()); + } + for (Map.Entry<String, Object> entry : sliceProfileCn.entrySet()) { + jsonObject.addProperty("SliceProfile.CN." + entry.getKey(), entry.getValue().toString()); + } + for (Map.Entry<String, Object> entry : sliceProfileAn.entrySet()) { + jsonObject.addProperty("SliceProfile.AN." + entry.getKey(), entry.getValue().toString()); + } + jsonObject.addProperty("TN.SuggestNSSIId", tnSuggestNssiId); + jsonObject.addProperty("TN.SuggestNSSIName", tnSuggestNssiName); + jsonObject.addProperty("TN.progress", tnProgress); + jsonObject.addProperty("TN.status", tnStatus); + jsonObject.addProperty("TN.statusDescription", tnStatusDescription); + jsonObject.addProperty("CN.SuggestNSSIId", cnSuggestNssiId); + jsonObject.addProperty("CN.SuggestNSSIName", cnSuggestNssiName); + jsonObject.addProperty("CN.progress", cnProgress); + jsonObject.addProperty("CN.status", cnStatus); + jsonObject.addProperty("CN.statusDescription", cnStatusDescription); + jsonObject.addProperty("AN.SuggestNSSIId", anSuggestNssiId); + jsonObject.addProperty("AN.SuggestNSSIName", anSuggestNssiName); + jsonObject.addProperty("AN.progress", anProgress); + jsonObject.addProperty("AN.status", anStatus); + jsonObject.addProperty("AN.statusDescription", anStatusDescription); + + return jsonObject.toString(); + } + + public void convertFromJson(String jsonString) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + Map<String, String> paramMap = (Map<String, String>) mapper.readValue(jsonString, Map.class); + this.setServiceId(paramMap.get("ServiceId")); + this.setServiceName(paramMap.get("ServiceName")); + this.setNstId(paramMap.get("NSTId")); + this.setNstName(paramMap.get("NSTName")); + this.setTnScriptName(paramMap.get("TN.ScriptName")); + this.setAnScriptName(paramMap.get("AN.ScriptName")); + this.setCnScriptName(paramMap.get("CN.ScriptName")); + Map<String, Object> serviceProfileMap = new HashMap<>(); + for (Map.Entry<String, String> entry : paramMap.entrySet()) { + if (entry.getKey().startsWith("ServiceProfile.")) { + serviceProfileMap.put(entry.getKey().replaceFirst("^ServiceProfile.", ""), entry.getValue()); + } + } + this.setServiceProfile(serviceProfileMap); + this.setSuggestNsiId(paramMap.get("suggestNSIId")); + this.setSuggestNsiName(paramMap.get("suggestNSIName")); + Map<String, Object> sliceProfileTnMap = new HashMap<>(); + for (Map.Entry<String, String> entry : paramMap.entrySet()) { + if (entry.getKey().startsWith("SliceProfile.TN.")) { + sliceProfileTnMap.put(entry.getKey().replaceFirst("^SliceProfile.TN.", ""), entry.getValue()); + } + } + this.setSliceProfileTn(sliceProfileTnMap); + Map<String, Object> sliceProfileCnMap = new HashMap<>(); + for (Map.Entry<String, String> entry : paramMap.entrySet()) { + if (entry.getKey().startsWith("SliceProfile.CN.")) { + sliceProfileCnMap.put(entry.getKey().replaceFirst("^SliceProfile.CN.", ""), entry.getValue()); + } + } + this.setSliceProfileCn(sliceProfileCnMap); + Map<String, Object> sliceProfileAnMap = new HashMap<>(); + for (Map.Entry<String, String> entry : paramMap.entrySet()) { + if (entry.getKey().startsWith("SliceProfile.AN.")) { + sliceProfileAnMap.put(entry.getKey().replaceFirst("^SliceProfile.AN.", ""), entry.getValue()); + } + } + this.setSliceProfileAn(sliceProfileAnMap); + this.setTnSuggestNssiId(paramMap.get("TN.SuggestNSSIId")); + this.setTnSuggestNssiName(paramMap.get("TN.SuggestNSSIName")); + this.setTnProgress(paramMap.get("TN.progress")); + this.setTnStatus(paramMap.get("TN.status")); + this.setTnStatusDescription(paramMap.get("TN.statusDescription")); + this.setCnSuggestNssiId(paramMap.get("CN.SuggestNSSIId")); + this.setCnSuggestNssiName(paramMap.get("CN.SuggestNSSIName")); + this.setCnProgress(paramMap.get("CN.progress")); + this.setCnStatus(paramMap.get("CN.status")); + this.setCnStatusDescription(paramMap.get("CN.statusDescription")); + this.setAnSuggestNssiId(paramMap.get("AN.SuggestNSSIId")); + this.setAnSuggestNssiName(paramMap.get("AN.SuggestNSSIName")); + this.setAnProgress(paramMap.get("AN.progress")); + this.setAnStatus(paramMap.get("AN.status")); + this.setAnStatusDescription(paramMap.get("AN.statusDescription")); + } +} + diff --git a/common/src/main/java/org/onap/so/beans/nsmf/TerminateNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/TerminateNssi.java new file mode 100644 index 0000000000..28cc565272 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/TerminateNssi.java @@ -0,0 +1,59 @@ +/*- + * ============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; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TerminateNssi { + + public final static String URL = "/api/rest/provMns/v1/NSS/nssi/%s"; + + private String nsiId; + + private String scriptName; + + private String extension; + + public String getNsiId() { + return nsiId; + } + + public void setNsiId(String nsiId) { + this.nsiId = nsiId; + } + + public String getScriptName() { + return scriptName; + } + + public void setScriptName(String scriptName) { + this.scriptName = scriptName; + } + + public String getExtension() { + return extension; + } + + public void setExtension(String extension) { + this.extension = extension; + } +} 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 new file mode 100644 index 0000000000..c3548f15af --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/TnSliceProfile.java @@ -0,0 +1,48 @@ +/*- + * ============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; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TnSliceProfile { + + private String bandwidth; + + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + private int latency; + + public String getBandwidth() { + return bandwidth; + } + + public void setBandwidth(String bandwidth) { + this.bandwidth = bandwidth; + } + + public int getLatency() { + return latency; + } + + public void setLatency(int latency) { + this.latency = latency; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/UeMobilityLevel.java b/common/src/main/java/org/onap/so/beans/nsmf/UeMobilityLevel.java new file mode 100644 index 0000000000..ffb7229838 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/UeMobilityLevel.java @@ -0,0 +1,60 @@ +/*- + * ============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.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public enum UeMobilityLevel { + + STATIONARY("stationary"), + + NOMADIC("nomadic"), + + RESTRICTED_MOBILITY("restricted mobility"), + + FULLY_MOBILITY("fully mobility"); + + private String ueMobilityLevel; + + UeMobilityLevel(String ueMobilityLevel) { + this.ueMobilityLevel = ueMobilityLevel; + } + + @JsonValue + public String getUeMobilityLevel() { + return ueMobilityLevel; + } + + @JsonCreator + public UeMobilityLevel forValue(String value) { + return valueOf(value); + } + + public static UeMobilityLevel fromString(String value) { + for (UeMobilityLevel ueLvl : UeMobilityLevel.values()) { + if (ueLvl.ueMobilityLevel.equalsIgnoreCase(value)) { + return ueLvl; + } + } + return null; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/UpdateCnNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/UpdateCnNssi.java new file mode 100644 index 0000000000..9fb8f26440 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/UpdateCnNssi.java @@ -0,0 +1,119 @@ +/*- + * ============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; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateCnNssi { + + public final static String URL = "/api/rest/provMns/v1/NSS/SliceProfiles/%s"; + + private String snssai; + + private String nssiId; + + private String nsstId; + + private String flavorId; + + private UpdateSliceProfile sliceProfile; + + private String scriptName; + + private String extension; + + private NsiInfo nsiInfo; + + private NewNsst newNsst; + + public String getSnssai() { + return snssai; + } + + public void setSnssai(String snssai) { + this.snssai = snssai; + } + + public String getNssiId() { + return nssiId; + } + + public void setNssiId(String nssiId) { + this.nssiId = nssiId; + } + + public String getNsstId() { + return nsstId; + } + + public void setNsstId(String nsstId) { + this.nsstId = nsstId; + } + + public String getFlavorId() { + return flavorId; + } + + public void setFlavorId(String flavorId) { + this.flavorId = flavorId; + } + + public UpdateSliceProfile getSliceProfile() { + return sliceProfile; + } + + public void setSliceProfile(UpdateSliceProfile sliceProfile) { + this.sliceProfile = sliceProfile; + } + + public String getScriptName() { + return scriptName; + } + + public void setScriptName(String scriptName) { + this.scriptName = scriptName; + } + + public String getExtension() { + return extension; + } + + public void setExtension(String extension) { + this.extension = extension; + } + + public NsiInfo getNsiInfo() { + return nsiInfo; + } + + public void setNsiInfo(NsiInfo nsiInfo) { + this.nsiInfo = nsiInfo; + } + + public NewNsst getNewNsst() { + return newNsst; + } + + public void setNewNsst(NewNsst newNsst) { + this.newNsst = newNsst; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/UpdateCnNssiById.java b/common/src/main/java/org/onap/so/beans/nsmf/UpdateCnNssiById.java new file mode 100644 index 0000000000..26e6ca02bb --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/UpdateCnNssiById.java @@ -0,0 +1,89 @@ +/*- + * ============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; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateCnNssiById { + + public final static String URL = "/api/rest/provMns/v1/NSS/nssi/%s"; + + private String nsstId; + + private String flavorId; + + private String scriptName; + + private String extension; + + private NsiInfo nsiInfo; + + private NewNsst newNsst; + + public String getNsstId() { + return nsstId; + } + + public void setNsstId(String nsstId) { + this.nsstId = nsstId; + } + + public String getFlavorId() { + return flavorId; + } + + public void setFlavorId(String flavorId) { + this.flavorId = flavorId; + } + + public String getScriptName() { + return scriptName; + } + + public void setScriptName(String scriptName) { + this.scriptName = scriptName; + } + + public String getExtension() { + return extension; + } + + public void setExtension(String extension) { + this.extension = extension; + } + + public NsiInfo getNsiInfo() { + return nsiInfo; + } + + public void setNsiInfo(NsiInfo nsiInfo) { + this.nsiInfo = nsiInfo; + } + + public NewNsst getNewNsst() { + return newNsst; + } + + public void setNewNsst(NewNsst newNsst) { + this.newNsst = newNsst; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/UpdateSliceProfile.java b/common/src/main/java/org/onap/so/beans/nsmf/UpdateSliceProfile.java new file mode 100644 index 0000000000..74ea7ae424 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/UpdateSliceProfile.java @@ -0,0 +1,101 @@ +/*- + * ============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.util.List; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateSliceProfile { + + private List<String> plmnIdList; + + private PerfReq perfReq; + + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + private int maxNumberofUEs; + + private List<String> coverageAreaTAList; + + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + private int latency; + + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + private int ueMobilityLevel; + + private String resourceSharingLevel; + + 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 int getUeMobilityLevel() { + return ueMobilityLevel; + } + + public void setUeMobilityLevel(int ueMobilityLevel) { + this.ueMobilityLevel = ueMobilityLevel; + } + + public String getResourceSharingLevel() { + return resourceSharingLevel; + } + + public void setResourceSharingLevel(String resourceSharingLevel) { + this.resourceSharingLevel = resourceSharingLevel; + } +} 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 new file mode 100644 index 0000000000..6388ca6106 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/VnfErrorList.java @@ -0,0 +1,47 @@ +/*- + * ============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; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class VnfErrorList { + + private String vnfInstanceId; + + private String vnfErrorDesc; + + public String getVnfInstanceId() { + return vnfInstanceId; + } + + public void setVnfInstanceId(String vnfInstanceId) { + this.vnfInstanceId = vnfInstanceId; + } + + public String getVnfErrorDesc() { + return vnfErrorDesc; + } + + public void setVnfErrorDesc(String vnfErrorDesc) { + this.vnfErrorDesc = vnfErrorDesc; + } +} diff --git a/common/src/main/java/org/onap/so/client/aai/AAIClient.java b/common/src/main/java/org/onap/so/client/aai/AAIClient.java index a1e0d7c102..d376d85a83 100644 --- a/common/src/main/java/org/onap/so/client/aai/AAIClient.java +++ b/common/src/main/java/org/onap/so/client/aai/AAIClient.java @@ -25,7 +25,6 @@ import javax.ws.rs.NotFoundException; import javax.ws.rs.core.UriBuilder; import org.onap.so.client.RestClient; import org.onap.so.client.graphinventory.GraphInventoryClient; -import org.onap.so.client.graphinventory.entities.uri.GraphInventoryUri; import org.onap.so.client.graphinventory.exceptions.GraphInventoryUriComputationException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,14 +45,15 @@ public class AAIClient extends GraphInventoryClient { } @Override - protected URI constructPath(GraphInventoryUri uri) { + protected URI constructPath(URI uri) { - return UriBuilder.fromUri(AAI_ROOT + "/" + this.getVersion().toString() + uri.build().toString()).build(); + return UriBuilder.fromUri(AAI_ROOT + "/" + this.getVersion().toString() + uri.toString()).build(); } @Override - public RestClient createClient(GraphInventoryUri uri) { + protected RestClient createClient(URI uri) { try { + return new AAIRestClient(getRestProperties(), constructPath(uri)); } catch (GraphInventoryUriComputationException | NotFoundException e) { logger.debug("failed to construct A&AI uri", e); diff --git a/common/src/main/java/org/onap/so/client/aai/AAIObjectBase.java b/common/src/main/java/org/onap/so/client/aai/AAIObjectBase.java new file mode 100644 index 0000000000..dab3cda32b --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/AAIObjectBase.java @@ -0,0 +1,7 @@ +package org.onap.so.client.aai; + +import org.onap.so.client.graphinventory.GraphInventoryObjectBase; + +public interface AAIObjectBase extends GraphInventoryObjectBase { + +} diff --git a/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java b/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java index e42a2a2383..d14a4bedc3 100644 --- a/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java +++ b/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java @@ -25,63 +25,64 @@ import org.onap.so.client.graphinventory.GraphInventoryObjectPlurals; import org.onap.so.constants.Defaults; import com.google.common.base.CaseFormat; -public class AAIObjectPlurals implements GraphInventoryObjectPlurals, Serializable { +public class AAIObjectPlurals implements AAIObjectBase, GraphInventoryObjectPlurals, Serializable { private static final long serialVersionUID = 5312713297525740746L; public static final AAIObjectPlurals CUSTOMER = - new AAIObjectPlurals(AAINamespaceConstants.BUSINESS, "/customers", "customer"); + new AAIObjectPlurals(AAIObjectType.CUSTOMER, AAINamespaceConstants.BUSINESS, "/customers"); public static final AAIObjectPlurals GENERIC_VNF = - new AAIObjectPlurals(AAINamespaceConstants.NETWORK, "/generic-vnfs", "generic-vnf"); + new AAIObjectPlurals(AAIObjectType.GENERIC_VNF, AAINamespaceConstants.NETWORK, "/generic-vnfs"); public static final AAIObjectPlurals PORT_GROUP = - new AAIObjectPlurals(AAIObjectType.VCE.uriTemplate(), "/port-groups", "port-group"); + new AAIObjectPlurals(AAIObjectType.PORT_GROUP, AAIObjectType.VCE.uriTemplate(), "/port-groups"); public static final AAIObjectPlurals PSERVER = - new AAIObjectPlurals(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/pservers", "pserver"); + new AAIObjectPlurals(AAIObjectType.PSERVER, AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/pservers"); public static final AAIObjectPlurals P_INTERFACE = - new AAIObjectPlurals(AAIObjectType.PSERVER.uriTemplate(), "/p-interfaces", "p-interface"); + new AAIObjectPlurals(AAIObjectType.P_INTERFACE, AAIObjectType.PSERVER.uriTemplate(), "/p-interfaces"); public static final AAIObjectPlurals L3_NETWORK = - new AAIObjectPlurals(AAINamespaceConstants.NETWORK, "/l3-networks", "l3-network"); + new AAIObjectPlurals(AAIObjectType.L3_NETWORK, AAINamespaceConstants.NETWORK, "/l3-networks"); public static final AAIObjectPlurals NETWORK_POLICY = - new AAIObjectPlurals(AAINamespaceConstants.NETWORK, "/network-policies", "network-policy"); + new AAIObjectPlurals(AAIObjectType.NETWORK_POLICY, AAINamespaceConstants.NETWORK, "/network-policies"); public static final AAIObjectPlurals VPN_BINDING = - new AAIObjectPlurals(AAINamespaceConstants.NETWORK, "/vpn-bindings", "vpn-binding"); - public static final AAIObjectPlurals SERVICE_SUBSCRIPTION = new AAIObjectPlurals( - AAIObjectType.CUSTOMER.uriTemplate(), "/service-subscriptions", "service-subscription"); - public static final AAIObjectPlurals SERVICE_INSTANCE = new AAIObjectPlurals( - AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), "/service-instances", "service-instance"); + new AAIObjectPlurals(AAIObjectType.VPN_BINDING, AAINamespaceConstants.NETWORK, "/vpn-bindings"); + public static final AAIObjectPlurals SERVICE_SUBSCRIPTION = new AAIObjectPlurals(AAIObjectType.SERVICE_SUBSCRIPTION, + AAIObjectType.CUSTOMER.uriTemplate(), "/service-subscriptions"); + public static final AAIObjectPlurals SERVICE_INSTANCE = new AAIObjectPlurals(AAIObjectType.SERVICE_INSTANCE, + AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), "/service-instances"); public static final AAIObjectPlurals OWNING_ENTITY = - new AAIObjectPlurals(AAINamespaceConstants.BUSINESS, "/owning-entities", "owning-entity"); - public static final AAIObjectPlurals VOLUME_GROUP = - new AAIObjectPlurals(AAIObjectType.CLOUD_REGION.uriTemplate(), "/volume-groups", "volume-group"); - public static final AAIObjectPlurals AVAILIBILITY_ZONE = - new AAIObjectPlurals(AAIObjectType.CLOUD_REGION.uriTemplate(), "/availability-zones", "availability-zone"); + new AAIObjectPlurals(AAIObjectType.OWNING_ENTITY, AAINamespaceConstants.BUSINESS, "/owning-entities"); + public static final AAIObjectPlurals VOLUME_GROUP = new AAIObjectPlurals(AAIObjectType.VOLUME_GROUP, + AAIObjectType.CLOUD_REGION.uriTemplate(), "/volume-groups"); + public static final AAIObjectPlurals AVAILIBILITY_ZONE = new AAIObjectPlurals(AAIObjectType.AVAILIBILITY_ZONE, + AAIObjectType.CLOUD_REGION.uriTemplate(), "/availability-zones"); public static final AAIObjectPlurals VF_MODULE = - new AAIObjectPlurals(AAIObjectType.GENERIC_VNF.uriTemplate(), "/vf-modules", "vf-module"); + new AAIObjectPlurals(AAIObjectType.VF_MODULE, AAIObjectType.GENERIC_VNF.uriTemplate(), "/vf-modules"); public static final AAIObjectPlurals CONFIGURATION = - new AAIObjectPlurals(AAINamespaceConstants.NETWORK, "/configurations", "configuration"); + new AAIObjectPlurals(AAIObjectType.CONFIGURATION, AAINamespaceConstants.NETWORK, "/configurations"); public static final AAIObjectPlurals DEFAULT_TENANT = - new AAIObjectPlurals(AAINamespaceConstants.CLOUD_INFRASTRUCTURE + "/cloud-regions/cloud-region/" - + Defaults.CLOUD_OWNER + "/AAIAIC25", "/tenants", "default-tenant"); - public static final AAIObjectPlurals NETWORK_TECHNOLOGY = new AAIObjectPlurals( - AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/network-technologies", "network-technology"); + new AAIObjectPlurals(AAIObjectType.DEFAULT_TENANT, AAINamespaceConstants.CLOUD_INFRASTRUCTURE + + "/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER + "/AAIAIC25", "/tenants"); + public static final AAIObjectPlurals NETWORK_TECHNOLOGY = new AAIObjectPlurals(AAIObjectType.NETWORK_TECHNOLOGY, + AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/network-technologies"); public static final AAIObjectPlurals LOGICAL_LINK = - new AAIObjectPlurals(AAINamespaceConstants.NETWORK, "/logical-links", "logical-link"); + new AAIObjectPlurals(AAIObjectType.LOGICAL_LINK, AAINamespaceConstants.NETWORK, "/logical-links"); public static final AAIObjectPlurals L_INTERFACE = - new AAIObjectPlurals(AAIObjectType.VSERVER.uriTemplate(), "/l-interfaces", "l-interface"); + new AAIObjectPlurals(AAIObjectType.L_INTERFACE, AAIObjectType.VSERVER.uriTemplate(), "/l-interfaces"); public static final AAIObjectPlurals SUB_L_INTERFACE = - new AAIObjectPlurals(AAIObjectType.L_INTERFACE.uriTemplate(), "/l-interfaces", "l-interface"); + new AAIObjectPlurals(AAIObjectType.L_INTERFACE, AAIObjectType.L_INTERFACE.uriTemplate(), "/l-interfaces"); public static final AAIObjectPlurals INSTANCE_GROUP = - new AAIObjectPlurals(AAINamespaceConstants.NETWORK, "/instance-groups", "instance-group"); - public static final AAIObjectPlurals PNF = new AAIObjectPlurals(AAINamespaceConstants.NETWORK, "/pnfs", "pnfs"); + new AAIObjectPlurals(AAIObjectType.INSTANCE_GROUP, AAINamespaceConstants.NETWORK, "/instance-groups"); + public static final AAIObjectPlurals PNF = + new AAIObjectPlurals(AAIObjectType.PNF, AAINamespaceConstants.NETWORK, "/pnfs"); private final String uriTemplate; private final String partialUri; - private final String name; + private final AAIObjectType type; - protected AAIObjectPlurals(String parentUri, String partialUri, String name) { + protected AAIObjectPlurals(AAIObjectType type, String parentUri, String partialUri) { this.uriTemplate = parentUri + partialUri; this.partialUri = partialUri; - this.name = name; + this.type = type; } @Override @@ -100,12 +101,17 @@ public class AAIObjectPlurals implements GraphInventoryObjectPlurals, Serializab } @Override + public AAIObjectType getType() { + return this.type; + } + + @Override public String typeName() { - return this.typeName(CaseFormat.LOWER_HYPHEN); + return this.getType().typeName(); } @Override public String typeName(CaseFormat format) { - return CaseFormat.LOWER_HYPHEN.to(format, this.name); + return this.getType().typeName(format); } } diff --git a/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java b/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java index c2c8e933b1..c9b69cd9e4 100644 --- a/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java +++ b/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java @@ -20,17 +20,14 @@ package org.onap.so.client.aai; -import java.io.Serializable; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.regex.Pattern; +import com.google.common.base.CaseFormat; import org.onap.aai.annotations.Metadata; import org.onap.aai.domain.yang.AggregateRoute; import org.onap.aai.domain.yang.AllottedResource; +import org.onap.aai.domain.yang.AvailabilityZone; import org.onap.aai.domain.yang.CloudRegion; import org.onap.aai.domain.yang.Collection; +import org.onap.aai.domain.yang.CommunicationServiceProfile; import org.onap.aai.domain.yang.Complex; import org.onap.aai.domain.yang.Configuration; import org.onap.aai.domain.yang.Connector; @@ -45,6 +42,7 @@ import org.onap.aai.domain.yang.InstanceGroup; import org.onap.aai.domain.yang.L3Network; import org.onap.aai.domain.yang.LInterface; import org.onap.aai.domain.yang.LineOfBusiness; +import org.onap.aai.domain.yang.LogicalLink; import org.onap.aai.domain.yang.ModelVer; import org.onap.aai.domain.yang.NetworkPolicy; import org.onap.aai.domain.yang.NetworkTechnology; @@ -58,8 +56,11 @@ import org.onap.aai.domain.yang.PortGroup; import org.onap.aai.domain.yang.Project; import org.onap.aai.domain.yang.Pserver; import org.onap.aai.domain.yang.RouteTableReference; +import org.onap.aai.domain.yang.Service; import org.onap.aai.domain.yang.ServiceInstance; +import org.onap.aai.domain.yang.ServiceProfile; import org.onap.aai.domain.yang.ServiceSubscription; +import org.onap.aai.domain.yang.SliceProfile; import org.onap.aai.domain.yang.SpPartner; import org.onap.aai.domain.yang.SriovPf; import org.onap.aai.domain.yang.Subnet; @@ -79,9 +80,14 @@ import org.reflections.Reflections; import org.reflections.scanners.SubTypesScanner; import org.reflections.util.ClasspathHelper; import org.reflections.util.ConfigurationBuilder; -import com.google.common.base.CaseFormat; +import java.io.Serializable; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.regex.Pattern; -public class AAIObjectType implements GraphInventoryObjectType, Serializable { +public class AAIObjectType implements AAIObjectBase, GraphInventoryObjectType, Serializable { private static final long serialVersionUID = -2877184776691514600L; private static Map<String, AAIObjectType> map = new HashMap<>(); @@ -122,6 +128,8 @@ public class AAIObjectType implements GraphInventoryObjectType, Serializable { public static final AAIObjectType SERVICE_INSTANCE_METADATA = new AAIObjectType( AAIObjectType.SERVICE_INSTANCE + "/metadata", org.onap.aai.domain.yang.v13.Metadata.class); + public static final AAIObjectType SERVICE = new AAIObjectType( + AAINamespaceConstants.SERVICE_DESIGN_AND_CREATION + "/services/service/{service-id}", Service.class); public static final AAIObjectType SERVICE_INSTANCE = new AAIObjectType(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), ServiceInstance.class); public static final AAIObjectType PROJECT = new AAIObjectType(AAINamespaceConstants.BUSINESS, Project.class); @@ -132,6 +140,8 @@ public class AAIObjectType implements GraphInventoryObjectType, Serializable { new AAIObjectType(AAINamespaceConstants.BUSINESS, OwningEntity.class); public static final AAIObjectType ALLOTTED_RESOURCE = new AAIObjectType(AAIObjectType.SERVICE_INSTANCE.uriTemplate(), AllottedResource.class); + public static final AAIObjectType ALLOTTED_RESOURCE_ALL = + new AAIObjectType(AAIObjectType.SERVICE_INSTANCE.uriTemplate(), "/allotted-resources", "allottedResources"); public static final AAIObjectType PNF = new AAIObjectType(AAINamespaceConstants.NETWORK, Pnf.class); public static final AAIObjectType OPERATIONAL_ENVIRONMENT = new AAIObjectType(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, OperationalEnvironment.class); @@ -150,6 +160,8 @@ public class AAIObjectType implements GraphInventoryObjectType, Serializable { new AAIObjectType(AAIObjectType.PSERVER.uriTemplate(), PInterface.class); public static final AAIObjectType SRIOV_PF = new AAIObjectType(AAIObjectType.P_INTERFACE.uriTemplate(), SriovPf.class); + public static final AAIObjectType LOGICAL_LINK = + new AAIObjectType(AAINamespaceConstants.NETWORK, LogicalLink.class); public static final AAIObjectType PHYSICAL_LINK = new AAIObjectType(AAINamespaceConstants.NETWORK, PhysicalLink.class); public static final AAIObjectType INSTANCE_GROUP = @@ -176,7 +188,15 @@ public class AAIObjectType implements GraphInventoryObjectType, Serializable { public static final AAIObjectType IMAGE = new AAIObjectType(AAIObjectType.CLOUD_REGION.uriTemplate(), Image.class); public static final AAIObjectType FLAVOR = new AAIObjectType(AAIObjectType.CLOUD_REGION.uriTemplate(), Flavor.class); - public static final AAIObjectType UNKNOWN = new AAIObjectType("", "", "unknown"); + public static final AAIObjectType UNKNOWN = new AAIObjectType("", "", "unknown") { + + private static final long serialVersionUID = 9208984071038447607L; + + @Override + public boolean passThrough() { + return true; + } + }; public static final AAIObjectType DSL = new AAIObjectType("/dsl", "", "dsl"); public static final AAIObjectType VNFM = new AAIObjectType( AAINamespaceConstants.EXTERNAL_SYSTEM + "/esr-vnfm-list/esr-vnfm/{vnfm-id}", EsrVnfm.class); @@ -188,6 +208,27 @@ public class AAIObjectType implements GraphInventoryObjectType, Serializable { public static final AAIObjectType CLOUD_ESR_SYSTEM_INFO_LIST = new AAIObjectType( AAIObjectType.CLOUD_REGION.uriTemplate(), "/esr-system-info-list", "cloud-esr-system-info-list"); public static final AAIObjectType ZONE = new AAIObjectType(AAINamespaceConstants.NETWORK, Zone.class); + public static final AAIObjectType AVAILIBILITY_ZONE = + new AAIObjectType(AAIObjectType.CLOUD_REGION.uriTemplate(), AvailabilityZone.class); + public static final AAIObjectType THIRDPARTY_SDNC_LIST = new AAIObjectType(AAINamespaceConstants.EXTERNAL_SYSTEM, + "/esr-thirdparty-sdnc-list", "thirdparty-sdnc-list"); + public static final AAIObjectType THIRDPARTY_SDNC_SYSTEM_INFO_LIST = + new AAIObjectType(AAINamespaceConstants.EXTERNAL_SYSTEM + "/esr-thirdparty-sdnc-list", + "/esr-thirdparty-sdnc/{sdnc-id}/esr-system-info-list", "thirdparty-sdnc-system-info-list"); + public static final AAIObjectType COMMUNICATION_SERVICE_PROFILE = + new AAIObjectType(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), CommunicationServiceProfile.class); + public static final AAIObjectType SERVICE_PROFILE = + new AAIObjectType(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), ServiceProfile.class); + public static final AAIObjectType SERVICE_PROFILE_ALL = + new AAIObjectType(AAIObjectType.SERVICE_INSTANCE.uriTemplate(), "/service-profiles", "serviceProfiles"); + public static final AAIObjectType SLICE_PROFILE = + new AAIObjectType(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), SliceProfile.class); + public static final AAIObjectType SLICE_PROFILE_ALL = + new AAIObjectType(AAIObjectType.SERVICE_INSTANCE.uriTemplate(), "/slice-profiles", "sliceProfiles"); + public static final AAIObjectType COMMUNICATION_PROFILE_ALL = new AAIObjectType( + AAIObjectType.SERVICE_INSTANCE.uriTemplate(), "/communication-service-profiles", "communicationProfiles"); + public static final AAIObjectType QUERY_ALLOTTED_RESOURCE = + new AAIObjectType(AAIObjectType.SERVICE_INSTANCE.uriTemplate(), "?depth=2", "service-Instance"); private final String uriTemplate; private final String parentUri; @@ -202,12 +243,13 @@ public class AAIObjectType implements GraphInventoryObjectType, Serializable { new Reflections(new ConfigurationBuilder().setUrls(packages).setScanners(new SubTypesScanner())); Set<Class<? extends AAIObjectType>> resources = r.getSubTypesOf(AAIObjectType.class); - try { - for (Class<? extends AAIObjectType> customTypeClass : resources) { - AAIObjectType customType; + + for (Class<? extends AAIObjectType> customTypeClass : resources) { + AAIObjectType customType; + try { customType = customTypeClass.newInstance(); + } catch (InstantiationException | IllegalAccessException e) { } - } catch (InstantiationException | IllegalAccessException e) { } } diff --git a/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java b/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java index a89bea6975..8e334de396 100644 --- a/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java +++ b/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java @@ -24,13 +24,14 @@ import java.util.Optional; import org.onap.aai.domain.yang.Relationship; import org.onap.so.client.aai.entities.AAIEdgeLabel; import org.onap.so.client.aai.entities.AAIResultWrapper; +import org.onap.so.client.aai.entities.uri.AAIBaseResourceUri; +import org.onap.so.client.aai.entities.uri.AAIPluralResourceUri; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.graphinventory.GraphInventoryResourcesClient; import org.onap.so.client.graphinventory.entities.GraphInventoryEdgeLabel; -import org.onap.so.client.graphinventory.entities.uri.GraphInventoryResourceUri; public class AAIResourcesClient extends - GraphInventoryResourcesClient<AAIResourcesClient, AAIResourceUri, AAIEdgeLabel, AAIResultWrapper, AAITransactionalClient, AAISingleTransactionClient> { + GraphInventoryResourcesClient<AAIResourcesClient, AAIBaseResourceUri<?, ?>, AAIResourceUri, AAIPluralResourceUri, AAIEdgeLabel, AAIResultWrapper, AAITransactionalClient, AAISingleTransactionClient> { private AAIClient aaiClient; @@ -55,6 +56,11 @@ public class AAIResourcesClient extends } @Override + public AAIResultWrapper createWrapper(Object obj) { + return new AAIResultWrapper(obj); + } + + @Override public AAITransactionalClient beginTransaction() { return new AAITransactionalClient(this, aaiClient); } @@ -65,17 +71,17 @@ public class AAIResourcesClient extends } @Override - protected Relationship buildRelationship(GraphInventoryResourceUri uri) { + protected Relationship buildRelationship(AAIResourceUri uri) { return super.buildRelationship(uri, Optional.empty()); } @Override - protected Relationship buildRelationship(GraphInventoryResourceUri uri, GraphInventoryEdgeLabel label) { + protected Relationship buildRelationship(AAIResourceUri uri, GraphInventoryEdgeLabel label) { return super.buildRelationship(uri, Optional.of(label)); } @Override - protected Relationship buildRelationship(GraphInventoryResourceUri uri, Optional<GraphInventoryEdgeLabel> label) { + protected Relationship buildRelationship(AAIResourceUri uri, Optional<GraphInventoryEdgeLabel> label) { return super.buildRelationship(uri, label); } diff --git a/common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java b/common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java index 8bc709b276..2698bc347f 100644 --- a/common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java +++ b/common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java @@ -38,4 +38,6 @@ public interface AAIRestClientI { Optional<Pnf> getPnfByName(String pnfId); void createPnf(String pnfId, Pnf pnf); + + void updatePnf(String pnfId, Pnf pnf); } diff --git a/common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java b/common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java index 03e2eaea1f..f2f96ca905 100644 --- a/common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java +++ b/common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java @@ -92,4 +92,9 @@ public class AAIRestClientImpl implements AAIRestClientI { new AAIResourcesClient().createIfNotExists(AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfId), Optional.of(pnf)); } + + @Override + public void updatePnf(String pnfId, Pnf pnf) { + new AAIResourcesClient().update(AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfId), pnf); + } } diff --git a/common/src/main/java/org/onap/so/client/aai/AAISingleTransactionClient.java b/common/src/main/java/org/onap/so/client/aai/AAISingleTransactionClient.java index 3f9715bdef..b1d29f445b 100644 --- a/common/src/main/java/org/onap/so/client/aai/AAISingleTransactionClient.java +++ b/common/src/main/java/org/onap/so/client/aai/AAISingleTransactionClient.java @@ -32,6 +32,7 @@ import org.onap.so.client.aai.entities.singletransaction.OperationBodyRequest; import org.onap.so.client.aai.entities.singletransaction.OperationBodyResponse; import org.onap.so.client.aai.entities.singletransaction.SingleTransactionRequest; import org.onap.so.client.aai.entities.singletransaction.SingleTransactionResponse; +import org.onap.so.client.aai.entities.uri.AAIBaseResourceUri; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.graphinventory.GraphInventoryPatchConverter; @@ -40,8 +41,8 @@ import org.onap.so.client.graphinventory.exceptions.BulkProcessFailed; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Joiner; -public class AAISingleTransactionClient - extends GraphInventoryTransactionClient<AAISingleTransactionClient, AAIResourceUri, AAIEdgeLabel> { +public class AAISingleTransactionClient extends + GraphInventoryTransactionClient<AAISingleTransactionClient, AAIBaseResourceUri<?, ?>, AAIResourceUri, AAIEdgeLabel> { private final SingleTransactionRequest request; private AAIResourcesClient resourcesClient; @@ -137,12 +138,12 @@ public class AAISingleTransactionClient } @Override - protected <T> Optional<T> get(GenericType<T> genericType, AAIResourceUri clone) { + protected <T> Optional<T> get(GenericType<T> genericType, AAIBaseResourceUri<?, ?> clone) { return resourcesClient.get(genericType, clone); } @Override - protected boolean exists(AAIResourceUri uri) { + protected boolean exists(AAIBaseResourceUri<?, ?> uri) { return resourcesClient.exists(uri); } diff --git a/common/src/main/java/org/onap/so/client/aai/AAITransactionalClient.java b/common/src/main/java/org/onap/so/client/aai/AAITransactionalClient.java index e621566e5a..7b7dccc999 100644 --- a/common/src/main/java/org/onap/so/client/aai/AAITransactionalClient.java +++ b/common/src/main/java/org/onap/so/client/aai/AAITransactionalClient.java @@ -35,6 +35,7 @@ import org.onap.so.client.aai.entities.AAIError; import org.onap.so.client.aai.entities.bulkprocess.OperationBody; import org.onap.so.client.aai.entities.bulkprocess.Transaction; import org.onap.so.client.aai.entities.bulkprocess.Transactions; +import org.onap.so.client.aai.entities.uri.AAIBaseResourceUri; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.graphinventory.GraphInventoryPatchConverter; @@ -45,8 +46,8 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Joiner; -public class AAITransactionalClient - extends GraphInventoryTransactionClient<AAITransactionalClient, AAIResourceUri, AAIEdgeLabel> { +public class AAITransactionalClient extends + GraphInventoryTransactionClient<AAITransactionalClient, AAIBaseResourceUri<?, ?>, AAIResourceUri, AAIEdgeLabel> { private final Transactions transactions; private Transaction currentTransaction; @@ -189,12 +190,12 @@ public class AAITransactionalClient } @Override - protected <T> Optional<T> get(GenericType<T> genericType, AAIResourceUri clone) { + protected <T> Optional<T> get(GenericType<T> genericType, AAIBaseResourceUri<?, ?> clone) { return resourcesClient.get(genericType, clone); } @Override - protected boolean exists(AAIResourceUri uri) { + protected boolean exists(AAIBaseResourceUri<?, ?> uri) { return resourcesClient.exists(uri); } diff --git a/common/src/main/java/org/onap/so/logger/ErrorCode.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIBaseResourceUri.java index a57ed99f2b..67f858a2bf 100644 --- a/common/src/main/java/org/onap/so/logger/ErrorCode.java +++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIBaseResourceUri.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 AT&T Intellectual Property. 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. @@ -18,23 +18,12 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.logger; +package org.onap.so.client.aai.entities.uri; -public enum ErrorCode { - PermissionError(100), - AvailabilityError(200), - DataError(300), - SchemaError(400), - BusinessProcessError(500), - UnknownError(900); +import org.onap.so.client.aai.AAIObjectBase; +import org.onap.so.client.graphinventory.entities.uri.GraphInventoryResourceUri; - private int value; +public interface AAIBaseResourceUri<T extends AAIBaseResourceUri<?, ?>, OT extends AAIObjectBase> + extends AAIUri<T, OT>, GraphInventoryResourceUri<T, OT> { - ErrorCode(int value) { - this.value = value; - } - - public int getValue() { - return this.value; - } } diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIPluralResourceUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIPluralResourceUri.java new file mode 100644 index 0000000000..2cec021c95 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIPluralResourceUri.java @@ -0,0 +1,9 @@ +package org.onap.so.client.aai.entities.uri; + +import org.onap.so.client.aai.AAIObjectPlurals; +import org.onap.so.client.graphinventory.entities.uri.GraphInventoryPluralResourceUri; + +public interface AAIPluralResourceUri extends AAIBaseResourceUri<AAIPluralResourceUri, AAIObjectPlurals>, + GraphInventoryPluralResourceUri<AAIPluralResourceUri, AAIObjectPlurals> { + +} diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIResourceUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIResourceUri.java index 70dfd581e8..e93d52889a 100644 --- a/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIResourceUri.java +++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIResourceUri.java @@ -1,64 +1,10 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.client.aai.entities.uri; import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; -import org.onap.so.client.graphinventory.Format; -import org.onap.so.client.graphinventory.entities.uri.Depth; -import org.onap.so.client.graphinventory.entities.uri.GraphInventoryResourceUri; - -public interface AAIResourceUri extends AAIUri, GraphInventoryResourceUri { - - public AAIResourceUri relationshipAPI(); - - public AAIResourceUri relatedTo(AAIObjectPlurals plural); - - public AAIResourceUri relatedTo(AAIObjectType type, String... values); - - public AAIResourceUri resourceVersion(String version); - - public AAIResourceUri format(Format format); - - @Override - public AAIResourceUri depth(Depth depth); - - @Override - public AAIResourceUri nodesOnly(boolean nodesOnly); - - @Override - public AAIResourceUri queryParam(String name, String... values); - - @Override - public AAIResourceUri replaceQueryParam(String name, String... values); - - @Override - public AAIResourceUri resultIndex(int index); - - @Override - public AAIResourceUri resultSize(int size); +import org.onap.so.client.graphinventory.entities.uri.GraphInventorySingleResourceUri; - @Override - public AAIResourceUri limit(int size); +public interface AAIResourceUri extends AAIBaseResourceUri<AAIResourceUri, AAIObjectType>, + GraphInventorySingleResourceUri<AAIResourceUri, AAIPluralResourceUri, AAIObjectType, AAIObjectPlurals> { - @Override - public AAIResourceUri clone(); } diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimplePluralUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimplePluralUri.java new file mode 100644 index 0000000000..9ab45a8aa9 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimplePluralUri.java @@ -0,0 +1,68 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. 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.client.aai.entities.uri; + +import javax.ws.rs.core.UriBuilder; +import org.onap.so.client.aai.AAIObjectPlurals; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.graphinventory.entities.uri.SimplePluralUri; + +public class AAISimplePluralUri + extends SimplePluralUri<AAIPluralResourceUri, AAIResourceUri, AAIObjectPlurals, AAIObjectType> + implements AAIPluralResourceUri { + + private static final long serialVersionUID = -6397024057188453229L; + + protected AAISimplePluralUri(AAIObjectPlurals type, UriBuilder builder, Object... values) { + super(type, builder, values); + } + + protected AAISimplePluralUri(AAIObjectPlurals type) { + super(type); + } + + protected AAISimplePluralUri(AAIObjectPlurals type, Object... values) { + super(type, values); + } + + protected AAISimplePluralUri(AAIObjectPlurals type, AAIResourceUri uri) { + super(type, uri); + } + + protected AAISimplePluralUri(AAIResourceUri parentUri, AAIObjectPlurals childType) { + super(parentUri, childType); + } + + protected AAISimplePluralUri(AAISimplePluralUri copy) { + super(copy); + } + + @Override + public AAISimplePluralUri clone() { + return new AAISimplePluralUri(this); + } + + @Override + public AAIObjectPlurals getObjectType() { + return this.pluralType; + } + +} diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java index 1fe9da984f..49dab59fc1 100644 --- a/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java +++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java @@ -21,15 +21,13 @@ package org.onap.so.client.aai.entities.uri; import java.net.URI; -import java.util.regex.Pattern; import javax.ws.rs.core.UriBuilder; import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; -import org.onap.so.client.graphinventory.Format; -import org.onap.so.client.graphinventory.entities.uri.Depth; import org.onap.so.client.graphinventory.entities.uri.SimpleUri; -public class AAISimpleUri extends SimpleUri implements AAIResourceUri { +public class AAISimpleUri extends SimpleUri<AAIResourceUri, AAIPluralResourceUri, AAIObjectType, AAIObjectPlurals> + implements AAIResourceUri { private static final long serialVersionUID = -6397024057188453229L; @@ -46,102 +44,30 @@ public class AAISimpleUri extends SimpleUri implements AAIResourceUri { super(type, builder, values); } - protected AAISimpleUri(AAIObjectPlurals type, UriBuilder builder, Object... values) { - super(type, builder, values); - } - - protected AAISimpleUri(AAIObjectPlurals type) { - super(type); - } - - protected AAISimpleUri(AAIObjectPlurals type, Object... values) { - super(type, values); - } - protected AAISimpleUri(AAIResourceUri parentUri, AAIObjectType childType, Object... childValues) { super(parentUri, childType, childValues); } - protected AAISimpleUri(AAIResourceUri parentUri, AAIObjectPlurals childType) { - super(parentUri, childType); - } - - @Override - public AAISimpleUri relationshipAPI() { - return (AAISimpleUri) super.relationshipAPI(); - } - - @Override - public AAISimpleUri relatedTo(AAIObjectPlurals plural) { - return (AAISimpleUri) super.relatedTo(plural); - } - - @Override - public AAISimpleUri relatedTo(AAIObjectType type, String... values) { - return (AAISimpleUri) super.relatedTo(type, values); - } - - @Override - public AAISimpleUri resourceVersion(String version) { - return (AAISimpleUri) super.resourceVersion(version); - } - - @Override - public AAISimpleUri queryParam(String name, String... values) { - return (AAISimpleUri) super.queryParam(name, values); - } - - @Override - public AAISimpleUri replaceQueryParam(String name, String... values) { - return (AAISimpleUri) super.replaceQueryParam(name, values); - } - - @Override - public AAISimpleUri resultIndex(int index) { - return (AAISimpleUri) super.resultIndex(index); - } - - @Override - public AAISimpleUri resultSize(int size) { - return (AAISimpleUri) super.resultSize(size); - } - - @Override - public AAISimpleUri limit(int size) { - return (AAISimpleUri) super.limit(size); + // copy constructor + protected AAISimpleUri(AAISimpleUri copy) { + super(copy); } @Override public AAISimpleUri clone() { - if (this.type != null) { - return new AAISimpleUri((AAIObjectType) this.type, this.internalURI.clone(), values); - } else { - return new AAISimpleUri((AAIObjectPlurals) this.pluralType, this.internalURI.clone(), values); - } - } - - @Override - public AAIObjectType getObjectType() { - return (AAIObjectType) this.type; + return new AAISimpleUri(this); } @Override - public AAISimpleUri depth(Depth depth) { - return (AAISimpleUri) super.depth(depth); - } - - @Override - public AAISimpleUri nodesOnly(boolean nodesOnly) { - return (AAISimpleUri) super.nodesOnly(nodesOnly); + public AAISimpleUri relatedTo(AAIObjectType type, String... values) { + this.internalURI = internalURI.path(relatedTo); + return new AAISimpleUri(this, type, values); } @Override - public AAISimpleUri format(Format format) { - return (AAISimpleUri) super.format(format); + public AAISimplePluralUri relatedTo(AAIObjectPlurals plural) { + this.internalURI.path(relatedTo); + return new AAISimplePluralUri(this, plural); } - @Override - protected Pattern getPrefixPattern() { - return Pattern.compile("/aai/v\\d+"); - } } diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUri.java index 6a4c90a6ee..8101643b78 100644 --- a/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUri.java +++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUri.java @@ -20,52 +20,13 @@ package org.onap.so.client.aai.entities.uri; -import org.onap.so.client.aai.AAIObjectType; -import org.onap.so.client.graphinventory.entities.uri.Depth; +import java.util.regex.Pattern; +import org.onap.so.client.aai.AAIObjectBase; import org.onap.so.client.graphinventory.entities.uri.GraphInventoryUri; -public interface AAIUri extends GraphInventoryUri { +public interface AAIUri<T extends AAIUri<?, ?>, OP extends AAIObjectBase> extends GraphInventoryUri<T, OP> { - /** - * By default A&AI enforces a depth of 1. Some objects can be told to retrieve objects nested beneath them by - * increasing this number. - * - * You can use 0 to restrict the returned information to only the object you requested You can use all to retrieve - * all nested objects (this should only be used if you really need a massive amount of information and are caching - * the retrieval) - * - * @param depth - * @return - */ - @Override - public AAIUri depth(Depth depth); - - /** - * Makes client only return object fields, no relationships - * - * @return - */ - @Override - public AAIUri nodesOnly(boolean nodesOnly); - - @Override - public AAIUri queryParam(String name, String... values); - - @Override - public AAIUri replaceQueryParam(String name, String... values); - - @Override - public AAIUri resultIndex(int index); - - @Override - public AAIUri resultSize(int size); - - @Override - public AAIUri limit(int size); - - @Override - public AAIUri clone(); - - @Override - public AAIObjectType getObjectType(); + public default Pattern getPrefixPattern() { + return Pattern.compile("/aai/v\\d+"); + } } diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUriFactory.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUriFactory.java index 406ff09952..bdd3921851 100644 --- a/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUriFactory.java +++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUriFactory.java @@ -47,13 +47,13 @@ public class AAIUriFactory { } } - public static AAIResourceUri createNodesUri(AAIObjectType type, Object... values) { - return new NodesUri(type, values); + public static NodesSingleUri createNodesUri(AAIObjectType type, Object... values) { + return new NodesSingleUri(type, values); } - public static AAIResourceUri createNodesUri(AAIObjectPlurals type) { - return new NodesUri(type); + public static NodesPluralUri createNodesUri(AAIObjectPlurals type) { + return new NodesPluralUri(type); } @@ -64,7 +64,7 @@ public class AAIUriFactory { * @param uri * @return */ - public static AAIResourceUri createResourceFromExistingURI(AAIObjectType type, URI uri) { + public static AAISimpleUri createResourceFromExistingURI(AAIObjectType type, URI uri) { return new AAISimpleUri(type, uri); } @@ -77,15 +77,15 @@ public class AAIUriFactory { * @param childValues * @return */ - public static AAIResourceUri createResourceFromParentURI(AAIResourceUri parentUri, AAIObjectType childType, + public static AAISimpleUri createResourceFromParentURI(AAIResourceUri parentUri, AAIObjectType childType, Object... childValues) { return new AAISimpleUri(parentUri, childType, childValues); } - public static AAIResourceUri createResourceFromParentURI(AAIResourceUri parentUri, AAIObjectPlurals childType) { + public static AAISimplePluralUri createResourceFromParentURI(AAIResourceUri parentUri, AAIObjectPlurals childType) { - return new AAISimpleUri(parentUri, childType); + return new AAISimplePluralUri(parentUri, childType); } /** @@ -94,9 +94,9 @@ public class AAIUriFactory { * @param type * @return */ - public static AAIResourceUri createResourceUri(AAIObjectPlurals type) { + public static AAISimplePluralUri createResourceUri(AAIObjectPlurals type) { - return new AAISimpleUri(type); + return new AAISimplePluralUri(type); } @@ -106,9 +106,9 @@ public class AAIUriFactory { * @param type * @return */ - public static AAIResourceUri createResourceUri(AAIObjectPlurals type, Object... values) { + public static AAISimplePluralUri createResourceUri(AAIObjectPlurals type, Object... values) { - return new AAISimpleUri(type, values); + return new AAISimplePluralUri(type, values); } } diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/HttpLookupUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/HttpLookupUri.java index 37d21b375e..a0f1962706 100644 --- a/common/src/main/java/org/onap/so/client/aai/entities/uri/HttpLookupUri.java +++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/HttpLookupUri.java @@ -111,8 +111,24 @@ public abstract class HttpLookupUri extends AAISimpleUri implements HttpAwareUri try { if (this.values.length == 1) { String uri = getObjectById(this.values[0]); - Map<String, String> map = getURIKeys(uri); - return super.build(map.values().toArray(values)); + Map<String, String> map = super.getURIKeys(uri); + this.values = map.values().toArray(values); + return super.build(values); + } + } catch (GraphInventoryUriNotFoundException | GraphInventoryPayloadException e) { + throw new GraphInventoryUriComputationException(e); + } + return super.build(); + } + + @Override + public URI locateAndBuild() { + try { + if (this.values.length == 1) { + String uri = getObjectById(this.values[0]); + Map<String, String> map = super.getURIKeys(uri); + this.values = map.values().toArray(values); + return super.build(values); } } catch (GraphInventoryUriNotFoundException | GraphInventoryPayloadException e) { throw new GraphInventoryUriComputationException(e); @@ -155,7 +171,4 @@ public abstract class HttpLookupUri extends AAISimpleUri implements HttpAwareUri } } - - @Override - public abstract URI buildNoNetwork(); } diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/NodesPluralUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/NodesPluralUri.java new file mode 100644 index 0000000000..8545fc96fb --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/NodesPluralUri.java @@ -0,0 +1,19 @@ +package org.onap.so.client.aai.entities.uri; + +import javax.ws.rs.core.UriBuilder; +import org.onap.so.client.aai.AAIObjectPlurals; +import org.onap.so.client.graphinventory.GraphInventoryObjectBase; + +public class NodesPluralUri extends AAISimplePluralUri implements NodesUri { + + private static final long serialVersionUID = -6743170679667245998L; + + protected NodesPluralUri(AAIObjectPlurals type) { + super(type); + } + + @Override + public String getTemplate(GraphInventoryObjectBase type) { + return UriBuilder.fromUri("/nodes").path(type.partialUri()).toTemplate(); + } +} diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/NodesSingleUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/NodesSingleUri.java new file mode 100644 index 0000000000..7274b1f3b9 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/NodesSingleUri.java @@ -0,0 +1,21 @@ +package org.onap.so.client.aai.entities.uri; + +import javax.ws.rs.core.UriBuilder; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.graphinventory.GraphInventoryObjectBase; + +public class NodesSingleUri extends AAISimpleUri implements NodesUri { + + private static final long serialVersionUID = 2721165364903444248L; + + protected NodesSingleUri(AAIObjectType type, Object... values) { + super(type, values); + } + + + @Override + public String getTemplate(GraphInventoryObjectBase type) { + return UriBuilder.fromUri("/nodes").path(type.partialUri()).toTemplate(); + } + +} diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/NodesUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/NodesUri.java index 4b4b5d92a2..6e5fa77f76 100644 --- a/common/src/main/java/org/onap/so/client/aai/entities/uri/NodesUri.java +++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/NodesUri.java @@ -20,32 +20,7 @@ package org.onap.so.client.aai.entities.uri; -import javax.ws.rs.core.UriBuilder; -import org.onap.so.client.aai.AAIObjectPlurals; -import org.onap.so.client.aai.AAIObjectType; -import org.onap.so.client.graphinventory.GraphInventoryObjectPlurals; -import org.onap.so.client.graphinventory.GraphInventoryObjectType; +public interface NodesUri { -public class NodesUri extends AAISimpleUri { - private static final long serialVersionUID = 8818689895730182042L; - - protected NodesUri(AAIObjectType type, Object... values) { - super(type, values); - } - - protected NodesUri(AAIObjectPlurals type) { - super(type); - } - - - @Override - protected String getTemplate(GraphInventoryObjectType type) { - return UriBuilder.fromUri("/nodes").path(type.partialUri()).toTemplate(); - } - - @Override - protected String getTemplate(GraphInventoryObjectPlurals type) { - return UriBuilder.fromUri("/nodes").path(type.partialUri()).toTemplate(); - } } diff --git a/common/src/main/java/org/onap/so/client/dmaap/DmaapConsumer.java b/common/src/main/java/org/onap/so/client/dmaap/DmaapConsumer.java index 4de546e9da..cbad59e968 100644 --- a/common/src/main/java/org/onap/so/client/dmaap/DmaapConsumer.java +++ b/common/src/main/java/org/onap/so/client/dmaap/DmaapConsumer.java @@ -20,12 +20,12 @@ package org.onap.so.client.dmaap; -import com.google.common.base.Stopwatch; import java.io.IOException; import java.util.concurrent.TimeUnit; import org.onap.so.client.dmaap.exceptions.DMaaPConsumerFailure; import org.onap.so.client.dmaap.exceptions.ExceededMaximumPollingTime; import org.onap.so.client.dmaap.rest.RestConsumer; +import com.google.common.base.Stopwatch; public abstract class DmaapConsumer extends DmaapClient { static final int MAX_ELAPSED_TIME = 180000; @@ -40,7 +40,6 @@ public abstract class DmaapConsumer extends DmaapClient { public boolean consume() throws Exception { Consumer mrConsumer = this.getConsumer(); - boolean accepted = false; Stopwatch stopwatch = Stopwatch.createUnstarted(); try { while (this.continuePolling()) { @@ -54,20 +53,17 @@ public abstract class DmaapConsumer extends DmaapClient { Iterable<String> itr = mrConsumer.fetch(); stopwatch.stop(); for (String message : itr) { - if (!accepted && this.isAccepted(message)) { + if (this.isAccepted(message)) { logger.info("accepted message found for " + this.getRequestId() + " on " + this.getTopic()); - accepted = true; } - if (accepted) { - logger.info("received dmaap message: " + message); - if (this.isFailure(message)) { - this.stopProcessingMessages(); - final String errorMsg = "failure received from dmaap topic " + this.getTopic(); - logger.error(errorMsg); - throw new DMaaPConsumerFailure(errorMsg); - } else { - this.processMessage(message); - } + logger.info("received dmaap message: " + message); + if (this.isFailure(message)) { + this.stopProcessingMessages(); + final String errorMsg = "failure received from dmaap topic " + this.getTopic(); + logger.error(errorMsg); + throw new DMaaPConsumerFailure(errorMsg); + } else { + this.processMessage(message); } } } diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryClient.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryClient.java index 98d48ec3a8..09efb5a48d 100644 --- a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryClient.java +++ b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryClient.java @@ -25,6 +25,7 @@ import org.onap.so.client.RestClient; import org.onap.so.client.RestProperties; import org.onap.so.client.RestPropertiesLoader; import org.onap.so.client.graphinventory.entities.uri.GraphInventoryUri; +import org.onap.so.client.graphinventory.entities.uri.HttpAwareUri; public abstract class GraphInventoryClient { @@ -36,9 +37,22 @@ public abstract class GraphInventoryClient { this.props = props; } - protected abstract URI constructPath(GraphInventoryUri uri); + protected abstract URI constructPath(URI uri); + + protected abstract RestClient createClient(URI uri); + + public RestClient createClient(GraphInventoryUri uri) { + final URI result; + if (uri instanceof HttpAwareUri) { + result = ((HttpAwareUri) uri).locateAndBuild(); + } else { + result = uri.build(); + } + + return createClient(result); + + } - public abstract RestClient createClient(GraphInventoryUri uri); public <T extends RestProperties> T getRestProperties() { if (props == null) { diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectBase.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectBase.java new file mode 100644 index 0000000000..72de833884 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectBase.java @@ -0,0 +1,9 @@ +package org.onap.so.client.graphinventory; + +public interface GraphInventoryObjectBase + extends GraphInventoryObjectName, GraphInventoryObjectUriTemplate, GraphInventoryObjectUriPartial { + + public default boolean passThrough() { + return false; + } +} diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectPlurals.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectPlurals.java index 42f4733e47..84604a76cf 100644 --- a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectPlurals.java +++ b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectPlurals.java @@ -20,7 +20,8 @@ package org.onap.so.client.graphinventory; -public interface GraphInventoryObjectPlurals - extends GraphInventoryObjectName, GraphInventoryObjectUriTemplate, GraphInventoryObjectUriPartial { +public interface GraphInventoryObjectPlurals extends GraphInventoryObjectBase { + + public GraphInventoryObjectType getType(); } diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectType.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectType.java index c11a08e867..d09a83a644 100644 --- a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectType.java +++ b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectType.java @@ -20,7 +20,6 @@ package org.onap.so.client.graphinventory; -public interface GraphInventoryObjectType - extends GraphInventoryObjectName, GraphInventoryObjectUriTemplate, GraphInventoryObjectUriPartial { +public interface GraphInventoryObjectType extends GraphInventoryObjectBase { } diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryResourcesClient.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryResourcesClient.java index c7cdb2ff58..f446e5ac4c 100644 --- a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryResourcesClient.java +++ b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryResourcesClient.java @@ -21,6 +21,11 @@ package org.onap.so.client.graphinventory; import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.Arrays; +import java.util.List; import java.util.Map; import java.util.Optional; import javax.ws.rs.NotFoundException; @@ -32,9 +37,13 @@ import org.onap.so.client.RestClient; import org.onap.so.client.RestProperties; import org.onap.so.client.graphinventory.entities.GraphInventoryEdgeLabel; import org.onap.so.client.graphinventory.entities.GraphInventoryResultWrapper; +import org.onap.so.client.graphinventory.entities.uri.GraphInventoryPluralResourceUri; import org.onap.so.client.graphinventory.entities.uri.GraphInventoryResourceUri; +import org.onap.so.client.graphinventory.entities.uri.GraphInventorySingleResourceUri; +import org.onap.so.client.graphinventory.entities.uri.HttpAwareUri; +import org.onap.so.client.graphinventory.exceptions.GraphInventoryMultipleItemsException; -public abstract class GraphInventoryResourcesClient<Self, Uri extends GraphInventoryResourceUri, EdgeLabel extends GraphInventoryEdgeLabel, Wrapper extends GraphInventoryResultWrapper, TransactionalClient, SingleTransactionClient> { +public abstract class GraphInventoryResourcesClient<Self, Uri extends GraphInventoryResourceUri<?, ?>, SingleUri extends GraphInventorySingleResourceUri<?, ?, ?, ?>, PluralUri extends GraphInventoryPluralResourceUri<?, ?>, EdgeLabel extends GraphInventoryEdgeLabel, Wrapper extends GraphInventoryResultWrapper, TransactionalClient, SingleTransactionClient> { protected GraphInventoryClient client; @@ -49,7 +58,7 @@ public abstract class GraphInventoryResourcesClient<Self, Uri extends GraphInven * @param uri * @return */ - public void create(Uri uri, Object obj) { + public void create(SingleUri uri, Object obj) { RestClient giRC = client.createClient(uri); giRC.put(obj); } @@ -60,7 +69,7 @@ public abstract class GraphInventoryResourcesClient<Self, Uri extends GraphInven * @param uri * @return */ - public void createEmpty(Uri uri) { + public void createEmpty(SingleUri uri) { RestClient giRC = client.createClient(uri); giRC.put(""); } @@ -72,7 +81,7 @@ public abstract class GraphInventoryResourcesClient<Self, Uri extends GraphInven * @return */ public boolean exists(Uri uri) { - GraphInventoryResourceUri forceMinimal = uri.clone(); + GraphInventoryResourceUri<?, ?> forceMinimal = (Uri) uri.clone(); forceMinimal.format(Format.COUNT); forceMinimal.limit(1); try { @@ -91,8 +100,8 @@ public abstract class GraphInventoryResourcesClient<Self, Uri extends GraphInven * @param uriB * @return */ - public void connect(Uri uriA, Uri uriB) { - GraphInventoryResourceUri uriAClone = uriA.clone(); + public void connect(SingleUri uriA, SingleUri uriB) { + GraphInventorySingleResourceUri<?, ?, ?, ?> uriAClone = (SingleUri) uriA.clone(); RestClient giRC = client.createClient(uriAClone.relationshipAPI()); giRC.put(this.buildRelationship(uriB)); } @@ -105,8 +114,8 @@ public abstract class GraphInventoryResourcesClient<Self, Uri extends GraphInven * @param edge label * @return */ - public void connect(Uri uriA, Uri uriB, EdgeLabel label) { - GraphInventoryResourceUri uriAClone = uriA.clone(); + public void connect(SingleUri uriA, SingleUri uriB, EdgeLabel label) { + GraphInventorySingleResourceUri<?, ?, ?, ?> uriAClone = (SingleUri) uriA.clone(); RestClient giRC = client.createClient(uriAClone.relationshipAPI()); giRC.put(this.buildRelationship(uriB, label)); } @@ -118,8 +127,8 @@ public abstract class GraphInventoryResourcesClient<Self, Uri extends GraphInven * @param uriB * @return */ - public void disconnect(Uri uriA, Uri uriB) { - GraphInventoryResourceUri uriAClone = uriA.clone(); + public void disconnect(SingleUri uriA, SingleUri uriB) { + GraphInventorySingleResourceUri<?, ?, ?, ?> uriAClone = (SingleUri) uriA.clone(); RestClient giRC = client.createClient(uriAClone.relationshipAPI()); giRC.delete(this.buildRelationship(uriB)); } @@ -130,8 +139,8 @@ public abstract class GraphInventoryResourcesClient<Self, Uri extends GraphInven * @param uri * @return */ - public void delete(Uri uri) { - GraphInventoryResourceUri clone = uri.clone(); + public void delete(SingleUri uri) { + GraphInventorySingleResourceUri<?, ?, ?, ?> clone = (SingleUri) uri.clone(); RestClient giRC = client.createClient(clone); Map<String, Object> result = giRC.get(new GenericType<Map<String, Object>>() {}).orElseThrow( () -> new NotFoundException(clone.build() + " does not exist in " + client.getGraphDBName())); @@ -145,7 +154,7 @@ public abstract class GraphInventoryResourcesClient<Self, Uri extends GraphInven * @param uri * @return */ - public void update(Uri uri, Object obj) { + public void update(SingleUri uri, Object obj) { RestClient giRC = client.createClient(uri); giRC.patch(obj); } @@ -206,6 +215,88 @@ public abstract class GraphInventoryResourcesClient<Self, Uri extends GraphInven } } + public <T, R> Optional<R> getOne(Class<T> pluralClass, Class<R> resultClass, PluralUri uri) { + Optional<List<R>> result = unwrapPlural(pluralClass, resultClass, uri); + + if (result.isPresent()) { + if (result.get().size() == 1) { + return Optional.of(result.get().get(0)); + } else { + throw new GraphInventoryMultipleItemsException(result.get().size(), uri); + } + } + + return Optional.empty(); + } + + public <T, R> Optional<R> getFirst(Class<T> pluralClass, Class<R> resultClass, PluralUri uri) { + Optional<List<R>> result = unwrapPlural(pluralClass, resultClass, uri); + + if (result.isPresent() && !result.get().isEmpty()) { + return Optional.of(result.get().get(0)); + } + + return Optional.empty(); + } + + public <T, R> Optional<Wrapper> getFirstWrapper(Class<T> pluralClass, Class<R> resultClass, PluralUri uri) { + + Optional<R> result = getFirst(pluralClass, resultClass, uri); + if (result.isPresent()) { + return Optional.of(this.createWrapper(result.get())); + } else { + return Optional.empty(); + } + } + + public <T, R> Optional<Wrapper> getOneWrapper(Class<T> pluralClass, Class<R> resultClass, PluralUri uri) { + + Optional<R> result = getOne(pluralClass, resultClass, uri); + if (result.isPresent()) { + return Optional.of(this.createWrapper(result.get())); + } else { + return Optional.empty(); + } + } + + protected <T, R> Optional<List<R>> unwrapPlural(Class<T> pluralClass, Class<R> resultClass, PluralUri uri) { + try { + PluralUri clone = (PluralUri) uri.clone().limit(1); + Optional<T> obj = client.createClient(clone).get(pluralClass); + if (obj.isPresent()) { + Optional<Method> listMethod = Arrays.stream(obj.get().getClass().getMethods()).filter(method -> { + + Type returnType = method.getGenericReturnType(); + if (returnType instanceof ParameterizedType) { + Type[] types = ((ParameterizedType) returnType).getActualTypeArguments(); + if (types != null && types[0] instanceof Class) { + Class<?> listClass = (Class<?>) types[0]; + return resultClass.equals(listClass); + } + } + + return false; + }).findFirst(); + if (listMethod.isPresent()) { + try { + return Optional.of((List<R>) listMethod.get().invoke(obj.get())); + + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + throw new RuntimeException(e); + } + } + } + return Optional.empty(); + + } catch (NotFoundException e) { + if (this.getRestProperties().mapNotFoundToEmpty()) { + return Optional.empty(); + } else { + throw e; + } + } + } + /** * Retrieves an object from GraphInventory wrapped in a helper class which offer additional features * @@ -269,8 +360,8 @@ public abstract class GraphInventoryResourcesClient<Self, Uri extends GraphInven * @param uri * @return */ - public Self createIfNotExists(Uri uri, Optional<Object> obj) { - if (!this.exists(uri)) { + public Self createIfNotExists(SingleUri uri, Optional<Object> obj) { + if (!this.exists((Uri) uri)) { if (obj.isPresent()) { this.create(uri, obj.get()); } else { @@ -281,17 +372,21 @@ public abstract class GraphInventoryResourcesClient<Self, Uri extends GraphInven return (Self) this; } - protected Relationship buildRelationship(GraphInventoryResourceUri uri) { + protected Relationship buildRelationship(SingleUri uri) { return buildRelationship(uri, Optional.empty()); } - protected Relationship buildRelationship(GraphInventoryResourceUri uri, GraphInventoryEdgeLabel label) { + protected Relationship buildRelationship(SingleUri uri, GraphInventoryEdgeLabel label) { return buildRelationship(uri, Optional.of(label)); } - protected Relationship buildRelationship(GraphInventoryResourceUri uri, Optional<GraphInventoryEdgeLabel> label) { + protected Relationship buildRelationship(SingleUri uri, Optional<GraphInventoryEdgeLabel> label) { final Relationship result = new Relationship(); - result.setRelatedLink(uri.build().toString()); + if (uri instanceof HttpAwareUri) { + result.setRelatedLink(((HttpAwareUri) uri).locateAndBuild().toString()); + } else { + result.setRelatedLink(uri.build().toString()); + } if (label.isPresent()) { result.setRelationshipLabel(label.get().toString()); } @@ -300,6 +395,8 @@ public abstract class GraphInventoryResourcesClient<Self, Uri extends GraphInven public abstract Wrapper createWrapper(String json); + public abstract Wrapper createWrapper(Object json); + /** * Starts a transaction which encloses multiple GraphInventory mutations * diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryTransactionClient.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryTransactionClient.java index 45ac1f741d..3469d73599 100644 --- a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryTransactionClient.java +++ b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryTransactionClient.java @@ -29,11 +29,12 @@ import javax.ws.rs.core.GenericType; import org.onap.aai.domain.yang.Relationship; import org.onap.so.client.graphinventory.entities.GraphInventoryEdgeLabel; import org.onap.so.client.graphinventory.entities.uri.GraphInventoryResourceUri; +import org.onap.so.client.graphinventory.entities.uri.GraphInventorySingleResourceUri; import org.onap.so.client.graphinventory.exceptions.BulkProcessFailed; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public abstract class GraphInventoryTransactionClient<Self, Uri extends GraphInventoryResourceUri, EdgeLabel extends GraphInventoryEdgeLabel> { +public abstract class GraphInventoryTransactionClient<Self, Uri extends GraphInventoryResourceUri<?, ?>, SingleUri extends GraphInventorySingleResourceUri<?, ?, ?, ?>, EdgeLabel extends GraphInventoryEdgeLabel> { protected static Logger logger = LoggerFactory.getLogger(GraphInventoryTransactionClient.class); @@ -50,7 +51,7 @@ public abstract class GraphInventoryTransactionClient<Self, Uri extends GraphInv * @param uri * @return */ - public Self create(Uri uri, Object obj) { + public Self create(SingleUri uri, Object obj) { this.put(uri.build().toString(), obj); incrementActionAmount(); return (Self) this; @@ -62,7 +63,7 @@ public abstract class GraphInventoryTransactionClient<Self, Uri extends GraphInv * @param uri * @return */ - public Self createEmpty(Uri uri) { + public Self createEmpty(SingleUri uri) { this.put(uri.build().toString(), new HashMap<String, String>()); incrementActionAmount(); return (Self) this; @@ -75,8 +76,8 @@ public abstract class GraphInventoryTransactionClient<Self, Uri extends GraphInv * @param uri * @return */ - public Self createIfNotExists(Uri uri, Optional<Object> obj) { - if (!this.exists(uri)) { + public Self createIfNotExists(SingleUri uri, Optional<Object> obj) { + if (!this.exists((Uri) uri)) { if (obj.isPresent()) { this.create(uri, obj.get()); } else { @@ -94,8 +95,8 @@ public abstract class GraphInventoryTransactionClient<Self, Uri extends GraphInv * @param uriB * @return */ - public Self connect(Uri uriA, Uri uriB) { - GraphInventoryResourceUri uriAClone = uriA.clone(); + public Self connect(SingleUri uriA, SingleUri uriB) { + GraphInventorySingleResourceUri uriAClone = uriA.clone(); this.put(uriAClone.relationshipAPI().build().toString(), this.buildRelationship(uriB)); incrementActionAmount(); return (Self) this; @@ -108,8 +109,8 @@ public abstract class GraphInventoryTransactionClient<Self, Uri extends GraphInv * @param uris * @return */ - public Self connect(Uri uriA, List<Uri> uris) { - for (Uri uri : uris) { + public Self connect(SingleUri uriA, List<SingleUri> uris) { + for (SingleUri uri : uris) { this.connect(uriA, uri); } return (Self) this; @@ -122,8 +123,8 @@ public abstract class GraphInventoryTransactionClient<Self, Uri extends GraphInv * @param uris * @return */ - public Self connect(Uri uriA, Uri uriB, EdgeLabel label) { - GraphInventoryResourceUri uriAClone = uriA.clone(); + public Self connect(SingleUri uriA, SingleUri uriB, EdgeLabel label) { + GraphInventorySingleResourceUri uriAClone = uriA.clone(); this.put(uriAClone.relationshipAPI().build().toString(), this.buildRelationship(uriB, label)); return (Self) this; } @@ -135,8 +136,8 @@ public abstract class GraphInventoryTransactionClient<Self, Uri extends GraphInv * @param uris * @return */ - public Self connect(Uri uriA, List<Uri> uris, EdgeLabel label) { - for (Uri uri : uris) { + public Self connect(SingleUri uriA, List<SingleUri> uris, EdgeLabel label) { + for (SingleUri uri : uris) { this.connect(uriA, uri, label); } return (Self) this; @@ -149,8 +150,8 @@ public abstract class GraphInventoryTransactionClient<Self, Uri extends GraphInv * @param uriB * @return */ - public Self disconnect(Uri uriA, Uri uriB) { - GraphInventoryResourceUri uriAClone = uriA.clone(); + public Self disconnect(SingleUri uriA, SingleUri uriB) { + GraphInventorySingleResourceUri uriAClone = uriA.clone(); this.delete(uriAClone.relationshipAPI().build().toString(), this.buildRelationship(uriB)); incrementActionAmount(); return (Self) this; @@ -163,8 +164,8 @@ public abstract class GraphInventoryTransactionClient<Self, Uri extends GraphInv * @param uris * @return */ - public Self disconnect(Uri uriA, List<Uri> uris) { - for (Uri uri : uris) { + public Self disconnect(SingleUri uriA, List<SingleUri> uris) { + for (SingleUri uri : uris) { this.disconnect(uriA, uri); } return (Self) this; @@ -176,8 +177,8 @@ public abstract class GraphInventoryTransactionClient<Self, Uri extends GraphInv * @param uri * @return */ - public Self delete(Uri uri) { - Map<String, Object> result = this.get(new GenericType<Map<String, Object>>() {}, (Uri) uri.clone()) + public Self delete(SingleUri uri) { + Map<String, Object> result = this.get(new GenericType<Map<String, Object>>() {}, (Uri) uri) .orElseThrow(() -> new NotFoundException(uri.build() + " does not exist in " + this.getGraphDBName())); String resourceVersion = (String) result.get("resource-version"); this.delete(uri.resourceVersion(resourceVersion).build().toString()); @@ -223,15 +224,15 @@ public abstract class GraphInventoryTransactionClient<Self, Uri extends GraphInv */ public abstract void execute() throws BulkProcessFailed; - private Relationship buildRelationship(Uri uri) { + private Relationship buildRelationship(SingleUri uri) { return buildRelationship(uri, Optional.empty()); } - private Relationship buildRelationship(Uri uri, EdgeLabel label) { + private Relationship buildRelationship(SingleUri uri, EdgeLabel label) { return buildRelationship(uri, Optional.of(label)); } - private Relationship buildRelationship(Uri uri, Optional<EdgeLabel> label) { + private Relationship buildRelationship(SingleUri uri, Optional<EdgeLabel> label) { final Relationship result = new Relationship(); result.setRelatedLink(uri.build().toString()); if (label.isPresent()) { diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryRelationships.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryRelationships.java index 6703416832..6e7b9c9f08 100644 --- a/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryRelationships.java +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryRelationships.java @@ -30,12 +30,12 @@ import java.util.function.Predicate; import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider; import org.onap.so.client.graphinventory.GraphInventoryObjectName; import org.onap.so.client.graphinventory.GraphInventoryObjectType; -import org.onap.so.client.graphinventory.entities.uri.GraphInventoryResourceUri; +import org.onap.so.client.graphinventory.entities.uri.GraphInventorySingleResourceUri; import org.onap.so.jsonpath.JsonPathUtil; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -public abstract class GraphInventoryRelationships<Wrapper extends GraphInventoryResultWrapper, Uri extends GraphInventoryResourceUri, Type extends GraphInventoryObjectType> { +public abstract class GraphInventoryRelationships<Wrapper extends GraphInventoryResultWrapper<?>, Uri extends GraphInventorySingleResourceUri<?, ?, ?, ?>, Type extends GraphInventoryObjectType> { protected final ObjectMapper mapper; protected Map<String, Object> map; diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryPluralResourceUri.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryPluralResourceUri.java new file mode 100644 index 0000000000..aa09702be8 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryPluralResourceUri.java @@ -0,0 +1,8 @@ +package org.onap.so.client.graphinventory.entities.uri; + +import org.onap.so.client.graphinventory.GraphInventoryObjectBase; + +public interface GraphInventoryPluralResourceUri<T extends GraphInventoryResourceUri<?, ?>, OT extends GraphInventoryObjectBase> + extends GraphInventoryResourceUri<T, OT> { + +} diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryResourceUri.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryResourceUri.java index c579a285d2..64933863d5 100644 --- a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryResourceUri.java +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryResourceUri.java @@ -21,42 +21,11 @@ package org.onap.so.client.graphinventory.entities.uri; import org.onap.so.client.graphinventory.Format; -import org.onap.so.client.graphinventory.entities.uri.Depth; -import org.onap.so.client.graphinventory.GraphInventoryObjectPlurals; -import org.onap.so.client.graphinventory.GraphInventoryObjectType; +import org.onap.so.client.graphinventory.GraphInventoryObjectBase; -public interface GraphInventoryResourceUri extends GraphInventoryUri { - public GraphInventoryResourceUri relationshipAPI(); +public interface GraphInventoryResourceUri<T extends GraphInventoryResourceUri<?, ?>, OT extends GraphInventoryObjectBase> + extends GraphInventoryUri<T, OT> { - public GraphInventoryResourceUri relatedTo(GraphInventoryObjectPlurals plural); + public T format(Format format); - public GraphInventoryResourceUri relatedTo(GraphInventoryObjectType type, String... values); - - public GraphInventoryResourceUri resourceVersion(String version); - - public GraphInventoryResourceUri format(Format format); - - @Override - public GraphInventoryResourceUri depth(Depth depth); - - @Override - public GraphInventoryResourceUri nodesOnly(boolean nodesOnly); - - @Override - public GraphInventoryResourceUri queryParam(String name, String... values); - - @Override - public GraphInventoryResourceUri replaceQueryParam(String name, String... values); - - @Override - public GraphInventoryResourceUri resultIndex(int index); - - @Override - public GraphInventoryResourceUri resultSize(int size); - - @Override - public GraphInventoryResourceUri limit(int size); - - @Override - public GraphInventoryResourceUri clone(); } diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventorySingleResourceUri.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventorySingleResourceUri.java new file mode 100644 index 0000000000..e45ff14a5e --- /dev/null +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventorySingleResourceUri.java @@ -0,0 +1,16 @@ +package org.onap.so.client.graphinventory.entities.uri; + +import org.onap.so.client.graphinventory.GraphInventoryObjectPlurals; +import org.onap.so.client.graphinventory.GraphInventoryObjectType; + +public interface GraphInventorySingleResourceUri<T extends GraphInventorySingleResourceUri<?, ?, ?, ?>, P extends GraphInventoryPluralResourceUri<?, ?>, SingleObject extends GraphInventoryObjectType, PluralObject extends GraphInventoryObjectPlurals> + extends GraphInventoryResourceUri<T, SingleObject> { + + public T resourceVersion(String version); + + public T relationshipAPI(); + + public P relatedTo(PluralObject plural); + + public T relatedTo(SingleObject type, String... values); +} diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryUri.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryUri.java index 6b48ad44ef..e3fda2fa23 100644 --- a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryUri.java +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryUri.java @@ -20,11 +20,15 @@ package org.onap.so.client.graphinventory.entities.uri; +import java.io.Serializable; import java.net.URI; import java.util.Map; +import java.util.regex.Pattern; +import org.onap.so.client.graphinventory.GraphInventoryObjectBase; import org.onap.so.client.graphinventory.GraphInventoryObjectType; -public interface GraphInventoryUri { +public interface GraphInventoryUri<T extends GraphInventoryUri<?, ?>, OT extends GraphInventoryObjectBase> + extends Serializable { public URI build(); @@ -39,26 +43,26 @@ public interface GraphInventoryUri { * @param depth * @return */ - public GraphInventoryUri depth(Depth depth); + public T depth(Depth depth); /** * Makes client only return object fields, no relationships * * @return */ - public GraphInventoryUri nodesOnly(boolean nodesOnly); + public T nodesOnly(boolean nodesOnly); - public GraphInventoryUri queryParam(String name, String... values); + public T queryParam(String name, String... values); - public GraphInventoryUri replaceQueryParam(String name, String... values); + public T replaceQueryParam(String name, String... values); - public GraphInventoryUri resultIndex(int index); + public T resultIndex(int index); - public GraphInventoryUri resultSize(int size); + public T resultSize(int size); - public GraphInventoryUri limit(int size); + public T limit(int size); - public GraphInventoryUri clone(); + public T clone(); /** * returns all key values of the URI as a map. Key names can be found in {@link GraphInventoryObjectType} @@ -67,9 +71,11 @@ public interface GraphInventoryUri { */ public Map<String, String> getURIKeys(); - public GraphInventoryObjectType getObjectType(); + public OT getObjectType(); public boolean equals(Object o); public int hashCode(); + + public Pattern getPrefixPattern(); } diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/HttpAwareUri.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/HttpAwareUri.java index fcfde74b33..1ee3d57b6c 100644 --- a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/HttpAwareUri.java +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/HttpAwareUri.java @@ -21,9 +21,12 @@ package org.onap.so.client.graphinventory.entities.uri; import java.net.URI; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; -public interface HttpAwareUri { +public interface HttpAwareUri extends AAIResourceUri { public URI buildNoNetwork(); + + public URI locateAndBuild(); } diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleBaseUri.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleBaseUri.java new file mode 100644 index 0000000000..fc1a008466 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleBaseUri.java @@ -0,0 +1,237 @@ +package org.onap.so.client.graphinventory.entities.uri; + +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.net.URI; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import javax.ws.rs.core.UriBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import org.onap.so.client.graphinventory.Format; +import org.onap.so.client.graphinventory.GraphInventoryObjectBase; +import org.onap.so.client.graphinventory.entities.uri.parsers.UriParser; +import org.onap.so.client.graphinventory.entities.uri.parsers.UriParserSpringImpl; +import org.onap.so.client.graphinventory.exceptions.IncorrectNumberOfUriKeys; +import org.springframework.web.util.UriUtils; + +public abstract class SimpleBaseUri<T extends GraphInventoryResourceUri<?, ?>, Parent extends GraphInventorySingleResourceUri<?, ?, ?, ?>, S extends GraphInventoryObjectBase> + implements GraphInventoryResourceUri<T, S> { + + private static final long serialVersionUID = -1011069933894179423L; + protected transient UriBuilder internalURI; + protected static final String relationshipAPI = "/relationship-list/relationship"; + protected static final String relatedTo = "/related-to"; + protected Object[] values; + protected final S type; + protected final Parent parentUri; + protected final Map<String, Set<String>> queryParams = new HashMap<>(); + + protected SimpleBaseUri(S type, Object... values) { + this.type = type; + this.internalURI = UriBuilder.fromPath(this.getTemplate(type)); + this.values = values; + this.parentUri = null; + validateValuesSize(this.getTemplate(type), values); + } + + protected SimpleBaseUri(S type, URI uri) { + if (!type.passThrough()) { + this.type = type; + this.internalURI = UriBuilder.fromPath(this.getTemplate(type)); + this.values = + this.getURIKeys(uri.getRawPath().replaceAll(getPrefixPattern().toString(), "")).values().toArray(); + this.parentUri = null; + } else { + this.type = type; + this.internalURI = UriBuilder.fromPath(uri.getRawPath().replaceAll(getPrefixPattern().toString(), "")); + this.values = new Object[0]; + this.parentUri = null; + } + + } + + protected SimpleBaseUri(S type, UriBuilder builder, Object... values) { + this.internalURI = builder; + this.values = values; + this.type = type; + this.parentUri = null; + + } + + protected SimpleBaseUri(Parent parentUri, S childType, Object... childValues) { + this.type = childType; + this.internalURI = UriBuilder.fromUri(type.partialUri()); + this.values = childValues; + this.parentUri = parentUri; + + validateValuesSize(childType.partialUri(), values); + } + + protected SimpleBaseUri(SimpleBaseUri<T, Parent, S> copy) { + this.type = copy.type; + this.internalURI = copy.internalURI.clone(); + this.values = copy.values.clone(); + if (copy.parentUri != null) { + this.parentUri = (Parent) copy.parentUri.clone(); + } else { + this.parentUri = null; + } + } + + protected void setInternalURI(UriBuilder builder) { + this.internalURI = builder; + } + + @Override + public T queryParam(String name, String... values) { + this.internalURI = internalURI.queryParam(name, values); + if (queryParams.containsKey(name)) { + queryParams.get(name).addAll(Arrays.asList(values)); + } else { + queryParams.put(name, Stream.of(values).collect(Collectors.toSet())); + } + return (T) this; + } + + @Override + public T replaceQueryParam(String name, String... values) { + this.internalURI = internalURI.replaceQueryParam(name, values); + queryParams.put(name, Stream.of(values).collect(Collectors.toSet())); + return (T) this; + } + + @Override + public T resultIndex(int index) { + this.internalURI = internalURI.replaceQueryParam("resultIndex", index); + return (T) this; + } + + @Override + public T resultSize(int size) { + this.internalURI = internalURI.replaceQueryParam("resultSize", size); + return (T) this; + } + + @Override + public T limit(int size) { + this.resultIndex(0).resultSize(size); + return (T) this; + } + + @Override + public URI build() { + return build(this.values); + } + + protected URI build(Object... values) { + + // This is a workaround because resteasy does not encode URIs correctly + final String[] encoded = new String[values.length]; + for (int i = 0; i < values.length; i++) { + encoded[i] = UriUtils.encode(values[i].toString(), StandardCharsets.UTF_8.toString()); + } + if (this.parentUri != null) { + return UriBuilder + .fromUri(this.parentUri.build().toString() + internalURI.buildFromEncoded(encoded).toString()) + .build(); + } else { + return internalURI.buildFromEncoded(encoded); + } + } + + @Override + public Map<String, String> getURIKeys() { + return this.getURIKeys(this.build().toString()); + } + + protected Map<String, String> getURIKeys(String uri) { + UriParser parser; + if (!("".equals(this.getTemplate(type)))) { + parser = new UriParserSpringImpl(this.getTemplate(type)); + } else { + return new HashMap<>(); + } + + + return parser.parse(uri); + } + + @Override + public abstract T clone(); + + @Override + public S getObjectType() { + return this.type; + } + + @Override + public boolean equals(Object o) { + if (o != null) { + return this.toString().equals(o.toString()); + } + return false; + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(this.toString()).toHashCode(); + } + + + @Override + public T depth(Depth depth) { + this.internalURI.replaceQueryParam("depth", depth.toString()); + return (T) this; + } + + @Override + public T nodesOnly(boolean nodesOnly) { + if (nodesOnly) { + this.internalURI.replaceQueryParam("nodes-only", ""); + } + return (T) this; + } + + @Override + public T format(Format format) { + this.internalURI.replaceQueryParam("format", format); + return (T) this; + } + + public void validateValuesSize(String template, Object... values) { + UriParser parser = new UriParserSpringImpl(template); + Set<String> variables = parser.getVariables(); + if (variables.size() != values.length) { + throw new IncorrectNumberOfUriKeys(String.format("Expected %s variables: %s", variables.size(), variables)); + } + } + + protected String getTemplate(GraphInventoryObjectBase type) { + return type.uriTemplate(); + } + + private void writeObject(ObjectOutputStream oos) throws IOException { + oos.defaultWriteObject(); + oos.writeUTF(this.internalURI.toTemplate()); + } + + private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException { + ois.defaultReadObject(); + String uri = ois.readUTF(); + this.setInternalURI(UriBuilder.fromUri(uri)); + } + + @Override + public String toString() { + return new ToStringBuilder(null, ToStringStyle.NO_CLASS_NAME_STYLE).append("type", type) + .append("parentUri", parentUri).append("values", values).append("queryParams", queryParams).toString(); + } +} diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimplePluralUri.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimplePluralUri.java new file mode 100644 index 0000000000..c0b6d573c1 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimplePluralUri.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.client.graphinventory.entities.uri; + +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import javax.ws.rs.core.UriBuilder; +import org.onap.so.client.graphinventory.GraphInventoryObjectPlurals; +import org.onap.so.client.graphinventory.GraphInventoryObjectType; + +public abstract class SimplePluralUri<T extends GraphInventoryPluralResourceUri<?, ?>, Parent extends GraphInventorySingleResourceUri<?, ?, ?, ?>, PT extends GraphInventoryObjectPlurals, OT extends GraphInventoryObjectType> + extends SimpleBaseUri<T, Parent, PT> implements GraphInventoryPluralResourceUri<T, PT>, Serializable { + + private static final long serialVersionUID = -337701171277616439L; + + protected final PT pluralType; + + protected SimplePluralUri(PT type, UriBuilder builder, Object... values) { + super(type, builder, values); + this.pluralType = type; + } + + protected SimplePluralUri(PT type) { + super(type, new Object[0]); + this.pluralType = type; + } + + protected SimplePluralUri(PT type, Object... values) { + super(type, values); + this.pluralType = type; + } + + protected SimplePluralUri(Parent parentUri, PT childType) { + super(parentUri, childType, new Object[0]); + this.pluralType = childType; + } + + public SimplePluralUri(SimplePluralUri<T, Parent, PT, OT> copy) { + super(copy); + this.pluralType = copy.pluralType; + } + + protected void setInternalURI(UriBuilder builder) { + this.internalURI = builder; + } + + private void writeObject(ObjectOutputStream oos) throws IOException { + oos.defaultWriteObject(); + oos.writeUTF(this.internalURI.toTemplate()); + } + + private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException { + ois.defaultReadObject(); + String uri = ois.readUTF(); + this.setInternalURI(UriBuilder.fromUri(uri)); + } +} diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java index ffe47c5c51..aff7392efe 100644 --- a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java @@ -23,254 +23,50 @@ package org.onap.so.client.graphinventory.entities.uri; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import java.io.Serializable; import java.net.URI; -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.regex.Pattern; import javax.ws.rs.core.UriBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; -import org.onap.so.client.graphinventory.Format; import org.onap.so.client.graphinventory.GraphInventoryObjectPlurals; import org.onap.so.client.graphinventory.GraphInventoryObjectType; -import org.onap.so.client.graphinventory.entities.uri.parsers.UriParser; -import org.onap.so.client.graphinventory.entities.uri.parsers.UriParserSpringImpl; -import org.onap.so.client.graphinventory.exceptions.IncorrectNumberOfUriKeys; -import org.springframework.web.util.UriUtils; -public class SimpleUri implements GraphInventoryResourceUri, Serializable { +public abstract class SimpleUri<T extends GraphInventorySingleResourceUri<?, ?, ?, ?>, PT extends GraphInventoryPluralResourceUri<?, ?>, S extends GraphInventoryObjectType, P extends GraphInventoryObjectPlurals> + extends SimpleBaseUri<T, T, S> implements GraphInventorySingleResourceUri<T, PT, S, P> { private static final long serialVersionUID = -337701171277616439L; - - protected transient UriBuilder internalURI; protected static final String relationshipAPI = "/relationship-list/relationship"; protected static final String relatedTo = "/related-to"; - protected final Object[] values; - protected final GraphInventoryObjectType type; - protected final GraphInventoryObjectPlurals pluralType; - - protected SimpleUri(GraphInventoryObjectType type, Object... values) { - this.type = type; - this.pluralType = null; - this.internalURI = UriBuilder.fromPath(this.getTemplate(type)); - this.values = values; - validateValuesSize(this.getTemplate(type), values); - } - - protected SimpleUri(GraphInventoryObjectType type, URI uri) { - this.type = type; - this.pluralType = null; - this.internalURI = UriBuilder.fromPath(uri.getRawPath().replaceAll(getPrefixPattern().toString(), "")); - this.values = new Object[0]; - } - protected SimpleUri(GraphInventoryObjectType type, UriBuilder builder, Object... values) { - this.internalURI = builder; - this.values = values; - this.type = type; - this.pluralType = null; + protected SimpleUri(S type, Object... values) { + super(type, values); } - protected SimpleUri(GraphInventoryObjectPlurals type, UriBuilder builder, Object... values) { - this.internalURI = builder; - this.values = values; - this.type = null; - this.pluralType = type; - } + protected SimpleUri(S type, URI uri) { + super(type, uri); - protected SimpleUri(GraphInventoryObjectPlurals type) { - this.type = null; - this.pluralType = type; - this.internalURI = UriBuilder.fromPath(this.getTemplate(type)); - this.values = new Object[0]; } - protected SimpleUri(GraphInventoryObjectPlurals type, Object... values) { - this.type = null; - this.pluralType = type; - this.internalURI = UriBuilder.fromPath(this.getTemplate(type)); - this.values = values; - validateValuesSize(this.getTemplate(type), values); - } + protected SimpleUri(S type, UriBuilder builder, Object... values) { + super(type, builder, values); - protected SimpleUri(GraphInventoryResourceUri parentUri, GraphInventoryObjectType childType, - Object... childValues) { - this.type = childType; - this.pluralType = null; - this.internalURI = UriBuilder.fromUri(parentUri.build()).path(childType.partialUri()); - this.values = childValues; - validateValuesSize(childType.partialUri(), values); } - protected SimpleUri(GraphInventoryResourceUri parentUri, GraphInventoryObjectPlurals childType) { - this.type = null; - this.pluralType = childType; - this.internalURI = UriBuilder.fromUri(parentUri.build()).path(childType.partialUri()); - this.values = new Object[0]; + protected SimpleUri(T parentUri, S childType, Object... childValues) { + super(parentUri, childType, childValues); } - protected void setInternalURI(UriBuilder builder) { - this.internalURI = builder; + protected SimpleUri(SimpleBaseUri<T, T, S> copy) { + super(copy); } @Override - public SimpleUri relationshipAPI() { - this.internalURI = internalURI.path(relationshipAPI); - return this; - } - - @Override - public SimpleUri relatedTo(GraphInventoryObjectPlurals plural) { - - this.internalURI = internalURI.path(relatedTo).path(plural.partialUri()); - return this; - } - - @Override - public SimpleUri relatedTo(GraphInventoryObjectType type, String... values) { - this.internalURI = - internalURI.path(relatedTo).path(UriBuilder.fromPath(type.partialUri()).build(values).toString()); - return this; - } - - @Override - public SimpleUri resourceVersion(String version) { + public T resourceVersion(String version) { this.internalURI = internalURI.replaceQueryParam("resource-version", version); - return this; - } - - @Override - public SimpleUri queryParam(String name, String... values) { - this.internalURI = internalURI.queryParam(name, values); - return this; - } - - @Override - public SimpleUri replaceQueryParam(String name, String... values) { - this.internalURI = internalURI.replaceQueryParam(name, values); - return this; - } - - @Override - public SimpleUri resultIndex(int index) { - this.internalURI = internalURI.replaceQueryParam("resultIndex", index); - return this; - } - - @Override - public SimpleUri resultSize(int size) { - this.internalURI = internalURI.replaceQueryParam("resultSize", size); - return this; - } - - @Override - public SimpleUri limit(int size) { - return this.resultIndex(0).resultSize(size); - } - - @Override - public URI build() { - return build(this.values); - } - - protected Pattern getPrefixPattern() { - return Pattern.compile("/.*?/v\\d+"); - } - - protected URI build(Object... values) { - // This is a workaround because resteasy does not encode URIs correctly - final String[] encoded = new String[values.length]; - for (int i = 0; i < values.length; i++) { - encoded[i] = UriUtils.encode(values[i].toString(), StandardCharsets.UTF_8.toString()); - } - return internalURI.buildFromEncoded(encoded); - } - - @Override - public Map<String, String> getURIKeys() { - return this.getURIKeys(this.build().toString()); - } - - protected Map<String, String> getURIKeys(String uri) { - UriParser parser; - if (this.type != null) { - if (!("".equals(this.getTemplate(type)))) { - parser = new UriParserSpringImpl(this.getTemplate(type)); - } else { - return new HashMap<>(); - } - } else { - parser = new UriParserSpringImpl(this.getTemplate(pluralType)); - } - - - return parser.parse(uri); - } - - @Override - public SimpleUri clone() { - if (this.type != null) { - return new SimpleUri(this.type, this.internalURI.clone(), values); - } else { - return new SimpleUri(this.pluralType, this.internalURI.clone(), values); - } - } - - @Override - public GraphInventoryObjectType getObjectType() { - return this.type; - } - - @Override - public boolean equals(Object o) { - if (o instanceof GraphInventoryUri) { - return this.build().equals(((GraphInventoryUri) o).build()); - } - return false; + return (T) this; } @Override - public int hashCode() { - return new HashCodeBuilder().append(this.build()).toHashCode(); - } - - - @Override - public SimpleUri depth(Depth depth) { - this.internalURI.replaceQueryParam("depth", depth.toString()); - return this; - } - - @Override - public SimpleUri nodesOnly(boolean nodesOnly) { - if (nodesOnly) { - this.internalURI.replaceQueryParam("nodes-only", ""); - } - return this; - } - - @Override - public SimpleUri format(Format format) { - this.internalURI.replaceQueryParam("format", format); - return this; - } - - public void validateValuesSize(String template, Object... values) { - UriParser parser = new UriParserSpringImpl(template); - Set<String> variables = parser.getVariables(); - if (variables.size() != values.length) { - throw new IncorrectNumberOfUriKeys(String.format("Expected %s variables: %s", variables.size(), variables)); - } - } - - protected String getTemplate(GraphInventoryObjectType type) { - return type.uriTemplate(); - } - - protected String getTemplate(GraphInventoryObjectPlurals type) { - return type.uriTemplate(); + public T relationshipAPI() { + this.internalURI = internalURI.path(relationshipAPI); + return (T) this; } private void writeObject(ObjectOutputStream oos) throws IOException { @@ -283,4 +79,5 @@ public class SimpleUri implements GraphInventoryResourceUri, Serializable { String uri = ois.readUTF(); this.setInternalURI(UriBuilder.fromUri(uri)); } + } diff --git a/common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryMultipleItemsException.java b/common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryMultipleItemsException.java new file mode 100644 index 0000000000..d3c17ce9e9 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryMultipleItemsException.java @@ -0,0 +1,13 @@ +package org.onap.so.client.graphinventory.exceptions; + +import org.onap.so.client.graphinventory.entities.uri.GraphInventoryPluralResourceUri; + +public class GraphInventoryMultipleItemsException extends RuntimeException { + + private static final long serialVersionUID = -1596266941681036917L; + + public GraphInventoryMultipleItemsException(int size, GraphInventoryPluralResourceUri uri) { + super(String.format("Found %s objects at %s when we only expected to find one.", size, uri.build())); + } + +} diff --git a/common/src/main/java/org/onap/so/constants/OrchestrationRequestFormat.java b/common/src/main/java/org/onap/so/constants/OrchestrationRequestFormat.java index 641bbb28c7..141352edce 100644 --- a/common/src/main/java/org/onap/so/constants/OrchestrationRequestFormat.java +++ b/common/src/main/java/org/onap/so/constants/OrchestrationRequestFormat.java @@ -21,5 +21,5 @@ package org.onap.so.constants; public enum OrchestrationRequestFormat { - DETAIL, STATUSDETAIL, SIMPLE + DETAIL, STATUSDETAIL, SIMPLE, SIMPLENOTASKINFO } diff --git a/common/src/main/java/org/onap/so/db/connections/ScheduledDnsLookup.java b/common/src/main/java/org/onap/so/db/connections/ScheduledDnsLookup.java index 40acac57aa..725da97d5b 100644 --- a/common/src/main/java/org/onap/so/db/connections/ScheduledDnsLookup.java +++ b/common/src/main/java/org/onap/so/db/connections/ScheduledDnsLookup.java @@ -8,11 +8,9 @@ import javax.management.JMX; import javax.management.MBeanServer; import javax.management.ObjectInstance; import javax.management.ObjectName; -import org.jboss.logging.MDC; -import org.onap.logging.filter.base.ONAPComponents; -import org.onap.logging.ref.slf4j.ONAPLogConstants; -import org.onap.so.logger.ErrorCode; -import org.onap.so.logger.ScheduledTasksMDCSetup; +import org.onap.logging.filter.base.ErrorCode; +import org.onap.logging.filter.base.ScheduledLogging; +import org.onap.logging.filter.base.ScheduledTaskException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -32,23 +30,16 @@ public class ScheduledDnsLookup { @Autowired private DbDnsIpAddress dnsIpAddress; - @Autowired - private ScheduledTasksMDCSetup scheduledMDCSetup; - private static Logger logger = LoggerFactory.getLogger(ScheduledDnsLookup.class); + @ScheduledLogging @Scheduled(fixedRate = 15000) - public void performDnsLookup() { - scheduledMDCSetup.mdcSetup(ONAPComponents.SO, "performDnsLookup"); + public void performDnsLookup() throws ScheduledTaskException { String dnsUrl = System.getenv(DB_HOST); - try { if (dnsUrl == null) { - scheduledMDCSetup.errorMDCSetup(ErrorCode.DataError, "Database DNS is not provided."); - logger.error("Database DNS is not provided. Please verify the configuration"); - MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.ERROR.toString()); - scheduledMDCSetup.exitAndClearMDC(); - return; + throw new ScheduledTaskException(ErrorCode.DataError, + "Database DNS is not provided. Please verify the configuration"); } InetAddress inetAddress = java.net.InetAddress.getByName(dnsUrl); @@ -57,7 +48,6 @@ public class ScheduledDnsLookup { /* This is in initial state */ if (currentIpAddress == null) { dnsIpAddress.setIpAddress(ipAddress); - scheduledMDCSetup.exitAndClearMDC(); return; } @@ -69,7 +59,6 @@ public class ScheduledDnsLookup { } catch (UnknownHostException e) { logger.warn("Database DNS %s is not resolvable to an IP Address", dnsUrl); } - scheduledMDCSetup.exitAndClearMDC(); } private void softEvictConnectionPool() { diff --git a/common/src/main/java/org/onap/so/logger/ScheduledTasksMDCSetup.java b/common/src/main/java/org/onap/so/logger/ScheduledTasksMDCSetup.java deleted file mode 100644 index 41c4b4bfae..0000000000 --- a/common/src/main/java/org/onap/so/logger/ScheduledTasksMDCSetup.java +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. 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.logger; - -import java.util.UUID; -import org.onap.logging.filter.base.Constants; -import org.onap.logging.filter.base.MDCSetup; -import org.onap.logging.filter.base.ONAPComponentsList; -import org.onap.logging.ref.slf4j.ONAPLogConstants; -import org.slf4j.MDC; -import org.springframework.stereotype.Component; - -@Component -public class ScheduledTasksMDCSetup extends MDCSetup { - - public void mdcSetup(ONAPComponentsList targetEntity, String serviceName) { - try { - setEntryTimeStamp(); - setServerFQDN(); - MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.INPROGRESS.toString()); - MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, UUID.randomUUID().toString()); - MDC.put(ONAPLogConstants.MDCs.TARGET_ENTITY, targetEntity.toString()); - MDC.put(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME, Constants.DefaultValues.UNKNOWN); - MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, serviceName); - setLogTimestamp(); - setElapsedTime(); - MDC.put(ONAPLogConstants.MDCs.PARTNER_NAME, getProperty(Constants.Property.PARTNER_NAME)); - logger.info(ONAPLogConstants.Markers.ENTRY, "Entering"); - } catch (Exception e) { - logger.warn("Error in ScheduledTasksMDCSetup mdcSetup: {}", e.getMessage()); - } - } - - public void errorMDCSetup(ErrorCode errorCode, String errorDescription) { - MDC.put(ONAPLogConstants.MDCs.ERROR_CODE, String.valueOf(errorCode.getValue())); - MDC.put(ONAPLogConstants.MDCs.ERROR_DESC, errorDescription); - } - - public void exitAndClearMDC() { - try { - setStatusCode(); - setLogTimestamp(); - setElapsedTime(); - logger.info(ONAPLogConstants.Markers.EXIT, "Exiting."); - } catch (Exception e) { - logger.warn("Error in ScheduledTasksMDCSetup clear MDC: {}", e.getMessage()); - } - MDC.clear(); - } - - public void setStatusCode() { - String currentStatusCode = MDC.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE); - if (currentStatusCode == null || !currentStatusCode.equals(ONAPLogConstants.ResponseStatus.ERROR.toString())) { - MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.COMPLETE.toString()); - } - } -} diff --git a/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOAuditLogContainerFilter.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOAuditLogContainerFilter.java index 5ae1082464..3e85cc5ec6 100644 --- a/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOAuditLogContainerFilter.java +++ b/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOAuditLogContainerFilter.java @@ -3,6 +3,7 @@ package org.onap.so.logging.jaxrs.filter; import javax.annotation.Priority; import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.container.ContainerResponseContext; +import javax.ws.rs.container.PreMatching; import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.logger.HttpHeadersConstants; import org.onap.so.logger.LogConstants; @@ -11,6 +12,7 @@ import org.springframework.stereotype.Component; import org.onap.logging.filter.base.AuditLogContainerFilter; @Priority(1) +@PreMatching @Component public class SOAuditLogContainerFilter extends AuditLogContainerFilter { @@ -26,9 +28,4 @@ public class SOAuditLogContainerFilter extends AuditLogContainerFilter { } MDC.put(LogConstants.URI_BASE, request.getUriInfo().getBaseUri().toString()); } - - @Override - protected void additionalPostHandling(ContainerResponseContext response) { - // override to add additional post handling - } } diff --git a/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProvider.java b/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProvider.java index 69046a2eba..4434dce4e3 100644 --- a/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProvider.java +++ b/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProvider.java @@ -21,6 +21,7 @@ package org.onap.so.rest.service; import com.google.common.base.Optional; +import org.springframework.http.HttpHeaders; import org.springframework.http.ResponseEntity; /** @@ -39,6 +40,16 @@ public interface HttpRestServiceProvider { /** * Execute the HTTP GET to the given URI template + * + * @param url the URL + * @param headers request headers + * @param clazz the type of the return value + * @return Returns the body of this entity. + */ + <T> Optional<T> get(final String url, final HttpHeaders headers, final Class<T> clazz); + + /** + * Execute the HTTP GET to the given URI template * * @param url the URL * @param clazz the type of the return value @@ -46,6 +57,15 @@ public interface HttpRestServiceProvider { */ <T> ResponseEntity<T> getHttpResponse(final String url, final Class<T> clazz); + /** + * Execute the HTTP GET to the given URI template + * + * @param url the URL + * @param headers request headers + * @param clazz the type of the return value + * @return Returns the {@link ResponseEntity}. + */ + <T> ResponseEntity<T> getHttpResponse(final String url, final HttpHeaders headers, final Class<T> clazz); /** * Execute the HTTP POST to the given URI template @@ -68,6 +88,18 @@ public interface HttpRestServiceProvider { <T> ResponseEntity<T> postHttpRequest(final Object object, final String url, final Class<T> clazz); /** + * Execute the HTTP POST to the given URI template + * + * @param object the entity (i.e. body) to write to the request + * @param url the URL + * @param clazz the type of the return value + * @param headers request headers + * @return Returns the {@link ResponseEntity}. + */ + <T> ResponseEntity<T> postHttpRequest(final Object object, final String url, final HttpHeaders headers, + final Class<T> clazz); + + /** * Execute the HTTP PUT to the given URI template * * @param object the entity (i.e. body) to write to the request diff --git a/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java b/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java index b82d73bbbf..04dd0bbb7a 100644 --- a/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java +++ b/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java @@ -20,8 +20,6 @@ package org.onap.so.rest.service; -import com.google.common.base.Optional; -import org.onap.so.configuration.rest.BasicHttpHeadersProvider; import org.onap.so.configuration.rest.HttpHeadersProvider; import org.onap.so.rest.exceptions.HttpResouceNotFoundException; import org.onap.so.rest.exceptions.InvalidRestRequestException; @@ -36,6 +34,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.client.HttpStatusCodeException; import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestTemplate; +import com.google.common.base.Optional; /** * A Service to perform HTTP requests @@ -46,16 +45,27 @@ public class HttpRestServiceProviderImpl implements HttpRestServiceProvider { private static final Logger LOGGER = LoggerFactory.getLogger(HttpRestServiceProviderImpl.class); private final RestTemplate restTemplate; - private final HttpHeadersProvider httpHeadersProvider; + private final HttpHeaders defaultHttpHeaders; public HttpRestServiceProviderImpl(final RestTemplate restTemplate) { this.restTemplate = restTemplate; - this.httpHeadersProvider = new BasicHttpHeadersProvider(); + this.defaultHttpHeaders = new HttpHeaders(); } + public HttpRestServiceProviderImpl(final RestTemplate restTemplate, final HttpHeaders defaultHttpHeaders) { + this.restTemplate = restTemplate; + this.defaultHttpHeaders = defaultHttpHeaders; + } + + /** + * + * @deprecated this constructor is deprecated in favor of using {@link HttpRestServiceProviderImpl(RestTemplate + * restTemplate, HttpHeaders defaultHttpHeaders)} + */ + @Deprecated public HttpRestServiceProviderImpl(final RestTemplate restTemplate, final HttpHeadersProvider httpHeadersProvider) { this.restTemplate = restTemplate; - this.httpHeadersProvider = httpHeadersProvider; + this.defaultHttpHeaders = httpHeadersProvider.getHttpHeaders(); } @Override @@ -64,10 +74,21 @@ public class HttpRestServiceProviderImpl implements HttpRestServiceProvider { return createOptional(response, url, HttpMethod.GET); } + @Override + public <T> Optional<T> get(final String url, final HttpHeaders headers, final Class<T> clazz) { + final ResponseEntity<T> response = invokeHttpRequest(new HttpEntity<>(headers), HttpMethod.GET, url, clazz); + return createOptional(response, url, HttpMethod.GET); + } @Override public <T> ResponseEntity<T> getHttpResponse(final String url, final Class<T> clazz) { - final HttpEntity<?> request = new HttpEntity<>(getHttpHeaders()); + final HttpEntity<?> request = new HttpEntity<>(getDefaultHttpHeaders()); + return invokeHttpRequest(request, HttpMethod.GET, url, clazz); + } + + @Override + public <T> ResponseEntity<T> getHttpResponse(final String url, final HttpHeaders headers, final Class<T> clazz) { + final HttpEntity<?> request = new HttpEntity<>(headers); return invokeHttpRequest(request, HttpMethod.GET, url, clazz); } @@ -79,7 +100,14 @@ public class HttpRestServiceProviderImpl implements HttpRestServiceProvider { @Override public <T> ResponseEntity<T> postHttpRequest(final Object object, final String url, final Class<T> clazz) { - final HttpEntity<?> request = new HttpEntity<>(object, getHttpHeaders()); + final HttpEntity<?> request = new HttpEntity<>(object, getDefaultHttpHeaders()); + return invokeHttpRequest(request, HttpMethod.POST, url, clazz); + } + + @Override + public <T> ResponseEntity<T> postHttpRequest(final Object object, final String url, final HttpHeaders headers, + final Class<T> clazz) { + final HttpEntity<?> request = new HttpEntity<>(object, headers); return invokeHttpRequest(request, HttpMethod.POST, url, clazz); } @@ -91,7 +119,7 @@ public class HttpRestServiceProviderImpl implements HttpRestServiceProvider { @Override public <T> ResponseEntity<T> putHttpRequest(final Object object, final String url, final Class<T> clazz) { - final HttpEntity<?> request = new HttpEntity<>(object, getHttpHeaders()); + final HttpEntity<?> request = new HttpEntity<>(object, getDefaultHttpHeaders()); return invokeHttpRequest(request, HttpMethod.PUT, url, clazz); } @@ -140,9 +168,21 @@ public class HttpRestServiceProviderImpl implements HttpRestServiceProvider { @Override public <T> ResponseEntity<T> deleteHttpRequest(final String url, final Class<T> clazz) { try { - final HttpEntity<?> request = new HttpEntity<>(getHttpHeaders()); + final HttpEntity<?> request = new HttpEntity<>(getDefaultHttpHeaders()); return restTemplate.exchange(url, HttpMethod.DELETE, request, clazz); + } catch (final HttpStatusCodeException httpStatusCodeException) { + final String message = "Unable to invoke HTTP " + HttpMethod.DELETE + " using url: " + url + ", Response: " + + httpStatusCodeException.getRawStatusCode(); + LOGGER.error(message, httpStatusCodeException); + final int rawStatusCode = httpStatusCodeException.getRawStatusCode(); + if (rawStatusCode == HttpStatus.BAD_REQUEST.value()) { + throw new InvalidRestRequestException("No result found for given url: " + url); + } else if (rawStatusCode == HttpStatus.NOT_FOUND.value()) { + throw new HttpResouceNotFoundException("No result found for given url: " + url); + } + throw new RestProcessingException("Unable to invoke HTTP " + HttpMethod.DELETE + " using URL: " + url, + httpStatusCodeException, rawStatusCode); } catch (final RestClientException restClientException) { LOGGER.error("Unable to invoke HTTP DELETE using url: " + url, restClientException); throw new InvalidRestRequestException("Unable to invoke HTTP DELETE using URL: " + url, @@ -150,7 +190,7 @@ public class HttpRestServiceProviderImpl implements HttpRestServiceProvider { } } - private HttpHeaders getHttpHeaders() { - return httpHeadersProvider.getHttpHeaders(); + private HttpHeaders getDefaultHttpHeaders() { + return defaultHttpHeaders; } } diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/CloudConfiguration.java b/common/src/main/java/org/onap/so/serviceinstancebeans/CloudConfiguration.java index 4a284b55ec..777dcc6171 100644 --- a/common/src/main/java/org/onap/so/serviceinstancebeans/CloudConfiguration.java +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/CloudConfiguration.java @@ -37,6 +37,8 @@ public class CloudConfiguration implements Serializable { protected String aicNodeClli; @JsonProperty("tenantId") protected String tenantId; + @JsonProperty("tenantName") + protected String tenantName; @JsonProperty("cloudOwner") protected String cloudOwner = Defaults.CLOUD_OWNER.toString(); @JsonProperty("lcpCloudRegionId") @@ -82,6 +84,13 @@ public class CloudConfiguration implements Serializable { this.tenantId = value; } + public String getTenantName() { + return tenantName; + } + + public void setTenantName(String tenantName) { + this.tenantName = tenantName; + } public String getLcpCloudRegionId() { return lcpCloudRegionId; @@ -102,7 +111,8 @@ public class CloudConfiguration implements Serializable { @Override public String toString() { return new ToStringBuilder(this).append("aicNodeClli", getAicNodeClli()).append("tenantId", getTenantId()) - .append("cloudOwner", getCloudOwner()).append("lcpCloudRegionId", getLcpCloudRegionId()).toString(); + .append("tenantName", getTenantName()).append("cloudOwner", getCloudOwner()) + .append("lcpCloudRegionId", getLcpCloudRegionId()).toString(); } diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestInfo.java b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestInfo.java index 250c5df5ce..026db1e644 100644 --- a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestInfo.java +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestInfo.java @@ -43,6 +43,8 @@ public class RequestInfo implements Serializable { protected String orderNumber; @JsonProperty("productFamilyId") protected String productFamilyId; + @JsonProperty("productFamilyName") + protected String productFamilyName; @JsonProperty("orderVersion") protected Integer orderVersion; @JsonSerialize(include = Inclusion.ALWAYS) @@ -180,6 +182,14 @@ public class RequestInfo implements Serializable { public void setProductFamilyId(String productFamilyId) { this.productFamilyId = productFamilyId; + }; + + public String getProductFamilyName() { + return productFamilyName; + } + + public void setProductFamilyName(String productFamilyName) { + this.productFamilyName = productFamilyName; } /** @@ -215,9 +225,9 @@ public class RequestInfo implements Serializable { public String toString() { return "RequestInfo [billingAccountNumber=" + billingAccountNumber + ", callbackUrl=" + callbackUrl + ", correlator=" + correlator + ", orderNumber=" + orderNumber + ", productFamilyId=" + productFamilyId - + ", orderVersion=" + orderVersion + ", source=" + source + ", instanceName=" + instanceName - + ", suppressRollback=" + suppressRollback + ", requestorId=" + requestorId + ", applicationId=" - + applicationId + "]"; + + ", productFamilyName=" + productFamilyName + ", orderVersion=" + orderVersion + ", source=" + source + + ", instanceName=" + instanceName + ", suppressRollback=" + suppressRollback + ", requestorId=" + + requestorId + ", applicationId=" + applicationId + "]"; } diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.java b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.java index 3ada984b58..f39aa3656a 100644 --- a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.java +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.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. @@ -32,6 +32,8 @@ public class RequestStatus { protected String requestState; @JsonProperty("statusMessage") protected String statusMessage; + @JsonProperty("resourceStatusMessage") + protected String resourceStatusMessage; @JsonProperty("percentProgress") protected Integer percentProgress; @JsonProperty("timestamp") @@ -95,6 +97,14 @@ public class RequestStatus { this.statusMessage = statusMessage; } + public String getResourceStatusMessage() { + return resourceStatusMessage; + } + + public void setResourceStatusMessage(String resourceStatusMessage) { + this.resourceStatusMessage = resourceStatusMessage; + } + public Integer getPercentProgress() { return percentProgress; } @@ -122,8 +132,8 @@ public class RequestStatus { @Override public String toString() { return new ToStringBuilder(this).append("requestState", requestState).append("statusMessage", statusMessage) - .append("percentProgress", percentProgress).append("timestamp", timeStamp) - .append("extSystemErrorSource", extSystemErrorSource) + .append("resourceStatusMessage", resourceStatusMessage).append("percentProgress", percentProgress) + .append("timestamp", timeStamp).append("extSystemErrorSource", extSystemErrorSource) .append("rollbackExtSystemErrorSource", rollbackExtSystemErrorSource).append("flowStatus", flowStatus) .append("retryStatusMessage", retryStatusMessage).append("rollbackStatusMessage", rollbackStatusMessage) .toString(); diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/ServiceInstancesRequest.java b/common/src/main/java/org/onap/so/serviceinstancebeans/ServiceInstancesRequest.java index 5bcdcb181b..05e69b7b19 100644 --- a/common/src/main/java/org/onap/so/serviceinstancebeans/ServiceInstancesRequest.java +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/ServiceInstancesRequest.java @@ -32,8 +32,8 @@ public class ServiceInstancesRequest implements Serializable { private String serviceInstanceId; @JsonProperty("vnfInstanceId") private String vnfInstanceId; - @JsonProperty("pnfId") - private String pnfId; + @JsonProperty("pnfName") + private String pnfName; @JsonProperty("networkInstanceId") private String networkInstanceId; @JsonProperty("volumeGroupInstanceId") @@ -69,12 +69,12 @@ public class ServiceInstancesRequest implements Serializable { this.vnfInstanceId = vnfInstanceId; } - public String getPnfId() { - return pnfId; + public String getPnfName() { + return pnfName; } - public void setPnfId(String pnfId) { - this.pnfId = pnfId; + public void setPnfName(String pnfName) { + this.pnfName = pnfName; } public String getNetworkInstanceId() { @@ -123,7 +123,7 @@ public class ServiceInstancesRequest implements Serializable { sb.append("requestDetails=").append(requestDetails); sb.append(", serviceInstanceId='").append(serviceInstanceId).append('\''); sb.append(", vnfInstanceId='").append(vnfInstanceId).append('\''); - sb.append(", pnfId='").append(pnfId).append('\''); + sb.append(", pnfName='").append(pnfName).append('\''); sb.append(", networkInstanceId='").append(networkInstanceId).append('\''); sb.append(", volumeGroupInstanceId='").append(volumeGroupInstanceId).append('\''); sb.append(", vfModuleInstanceId='").append(vfModuleInstanceId).append('\''); diff --git a/common/src/main/java/org/onap/so/utils/CryptoUtils.java b/common/src/main/java/org/onap/so/utils/CryptoUtils.java index 1c38dfb774..eecee4c83f 100644 --- a/common/src/main/java/org/onap/so/utils/CryptoUtils.java +++ b/common/src/main/java/org/onap/so/utils/CryptoUtils.java @@ -24,7 +24,7 @@ package org.onap.so.utils; import org.onap.so.logger.LoggingAnchor; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java b/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java index 4f13cec8f4..035ad1dc81 100644 --- a/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java +++ b/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java @@ -6,6 +6,7 @@ import java.util.concurrent.ConcurrentHashMap; import org.camunda.bpm.client.ExternalTaskClient; import org.camunda.bpm.client.interceptor.ClientRequestInterceptor; import org.camunda.bpm.client.interceptor.auth.BasicAuthProvider; +import org.onap.logging.filter.base.ScheduledLogging; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -53,6 +54,7 @@ public class ExternalTaskServiceUtils { return Integer.parseInt(env.getProperty("workflow.topics.maxClients", "3")); } + @ScheduledLogging @Scheduled(fixedDelay = 30000) public void checkAllClientsActive() { getClients().stream().filter(client -> !client.isActive()).forEach(ExternalTaskClient::start); diff --git a/common/src/main/java/org/onap/so/utils/XmlMarshaller.java b/common/src/main/java/org/onap/so/utils/XmlMarshaller.java index 0ff3ccfa9c..3ae644be6b 100644 --- a/common/src/main/java/org/onap/so/utils/XmlMarshaller.java +++ b/common/src/main/java/org/onap/so/utils/XmlMarshaller.java @@ -34,7 +34,7 @@ import javax.xml.parsers.SAXParserFactory; import javax.xml.transform.sax.SAXSource; import org.onap.so.logger.LoggingAnchor; import org.onap.so.exceptions.MarshallerException; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/common/src/test/java/org/onap/so/client/aai/AAIObjectTypeTest.java b/common/src/test/java/org/onap/so/client/aai/AAIObjectTypeTest.java index 8f449c21f3..20a6678386 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAIObjectTypeTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAIObjectTypeTest.java @@ -22,7 +22,7 @@ package org.onap.so.client.aai; import static org.junit.Assert.assertEquals; import org.junit.Test; -import org.onap.so.client.aai.entities.uri.AAIUri; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; public class AAIObjectTypeTest { @@ -56,14 +56,14 @@ public class AAIObjectTypeTest { @Test public void instanceGroupObjectTypeTest() { final String id = "test1"; - AAIUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, id); + AAIResourceUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, id); assertEquals("/network/instance-groups/instance-group/test1", aaiUri.build().toString()); } @Test public void collectionObjectTypeTest() { final String id = "test1"; - AAIUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, id); + AAIResourceUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, id); assertEquals("/network/collections/collection/test1", aaiUri.build().toString()); } @@ -85,7 +85,7 @@ public class AAIObjectTypeTest { @Test public void networkPolicyObjectTypeTest() { final String id = "test1"; - AAIUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, id); + AAIResourceUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, id); assertEquals("/network/network-policies/network-policy/test1", aaiUri.build().toString()); } } diff --git a/common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java index 5b2bff277d..c70f16eb83 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java @@ -48,7 +48,6 @@ import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.entities.CustomQuery; import org.onap.so.client.aai.entities.Results; import org.onap.so.client.aai.entities.uri.AAIResourceUri; -import org.onap.so.client.aai.entities.uri.AAIUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.graphinventory.Format; import org.onap.so.client.graphinventory.GraphInventoryClient; @@ -83,10 +82,10 @@ public class AAIQueryClientTest { Format format = Format.SIMPLE; CustomQuery query = new CustomQuery(uris); - doReturn(restClient).when(client).createClient(isA(AAIUri.class)); + doReturn(restClient).when(client).createClient(isA(AAIResourceUri.class)); aaiQueryClient.query(format, query); - verify(client, times(1)).createClient( - AAIUriFactory.createResourceUri(AAIObjectType.CUSTOM_QUERY).queryParam("format", format.toString())); + verify(client, times(1)) + .createClient(AAIUriFactory.createResourceUri(AAIObjectType.CUSTOM_QUERY).format(format)); verify(restClient, times(1)).put(query, String.class); } @@ -99,7 +98,7 @@ public class AAIQueryClientTest { aaiQueryClient.nodesOnly(); aaiQueryClient.subgraph(subgraph); - AAIUri aaiUri = spy(AAIUriFactory.createResourceUri(AAIObjectType.CUSTOM_QUERY)); + AAIResourceUri aaiUri = spy(AAIUriFactory.createResourceUri(AAIObjectType.CUSTOM_QUERY)); doReturn(aaiUri).when(aaiUri).clone(); aaiQueryClient.setupQueryParams(aaiUri); @@ -133,7 +132,7 @@ public class AAIQueryClientTest { @Test public void querySingleTypeTest() throws IOException { - when(client.createClient(isA(AAIUri.class))).thenReturn(restClient); + when(client.createClient(isA(AAIResourceUri.class))).thenReturn(restClient); when(restClient.put(any(Object.class), any(GenericType.class))).thenReturn( mapper.readValue(getJson("pathed-result.json"), new TypeReference<Results<Map<String, Object>>>() {})); diff --git a/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientTest.java index 94d14684c7..a7fd6e904e 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientTest.java @@ -31,8 +31,12 @@ import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMoc import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.hamcrest.CoreMatchers.containsString; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import java.util.Optional; import javax.ws.rs.BadRequestException; import org.junit.Before; import org.junit.Rule; @@ -42,12 +46,17 @@ import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.aai.domain.yang.GenericVnfs; import org.onap.aai.domain.yang.Relationship; +import org.onap.so.client.RestClient; import org.onap.so.client.aai.entities.AAIEdgeLabel; import org.onap.so.client.aai.entities.AAIResultWrapper; +import org.onap.so.client.aai.entities.uri.AAIPluralResourceUri; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.defaultproperties.DefaultAAIPropertiesImpl; +import org.onap.so.client.graphinventory.exceptions.GraphInventoryMultipleItemsException; import com.github.tomakehurst.wiremock.admin.NotFoundException; import com.github.tomakehurst.wiremock.junit.WireMockRule; @@ -198,4 +207,102 @@ public class AAIResourcesClientTest { } + @Test + public void testGetOne() { + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("my-vnf-id"); + GenericVnfs vnfs = new GenericVnfs(); + vnfs.getGenericVnf().add(vnf); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF); + RestClient restClientMock = mock(RestClient.class); + doReturn(restClientMock).when(client).createClient(uri); + when(restClientMock.get(GenericVnfs.class)).thenReturn(Optional.of(vnfs)); + + Optional<GenericVnf> result = aaiClient.getOne(GenericVnfs.class, GenericVnf.class, uri); + + assertEquals("my-vnf-id", result.get().getVnfId()); + } + + @Test + public void testGetOneMultipleResults() { + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("my-vnf-id"); + GenericVnf vnf2 = new GenericVnf(); + vnf.setVnfId("my-vnf-id2"); + GenericVnfs vnfs = new GenericVnfs(); + vnfs.getGenericVnf().add(vnf); + vnfs.getGenericVnf().add(vnf2); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF); + RestClient restClientMock = mock(RestClient.class); + doReturn(restClientMock).when(client).createClient(uri); + when(restClientMock.get(GenericVnfs.class)).thenReturn(Optional.of(vnfs)); + + thrown.expect(GraphInventoryMultipleItemsException.class); + aaiClient.getOne(GenericVnfs.class, GenericVnf.class, uri); + } + + @Test + public void testGetFirstMultipleResults() { + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("my-vnf-id"); + GenericVnf vnf2 = new GenericVnf(); + vnf2.setVnfId("my-vnf-id2"); + GenericVnfs vnfs = new GenericVnfs(); + vnfs.getGenericVnf().add(vnf); + vnfs.getGenericVnf().add(vnf2); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF); + RestClient restClientMock = mock(RestClient.class); + doReturn(restClientMock).when(client).createClient(uri); + when(restClientMock.get(GenericVnfs.class)).thenReturn(Optional.of(vnfs)); + + Optional<GenericVnf> result = aaiClient.getFirst(GenericVnfs.class, GenericVnf.class, uri); + + assertEquals("my-vnf-id", result.get().getVnfId()); + } + + @Test + public void testGetOneNoResults() { + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("my-vnf-id"); + GenericVnfs vnfs = new GenericVnfs(); + vnfs.getGenericVnf().add(vnf); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF); + RestClient restClientMock = mock(RestClient.class); + doReturn(restClientMock).when(client).createClient(uri); + when(restClientMock.get(GenericVnfs.class)).thenReturn(Optional.empty()); + + Optional<GenericVnf> result = aaiClient.getOne(GenericVnfs.class, GenericVnf.class, uri); + + assertFalse(result.isPresent()); + } + + @Test + public void testGetFirstNoResults() { + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("my-vnf-id"); + GenericVnfs vnfs = new GenericVnfs(); + vnfs.getGenericVnf().add(vnf); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF); + RestClient restClientMock = mock(RestClient.class); + doReturn(restClientMock).when(client).createClient(uri); + when(restClientMock.get(GenericVnfs.class)).thenReturn(Optional.empty()); + + Optional<GenericVnf> result = aaiClient.getFirst(GenericVnfs.class, GenericVnf.class, uri); + + assertFalse(result.isPresent()); + } + + @Test + public void testGetFirstWrongPluralClass() { + GenericVnf vnf = new GenericVnf(); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF); + RestClient restClientMock = mock(RestClient.class); + doReturn(restClientMock).when(client).createClient(uri); + when(restClientMock.get(GenericVnf.class)).thenReturn(Optional.of(vnf)); + + Optional<GenericVnf> result = aaiClient.getFirst(GenericVnf.class, GenericVnf.class, uri); + + assertFalse(result.isPresent()); + } + } diff --git a/common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java index 305cdf59cc..cbcb60513b 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java @@ -95,7 +95,7 @@ public class AAITransactionalClientTest { @Test public void testConnect() throws IOException { - List<AAIResourceUri> uris = new ArrayList<AAIResourceUri>(); + List<AAIResourceUri> uris = new ArrayList<>(); uris.add(uriB); Map<String, Object> map = new HashMap<>(); @@ -117,7 +117,7 @@ public class AAITransactionalClientTest { @Test public void testDisconnect() throws IOException { - List<AAIResourceUri> uris = new ArrayList<AAIResourceUri>(); + List<AAIResourceUri> uris = new ArrayList<>(); uris.add(uriB); AAITransactionalClient transactions = aaiClient.beginTransaction().disconnect(uriA, uris); diff --git a/common/src/test/java/org/onap/so/client/aai/AAIURITest.java b/common/src/test/java/org/onap/so/client/aai/AAIURITest.java index 556b4429d4..8971f91602 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAIURITest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAIURITest.java @@ -23,7 +23,7 @@ package org.onap.so.client.aai; import static org.junit.Assert.assertEquals; import javax.ws.rs.core.UriBuilder; import org.junit.Test; -import org.onap.so.client.aai.entities.uri.AAIUri; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; public class AAIURITest { @@ -33,7 +33,7 @@ public class AAIURITest { @Test public void verifyTemplateReplacement() { final String id = "test1"; - AAIUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, id); + AAIResourceUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, id); String manualReplace = AAIObjectType.CONFIGURATION.toString().replaceAll("\\{configuration-id\\}", id); assertEquals("uri template replaced", aaiUri.build(), UriBuilder.fromPath(manualReplace).build()); diff --git a/common/src/test/java/org/onap/so/client/aai/entities/RelationshipsTest.java b/common/src/test/java/org/onap/so/client/aai/entities/RelationshipsTest.java index ec7c6434a7..039bbb3614 100644 --- a/common/src/test/java/org/onap/so/client/aai/entities/RelationshipsTest.java +++ b/common/src/test/java/org/onap/so/client/aai/entities/RelationshipsTest.java @@ -43,15 +43,12 @@ public class RelationshipsTest { Relationships relationships = wrapper.getRelationships().get(); List<AAIResourceUri> test = relationships.getRelatedUris(AAIObjectType.VCE); - - System.out.println(test.get(0).build()); List<AAIResourceUri> uris = Arrays.asList( AAIUriFactory.createResourceUri(AAIObjectType.VCE, "a9fec18e-1ea3-40e4-a6c0-a89b3de07053"), AAIUriFactory.createResourceUri(AAIObjectType.VCE, "8ae1e5f8-61f1-4c71-913a-b40cc4593cb9"), AAIUriFactory.createResourceUri(AAIObjectType.VCE, "a2935fa9-b743-49f4-9813-a127f13c4e93"), AAIUriFactory.createResourceUri(AAIObjectType.VCE, "c7fe7698-8063-4e26-8bd3-ca3edde0b0d4")); - assertTrue(uris.containsAll(test) && test.containsAll(uris)); } diff --git a/common/src/test/java/org/onap/so/client/aai/entities/uri/AAISimpleUriFromParentUriTest.java b/common/src/test/java/org/onap/so/client/aai/entities/uri/AAISimpleUriFromParentUriTest.java index d26ff8d507..0249bea794 100644 --- a/common/src/test/java/org/onap/so/client/aai/entities/uri/AAISimpleUriFromParentUriTest.java +++ b/common/src/test/java/org/onap/so/client/aai/entities/uri/AAISimpleUriFromParentUriTest.java @@ -33,7 +33,7 @@ public class AAISimpleUriFromParentUriTest { AAIResourceUri parentUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "key1", "key2", "key3"); - AAIUri uri = new AAISimpleUri(parentUri, AAIObjectType.ALLOTTED_RESOURCE, "key4"); + AAIResourceUri uri = new AAISimpleUri(parentUri, AAIObjectType.ALLOTTED_RESOURCE, "key4"); assertEquals("path appended", "/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3/allotted-resources/allotted-resource/key4", diff --git a/common/src/test/java/org/onap/so/client/aai/entities/uri/AAISimpleUriFromUriTest.java b/common/src/test/java/org/onap/so/client/aai/entities/uri/AAISimpleUriFromUriTest.java index ab1529d3ba..6bf67ffce8 100644 --- a/common/src/test/java/org/onap/so/client/aai/entities/uri/AAISimpleUriFromUriTest.java +++ b/common/src/test/java/org/onap/so/client/aai/entities/uri/AAISimpleUriFromUriTest.java @@ -24,7 +24,6 @@ import static org.junit.Assert.assertEquals; import javax.ws.rs.core.UriBuilder; import org.junit.Test; import org.onap.so.client.aai.AAIObjectType; -import org.onap.so.client.graphinventory.entities.uri.SimpleUri; public class AAISimpleUriFromUriTest { @@ -33,7 +32,7 @@ public class AAISimpleUriFromUriTest { @Test public void removeHost() { - AAIUri uri = new AAISimpleUri(AAIObjectType.UNKNOWN, + AAIResourceUri uri = new AAISimpleUri(AAIObjectType.UNKNOWN, UriBuilder .fromUri("https://localhost:8443/aai/v9/network/vces/vce/a9fec18e-1ea3-40e4-a6c0-a89b3de07053") .build()); @@ -46,7 +45,7 @@ public class AAISimpleUriFromUriTest { @Test public void noChange() { - AAIUri uri = new AAISimpleUri(AAIObjectType.UNKNOWN, + AAIResourceUri uri = new AAISimpleUri(AAIObjectType.UNKNOWN, UriBuilder.fromUri("/network/vces/vce/a9fec18e-1ea3-40e4-a6c0-a89b3de07053").build()); assertEquals("no change", "/network/vces/vce/a9fec18e-1ea3-40e4-a6c0-a89b3de07053", uri.build().toString()); @@ -56,11 +55,22 @@ public class AAISimpleUriFromUriTest { @Test public void encodingPreserved() { - AAIUri uri = new AAISimpleUri(AAIObjectType.UNKNOWN, + AAIResourceUri uri = new AAISimpleUri(AAIObjectType.UNKNOWN, UriBuilder.fromUri("/network/vces/vce/a9f%20%20ec18e-1ea3-40e4-a6c0-a89b3de07053").build()); assertEquals("encoding preserved", "/network/vces/vce/a9f%20%20ec18e-1ea3-40e4-a6c0-a89b3de07053", uri.build().toString()); } + + @Test + public void beforeBuildEquality() { + + AAIResourceUri uri = new AAISimpleUri(AAIObjectType.VCE, + UriBuilder.fromUri("/network/vces/vce/a9f%20%20ec18e-1ea3-40e4-a6c0-a89b3de07053").build()); + + AAIResourceUri uri2 = new AAISimpleUri(AAIObjectType.VCE, "a9f ec18e-1ea3-40e4-a6c0-a89b3de07053"); + assertEquals("are equal", uri2, uri); + + } } diff --git a/common/src/test/java/org/onap/so/client/aai/entities/uri/AAISimpleUriTest.java b/common/src/test/java/org/onap/so/client/aai/entities/uri/AAISimpleUriTest.java index 4e9d5aa8e8..6c1b3d69a2 100644 --- a/common/src/test/java/org/onap/so/client/aai/entities/uri/AAISimpleUriTest.java +++ b/common/src/test/java/org/onap/so/client/aai/entities/uri/AAISimpleUriTest.java @@ -20,14 +20,10 @@ package org.onap.so.client.aai.entities.uri; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.collection.IsEmptyCollection.empty; -import static org.hamcrest.collection.IsIterableContainingInOrder.contains; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -36,7 +32,6 @@ import org.junit.Test; import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.graphinventory.entities.uri.Depth; -import org.onap.so.client.graphinventory.entities.uri.SimpleUri; public class AAISimpleUriTest { @@ -44,34 +39,52 @@ public class AAISimpleUriTest { @Test public void relatedToTestPlural() { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1"); - uri.relatedTo(AAIObjectPlurals.PSERVER); + AAIPluralResourceUri uri = + AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1").relatedTo(AAIObjectPlurals.PSERVER); String uriOutput = uri.build().toString(); - assertEquals(true, uriOutput.contains("related-to")); + assertEquals("/network/generic-vnfs/generic-vnf/test1/related-to/pservers", uriOutput); } @Test public void relatedToTestSingular() { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1"); - uri.relatedTo(AAIObjectType.PSERVER, "test2"); + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1") + .relatedTo(AAIObjectType.PSERVER, "test2"); String uriOutput = uri.build().toString(); - assertEquals(true, uriOutput.contains("related-to")); + assertEquals("/network/generic-vnfs/generic-vnf/test1/related-to/pservers/pserver/test2", uriOutput); } @Test public void cloneTestSingular() { AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1"); AAIResourceUri cloned = uri.clone(); - Map<String, String> keys = cloned.getURIKeys(); - assertThat(keys.values(), contains("test1")); + assertEquals("/network/generic-vnfs/generic-vnf/test1", cloned.build().toString()); + + cloned.limit(2); + + assertNotEquals(uri.build().toString(), cloned.build().toString()); } @Test public void cloneTestPlural() { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF); - AAIResourceUri cloned = uri.clone(); - Map<String, String> keys = cloned.getURIKeys(); - assertThat(keys.values(), empty()); + AAISimplePluralUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF); + AAISimplePluralUri cloned = uri.clone(); + assertEquals("/network/generic-vnfs", cloned.build().toString()); + } + + @Test + public void cloneTestWithRelatedTo() { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1") + .relatedTo(AAIObjectType.PSERVER, "test2"); + String uriOutput = uri.clone().build().toString(); + assertEquals("/network/generic-vnfs/generic-vnf/test1/related-to/pservers/pserver/test2", uriOutput); + } + + @Test + public void cloneTestPluralWithRelatedTo() { + AAIPluralResourceUri uri = + AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1").relatedTo(AAIObjectPlurals.PSERVER); + String uriOutput = uri.clone().build().toString(); + assertEquals("/network/generic-vnfs/generic-vnf/test1/related-to/pservers", uriOutput); } @Test diff --git a/common/src/test/java/org/onap/so/client/aai/entities/uri/AAIUriFactoryTest.java b/common/src/test/java/org/onap/so/client/aai/entities/uri/AAIUriFactoryTest.java index 9b4f5dafb5..8a203f6439 100644 --- a/common/src/test/java/org/onap/so/client/aai/entities/uri/AAIUriFactoryTest.java +++ b/common/src/test/java/org/onap/so/client/aai/entities/uri/AAIUriFactoryTest.java @@ -24,14 +24,13 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; -import org.onap.so.client.graphinventory.entities.uri.SimpleUri; public class AAIUriFactoryTest { @Test public void testCreateResourceUri() { - AAIUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "VIP(VelocitytoIP)"); + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "VIP(VelocitytoIP)"); String expected = "/network/generic-vnfs/generic-vnf/VIP%28VelocitytoIP%29"; assertEquals(expected, uri.build().toString()); @@ -40,7 +39,7 @@ public class AAIUriFactoryTest { @Test public void testCreateNodesUri() { - AAIUri uri = AAIUriFactory.createNodesUri(AAIObjectType.GENERIC_VNF, "VIP(VelocitytoIP)"); + AAIResourceUri uri = AAIUriFactory.createNodesUri(AAIObjectType.GENERIC_VNF, "VIP(VelocitytoIP)"); String expected = "/nodes/generic-vnfs/generic-vnf/VIP%28VelocitytoIP%29"; assertEquals(expected, uri.build().toString()); @@ -49,8 +48,8 @@ public class AAIUriFactoryTest { @Test public void testCreateResourceFromExistingURI() { - AAIUri uri = new AAISimpleUri(AAIObjectType.GENERIC_VNF, "VIP(VelocitytoIP)"); - AAIUri uri2 = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.GENERIC_VNF, uri.build()); + AAIResourceUri uri = new AAISimpleUri(AAIObjectType.GENERIC_VNF, "VIP(VelocitytoIP)"); + AAIResourceUri uri2 = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.GENERIC_VNF, uri.build()); String expected = "/network/generic-vnfs/generic-vnf/VIP%28VelocitytoIP%29"; assertEquals(expected, uri2.build().toString()); @@ -59,7 +58,8 @@ public class AAIUriFactoryTest { @Test public void testCreateResourceURIForPluralsWithValues() { - AAIUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.SERVICE_INSTANCE, "customerId", "serviceType"); + AAIPluralResourceUri uri = + AAIUriFactory.createResourceUri(AAIObjectPlurals.SERVICE_INSTANCE, "customerId", "serviceType"); String expected = "/business/customers/customer/customerId/service-subscriptions/service-subscription/serviceType/service-instances"; diff --git a/common/src/test/java/org/onap/so/client/aai/entities/uri/AllottedResourceLookupUriTest.java b/common/src/test/java/org/onap/so/client/aai/entities/uri/AllottedResourceLookupUriTest.java index 4be6753894..a92a7c3c1a 100644 --- a/common/src/test/java/org/onap/so/client/aai/entities/uri/AllottedResourceLookupUriTest.java +++ b/common/src/test/java/org/onap/so/client/aai/entities/uri/AllottedResourceLookupUriTest.java @@ -44,7 +44,7 @@ public class AllottedResourceLookupUriTest { "/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3/allotted-resources/allotted-resource/key4") .when(spy).getObjectById(any(Object.class)); - final URI result = spy.build(); + final URI result = spy.locateAndBuild(); final URI expected = UriBuilder.fromPath( "/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3/allotted-resources/allotted-resource/key4") .build(); diff --git a/common/src/test/java/org/onap/so/client/aai/entities/uri/IncorrectNumberOfUriKeysTest.java b/common/src/test/java/org/onap/so/client/aai/entities/uri/IncorrectNumberOfUriKeysTest.java index 86ee08c4e6..3fbbc7c110 100644 --- a/common/src/test/java/org/onap/so/client/aai/entities/uri/IncorrectNumberOfUriKeysTest.java +++ b/common/src/test/java/org/onap/so/client/aai/entities/uri/IncorrectNumberOfUriKeysTest.java @@ -21,8 +21,6 @@ package org.onap.so.client.aai.entities.uri; import static org.hamcrest.CoreMatchers.equalTo; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -48,7 +46,7 @@ public class IncorrectNumberOfUriKeysTest { public void verifyIncorrectNumberOfKeysPlural() { thrown.expect(IncorrectNumberOfUriKeys.class); - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, "my-cloud-owner"); + AAISimplePluralUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, "my-cloud-owner"); } diff --git a/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java b/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java index 9bef35e3b5..71d65b6f45 100644 --- a/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java +++ b/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java @@ -56,11 +56,11 @@ import org.mockito.InjectMocks; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.client.aai.AAIClient; -import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIResourcesClient; import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.defaultproperties.DefaultAAIPropertiesImpl; -import org.onap.so.client.graphinventory.entities.uri.Depth; +import org.onap.so.client.graphinventory.entities.uri.HttpAwareUri; import org.onap.so.client.graphinventory.exceptions.GraphInventoryPayloadException; import org.onap.so.client.graphinventory.exceptions.GraphInventoryUriComputationException; import org.onap.so.client.graphinventory.exceptions.GraphInventoryUriNotFoundException; @@ -111,7 +111,7 @@ public class ServiceInstanceUriTest { "/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3") .when(spy).getObjectById(any(Object.class)); - final URI result = spy.build(); + final URI result = spy.locateAndBuild(); final URI expected = UriBuilder.fromPath( "/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3") .build(); @@ -129,7 +129,7 @@ public class ServiceInstanceUriTest { "/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3") .when(spy).getObjectById(any(Object.class)); - final URI result = spy.resourceVersion("1234").build(); + final URI result = ((HttpAwareUri) spy.resourceVersion("1234")).locateAndBuild(); final URI expected = UriBuilder.fromUri( "/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3?resource-version=1234") .build(); @@ -147,7 +147,7 @@ public class ServiceInstanceUriTest { "/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3%20space") .when(spy).getObjectById(any(Object.class)); - final URI result = spy.build(); + final URI result = spy.locateAndBuild(); final URI expected = UriBuilder.fromUri( "/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3%20space") .build(); @@ -175,9 +175,8 @@ public class ServiceInstanceUriTest { ServiceInstanceUri spy = spy(instance); String uri = "/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3"; - doReturn(uri).when(spy).getObjectById(any(Object.class)); doReturn(Optional.of(uri)).when(spy).getCachedValue(); - final URI result = spy.resourceVersion("1234").clone().build(); + final URI result = ((HttpAwareUri) spy.resourceVersion("1234").clone()).locateAndBuild(); final URI expected = UriBuilder.fromUri( "/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3?resource-version=1234") .build(); @@ -210,7 +209,7 @@ public class ServiceInstanceUriTest { when(wrapper.getJson()).thenReturn(content); when(spy.getResourcesClient()).thenReturn(mockResourcesClient); exception.expect(GraphInventoryUriComputationException.class); - spy.build(); + spy.locateAndBuild(); } @@ -233,7 +232,7 @@ public class ServiceInstanceUriTest { .stubFor(get(urlPathMatching("/aai/v[0-9]+/nodes/service-instances/service-instance/key3")).willReturn( aResponse().withStatus(404).withHeader("Content-Type", "application/json").withBodyFile(""))); exception.expect(NotFoundException.class); - spy.build(); + spy.locateAndBuild(); } @Test @@ -250,7 +249,7 @@ public class ServiceInstanceUriTest { ArgumentMatchers.<Class<NotFoundException>>any())).thenReturn(wrapper); when(wrapper.getJson()).thenReturn(content); when(spy.getResourcesClient()).thenReturn(mockResourcesClient); - spy.build(); + spy.locateAndBuild(); instance = spy.clone(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); @@ -271,6 +270,32 @@ public class ServiceInstanceUriTest { // use the cached value do not call out to external system verify(spy2, times(0)).getResourcesClient(); + } + + @Test + public void relatedToTest() throws GraphInventoryUriNotFoundException, GraphInventoryPayloadException { + ServiceInstanceUri instance = new ServiceInstanceUri("key1"); + ServiceInstanceUri spy = spy(instance); + doReturn( + "/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3") + .when(spy).getObjectById(any(Object.class)); + + final URI result = spy.relatedTo(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", "my-vnf-name").build(); + final URI expected = UriBuilder.fromUri( + "/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3/related-to/generic-vnfs?vnf-name=my-vnf-name") + .build(); + assertEquals("result is equal", expected, result); + } + + @Test + public void relatedToEqualityTestBeforeBuildTest() + throws GraphInventoryUriNotFoundException, GraphInventoryPayloadException { + ServiceInstanceUri instance = new ServiceInstanceUri("key1"); + ServiceInstanceUri spy = spy(instance); + + final AAIPluralResourceUri result = + spy.relatedTo(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", "my-vnf-name"); + assertEquals("result is equal", result, result); } } diff --git a/common/src/test/java/org/onap/so/logger/ScheduledTasksMDCSetupTest.java b/common/src/test/java/org/onap/so/logger/ScheduledTasksMDCSetupTest.java deleted file mode 100644 index f232781871..0000000000 --- a/common/src/test/java/org/onap/so/logger/ScheduledTasksMDCSetupTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. 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.logger; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import org.junit.After; -import org.junit.Test; -import org.onap.logging.filter.base.Constants; -import org.onap.logging.ref.slf4j.ONAPLogConstants; -import org.onap.so.utils.Components; -import org.onap.so.utils.UUIDChecker; -import org.slf4j.MDC; - -public class ScheduledTasksMDCSetupTest { - private ScheduledTasksMDCSetup tasksMDCSetup = new ScheduledTasksMDCSetup(); - - @After - public void tearDown() { - MDC.clear(); - System.clearProperty("partnerName"); - } - - @Test - public void mdcSetupTest() { - System.setProperty("partnerName", Components.APIH.toString()); - tasksMDCSetup.mdcSetup(Components.APIH, "mdcSetupTest"); - - assertTrue(UUIDChecker.isValidUUID(MDC.get(ONAPLogConstants.MDCs.REQUEST_ID))); - assertEquals(Components.APIH.toString(), MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY)); - assertEquals(Components.APIH.toString(), MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME)); - assertEquals("mdcSetupTest", MDC.get(ONAPLogConstants.MDCs.SERVICE_NAME)); - assertEquals(Constants.DefaultValues.UNKNOWN, MDC.get(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME)); - assertNotNull(MDC.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP)); - assertNotNull(MDC.get(ONAPLogConstants.MDCs.ELAPSED_TIME)); - assertNotNull(MDC.get(ONAPLogConstants.MDCs.LOG_TIMESTAMP)); - assertNotNull(MDC.get(ONAPLogConstants.MDCs.SERVER_FQDN)); - } - - @Test - public void errorMDCSetupTest() { - tasksMDCSetup.errorMDCSetup(ErrorCode.UnknownError, "Error"); - - assertEquals("900", MDC.get(ONAPLogConstants.MDCs.ERROR_CODE)); - assertEquals("Error", MDC.get(ONAPLogConstants.MDCs.ERROR_DESC)); - } - - @Test - public void setStatusCodeTest() { - tasksMDCSetup.setStatusCode(); - - assertEquals(ONAPLogConstants.ResponseStatus.COMPLETE.toString(), - MDC.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE)); - } - - @Test - public void setStatusCodeErrorTest() { - MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.ERROR.toString()); - tasksMDCSetup.setStatusCode(); - - assertEquals(ONAPLogConstants.ResponseStatus.ERROR.toString(), - MDC.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE)); - } -} |