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 com.google.common.base.CaseFormat;
24 import com.google.common.base.Joiner;
25 import org.openecomp.aai.exceptions.AAIException;
26 import org.openecomp.aai.introspection.Introspector;
27 import org.openecomp.aai.introspection.Loader;
28 import org.openecomp.aai.restcore.HttpMethod;
29 import org.openecomp.aai.serialization.db.EdgeType;
31 import javax.ws.rs.core.MultivaluedMap;
32 import java.io.UnsupportedEncodingException;
34 import java.util.ArrayList;
35 import java.util.List;
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 processNamespace(Introspector obj) {
72 this.namespace = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL, obj.getDbName());
73 pieces.add(toUpperCamel(obj.getDbName()));
81 public String getCloudRegionTransform() {
89 public boolean useOriginalLoader() {
96 * @return the namespace
98 public String getNamespace() {
99 return this.namespace;
103 * Gets the top object.
105 * @return the top object
107 public String getTopObject() {
108 return this.topObject;
112 * Gets the method name.
114 * @param httpMethod the http method
115 * @param isPreprocess the is preprocess
116 * @return the method name
118 public String getMethodName(HttpMethod httpMethod, boolean isPreprocess) {
119 String result = "Dynamic";
120 if (httpMethod.equals(HttpMethod.PUT)) {
122 } else if (httpMethod.equals(HttpMethod.DELETE)) {
125 throw new IllegalArgumentException("http method not supported: " + httpMethod);
127 result += this.methodName;
132 result += "PostProc";
140 * @param name the name
143 private String toUpperCamel(String name) {
145 result = CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, name);
150 public void processObject(Introspector obj, EdgeType type, MultivaluedMap<String, String> uriKeys)
151 throws AAIException {
152 String upperCamel = toUpperCamel(obj.getDbName());
153 if (topObject.equals("")) {
154 topObject = upperCamel;
156 pieces.add(upperCamel);
160 public void processContainer(Introspector obj, EdgeType type, MultivaluedMap<String, String> uriKeys,
161 boolean isFinalContainer) throws AAIException {
162 pieces.add(toUpperCamel(obj.getName()));