diff options
author | Bin Yang <bin.yang@windriver.com> | 2019-04-16 06:33:04 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-04-16 06:33:04 +0000 |
commit | e8697face7909927a9ddb418f116c76e3c6d8c8f (patch) | |
tree | 2b4a9c252553768b405fe0ca7f79c98dda3db22c /artifactbroker/plugins | |
parent | e3e4aaf2140c94fe0811c40186df2f860a2346d7 (diff) | |
parent | 88d98921926c194899a393aa08f4793afc026b8c (diff) |
Merge "Fix the sonar issue and clm issue"
Diffstat (limited to 'artifactbroker/plugins')
6 files changed, 1 insertions, 177 deletions
diff --git a/artifactbroker/plugins/forwarding-plugins/pom.xml b/artifactbroker/plugins/forwarding-plugins/pom.xml index 9ceab89..8b4e8cb 100644 --- a/artifactbroker/plugins/forwarding-plugins/pom.xml +++ b/artifactbroker/plugins/forwarding-plugins/pom.xml @@ -40,17 +40,6 @@ <artifactId>multicloud-framework-artifactbroker-main</artifactId> <version>${project.version}</version> </dependency> - <dependency> - <groupId>org.onap.policy.engine</groupId> - <artifactId>PolicyEngineAPI</artifactId> - <version>${policy.engine.version}</version> - <exclusions> - <exclusion> - <groupId>org.eclipse.persistence</groupId> - <artifactId>eclipselink</artifactId> - </exclusion> - </exclusions> - </dependency> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-all</artifactId> diff --git a/artifactbroker/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpArtifactForwarder.java b/artifactbroker/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpArtifactForwarder.java index 3fe6dd8..4179fc7 100644 --- a/artifactbroker/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpArtifactForwarder.java +++ b/artifactbroker/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpArtifactForwarder.java @@ -52,12 +52,10 @@ import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.common.parameters.ParameterService; import org.onap.policy.distribution.forwarding.ArtifactForwarder; -import org.onap.policy.distribution.forwarding.xacml.pdp.adapters.XacmlPdpOptimizationPolicyAdapter; import org.onap.policy.distribution.model.CloudArtifact; import org.onap.policy.distribution.model.PolicyInput; import org.onap.policy.distribution.model.VfModuleModel; import org.onap.sdc.api.notification.IArtifactInfo; -import org.springframework.http.HttpStatus; /** diff --git a/artifactbroker/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpPolicyAdapter.java b/artifactbroker/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpPolicyAdapter.java deleted file mode 100644 index c50eac1..0000000 --- a/artifactbroker/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpPolicyAdapter.java +++ /dev/null @@ -1,53 +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.forwarding.xacml.pdp; - -import org.onap.policy.api.PolicyParameters; -import org.onap.policy.api.PushPolicyParameters; -import org.onap.policy.distribution.model.Policy; - -/** - * Adapts {@link Policy} objects to objects compatible with the XACML PDP API. - */ -public interface XacmlPdpPolicyAdapter<T extends Policy> { - - /** - * Get the policy. - * - * @return the policy - */ - T getPolicy(); - - /** - * Get as a {@link PolicyParameters} object. - * - * @returna {@link PolicyParameters} object - */ - PolicyParameters getAsPolicyParameters(); - - /** - * Get as a {@link PushPolicyParameters} object. - * - * @returna {@link PushPolicyParameters} object - */ - PushPolicyParameters getAsPushPolicyParameters(final String pdpGroups); - -} diff --git a/artifactbroker/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/adapters/AbstractXacmlPdpPolicyAdapter.java b/artifactbroker/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/adapters/AbstractXacmlPdpPolicyAdapter.java deleted file mode 100644 index c136516..0000000 --- a/artifactbroker/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/adapters/AbstractXacmlPdpPolicyAdapter.java +++ /dev/null @@ -1,54 +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.forwarding.xacml.pdp.adapters; - -import org.onap.policy.api.PushPolicyParameters; -import org.onap.policy.distribution.forwarding.xacml.pdp.XacmlPdpPolicyAdapter; -import org.onap.policy.distribution.model.Policy; - -/** - * Base class for {@link XacmlPdpPolicyAdapter} implementations. - * - * @param <T> the type of policy the adapter handles - */ -public abstract class AbstractXacmlPdpPolicyAdapter<T extends Policy> implements XacmlPdpPolicyAdapter<T> { - - private T policy; - - protected AbstractXacmlPdpPolicyAdapter(T policy) { - this.policy = policy; - } - - @Override - public T getPolicy() { - return policy; - } - - @Override - public PushPolicyParameters getAsPushPolicyParameters(String pdpGroups) { - PushPolicyParameters pushPolicyParameters = new PushPolicyParameters(); - pushPolicyParameters.setPolicyName(policy.getPolicyName()); - pushPolicyParameters.setPolicyType(policy.getPolicyType()); - pushPolicyParameters.setPdpGroup(pdpGroups); - return pushPolicyParameters; - } - -} diff --git a/artifactbroker/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/adapters/XacmlPdpOptimizationPolicyAdapter.java b/artifactbroker/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/adapters/XacmlPdpOptimizationPolicyAdapter.java deleted file mode 100644 index 1ec654f..0000000 --- a/artifactbroker/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/adapters/XacmlPdpOptimizationPolicyAdapter.java +++ /dev/null @@ -1,54 +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.forwarding.xacml.pdp.adapters; - -import org.onap.policy.api.PolicyConfigType; -import org.onap.policy.api.PolicyParameters; -import org.onap.policy.distribution.model.OptimizationPolicy; - -/** - * Adapts {@link OptimizationPolicy} objects to objects compatible with the XACML PDP API. - */ -public class XacmlPdpOptimizationPolicyAdapter extends AbstractXacmlPdpPolicyAdapter<OptimizationPolicy> { - - /** - * Create an instance to adapt the given {@link OptimizationPolicy}. - * - * @param optimizationPolicy the {@link OptimizationPolicy} to be adapted - */ - public XacmlPdpOptimizationPolicyAdapter(final OptimizationPolicy optimizationPolicy) { - super(optimizationPolicy); - } - - @Override - public PolicyParameters getAsPolicyParameters() { - PolicyParameters policyParameters = new PolicyParameters(); - policyParameters.setPolicyName(getPolicy().getPolicyName()); - policyParameters.setPolicyDescription(getPolicy().getPolicyDescription()); - policyParameters.setPolicyConfigType(PolicyConfigType.valueOf(getPolicy().getPolicyConfigType())); - policyParameters.setOnapName(getPolicy().getOnapName()); - policyParameters.setRiskLevel(getPolicy().getRiskLevel()); - policyParameters.setConfigBody(getPolicy().getConfigBody()); - policyParameters.setRiskType(getPolicy().getRiskType()); - return policyParameters; - } - -} diff --git a/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java index 37fb314..8bf69da 100644 --- a/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java +++ b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java @@ -338,10 +338,8 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo private static void writeFileByFileWriter(String filePath, String content) throws IOException { File file = new File(filePath); synchronized (file) { - try { - FileWriter fw = new FileWriter(filePath); + try (FileWriter fw = new FileWriter(filePath)) { fw.write(content); - fw.close(); } catch (final IOException exp) { LOGGER.error("Failed to write File by File Writer ", exp); } |