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;
26 import java.net.URISyntaxException;
29 import java.util.Properties;
31 import org.onap.ccsdk.sli.adaptors.aai.data.AAIDatum;
33 import com.fasterxml.jackson.core.JsonProcessingException;
34 import com.fasterxml.jackson.databind.ObjectMapper;
36 public class UpdateRequest extends AAIRequest {
38 private AAIRequest request;
39 private Map<String, String> params;
41 public UpdateRequest(AAIRequest request, Map<String, String> parms) {
42 this.request = request;
47 public URL getRequestUrl(String method, String resourceVersion)
48 throws UnsupportedEncodingException, MalformedURLException, URISyntaxException {
49 return request.getRequestUrl(method, resourceVersion);
53 public URL getRequestQueryUrl(String method) throws UnsupportedEncodingException, MalformedURLException, URISyntaxException {
54 return request.getRequestQueryUrl(method);
58 public String toJSONString() {
59 ObjectMapper mapper = AAIService.getObjectMapper();
63 json = mapper.writeValueAsString(params);
64 } catch (JsonProcessingException e) {
65 LOG.error("Could not convert parameters of " + request.getRequestObject().getClass().getName(), e);
72 public String[] getArgsList() {
73 return request.getArgsList();
77 public Class<? extends AAIDatum> getModelClass() {
78 return request.getModelClass();
82 public void addRequestProperty(String key, String value) {
83 request.requestProperties.put(key, value);
86 public static String processPathData(String request_url, Properties requestProperties) throws UnsupportedEncodingException {
88 // if(request != null) {
89 // Class<?> clazz = request.getClass();
90 // Method function = null;
92 // function = clazz.getMethod("processPathData", request_url.getClass(), requestProperties.getClass());
93 // request_url = (String) function.invoke(null, request_url, requestProperties);
94 // } catch (Exception e) {
95 // e.printStackTrace();
99 // request.processPathData(request_url, requestProperties);
103 public void processRequestPathValues(Map<String, String> nameValues) {
104 request.processRequestPathValues(nameValues);