2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
 
   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.
 
  19  * SPDX-License-Identifier: Apache-2.0
 
  20  * ============LICENSE_END=========================================================
 
  23 package org.onap.policy.pdp.xacml.application.common.std;
 
  25 import com.att.research.xacml.std.annotations.XACMLAction;
 
  26 import com.att.research.xacml.std.annotations.XACMLRequest;
 
  27 import com.att.research.xacml.std.annotations.XACMLResource;
 
  28 import com.att.research.xacml.std.annotations.XACMLSubject;
 
  31 import java.util.Map.Entry;
 
  33 import org.onap.policy.models.decisions.concepts.DecisionRequest;
 
  35 @XACMLRequest(ReturnPolicyIdList = true)
 
  36 public class StdCombinedPolicyRequest {
 
  38     public StdCombinedPolicyRequest() {
 
  42     @XACMLSubject(includeInResults = true)
 
  43     String onapName = "DCAE";
 
  45     @XACMLResource(includeInResults = true)
 
  46     String resource = "onap.policies.Monitoring";
 
  49     String action = "configure";
 
  53      * Parses the DecisionRequest into a MonitoringRequest.
 
  55      * @param decisionRequest Input DecisionRequest
 
  56      * @return MonitoringRequest
 
  58     public static StdCombinedPolicyRequest createInstance(DecisionRequest decisionRequest) {
 
  59         StdCombinedPolicyRequest request = new StdCombinedPolicyRequest();
 
  60         request.onapName = decisionRequest.getOnapName();
 
  61         request.action = decisionRequest.getAction();
 
  63         Map<String, Object> resources = decisionRequest.getResource();
 
  64         for (Entry<String, Object> entry : resources.entrySet()) {
 
  65             if ("policy-id".equals(entry.getKey())) {
 
  67                 // TODO handle lists of policies
 
  69                 request.resource = entry.getValue().toString();
 
  72             if ("policy-type".equals(entry.getKey())) {
 
  74                 // TODO handle lists of policies
 
  76                 request.resource = entry.getValue().toString();
 
  80         // TODO handle a bad incoming request. Do that here?