2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 ONAP 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.openecomp.sdnc.sli.aai;
24 import java.io.UnsupportedEncodingException;
25 import java.net.MalformedURLException;
28 import java.util.Properties;
30 import org.openecomp.sdnc.sli.aai.data.AAIDatum;
32 import com.fasterxml.jackson.core.JsonProcessingException;
33 import com.fasterxml.jackson.databind.ObjectMapper;
35 public class UpdateRequest extends AAIRequest {
37 private AAIRequest request;
38 private Map<String, String> params;
40 public UpdateRequest(AAIRequest request, Map<String, String> parms) {
41 this.request = request;
46 public URL getRequestUrl(String method, String resourceVersion)
47 throws UnsupportedEncodingException, MalformedURLException {
48 return request.getRequestUrl(method, resourceVersion);
52 public URL getRequestQueryUrl(String method) throws UnsupportedEncodingException, MalformedURLException {
53 return request.getRequestQueryUrl(method);
57 public String toJSONString() {
58 ObjectMapper mapper = AAIService.getObjectMapper();
62 json = mapper.writeValueAsString(params);
63 } catch (JsonProcessingException e) {
64 LOG.error("Could not convert parameters of " + request.getRequestObject().getClass().getName(), e);
71 public String[] getArgsList() {
72 return request.getArgsList();
76 public Class<? extends AAIDatum> getModelClass() {
77 return request.getModelClass();
81 public void addRequestProperty(String key, String value) {
82 request.requestProperties.put(key, value);
85 public static String processPathData(String request_url, Properties requestProperties) throws UnsupportedEncodingException {
87 // if(request != null) {
88 // Class<?> clazz = request.getClass();
89 // Method function = null;
91 // function = clazz.getMethod("processPathData", request_url.getClass(), requestProperties.getClass());
92 // request_url = (String) function.invoke(null, request_url, requestProperties);
93 // } catch (Exception e) {
94 // e.printStackTrace();
98 // request.processPathData(request_url, requestProperties);
102 public void processRequestPathValues(Map<String, String> nameValues) {
103 request.processRequestPathValues(nameValues);