2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.sli.adaptors.aai;
24 import java.io.UnsupportedEncodingException;
25 import java.net.MalformedURLException;
29 import org.onap.ccsdk.sli.adaptors.aai.data.AAIDatum;
31 import com.fasterxml.jackson.core.JsonProcessingException;
32 import com.fasterxml.jackson.databind.ObjectMapper;
33 import com.google.common.base.Joiner;
35 public class SelfLinkRequest extends AAIRequest {
37 private final Class<? extends AAIDatum> classType;
39 public static final String SELFLINK = "selflink";
41 public SelfLinkRequest(Class<?> type) {
42 classType = (Class<? extends AAIDatum>)type;
47 public URL getRequestUrl(String method, String resourceVersion) throws UnsupportedEncodingException, MalformedURLException {
49 String request_url = null;
51 request_url = requestProperties.getProperty(SELFLINK);
53 URI uri = new URI(request_url);
54 if(uri.getHost() == null) {
55 request_url = target_uri + request_url;
57 } catch(Exception exc) {
58 LOG.error("SelfLinkRequest.getRequestUrl", exc);
62 if(request_url.contains("?")) {
63 query = request_url.substring(request_url.indexOf("?"));
64 Joiner.MapJoiner mapJoiner = Joiner.on(",").withKeyValueSeparator("=");
65 // String queryString = mapJoiner.join(query);
67 request_url = request_url + "?depth=1";
70 URL http_req_url = new URL(request_url);
72 aaiService.LOGwriteFirstTrace(method, http_req_url.toString());
78 public URL getRequestQueryUrl(String method) throws UnsupportedEncodingException, MalformedURLException {
79 return this.getRequestUrl(method, null);
84 public String toJSONString() {
85 ObjectMapper mapper = getObjectMapper();
86 String json_text = null;
88 json_text = mapper.writeValueAsString(classType);
89 } catch (JsonProcessingException exc) {
90 handleException(this, exc);
97 public String[] getArgsList() {
98 String[] args = {SELFLINK};
103 public Class<? extends AAIDatum> getModelClass() {