2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 Wipro Limited.
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.onap.policy.controlloop.actor.so;
23 import java.util.List;
25 import java.util.concurrent.CompletableFuture;
26 import javax.ws.rs.client.Entity;
27 import javax.ws.rs.core.MediaType;
28 import org.onap.policy.common.endpoints.event.comm.Topic;
29 import org.onap.policy.common.endpoints.utils.NetLoggerUtil;
30 import org.onap.policy.common.utils.coder.CoderException;
31 import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
32 import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
33 import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
34 import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig;
35 import org.onap.policy.so.SoRequest3gpp;
37 public class ModifyNssi extends SoOperation {
38 public static final String NAME = "Modify NSSI";
40 private static final List<String> PROPERTY_NAMES = List.of(
41 OperationProperties.AAI_SERVICE,
42 OperationProperties.EVENT_PAYLOAD);
45 * Constructs the object.
47 * @param params operation parameters
48 * @param config configuration for this operation
50 public ModifyNssi(ControlLoopOperationParams params, HttpPollingConfig config) {
51 super(params, config, PROPERTY_NAMES);
55 protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
57 SoRequest3gpp soRequest = makeRequest();
59 String path = getPath();
60 String url = getClient().getBaseUrl() + path;
62 String strRequest = prettyPrint(soRequest);
63 logMessage(NetLoggerUtil.EventType.OUT, Topic.CommInfrastructure.REST, url, strRequest);
65 Entity<String> entity = Entity.entity(strRequest, MediaType.APPLICATION_JSON);
66 Map<String, Object> headers = createSimpleHeaders();
68 return handleResponse(outcome, url, callback -> getClient().put(callback, path, entity, headers));
71 private SoRequest3gpp makeRequest() {
73 Map<String, Object> payload = params.getPayload();
76 return getCoder().convert(payload, SoRequest3gpp.class);
77 } catch (CoderException e) {
78 throw new IllegalArgumentException("invalid payload value: " + payload, e);