aboutsummaryrefslogtreecommitdiffstats
path: root/appc-adapters/appc-ansible-adapter
diff options
context:
space:
mode:
authorSkip Wonnell <skip@att.com>2018-01-13 12:11:11 -0600
committerPatrick Brady <pb071s@att.com>2018-01-15 22:57:09 +0000
commit2249d3681c16761c55f0e2de7de79c3bd6207d5e (patch)
tree4147292e688ba980a53f58e19bc35a81bdfb8121 /appc-adapters/appc-ansible-adapter
parentd3a76ab8023dc8b448f88fed07a5a9032a313c0a (diff)
Code hardening for Ansible Bundle
Fix all Sonar issues in AnsibleActivator.java and AnsibleAdapter.java Format code to ONAP style Issue-ID: APPC-401 Change-Id: Ic628684711e0265f599b9409023a98625fcddc81 Signed-off-by: Skip Wonnell <skip@att.com>
Diffstat (limited to 'appc-adapters/appc-ansible-adapter')
-rw-r--r--appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/AnsibleActivator.java41
-rw-r--r--appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/AnsibleAdapter.java24
2 files changed, 27 insertions, 38 deletions
diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/AnsibleActivator.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/AnsibleActivator.java
index d76cd50f1..5f9d1d05e 100644
--- a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/AnsibleActivator.java
+++ b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/AnsibleActivator.java
@@ -9,30 +9,29 @@
* 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.
- *
+ *
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
* ============LICENSE_END=========================================================
*/
package org.onap.appc.adapter.ansible;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-
import org.onap.appc.Constants;
import org.onap.appc.adapter.ansible.impl.AnsibleAdapterImpl;
import org.onap.appc.configuration.Configuration;
import org.onap.appc.configuration.ConfigurationFactory;
import org.onap.appc.i18n.Msg;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
@@ -41,6 +40,8 @@ import com.att.eelf.configuration.EELFManager;
*/
public class AnsibleActivator implements BundleActivator {
+ private static final String ANSIBLE_ADAPTER = "Ansible Adapter";
+ private static final String BUNDLE_NAME = "APPC Ansible Adapter";
/**
* The bundle registration
*/
@@ -70,25 +71,25 @@ public class AnsibleActivator implements BundleActivator {
*
* @param context The execution context of the bundle being started.
* @throws java.lang.Exception If this method throws an exception, this bundle is marked as stopped and the
- * Framework will remove this bundle's listeners, unregister all services registered
- * by this bundle, and release all services used by this bundle.
+ * Framework will remove this bundle's listeners, unregister all services registered
+ * by this bundle, and release all services used by this bundle.
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
@Override
public void start(BundleContext context) throws Exception {
- logger.info("Starting bundle " + getName());
+ logger.info("Starting bundle " + BUNDLE_NAME);
String appName = "APPC: ";
- logger.info(Msg.COMPONENT_INITIALIZING, appName, "Ansible Adapter");
+ logger.info(Msg.COMPONENT_INITIALIZING, appName, ANSIBLE_ADAPTER);
adapter = new AnsibleAdapterImpl();
if (registration == null) {
logger.info(Msg.REGISTERING_SERVICE, appName, adapter.getAdapterName(),
- AnsibleAdapter.class.getSimpleName());
+ AnsibleAdapter.class.getSimpleName());
registration = context.registerService(AnsibleAdapter.class, adapter, null);
}
- logger.info(Msg.COMPONENT_INITIALIZED, appName, "Ansible adapter");
+ logger.info(Msg.COMPONENT_INITIALIZED, appName, ANSIBLE_ADAPTER);
}
/**
@@ -102,25 +103,21 @@ public class AnsibleActivator implements BundleActivator {
*
* @param context The execution context of the bundle being stopped.
* @throws java.lang.Exception If this method throws an exception, the bundle is still marked as stopped, and the
- * Framework will remove the bundle's listeners, unregister all services registered
- * by the bundle, and release all services used by the bundle.
+ * Framework will remove the bundle's listeners, unregister all services registered
+ * by the bundle, and release all services used by the bundle.
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
@Override
public void stop(BundleContext context) throws Exception {
- logger.info("Stopping bundle " + getName());
+ logger.info("Stopping bundle " + BUNDLE_NAME);
if (registration != null) {
String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
- logger.info(Msg.COMPONENT_TERMINATING, appName, "Ansible adapter");
+ logger.info(Msg.COMPONENT_TERMINATING, appName, ANSIBLE_ADAPTER);
logger.info(Msg.UNREGISTERING_SERVICE, appName, adapter.getAdapterName());
registration.unregister();
registration = null;
- logger.info(Msg.COMPONENT_TERMINATED, appName, "Ansible adapter");
+ logger.info(Msg.COMPONENT_TERMINATED, appName, ANSIBLE_ADAPTER);
}
}
-
- public String getName() {
- return "APPC Ansible Adapter";
- }
}
diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/AnsibleAdapter.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/AnsibleAdapter.java
index 7bff184bc..93e1c4d3b 100644
--- a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/AnsibleAdapter.java
+++ b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/AnsibleAdapter.java
@@ -9,15 +9,15 @@
* 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.
- *
+ *
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
* ============LICENSE_END=========================================================
*/
@@ -25,36 +25,28 @@
package org.onap.appc.adapter.ansible;
import java.util.Map;
-
-import org.onap.appc.exceptions.APPCException;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
/**
- * This interface defines the operations that the Ansible adapter exposes.
- *
+ * This interface defines the operations that the Ansible adapter exposes.
+ *
*/
public interface AnsibleAdapter extends SvcLogicJavaPlugin {
-
-
/**
* Returns the symbolic name of the adapter
- *
+ *
* @return The adapter name
*/
String getAdapterName();
-
/* Method to post request for execution of Playbook */
void reqExec(Map<String, String> params, SvcLogicContext ctx) throws SvcLogicException;
/* Method to get result of a playbook execution request */
void reqExecResult(Map<String, String> params, SvcLogicContext ctx) throws SvcLogicException;
-
- /* Method to get log of a playbook execution request */
+ /* Method to get log of a playbook execution request */
void reqExecLog(Map<String, String> params, SvcLogicContext ctx) throws SvcLogicException;
-
-
}