diff options
author | 2018-07-30 15:56:09 -0400 | |
---|---|---|
committer | 2018-07-31 11:09:25 -0400 | |
commit | 5a6a6de6f1a26a1897e4917a0df613e25a24eb70 (patch) | |
tree | 59a968f27b4b603aacc9d5e7b51fb598aeec5321 /common/src/main/java/org/openecomp/mso/client/aai/entities | |
parent | b6dc38501f3b746426b42d9de4cc883d894149e8 (diff) |
Containerization feature of SO
Change-Id: I95381232eeefcd247a66a5cec370a8ce1c288e18
Issue-ID: SO-670
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'common/src/main/java/org/openecomp/mso/client/aai/entities')
22 files changed, 0 insertions, 1621 deletions
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntity.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntity.java deleted file mode 100644 index 3f0c4f3439..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntity.java +++ /dev/null @@ -1,25 +0,0 @@ -/*- - * ============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.openecomp.mso.client.aai.entities; - -public class AAIEntity{ - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntityObject.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntityObject.java deleted file mode 100644 index e4a64c4161..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntityObject.java +++ /dev/null @@ -1,29 +0,0 @@ -/*- - * ============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.openecomp.mso.client.aai.entities; - -import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri; - -public interface AAIEntityObject { - - public AAIResourceUri getUri(); - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIError.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIError.java deleted file mode 100644 index 5f895ef862..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIError.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============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.openecomp.mso.client.aai.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({ - "requestError" -}) -public class AAIError { - - @JsonProperty("requestError") - private RequestError requestError; - - @JsonProperty("requestError") - public RequestError getRequestError() { - return requestError; - } - - @JsonProperty("requestError") - public void setRequestError(RequestError requestError) { - this.requestError = requestError; - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIResultWrapper.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIResultWrapper.java deleted file mode 100644 index 9898f04844..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIResultWrapper.java +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * ============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.openecomp.mso.client.aai.entities; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; - -import org.openecomp.mso.client.aai.AAICommonObjectMapperProvider; -import org.openecomp.mso.jsonpath.JsonPathUtil; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class AAIResultWrapper { - - private final String jsonBody; - private final ObjectMapper mapper; - public AAIResultWrapper(String json) { - this.jsonBody = json; - this.mapper = new AAICommonObjectMapperProvider().getMapper(); - } - - public Optional<Relationships> getRelationships() { - final String path = "$.relationship-list"; - Optional<String> result = JsonPathUtil.getInstance().locateResult(jsonBody, path); - if (result.isPresent()) { - return Optional.of(new Relationships(result.get())); - } else { - return Optional.empty(); - } - } - - public String getJson() { - return jsonBody; - } - - public Map<String, Object> asMap() { - try { - return mapper.readValue(this.jsonBody, new TypeReference<Map<String, Object>>(){}); - } catch (IOException e) { - return new HashMap<>(); - } - } - - public <T> Optional<T> asBean(Class<T> clazz) { - try { - return Optional.of(mapper.readValue(this.jsonBody, clazz)); - } catch (IOException e) { - return Optional.empty(); - } - } - - @Override - public String toString() { - return this.getJson(); - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/Configuration.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/Configuration.java deleted file mode 100644 index a2d0fb3604..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/Configuration.java +++ /dev/null @@ -1,162 +0,0 @@ -/*- - * ============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.openecomp.mso.client.aai.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({ - "configuration-id", - "configuration-type", - "configuration-sub-type", - "model-invariant-id", - "model-version-id", - "orchestration-status", - "operational-status", - "configuration-selflink", - "model-customization-id" -}) -public class Configuration { - - @JsonProperty("configuration-id") - private String configurationId; - @JsonProperty("configuration-name") - private String configurationName; - @JsonProperty("configuration-type") - private String configurationType; - @JsonProperty("configuration-sub-type") - private String configurationSubType; - @JsonProperty("model-invariant-id") - private String modelInvariantId; - @JsonProperty("model-version-id") - private String modelVersionId; - @JsonProperty("orchestration-status") - private String orchestrationStatus; - @JsonProperty("operational-status") - private String operationalStatus; - @JsonProperty("configuration-selflink") - private String configurationSelflink; - @JsonProperty("model-customization-id") - private String modelCustomizationId; - - @JsonProperty("configuration-id") - public String getConfigurationId() { - return configurationId; - } - - @JsonProperty("configuration-id") - public void setConfigurationId(String configurationId) { - this.configurationId = configurationId; - } - - @JsonProperty("configuration-name") - public String getConfigurationName() { - return configurationName; - } - - @JsonProperty("configuration-name") - public void setConfigurationName(String configurationName) { - this.configurationName = configurationName; - } - - @JsonProperty("configuration-type") - public String getConfigurationType() { - return configurationType; - } - - @JsonProperty("configuration-type") - public void setConfigurationType(String configurationType) { - this.configurationType = configurationType; - } - - @JsonProperty("configuration-sub-type") - public String getConfigurationSubType() { - return configurationSubType; - } - - @JsonProperty("configuration-sub-type") - public void setConfigurationSubType(String configurationSubType) { - this.configurationSubType = configurationSubType; - } - - @JsonProperty("model-invariant-id") - public String getModelInvariantId() { - return modelInvariantId; - } - - @JsonProperty("model-invariant-id") - public void setModelInvariantId(String modelInvariantId) { - this.modelInvariantId = modelInvariantId; - } - - @JsonProperty("model-version-id") - public String getModelVersionId() { - return modelVersionId; - } - - @JsonProperty("model-version-id") - public void setModelVersionId(String modelVersionId) { - this.modelVersionId = modelVersionId; - } - - @JsonProperty("orchestration-status") - public String getOrchestrationStatus() { - return orchestrationStatus; - } - - @JsonProperty("orchestration-status") - public void setOrchestrationStatus(String orchestrationStatus) { - this.orchestrationStatus = orchestrationStatus; - } - - @JsonProperty("operational-status") - public String getOperationalStatus() { - return operationalStatus; - } - - @JsonProperty("operational-status") - public void setOperationalStatus(String operationalStatus) { - this.operationalStatus = operationalStatus; - } - - @JsonProperty("model-customization-id") - public String getModelCustomizationId() { - return modelCustomizationId; - } - - @JsonProperty("model-customization-id") - public void setModelCustomizationId(String modelCustomizationId) { - this.modelCustomizationId = modelCustomizationId; - } - - @JsonProperty("configuration-selflink") - public String getConfigurationSelflink() { - return configurationSelflink; - } - - @JsonProperty("configuration-selflink") - public void setConfigurationSelflink(String configurationSelflink) { - this.configurationSelflink = configurationSelflink; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/CustomQuery.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/CustomQuery.java deleted file mode 100644 index 3d014b8f67..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/CustomQuery.java +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * ============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.openecomp.mso.client.aai.entities; - -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.List; - -import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri; - -import com.fasterxml.jackson.annotation.JsonInclude; - - -@JsonInclude(JsonInclude.Include.NON_NULL) -public class CustomQuery { - - private List<String> start; - private String query; - private String gremlin; - - public String getGremlin() { - return gremlin; - } - - public void setGremlin(String gremlin) { - this.gremlin = gremlin; - } - - - public CustomQuery(List<AAIResourceUri> start){ - this.setStart(start); - } - - public CustomQuery(List<AAIResourceUri> start, String query){ - this.setStart(start); - this.query= "query/" + query; - } - - public CustomQuery(String gremlin) throws UnsupportedEncodingException{ - this.gremlin=gremlin; - } - - public List<String> getStart() { - return start; - } - - public void setStart(List<AAIResourceUri> start) { - this.start = this.mapUris(start); - } - - public String getQuery() { - return query; - } - - public void setQuery(String query) { - this.query = query; - } - - private List<String> mapUris(List<AAIResourceUri> uris) { - final List<String> result = new ArrayList<>(); - uris.stream().map(item -> item.build().toString()).forEach(result::add); - return result; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/Relationships.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/Relationships.java deleted file mode 100644 index cca2fb3744..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/Relationships.java +++ /dev/null @@ -1,140 +0,0 @@ -/*- - * ============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.openecomp.mso.client.aai.entities; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.function.Predicate; - -import javax.ws.rs.core.UriBuilder; - -import org.openecomp.mso.client.aai.AAICommonObjectMapperProvider; -import org.openecomp.mso.client.aai.AAIObjectName; -import org.openecomp.mso.client.aai.AAIObjectType; -import org.openecomp.mso.client.aai.AAIResourcesClient; -import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri; -import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory; -import org.openecomp.mso.jsonpath.JsonPathUtil; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.base.CaseFormat; - -public class Relationships { - - private final ObjectMapper mapper; - private Map<String, Object> map; - private final String jsonBody; - public Relationships(String json) { - this.jsonBody = json; - this.mapper = new AAICommonObjectMapperProvider().getMapper(); - try { - this.map = mapper.readValue(json, new TypeReference<Map<String, Object>>() {}); - } catch (IOException e) { - this.map = new HashMap<>(); - } - } - - public List<AAIResultWrapper> getByType(AAIObjectName type) { - - return this.getAll(Optional.of(type)); - } - - public List<AAIResultWrapper> getAll() { - - return this.getAll(Optional.empty()); - } - - - public List<String> getRelatedLinks() { - return this.getRelatedLinks(Optional.empty()); - } - - public List<String> getRelatedLinks(AAIObjectName type) { - return this.getRelatedLinks(Optional.of(type)); - } - - public List<AAIResourceUri> getRelatedAAIUris() { - return this.getRelatedAAIUris(x -> true); - } - - public List<AAIResourceUri> getRelatedAAIUris(AAIObjectName type) { - return this.getRelatedAAIUris(x -> type.typeName().equals(x)); - } - protected List<AAIResourceUri> getRelatedAAIUris(Predicate<String> p) { - List<AAIResourceUri> result = new ArrayList<>(); - if (map.containsKey("relationship")) { - List<Map<String, Object>> relationships = (List<Map<String, Object>>)map.get("relationship"); - for (Map<String, Object> relationship : relationships) { - final String relatedTo = (String)relationship.get("related-to"); - if (p.test(relatedTo)) { - AAIObjectType type; - try { - type = AAIObjectType.valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, relatedTo)); - } catch (IllegalArgumentException e) { - type = AAIObjectType.UNKNOWN; - } - final String relatedLink = (String)relationship.get("related-link"); - - result.add(AAIUriFactory.createResourceFromExistingURI(type, UriBuilder.fromPath(relatedLink).build())); - } - } - } - return result; - } - - - - protected List<AAIResultWrapper> getAll(final Optional<AAIObjectName> type) { - List<AAIResourceUri> relatedLinks; - if (type.isPresent()) { - relatedLinks = this.getRelatedAAIUris(type.get()); - } else { - relatedLinks = this.getRelatedAAIUris(); - } - ArrayList<AAIResultWrapper> result = new ArrayList<>(); - for (AAIResourceUri link : relatedLinks) { - result.add(this.get(link)); - } - return result; - } - - protected AAIResultWrapper get(AAIResourceUri uri) { - return new AAIResourcesClient().get(uri); - - } - - protected List<String> getRelatedLinks(Optional<AAIObjectName> type) { - String matcher = ""; - if (type.isPresent()) { - matcher = "[?(@.related-to=='" + type.get() + "')]"; - } - return JsonPathUtil.getInstance().locateResultList(this.jsonBody, String.format("$.relationship%s.related-link", matcher)); - } - - public String getJson() { - return this.jsonBody; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/RequestError.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/RequestError.java deleted file mode 100644 index 2fd3572401..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/RequestError.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============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.openecomp.mso.client.aai.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({ - "serviceException" -}) -public class RequestError { - - @JsonProperty("serviceException") - private ServiceException serviceException; - - @JsonProperty("serviceException") - public ServiceException getServiceException() { - return serviceException; - } - - @JsonProperty("serviceException") - public void setServiceException(ServiceException serviceException) { - this.serviceException = serviceException; - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/Results.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/Results.java deleted file mode 100644 index e91823a348..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/Results.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============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.openecomp.mso.client.aai.entities; - -import java.util.ArrayList; -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({ -"results" -}) -public class Results<T> { - @JsonProperty("results") - protected List<T> results; - - @JsonProperty("results") - public List<T> getResult() { - if (results == null) { - results = new ArrayList<>(); - } - return this.results; - } - @JsonProperty("results") - public void setResult(List<T> results) { - this.results=results; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/ServiceException.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/ServiceException.java deleted file mode 100644 index 66ca10d06b..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/ServiceException.java +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * ============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.openecomp.mso.client.aai.entities; - -import java.util.ArrayList; -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({ - "messageId", - "text", - "variables" -}) -public class ServiceException { - - @JsonProperty("messageId") - private String messageId; - @JsonProperty("text") - private String text; - @JsonProperty("variables") - private List<String> variables = new ArrayList<>(); - - @JsonProperty("messageId") - public String getMessageId() { - return messageId; - } - - @JsonProperty("messageId") - public void setMessageId(String messageId) { - this.messageId = messageId; - } - - @JsonProperty("text") - public String getText() { - return text; - } - - @JsonProperty("text") - public void setText(String text) { - this.text = text; - } - - @JsonProperty("variables") - public List<String> getVariables() { - return variables; - } - - @JsonProperty("variables") - public void setVariables(List<String> variables) { - this.variables = variables; - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/bulkprocess/OperationBody.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/bulkprocess/OperationBody.java deleted file mode 100644 index ddd9a454f8..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/bulkprocess/OperationBody.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============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.openecomp.mso.client.aai.entities.bulkprocess; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ -"uri", -"body" -}) -public class OperationBody { - -@JsonProperty("uri") -private String uri; -@JsonProperty("body") -private Object body; - -@JsonProperty("uri") -public String getUri() { -return uri; -} - -@JsonProperty("uri") -public void setUri(String uri) { -this.uri = uri; -} - -public OperationBody withUri(String uri) { -this.uri = uri; -return this; -} - -@JsonProperty("body") -public Object getBody() { -return body; -} - -@JsonProperty("body") -public void setBody(Object body) { -this.body = body; -} - -public OperationBody withBody(Object body) { -this.body = body; -return this; -} - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/bulkprocess/Transaction.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/bulkprocess/Transaction.java deleted file mode 100644 index 8c4d54dc16..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/bulkprocess/Transaction.java +++ /dev/null @@ -1,95 +0,0 @@ -/*- - * ============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.openecomp.mso.client.aai.entities.bulkprocess; - -import java.util.ArrayList; -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({ -"patch", -"patch", -"delete" -}) -public class Transaction { - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonProperty("put") -private List<OperationBody> put = new ArrayList<>(); - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonProperty("patch") -private List<OperationBody> patch = new ArrayList<>(); - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonProperty("delete") -private List<OperationBody> delete = new ArrayList<>(); - -@JsonProperty("put") -public List<OperationBody> getPut() { -return put; -} - -@JsonProperty("put") -public void setPut(List<OperationBody> put) { -this.put = put; -} - -public Transaction withPut(List<OperationBody> put) { -this.put = put; -return this; -} - -@JsonProperty("patch") -public List<OperationBody> getPatch() { -return patch; -} - -@JsonProperty("patch") -public void setPatch(List<OperationBody> patch) { -this.patch = patch; -} - -public Transaction withPatch(List<OperationBody> patch) { -this.patch = patch; -return this; -} - -@JsonProperty("delete") -public List<OperationBody> getDelete() { -return delete; -} - -@JsonProperty("delete") -public void setDelete(List<OperationBody> delete) { -this.delete = delete; -} - -public Transaction withDelete(List<OperationBody> delete) { -this.delete = delete; -return this; -} - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/bulkprocess/Transactions.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/bulkprocess/Transactions.java deleted file mode 100644 index f6ce3c5d2c..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/bulkprocess/Transactions.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============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.openecomp.mso.client.aai.entities.bulkprocess; - -import java.util.ArrayList; -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({ -"transactions" -}) -public class Transactions { - -@JsonProperty("transactions") -private List<Transaction> transactions = new ArrayList<>(); - -@JsonProperty("transactions") -public List<Transaction> getTransactions() { -return transactions; -} - -@JsonProperty("transactions") -public void setTransactions(List<Transaction> transactions) { -this.transactions = transactions; -} - -public Transactions withTransactions(List<Transaction> transactions) { -this.transactions = transactions; -return this; -} - -}
\ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIResourceUri.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIResourceUri.java deleted file mode 100644 index 36e3d008ae..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIResourceUri.java +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============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.openecomp.mso.client.aai.entities.uri; - -import org.openecomp.mso.client.aai.AAIObjectPlurals; -import org.openecomp.mso.client.aai.AAIObjectType; - -public interface AAIResourceUri extends AAIUri { - - public AAIResourceUri relationshipAPI(); - public AAIResourceUri relatedTo(AAIObjectPlurals plural); - public AAIResourceUri relatedTo(AAIObjectType type, String... values); - public AAIResourceUri resourceVersion(String version); - public AAIResourceUri depth(Depth depth); - public AAIResourceUri nodesOnly(boolean nodesOnly); - public AAIResourceUri queryParam(String name, String... values); - public AAIResourceUri clone(); -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIUri.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIUri.java deleted file mode 100644 index 1617bcddea..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIUri.java +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * ============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.openecomp.mso.client.aai.entities.uri; - -import java.net.URI; -import java.util.Map; - -import org.openecomp.mso.client.aai.AAIObjectPlurals; -import org.openecomp.mso.client.aai.AAIObjectType; - -public interface AAIUri { - - public URI build(); - /** - * 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 - */ - public AAIUri depth(Depth depth); - /** - * Makes client only return object fields, no relationships - * - * @return - */ - public AAIUri nodesOnly(boolean nodesOnly); - public AAIUri queryParam(String name, String... values); - public AAIUri clone(); - - /** - * returns all key values of the URI as a map. Key names can be found in {@link AAIObjectType} - * @return - */ - public Map<String, String> getURIKeys(); - public AAIObjectType getObjectType(); - public boolean equals(Object o); -}
\ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIUriFactory.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIUriFactory.java deleted file mode 100644 index cb33435c69..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIUriFactory.java +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============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.openecomp.mso.client.aai.entities.uri; - -import java.net.URI; - -import org.openecomp.mso.client.aai.AAIObjectPlurals; -import org.openecomp.mso.client.aai.AAIObjectType; - - -public class AAIUriFactory { - - /** - * values are filled into the URI template specified in {@link AAIObjectType} in order - * - * @param type - * @param values - * @return - */ - public static AAIResourceUri createResourceUri(AAIObjectType type, Object... values) { - if (AAIObjectType.SERVICE_INSTANCE.equals(type)) { - return new ServiceInstanceUri(values); - } else { - return new SimpleUri(type, values); - } - } - - public static AAIResourceUri createNodesUri(AAIObjectType type, Object... values) { - return new NodesUri(type, values); - - } - - /** - * This method should only be used to wrap a URI retrieved from A&AI contained within an object response - * - * @param type - * @param uri - * @return - */ - public static AAIResourceUri createResourceFromExistingURI(AAIObjectType type, URI uri) { - return new SimpleUri(type, uri); - } - - /** - * Creates a uri for a plural type e.g. /cloud-infrastructure/pservers - * - * @param type - * @return - */ - public static AAIResourceUri createResourceUri(AAIObjectPlurals type) { - - return new SimpleUri(type); - - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/Depth.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/Depth.java deleted file mode 100644 index 7522ea33d1..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/Depth.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============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.openecomp.mso.client.aai.entities.uri; - -public enum Depth { - ZERO("0"), - ONE("1"), - TWO("2"), - THREE("3"), - FOUR("4"), - FIVE("5"), - SIX("6"), - ALL("all"); - - private final String depth; - private Depth(String s) { - - this.depth = s; - } - - - @Override - public String toString() { - return this.depth; - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/NodesUri.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/NodesUri.java deleted file mode 100644 index 407e0ecc9e..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/NodesUri.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ============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.openecomp.mso.client.aai.entities.uri; - -import javax.ws.rs.core.UriBuilder; - -import org.openecomp.mso.client.aai.AAIObjectPlurals; -import org.openecomp.mso.client.aai.AAIObjectType; - -public class NodesUri extends SimpleUri { - - protected NodesUri(AAIObjectType type, Object... values) { - super(type, values); - } - - - @Override - protected String getTemplate(AAIObjectType type) { - return "/nodes" + type.partialUri(); - } - - @Override - protected String getTemplate(AAIObjectPlurals type) { - return "/nodes" + type.partialUri(); - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/ServiceInstanceUri.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/ServiceInstanceUri.java deleted file mode 100644 index cdaecedfa9..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/ServiceInstanceUri.java +++ /dev/null @@ -1,129 +0,0 @@ -/*- - * ============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.openecomp.mso.client.aai.entities.uri; - -import java.io.IOException; -import java.net.URI; -import java.util.Collections; -import java.util.Map; -import java.util.Optional; - -import javax.ws.rs.BadRequestException; -import javax.ws.rs.client.ResponseProcessingException; -import javax.ws.rs.core.UriBuilder; - -import org.openecomp.mso.client.aai.AAIObjectType; -import org.openecomp.mso.client.aai.AAIQueryClient; -import org.openecomp.mso.client.aai.Format; -import org.openecomp.mso.client.aai.entities.CustomQuery; -import org.openecomp.mso.client.aai.entities.Results; -import org.openecomp.mso.client.aai.exceptions.AAIPayloadException; -import org.openecomp.mso.client.aai.exceptions.AAIUriComputationException; -import org.openecomp.mso.client.aai.exceptions.AAIUriNotFoundException; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class ServiceInstanceUri extends SimpleUri { - - private Optional<String> cachedValue = Optional.empty(); - - protected ServiceInstanceUri(Object... values) { - super(AAIObjectType.SERVICE_INSTANCE, values); - } - protected ServiceInstanceUri(UriBuilder builder, Optional<String> cachedValue, Object... values) { - super(AAIObjectType.SERVICE_INSTANCE, builder, values); - this.cachedValue = cachedValue; - } - protected String getSerivceInstance(Object id) throws AAIUriNotFoundException, AAIPayloadException { - if (!this.getCachedValue().isPresent()) { - AAIResourceUri serviceInstanceUri = AAIUriFactory.createNodesUri(AAIObjectType.SERVICE_INSTANCE, id); - CustomQuery query = new CustomQuery(Collections.singletonList(serviceInstanceUri)); - String resultJson; - try { - resultJson = this.getQueryClient().query(Format.PATHED, query); - } catch (ResponseProcessingException e) { - if (e.getCause() instanceof BadRequestException) { - throw new AAIUriNotFoundException("Service instance " + id + " not found at: " + serviceInstanceUri.build()); - } else { - throw e; - } - } - try { - cachedValue = extractRelatedLink(resultJson); - if (!cachedValue.isPresent()) { - throw new AAIUriNotFoundException("Service instance " + id + " not found at: " + serviceInstanceUri.build()); - } - } catch (IOException e) { - throw new AAIPayloadException("could not map payload: " + resultJson, e); - } - - } - - return this.getCachedValue().get(); - } - - protected Optional<String> extractRelatedLink(String jsonString) throws IOException { - Optional<String> result; - ObjectMapper mapper = new ObjectMapper(); - - Results<Map<String, String>> results = mapper.readValue(jsonString, new TypeReference<Results<Map<String, String>>>(){}); - if (results.getResult().size() == 1) { - String uriString = results.getResult().get(0).get("resource-link"); - URI uri = UriBuilder.fromUri(uriString).build(); - String rawPath = uri.getRawPath(); - result = Optional.of(rawPath.replaceAll("/aai/v\\d+", "")); - } else if (results.getResult().isEmpty()) { - result = Optional.empty(); - } else { - throw new IllegalStateException("more than one result returned"); - } - - return result; - } - - protected Optional<String> getCachedValue() { - return this.cachedValue; - } - - @Override - public URI build() { - try { - if (this.values.length == 1) { - String uri = getSerivceInstance(this.values[0]); - Map<String, String> map = getURIKeys(uri); - return super.build(map.values().toArray(values)); - } - } catch (AAIUriNotFoundException | AAIPayloadException e) { - throw new AAIUriComputationException(e); - } - return super.build(); - } - - @Override - public ServiceInstanceUri clone() { - return new ServiceInstanceUri(this.internalURI.clone(), this.getCachedValue(), values); - } - - protected AAIQueryClient getQueryClient() { - return new AAIQueryClient(); - } -}
\ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/SimpleUri.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/SimpleUri.java deleted file mode 100644 index f3e6fad48b..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/SimpleUri.java +++ /dev/null @@ -1,187 +0,0 @@ -/*- - * ============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.openecomp.mso.client.aai.entities.uri; - -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.Map; - -import javax.ws.rs.core.UriBuilder; - -import org.openecomp.mso.client.aai.AAIObjectPlurals; -import org.openecomp.mso.client.aai.AAIObjectType; -import org.openecomp.mso.client.aai.entities.uri.parsers.UriParser; -import org.openecomp.mso.client.aai.entities.uri.parsers.UriParserSpringImpl; -import org.springframework.web.util.UriUtils; - -public class SimpleUri implements AAIResourceUri { - - protected UriBuilder internalURI; - protected final static String relationshipAPI = "/relationship-list/relationship"; - protected final static String relatedTo = "/related-to"; - protected final Object[] values; - protected final AAIObjectType type; - protected final AAIObjectPlurals pluralType; - protected SimpleUri(AAIObjectType type, Object... values) { - this.type = type; - this.pluralType = null; - this.internalURI = UriBuilder.fromPath(this.getTemplate(type)); - this.values = values; - } - protected SimpleUri(AAIObjectType type, URI uri) { - this.type = type; - this.pluralType = null; - this.internalURI = UriBuilder.fromPath(uri.getRawPath().replaceAll("/aai/v\\d+", "")); - this.values = new Object[0]; - } - protected SimpleUri(AAIObjectType type, UriBuilder builder, Object... values) { - this.internalURI = builder; - this.values = values; - this.type = type; - this.pluralType = null; - } - protected SimpleUri(AAIObjectPlurals type, UriBuilder builder, Object... values) { - this.internalURI = builder; - this.values = values; - this.type = null; - this.pluralType = type; - } - protected SimpleUri(AAIObjectPlurals type) { - this.type = null; - this.pluralType = type; - this.internalURI = UriBuilder.fromPath(this.getTemplate(type)); - this.values = new Object[0]; - } - - @Override - public SimpleUri relationshipAPI() { - this.internalURI = internalURI.path(relationshipAPI); - return this; - } - - @Override - public SimpleUri relatedTo(AAIObjectPlurals plural) { - - this.internalURI = internalURI.path(relatedTo).path(plural.partialUri()); - return this; - } - @Override - public SimpleUri relatedTo(AAIObjectType type, String... values) { - this.internalURI = internalURI.path(relatedTo).path(UriBuilder.fromPath(type.partialUri()).build(values).toString()); - return this; - } - - @Override - public SimpleUri resourceVersion(String version) { - this.internalURI = internalURI.queryParam("resource-version", version); - return this; - } - - @Override - public SimpleUri queryParam(String name, String... values) { - this.internalURI = internalURI.queryParam(name, values); - return 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++) { - try { - encoded[i] = UriUtils.encode(values[i].toString(), StandardCharsets.UTF_8.toString()); - } catch (UnsupportedEncodingException e) { - encoded[i] = values[i].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 AAIObjectType getObjectType() { - return this.type; - } - - @Override - public boolean equals(Object o) { - if (o instanceof AAIUri) { - return this.build().equals(((AAIUri)o).build()); - } - return false; - } - @Override - public SimpleUri depth(Depth depth) { - this.internalURI.queryParam("depth", depth.toString()); - return this; - } - @Override - public SimpleUri nodesOnly(boolean nodesOnly) { - if (nodesOnly) { - this.internalURI.queryParam("nodes-only", ""); - } - return this; - } - - protected String getTemplate(AAIObjectType type) { - return type.uriTemplate(); - } - - protected String getTemplate(AAIObjectPlurals type) { - return type.uriTemplate(); - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParser.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParser.java deleted file mode 100644 index 8e37d595b0..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParser.java +++ /dev/null @@ -1,29 +0,0 @@ -/*- - * ============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.openecomp.mso.client.aai.entities.uri.parsers; - -import java.util.Map; -import java.util.Set; - -public interface UriParser { - public Set<String> getVariables(); - public Map<String, String> parse(final String uri); -}
\ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParserSpringImpl.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParserSpringImpl.java deleted file mode 100644 index 75f9005125..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParserSpringImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * ============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.openecomp.mso.client.aai.entities.uri.parsers; -import java.io.UnsupportedEncodingException; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import org.springframework.web.util.UriTemplate; -import org.springframework.web.util.UriUtils; - -public class UriParserSpringImpl implements UriParser { - - private final UriTemplate uriTemplate; - - public UriParserSpringImpl(final String template) { - this.uriTemplate = new UriTemplate(template); - } - - @Override - public Map<String, String> parse(final String uri) { - final boolean match = this.uriTemplate.matches(uri); - if (!match) { - return new LinkedHashMap<>(); - } - return Collections.unmodifiableMap(decodeParams(this.uriTemplate.match(uri))); - } - - @Override - public Set<String> getVariables() { - return Collections.unmodifiableSet(new LinkedHashSet<String>(this.uriTemplate.getVariableNames())); - } - - protected Map<String, String> decodeParams(Map<String, String> map) { - final Map<String, String> result = new LinkedHashMap<>(); - - for (Entry<String, String> entry : map.entrySet()) { - try { - result.put(entry.getKey(), UriUtils.decode(entry.getValue(), "UTF-8")); - } catch (UnsupportedEncodingException e) { - result.put(entry.getKey(), ""); - } - } - - return result; - } -}
\ No newline at end of file |