From e80efa0dbe903e976f5b2799144658c7ba02e534 Mon Sep 17 00:00:00 2001 From: ramverma Date: Thu, 13 Sep 2018 16:31:35 +0100 Subject: Adding policy decoder to extract file from csar * Adding decoder configuration parameters infrastructure to support plugin based architecture. Adding a new policy decoder after this will be just creating a new decoder class and its corresponding parameter class. * Adding a new decoder which extracts policy file from given csar. It is written in a generic way to extract file for any pdp like apex, drools. * Adding configuration parameters for the new decoder. The policy file name and policy type is passed as parameter to the decoder. * Fixing few broken package declaration in pdpx decoder tests. * Adding test cases for all code changes. Change-Id: I95e68cebce0f9747ca63b090f9b9116ce8836939 Issue-ID: POLICY-1101 Signed-off-by: ramverma --- .../policy/distribution/model/ApexPdpPolicy.java | 69 --------------------- .../policy/distribution/model/PolicyAsString.java | 70 ++++++++++++++++++++++ 2 files changed, 70 insertions(+), 69 deletions(-) delete mode 100644 model/src/main/java/org/onap/policy/distribution/model/ApexPdpPolicy.java create mode 100644 model/src/main/java/org/onap/policy/distribution/model/PolicyAsString.java (limited to 'model/src/main/java') diff --git a/model/src/main/java/org/onap/policy/distribution/model/ApexPdpPolicy.java b/model/src/main/java/org/onap/policy/distribution/model/ApexPdpPolicy.java deleted file mode 100644 index a8f45764..00000000 --- a/model/src/main/java/org/onap/policy/distribution/model/ApexPdpPolicy.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.distribution.model; - -import java.io.InputStream; - -/** - * This class represents an apex-pdp policy which can be decoded by a relevant {@link PolicyDecoder}. - * - * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com) - */ -public class ApexPdpPolicy implements Policy { - private String policyName; - private InputStream policyInputStream; - - /** - * Constructor for creating instance of {@link ApexPdpPolicy}. - * - * @param policyName the policy file name - * @param policyInputStream the input stream - */ - public ApexPdpPolicy(final String policyName, final InputStream policyInputStream) { - this.policyName = policyName; - this.policyInputStream = policyInputStream; - } - - /** - * Returns the policyInputStream of this ApexPdpPolicy instance. - * - * @return the policyInputStream - */ - public InputStream getPolicyInputStream() { - return policyInputStream; - } - - /** - * {@inheritDoc}. - */ - @Override - public String getPolicyName() { - return policyName; - } - - /** - * {@inheritDoc}. - */ - @Override - public String getPolicyType() { - return "Method not supported"; - } -} diff --git a/model/src/main/java/org/onap/policy/distribution/model/PolicyAsString.java b/model/src/main/java/org/onap/policy/distribution/model/PolicyAsString.java new file mode 100644 index 00000000..1600d8f7 --- /dev/null +++ b/model/src/main/java/org/onap/policy/distribution/model/PolicyAsString.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.distribution.model; + +/** + * This class represents a policy which can be decoded by a relevant {@link PolicyDecoder}. + * + * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com) + */ +public class PolicyAsString implements Policy { + private String policyName; + private String policyType; + private String policy; + + /** + * Constructor for creating instance of {@link PolicyAsString}. + * + * @param policyName the policy file name + * @param policyType the policy type + * @param policy the policy + */ + public PolicyAsString(final String policyName, final String policyType, final String policy) { + this.policyName = policyName; + this.policyType = policyType; + this.policy = policy; + } + + /** + * Returns the policy of this {@link PolicyAsString} instance. + * + * @return the policy + */ + public String getPolicy() { + return policy; + } + + /** + * {@inheritDoc}. + */ + @Override + public String getPolicyName() { + return policyName; + } + + /** + * {@inheritDoc}. + */ + @Override + public String getPolicyType() { + return policyType; + } +} -- cgit 1.2.3-korg