2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.policy.pypdp;
23 import java.util.UUID;
25 import org.openecomp.policy.api.DeletePolicyParameters;
26 import org.openecomp.policy.api.PolicyConfigException;
27 import org.openecomp.policy.std.StdPolicyEngine;
29 import org.openecomp.policy.xacml.api.XACMLErrorConstants;
31 import org.openecomp.policy.common.logging.eelf.PolicyLogger;
33 public class DeletePolicyRequest {
34 private StdPolicyEngine pe;
35 public DeletePolicyRequest(StdPolicyEngine pe){
39 public String run(DeletePolicyParameters pep, String requestID, String userID, String passcode) {
43 // construct a UUID from the request string
44 if(pep.getRequestID()==null){
45 if (requestID != null && !requestID.isEmpty()) {
47 pep.setRequestID(UUID.fromString(requestID));
49 catch (IllegalArgumentException e) {
50 pep.setRequestID(UUID.randomUUID());
51 PolicyLogger.info("Generated Random UUID: " + pep.getRequestID().toString());
56 if (pep.getPolicyName()!= null && !pep.getPolicyName().isEmpty()) {
57 if (pep.getPolicyComponent() != null && !pep.getPolicyComponent().isEmpty()) {
61 result = pe.deletePolicy(pep, userID, passcode).getResponseMessage();
63 } catch (PolicyConfigException e) {
64 result = e.getMessage();
65 } catch (Exception e) {
66 // TODO Auto-generated catch block
71 result = XACMLErrorConstants.ERROR_DATA_ISSUE + "BAD REQUEST: policyComponent was null or empty.";
74 result = XACMLErrorConstants.ERROR_DATA_ISSUE + "BAD REQUEST: policyName was null or empty.";