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=========================================================
20 package org.onap.aai.parsers.uri;
22 import com.google.common.base.CaseFormat;
23 import com.google.common.base.Joiner;
24 import org.onap.aai.exceptions.AAIException;
25 import org.onap.aai.introspection.Introspector;
26 import org.onap.aai.introspection.Loader;
27 import org.onap.aai.restcore.HttpMethod;
28 import org.onap.aai.serialization.db.EdgeType;
30 import javax.ws.rs.core.MultivaluedMap;
31 import java.io.UnsupportedEncodingException;
33 import java.util.ArrayList;
34 import java.util.List;
37 * The Class URIToExtensionInformation.
39 public class URIToExtensionInformation implements Parsable {
41 private String namespace = "";
43 private String methodName = "";
45 private String topObject = "";
47 private List<String> pieces = null;
50 * Instantiates a new URI to extension information.
52 * @param loader the loader
54 * @throws IllegalArgumentException the illegal argument exception
55 * @throws AAIException the AAI exception
56 * @throws UnsupportedEncodingException the unsupported encoding exception
58 public URIToExtensionInformation(Loader loader, URI uri) throws IllegalArgumentException, AAIException, UnsupportedEncodingException {
59 pieces = new ArrayList<>();
60 URIParser parser = new URIParser(loader, uri);
63 this.methodName = Joiner.on("").join(this.pieces);
70 public void processNamespace(Introspector obj) {
71 this.namespace = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL, obj.getDbName());
72 pieces.add(toUpperCamel(obj.getDbName()));
80 public String getCloudRegionTransform() {
88 public boolean useOriginalLoader() {
95 * @return the namespace
97 public String getNamespace() {
98 return this.namespace;
102 * Gets the top object.
104 * @return the top object
106 public String getTopObject() {
107 return this.topObject;
111 * Gets the method name.
113 * @param httpMethod the http method
114 * @param isPreprocess the is preprocess
115 * @return the method name
117 public String getMethodName(HttpMethod httpMethod, boolean isPreprocess) {
118 String result = "Dynamic";
120 if (httpMethod.equals(HttpMethod.PUT) || httpMethod.equals(HttpMethod.PUT_EDGE)) {
124 if (httpMethod.equals(HttpMethod.PUT) ) {
126 } else if (httpMethod.equals(HttpMethod.PUT_EDGE)) {
128 } else if (httpMethod.equals(HttpMethod.DELETE)) {
131 throw new IllegalArgumentException("http method not supported: " + httpMethod);
133 result += this.methodName;
138 result += "PostProc";
146 * @param name the name
149 private String toUpperCamel(String name) {
151 result = CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, name);
156 public void processObject(Introspector obj, EdgeType type, MultivaluedMap<String, String> uriKeys)
157 throws AAIException {
158 String upperCamel = toUpperCamel(obj.getDbName());
159 if (topObject.equals("")) {
160 topObject = upperCamel;
162 pieces.add(upperCamel);
166 public void processContainer(Introspector obj, EdgeType type, MultivaluedMap<String, String> uriKeys,
167 boolean isFinalContainer) throws AAIException {
168 pieces.add(toUpperCamel(obj.getName()));