2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 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=========================================================
21 package org.openecomp.aai.parsers.uri;
23 import java.io.UnsupportedEncodingException;
25 import java.util.ArrayList;
26 import java.util.List;
28 import javax.ws.rs.core.MultivaluedMap;
30 import org.openecomp.aai.exceptions.AAIException;
31 import org.openecomp.aai.introspection.Introspector;
32 import org.openecomp.aai.introspection.Loader;
33 import org.openecomp.aai.restcore.HttpMethod;
34 import com.google.common.base.CaseFormat;
35 import com.google.common.base.Joiner;
38 * The Class URIToExtensionInformation.
40 public class URIToExtensionInformation implements Parsable {
42 private String namespace = "";
44 private String methodName = "";
46 private String topObject = "";
48 private List<String> pieces = null;
51 * Instantiates a new URI to extension information.
53 * @param loader the loader
55 * @throws IllegalArgumentException the illegal argument exception
56 * @throws AAIException the AAI exception
57 * @throws UnsupportedEncodingException the unsupported encoding exception
59 public URIToExtensionInformation(Loader loader, URI uri) throws IllegalArgumentException, AAIException, UnsupportedEncodingException {
60 pieces = new ArrayList<>();
61 URIParser parser = new URIParser(loader, uri);
64 this.methodName = Joiner.on("").join(this.pieces);
71 public void processObject(Introspector obj, MultivaluedMap<String, String> uriKeys) {
72 String upperCamel = toUpperCamel(obj.getDbName());
73 if (topObject.equals("")) {
74 topObject = upperCamel;
76 pieces.add(upperCamel);
84 public void processContainer(Introspector obj, MultivaluedMap<String, String> uriKeys, boolean isFinalContainer) {
85 pieces.add(toUpperCamel(obj.getName()));
92 public void processNamespace(Introspector obj) {
93 this.namespace = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL, obj.getDbName());
94 pieces.add(toUpperCamel(obj.getDbName()));
102 public String getCloudRegionTransform() {
110 public boolean useOriginalLoader() {
115 * Gets the namespace.
117 * @return the namespace
119 public String getNamespace() {
120 return this.namespace;
124 * Gets the top object.
126 * @return the top object
128 public String getTopObject() {
129 return this.topObject;
133 * Gets the method name.
135 * @param httpMethod the http method
136 * @param isPreprocess the is preprocess
137 * @return the method name
139 public String getMethodName(HttpMethod httpMethod, boolean isPreprocess) {
140 String result = "Dynamic";
141 if (httpMethod.equals(HttpMethod.PUT)) {
143 } else if (httpMethod.equals(HttpMethod.DELETE)) {
146 throw new IllegalArgumentException("http method not supported: " + httpMethod);
148 result += this.methodName;
153 result += "PostProc";
161 * @param name the name
164 private String toUpperCamel(String name) {
166 result = CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, name);