2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * Modifications Copyright (C) 2018 IBM.
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.ccsdk.sli.adaptors.aai;
25 import java.io.UnsupportedEncodingException;
26 import java.net.MalformedURLException;
27 import java.net.URISyntaxException;
30 import java.util.Properties;
32 import org.onap.ccsdk.sli.adaptors.aai.data.AAIDatum;
34 import com.fasterxml.jackson.core.JsonProcessingException;
35 import com.fasterxml.jackson.databind.ObjectMapper;
37 public class UpdateRequest extends AAIRequest {
39 private AAIRequest request;
40 private Map<String, String> params;
42 public UpdateRequest(AAIRequest request, Map<String, String> parms) {
43 this.request = request;
48 public URL getRequestUrl(String method, String resourceVersion)
49 throws UnsupportedEncodingException, MalformedURLException, URISyntaxException {
50 return request.getRequestUrl(method, resourceVersion);
54 public URL getRequestQueryUrl(String method) throws UnsupportedEncodingException, MalformedURLException, URISyntaxException {
55 return request.getRequestQueryUrl(method);
59 public String toJSONString() {
60 ObjectMapper mapper = AAIService.getObjectMapper();
64 json = mapper.writeValueAsString(params);
65 } catch (JsonProcessingException e) {
66 LOG.error("Could not convert parameters of " + request.getRequestObject().getClass().getName(), e);
73 public String[] getArgsList() {
74 return request.getArgsList();
78 public Class<? extends AAIDatum> getModelClass() {
79 return request.getModelClass();
83 public void addRequestProperty(String key, String value) {
84 request.requestProperties.put(key, value);
87 public static String processPathData(String requestUrl, Properties requestProperties) {
89 // if(request != null) {
90 // Class<?> clazz = request.getClass();
91 // Method function = null;
93 // function = clazz.getMethod("processPathData", request_url.getClass(), requestProperties.getClass());
94 // request_url = (String) function.invoke(null, request_url, requestProperties);
95 // } catch (Exception e) {
96 // e.printStackTrace();
100 // request.processPathData(request_url, requestProperties);
104 public void processRequestPathValues(Map<String, String> nameValues) {
105 request.processRequestPathValues(nameValues);