This is an automated email from the ASF dual-hosted git repository.

madhan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git


The following commit(s) were added to refs/heads/master by this push:
     new c482cc3c0 ATLAS-4968: checkstyle compliance updates - tools module 
(#281)
c482cc3c0 is described below

commit c482cc3c0d07920439fa333b6841e3a224f3aae2
Author: Abhishek Kumar <a...@apache.org>
AuthorDate: Tue Feb 11 09:52:43 2025 -0800

    ATLAS-4968: checkstyle compliance updates - tools module (#281)
---
 tools/atlas-index-repair/pom.xml                   |  13 +--
 .../java/org/apache/atlas/tools/RepairIndex.java   |  77 +++++++--------
 tools/classification-updater/pom.xml               |  16 +--
 .../org/apache/atlas/tools/BulkFetchAndUpdate.java | 108 ++++++++++-----------
 tools/notification-analyzer/pom.xml                |  11 +--
 .../apache/atlas/tools/NotificationAnalyzer.java   |  22 +++--
 6 files changed, 114 insertions(+), 133 deletions(-)

diff --git a/tools/atlas-index-repair/pom.xml b/tools/atlas-index-repair/pom.xml
index 64014c21c..0b12730d7 100644
--- a/tools/atlas-index-repair/pom.xml
+++ b/tools/atlas-index-repair/pom.xml
@@ -18,40 +18,37 @@
   -->
 <project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>
     <modelVersion>4.0.0</modelVersion>
-
     <parent>
         <groupId>org.apache.atlas</groupId>
         <artifactId>apache-atlas</artifactId>
         <version>3.0.0-SNAPSHOT</version>
         <relativePath>../../</relativePath>
     </parent>
-
     <artifactId>atlas-index-repair-tool</artifactId>
     <packaging>jar</packaging>
-
     <name>Apache Atlas index repair tool</name>
     <description>Apache Atlas index repair Module</description>
+    <properties>
+        <checkstyle.failOnViolation>true</checkstyle.failOnViolation>
+        <checkstyle.skip>false</checkstyle.skip>
+    </properties>
 
     <dependencies>
-
         <dependency>
             <groupId>org.apache.atlas</groupId>
             <artifactId>atlas-client-v2</artifactId>
             <version>${project.version}</version>
         </dependency>
-
         <dependency>
             <groupId>org.apache.atlas</groupId>
             <artifactId>atlas-graphdb-janus</artifactId>
             <version>${project.version}</version>
         </dependency>
-
         <dependency>
             <groupId>org.apache.atlas</groupId>
             <artifactId>atlas-repository</artifactId>
             <version>${project.version}</version>
         </dependency>
-
         <dependency>
             <groupId>org.janusgraph</groupId>
             <artifactId>janusgraph-core</artifactId>
@@ -67,7 +64,5 @@
                 </exclusion>
             </exclusions>
         </dependency>
-
     </dependencies>
-
 </project>
diff --git 
a/tools/atlas-index-repair/src/main/java/org/apache/atlas/tools/RepairIndex.java
 
b/tools/atlas-index-repair/src/main/java/org/apache/atlas/tools/RepairIndex.java
index 8a8e8cafc..4d362cdbd 100644
--- 
a/tools/atlas-index-repair/src/main/java/org/apache/atlas/tools/RepairIndex.java
+++ 
b/tools/atlas-index-repair/src/main/java/org/apache/atlas/tools/RepairIndex.java
@@ -26,7 +26,6 @@ import 
org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
 import org.apache.atlas.repository.graphdb.AtlasVertex;
 import org.apache.atlas.repository.graphdb.janus.AtlasJanusGraphDatabase;
 import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2;
-import org.apache.atlas.security.SecurityProperties;
 import org.apache.atlas.utils.AuthenticationUtil;
 import org.apache.atlas.utils.SSLUtil;
 import org.apache.commons.cli.CommandLine;
@@ -57,29 +56,28 @@ import java.util.function.Consumer;
 public class RepairIndex {
     private static final Logger LOG = 
LoggerFactory.getLogger(RepairIndex.class);
 
-    private static final int EXIT_CODE_SUCCESS = 0;
-    private static final int EXIT_CODE_FAILED = 1;
-    private static final int  MAX_TRIES_ON_FAILURE = 3;
-
-    private static final String INDEX_NAME_VERTEX_INDEX = "vertex_index";
-    private static final String INDEX_NAME_FULLTEXT_INDEX = "fulltext_index";
-    private static final String INDEX_NAME_EDGE_INDEX = "edge_index";
-    private static final String DEFAULT_ATLAS_URL = "http://localhost:21000/";;
+    private static final int EXIT_CODE_SUCCESS                      = 0;
+    private static final int EXIT_CODE_FAILED                       = 1;
+    private static final int MAX_TRIES_ON_FAILURE                   = 3;
+    private static final String INDEX_NAME_VERTEX_INDEX             = 
"vertex_index";
+    private static final String INDEX_NAME_FULLTEXT_INDEX           = 
"fulltext_index";
+    private static final String INDEX_NAME_EDGE_INDEX               = 
"edge_index";
+    private static final String DEFAULT_ATLAS_URL                   = 
"http://localhost:21000/";;
     private static final String APPLICATION_PROPERTY_ATLAS_ENDPOINT = 
"atlas.rest.address";
 
-    private static JanusGraph graph;
+    private static JanusGraph    graph;
     private static AtlasClientV2 atlasClientV2;
-    private static boolean isSelectiveRestore;
+    private static boolean       isSelectiveRestore;
 
     public static void main(String[] args) {
         int exitCode = EXIT_CODE_FAILED;
         LOG.info("Started index repair");
 
         try {
-            CommandLine cmd = getCommandLine(args);
-            String guid = cmd.getOptionValue("g");
+            CommandLine cmd  = getCommandLine(args);
+            String      guid = cmd.getOptionValue("g");
 
-            if(guid != null && !guid.isEmpty()){
+            if (guid != null && !guid.isEmpty()) {
                 isSelectiveRestore = true;
                 String uid = cmd.getOptionValue("u");
                 String pwd = cmd.getOptionValue("p");
@@ -108,7 +106,7 @@ public class RepairIndex {
 
         if (isSelectiveRestore) {
             repairIndex.restoreSelective(guid);
-        }else{
+        } else {
             repairIndex.restoreAll();
         }
 
@@ -131,24 +129,24 @@ public class RepairIndex {
     }
 
     private static String[] getIndexes() {
-        return new String[]{ INDEX_NAME_VERTEX_INDEX, INDEX_NAME_EDGE_INDEX, 
INDEX_NAME_FULLTEXT_INDEX};
+        return new String[] {INDEX_NAME_VERTEX_INDEX, INDEX_NAME_EDGE_INDEX, 
INDEX_NAME_FULLTEXT_INDEX};
     }
 
     private static void setupAtlasClient(String uid, String pwd) throws 
AtlasException {
         String[] atlasEndpoint = getAtlasRESTUrl();
         if (atlasEndpoint == null || atlasEndpoint.length == 0) {
-            atlasEndpoint = new String[]{DEFAULT_ATLAS_URL};
+            atlasEndpoint = new String[] {DEFAULT_ATLAS_URL};
         }
-        atlasClientV2 = getAtlasClientV2(atlasEndpoint, new String[]{uid, 
pwd});
+        atlasClientV2 = getAtlasClientV2(atlasEndpoint, new String[] {uid, 
pwd});
     }
 
     private void restoreAll() throws Exception {
-        for (String indexName : getIndexes()){
+        for (String indexName : getIndexes()) {
             displayCrlf("Restoring: " + indexName);
             long startTime = System.currentTimeMillis();
 
-            ManagementSystem mgmt = (ManagementSystem) graph.openManagement();
-            JanusGraphIndex index = mgmt.getGraphIndex(indexName);
+            ManagementSystem mgmt  = (ManagementSystem) graph.openManagement();
+            JanusGraphIndex  index = mgmt.getGraphIndex(indexName);
             mgmt.updateIndex(index, SchemaAction.REINDEX).get();
             mgmt.commit();
 
@@ -159,15 +157,14 @@ public class RepairIndex {
         }
     }
 
-
-    private void restoreSelective(String guid) throws Exception  {
+    private void restoreSelective(String guid) throws Exception {
         Set<String> referencedGUIDs = new 
HashSet<>(getEntityAndReferenceGuids(guid));
-        displayCrlf("processing referencedGuids => "+ referencedGUIDs);
+        displayCrlf("processing referencedGuids => " + referencedGUIDs);
 
-        StandardJanusGraph janusGraph = (StandardJanusGraph) graph;
-        IndexSerializer indexSerializer = janusGraph.getIndexSerializer();
+        StandardJanusGraph janusGraph      = (StandardJanusGraph) graph;
+        IndexSerializer    indexSerializer = janusGraph.getIndexSerializer();
 
-        for (String indexName : getIndexes()){
+        for (String indexName : getIndexes()) {
             displayCrlf("Restoring: " + indexName);
             long startTime = System.currentTimeMillis();
             reindexVertex(indexName, indexSerializer, referencedGUIDs);
@@ -179,19 +176,19 @@ public class RepairIndex {
 
     private static void reindexVertex(String indexName, IndexSerializer 
indexSerializer, Set<String> entityGUIDs) throws Exception {
         Map<String, Map<String, List<IndexEntry>>> documentsPerStore = new 
java.util.HashMap<>();
-        ManagementSystem mgmt = (ManagementSystem) graph.openManagement();
-        StandardJanusGraphTx tx = mgmt.getWrappedTx();
-        BackendTransaction mutator = tx.getTxHandle();
-        JanusGraphIndex index = mgmt.getGraphIndex(indexName);
-        MixedIndexType indexType = (MixedIndexType) 
mgmt.getSchemaVertex(index).asIndexType();
+        ManagementSystem                           mgmt              = 
(ManagementSystem) graph.openManagement();
+        StandardJanusGraphTx                       tx                = 
mgmt.getWrappedTx();
+        BackendTransaction                         mutator           = 
tx.getTxHandle();
+        JanusGraphIndex                            index             = 
mgmt.getGraphIndex(indexName);
+        MixedIndexType                             indexType         = 
(MixedIndexType) mgmt.getSchemaVertex(index).asIndexType();
 
-        for (String entityGuid : entityGUIDs){
+        for (String entityGuid : entityGUIDs) {
             for (int attemptCount = 1; attemptCount <= MAX_TRIES_ON_FAILURE; 
attemptCount++) {
                 AtlasVertex vertex = AtlasGraphUtilsV2.findByGuid(entityGuid);
                 try {
                     indexSerializer.reindexElement(vertex.getWrappedElement(), 
indexType, documentsPerStore);
                     break;
-                }catch (Exception e){
+                } catch (Exception e) {
                     displayCrlf("Exception: " + e.getMessage());
                     displayCrlf("Pausing before retry..");
                     Thread.sleep(2000 * attemptCount);
@@ -204,8 +201,8 @@ public class RepairIndex {
     private static Set<String> getEntityAndReferenceGuids(String guid) throws 
Exception {
         Set<String> set = new HashSet<>();
         set.add(guid);
-        AtlasEntityWithExtInfo entity = atlasClientV2.getEntityByGuid(guid);
-        Map<String, AtlasEntity> map = entity.getReferredEntities();
+        AtlasEntityWithExtInfo   entity = atlasClientV2.getEntityByGuid(guid);
+        Map<String, AtlasEntity> map    = entity.getReferredEntities();
         if (map == null || map.isEmpty()) {
             return set;
         }
@@ -230,21 +227,19 @@ public class RepairIndex {
     }
 
     private static String[] getAtlasRESTUrl() {
-        Configuration atlasConf = null;
+        Configuration atlasConf;
         try {
             atlasConf = ApplicationProperties.get();
             return 
atlasConf.getStringArray(APPLICATION_PROPERTY_ATLAS_ENDPOINT);
         } catch (AtlasException e) {
-            return new String[]{DEFAULT_ATLAS_URL};
+            return new String[] {DEFAULT_ATLAS_URL};
         }
     }
 
     private static AtlasClientV2 getAtlasClientV2(String[] atlasEndpoint, 
String[] uidPwdFromCommandLine) throws AtlasException {
         AtlasClientV2 atlasClientV2;
         if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) {
-            String[] uidPwd = (uidPwdFromCommandLine[0] == null || 
uidPwdFromCommandLine[1] == null)
-                    ? AuthenticationUtil.getBasicAuthenticationInput()
-                    : uidPwdFromCommandLine;
+            String[] uidPwd = (uidPwdFromCommandLine[0] == null || 
uidPwdFromCommandLine[1] == null) ? 
AuthenticationUtil.getBasicAuthenticationInput() : uidPwdFromCommandLine;
 
             atlasClientV2 = new AtlasClientV2(atlasEndpoint, uidPwd);
         } else {
diff --git a/tools/classification-updater/pom.xml 
b/tools/classification-updater/pom.xml
index e44cda590..7a2606b04 100644
--- a/tools/classification-updater/pom.xml
+++ b/tools/classification-updater/pom.xml
@@ -18,50 +18,41 @@
   -->
 <project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>
     <modelVersion>4.0.0</modelVersion>
-
     <parent>
         <groupId>org.apache.atlas</groupId>
         <artifactId>apache-atlas</artifactId>
         <version>3.0.0-SNAPSHOT</version>
         <relativePath>../../</relativePath>
     </parent>
-
     <artifactId>atlas-classification-updater</artifactId>
     <packaging>jar</packaging>
-
     <name>Apache Atlas classification updater</name>
     <description>Apache Atlas classification updater Module</description>
-
     <properties>
         <calcite.version>0.9.2-incubating</calcite.version>
+        <checkstyle.failOnViolation>true</checkstyle.failOnViolation>
+        <checkstyle.skip>false</checkstyle.skip>
     </properties>
-
     <dependencies>
-
         <!-- to bring up atlas server for integration tests -->
-
         <dependency>
             <groupId>com.fasterxml.jackson.core</groupId>
             <artifactId>jackson-databind</artifactId>
             <version>${jackson.databind.version}</version>
         </dependency>
-
         <dependency>
             <groupId>org.apache.atlas</groupId>
             <artifactId>atlas-client-v1</artifactId>
         </dependency>
-
         <dependency>
             <groupId>org.apache.atlas</groupId>
             <artifactId>atlas-client-v2</artifactId>
             <version>${project.version}</version>
         </dependency>
-
         <dependency>
             <groupId>org.apache.atlas</groupId>
             <artifactId>atlas-notification</artifactId>
         </dependency>
-
         <dependency>
             <groupId>org.mockito</groupId>
             <artifactId>mockito-all</artifactId>
@@ -71,17 +62,14 @@
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
         </dependency>
-
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-log4j12</artifactId>
         </dependency>
-
         <dependency>
             <groupId>org.testng</groupId>
             <artifactId>testng</artifactId>
         </dependency>
-
     </dependencies>
 
     <build>
diff --git 
a/tools/classification-updater/src/main/java/org/apache/atlas/tools/BulkFetchAndUpdate.java
 
b/tools/classification-updater/src/main/java/org/apache/atlas/tools/BulkFetchAndUpdate.java
index 91ff89a00..e554f5414 100644
--- 
a/tools/classification-updater/src/main/java/org/apache/atlas/tools/BulkFetchAndUpdate.java
+++ 
b/tools/classification-updater/src/main/java/org/apache/atlas/tools/BulkFetchAndUpdate.java
@@ -45,6 +45,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.ws.rs.core.MultivaluedMap;
+
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileNotFoundException;
@@ -64,20 +65,23 @@ import static 
org.apache.atlas.model.instance.AtlasEntity.Status.DELETED;
 public class BulkFetchAndUpdate {
     private static final Logger LOG = 
LoggerFactory.getLogger(BulkFetchAndUpdate.class);
 
-    private static final String DATE_FORMAT_SUPPORTED = 
"yyyy-MM-dd'T'HH:mm:ss";
-    private static final String OPTION_FROM = "f";
-
+    private static final String DATE_FORMAT_SUPPORTED               = 
"yyyy-MM-dd'T'HH:mm:ss";
+    private static final String OPTION_FROM                         = "f";
     private static final String APPLICATION_PROPERTY_ATLAS_ENDPOINT = 
"atlas.rest.address";
-    private static final String SYSTEM_PROPERTY_USER_DIR = "user.dir";
-    private static final String STEP_PREPARE = "prepare";
-    private static final String STEP_UPDATE = "update";
-    private static final int EXIT_CODE_SUCCESS = 0;
-    private static final int EXIT_CODE_FAILED = 1;
-    private static final String DEFAULT_ATLAS_URL = "http://localhost:21000/";;
-    private static final String FILE_CLASSIFICATION_DEFS = 
"classification-definitions.json";
-    private static final String FILE_ENTITY_HEADERS = "entity-headers.json";
-
-    private final static String[] filesToUse = new String[] {
+    private static final String SYSTEM_PROPERTY_USER_DIR            = 
"user.dir";
+    private static final String STEP_PREPARE                        = 
"prepare";
+    private static final String STEP_UPDATE                         = "update";
+    private static final String DEFAULT_ATLAS_URL                   = 
"http://localhost:21000/";;
+    private static final String FILE_CLASSIFICATION_DEFS            = 
"classification-definitions.json";
+    private static final String FILE_ENTITY_HEADERS                 = 
"entity-headers.json";
+    private static final int    EXIT_CODE_SUCCESS                   = 0;
+    private static final int    EXIT_CODE_FAILED                    = 1;
+
+    private BulkFetchAndUpdate() {
+        // to block instantiation
+    }
+
+    private static final String[] filesToUse = new String[] {
             FILE_CLASSIFICATION_DEFS,
             FILE_ENTITY_HEADERS
     };
@@ -86,21 +90,21 @@ public class BulkFetchAndUpdate {
         int exitCode = EXIT_CODE_FAILED;
 
         try {
-            long fromTimestamp = 0L;
-            CommandLine cmd = getCommandLine(args);
+            long        fromTimestamp = 0L;
+            CommandLine cmd           = getCommandLine(args);
 
             String stepToExecute = cmd.getOptionValue("s").trim();
-            String uid = cmd.getOptionValue("u");
-            String pwd = cmd.getOptionValue("p");
-            String directory = cmd.getOptionValue("d");
-            String fromTime = cmd.getOptionValue(OPTION_FROM);
-            String basePath = getDirectory(directory);
+            String uid           = cmd.getOptionValue("u");
+            String pwd           = cmd.getOptionValue("p");
+            String directory     = cmd.getOptionValue("d");
+            String fromTime      = cmd.getOptionValue(OPTION_FROM);
+            String basePath      = getDirectory(directory);
 
             displayCrLf(basePath);
 
             String[] atlasEndpoint = getAtlasRESTUrl();
             if (atlasEndpoint == null || atlasEndpoint.length == 0) {
-                atlasEndpoint = new String[]{DEFAULT_ATLAS_URL};
+                atlasEndpoint = new String[] {DEFAULT_ATLAS_URL};
             }
 
             if (StringUtils.equals(stepToExecute, STEP_PREPARE)) {
@@ -138,7 +142,7 @@ public class BulkFetchAndUpdate {
                 return 0;
             }
 
-            TimeZone utc = TimeZone.getDefault();
+            TimeZone         utc              = TimeZone.getDefault();
             SimpleDateFormat simpleDateFormat = new 
SimpleDateFormat(DATE_FORMAT_SUPPORTED);
             simpleDateFormat.setTimeZone(utc);
 
@@ -150,7 +154,7 @@ public class BulkFetchAndUpdate {
     }
 
     private static void process(String stepToExecute, String basePath, 
String[] atlasEndpoint, String uid, String pwd, long fromTimestamp) throws 
Exception {
-        AtlasClientV2 atlasClientV2 = getAtlasClientV2(atlasEndpoint, new 
String[]{uid, pwd});
+        AtlasClientV2 atlasClientV2 = getAtlasClientV2(atlasEndpoint, new 
String[] {uid, pwd});
 
         switch (stepToExecute) {
             case STEP_PREPARE: {
@@ -207,24 +211,21 @@ public class BulkFetchAndUpdate {
     }
 
     private static String[] getAtlasRESTUrl() {
-        Configuration atlasConf = null;
+        Configuration atlasConf;
         try {
             atlasConf = ApplicationProperties.get();
             return 
atlasConf.getStringArray(APPLICATION_PROPERTY_ATLAS_ENDPOINT);
         } catch (AtlasException e) {
-            return new String[]{DEFAULT_ATLAS_URL};
+            return new String[] {DEFAULT_ATLAS_URL};
         }
     }
 
     private static AtlasClientV2 getAtlasClientV2(String[] atlasEndpoint, 
String[] uidPwdFromCommandLine) throws IOException {
         AtlasClientV2 atlasClientV2;
         if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) {
-            String[] uidPwd = (uidPwdFromCommandLine[0] == null || 
uidPwdFromCommandLine[1] == null)
-                    ? AuthenticationUtil.getBasicAuthenticationInput()
-                    : uidPwdFromCommandLine;
+            String[] uidPwd = (uidPwdFromCommandLine[0] == null || 
uidPwdFromCommandLine[1] == null) ? 
AuthenticationUtil.getBasicAuthenticationInput() : uidPwdFromCommandLine;
 
             atlasClientV2 = new AtlasClientV2(atlasEndpoint, uidPwd);
-
         } else {
             UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
             atlasClientV2 = new AtlasClientV2(ugi, ugi.getShortUserName(), 
atlasEndpoint);
@@ -247,6 +248,7 @@ public class BulkFetchAndUpdate {
             fn.accept(String.format(formatMessage[0], formatMessage[1]));
         }
     }
+
     private static void closeReader(BufferedReader bufferedReader) {
         try {
             if (bufferedReader == null) {
@@ -273,7 +275,7 @@ public class BulkFetchAndUpdate {
     }
 
     private static boolean fileCheck(String basePath, String file, boolean 
existCheck) {
-        String errorMessage = existCheck ? "does not exist" : "exists" ;
+        String errorMessage = existCheck ? "does not exist" : "exists";
         if (checkFileExists(basePath + file) != existCheck) {
             displayCrLf(String.format("File '%s' %s!", basePath + file, 
errorMessage));
             return false;
@@ -299,17 +301,19 @@ public class BulkFetchAndUpdate {
     }
 
     private static class Preparer {
-        private static final String  ATTR_NAME_QUALIFIED_NAME = 
"qualifiedName";
+        private static final String ATTR_NAME_QUALIFIED_NAME = "qualifiedName";
 
-        private AtlasClientV2 atlasClientV2;
-        private Map<String, String> typeNameUniqueAttributeNameMap = new 
HashMap<>();
+        private final AtlasClientV2 atlasClientV2;
+        private final Map<String, String> typeNameUniqueAttributeNameMap = new 
HashMap<>();
 
         public Preparer(AtlasClientV2 atlasClientV2) {
             this.atlasClientV2 = atlasClientV2;
         }
 
         public void run(String basePath, long fromTimestamp) throws Exception {
-            if (!fileCheck(basePath, filesToUse, false)) return;
+            if (!fileCheck(basePath, filesToUse, false)) {
+                return;
+            }
 
             displayCrLf("Starting: from: " + fromTimestamp + " to: " + 
"current time (" + System.currentTimeMillis() + ")...");
             writeClassificationDefs(basePath, FILE_CLASSIFICATION_DEFS, 
getAllClassificationsDefs());
@@ -318,9 +322,7 @@ public class BulkFetchAndUpdate {
         }
 
         private void writeClassificationDefs(String basePath, String fileName, 
List<AtlasClassificationDef> classificationDefs) throws IOException {
-            FileWriter fileWriter = null;
-            try {
-                fileWriter = getFileWriter(basePath, fileName);
+            try (FileWriter fileWriter = getFileWriter(basePath, fileName)) {
                 for (AtlasClassificationDef classificationDef : 
classificationDefs) {
                     try {
                         classificationDef.setGuid(null);
@@ -332,15 +334,10 @@ public class BulkFetchAndUpdate {
                     }
                 }
             }
-            finally {
-                if (fileWriter != null) {
-                    fileWriter.close();
-                }
-            }
         }
 
         private void writeEntityHeaders(String basePath, String fileName, long 
fromTimestamp) throws AtlasServiceException, IOException {
-            FileWriter fileWriter = null;
+            FileWriter fileWriter;
 
             try {
                 fileWriter = getFileWriter(basePath, fileName);
@@ -351,8 +348,8 @@ public class BulkFetchAndUpdate {
             }
 
             try {
-                AtlasEntityHeaders entityHeaders = 
atlasClientV2.getEntityHeaders(fromTimestamp);
-                int guidHeaderMapSize = 
entityHeaders.getGuidHeaderMap().size();
+                AtlasEntityHeaders entityHeaders     = 
atlasClientV2.getEntityHeaders(fromTimestamp);
+                int                guidHeaderMapSize = 
entityHeaders.getGuidHeaderMap().size();
                 try {
                     displayCrLf("Read entities: " + guidHeaderMapSize);
                     AtlasEntityHeaders updatedHeaders = 
removeEntityGuids(entityHeaders);
@@ -361,7 +358,7 @@ public class BulkFetchAndUpdate {
                     displayCrLf("Writing entities: " + 
updatedHeaders.getGuidHeaderMap().size());
                 } catch (Exception e) {
                     LOG.error("Error writing: {}", guidHeaderMapSize, e);
-                    displayCrLf("Error writing: " + e.toString());
+                    displayCrLf("Error writing: " + e);
                 }
             } finally {
                 if (fileWriter != null) {
@@ -412,7 +409,7 @@ public class BulkFetchAndUpdate {
                     if (!found) {
                         currentHeader.getClassifications().add(c);
                     } else {
-                        displayCrLf("Ignoring: " + c.toString());
+                        displayCrLf("Ignoring: " + c);
                         LOG.warn("Ignoring: {}", AtlasJson.toJson(c));
                     }
                 }
@@ -467,15 +464,16 @@ public class BulkFetchAndUpdate {
     }
 
     private static class Updater {
-        private AtlasClientV2 atlasClientV2;
+        private final AtlasClientV2 atlasClientV2;
 
         public Updater(AtlasClientV2 atlasClientV2) {
-
             this.atlasClientV2 = atlasClientV2;
         }
 
         public void run(String basePath) throws Exception {
-            if (!fileCheck(basePath, filesToUse, true)) return;
+            if (!fileCheck(basePath, filesToUse, true)) {
+                return;
+            }
 
             displayCrLf("Starting...");
             readAndCreateOrUpdateClassificationDefs(basePath, 
FILE_CLASSIFICATION_DEFS);
@@ -508,9 +506,10 @@ public class BulkFetchAndUpdate {
         private void readAndCreateOrUpdateClassificationDefs(String basePath, 
String fileName) throws Exception {
             BufferedReader bufferedReader = null;
             try {
+                String cd;
                 bufferedReader = getBufferedReader(basePath, fileName);
 
-                for (String cd; (cd = bufferedReader.readLine()) != null; ) {
+                while ((cd = bufferedReader.readLine()) != null) {
                     AtlasClassificationDef classificationDef = 
AtlasType.fromJson(cd, AtlasClassificationDef.class);
                     createOrUpdateClassification(classificationDef);
                 }
@@ -520,7 +519,7 @@ public class BulkFetchAndUpdate {
         }
 
         private void createOrUpdateClassification(AtlasClassificationDef 
classificationDef) {
-            String name = classificationDef.getName();
+            String        name     = classificationDef.getName();
             AtlasTypesDef typesDef = new AtlasTypesDef(null, null, 
Collections.singletonList(classificationDef), null, null);
             try {
                 display("%s -> ", name);
@@ -538,15 +537,12 @@ public class BulkFetchAndUpdate {
         }
 
         private void updateClassification(AtlasClassificationDef 
classificationDef) {
-            String name = classificationDef.getName();
+            String        name     = classificationDef.getName();
             AtlasTypesDef typesDef = new AtlasTypesDef(null, null, 
Collections.singletonList(classificationDef), null, null);
             try {
                 display("Update: %s -> ", name);
                 atlasClientV2.updateAtlasTypeDefs(typesDef);
                 displayCrLf(" [Done]");
-            } catch (AtlasServiceException e) {
-                LOG.error("{} skipped!", name, e);
-                displayCrLf(" [Skipped]", name);
             } catch (Exception ex) {
                 LOG.error("{} skipped!", name, ex);
                 displayCrLf(" [Skipped]", name);
diff --git a/tools/notification-analyzer/pom.xml 
b/tools/notification-analyzer/pom.xml
index 86bcd884b..e040488b3 100644
--- a/tools/notification-analyzer/pom.xml
+++ b/tools/notification-analyzer/pom.xml
@@ -18,20 +18,20 @@
   -->
 <project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>
     <modelVersion>4.0.0</modelVersion>
-
     <parent>
         <groupId>org.apache.atlas</groupId>
         <artifactId>apache-atlas</artifactId>
         <version>3.0.0-SNAPSHOT</version>
         <relativePath>../../</relativePath>
     </parent>
-
     <artifactId>atlas-notification-analyzer</artifactId>
     <packaging>jar</packaging>
-
     <name>Apache Atlas Notification Analyzer</name>
     <description>Apache Atlas Notification Analyzer</description>
-
+    <properties>
+        <checkstyle.failOnViolation>true</checkstyle.failOnViolation>
+        <checkstyle.skip>false</checkstyle.skip>
+    </properties>
     <dependencies>
         <dependency>
             <groupId>commons-cli</groupId>
@@ -43,7 +43,6 @@
             <artifactId>commons-collections</artifactId>
             <version>${commons-collections.version}</version>
         </dependency>
-
         <dependency>
             <groupId>org.apache.atlas</groupId>
             <artifactId>atlas-notification</artifactId>
@@ -54,14 +53,12 @@
             <artifactId>slf4j-api</artifactId>
             <version>${slf4j.version}</version>
         </dependency>
-
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-log4j12</artifactId>
             <version>${slf4j.version}</version>
         </dependency>
     </dependencies>
-
     <profiles>
         <profile>
             <id>dist</id>
diff --git 
a/tools/notification-analyzer/src/main/java/org/apache/atlas/tools/NotificationAnalyzer.java
 
b/tools/notification-analyzer/src/main/java/org/apache/atlas/tools/NotificationAnalyzer.java
index 20b106546..67f1093f4 100644
--- 
a/tools/notification-analyzer/src/main/java/org/apache/atlas/tools/NotificationAnalyzer.java
+++ 
b/tools/notification-analyzer/src/main/java/org/apache/atlas/tools/NotificationAnalyzer.java
@@ -21,6 +21,10 @@ package org.apache.atlas.tools;
 import org.apache.atlas.model.instance.AtlasEntity;
 import org.apache.atlas.model.instance.AtlasObjectId;
 import org.apache.atlas.model.notification.HookNotification;
+import 
org.apache.atlas.model.notification.HookNotification.EntityCreateRequestV2;
+import 
org.apache.atlas.model.notification.HookNotification.EntityDeleteRequestV2;
+import 
org.apache.atlas.model.notification.HookNotification.EntityPartialUpdateRequestV2;
+import 
org.apache.atlas.model.notification.HookNotification.EntityUpdateRequestV2;
 import org.apache.atlas.notification.AtlasNotificationMessageDeserializer;
 import org.apache.atlas.notification.NotificationInterface.NotificationType;
 import org.apache.atlas.utils.AtlasJson;
@@ -29,10 +33,6 @@ import 
org.apache.atlas.v1.model.notification.HookNotificationV1.EntityCreateReq
 import 
org.apache.atlas.v1.model.notification.HookNotificationV1.EntityDeleteRequest;
 import 
org.apache.atlas.v1.model.notification.HookNotificationV1.EntityPartialUpdateRequest;
 import 
org.apache.atlas.v1.model.notification.HookNotificationV1.EntityUpdateRequest;
-import 
org.apache.atlas.model.notification.HookNotification.EntityCreateRequestV2;
-import 
org.apache.atlas.model.notification.HookNotification.EntityDeleteRequestV2;
-import 
org.apache.atlas.model.notification.HookNotification.EntityPartialUpdateRequestV2;
-import 
org.apache.atlas.model.notification.HookNotification.EntityUpdateRequestV2;
 import org.apache.commons.cli.BasicParser;
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.CommandLineParser;
@@ -40,8 +40,18 @@ import org.apache.commons.cli.Options;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.*;
-import java.util.*;
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.IntSummaryStatistics;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
 import java.util.concurrent.atomic.AtomicInteger;
 
 public class NotificationAnalyzer {

Reply via email to