2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.aai.parsers.uri;
23 import com.google.common.base.CaseFormat;
24 import com.google.common.base.Joiner;
26 import java.io.UnsupportedEncodingException;
28 import java.util.ArrayList;
29 import java.util.List;
31 import javax.ws.rs.core.MultivaluedMap;
33 import org.onap.aai.edges.enums.EdgeType;
34 import org.onap.aai.exceptions.AAIException;
35 import org.onap.aai.introspection.Introspector;
36 import org.onap.aai.introspection.Loader;
37 import org.onap.aai.restcore.HttpMethod;
40 * The Class URIToExtensionInformation.
42 public class URIToExtensionInformation implements Parsable {
44 private String namespace = "";
46 private String methodName = "";
48 private String topObject = "";
50 private List<String> pieces = null;
53 * Instantiates a new URI to extension information.
55 * @param loader the loader
57 * @throws IllegalArgumentException the illegal argument exception
58 * @throws AAIException the AAI exception
59 * @throws UnsupportedEncodingException the unsupported encoding exception
61 public URIToExtensionInformation(Loader loader, URI uri)
62 throws IllegalArgumentException, AAIException, UnsupportedEncodingException {
63 pieces = new ArrayList<>();
64 URIParser parser = new URIParser(loader, uri);
67 this.methodName = Joiner.on("").join(this.pieces);
74 public void processNamespace(Introspector obj) {
75 this.namespace = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL, obj.getDbName());
76 pieces.add(toUpperCamel(obj.getDbName()));
84 public String getCloudRegionTransform() {
92 public boolean useOriginalLoader() {
99 * @return the namespace
101 public String getNamespace() {
102 return this.namespace;
106 * Gets the top object.
108 * @return the top object
110 public String getTopObject() {
111 return this.topObject;
115 * Gets the method name.
117 * @param httpMethod the http method
118 * @param isPreprocess the is preprocess
119 * @return the method name
121 public String getMethodName(HttpMethod httpMethod, boolean isPreprocess) {
122 String result = "Dynamic";
124 * if (httpMethod.equals(HttpMethod.PUT) || httpMethod.equals(HttpMethod.PUT_EDGE)) {
128 if (httpMethod.equals(HttpMethod.PUT)) {
130 } else if (httpMethod.equals(HttpMethod.PUT_EDGE)) {
132 } else if (httpMethod.equals(HttpMethod.DELETE)) {
135 throw new IllegalArgumentException("http method not supported: " + httpMethod);
137 result += this.methodName;
142 result += "PostProc";
150 * @param name the name
153 private String toUpperCamel(String name) {
155 result = CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, name);
160 public void processObject(Introspector obj, EdgeType type, MultivaluedMap<String, String> uriKeys)
161 throws AAIException {
162 String upperCamel = toUpperCamel(obj.getDbName());
163 if (topObject.equals("")) {
164 topObject = upperCamel;
166 pieces.add(upperCamel);
170 public void processContainer(Introspector obj, EdgeType type, MultivaluedMap<String, String> uriKeys,
171 boolean isFinalContainer) throws AAIException {
172 pieces.add(toUpperCamel(obj.getName()));