2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 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 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 package org.onap.aai.parsers.uri;
24 import com.google.common.base.CaseFormat;
25 import com.google.common.base.Joiner;
26 import org.onap.aai.exceptions.AAIException;
27 import org.onap.aai.introspection.Introspector;
28 import org.onap.aai.introspection.Loader;
29 import org.onap.aai.restcore.HttpMethod;
30 import org.onap.aai.serialization.db.EdgeType;
32 import javax.ws.rs.core.MultivaluedMap;
33 import java.io.UnsupportedEncodingException;
35 import java.util.ArrayList;
36 import java.util.List;
39 * The Class URIToExtensionInformation.
41 public class URIToExtensionInformation implements Parsable {
43 private String namespace = "";
45 private String methodName = "";
47 private String topObject = "";
49 private List<String> pieces = null;
52 * Instantiates a new URI to extension information.
54 * @param loader the loader
56 * @throws IllegalArgumentException the illegal argument exception
57 * @throws AAIException the AAI exception
58 * @throws UnsupportedEncodingException the unsupported encoding exception
60 public URIToExtensionInformation(Loader loader, URI uri) throws IllegalArgumentException, AAIException, UnsupportedEncodingException {
61 pieces = new ArrayList<>();
62 URIParser parser = new URIParser(loader, uri);
65 this.methodName = Joiner.on("").join(this.pieces);
72 public void processNamespace(Introspector obj) {
73 this.namespace = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL, obj.getDbName());
74 pieces.add(toUpperCamel(obj.getDbName()));
82 public String getCloudRegionTransform() {
90 public boolean useOriginalLoader() {
97 * @return the namespace
99 public String getNamespace() {
100 return this.namespace;
104 * Gets the top object.
106 * @return the top object
108 public String getTopObject() {
109 return this.topObject;
113 * Gets the method name.
115 * @param httpMethod the http method
116 * @param isPreprocess the is preprocess
117 * @return the method name
119 public String getMethodName(HttpMethod httpMethod, boolean isPreprocess) {
120 String result = "Dynamic";
122 if (httpMethod.equals(HttpMethod.PUT) || httpMethod.equals(HttpMethod.PUT_EDGE)) {
126 if (httpMethod.equals(HttpMethod.PUT) ) {
128 } else if (httpMethod.equals(HttpMethod.PUT_EDGE)) {
130 } else if (httpMethod.equals(HttpMethod.DELETE)) {
133 throw new IllegalArgumentException("http method not supported: " + httpMethod);
135 result += this.methodName;
140 result += "PostProc";
148 * @param name the name
151 private String toUpperCamel(String name) {
153 result = CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, name);
158 public void processObject(Introspector obj, EdgeType type, MultivaluedMap<String, String> uriKeys)
159 throws AAIException {
160 String upperCamel = toUpperCamel(obj.getDbName());
161 if (topObject.equals("")) {
162 topObject = upperCamel;
164 pieces.add(upperCamel);
168 public void processContainer(Introspector obj, EdgeType type, MultivaluedMap<String, String> uriKeys,
169 boolean isFinalContainer) throws AAIException {
170 pieces.add(toUpperCamel(obj.getName()));