diff options
Diffstat (limited to 'common/src/main/java/org')
20 files changed, 961 insertions, 43 deletions
diff --git a/common/src/main/java/org/onap/so/client/RestClient.java b/common/src/main/java/org/onap/so/client/RestClient.java index 007c666ac2..631850a01f 100644 --- a/common/src/main/java/org/onap/so/client/RestClient.java +++ b/common/src/main/java/org/onap/so/client/RestClient.java @@ -71,7 +71,7 @@ public abstract class RestClient { protected Optional<URI> path; protected String accept; protected String contentType; - protected String requestId; + protected String requestId = ""; protected JaxRsClientLogging jaxRsClientLogging; protected RestProperties props; diff --git a/common/src/main/java/org/onap/so/client/aai/AAIClientResponseExceptionMapper.java b/common/src/main/java/org/onap/so/client/aai/AAIClientResponseExceptionMapper.java index 514eab6fc4..ffc474a55a 100644 --- a/common/src/main/java/org/onap/so/client/aai/AAIClientResponseExceptionMapper.java +++ b/common/src/main/java/org/onap/so/client/aai/AAIClientResponseExceptionMapper.java @@ -29,6 +29,7 @@ import javax.ws.rs.ext.Provider; import javax.annotation.Priority; import javax.ws.rs.ext.Provider; +import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.client.ResponseExceptionMapper; import org.onap.so.client.aai.entities.AAIError; import org.onap.so.logger.MsoLogger; @@ -42,7 +43,7 @@ public class AAIClientResponseExceptionMapper extends ResponseExceptionMapper { private final String requestId; public AAIClientResponseExceptionMapper() { - this.requestId = MDC.get(MsoLogger.REQUEST_ID); + this.requestId = MDC.get(ONAPLogConstants.MDCs.REQUEST_ID); } @Override public Optional<String> extractMessage(String entity) { 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 ce75b1716a..518fcf59d5 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,6 +20,40 @@ package org.onap.so.client.aai; +import java.util.HashMap; +import java.util.Map; + +import org.onap.aai.annotations.Metadata; +import org.onap.aai.domain.yang.AllottedResource; +import org.onap.aai.domain.yang.CloudRegion; +import org.onap.aai.domain.yang.Collection; +import org.onap.aai.domain.yang.Configuration; +import org.onap.aai.domain.yang.Customer; +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.aai.domain.yang.InstanceGroup; +import org.onap.aai.domain.yang.L3Network; +import org.onap.aai.domain.yang.LinesOfBusiness; +import org.onap.aai.domain.yang.ModelVer; +import org.onap.aai.domain.yang.NetworkPolicy; +import org.onap.aai.domain.yang.OperationalEnvironment; +import org.onap.aai.domain.yang.OwningEntity; +import org.onap.aai.domain.yang.PInterface; +import org.onap.aai.domain.yang.PhysicalLink; +import org.onap.aai.domain.yang.Platform; +import org.onap.aai.domain.yang.Project; +import org.onap.aai.domain.yang.Pserver; +import org.onap.aai.domain.yang.RouteTableReferences; +import org.onap.aai.domain.yang.ServiceInstance; +import org.onap.aai.domain.yang.ServiceSubscription; +import org.onap.aai.domain.yang.Tenant; +import org.onap.aai.domain.yang.TunnelXconnect; +import org.onap.aai.domain.yang.VfModule; +import org.onap.aai.domain.yang.VlanTag; +import org.onap.aai.domain.yang.Vce; +import org.onap.aai.domain.yang.Vnfc; +import org.onap.aai.domain.yang.VolumeGroup; +import org.onap.aai.domain.yang.VpnBinding; +import org.onap.aai.domain.yang.Vserver; import org.onap.so.client.graphinventory.GraphInventoryObjectType; import com.google.common.base.CaseFormat; @@ -27,57 +61,82 @@ import com.google.common.base.CaseFormat; public enum AAIObjectType implements GraphInventoryObjectType { DEFAULT_CLOUD_REGION(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/cloud-regions/cloud-region/att-aic/{cloud-region-id}"), - CUSTOMER(AAINamespaceConstants.BUSINESS, "/customers/customer/{global-customer-id}"), + CUSTOMER(AAINamespaceConstants.BUSINESS, Customer.class), GENERIC_QUERY("/search", "/generic-query"), BULK_PROCESS("/bulkprocess", ""), - GENERIC_VNF(AAINamespaceConstants.NETWORK, "/generic-vnfs/generic-vnf/{vnf-id}"), - VF_MODULE(AAIObjectType.GENERIC_VNF.uriTemplate(), "/vf-modules/vf-module/{vf-module-id}"), - L3_NETWORK(AAINamespaceConstants.NETWORK, "/l3-networks/l3-network/{network-id}"), - NETWORK_POLICY(AAINamespaceConstants.NETWORK, "/network-policies/network-policy/{network-policy-id}"), + GENERIC_VNF(AAINamespaceConstants.NETWORK, GenericVnf.class), + VF_MODULE(AAIObjectType.GENERIC_VNF.uriTemplate(), VfModule.class), + L3_NETWORK(AAINamespaceConstants.NETWORK, L3Network.class), + NETWORK_POLICY(AAINamespaceConstants.NETWORK, NetworkPolicy.class), NODES_QUERY("/search", "/nodes-query"), CUSTOM_QUERY("/query", ""), - ROUTE_TABLE_REFERENCE(AAINamespaceConstants.NETWORK, "/route-table-references/route-table-reference/{route-table-reference-id}"), + ROUTE_TABLE_REFERENCE(AAINamespaceConstants.NETWORK, RouteTableReferences.class), DEFAULT_TENANT(AAINamespaceConstants.CLOUD_INFRASTRUCTURE + "/cloud-regions/cloud-region/att-aic/AAIAIC25", "/tenants/tenant/{tenant-id}"), - VCE(AAINamespaceConstants.NETWORK, "/vces/vce/{vnf-id}"), - VPN_BINDING(AAINamespaceConstants.NETWORK, "/vpn-bindings/vpn-binding/{vpn-id}"), + VCE(AAINamespaceConstants.NETWORK, Vce.class), + VPN_BINDING(AAINamespaceConstants.NETWORK, VpnBinding.class), VPN_BINDINGS(AAINamespaceConstants.NETWORK, "/vpn-bindings"), - CONFIGURATION(AAINamespaceConstants.NETWORK, "/configurations/configuration/{configuration-id}"), - PSERVER(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/pservers/pserver/{hostname}"), - SERVICE_SUBSCRIPTION(AAIObjectType.CUSTOMER.uriTemplate(), "/service-subscriptions/service-subscription/{service-type}"), - SERVICE_INSTANCE(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), "/service-instances/service-instance/{service-instance-id}"), - PROJECT(AAINamespaceConstants.BUSINESS, "/projects/project/{id}"), - LINE_OF_BUSINESS(AAINamespaceConstants.BUSINESS, "/lines-of-business/line-of-business/{id}"), - PLATFORM(AAINamespaceConstants.BUSINESS, "/platforms/platform/{id}"), - OWNING_ENTITY(AAINamespaceConstants.BUSINESS, "/owning-entities/owning-entity/{id}"), - ALLOTTED_RESOURCE(AAIObjectType.SERVICE_INSTANCE.uriTemplate(), "/allotted-resources/allotted-resource/{id}"), + CONFIGURATION(AAINamespaceConstants.NETWORK, Configuration.class), + PSERVER(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, Pserver.class), + SERVICE_SUBSCRIPTION(AAIObjectType.CUSTOMER.uriTemplate(), ServiceSubscription.class), + SERVICE_INSTANCE(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), ServiceInstance.class), + PROJECT(AAINamespaceConstants.BUSINESS, Project.class), + LINE_OF_BUSINESS(AAINamespaceConstants.BUSINESS, LinesOfBusiness.class), + PLATFORM(AAINamespaceConstants.BUSINESS, Platform.class), + OWNING_ENTITY(AAINamespaceConstants.BUSINESS, OwningEntity.class), + ALLOTTED_RESOURCE(AAIObjectType.SERVICE_INSTANCE.uriTemplate(), AllottedResource.class), PNF(AAINamespaceConstants.NETWORK, "/pnfs/pnf/{pnf-name}"), - OPERATIONAL_ENVIRONMENT(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/operational-environments/operational-environment/{operational-environment-id}"), - CLOUD_REGION(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/cloud-regions/cloud-region/{cloud-owner-id}/{cloud-region-id}"), - TENANT(AAIObjectType.CLOUD_REGION.uriTemplate(), "/tenants/tenant/{tenant-id}"), - VOLUME_GROUP(AAIObjectType.CLOUD_REGION.uriTemplate(), "/volume-groups/volume-group/{volume-group-id}"), - VSERVER(AAIObjectType.TENANT.uriTemplate(), "/vservers/vserver/{vserver-id}"), - MODEL_VER(AAINamespaceConstants.SERVICE_DESIGN_AND_CREATION + "/models/model/{model-invariant-id}", "/model-vers/model-ver/{model-version-id}"), - TUNNEL_XCONNECT(AAIObjectType.ALLOTTED_RESOURCE.uriTemplate(), "/tunnel-xconnects/tunnel-xconnect/{tunnel-id}"), - P_INTERFACE(AAIObjectType.PSERVER.uriTemplate(), "/p-interfaces/p-interface/{interface-name}"), - PHYSICAL_LINK(AAINamespaceConstants.NETWORK, "/physical-links/physical-link/{link-name}"), - INSTANCE_GROUP(AAINamespaceConstants.NETWORK, "/instance-groups/instance-group/{id}"), - COLLECTION(AAINamespaceConstants.NETWORK, "/collections/collection/{collection-id}"), + OPERATIONAL_ENVIRONMENT(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, OperationalEnvironment.class), + CLOUD_REGION(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, CloudRegion.class), + TENANT(AAIObjectType.CLOUD_REGION.uriTemplate(), Tenant.class), + VOLUME_GROUP(AAIObjectType.CLOUD_REGION.uriTemplate(), VolumeGroup.class), + VSERVER(AAIObjectType.TENANT.uriTemplate(), Vserver.class), + MODEL_VER(AAINamespaceConstants.SERVICE_DESIGN_AND_CREATION + "/models/model/{model-invariant-id}", ModelVer.class), + TUNNEL_XCONNECT(AAIObjectType.ALLOTTED_RESOURCE.uriTemplate(), TunnelXconnect.class), + P_INTERFACE(AAIObjectType.PSERVER.uriTemplate(), PInterface.class), + PHYSICAL_LINK(AAINamespaceConstants.NETWORK, PhysicalLink.class), + INSTANCE_GROUP(AAINamespaceConstants.NETWORK, InstanceGroup.class), + COLLECTION(AAINamespaceConstants.NETWORK, Collection.class), + VNFC(AAINamespaceConstants.NETWORK, Vnfc.class), + VLAN_TAG(AAINamespaceConstants.NETWORK, VlanTag.class), UNKNOWN("", ""); private final String uriTemplate; private final String parentUri; private final String partialUri; + private final Class<?> aaiObjectClass; + private static Map<String, AAIObjectType> map = new HashMap<>(); private AAIObjectType(String parentUri, String partialUri) { this.parentUri = parentUri; this.partialUri = partialUri; this.uriTemplate = parentUri + partialUri; + this.aaiObjectClass = null; + } + + private AAIObjectType(String parentUri, Class<?> aaiObjectClass) { + this.parentUri = parentUri; + this.partialUri = removeParentUri(aaiObjectClass, parentUri); + this.uriTemplate = parentUri + partialUri; + this.aaiObjectClass = aaiObjectClass; } @Override public String toString() { return this.uriTemplate(); } - + + public static AAIObjectType fromTypeName(String name) { + if (map.isEmpty()) { + for (AAIObjectType type : AAIObjectType.values()) { + map.put(type.typeName(), type); + } + } + + if (map.containsKey(name)) { + return map.get(name); + } else { + return AAIObjectType.UNKNOWN; + } + } @Override public String typeName() { return this.typeName(CaseFormat.LOWER_HYPHEN); @@ -101,4 +160,8 @@ public enum AAIObjectType implements GraphInventoryObjectType { public String partialUri() { return this.partialUri; } + + protected String removeParentUri(Class<?> aaiObjectClass, String parentUri) { + return aaiObjectClass.getAnnotation(Metadata.class).uriTemplate().replace(parentUri, ""); + } } diff --git a/common/src/main/java/org/onap/so/client/aai/entities/AAIEdgeLabel.java b/common/src/main/java/org/onap/so/client/aai/entities/AAIEdgeLabel.java index 0356e86861..434dbf946b 100644 --- a/common/src/main/java/org/onap/so/client/aai/entities/AAIEdgeLabel.java +++ b/common/src/main/java/org/onap/so/client/aai/entities/AAIEdgeLabel.java @@ -1,3 +1,23 @@ +/*- + * ============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; import org.onap.so.client.graphinventory.entities.GraphInventoryEdgeLabel; diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryEdgeLabel.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryEdgeLabel.java index 1ede2f9e1b..461920fe7f 100644 --- a/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryEdgeLabel.java +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryEdgeLabel.java @@ -1,3 +1,23 @@ +/*- + * ============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.graphinventory.entities; public interface GraphInventoryEdgeLabel { 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 145959dc73..3d08c8d40c 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 @@ -1,3 +1,23 @@ +/*- + * ============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.graphinventory.entities.uri; import java.net.URI; diff --git a/common/src/main/java/org/onap/so/client/policy/PolicyClient.java b/common/src/main/java/org/onap/so/client/policy/PolicyClient.java index 74c1e398db..6743bc2c34 100644 --- a/common/src/main/java/org/onap/so/client/policy/PolicyClient.java +++ b/common/src/main/java/org/onap/so/client/policy/PolicyClient.java @@ -20,6 +20,7 @@ package org.onap.so.client.policy; +import org.onap.so.client.policy.entities.Config; import org.onap.so.client.policy.entities.DictionaryData; import org.onap.so.client.policy.entities.PolicyDecision; @@ -29,4 +30,6 @@ public interface PolicyClient { String errorCode); public DictionaryData getAllowedTreatments(String bbID, String workStep); + + public Config getConfigWithPolicyName(String policyName); } diff --git a/common/src/main/java/org/onap/so/client/policy/PolicyClientImpl.java b/common/src/main/java/org/onap/so/client/policy/PolicyClientImpl.java index 1fd01e65ed..71a3227c56 100644 --- a/common/src/main/java/org/onap/so/client/policy/PolicyClientImpl.java +++ b/common/src/main/java/org/onap/so/client/policy/PolicyClientImpl.java @@ -20,6 +20,7 @@ package org.onap.so.client.policy; +import java.io.IOException; import java.util.List; import org.onap.so.client.RestClient; @@ -27,10 +28,13 @@ import org.onap.so.client.RestPropertiesLoader; import org.onap.so.client.defaultproperties.PolicyRestPropertiesImpl; import org.onap.so.client.policy.entities.AllowedTreatments; import org.onap.so.client.policy.entities.Bbid; +import org.onap.so.client.policy.entities.Config; +import org.onap.so.client.policy.entities.ConfigRequestParameters; import org.onap.so.client.policy.entities.DecisionAttributes; import org.onap.so.client.policy.entities.DictionaryData; import org.onap.so.client.policy.entities.DictionaryItemsRequest; import org.onap.so.client.policy.entities.DictionaryJson; +import org.onap.so.client.policy.entities.PolicyConfig; import org.onap.so.client.policy.entities.PolicyDecision; import org.onap.so.client.policy.entities.PolicyDecisionRequest; import org.onap.so.client.policy.entities.PolicyServiceType; @@ -38,11 +42,19 @@ import org.onap.so.client.policy.entities.Workstep; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; + public class PolicyClientImpl implements PolicyClient { private static Logger logger = LoggerFactory.getLogger(PolicyClientImpl.class); private PolicyRestProperties props; + private ObjectMapper mapper = new ObjectMapper(); + public PolicyClientImpl() { props = RestPropertiesLoader.getInstance().getNewImpl(PolicyRestProperties.class); if (props == null) { @@ -63,7 +75,7 @@ public class PolicyClientImpl implements PolicyClient { } protected PolicyDecision getDecision(DecisionAttributes decisionAttributes) { - PolicyRestClient client = new PolicyRestClient(this.props, PolicyServiceType.GET_DECISION); + PolicyRestClient client = this.getPolicyRestClient(PolicyServiceType.GET_DECISION); PolicyDecisionRequest decisionRequest = new PolicyDecisionRequest(); decisionRequest.setDecisionAttributes(decisionAttributes); decisionRequest.setEcompcomponentName(RestClient.ECOMP_COMPONENT_NAME); @@ -73,7 +85,7 @@ public class PolicyClientImpl implements PolicyClient { public DictionaryData getAllowedTreatments(String bbID, String workStep) { - PolicyRestClient client = new PolicyRestClient(this.props, PolicyServiceType.GET_DICTIONARY_ITEMS); + PolicyRestClient client = this.getPolicyRestClient(PolicyServiceType.GET_DICTIONARY_ITEMS); DictionaryItemsRequest dictionaryItemsRequest = new DictionaryItemsRequest(); dictionaryItemsRequest.setDictionaryType("Decision"); dictionaryItemsRequest.setDictionary("RainyDayTreatments"); @@ -92,5 +104,35 @@ public class PolicyClientImpl implements PolicyClient { logger.error("There is no AllowedTreatments with that specified parameter set"); return null; } - + + @Override + public Config getConfigWithPolicyName(String policyName) { + PolicyRestClient client = this.getPolicyRestClient(PolicyServiceType.GET_CONFIG); + ConfigRequestParameters configReqParameters = new ConfigRequestParameters(); + configReqParameters.setPolicyName(policyName); + PolicyConfig[] policyConfigList = client.post(configReqParameters, PolicyConfig[].class); + PolicyConfig policyConfig = null; + if(policyConfigList.length > 1) { + logger.debug("Too many configs for policyName: " + policyName); + return null; + } + try { + policyConfig = policyConfigList[0]; + return this.getConfigFromStringJson(policyConfig.getConfig()); + } catch (IOException e) { + logger.error(e.getMessage()); + return null; + } + } + + protected Config getConfigFromStringJson(String configJson) throws JsonParseException, JsonMappingException, IOException { + String unescapedJson = configJson.replaceAll("\\\\", ""); + mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false); + mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, false); + return mapper.readValue(unescapedJson, Config.class); + } + + protected PolicyRestClient getPolicyRestClient(PolicyServiceType policyServiceType) { + return new PolicyRestClient(this.props, policyServiceType); + } } diff --git a/common/src/main/java/org/onap/so/client/policy/entities/Config.java b/common/src/main/java/org/onap/so/client/policy/entities/Config.java new file mode 100644 index 0000000000..6c9c0759d6 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/policy/entities/Config.java @@ -0,0 +1,217 @@ +/*- + * ============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.policy.entities; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "configName", + "riskLevel", + "policyName", + "policyScope", + "guard", + "description", + "priority", + "uuid", + "version", + "content", + "riskType", + "service", + "location", + "templateVersion" +}) +@JsonRootName(value = "config") +public class Config { + + @JsonProperty("configName") + private String configName; + @JsonProperty("riskLevel") + private String riskLevel; + @JsonProperty("policyName") + private String policyName; + @JsonProperty("policyScope") + private String policyScope; + @JsonProperty("guard") + private String guard; + @JsonProperty("description") + private String description; + @JsonProperty("priority") + private String priority; + @JsonProperty("uuid") + private String uuid; + @JsonProperty("version") + private String version; + @JsonProperty("content") + private Content content; + @JsonProperty("riskType") + private String riskType; + @JsonProperty("service") + private String service; + @JsonProperty("location") + private String location; + @JsonProperty("templateVersion") + private String templateVersion; + + @JsonProperty("configName") + public String getConfigName() { + return configName; + } + + @JsonProperty("configName") + public void setConfigName(String configName) { + this.configName = configName; + } + + @JsonProperty("riskLevel") + public String getRiskLevel() { + return riskLevel; + } + + @JsonProperty("riskLevel") + public void setRiskLevel(String riskLevel) { + this.riskLevel = riskLevel; + } + + @JsonProperty("policyName") + public String getPolicyName() { + return policyName; + } + + @JsonProperty("policyName") + public void setPolicyName(String policyName) { + this.policyName = policyName; + } + + @JsonProperty("policyScope") + public String getPolicyScope() { + return policyScope; + } + + @JsonProperty("policyScope") + public void setPolicyScope(String policyScope) { + this.policyScope = policyScope; + } + + @JsonProperty("guard") + public String getGuard() { + return guard; + } + + @JsonProperty("guard") + public void setGuard(String guard) { + this.guard = guard; + } + + @JsonProperty("description") + public String getDescription() { + return description; + } + + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + @JsonProperty("priority") + public String getPriority() { + return priority; + } + + @JsonProperty("priority") + public void setPriority(String priority) { + this.priority = priority; + } + + @JsonProperty("uuid") + public String getUuid() { + return uuid; + } + + @JsonProperty("uuid") + public void setUuid(String uuid) { + this.uuid = uuid; + } + + @JsonProperty("version") + public String getVersion() { + return version; + } + + @JsonProperty("version") + public void setVersion(String version) { + this.version = version; + } + + @JsonProperty("content") + public Content getContent() { + return content; + } + + @JsonProperty("content") + public void setContent(Content content) { + this.content = content; + } + + @JsonProperty("riskType") + public String getRiskType() { + return riskType; + } + + @JsonProperty("riskType") + public void setRiskType(String riskType) { + this.riskType = riskType; + } + + @JsonProperty("service") + public String getService() { + return service; + } + + @JsonProperty("service") + public void setService(String service) { + this.service = service; + } + + @JsonProperty("location") + public String getLocation() { + return location; + } + + @JsonProperty("location") + public void setLocation(String location) { + this.location = location; + } + + @JsonProperty("templateVersion") + public String getTemplateVersion() { + return templateVersion; + } + + @JsonProperty("templateVersion") + public void setTemplateVersion(String templateVersion) { + this.templateVersion = templateVersion; + } + +} diff --git a/common/src/main/java/org/onap/so/client/policy/entities/ConfigRequestParameters.java b/common/src/main/java/org/onap/so/client/policy/entities/ConfigRequestParameters.java new file mode 100644 index 0000000000..8cd5b93a36 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/policy/entities/ConfigRequestParameters.java @@ -0,0 +1,127 @@ +/*- + * ============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.policy.entities; + +import java.util.HashMap; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "configAttributes", + "configName", + "ecompName", + "onapName", + "policyName", + "requestID", + "unique" +}) +public class ConfigRequestParameters { + + @JsonProperty("configAttributes") + private Map<String, String> configAttributes = new HashMap<>(); + @JsonProperty("configName") + private String configName; + @JsonProperty("ecompName") + private String ecompName; + @JsonProperty("onapName") + private String onapName; + @JsonProperty("policyName") + private String policyName; + @JsonProperty("requestID") + private String requestID; + @JsonProperty("unique") + private Boolean unique; + + @JsonProperty("configAttributes") + public Map<String, String> getConfigAttributes() { + return configAttributes; + } + + @JsonProperty("configAttributes") + public void setConfigAttributes(Map<String, String> configAttributes) { + this.configAttributes = configAttributes; + } + + @JsonProperty("configName") + public String getConfigName() { + return configName; + } + + @JsonProperty("configName") + public void setConfigName(String configName) { + this.configName = configName; + } + + @JsonProperty("ecompName") + public String getEcompName() { + return ecompName; + } + + @JsonProperty("ecompName") + public void setEcompName(String ecompName) { + this.ecompName = ecompName; + } + + @JsonProperty("onapName") + public String getOnapName() { + return onapName; + } + + @JsonProperty("onapName") + public void setOnapName(String onapName) { + this.onapName = onapName; + } + + @JsonProperty("policyName") + public String getPolicyName() { + return policyName; + } + + @JsonProperty("policyName") + public void setPolicyName(String policyName) { + this.policyName = policyName; + } + + @JsonProperty("requestID") + public String getRequestID() { + return requestID; + } + + @JsonProperty("requestID") + public void setRequestID(String requestID) { + this.requestID = requestID; + } + + @JsonProperty("unique") + public Boolean getUnique() { + return unique; + } + + @JsonProperty("unique") + public void setUnique(Boolean unique) { + this.unique = unique; + } + +} diff --git a/common/src/main/java/org/onap/so/client/policy/entities/Content.java b/common/src/main/java/org/onap/so/client/policy/entities/Content.java new file mode 100644 index 0000000000..a473f6c566 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/policy/entities/Content.java @@ -0,0 +1,47 @@ +/*- + * ============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.policy.entities; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "fabric-config-models" +}) +public class Content { + + @JsonProperty("fabric-config-models") + private List<FabricConfigModel> fabricConfigModels = null; + + @JsonProperty("fabric-config-models") + public List<FabricConfigModel> getFabricConfigModels() { + return fabricConfigModels; + } + + @JsonProperty("fabric-config-models") + public void setFabricConfigModels(List<FabricConfigModel> fabricConfigModels) { + this.fabricConfigModels = fabricConfigModels; + } + +} diff --git a/common/src/main/java/org/onap/so/client/policy/entities/FabricConfigModel.java b/common/src/main/java/org/onap/so/client/policy/entities/FabricConfigModel.java new file mode 100644 index 0000000000..d1a924cb7d --- /dev/null +++ b/common/src/main/java/org/onap/so/client/policy/entities/FabricConfigModel.java @@ -0,0 +1,59 @@ +/*- + * ============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.policy.entities; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "vnfProfile", + "lagProfile" +}) +public class FabricConfigModel { + + @JsonProperty("vnfProfile") + private String vnfProfile; + @JsonProperty("lagProfile") + private String lagProfile; + + @JsonProperty("vnfProfile") + public String getVnfProfile() { + return vnfProfile; + } + + @JsonProperty("vnfProfile") + public void setVnfProfile(String vnfProfile) { + this.vnfProfile = vnfProfile; + } + + @JsonProperty("lagProfile") + public String getLagProfile() { + return lagProfile; + } + + @JsonProperty("lagProfile") + public void setLagProfile(String lagProfile) { + this.lagProfile = lagProfile; + } + +} diff --git a/common/src/main/java/org/onap/so/client/policy/entities/PolicyConfig.java b/common/src/main/java/org/onap/so/client/policy/entities/PolicyConfig.java new file mode 100644 index 0000000000..807829e323 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/policy/entities/PolicyConfig.java @@ -0,0 +1,166 @@ +/*- + * ============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.policy.entities; + +import java.util.HashMap; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "policyConfigMessage", + "policyConfigStatus", + "type", + "config", + "policyName", + "policyType", + "policyVersion", + "matchingConditions", + "responseAttributes", + "property" +}) +public class PolicyConfig { + + @JsonProperty("policyConfigMessage") + private String policyConfigMessage; + @JsonProperty("policyConfigStatus") + private String policyConfigStatus; + @JsonProperty("type") + private String type; + @JsonProperty("config") + private String config; + @JsonProperty("policyName") + private String policyName; + @JsonProperty("policyType") + private String policyType; + @JsonProperty("policyVersion") + private String policyVersion; + @JsonProperty("matchingConditions") + private Map<String, String> matchingConditions = new HashMap<>(); + @JsonProperty("responseAttributes") + private Map<String, String> responseAttributes = new HashMap<>(); + @JsonProperty("property") + private Object property; + + @JsonProperty("policyConfigMessage") + public String getPolicyConfigMessage() { + return policyConfigMessage; + } + + @JsonProperty("policyConfigMessage") + public void setPolicyConfigMessage(String policyConfigMessage) { + this.policyConfigMessage = policyConfigMessage; + } + + @JsonProperty("policyConfigStatus") + public String getPolicyConfigStatus() { + return policyConfigStatus; + } + + @JsonProperty("policyConfigStatus") + public void setPolicyConfigStatus(String policyConfigStatus) { + this.policyConfigStatus = policyConfigStatus; + } + + @JsonProperty("type") + public String getType() { + return type; + } + + @JsonProperty("type") + public void setType(String type) { + this.type = type; + } + + @JsonProperty("config") + public String getConfig() { + return config; + } + + @JsonProperty("config") + public void setConfig(String config) { + this.config = config; + } + + @JsonProperty("policyName") + public String getPolicyName() { + return policyName; + } + + @JsonProperty("policyName") + public void setPolicyName(String policyName) { + this.policyName = policyName; + } + + @JsonProperty("policyType") + public String getPolicyType() { + return policyType; + } + + @JsonProperty("policyType") + public void setPolicyType(String policyType) { + this.policyType = policyType; + } + + @JsonProperty("policyVersion") + public String getPolicyVersion() { + return policyVersion; + } + + @JsonProperty("policyVersion") + public void setPolicyVersion(String policyVersion) { + this.policyVersion = policyVersion; + } + + @JsonProperty("matchingConditions") + public Map<String, String> getMatchingConditions() { + return matchingConditions; + } + + @JsonProperty("matchingConditions") + public void setMatchingConditions(Map<String, String> matchingConditions) { + this.matchingConditions = matchingConditions; + } + + @JsonProperty("responseAttributes") + public Map<String, String> getResponseAttributes() { + return responseAttributes; + } + + @JsonProperty("responseAttributes") + public void setResponseAttributes(Map<String, String> responseAttributes) { + this.responseAttributes = responseAttributes; + } + + @JsonProperty("property") + public Object getProperty() { + return property; + } + + @JsonProperty("property") + public void setProperty(Object property) { + this.property = property; + } + +} diff --git a/common/src/main/java/org/onap/so/exceptions/MSOException.java b/common/src/main/java/org/onap/so/exceptions/MSOException.java index c4be075cf0..f49cd8d8f8 100644 --- a/common/src/main/java/org/onap/so/exceptions/MSOException.java +++ b/common/src/main/java/org/onap/so/exceptions/MSOException.java @@ -1,3 +1,23 @@ +/*- + * ============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.exceptions; diff --git a/common/src/main/java/org/onap/so/logger/LoggerStartupListener.java b/common/src/main/java/org/onap/so/logger/LoggerStartupListener.java index 1ed18eae0f..794d02a240 100644 --- a/common/src/main/java/org/onap/so/logger/LoggerStartupListener.java +++ b/common/src/main/java/org/onap/so/logger/LoggerStartupListener.java @@ -15,7 +15,6 @@ * 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. - * Modifications Copyright (C) 2018 IBM. * ============LICENSE_END========================================================= */ diff --git a/common/src/main/java/org/onap/so/logger/MsoLogger.java b/common/src/main/java/org/onap/so/logger/MsoLogger.java index 3ef01f5216..94ffa71169 100644 --- a/common/src/main/java/org/onap/so/logger/MsoLogger.java +++ b/common/src/main/java/org/onap/so/logger/MsoLogger.java @@ -31,6 +31,7 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; +import org.apache.commons.lang3.StringUtils; import org.onap.so.entity.MsoRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -291,7 +292,9 @@ public class MsoLogger { public void recordAuditEvent(Long startTime, StatusCode statusCode, ResponseCode responseCode, String responseDesc) { - MDC.put(MsoLogger.PARTNERNAME, "UNKNOWN"); + if (StringUtils.isEmpty(MDC.get(MsoLogger.PARTNERNAME))) { + MDC.put(MsoLogger.PARTNERNAME, "UNKNOWN"); + } prepareAuditMsg(startTime, statusCode, responseCode.getValue(), responseDesc); auditLogger.info(""); MDC.remove(TIMER); diff --git a/common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCSetup.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCSetup.java index efc0aa84ef..f0a16561aa 100644 --- a/common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCSetup.java +++ b/common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCSetup.java @@ -1,3 +1,23 @@ +/*- + * ============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.logging.jaxrs.filter; import java.net.InetAddress; @@ -87,4 +107,4 @@ public class MDCSetup { } MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, statusCode); } -}
\ No newline at end of file +} diff --git a/common/src/main/java/org/onap/so/logging/spring/interceptor/LoggingInterceptor.java b/common/src/main/java/org/onap/so/logging/spring/interceptor/LoggingInterceptor.java index 755d18b5ee..194a445ce2 100644 --- a/common/src/main/java/org/onap/so/logging/spring/interceptor/LoggingInterceptor.java +++ b/common/src/main/java/org/onap/so/logging/spring/interceptor/LoggingInterceptor.java @@ -1,3 +1,23 @@ +/*- + * ============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.logging.spring.interceptor; import java.util.Collections; @@ -96,4 +116,4 @@ public class LoggingInterceptor extends HandlerInterceptorAdapter { } -}
\ No newline at end of file +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/Request.java b/common/src/main/java/org/onap/so/serviceinstancebeans/Request.java index bda3096f05..8e7e5e945e 100644 --- a/common/src/main/java/org/onap/so/serviceinstancebeans/Request.java +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/Request.java @@ -20,9 +20,10 @@ package org.onap.so.serviceinstancebeans; +import java.util.List; + import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; -import org.apache.commons.lang3.builder.ToStringBuilder; @JsonInclude(Include.NON_DEFAULT) @@ -35,6 +36,7 @@ public class Request { protected RequestDetails requestDetails; protected InstanceReferences instanceReferences; protected RequestStatus requestStatus; + protected List<RequestProcessingData> requestProcessingData; public String getRequestId() { @@ -79,12 +81,19 @@ public class Request { public void setRequestDetails(RequestDetails requestDetails) { this.requestDetails = requestDetails; } + public List<RequestProcessingData> getRequestProcessingData() { + return requestProcessingData; + } + public void setRequestProcessingData(List<RequestProcessingData> requestProcessingData) { + this.requestProcessingData = requestProcessingData; + } @Override public String toString() { - return new ToStringBuilder(this).append("requestId", requestId).append("startTime", startTime) - .append("requestScope", requestScope).append("requestType", requestType) - .append("requestDetails", requestDetails).append("instanceReferences", instanceReferences) - .append("requestStatus", requestStatus).toString(); + return "Request [requestId=" + requestId + ", startTime=" + startTime + + ", requestScope=" + requestScope + ", requestType=" + requestType + + ", requestDetails=" + requestDetails + ", instanceReferences=" + instanceReferences + + ", requestStatus=" + requestStatus + ", requestProcessingData=" + requestProcessingData + "]"; } + } diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestProcessingData.java b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestProcessingData.java new file mode 100644 index 0000000000..3373f78335 --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestProcessingData.java @@ -0,0 +1,62 @@ +/* ============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.serviceinstancebeans; + +import java.util.HashMap; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import org.apache.commons.lang3.builder.ToStringBuilder; + + +@JsonInclude(Include.NON_DEFAULT) +public class RequestProcessingData { + + protected String groupingId; + protected String tag; + protected List<HashMap<String, String>> dataPairs; + + public String getGroupingId() { + return groupingId; + } + public void setGroupingId(String groupingId) { + this.groupingId = groupingId; + } + public String getTag() { + return tag; + } + public void setTag(String tag) { + this.tag = tag; + } + public List<HashMap<String, String>> getDataPairs() { + return dataPairs; + } + public void setDataPairs(List<HashMap<String, String>> dataPairs) { + this.dataPairs = dataPairs; + } + @Override + public String toString() { + return new ToStringBuilder(this).append("groupingId", groupingId).append("tag", tag) + .append("dataPairs", dataPairs).toString(); + } + + +} |