diff options
author | liboNet <libo.zhu@intel.com> | 2018-08-18 03:15:59 +0800 |
---|---|---|
committer | liboNet <libo.zhu@intel.com> | 2018-08-22 09:57:45 +0800 |
commit | 742c4b2ed82860e2a74f3db3b2048173fbc530d8 (patch) | |
tree | c663025f715682863056730c7dbccd8fd522ded7 /plugins/reception-plugins/src/main | |
parent | 612196451afe9b16b8914858dd58f3bb0dae8579 (diff) |
integrate PSSDConfiguration to distribution
* Integrate the PSSDConfiguration to distribution config parameter.
* Moved related PSSDConfigurationParameterGroup classes from "handling"
to "parameters" to avoid specified sdc dependency.
* Modify all the test case since the distribution config parameter
has been changed, update CommonTestData to wrap it.
* Add neccessnary SDC handling exceptions which to be used for
SDC handler integration.
* update the PSSDCOnfiguraitonParameterGroup to add UUID to the setName
function to generate unique name for each instance.
* use builder to create PSSDConfigurationParametersGroup instead of using
many parameters
Change-Id: I3c78bc2a51ebc84761bc9458096d6ffa18070b47
Issue-ID: POLICY-956
Signed-off-by: liboNet <libo.zhu@intel.com>
Diffstat (limited to 'plugins/reception-plugins/src/main')
6 files changed, 217 insertions, 199 deletions
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/PSSDConfiguration.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/PSSDConfiguration.java index 86d2a550..baba4d42 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/PSSDConfiguration.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/PSSDConfiguration.java @@ -23,6 +23,7 @@ package org.onap.policy.distribution.reception.handling.sdc; import java.util.List; import org.onap.sdc.api.consumer.IConfiguration; +import org.onap.policy.distribution.reception.parameters.PSSDConfigurationParametersGroup; /** * Properties for the handling Sdc diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/PSSDConfigurationParametersGroup.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/PSSDConfigurationParametersGroup.java deleted file mode 100644 index 7fa81149..00000000 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/PSSDConfigurationParametersGroup.java +++ /dev/null @@ -1,199 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Intel. 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.reception.handling.sdc; - -import java.util.List; - -import org.onap.policy.common.parameters.GroupValidationResult; -import org.onap.policy.common.parameters.ParameterGroup; -import org.onap.policy.common.parameters.ValidationStatus; - -/** - * This class handles reading, parsing and validating of the Policy SDC Service Distribution parameters from Json - * format, which strictly adheres to the interface:IConfiguration, defined by SDC SDK. - */ -public class PSSDConfigurationParametersGroup implements ParameterGroup { - // Policy SDC Service Distribution specified field. - private String name; - - // Interface of IConfiguration item - private String asdcAddress; - private List<String> messageBusAddress; - private String user; - private String password; - private int pollingInterval; - private int pollingTimeout; - private String consumerId; - private List<String> artifactTypes; - private String consumerGroup; - private String environmentName; - private String keystorePath; - private String keystorePassword; - private boolean activeserverTlsAuth; - private boolean isFilterinEmptyResources; - private Boolean isUseHttpsWithDmaap; - - public String getAsdcAddress() { - return asdcAddress; - } - - public List<String> getMsgBusAddress() { - return messageBusAddress; - } - - public String getUser() { - return user; - } - - public String getPassword() { - return password; - } - - public int getPollingInterval() { - return pollingInterval; - } - - public int getPollingTimeout() { - return pollingTimeout; - } - - public String getConsumerID() { - return consumerId; - } - - public List<String> getArtifactTypes() { - return artifactTypes; - } - - public String getConsumerGroup() { - return consumerGroup; - } - - public String getEnvironmentName() { - return environmentName; - } - - public String getKeyStorePassword() { - return keystorePassword; - } - - public String getKeyStorePath() { - return keystorePath; - } - - public boolean activateServerTLSAuth() { - return activeserverTlsAuth; - } - - public boolean isFilterInEmptyResources() { - return isFilterinEmptyResources; - } - - public Boolean isUseHttpsWithDmaap() { - return isUseHttpsWithDmaap; - } - - @Override - public String toString() { - return "name =" + name + ",TestParameters:[asdcAddress = " + asdcAddress + ", messageBusAddress = " - + messageBusAddress + ", user = " + user + "]"; - } - - @Override - public String getName() { - return name; - } - - @Override - public GroupValidationResult validate() { - final GroupValidationResult validationResult = new GroupValidationResult(this); - - if (name == null || name.trim().length() == 0) { - validationResult.setResult("name", ValidationStatus.INVALID, "name must be a non-blank string"); - } - - if (asdcAddress == null || asdcAddress.trim().length() == 0) { - validationResult.setResult("asdcAddress", ValidationStatus.INVALID, - "asdcAddress must be a non-blank string"); - } - - if (user == null || user.trim().length() == 0) { - validationResult.setResult("user", ValidationStatus.INVALID, "user must be a non-blank string"); - } - - if (consumerId == null || consumerId.trim().length() == 0) { - validationResult.setResult("consumerId", ValidationStatus.INVALID, "consumerId must be a non-blank string"); - } - - if (consumerGroup == null || consumerGroup.trim().length() == 0) { - validationResult.setResult("consumerGroup", ValidationStatus.INVALID, - "consumerGroup must be a non-blank string"); - } - - if (keystorePath == null || keystorePath.trim().length() == 0) { - validationResult.setResult("keystorePath", ValidationStatus.INVALID, - "keystorePath must be a non-blank string"); - } - - if (keystorePassword == null || keystorePassword.trim().length() == 0) { - validationResult.setResult("keystorePassword", ValidationStatus.INVALID, - "keystorePassword must be a non-blank string"); - } - - if (messageBusAddress == null) { - validationResult.setResult("messageBusAddress", ValidationStatus.INVALID, - "messageBusAddress must be a list of non-blank string"); - } else { - for (final String temp : messageBusAddress) { - if (temp.trim().length() == 0) { - validationResult.setResult("messageBusAddress", ValidationStatus.INVALID, - "the string of messageBusAddress must be a non-blank string"); - } - } - } - - if (artifactTypes == null) { - validationResult.setResult("artifactTypes", ValidationStatus.INVALID, - "artifactTypes must be a list of non-blank string"); - } else { - for (final String temp : artifactTypes) { - if (temp.trim().length() == 0) { - validationResult.setResult("artifactTypes", ValidationStatus.INVALID, - "the string of artifactTypes must be a non-blank string"); - } - } - } - - if (pollingInterval <= 0) { - validationResult.setResult("pollingInterval", ValidationStatus.INVALID, - "pollingInterval must be a positive integer"); - } - - if (pollingTimeout <= 0) { - validationResult.setResult("pollingTimeout", ValidationStatus.INVALID, - "pollingTimeout must be a positive integer"); - } - - return validationResult; - } - -} - diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/ArtifactInstallerException.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/ArtifactInstallerException.java new file mode 100644 index 00000000..043b0a41 --- /dev/null +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/ArtifactInstallerException.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Intel. 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.reception.handling.sdc.exceptions; + + +/** + * Exception during artifact installation. + */ +public class ArtifactInstallerException extends Exception { + + /** + * serialization id. + */ + private static final long serialVersionUID = -8507246953751956974L; + + /** + * Constructor for creating ArtifactInstallerException using message. + * + * @param message The message to dump + */ + public ArtifactInstallerException (final String message) { + super (message); + + } + + /** + * Constructor for creating ArtifactInstallerException using message and exception. + * + * @param message The message to dump + * @param e the exception that caused this exception to be thrown + */ + public ArtifactInstallerException (final String message, final Exception e) { + super (message, e); + + } +} diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PSSDControllerException.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PSSDControllerException.java new file mode 100644 index 00000000..ff9acfd0 --- /dev/null +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PSSDControllerException.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Intel. 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.reception.handling.sdc.exceptions; + + +/** + * Exception of the PSSD controller. + */ +public class PSSDControllerException extends Exception { + + /** + * serialization id. + */ + private static final long serialVersionUID = -8507246953751956974L; + + /** + * Constructor for creating PSSDControllerException using message. + * + * @param message The message to dump + */ + public PSSDControllerException (final String message) { + super (message); + + } + + /** + * Constructor for creating PSSDControllerException using message and exception. + * + * @param message The message to dump + * @param e the exception that caused this exception to be thrown + */ + public PSSDControllerException (final String message, final Exception e) { + super (message, e); + + } +} diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PSSDDownloadException.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PSSDDownloadException.java new file mode 100644 index 00000000..f95179c1 --- /dev/null +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PSSDDownloadException.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Intel. 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.reception.handling.sdc.exceptions; + + +/** + * Exception during download from PSSD. + */ +public class PSSDDownloadException extends Exception { + + /** + * serialization id. + */ + private static final long serialVersionUID = -8507246953751956974L; + + /** + * Constructor for creating PSSDDownloadException using message. + * + * @param message The message to dump + */ + public PSSDDownloadException (final String message) { + super (message); + + } + + /** + * Constructor for creating PSSDDownloadException using message and exception. + * + * @param message The message to dump + * @param e the exception that caused this exception to be thrown + */ + public PSSDDownloadException (final String message, final Exception e) { + super (message, e); + + } +} diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PSSDParametersException.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PSSDParametersException.java new file mode 100644 index 00000000..91922d7d --- /dev/null +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PSSDParametersException.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Intel. 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.reception.handling.sdc.exceptions; + + +/** + * Exception of the PSSD controller. + */ +public class PSSDParametersException extends Exception { + + /** + * serialization id. + */ + private static final long serialVersionUID = -8507246953751956974L; + + /** + * Constructor for creating PSSDParametersException using message. + * + * @param message The message to dump + */ + public PSSDParametersException (final String message) { + super (message); + + } + + /** + * Constructor for creating PSSDParametersException using message and exception. + * + * @param message The message to dump + * @param e the exception that caused this exception to be thrown + */ + public PSSDParametersException (final String message, final Exception e) { + super (message, e); + + } +} |