Removed checkstyle warnings
[policy/engine.git] / BRMSGateway / src / main / java / org / onap / policy / brms / api / BrmsPush.java
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.brmsInterface;
+package org.onap.policy.brms.api;
+
+import com.att.nsa.cambria.client.CambriaBatchingPublisher;
+import com.att.nsa.cambria.client.CambriaClientBuilders;
+import com.att.nsa.cambria.client.CambriaClientBuilders.PublisherBuilder;
+import com.fasterxml.jackson.core.JsonProcessingException;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -71,9 +76,9 @@ import org.codehaus.plexus.util.WriterFactory;
 import org.eclipse.persistence.config.PersistenceUnitProperties;
 import org.onap.policy.api.PEDependency;
 import org.onap.policy.api.PolicyException;
-import org.onap.policy.brmsInterface.jpa.BRMSGroupInfo;
-import org.onap.policy.brmsInterface.jpa.BRMSPolicyInfo;
-import org.onap.policy.brmsInterface.jpa.DependencyInfo;
+import org.onap.policy.brms.entity.BrmsGroupInfo;
+import org.onap.policy.brms.entity.BrmsPolicyInfo;
+import org.onap.policy.brms.entity.DependencyInfo;
 import org.onap.policy.common.im.IntegrityMonitor;
 import org.onap.policy.common.logging.eelf.MessageCodes;
 import org.onap.policy.common.logging.eelf.PolicyLogger;
@@ -90,32 +95,29 @@ import org.sonatype.nexus.client.NexusConnectionException;
 import org.sonatype.nexus.client.rest.NexusRestClient;
 import org.sonatype.nexus.rest.model.NexusArtifact;
 
-import com.att.nsa.cambria.client.CambriaBatchingPublisher;
-import com.att.nsa.cambria.client.CambriaClientBuilders;
-import com.att.nsa.cambria.client.CambriaClientBuilders.PublisherBuilder;
-import com.fasterxml.jackson.core.JsonProcessingException;
-
 /**
- * BRMSPush: Application responsible to push policies to the BRMS PDP Policy Repository (PR). Mavenize and push policy
- * to PR
+ * BRMSPush: Application responsible to push policies to the BRMS PDP Policy Repository (PR).
+ * Mavenize and push policy to PR
  * 
  * @version 1.0
  */
 
 @SuppressWarnings("deprecation")
-public class BRMSPush {
+public class BrmsPush {
     private static final String GROUP_NAMES = "groupNames";
-       private static final String DROOLS_APPS_TEMPLATE_GROUP = "org.onap.policy.drools-applications.controlloop.templates";
-       private static final String DROOLS_APPS_MODEL_GROUP    = "org.onap.policy.drools-applications.controlloop.common.model-impl";
-       private static final String META_INF = "META-INF";
-       private static final String KMODULE_XML_FILE = "kmodule.xml";
-       private static final String POM_XML_FILE = "pom.xml";
-       private static final String VERSION_0_1_0 = "0.1.0";
-       private static final String RULES = "rules";
-       private static final String RESOURCES = "resources";
-       private static final Logger LOGGER = FlexLogger.getLogger(BRMSPush.class.getName());
+    private static final String DROOLS_APPS_TEMPLATE_GROUP =
+            "org.onap.policy.drools-applications.controlloop.templates";
+    private static final String DROOLS_APPS_MODEL_GROUP =
+            "org.onap.policy.drools-applications.controlloop.common.model-impl";
+    private static final String META_INF = "META-INF";
+    private static final String KMODULE_XML_FILE = "kmodule.xml";
+    private static final String POM_XML_FILE = "pom.xml";
+    private static final String VERSION_0_1_0 = "0.1.0";
+    private static final String RULES = "rules";
+    private static final String RESOURCES = "resources";
+    private static final Logger LOGGER = FlexLogger.getLogger(BrmsPush.class.getName());
     private static final String PROJECTSLOCATION = "RuleProjects";
-    private static final String[] GOALS = { "clean", "deploy" };
+    private static final String[] GOALS = {"clean", "deploy"};
     private static final String DEFAULT_VERSION = "1.2.0-SNAPSHOT";
     private static final String DEPENDENCY_FILE = "dependency.json";
     private static final String BRMSPERSISTENCE = "brmsEclipselink.persistencexml";
@@ -124,12 +126,12 @@ public class BRMSPush {
     private static IntegrityMonitor im;
     private static BackUpMonitor bm;
     private String defaultName = null;
-    private String repID = null;
+    private String repId = null;
     private String repName = null;
-    private ArrayList<String> repURLs = null;
+    private List<String> repUrlList = null;
     private String repUserName = null;
     private String repPassword = null;
-    private String policyKeyID = null;
+    private String policyKeyId = null;
     private boolean createFlag = false;
     private String uebList = null;
     private List<String> dmaapList = null;
@@ -139,19 +141,26 @@ public class BRMSPush {
     private Long uebDelay = Long.parseLong("20");
     private Long dmaapDelay = Long.parseLong("5000");
     private String notificationType = null;
-    private ArrayList<ControllerPOJO> controllers;
-    private HashMap<String, ArrayList<Object>> groupMap = new HashMap<>();
-    private Map<String, String> policyMap = new HashMap<>();
+    private List<ControllerPojo> controllers;
+    private Map<String, ArrayList<Object>> groupMap = new HashMap<>();
+    private final Map<String, String> policyMap = new HashMap<>();
     private String brmsdependencyversion;
     private EntityManager em;
     private boolean syncFlag = false;
 
-    public BRMSPush(String propertiesFile, BackUpHandler handler) throws PolicyException {
-        if(propertiesFile==null || handler==null){
+    /**
+     * Responsible to push policies to the BRMS PDP Policy Repository (PR).
+     * 
+     * @param propertiesFile the properties file
+     * @param handler the {@link BackUpHandler}
+     * @throws PolicyException PolicyException related to the operation
+     */
+    public BrmsPush(final String propertiesFile, final BackUpHandler handler) throws PolicyException {
+        if (propertiesFile == null || handler == null) {
             throw new PolicyException("Error no propertiesFile or handler");
         }
-        Properties config = new Properties();
-        Path file = Paths.get(propertiesFile);
+        final Properties config = new Properties();
+        final Path file = Paths.get(propertiesFile);
         if (Files.notExists(file)) {
             LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Config File doesn't Exist in the specified Path "
                     + file.toString());
@@ -165,12 +174,13 @@ public class BRMSPush {
         }
     }
 
-    private void setProperty(Path file, Properties config, BackUpHandler handler) throws PolicyException {
+    private void setProperty(final Path file, final Properties config, final BackUpHandler handler)
+            throws PolicyException {
         InputStream in;
         try {
             in = new FileInputStream(file.toFile());
             config.load(in);
-        } catch (IOException e) {
+        } catch (final IOException e) {
             LOGGER.error(
                     XACMLErrorConstants.ERROR_DATA_ISSUE + "Data/File Read Error while reading from the property file.",
                     e);
@@ -188,22 +198,23 @@ public class BRMSPush {
             }
             resourceName = resourceName.trim();
             setIntegrityMonitor(IntegrityMonitor.getInstance(resourceName, config));
-        } catch (Exception e) {
+        } catch (final Exception e) {
             LOGGER.error("Error starting Integerity Monitor: " + e);
         }
         LOGGER.info("Trying to set up BackUpMonitor");
         try {
             setBackupMonitor(BackUpMonitor.getInstance(BackUpMonitor.ResourceNode.BRMS.toString(), resourceName, config,
                     handler));
-        } catch (Exception e) {
+        } catch (final Exception e) {
             LOGGER.error("Error starting BackUpMonitor: " + e);
         }
-        if(!config.containsKey(BRMSPERSISTENCE)){
+        if (!config.containsKey(BRMSPERSISTENCE)) {
             config.setProperty(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML, "META-INF/persistenceBRMS.xml");
         } else {
-            config.setProperty(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML, config.getProperty(BRMSPERSISTENCE,"META-INF/persistenceBRMS.xml"));
+            config.setProperty(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML,
+                    config.getProperty(BRMSPERSISTENCE, "META-INF/persistenceBRMS.xml"));
         }
-        EntityManagerFactory emf = Persistence.createEntityManagerFactory("BRMSGW", config);
+        final EntityManagerFactory emf = Persistence.createEntityManagerFactory("BRMSGW", config);
         em = emf.createEntityManager();
         defaultName = config.getProperty("defaultName");
         if (defaultName == null) {
@@ -213,14 +224,14 @@ public class BRMSPush {
                     XACMLErrorConstants.ERROR_DATA_ISSUE + "defaultName property is missing from the property file");
         }
         defaultName = defaultName.trim();
-        repID = config.getProperty("repositoryID");
-        if (repID == null) {
+        repId = config.getProperty("repositoryID");
+        if (repId == null) {
             LOGGER.error(
                     XACMLErrorConstants.ERROR_DATA_ISSUE + "repositoryID property is missing from the property file ");
             throw new PolicyException(
                     XACMLErrorConstants.ERROR_DATA_ISSUE + "repositoryID property is missing from the property file ");
         }
-        repID = repID.trim();
+        repId = repId.trim();
         repName = config.getProperty("repositoryName");
         if (repName == null) {
             LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE
@@ -229,18 +240,18 @@ public class BRMSPush {
                     + "repositoryName property is missing from the property file ");
         }
         repName = repName.trim();
-        String repURL = config.getProperty("repositoryURL");
-        if (repURL == null) {
+        final String repUrl = config.getProperty("repositoryURL");
+        if (repUrl == null) {
             LOGGER.error(
                     XACMLErrorConstants.ERROR_DATA_ISSUE + "repositoryURL property is missing from the property file ");
             throw new PolicyException(
                     XACMLErrorConstants.ERROR_DATA_ISSUE + "repositoryURL property is missing from the property file ");
         }
-        if (repURL.contains(",")) {
-            repURLs = new ArrayList<>(Arrays.asList(repURL.trim().split(",")));
+        if (repUrl.contains(",")) {
+            repUrlList = new ArrayList<>(Arrays.asList(repUrl.trim().split(",")));
         } else {
-            repURLs = new ArrayList<>();
-            repURLs.add(repURL);
+            repUrlList = new ArrayList<>();
+            repUrlList.add(repUrl);
         }
         repUserName = config.getProperty("repositoryUsername");
         repPassword = config.getProperty("repositoryPassword");
@@ -252,15 +263,15 @@ public class BRMSPush {
         }
         repUserName = repUserName.trim();
         repPassword = repPassword.trim();
-        policyKeyID = config.getProperty("policyKeyID");
-        if (policyKeyID == null) {
+        policyKeyId = config.getProperty("policyKeyID");
+        if (policyKeyId == null) {
             LOGGER.error(
                     XACMLErrorConstants.ERROR_DATA_ISSUE + "policyKeyID property is missing from the property file ");
             throw new PolicyException(
                     XACMLErrorConstants.ERROR_DATA_ISSUE + "policyKeyID property is missing from the property file ");
         }
-        policyKeyID = policyKeyID.trim();
-        String syncF = config.getProperty("sync", "false").trim();
+        policyKeyId = policyKeyId.trim();
+        final String syncF = config.getProperty("sync", "false").trim();
         syncFlag = Boolean.parseBoolean(syncF);
         if (syncFlag) {
             PolicyLogger.info("SYNC Flag is turned ON. DB will be given Priority.");
@@ -282,8 +293,8 @@ public class BRMSPush {
             // Setting up the Publisher for DMaaP MR
             String dmaapServers = config.getProperty("NOTIFICATION_SERVERS");
             pubTopic = config.getProperty("NOTIFICATION_TOPIC");
-            String aafLogin = config.getProperty("CLIENT_ID").trim();
-            String aafPassword = config.getProperty("CLIENT_KEY").trim();
+            final String aafLogin = config.getProperty("CLIENT_ID").trim();
+            final String aafPassword = config.getProperty("CLIENT_KEY").trim();
 
             if (dmaapServers == null || pubTopic == null) {
                 LOGGER.error(
@@ -302,15 +313,15 @@ public class BRMSPush {
                 dmaapList.add(dmaapServers);
             }
 
-            this.publisher = new BusPublisher.DmaapPublisherWrapper(this.dmaapList, this.pubTopic, aafLogin,
-                    aafPassword);
+            this.publisher =
+                    new BusPublisher.DmaapPublisherWrapper(this.dmaapList, this.pubTopic, aafLogin, aafPassword);
 
-            String dDelay = config.getProperty("NOTIFICATION_DELAY");
-            if (dDelay != null && !dDelay.isEmpty()) {
-                dDelay = dDelay.trim();
+            String notificationDelay = config.getProperty("NOTIFICATION_DELAY");
+            if (notificationDelay != null && !notificationDelay.isEmpty()) {
+                notificationDelay = notificationDelay.trim();
                 try {
-                    dmaapDelay = Long.parseLong(dDelay);
-                } catch (NumberFormatException e) {
+                    dmaapDelay = Long.parseLong(notificationDelay);
+                } catch (final NumberFormatException e) {
                     LOGGER.error("DMAAP_DELAY not a long format number" + e);
                 }
             }
@@ -321,8 +332,6 @@ public class BRMSPush {
             // Setting up the Publisher for UEB
             uebList = config.getProperty("NOTIFICATION_SERVERS");
             pubTopic = config.getProperty("NOTIFICATION_TOPIC");
-            String apiKey = config.getProperty("UEB_API_KEY");
-            String apiSecret = config.getProperty("UEB_API_SECRET");
             if (uebList == null || pubTopic == null) {
                 LOGGER.error(
                         XACMLErrorConstants.ERROR_DATA_ISSUE + "UEB properties are missing from the property file ");
@@ -333,17 +342,19 @@ public class BRMSPush {
             pubTopic = pubTopic.trim();
             pubBuilder = new CambriaClientBuilders.PublisherBuilder();
             pubBuilder.usingHosts(uebList).onTopic(pubTopic);
+            String apiKey = config.getProperty("UEB_API_KEY");
+            String apiSecret = config.getProperty("UEB_API_SECRET");
             if (apiKey != null && !apiKey.isEmpty() && apiSecret != null && !apiSecret.isEmpty()) {
                 apiKey = apiKey.trim();
                 apiSecret = apiSecret.trim();
                 pubBuilder.authenticatedBy(apiKey, apiSecret);
             }
-            String uDelay = config.getProperty("NOTIFICATION_DELAY");
-            if (uDelay != null && !uDelay.isEmpty()) {
-                uDelay = uDelay.trim();
+            String notificationDelay = config.getProperty("NOTIFICATION_DELAY");
+            if (notificationDelay != null && !notificationDelay.isEmpty()) {
+                notificationDelay = notificationDelay.trim();
                 try {
-                    uebDelay = Long.parseLong(uDelay);
-                } catch (NumberFormatException e) {
+                    uebDelay = Long.parseLong(notificationDelay);
+                } catch (final NumberFormatException e) {
                     LOGGER.error("UEB_DELAY not a long format number" + e);
                 }
             }
@@ -353,31 +364,32 @@ public class BRMSPush {
 
     }
 
-    private static void setBackupMonitor(BackUpMonitor instance) {
+    private static void setBackupMonitor(final BackUpMonitor instance) {
         bm = instance;
     }
 
-    private static void setIntegrityMonitor(IntegrityMonitor instance) {
+    private static void setIntegrityMonitor(final IntegrityMonitor instance) {
         im = instance;
     }
 
     /**
      * Will Initialize the variables required for BRMSPush.
      */
-    public void initiate(boolean flag) {
+    public void initiate(final boolean flag) {
         resetModifiedGroups();
         controllers = new ArrayList<>();
         try {
             bm.updateNotification();
-        } catch (Exception e) {
+        } catch (final Exception e) {
             LOGGER.error("Error while updating Notification: " + e.getMessage(), e);
         }
-        if (flag)
+        if (flag) {
             syncGroupInfo();
+        }
     }
-    
-    public void resetDS(){
-       resetModifiedGroups();
+
+    public void resetDs() {
+        resetModifiedGroups();
         controllers = new ArrayList<>();
     }
 
@@ -388,57 +400,56 @@ public class BRMSPush {
     /**
      * Will Add rules to projects. Creates necessary folders if required.
      */
-    public void addRule(String name, String rule, Map<String, String> responseAttributes) {
+    public void addRule(final String name, final String rule, final Map<String, String> responseAttributes) {
         // 1 check the response Attributes and determine if this belongs to any projects.
         // 2 if not create folder
         // 3 create pom.
         // 4 copy the rule.
         // 5 store the groups that have been updated.
-        String kSessionName = null;
+        String ksessionName = null;
         String selectedName = null;
         if (!responseAttributes.isEmpty()) {
             // Pick selected Value
             String userControllerName = null;
-            ArrayList<PEDependency> userDependencies = new ArrayList<>();
-            for (Map.Entry<String, String> entry: responseAttributes.entrySet()) {
-               String key = entry.getKey();
-               String value = entry.getValue();
-                if (key.equals(policyKeyID)) {
+            final ArrayList<PEDependency> userDependencies = new ArrayList<>();
+            for (final Map.Entry<String, String> entry : responseAttributes.entrySet()) {
+                final String key = entry.getKey();
+                String value = entry.getValue();
+                if (key.equals(policyKeyId)) {
                     selectedName = value;
                 }
                 // kmodule configurations
                 else if ("kSessionName".equals(key)) {
-                    kSessionName = value;
+                    ksessionName = value;
                 }
                 // Check User Specific values.
                 if ("$controller:".equals(key)) {
                     try {
-                        PEDependency dependency = PolicyUtils.jsonStringToObject(value,
-                                PEDependency.class);
+                        final PEDependency dependency = PolicyUtils.jsonStringToObject(value, PEDependency.class);
                         userControllerName = key.replaceFirst("$controller:", "");
-                        LOGGER.info("addRule: userControllerName - " + userControllerName + ", dependency: - " + dependency);
+                        LOGGER.info("addRule: userControllerName - " + userControllerName + ", dependency: - "
+                                + dependency);
                         addToGroup(userControllerName, dependency);
-                    } catch (Exception e) {
+                    } catch (final Exception e) {
                         LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while resolving Controller: " + e);
                     }
 
                 } else if ("$dependency$".equals(key) && value.startsWith("[") && value.endsWith("]")) {
                     value = value.substring(1, value.length() - 1).trim();
-                    List<String> dependencyStrings = Arrays.asList(value.split(Pattern.quote("},{")));
-                    for (String dependencyString : dependencyStrings) {
+                    final List<String> dependencyStrings = Arrays.asList(value.split(Pattern.quote("},{")));
+                    for (final String dependencyString : dependencyStrings) {
                         try {
-                            userDependencies
-                                    .add(PolicyUtils.jsonStringToObject(dependencyString, PEDependency.class));
-                        } catch (Exception e) {
-                            LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW
-                                    + "Error while resolving Dependencies: " + e);
+                            userDependencies.add(PolicyUtils.jsonStringToObject(dependencyString, PEDependency.class));
+                        } catch (final Exception e) {
+                            LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while resolving Dependencies: "
+                                    + e);
                         }
                     }
                 }
             }
             if (userControllerName != null) {
                 // Adding custom dependencies here.
-                ArrayList<Object> values = groupMap.get(userControllerName);
+                final ArrayList<Object> values = groupMap.get(userControllerName);
                 values.add(userDependencies);
                 groupMap.put(userControllerName, values);
                 selectedName = userControllerName;
@@ -449,45 +460,48 @@ public class BRMSPush {
             selectedName = defaultName;
         }
         if (groupMap.containsKey(selectedName)) {
-            // If the key is not got as parameters set by the user, setting the default value for kSessionName as
+            // If the key is not got as parameters set by the user, setting the default value for
+            // kSessionName as
             // closedLoop
-            if (kSessionName == null) {
-               LOGGER.info("kSessionName is null, selectedName is  : " + selectedName );
+            if (ksessionName == null) {
+                LOGGER.info("kSessionName is null, selectedName is  : " + selectedName);
                 if (selectedName.equalsIgnoreCase(defaultName)) {
-                    kSessionName = "closedloop";
+                    ksessionName = "closedloop";
                 } else {
-                    kSessionName = "closedloop-" + selectedName;
+                    ksessionName = "closedloop-" + selectedName;
                 }
             }
             // create directories if missing.
-            manageProject(selectedName, kSessionName, name, rule);
-            addModifiedGroup(selectedName, "update"); // Will check for Create Later after generating the Pom.
+            manageProject(selectedName, ksessionName, name, rule);
+
+            // Will check for Create Later after generating the Pom.
+            addModifiedGroup(selectedName, "update");
         }
     }
 
     private void syncGroupInfo() {
         // Sync DB to JMemory.
-        EntityTransaction et = em.getTransaction();
+        final EntityTransaction et = em.getTransaction();
         et.begin();
-        Query query = em.createQuery("select b from BRMSGroupInfo AS b");
-        List<?> bList = query.getResultList();
-        if (bList.size() != groupMap.size()) {
-            for (Object value : bList) {
-                BRMSGroupInfo brmsGroupInfo = (BRMSGroupInfo) value;
-                PEDependency dependency = new PEDependency();
+        Query query = em.createQuery("select b from BrmsGroupInfo AS b");
+        List<?> result = query.getResultList();
+        if (result.size() != groupMap.size()) {
+            for (final Object value : result) {
+                final BrmsGroupInfo brmsGroupInfo = (BrmsGroupInfo) value;
+                final PEDependency dependency = new PEDependency();
                 dependency.setArtifactId(brmsGroupInfo.getArtifactId());
                 dependency.setGroupId(brmsGroupInfo.getGroupId());
                 dependency.setVersion(brmsGroupInfo.getVersion());
-                ArrayList<Object> values = new ArrayList<>();
+                final ArrayList<Object> values = new ArrayList<>();
                 values.add(dependency);
                 groupMap.put(brmsGroupInfo.getControllerName(), values);
             }
         }
-        query = em.createQuery("select g from BRMSPolicyInfo AS g");
-        bList = query.getResultList();
-        if (bList.size() != policyMap.size()) {
-            for (Object value : bList) {
-                BRMSPolicyInfo brmsPolicyInfo = (BRMSPolicyInfo) value;
+        query = em.createQuery("select g from BrmsPolicyInfo AS g");
+        result = query.getResultList();
+        if (result.size() != policyMap.size()) {
+            for (final Object value : result) {
+                final BrmsPolicyInfo brmsPolicyInfo = (BrmsPolicyInfo) value;
                 policyMap.put(brmsPolicyInfo.getPolicyName(), brmsPolicyInfo.getControllerName().getControllerName());
             }
         }
@@ -495,32 +509,33 @@ public class BRMSPush {
         LOGGER.info("Updated Local Memory values with values from database.");
     }
 
-    private void manageProject(String selectedName, String kSessionName, String name, String rule) {
+    private void manageProject(final String selectedName, final String ksessionName, final String name,
+            final String rule) {
         // Check if the Project is in Sync. If not get the latest Version.
         syncProject(selectedName);
-        createProject(PROJECTSLOCATION + File.separator + getArtifactID(selectedName) + File.separator + "src"
-                + File.separator + "main" + File.separator + RESOURCES, kSessionName);
-        copyDataToFile(PROJECTSLOCATION + File.separator + getArtifactID(selectedName) + File.separator + "src"
-                + File.separator + "main" + File.separator + RESOURCES + File.separator + RULES + File.separator
-                + name + ".drl", rule);
+        createProject(PROJECTSLOCATION + File.separator + getArtifactId(selectedName) + File.separator + "src"
+                + File.separator + "main" + File.separator + RESOURCES, ksessionName);
+        copyDataToFile(PROJECTSLOCATION + File.separator + getArtifactId(selectedName) + File.separator + "src"
+                + File.separator + "main" + File.separator + RESOURCES + File.separator + RULES + File.separator + name
+                + ".drl", rule);
         addToPolicy(name, selectedName);
     }
 
     /*
      * Add Policy to JMemory and DataBase.
      */
-    private void addToPolicy(String policyName, String controllerName) {
+    private void addToPolicy(final String policyName, final String controllerName) {
         policyMap.put(policyName, controllerName);
-        EntityTransaction et = em.getTransaction();
+        final EntityTransaction et = em.getTransaction();
         et.begin();
-        Query query = em.createQuery("select b from BRMSPolicyInfo as b where b.policyName = :pn");
+        Query query = em.createQuery("select b from BrmsPolicyInfo as b where b.policyName = :pn");
         query.setParameter("pn", policyName);
-        List<?> pList = query.getResultList();
+        final List<?> pList = query.getResultList();
         boolean create = false;
-        BRMSPolicyInfo brmsPolicyInfo = new BRMSPolicyInfo();
+        BrmsPolicyInfo brmsPolicyInfo = new BrmsPolicyInfo();
         if (!pList.isEmpty()) {
             // Already exists.
-            brmsPolicyInfo = (BRMSPolicyInfo) pList.get(0);
+            brmsPolicyInfo = (BrmsPolicyInfo) pList.get(0);
             if (!brmsPolicyInfo.getControllerName().getControllerName().equals(controllerName)) {
                 create = true;
             }
@@ -528,12 +543,12 @@ public class BRMSPush {
             create = true;
         }
         if (create) {
-            query = em.createQuery("select b from BRMSGroupInfo as b where b.controllerName = :cn");
+            query = em.createQuery("select b from BrmsGroupInfo as b where b.controllerName = :cn");
             query.setParameter("cn", controllerName);
-            List<?> bList = query.getResultList();
-            BRMSGroupInfo brmsGroupInfo = new BRMSGroupInfo();
+            final List<?> bList = query.getResultList();
+            BrmsGroupInfo brmsGroupInfo = new BrmsGroupInfo();
             if (!bList.isEmpty()) {
-                brmsGroupInfo = (BRMSGroupInfo) bList.get(0);
+                brmsGroupInfo = (BrmsGroupInfo) bList.get(0);
             }
             brmsPolicyInfo.setPolicyName(policyName);
             brmsPolicyInfo.setControllerName(brmsGroupInfo);
@@ -543,8 +558,8 @@ public class BRMSPush {
         et.commit();
     }
 
-    private void syncProject(String selectedName) {
-        boolean projectExists = checkProject(selectedName);
+    private void syncProject(final String selectedName) {
+        final boolean projectExists = checkProject(selectedName);
         if (projectExists) {
             String version;
             version = getVersion(selectedName);
@@ -553,8 +568,8 @@ public class BRMSPush {
                         + " going with Default value");
                 version = VERSION_0_1_0;
             }
-            String nextVersion = incrementVersion(version);
-            boolean outOfSync = checkRemoteSync(selectedName, nextVersion);
+            final String nextVersion = incrementVersion(version);
+            final boolean outOfSync = checkRemoteSync(selectedName, nextVersion);
             if (!outOfSync) {
                 return;
             }
@@ -563,80 +578,83 @@ public class BRMSPush {
         downloadProject(selectedName);
     }
 
-    private void downloadProject(String selectedName) {
-        NexusArtifact artifact = getLatestArtifactFromNexus(selectedName);
-        if (artifact == null)
+    private void downloadProject(final String selectedName) {
+        final NexusArtifact artifact = getLatestArtifactFromNexus(selectedName);
+        if (artifact == null) {
             return;
-        String dirName = getDirectoryName(selectedName);
+        }
+        final String dirName = getDirectoryName(selectedName);
         URL website;
-        String fileName = "rule.jar";
+        final String fileName = "rule.jar";
         try {
             website = new URL(artifact.getResourceURI());
-            tryReadableByteChannel rbc = Channels.newChannel(website.openStream());
-                       FileOutputStream fos = new FileOutputStream(fileName)){
-               fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
+            try (ReadableByteChannel rbc = Channels.newChannel(website.openStream());
+                    FileOutputStream fos = new FileOutputStream(fileName)) {
+                fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
                 extractJar(fileName, dirName);
                 new File(fileName).delete();
-            }catch (IOException e) {
-         LOGGER.error("Error while downloading the project to File System. " + e.getMessage(), e);
-                       }
-          
-        } catch (IOException e1) {
+            } catch (final IOException e) {
+                LOGGER.error("Error while downloading the project to File System. " + e.getMessage(), e);
+            }
+
+        } catch (final IOException e1) {
             LOGGER.error("Error while retrieve the artifact. " + e1.getMessage(), e1);
         }
     }
 
-private void extractJar(String jarFileName, String artifactId){
-               try (JarFile jar = new JarFile(jarFileName)) {  
-        Enumeration<?> enumEntries = jar.entries();
-        while (enumEntries.hasMoreElements()) {
-            JarEntry file = (JarEntry) enumEntries.nextElement();
-            File f = null;
-            String fileName = file.getName().substring(file.getName().lastIndexOf("/") + 1);
-            if (file.getName().endsWith(".drl")) {
-                String path = PROJECTSLOCATION + File.separator + artifactId + File.separator + "src" + File.separator
-                        + "main" + File.separator + RESOURCES + File.separator + RULES;
-                new File(path).mkdirs();
-                if (syncFlag && policyMap.containsKey(fileName.replace(".drl", ""))) {
-                    f = new File(path + File.separator + fileName);
-                } else {
-                    f = new File(path + File.separator + fileName);
+    private void extractJar(final String jarFileName, final String artifactId) {
+        try (JarFile jar = new JarFile(jarFileName)) {
+            final Enumeration<?> enumEntries = jar.entries();
+            while (enumEntries.hasMoreElements()) {
+                final JarEntry jarEntry = (JarEntry) enumEntries.nextElement();
+                File file = null;
+                final String fileName = jarEntry.getName().substring(jarEntry.getName().lastIndexOf("/") + 1);
+                if (jarEntry.getName().endsWith(".drl")) {
+                    final String path = PROJECTSLOCATION + File.separator + artifactId + File.separator + "src"
+                            + File.separator + "main" + File.separator + RESOURCES + File.separator + RULES;
+                    new File(path).mkdirs();
+                    if (syncFlag && policyMap.containsKey(fileName.replace(".drl", ""))) {
+                        file = new File(path + File.separator + fileName);
+                    } else {
+                        file = new File(path + File.separator + fileName);
+                    }
+                } else if (jarEntry.getName().endsWith(POM_XML_FILE)) {
+                    final String path = PROJECTSLOCATION + File.separator + artifactId;
+                    new File(path).mkdirs();
+                    file = new File(path + File.separator + fileName);
+                } else if (jarEntry.getName().endsWith(KMODULE_XML_FILE)) {
+                    final String path = PROJECTSLOCATION + File.separator + artifactId + File.separator + "src"
+                            + File.separator + "main" + File.separator + RESOURCES + File.separator + META_INF;
+                    new File(path).mkdirs();
+                    file = new File(path + File.separator + fileName);
                 }
-            } else if (file.getName().endsWith(POM_XML_FILE)) {
-                String path = PROJECTSLOCATION + File.separator + artifactId;
-                new File(path).mkdirs();
-                f = new File(path + File.separator + fileName);
-            } else if (file.getName().endsWith(KMODULE_XML_FILE)) {
-                String path = PROJECTSLOCATION + File.separator + artifactId + File.separator + "src" + File.separator
-                        + "main" + File.separator + RESOURCES + File.separator + META_INF;
-                new File(path).mkdirs();
-                f = new File(path + File.separator + fileName);
-            }
-            if (f != null) {
-                               try (InputStream is = jar.getInputStream(file); FileOutputStream fos = new FileOutputStream(f)) {
-                while (is.available() > 0) {
-                    fos.write(is.read());
+                if (file != null) {
+                    try (InputStream is = jar.getInputStream(jarEntry);
+                            FileOutputStream fos = new FileOutputStream(file)) {
+                        while (is.available() > 0) {
+                            fos.write(is.read());
+                        }
+                        LOGGER.info(fileName + " Created..");
+                    } catch (final IOException e) {
+                        LOGGER.info("exception Occured" + e);
+                    }
                 }
-                LOGGER.info(fileName + " Created..");
-                               } catch (IOException e) {
-                                               LOGGER.info("exception Occured" + e);
-                                       }
             }
-         }
-               } catch (IOException e) {
-                       LOGGER.info("exception Occured" + e);
-               }
-  }
-
-    private NexusArtifact getLatestArtifactFromNexus(String selectedName) {
-        List<NexusArtifact> artifacts = getArtifactFromNexus(selectedName, null);
+        } catch (final IOException e) {
+            LOGGER.info("exception Occured" + e);
+        }
+    }
+
+    private NexusArtifact getLatestArtifactFromNexus(final String selectedName) {
+        final List<NexusArtifact> artifacts = getArtifactFromNexus(selectedName, null);
         int bigNum = 0;
         int smallNum = 0;
         NexusArtifact result = null;
-        for (NexusArtifact artifact : artifacts) {
-            int majorVal = Integer.parseInt(artifact.getVersion().substring(0, artifact.getVersion().indexOf(".")));
-            int minorVal = Integer.parseInt(artifact.getVersion().substring(artifact.getVersion().indexOf(".") + 1,
-                    artifact.getVersion().lastIndexOf(".")));
+        for (final NexusArtifact artifact : artifacts) {
+            final int majorVal =
+                    Integer.parseInt(artifact.getVersion().substring(0, artifact.getVersion().indexOf(".")));
+            final int minorVal = Integer.parseInt(artifact.getVersion()
+                    .substring(artifact.getVersion().indexOf(".") + 1, artifact.getVersion().lastIndexOf(".")));
             if (majorVal > bigNum) {
                 bigNum = majorVal;
                 smallNum = minorVal;
@@ -652,36 +670,36 @@ private void extractJar(String jarFileName, String artifactId){
     }
 
     // Additional Check due to Limitations from Nexus API to check if the artifact is the latest.
-    private NexusArtifact additionalNexusLatestCheck(String selectedName, NexusArtifact result) {
-        if(result==null){
+    private NexusArtifact additionalNexusLatestCheck(final String selectedName, final NexusArtifact result) {
+        if (result == null) {
             return result;
         }
-        String nextVersion = incrementVersion(result.getVersion());
-        List<NexusArtifact> artifact = getArtifactFromNexus(selectedName, nextVersion);
+        final String nextVersion = incrementVersion(result.getVersion());
+        final List<NexusArtifact> artifact = getArtifactFromNexus(selectedName, nextVersion);
         return artifact.isEmpty() ? result : additionalNexusLatestCheck(selectedName, artifact.get(0));
     }
 
-    private boolean checkRemoteSync(String selectedName, String version) {
-        List<NexusArtifact> artifacts = getArtifactFromNexus(selectedName, version);
+    private boolean checkRemoteSync(final String selectedName, final String version) {
+        final List<NexusArtifact> artifacts = getArtifactFromNexus(selectedName, version);
         return artifacts.isEmpty() ? false : true;
     }
 
-    private List<NexusArtifact> getArtifactFromNexus(String selectedName, String version) {
+    private List<NexusArtifact> getArtifactFromNexus(final String selectedName, final String version) {
         final NexusClient client = new NexusRestClient();
-        int i = 0;
+        int index = 0;
         boolean flag = false;
-        while (i < repURLs.size()) {
+        while (index < repUrlList.size()) {
             try {
-                String repURL = repURLs.get(0);
-                client.connect(repURL.substring(0, repURL.indexOf(repURL.split(":[0-9]+\\/nexus")[1])), repUserName,
+                final String repUrl = repUrlList.get(0);
+                client.connect(repUrl.substring(0, repUrl.indexOf(repUrl.split(":[0-9]+\\/nexus")[1])), repUserName,
                         repPassword);
                 final NexusArtifact template = new NexusArtifact();
-                template.setGroupId(getGroupID(selectedName));
-                template.setArtifactId(getArtifactID(selectedName));
+                template.setGroupId(getGroupId(selectedName));
+                template.setArtifactId(getArtifactId(selectedName));
                 if (version != null) {
                     template.setVersion(version);
                 }
-                List<NexusArtifact> resultList = client.searchByGAV(template);
+                final List<NexusArtifact> resultList = client.searchByGAV(template);
                 if (resultList != null) {
                     flag = true;
                     return resultList;
@@ -697,29 +715,15 @@ private void extractJar(String jarFileName, String artifactId){
                             + e.getMessage(), e);
                 }
                 if (!flag) {
-                    Collections.rotate(repURLs, -1);
-                    i++;
+                    Collections.rotate(repUrlList, -1);
+                    index++;
                 }
             }
         }
         return new ArrayList<>();
     }
 
-    private void setVersion(String selectedName) {
-        String newVersion = VERSION_0_1_0;
-        createFlag = false;
-        NexusArtifact artifact = getLatestArtifactFromNexus(selectedName);
-        if (artifact != null) {
-            newVersion = incrementVersion(artifact.getVersion());
-        }
-        if (VERSION_0_1_0.equals(newVersion)) {
-            createFlag = true;
-        }
-        setVersion(newVersion, selectedName);
-        LOGGER.info("Controller: " + selectedName + "is on version: " + newVersion);
-    }
-
-    private String incrementVersion(String version) {
+    private String incrementVersion(final String version) {
         int majorVal = Integer.parseInt(version.substring(0, version.indexOf(".")));
         int minorVal = Integer.parseInt(version.substring(version.indexOf(".") + 1, version.lastIndexOf(".")));
         if (minorVal >= 9) {
@@ -731,52 +735,50 @@ private void extractJar(String jarFileName, String artifactId){
         return majorVal + "." + minorVal + version.substring(version.lastIndexOf("."));
     }
 
-    private boolean checkProject(String selectedName) {
+    private boolean checkProject(final String selectedName) {
         return new File(PROJECTSLOCATION + File.separator + getDirectoryName(selectedName)).exists();
     }
 
-    private String getDirectoryName(String selectedName) {
-        return getArtifactID(selectedName);
+    private String getDirectoryName(final String selectedName) {
+        return getArtifactId(selectedName);
     }
 
     /**
      * Will Push policies to the PolicyRepo.
      * 
-     * @param notificationType
-     *            <String> type of notification Type.
-     * @throws PolicyException
+     * @throws PolicyException PolicyException related to the operation
      */
     public void pushRules() throws PolicyException {
         // Check how many groups have been updated.
         // Invoke their Maven process.
         try {
             im.startTransaction();
-        } catch (Exception e) {
+        } catch (final Exception e) {
             LOGGER.error("Error while starting Transaction " + e);
         }
         if (!modifiedGroups.isEmpty()) {
             Boolean flag = false;
-            for (Map.Entry<String, String> entry : modifiedGroups.entrySet()) {
+            for (final Map.Entry<String, String> entry : modifiedGroups.entrySet()) {
                 InvocationResult result = null;
-               String group = entry.getKey();
+                final String group = entry.getKey();
                 try {
-                       LOGGER.info("PushRules: ModifiedGroups, Key: " + group + ", Value: " + entry.getValue());
-                    InvocationRequest request = new DefaultInvocationRequest();
+                    LOGGER.info("PushRules: ModifiedGroups, Key: " + group + ", Value: " + entry.getValue());
+                    final InvocationRequest request = new DefaultInvocationRequest();
                     setVersion(group);
                     createPom(group);
                     request.setPomFile(new File(
-                            PROJECTSLOCATION + File.separator + getArtifactID(group) + File.separator + POM_XML_FILE));
+                            PROJECTSLOCATION + File.separator + getArtifactId(group) + File.separator + POM_XML_FILE));
                     request.setGoals(Arrays.asList(GOALS));
-                    Invoker invoker = new DefaultInvoker();
+                    final Invoker invoker = new DefaultInvoker();
                     result = invoker.execute(request);
                     if (result.getExecutionException() != null) {
                         LOGGER.error(result.getExecutionException());
                     } else if (result.getExitCode() != 0) {
                         LOGGER.error("Maven Invocation failure..!");
                     }
-                } catch (Exception e) {
+                } catch (final Exception e) {
                     LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Maven Invocation issue for "
-                            + getArtifactID(group) + e.getMessage(), e);
+                            + getArtifactId(group) + e.getMessage(), e);
                 }
                 if (result != null && result.getExitCode() == 0) {
                     LOGGER.info("Build Completed..!");
@@ -802,8 +804,8 @@ private void extractJar(String jarFileName, String artifactId){
     /**
      * Removes a Rule from Rule Projects.
      */
-    public void removeRule(String name) {
-        String controllerName = getGroupName(name);
+    public void removeRule(final String name) {
+        final String controllerName = getGroupName(name);
         if (controllerName == null) {
             LOGGER.info("Error finding the controllerName for the given Policy: " + name);
             return;
@@ -812,7 +814,7 @@ private void extractJar(String jarFileName, String artifactId){
         getNameAndSetRemove(controllerName, name);
     }
 
-    private String getGroupName(String name) {
+    private String getGroupName(final String name) {
         if (policyMap.containsKey(name)) {
             return policyMap.get(name);
         } else {
@@ -821,57 +823,57 @@ private void extractJar(String jarFileName, String artifactId){
         }
     }
 
-    private void addModifiedGroup(String controllerName, String operation) {
+    private void addModifiedGroup(final String controllerName, final String operation) {
         if (controllerName != null) {
             modifiedGroups.put(controllerName, operation);
         }
     }
 
-    private void addNotification(String controllerName, String operation) {
-        ControllerPOJO controllerPOJO = new ControllerPOJO();
-        controllerPOJO.setName(controllerName);
-        controllerPOJO.setOperation(operation);
-        HashMap<String, String> drools = new HashMap<>();
-        drools.put("groupId", getGroupID(controllerName));
-        drools.put("artifactId", getArtifactID(controllerName));
+    private void addNotification(final String controllerName, final String operation) {
+        final ControllerPojo controllerPojo = new ControllerPojo();
+        controllerPojo.setName(controllerName);
+        controllerPojo.setOperation(operation);
+        final HashMap<String, String> drools = new HashMap<>();
+        drools.put("groupId", getGroupId(controllerName));
+        drools.put("artifactId", getArtifactId(controllerName));
         drools.put("version", getVersion(controllerName));
-        controllerPOJO.setDrools(drools);
-        controllers.add(controllerPOJO);
+        controllerPojo.setDrools(drools);
+        controllers.add(controllerPojo);
         try {
-            LOGGER.debug("Notification added: " + PolicyUtils.objectToJsonString(controllerPOJO));
-        } catch (JsonProcessingException e) {
+            LOGGER.debug("Notification added: " + PolicyUtils.objectToJsonString(controllerPojo));
+        } catch (final JsonProcessingException e) {
             LOGGER.error(MessageCodes.ERROR_SCHEMA_INVALID + "Json Processing Error " + e);
         }
     }
 
-    private void removedRuleModifiedGroup(String controllerName) {
+    private void removedRuleModifiedGroup(final String controllerName) {
         // This will be sending Notification to PDPD directly to Lock
-        ControllerPOJO controllerPOJO = new ControllerPOJO();
-        controllerPOJO.setName(controllerName);
-        controllerPOJO.setOperation("lock");
-        List<ControllerPOJO> controllerPojos = new ArrayList<>();
-        controllerPojos.add(controllerPOJO);
+        final ControllerPojo controllerPojo = new ControllerPojo();
+        controllerPojo.setName(controllerName);
+        controllerPojo.setOperation("lock");
+        final List<ControllerPojo> controllerPojos = new ArrayList<>();
+        controllerPojos.add(controllerPojo);
         sendNotification(controllerPojos);
     }
 
-    private void sendNotification(List<ControllerPOJO> controllers) {
-        NotificationPOJO notification = new NotificationPOJO();
-        String requestId = UUID.randomUUID().toString();
+    private void sendNotification(final List<ControllerPojo> controllers) {
+        final NotificationPojo notification = new NotificationPojo();
+        final String requestId = UUID.randomUUID().toString();
         LOGGER.info("Generating notification RequestID : " + requestId);
-        notification.setRequestID(requestId);
+        notification.setRequestId(requestId);
         notification.setEntity("controller");
         notification.setControllers(controllers);
         try {
-            String notificationJson = PolicyUtils.objectToJsonString(notification);
+            final String notificationJson = PolicyUtils.objectToJsonString(notification);
             LOGGER.info("Sending Notification :\n" + notificationJson);
             sendMessage(notificationJson);
-        } catch (Exception e) {
+        } catch (final Exception e) {
             LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while sending notification to PDP-D "
                     + e.getMessage(), e);
         }
     }
 
-    private void sendMessage(String message) throws IOException, GeneralSecurityException, InterruptedException {
+    private void sendMessage(final String message) throws IOException, GeneralSecurityException, InterruptedException {
 
         if ("dmaap".equalsIgnoreCase(notificationType)) {
             // Sending Message through DMaaP Message Router
@@ -887,7 +889,7 @@ private void extractJar(String jarFileName, String artifactId){
             // Sending Message through UEB interface.
             LOGGER.debug("UEB Publishing Message");
 
-            CambriaBatchingPublisher pub = pubBuilder.build();
+            final CambriaBatchingPublisher pub = pubBuilder.build();
             pub.send("MyPartitionKey", message);
 
             final List<?> stuck = pub.close(uebDelay, TimeUnit.SECONDS);
@@ -900,26 +902,26 @@ private void extractJar(String jarFileName, String artifactId){
 
     }
 
-    private void createPom(String name) {
-        Model model = new Model();
+    private void createPom(final String name) {
+        final Model model = new Model();
         model.setModelVersion("4.0.0");
-        model.setGroupId(getGroupID(name));
-        model.setArtifactId(getArtifactID(name));
+        model.setGroupId(getGroupId(name));
+        model.setArtifactId(getArtifactId(name));
         model.setVersion(getVersion(name));
         model.setName(name);
-        DistributionManagement distributionManagement = new DistributionManagement();
-        DeploymentRepository repository = new DeploymentRepository();
-        repository.setId(repID);
+        final DistributionManagement distributionManagement = new DistributionManagement();
+        final DeploymentRepository repository = new DeploymentRepository();
+        repository.setId(repId);
         repository.setName(repName);
-        repository.setUrl(repURLs.get(0));
+        repository.setUrl(repUrlList.get(0));
         distributionManagement.setRepository(repository);
         model.setDistributionManagement(distributionManagement);
         // Dependency Management goes here.
         List<Dependency> dependencyList = new ArrayList<>();
         if (groupMap.get(name).size() > 1) {
             @SuppressWarnings("unchecked")
-            ArrayList<PEDependency> dependencies = (ArrayList<PEDependency>) groupMap.get(name).get(1);
-            for (PEDependency dependency : dependencies) {
+            final ArrayList<PEDependency> dependencies = (ArrayList<PEDependency>) groupMap.get(name).get(1);
+            for (final PEDependency dependency : dependencies) {
                 dependencyList.add(dependency.getDependency());
             }
         } else {
@@ -930,30 +932,31 @@ private void extractJar(String jarFileName, String artifactId){
         Writer writer = null;
         try {
             writer = WriterFactory.newXmlWriter(
-                    new File(PROJECTSLOCATION + File.separator + getArtifactID(name) + File.separator + POM_XML_FILE));
-            MavenXpp3Writer pomWriter = new MavenXpp3Writer();
+                    new File(PROJECTSLOCATION + File.separator + getArtifactId(name) + File.separator + POM_XML_FILE));
+            final MavenXpp3Writer pomWriter = new MavenXpp3Writer();
             pomWriter.write(writer, model);
-        } catch (Exception e) {
-            LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while creating POM for " + getArtifactID(name)
+        } catch (final Exception e) {
+            LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while creating POM for " + getArtifactId(name)
                     + e.getMessage(), e);
         } finally {
             IOUtil.close(writer);
         }
     }
 
-    private List<Dependency> getDependencies(String controllerName) {
+    private List<Dependency> getDependencies(final String controllerName) {
         // Read the Dependency Information from property file.
-        Path file = Paths.get(DEPENDENCY_FILE);
+        final Path file = Paths.get(DEPENDENCY_FILE);
         if (!Files.notExists(file)) {
             try {
-                String dependencyJSON = new String(Files.readAllBytes(file), StandardCharsets.UTF_8);
-                DependencyInfo dependencyInfo = PolicyUtils.jsonStringToObject(dependencyJSON, DependencyInfo.class);
+                final String dependencyJson = new String(Files.readAllBytes(file), StandardCharsets.UTF_8);
+                final DependencyInfo dependencyInfo =
+                        PolicyUtils.jsonStringToObject(dependencyJson, DependencyInfo.class);
                 String controller = "default";
                 if (dependencyInfo.getDependencies().containsKey(controllerName)) {
                     controller = controllerName;
                 }
-                List<Dependency> dependencyList = new ArrayList<>();
-                for (PEDependency dependency : dependencyInfo.getDependencies().get(controller)) {
+                final List<Dependency> dependencyList = new ArrayList<>();
+                for (final PEDependency dependency : dependencyInfo.getDependencies().get(controller)) {
                     dependencyList.add(dependency.getDependency());
                 }
                 return dependencyList;
@@ -966,49 +969,54 @@ private void extractJar(String jarFileName, String artifactId){
         return defaultDependencies(controllerName);
     }
 
-    // Default Dependency Section. Can be changed as required.
-    public List<Dependency> defaultDependencies(String controllerName) {
+    /**
+     * Default Dependency Section. Can be changed as required.
+     * 
+     * @param controllerName the controller name
+     * @return changed dependency list
+     */
+    public List<Dependency> defaultDependencies(final String controllerName) {
 
-        List<Dependency> dependencyList = new ArrayList<>();
-        String version = StringEscapeUtils.escapeJava(brmsdependencyversion);
+        final List<Dependency> dependencyList = new ArrayList<>();
+        final String version = StringEscapeUtils.escapeJava(brmsdependencyversion);
 
-        Dependency demoDependency = new Dependency();
+        final Dependency demoDependency = new Dependency();
         demoDependency.setGroupId(DROOLS_APPS_TEMPLATE_GROUP);
         demoDependency.setArtifactId("template.demo");
         demoDependency.setVersion(version);
         dependencyList.add(demoDependency);
 
-        Dependency controlloopDependency = new Dependency();
+        final Dependency controlloopDependency = new Dependency();
         controlloopDependency.setGroupId(DROOLS_APPS_MODEL_GROUP);
         controlloopDependency.setArtifactId("events");
         controlloopDependency.setVersion(version);
         dependencyList.add(controlloopDependency);
 
-        Dependency restDependency = new Dependency();
+        final Dependency restDependency = new Dependency();
         restDependency.setGroupId(DROOLS_APPS_MODEL_GROUP);
         restDependency.setArtifactId("controlloop.common.model-impl.rest");
         restDependency.setVersion(version);
         dependencyList.add(restDependency);
 
-        Dependency appcDependency = new Dependency();
+        final Dependency appcDependency = new Dependency();
         appcDependency.setGroupId(DROOLS_APPS_MODEL_GROUP);
         appcDependency.setArtifactId("controlloop.common.model-impl.appc");
         appcDependency.setVersion(version);
         dependencyList.add(appcDependency);
 
-        Dependency aaiDependency = new Dependency();
+        final Dependency aaiDependency = new Dependency();
         aaiDependency.setGroupId(DROOLS_APPS_MODEL_GROUP);
         aaiDependency.setArtifactId("controlloop.common.model-impl.aai");
         aaiDependency.setVersion(version);
         dependencyList.add(aaiDependency);
 
-        Dependency msoDependency = new Dependency();
+        final Dependency msoDependency = new Dependency();
         msoDependency.setGroupId(DROOLS_APPS_MODEL_GROUP);
         msoDependency.setArtifactId("controlloop.common.model-impl.so");
         msoDependency.setVersion(version);
         dependencyList.add(msoDependency);
 
-        Dependency trafficgeneratorDependency = new Dependency();
+        final Dependency trafficgeneratorDependency = new Dependency();
         trafficgeneratorDependency.setGroupId(DROOLS_APPS_MODEL_GROUP);
         trafficgeneratorDependency.setArtifactId("controlloop.common.model-impl.trafficgenerator");
         trafficgeneratorDependency.setVersion(version);
@@ -1016,12 +1024,12 @@ private void extractJar(String jarFileName, String artifactId){
         return dependencyList;
     }
 
-    private void createProject(String path, String ksessionName) {
+    private void createProject(final String path, final String ksessionName) {
         new File(path + File.separator + RULES).mkdirs();
         new File(path + File.separator + META_INF).mkdirs();
         if (!Files.exists(Paths.get(path + File.separator + META_INF + File.separator + KMODULE_XML_FILE))) {
             // Hard coding XML for PDP Drools to accept our Rules.
-            String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "\n"
+            final String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "\n"
                     + "<kmodule xmlns=\"http://jboss.org/kie/6.0.0/kmodule\">" + "\n"
                     + "<kbase name=\"rules\" packages=\"rules\">" + "\n" + "<ksession name=\"" + ksessionName + "\"/>"
                     + "\n" + "</kbase></kmodule>";
@@ -1029,75 +1037,72 @@ private void extractJar(String jarFileName, String artifactId){
         }
     }
 
-    private void copyDataToFile(String file, String rule) {
+    private void copyDataToFile(final String file, final String rule) {
         try {
             FileUtils.writeStringToFile(new File(file), rule);
-        } catch (Exception e) {
+        } catch (final Exception e) {
             LOGGER.error(
                     XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while creating Rule for " + file + e.getMessage(),
                     e);
         }
     }
 
-    private void readGroups(Properties config) throws PolicyException {
+    private void readGroups(final Properties config) throws PolicyException {
         String[] groupNames;
-        String groupNamesError = "groupNames property is missing or empty from the property file ";
-               if (!config.containsKey(GROUP_NAMES) || config.getProperty(GROUP_NAMES)==null){
-            throw new PolicyException(XACMLErrorConstants.ERROR_DATA_ISSUE
-                    + groupNamesError);
+        final String groupNamesError = "groupNames property is missing or empty from the property file ";
+        if (!config.containsKey(GROUP_NAMES) || config.getProperty(GROUP_NAMES) == null) {
+            throw new PolicyException(XACMLErrorConstants.ERROR_DATA_ISSUE + groupNamesError);
         }
         if (config.getProperty(GROUP_NAMES).contains(",")) {
             groupNames = config.getProperty(GROUP_NAMES).replaceAll(" ", "").split(",");
         } else {
-            groupNames = new String[] { config.getProperty(GROUP_NAMES).replaceAll(" ", "") };
+            groupNames = new String[] {config.getProperty(GROUP_NAMES).replaceAll(" ", "")};
         }
         if (groupNames == null || groupNames.length == 0) {
-            LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE
-                    + groupNamesError);
-            throw new PolicyException(XACMLErrorConstants.ERROR_DATA_ISSUE
-                    + groupNamesError);
+            LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + groupNamesError);
+            throw new PolicyException(XACMLErrorConstants.ERROR_DATA_ISSUE + groupNamesError);
         }
         groupMap = new HashMap<>();
         for (int counter = 0; counter < groupNames.length; counter++) {
-            String name = groupNames[counter];
-            String groupID = config.getProperty(name + ".groupID");
-            if (groupID == null) {
+            final String name = groupNames[counter];
+            final String groupId = config.getProperty(name + ".groupID");
+            if (groupId == null) {
                 LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + name
                         + ".groupID property is missing from the property file ");
                 throw new PolicyException(XACMLErrorConstants.ERROR_DATA_ISSUE + name
                         + ".groupID property is missing from the property file ");
             }
-            String artifactID = config.getProperty(name + ".artifactID");
-            if (artifactID == null) {
+            final String artifactId = config.getProperty(name + ".artifactID");
+            if (artifactId == null) {
                 LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + name
                         + ".artifactID property is missing from the property file ");
                 throw new PolicyException(XACMLErrorConstants.ERROR_DATA_ISSUE + name
                         + ".artifactID property is missing from the property file ");
             }
-            PEDependency dependency = new PEDependency();
-            dependency.setArtifactId(artifactID);
-            dependency.setGroupId(groupID);
+            final PEDependency dependency = new PEDependency();
+            dependency.setArtifactId(artifactId);
+            dependency.setGroupId(groupId);
             // Add to list if we got all
             addToGroup(name, dependency);
         }
     }
 
-    private void addToGroup(String name, PEDependency dependency) {
-        ArrayList<Object> values = new ArrayList<>();
+    private void addToGroup(final String name, final PEDependency dependency) {
+        final ArrayList<Object> values = new ArrayList<>();
         values.add(dependency);
         groupMap.put(name, values);
-        EntityTransaction et = em.getTransaction();
+        final EntityTransaction et = em.getTransaction();
         et.begin();
-        Query query = em.createQuery("select b from BRMSGroupInfo as b where b.controllerName = :cn");
+        final Query query = em.createQuery("select b from BrmsGroupInfo as b where b.controllerName = :cn");
         query.setParameter("cn", name);
-        List<?> groupList = query.getResultList();
-        BRMSGroupInfo brmsGroupInfo = null;
+        final List<?> groupList = query.getResultList();
+        BrmsGroupInfo brmsGroupInfo = null;
         if (!groupList.isEmpty()) {
             LOGGER.info("Controller name already Existing in DB. Will be updating the DB Values" + name);
-            brmsGroupInfo = (BRMSGroupInfo) groupList.get(0);
+            brmsGroupInfo = (BrmsGroupInfo) groupList.get(0);
         }
         if (brmsGroupInfo == null) {
-            brmsGroupInfo = new BRMSGroupInfo();
+            brmsGroupInfo = new BrmsGroupInfo();
         }
         brmsGroupInfo.setControllerName(name);
         brmsGroupInfo.setGroupId(dependency.getGroupId());
@@ -1108,23 +1113,23 @@ private void extractJar(String jarFileName, String artifactId){
         et.commit();
     }
 
-    private String getArtifactID(String name) {
+    private String getArtifactId(final String name) {
         return ((PEDependency) groupMap.get(name).get(0)).getArtifactId();
     }
 
-    private String getGroupID(String name) {
+    private String getGroupId(final String name) {
         return ((PEDependency) groupMap.get(name).get(0)).getGroupId();
     }
 
-    private String getVersion(String name) {
+    private String getVersion(final String name) {
         return ((PEDependency) groupMap.get(name).get(0)).getVersion();
     }
 
-    private void getNameAndSetRemove(String controllerName, String policyName) {
-        String artifactName = getArtifactID(controllerName);
-        String ruleFolder = PROJECTSLOCATION + File.separator + artifactName + File.separator + "src" + File.separator
-                + "main" + File.separator + RESOURCES + File.separator + RULES;
-        File file = new File(ruleFolder + File.separator + policyName + ".drl");
+    private void getNameAndSetRemove(final String controllerName, final String policyName) {
+        final String artifactName = getArtifactId(controllerName);
+        final String ruleFolder = PROJECTSLOCATION + File.separator + artifactName + File.separator + "src"
+                + File.separator + "main" + File.separator + RESOURCES + File.separator + RULES;
+        final File file = new File(ruleFolder + File.separator + policyName + ".drl");
         if (file.delete()) {
             LOGGER.info("Deleted File.. " + file.getAbsolutePath());
             removePolicyFromGroup(policyName, controllerName);
@@ -1138,17 +1143,17 @@ private void extractJar(String jarFileName, String artifactId){
     }
 
     // Removes Policy from Memory and Database.
-    private void removePolicyFromGroup(String policyName, String controllerName) {
+    private void removePolicyFromGroup(final String policyName, final String controllerName) {
         policyMap.remove(policyName);
-        EntityTransaction et = em.getTransaction();
+        final EntityTransaction et = em.getTransaction();
         et.begin();
-        Query query = em.createQuery("select b from BRMSPolicyInfo as b where b.policyName = :pn");
+        final Query query = em.createQuery("select b from BrmsPolicyInfo as b where b.policyName = :pn");
         query.setParameter("pn", policyName);
-        List<?> pList = query.getResultList();
-        BRMSPolicyInfo brmsPolicyInfo;
+        final List<?> pList = query.getResultList();
+        BrmsPolicyInfo brmsPolicyInfo;
         if (!pList.isEmpty()) {
             // Already exists.
-            brmsPolicyInfo = (BRMSPolicyInfo) pList.get(0);
+            brmsPolicyInfo = (BrmsPolicyInfo) pList.get(0);
             if (brmsPolicyInfo.getControllerName().getControllerName().equals(controllerName)) {
                 em.remove(brmsPolicyInfo);
                 em.flush();
@@ -1157,8 +1162,22 @@ private void extractJar(String jarFileName, String artifactId){
         et.commit();
     }
 
-    private void setVersion(String newVersion, String controllerName) {
-        PEDependency userController = (PEDependency) groupMap.get(controllerName).get(0);
+    private void setVersion(final String selectedName) {
+        String newVersion = VERSION_0_1_0;
+        createFlag = false;
+        final NexusArtifact artifact = getLatestArtifactFromNexus(selectedName);
+        if (artifact != null) {
+            newVersion = incrementVersion(artifact.getVersion());
+        }
+        if (VERSION_0_1_0.equals(newVersion)) {
+            createFlag = true;
+        }
+        setVersion(newVersion, selectedName);
+        LOGGER.info("Controller: " + selectedName + "is on version: " + newVersion);
+    }
+
+    private void setVersion(final String newVersion, final String controllerName) {
+        final PEDependency userController = (PEDependency) groupMap.get(controllerName).get(0);
         userController.setVersion(newVersion);
         groupMap.get(controllerName).set(0, userController);
     }
@@ -1168,16 +1187,21 @@ private void extractJar(String jarFileName, String artifactId){
         return bm;
     }
 
-    public void rotateURLs() {
-        if (repURLs != null) {
-            Collections.rotate(repURLs, -1);
+    /**
+     * Rotate URLs list.
+     */
+    public void rotateUrls() {
+        if (repUrlList != null) {
+            Collections.rotate(repUrlList, -1);
         }
     }
 
+    /**
+     * Get URL List Size.
+     * 
+     * @return URL list size
+     */
     public int urlListSize() {
-        if (repURLs != null) {
-            return repURLs.size();
-        } else
-            return 0;
+        return repUrlList != null ? repUrlList.size() : 0;
     }
 }