ATLAS-1304: Redundant code removal and code simplification Signed-off-by: Madhan Neethiraj <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/1620284e Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/1620284e Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/1620284e Branch: refs/heads/master Commit: 1620284e4c5d81a8722746d93fc32482bf41583a Parents: f6e27b5 Author: apoorvnaik <[email protected]> Authored: Thu Dec 15 19:28:12 2016 -0800 Committer: Madhan Neethiraj <[email protected]> Committed: Thu Dec 15 19:30:16 2016 -0800 ---------------------------------------------------------------------- .../apache/atlas/falcon/event/FalconEvent.java | 2 - .../apache/atlas/falcon/hook/FalconHookIT.java | 2 +- .../atlas/hive/bridge/HiveMetaStoreBridge.java | 2 +- .../org/apache/atlas/hive/hook/HiveHook.java | 44 +++++----- .../atlas/hive/rewrite/RewriteException.java | 2 - .../java/org/apache/atlas/hive/HiveITBase.java | 4 +- .../hive/bridge/HiveMetaStoreBridgeTest.java | 2 +- .../org/apache/atlas/hive/hook/HiveHookIT.java | 20 ++--- .../atlas/storm/hook/StormTopologyUtil.java | 10 +-- .../atlas/authorize/AtlasActionTypes.java | 2 +- .../apache/atlas/authorize/AtlasAuthorizer.java | 6 +- .../atlas/authorize/AtlasResourceTypes.java | 2 +- .../simple/AtlasAuthorizationUtils.java | 2 +- .../atlas/authorize/simple/FileReaderUtil.java | 2 +- .../atlas/authorize/simple/PolicyParser.java | 14 ++-- .../atlas/authorize/simple/PolicyUtil.java | 6 +- .../authorize/simple/SimpleAtlasAuthorizer.java | 26 +++--- .../authorize/simple/PolicyParserTest.java | 58 ++++++------- .../atlas/authorize/simple/PolicyUtilTest.java | 24 +++--- .../simple/SimpleAtlasAuthorizerTest.java | 24 +++--- .../atlas/catalog/BaseResourceProvider.java | 2 - .../apache/atlas/catalog/DefaultTypeSystem.java | 10 +-- .../apache/atlas/catalog/TermVertexWrapper.java | 4 - .../definition/TaxonomyResourceDefinition.java | 1 - .../atlas/catalog/query/QueryExpression.java | 2 +- .../catalog/EntityTagResourceProviderTest.java | 2 - .../java/org/apache/atlas/AtlasAdminClient.java | 4 +- .../atlas/security/SecureClientUtils.java | 7 +- .../java/org/apache/atlas/AtlasClientTest.java | 3 +- .../atlas/groovy/FunctionCallExpression.java | 2 +- .../security/InMemoryJAASConfiguration.java | 38 +++++---- .../apache/atlas/utils/AuthenticationUtil.java | 8 +- .../org/apache/atlas/utils/PropertiesUtil.java | 4 +- .../public/js/views/tag/addTagModalView.js | 4 +- .../repository/graphdb/AtlasGraphQuery.java | 2 +- .../repository/graphdb/AtlasIndexQuery.java | 2 +- .../titan/query/NativeTitanGraphQuery.java | 2 +- .../graphdb/titan/query/TitanGraphQuery.java | 2 +- .../graphdb/titan/query/expr/InPredicate.java | 4 +- .../graphdb/titan/query/expr/OrCondition.java | 4 +- .../titan/diskstorage/hbase/HBaseCompat.java | 4 +- .../diskstorage/hbase/HBaseCompatLoader.java | 6 +- .../hbase/HBaseKeyColumnValueStore.java | 9 +-- .../diskstorage/hbase/HBaseStoreManager.java | 85 ++++++++++---------- .../diskstorage/locking/LocalLockMediator.java | 24 +++--- .../titan/diskstorage/solr/Solr5Index.java | 68 +++++++--------- .../query/graph/GraphCentricQueryBuilder.java | 35 ++++---- .../repository/graphdb/titan0/Titan0Graph.java | 6 +- .../graphdb/titan0/Titan0GraphIndex.java | 2 +- .../repository/graphdb/titan0/Titan0Vertex.java | 2 +- .../titan0/query/NativeTitan0GraphQuery.java | 2 +- .../locking/LocalLockMediatorTest.java | 4 +- .../graphdb/titan0/GraphQueryTest.java | 2 +- .../graphdb/titan0/Titan0DatabaseTest.java | 26 ++---- .../org/apache/atlas/model/SearchFilter.java | 2 +- .../atlas/model/instance/AtlasEntity.java | 2 +- .../atlas/model/instance/AtlasEntityHeader.java | 1 - .../instance/AtlasEntityWithAssociations.java | 1 - .../atlas/model/instance/AtlasStruct.java | 8 +- .../model/instance/EntityMutationResponse.java | 3 +- .../atlas/model/instance/EntityMutations.java | 1 - .../atlas/model/typedef/AtlasBaseTypeDef.java | 13 ++- .../model/typedef/AtlasClassificationDef.java | 8 +- .../atlas/model/typedef/AtlasEntityDef.java | 8 +- .../atlas/model/typedef/AtlasEnumDef.java | 10 +-- .../atlas/model/typedef/AtlasStructDef.java | 18 ++--- .../org/apache/atlas/type/AtlasArrayType.java | 10 +-- .../apache/atlas/type/AtlasBuiltInTypes.java | 12 +-- .../atlas/type/AtlasClassificationType.java | 5 +- .../org/apache/atlas/type/AtlasEntityType.java | 5 +- .../org/apache/atlas/type/AtlasEnumType.java | 3 +- .../org/apache/atlas/type/AtlasMapType.java | 4 +- .../org/apache/atlas/type/AtlasStructType.java | 23 +++--- .../apache/atlas/type/AtlasTypeRegistry.java | 24 +++--- .../org/apache/atlas/type/AtlasTypeUtil.java | 4 +- .../test/java/org/apache/atlas/TestUtilsV2.java | 2 +- .../org/apache/atlas/model/ModelTestUtil.java | 32 ++++---- .../atlas/model/typedef/TestAtlasEntityDef.java | 2 +- .../atlas/model/typedef/TestAtlasEnumDef.java | 2 +- .../apache/atlas/type/TestAtlasArrayType.java | 14 ++-- .../atlas/type/TestAtlasBigDecimalType.java | 2 +- .../atlas/type/TestAtlasBigIntegerType.java | 2 +- .../apache/atlas/type/TestAtlasBooleanType.java | 2 +- .../apache/atlas/type/TestAtlasByteType.java | 2 +- .../atlas/type/TestAtlasClassificationType.java | 8 +- .../apache/atlas/type/TestAtlasDateType.java | 2 +- .../apache/atlas/type/TestAtlasDoubleType.java | 2 +- .../apache/atlas/type/TestAtlasEntityType.java | 8 +- .../apache/atlas/type/TestAtlasFloatType.java | 2 +- .../org/apache/atlas/type/TestAtlasIntType.java | 2 +- .../apache/atlas/type/TestAtlasLongType.java | 2 +- .../org/apache/atlas/type/TestAtlasMapType.java | 18 ++--- .../atlas/type/TestAtlasObjectIdType.java | 12 +-- .../apache/atlas/type/TestAtlasShortType.java | 2 +- .../apache/atlas/type/TestAtlasStringType.java | 2 +- .../apache/atlas/type/TestAtlasStructType.java | 8 +- .../apache/atlas/kafka/KafkaNotification.java | 2 +- .../classloader/AtlasPluginClassLoaderUtil.java | 2 +- release-log.txt | 1 + .../apache/atlas/RepositoryMetadataModule.java | 4 +- .../atlas/discovery/DataSetLineageService.java | 8 +- .../graph/GraphBackedDiscoveryService.java | 1 - .../gremlin/Gremlin2ExpressionFactory.java | 3 +- .../gremlin/Gremlin3ExpressionFactory.java | 3 +- .../repository/graph/AtlasGraphProvider.java | 4 +- .../atlas/repository/graph/DeleteHandler.java | 7 +- .../atlas/repository/graph/EntityProcessor.java | 2 +- .../graph/GraphBackedMetadataRepository.java | 2 - .../graph/GraphBackedSearchIndexer.java | 2 +- .../atlas/repository/graph/GraphHelper.java | 7 +- .../graph/GraphSchemaInitializer.java | 3 - .../graph/GraphToTypedInstanceMapper.java | 4 +- .../repository/memory/AttributeStores.java | 6 +- .../atlas/repository/memory/ClassStore.java | 10 +-- .../memory/HierarchicalTypeStore.java | 8 +- .../atlas/repository/memory/MemRepository.java | 10 +-- .../memory/ReplaceIdWithInstance.java | 40 +++++---- .../store/graph/AtlasEntityDefStore.java | 1 - .../store/graph/v1/AtlasEnumDefStoreV1.java | 1 - .../store/graph/v1/AtlasGraphUtilsV1.java | 2 +- .../graph/v1/AtlasTypeDefGraphStoreV1.java | 34 +++----- .../typestore/GraphBackedTypeStore.java | 4 +- .../atlas/services/DefaultMetadataService.java | 7 +- .../util/AtlasRepositoryConfiguration.java | 1 - .../org/apache/atlas/util/TypeDefSorter.java | 3 - .../GraphBackedDiscoveryServiceTest.java | 10 +-- .../audit/AuditRepositoryTestBase.java | 1 - .../repository/graph/GraphHelperMockTest.java | 10 +-- .../typestore/GraphBackedTypeStoreTest.java | 6 +- .../service/DefaultMetadataServiceTest.java | 4 +- .../persistence/ReferenceableInstance.java | 2 +- .../typesystem/persistence/StructInstance.java | 14 ++-- .../atlas/typesystem/types/AttributeInfo.java | 2 +- .../atlas/typesystem/types/ClassType.java | 2 +- .../atlas/typesystem/types/DataTypes.java | 14 ++-- .../typesystem/types/HierarchicalType.java | 42 ++++------ .../typesystem/types/ObjectGraphTraversal.java | 4 +- .../typesystem/types/ObjectGraphWalker.java | 4 +- .../atlas/typesystem/types/StructType.java | 6 +- .../typesystem/types/TypedStructHandler.java | 5 +- .../atlas/typesystem/types/cache/TypeCache.java | 4 +- .../typesystem/builders/InstanceBuilder.scala | 2 +- .../typesystem/builders/TypesBuilder.scala | 8 +- .../typesystem/json/InstanceSerialization.scala | 4 +- .../typesystem/json/SerializationJavaTest.java | 6 +- .../atlas/typesystem/types/StructTest.java | 2 - .../atlas/typesystem/types/TraitTest.java | 20 ++--- .../atlas/typesystem/types/TypeSystemTest.java | 10 +-- .../atlas/typesystem/types/ValidationTest.java | 3 - .../types/cache/DefaultTypeCacheTest.java | 2 +- .../java/org/apache/atlas/web/dao/UserDao.java | 6 +- .../atlas/web/filters/ActiveServerFilter.java | 8 +- .../web/filters/AtlasAuthenticationFilter.java | 10 +-- .../web/filters/AtlasAuthorizationFilter.java | 3 +- .../web/filters/AtlasCSRFPreventionFilter.java | 9 +-- .../atlas/web/resources/AdminResource.java | 7 +- .../atlas/web/rest/module/RestModule.java | 29 ------- .../AtlasAbstractAuthenticationProvider.java | 12 ++- .../atlas/web/service/CuratorFactory.java | 2 +- .../apache/atlas/web/service/UserService.java | 1 - .../org/apache/atlas/web/setup/SetupSteps.java | 2 +- .../org/apache/atlas/examples/QuickStartIT.java | 1 - .../NotificationHookConsumerKafkaTest.java | 4 +- .../web/filters/ActiveServerFilterTest.java | 2 - .../AtlasAuthenticationKerberosFilterTest.java | 10 +-- .../atlas/web/listeners/LoginProcessorIT.java | 1 - .../web/listeners/TestGuiceServletConfig.java | 1 - .../web/resources/EntityJerseyResourceIT.java | 2 +- .../web/resources/TaxonomyServiceTest.java | 1 - .../atlas/web/security/BaseSecurityTest.java | 1 - .../atlas/web/security/SSLAndKerberosTest.java | 12 +-- .../web/service/ActiveInstanceStateTest.java | 5 -- .../service/SecureEmbeddedServerTestBase.java | 5 +- 173 files changed, 619 insertions(+), 813 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/event/FalconEvent.java ---------------------------------------------------------------------- diff --git a/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/event/FalconEvent.java b/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/event/FalconEvent.java index 0b918ba..51db894 100644 --- a/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/event/FalconEvent.java +++ b/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/event/FalconEvent.java @@ -20,8 +20,6 @@ package org.apache.atlas.falcon.event; import org.apache.falcon.entity.v0.Entity; -import java.util.Date; - /** * Falcon event to interface with Atlas Service. */ http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/addons/falcon-bridge/src/test/java/org/apache/atlas/falcon/hook/FalconHookIT.java ---------------------------------------------------------------------- diff --git a/addons/falcon-bridge/src/test/java/org/apache/atlas/falcon/hook/FalconHookIT.java b/addons/falcon-bridge/src/test/java/org/apache/atlas/falcon/hook/FalconHookIT.java index 8d0a47a..2acc575 100644 --- a/addons/falcon-bridge/src/test/java/org/apache/atlas/falcon/hook/FalconHookIT.java +++ b/addons/falcon-bridge/src/test/java/org/apache/atlas/falcon/hook/FalconHookIT.java @@ -178,7 +178,7 @@ public class FalconHookIT { String inputId = ((List<Id>) processEntity.get("inputs")).get(0).getId()._getId(); Referenceable pathEntity = atlasClient.getEntity(inputId); - assertEquals(pathEntity.getTypeName(), HiveMetaStoreBridge.HDFS_PATH.toString()); + assertEquals(pathEntity.getTypeName(), HiveMetaStoreBridge.HDFS_PATH); List<Location> locations = FeedHelper.getLocations(feedCluster, feed); Location dataLocation = FileSystemStorage.getLocation(locations, LocationType.DATA); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/addons/hive-bridge/src/main/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java ---------------------------------------------------------------------- diff --git a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java index cbc51cc..0f8afd5 100755 --- a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java +++ b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java @@ -575,7 +575,7 @@ public class HiveMetaStoreBridge { } public Referenceable fillHDFSDataSet(String pathUri) { - Referenceable ref = new Referenceable(HDFS_PATH.toString()); + Referenceable ref = new Referenceable(HDFS_PATH); ref.set("path", pathUri); Path path = new Path(pathUri); ref.set(AtlasClient.NAME, Path.getPathWithoutSchemeAndAuthority(path).toString().toLowerCase()); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java ---------------------------------------------------------------------- diff --git a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java index cf8851c..143241f 100755 --- a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java +++ b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java @@ -37,12 +37,7 @@ import org.apache.hadoop.hive.metastore.TableType; import org.apache.hadoop.hive.metastore.api.Database; import org.apache.hadoop.hive.metastore.api.FieldSchema; import org.apache.hadoop.hive.ql.hooks.*; -import org.apache.hadoop.hive.ql.hooks.Entity; import org.apache.hadoop.hive.ql.hooks.Entity.Type; -import org.apache.hadoop.hive.ql.hooks.ExecuteWithHookContext; -import org.apache.hadoop.hive.ql.hooks.HookContext; -import org.apache.hadoop.hive.ql.hooks.ReadEntity; -import org.apache.hadoop.hive.ql.hooks.WriteEntity; import org.apache.hadoop.hive.ql.metadata.HiveException; import org.apache.hadoop.hive.ql.metadata.Partition; import org.apache.hadoop.hive.ql.metadata.Table; @@ -360,16 +355,16 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext { String changedColStringOldName = oldColList.get(0).getName(); String changedColStringNewName = changedColStringOldName; - for (int i = 0; i < oldColList.size(); i++) { - if (!newColHashMap.containsKey(oldColList.get(i))) { - changedColStringOldName = oldColList.get(i).getName(); + for (FieldSchema oldCol : oldColList) { + if (!newColHashMap.containsKey(oldCol)) { + changedColStringOldName = oldCol.getName(); break; } } - for (int i = 0; i < newColList.size(); i++) { - if (!oldColHashMap.containsKey(newColList.get(i))) { - changedColStringNewName = newColList.get(i).getName(); + for (FieldSchema newCol : newColList) { + if (!oldColHashMap.containsKey(newCol)) { + changedColStringNewName = newCol.getName(); break; } } @@ -395,7 +390,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext { if (writeEntity.getType() == Type.TABLE) { Table newTable = writeEntity.getTable(); createOrUpdateEntities(dgiBridge, event, writeEntity, true, oldTable); - final String newQualifiedTableName = dgiBridge.getTableQualifiedName(dgiBridge.getClusterName(), + final String newQualifiedTableName = HiveMetaStoreBridge.getTableQualifiedName(dgiBridge.getClusterName(), newTable); String oldColumnQFName = HiveMetaStoreBridge.getColumnQualifiedName(newQualifiedTableName, oldColName); String newColumnQFName = HiveMetaStoreBridge.getColumnQualifiedName(newQualifiedTableName, newColName); @@ -424,9 +419,9 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext { Table newTable = writeEntity.getTable(); //Hive sends with both old and new table names in the outputs which is weird. So skipping that with the below check if (!newTable.getDbName().equals(oldTable.getDbName()) || !newTable.getTableName().equals(oldTable.getTableName())) { - final String oldQualifiedName = dgiBridge.getTableQualifiedName(dgiBridge.getClusterName(), + final String oldQualifiedName = HiveMetaStoreBridge.getTableQualifiedName(dgiBridge.getClusterName(), oldTable); - final String newQualifiedName = dgiBridge.getTableQualifiedName(dgiBridge.getClusterName(), + final String newQualifiedName = HiveMetaStoreBridge.getTableQualifiedName(dgiBridge.getClusterName(), newTable); //Create/update old table entity - create entity with oldQFNme and old tableName if it doesnt exist. If exists, will update @@ -624,7 +619,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext { // filter out select queries which do not modify data if (!isSelectQuery) { - SortedSet<ReadEntity> sortedHiveInputs = new TreeSet<>(entityComparator);; + SortedSet<ReadEntity> sortedHiveInputs = new TreeSet<>(entityComparator); if ( event.getInputs() != null) { sortedHiveInputs.addAll(event.getInputs()); } @@ -671,7 +666,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext { private <T extends Entity> void processHiveEntity(HiveMetaStoreBridge dgiBridge, HiveEventContext event, T entity, Set<String> dataSetsProcessed, SortedMap<T, Referenceable> dataSets, Set<Referenceable> entities) throws Exception { if (entity.getType() == Type.TABLE || entity.getType() == Type.PARTITION) { - final String tblQFName = dgiBridge.getTableQualifiedName(dgiBridge.getClusterName(), entity.getTable()); + final String tblQFName = HiveMetaStoreBridge.getTableQualifiedName(dgiBridge.getClusterName(), entity.getTable()); if (!dataSetsProcessed.contains(tblQFName)) { LinkedHashMap<Type, Referenceable> result = createOrUpdateEntities(dgiBridge, event, entity, false); dataSets.put(entity, result.get(Type.TABLE)); @@ -754,14 +749,11 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext { } private static boolean isCreateOp(HiveEventContext hiveEvent) { - if (HiveOperation.CREATETABLE.equals(hiveEvent.getOperation()) - || HiveOperation.CREATEVIEW.equals(hiveEvent.getOperation()) - || HiveOperation.ALTERVIEW_AS.equals(hiveEvent.getOperation()) - || HiveOperation.ALTERTABLE_LOCATION.equals(hiveEvent.getOperation()) - || HiveOperation.CREATETABLE_AS_SELECT.equals(hiveEvent.getOperation())) { - return true; - } - return false; + return HiveOperation.CREATETABLE.equals(hiveEvent.getOperation()) + || HiveOperation.CREATEVIEW.equals(hiveEvent.getOperation()) + || HiveOperation.ALTERVIEW_AS.equals(hiveEvent.getOperation()) + || HiveOperation.ALTERTABLE_LOCATION.equals(hiveEvent.getOperation()) + || HiveOperation.CREATETABLE_AS_SELECT.equals(hiveEvent.getOperation()); } private Referenceable getProcessReferenceable(HiveMetaStoreBridge dgiBridge, HiveEventContext hiveEvent, @@ -973,8 +965,8 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext { } private static boolean addQueryType(HiveOperation op, WriteEntity entity) { - if (((WriteEntity) entity).getWriteType() != null && HiveOperation.QUERY.equals(op)) { - switch (((WriteEntity) entity).getWriteType()) { + if (entity.getWriteType() != null && HiveOperation.QUERY.equals(op)) { + switch (entity.getWriteType()) { case INSERT: case INSERT_OVERWRITE: case UPDATE: http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/addons/hive-bridge/src/main/java/org/apache/atlas/hive/rewrite/RewriteException.java ---------------------------------------------------------------------- diff --git a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/rewrite/RewriteException.java b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/rewrite/RewriteException.java index 79a1afe..c87bf6b 100644 --- a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/rewrite/RewriteException.java +++ b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/rewrite/RewriteException.java @@ -17,8 +17,6 @@ */ package org.apache.atlas.hive.rewrite; -import org.apache.hadoop.hive.ql.parse.ParseException; - public class RewriteException extends Exception { public RewriteException(final String message, final Exception exception) { super(message, exception); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/addons/hive-bridge/src/test/java/org/apache/atlas/hive/HiveITBase.java ---------------------------------------------------------------------- diff --git a/addons/hive-bridge/src/test/java/org/apache/atlas/hive/HiveITBase.java b/addons/hive-bridge/src/test/java/org/apache/atlas/hive/HiveITBase.java index 5abf2df..4b736a8 100644 --- a/addons/hive-bridge/src/test/java/org/apache/atlas/hive/HiveITBase.java +++ b/addons/hive-bridge/src/test/java/org/apache/atlas/hive/HiveITBase.java @@ -215,8 +215,8 @@ public class HiveITBase { protected void validateHDFSPaths(Referenceable processReference, String attributeName, String... testPaths) throws Exception { List<Id> hdfsPathRefs = (List<Id>) processReference.get(attributeName); - for (int i = 0; i < testPaths.length; i++) { - final Path path = new Path(testPaths[i]); + for (String testPath : testPaths) { + final Path path = new Path(testPath); final String testPathNormed = lower(path.toString()); String hdfsPathId = assertHDFSPathIsRegistered(testPathNormed); Assert.assertEquals(hdfsPathRefs.get(0)._getId(), hdfsPathId); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/addons/hive-bridge/src/test/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridgeTest.java ---------------------------------------------------------------------- diff --git a/addons/hive-bridge/src/test/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridgeTest.java b/addons/hive-bridge/src/test/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridgeTest.java index 0cba27e..0256cf3 100644 --- a/addons/hive-bridge/src/test/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridgeTest.java +++ b/addons/hive-bridge/src/test/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridgeTest.java @@ -208,7 +208,7 @@ public class HiveMetaStoreBridgeTest { when(atlasClient.getEntity("82e06b34-9151-4023-aa9d-b82103a50e77")).thenReturn(createTableReference()); String processQualifiedName = HiveMetaStoreBridge.getTableQualifiedName(CLUSTER_NAME, hiveTables.get(1)); when(atlasClient.getEntity(HiveDataTypes.HIVE_PROCESS.getName(), AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, - processQualifiedName)).thenReturn(getEntityReference(HiveDataTypes.HIVE_PROCESS.getName(), "82e06b34-9151-4023-aa9d-b82103a50e77"));; + processQualifiedName)).thenReturn(getEntityReference(HiveDataTypes.HIVE_PROCESS.getName(), "82e06b34-9151-4023-aa9d-b82103a50e77")); HiveMetaStoreBridge bridge = new HiveMetaStoreBridge(CLUSTER_NAME, hiveClient, atlasClient); try { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/addons/hive-bridge/src/test/java/org/apache/atlas/hive/hook/HiveHookIT.java ---------------------------------------------------------------------- diff --git a/addons/hive-bridge/src/test/java/org/apache/atlas/hive/hook/HiveHookIT.java b/addons/hive-bridge/src/test/java/org/apache/atlas/hive/hook/HiveHookIT.java index 23a13ea..e5bd65a 100755 --- a/addons/hive-bridge/src/test/java/org/apache/atlas/hive/hook/HiveHookIT.java +++ b/addons/hive-bridge/src/test/java/org/apache/atlas/hive/hook/HiveHookIT.java @@ -533,7 +533,7 @@ public class HiveHookIT extends HiveITBase { Referenceable processRef1 = validateProcess(event, expectedInputs, outputs); //Test sorting of tbl names - SortedSet<String> sortedTblNames = new TreeSet<String>(); + SortedSet<String> sortedTblNames = new TreeSet<>(); sortedTblNames.add(inputTable1Name.toLowerCase()); sortedTblNames.add(inputTable2Name.toLowerCase()); @@ -584,13 +584,13 @@ public class HiveHookIT extends HiveITBase { Set<ReadEntity> inputs = getInputs(tableName, Entity.Type.TABLE); final Set<WriteEntity> outputs = getOutputs(pFile1, Entity.Type.DFS_DIR); - ((WriteEntity)outputs.iterator().next()).setWriteType(WriteEntity.WriteType.PATH_WRITE); + outputs.iterator().next().setWriteType(WriteEntity.WriteType.PATH_WRITE); final HiveHook.HiveEventContext hiveEventContext = constructEvent(query, HiveOperation.QUERY, inputs, outputs); Referenceable processReference = validateProcess(hiveEventContext); validateHDFSPaths(processReference, OUTPUTS, pFile1); - String tableId = assertTableIsRegistered(DEFAULT_DB, tableName); + assertTableIsRegistered(DEFAULT_DB, tableName); validateInputTables(processReference, inputs); //Rerun same query with same HDFS path @@ -630,7 +630,7 @@ public class HiveHookIT extends HiveITBase { Set<ReadEntity> inputs = getInputs(tableName, Entity.Type.TABLE); final Set<WriteEntity> outputs = getOutputs(pFile1, Entity.Type.DFS_DIR); - ((WriteEntity)outputs.iterator().next()).setWriteType(WriteEntity.WriteType.PATH_WRITE); + outputs.iterator().next().setWriteType(WriteEntity.WriteType.PATH_WRITE); final Set<ReadEntity> partitionIps = new LinkedHashSet<>(inputs); partitionIps.addAll(getInputs(DEFAULT_DB + "@" + tableName + "@dt='" + PART_FILE + "'", Entity.Type.PARTITION)); @@ -646,7 +646,7 @@ public class HiveHookIT extends HiveITBase { runCommand(query); final Set<WriteEntity> pFile2Outputs = getOutputs(pFile2, Entity.Type.DFS_DIR); - ((WriteEntity)pFile2Outputs.iterator().next()).setWriteType(WriteEntity.WriteType.PATH_WRITE); + pFile2Outputs.iterator().next().setWriteType(WriteEntity.WriteType.PATH_WRITE); //Now the process has 2 paths - one older with deleted reference to partition and another with the the latest partition Set<WriteEntity> p2Outputs = new LinkedHashSet<WriteEntity>() {{ addAll(pFile2Outputs); @@ -676,7 +676,7 @@ public class HiveHookIT extends HiveITBase { Set<ReadEntity> inputs = getInputs(tableName, Entity.Type.TABLE); Set<WriteEntity> outputs = getOutputs(insertTableName, Entity.Type.TABLE); outputs.iterator().next().setName(getQualifiedTblName(insertTableName + HiveMetaStoreBridge.TEMP_TABLE_PREFIX + SessionState.get().getSessionId())); - ((WriteEntity)outputs.iterator().next()).setWriteType(WriteEntity.WriteType.INSERT); + outputs.iterator().next().setWriteType(WriteEntity.WriteType.INSERT); validateProcess(constructEvent(query, HiveOperation.QUERY, inputs, outputs)); @@ -696,7 +696,7 @@ public class HiveHookIT extends HiveITBase { final Set<ReadEntity> inputs = getInputs(tableName, Entity.Type.TABLE); final Set<WriteEntity> outputs = getOutputs(insertTableName, Entity.Type.TABLE); - ((WriteEntity)outputs.iterator().next()).setWriteType(WriteEntity.WriteType.INSERT); + outputs.iterator().next().setWriteType(WriteEntity.WriteType.INSERT); final Set<ReadEntity> partitionIps = new LinkedHashSet<ReadEntity>() { { @@ -1673,7 +1673,7 @@ public class HiveHookIT extends HiveITBase { private void verifyProperties(Struct referenceable, Map<String, String> expectedProps, boolean checkIfNotExists) { Map<String, String> parameters = (Map<String, String>) referenceable.get(HiveMetaStoreBridge.PARAMETERS); - if (checkIfNotExists == false) { + if (!checkIfNotExists) { //Check if properties exist Assert.assertNotNull(parameters); for (String propKey : expectedProps.keySet()) { @@ -1745,11 +1745,11 @@ public class HiveHookIT extends HiveITBase { } private String getDSTypeName(Entity entity) { - return Entity.Type.TABLE.equals(entity.getType()) ? HiveDataTypes.HIVE_TABLE.name() : HiveMetaStoreBridge.HDFS_PATH.toString(); + return Entity.Type.TABLE.equals(entity.getType()) ? HiveDataTypes.HIVE_TABLE.name() : HiveMetaStoreBridge.HDFS_PATH; } private <T extends Entity> SortedMap<T, Referenceable> getSortedProcessDataSets(Set<T> inputTbls) { - SortedMap<T, Referenceable> inputs = new TreeMap<T, Referenceable>(entityComparator); + SortedMap<T, Referenceable> inputs = new TreeMap<>(entityComparator); if (inputTbls != null) { for (final T tbl : inputTbls) { Referenceable inputTableRef = new Referenceable(getDSTypeName(tbl), new HashMap<String, Object>() {{ http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/addons/storm-bridge/src/main/java/org/apache/atlas/storm/hook/StormTopologyUtil.java ---------------------------------------------------------------------- diff --git a/addons/storm-bridge/src/main/java/org/apache/atlas/storm/hook/StormTopologyUtil.java b/addons/storm-bridge/src/main/java/org/apache/atlas/storm/hook/StormTopologyUtil.java index edd95ba..d646fba 100644 --- a/addons/storm-bridge/src/main/java/org/apache/atlas/storm/hook/StormTopologyUtil.java +++ b/addons/storm-bridge/src/main/java/org/apache/atlas/storm/hook/StormTopologyUtil.java @@ -18,6 +18,7 @@ package org.apache.atlas.storm.hook; +import org.apache.commons.lang.StringUtils; import org.apache.storm.generated.Bolt; import org.apache.storm.generated.GlobalStreamId; import org.apache.storm.generated.Grouping; @@ -82,8 +83,7 @@ public final class StormTopologyUtil { components.add(boltName); components = removeSystemComponent ? removeSystemComponents(components) : components; - if ((removeSystemComponent && !isSystemComponent(inputComponentId)) || - !removeSystemComponent) { + if (!removeSystemComponent || !isSystemComponent(inputComponentId)) { adjacencyMap.put(inputComponentId, components); } } @@ -132,7 +132,7 @@ public final class StormTopologyUtil { Set<Object> objectsToSkip) throws IllegalAccessException { if (objectsToSkip == null) { - objectsToSkip = new HashSet<Object>(); + objectsToSkip = new HashSet<>(); } Map<String, String> output = new HashMap<>(); @@ -175,9 +175,7 @@ public final class StormTopologyUtil { String keyStr = getString(mapKey, false, objectsToSkip); String valStr = getString(mapVal, false, objectsToSkip); - if ((valStr == null) || (valStr.isEmpty())) { - continue; - } else { + if (StringUtils.isNotEmpty(valStr)) { output.put(String.format("%s.%s", key, keyStr), valStr); } } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/authorization/src/main/java/org/apache/atlas/authorize/AtlasActionTypes.java ---------------------------------------------------------------------- diff --git a/authorization/src/main/java/org/apache/atlas/authorize/AtlasActionTypes.java b/authorization/src/main/java/org/apache/atlas/authorize/AtlasActionTypes.java index b42162f..c5969db 100644 --- a/authorization/src/main/java/org/apache/atlas/authorize/AtlasActionTypes.java +++ b/authorization/src/main/java/org/apache/atlas/authorize/AtlasActionTypes.java @@ -18,5 +18,5 @@ package org.apache.atlas.authorize; public enum AtlasActionTypes { - READ, CREATE, UPDATE, DELETE; + READ, CREATE, UPDATE, DELETE } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/authorization/src/main/java/org/apache/atlas/authorize/AtlasAuthorizer.java ---------------------------------------------------------------------- diff --git a/authorization/src/main/java/org/apache/atlas/authorize/AtlasAuthorizer.java b/authorization/src/main/java/org/apache/atlas/authorize/AtlasAuthorizer.java index 9c50a04..d64c692 100644 --- a/authorization/src/main/java/org/apache/atlas/authorize/AtlasAuthorizer.java +++ b/authorization/src/main/java/org/apache/atlas/authorize/AtlasAuthorizer.java @@ -25,18 +25,18 @@ public interface AtlasAuthorizer { /** * This method will load the policy file and would initialize the required data-structures. */ - public void init(); + void init(); /** * This method is responsible to perform the actual authorization for every REST API call. It will check if * user can perform action on resource. */ - public boolean isAccessAllowed(AtlasAccessRequest request) throws AtlasAuthorizationException; + boolean isAccessAllowed(AtlasAccessRequest request) throws AtlasAuthorizationException; /** * This method is responsible to perform the cleanup and release activities. It must be called when you are done * with the Authorization activity and once it's called a restart would be required. Try to invoke this while * destroying the context. */ - public void cleanUp(); + void cleanUp(); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/authorization/src/main/java/org/apache/atlas/authorize/AtlasResourceTypes.java ---------------------------------------------------------------------- diff --git a/authorization/src/main/java/org/apache/atlas/authorize/AtlasResourceTypes.java b/authorization/src/main/java/org/apache/atlas/authorize/AtlasResourceTypes.java index e34c740..deccf84 100644 --- a/authorization/src/main/java/org/apache/atlas/authorize/AtlasResourceTypes.java +++ b/authorization/src/main/java/org/apache/atlas/authorize/AtlasResourceTypes.java @@ -19,5 +19,5 @@ package org.apache.atlas.authorize; public enum AtlasResourceTypes { - UNKNOWN, ENTITY, TYPE, OPERATION, TAXONOMY, TERM; + UNKNOWN, ENTITY, TYPE, OPERATION, TAXONOMY, TERM } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/authorization/src/main/java/org/apache/atlas/authorize/simple/AtlasAuthorizationUtils.java ---------------------------------------------------------------------- diff --git a/authorization/src/main/java/org/apache/atlas/authorize/simple/AtlasAuthorizationUtils.java b/authorization/src/main/java/org/apache/atlas/authorize/simple/AtlasAuthorizationUtils.java index e48c5ae..2ef4ea2 100644 --- a/authorization/src/main/java/org/apache/atlas/authorize/simple/AtlasAuthorizationUtils.java +++ b/authorization/src/main/java/org/apache/atlas/authorize/simple/AtlasAuthorizationUtils.java @@ -103,7 +103,7 @@ public class AtlasAuthorizationUtils { * unprotected types are mapped with AtlasResourceTypes.UNKNOWN, access to these are allowed. */ public static Set<AtlasResourceTypes> getAtlasResourceType(String contextPath) { - Set<AtlasResourceTypes> resourceTypes = new HashSet<AtlasResourceTypes>(); + Set<AtlasResourceTypes> resourceTypes = new HashSet<>(); if (isDebugEnabled) { LOG.debug("==> getAtlasResourceType for " + contextPath); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/authorization/src/main/java/org/apache/atlas/authorize/simple/FileReaderUtil.java ---------------------------------------------------------------------- diff --git a/authorization/src/main/java/org/apache/atlas/authorize/simple/FileReaderUtil.java b/authorization/src/main/java/org/apache/atlas/authorize/simple/FileReaderUtil.java index 6836249..9d9caa9 100644 --- a/authorization/src/main/java/org/apache/atlas/authorize/simple/FileReaderUtil.java +++ b/authorization/src/main/java/org/apache/atlas/authorize/simple/FileReaderUtil.java @@ -36,7 +36,7 @@ public class FileReaderUtil { if (isDebugEnabled) { LOG.debug("==> FileReaderUtil readFile"); } - List<String> list = new ArrayList<String>(); + List<String> list = new ArrayList<>(); LOG.info("reading the file" + path); List<String> fileLines = Files.readAllLines(Paths.get(path), Charset.forName("UTF-8")); if (fileLines != null) { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/authorization/src/main/java/org/apache/atlas/authorize/simple/PolicyParser.java ---------------------------------------------------------------------- diff --git a/authorization/src/main/java/org/apache/atlas/authorize/simple/PolicyParser.java b/authorization/src/main/java/org/apache/atlas/authorize/simple/PolicyParser.java index 2a6929a..5740a1c 100644 --- a/authorization/src/main/java/org/apache/atlas/authorize/simple/PolicyParser.java +++ b/authorization/src/main/java/org/apache/atlas/authorize/simple/PolicyParser.java @@ -51,7 +51,7 @@ public class PolicyParser { if (isDebugEnabled) { LOG.debug("==> PolicyParser getListOfAutorities"); } - List<AtlasActionTypes> authorities = new ArrayList<AtlasActionTypes>(); + List<AtlasActionTypes> authorities = new ArrayList<>(); for (int i = 0; i < auth.length(); i++) { char access = auth.toLowerCase().charAt(i); @@ -86,7 +86,7 @@ public class PolicyParser { if (isDebugEnabled) { LOG.debug("==> PolicyParser parsePolicies"); } - List<PolicyDef> policyDefs = new ArrayList<PolicyDef>(); + List<PolicyDef> policyDefs = new ArrayList<>(); for (String policy : policies) { PolicyDef policyDef = parsePolicy(policy); if (policyDef != null) { @@ -129,7 +129,7 @@ public class PolicyParser { } boolean isValidEntity = Pattern.matches("(.+:.+)+", entity); boolean isEmpty = entity.isEmpty(); - if (isValidEntity == false || isEmpty == true) { + if (!isValidEntity || isEmpty) { if (isDebugEnabled) { LOG.debug("group/user/resource not properly define in Policy"); LOG.debug("<== PolicyParser validateEntity"); @@ -150,7 +150,7 @@ public class PolicyParser { } String[] users = usersDef.split(","); String[] userAndRole = null; - Map<String, List<AtlasActionTypes>> usersMap = new HashMap<String, List<AtlasActionTypes>>(); + Map<String, List<AtlasActionTypes>> usersMap = new HashMap<>(); if (validateEntity(usersDef)) { for (String user : users) { if (!Pattern.matches("(.+:.+)+", user)) { @@ -179,7 +179,7 @@ public class PolicyParser { } String[] groups = groupsDef.split("\\,"); String[] groupAndRole = null; - Map<String, List<AtlasActionTypes>> groupsMap = new HashMap<String, List<AtlasActionTypes>>(); + Map<String, List<AtlasActionTypes>> groupsMap = new HashMap<>(); if (validateEntity(groupsDef.trim())) { for (String group : groups) { if (!Pattern.matches("(.+:.+)+", group)) { @@ -209,7 +209,7 @@ public class PolicyParser { } String[] resources = resourceDef.split(","); String[] resourceTypeAndName = null; - Map<AtlasResourceTypes, List<String>> resourcesMap = new HashMap<AtlasResourceTypes, List<String>>(); + Map<AtlasResourceTypes, List<String>> resourcesMap = new HashMap<>(); if (validateEntity(resourceDef)) { for (String resource : resources) { if (!Pattern.matches("(.+:.+)+", resource)) { @@ -238,7 +238,7 @@ public class PolicyParser { List<String> resourceList = resourcesMap.get(resourceType); if (resourceList == null) { - resourceList = new ArrayList<String>(); + resourceList = new ArrayList<>(); } resourceList.add(resourceTypeAndName[RESOURCE_NAME]); resourcesMap.put(resourceType, resourceList); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/authorization/src/main/java/org/apache/atlas/authorize/simple/PolicyUtil.java ---------------------------------------------------------------------- diff --git a/authorization/src/main/java/org/apache/atlas/authorize/simple/PolicyUtil.java b/authorization/src/main/java/org/apache/atlas/authorize/simple/PolicyUtil.java index 9508eb3..8a3850f 100644 --- a/authorization/src/main/java/org/apache/atlas/authorize/simple/PolicyUtil.java +++ b/authorization/src/main/java/org/apache/atlas/authorize/simple/PolicyUtil.java @@ -40,7 +40,7 @@ public class PolicyUtil { + " & " + principalType); } Map<String, Map<AtlasResourceTypes, List<String>>> userReadMap = - new HashMap<String, Map<AtlasResourceTypes, List<String>>>(); + new HashMap<>(); // Iterate over the list of policies to create map for (PolicyDef policyDef : policyDefList) { @@ -63,7 +63,7 @@ public class PolicyUtil { if (isDebugEnabled) { LOG.debug("Resource list not found for " + username + ", creating it"); } - userResourceList = new HashMap<AtlasResourceTypes, List<String>>(); + userResourceList = new HashMap<>(); } /* * Iterate over resources from the current policy def and update the resource list for the current user @@ -77,7 +77,7 @@ public class PolicyUtil { if (resourceList == null) { // if the resource list was not added for this type then // create and add all the resources in this policy - resourceList = new ArrayList<String>(); + resourceList = new ArrayList<>(); resourceList.addAll(resourceTypeMap.getValue()); } else { // if the resource list is present then merge both the http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/authorization/src/main/java/org/apache/atlas/authorize/simple/SimpleAtlasAuthorizer.java ---------------------------------------------------------------------- diff --git a/authorization/src/main/java/org/apache/atlas/authorize/simple/SimpleAtlasAuthorizer.java b/authorization/src/main/java/org/apache/atlas/authorize/simple/SimpleAtlasAuthorizer.java index 57156b7..5956f5c 100644 --- a/authorization/src/main/java/org/apache/atlas/authorize/simple/SimpleAtlasAuthorizer.java +++ b/authorization/src/main/java/org/apache/atlas/authorize/simple/SimpleAtlasAuthorizer.java @@ -45,7 +45,7 @@ import com.google.common.annotations.VisibleForTesting; public final class SimpleAtlasAuthorizer implements AtlasAuthorizer { public enum AtlasAccessorTypes { - USER, GROUP; + USER, GROUP } private static final Logger LOG = LoggerFactory.getLogger(SimpleAtlasAuthorizer.class); @@ -133,8 +133,8 @@ public final class SimpleAtlasAuthorizer implements AtlasAuthorizer { + "\nResource :: " + resource); boolean isAccessAllowed = false; - boolean isUser = user == null ? false : true; - boolean isGroup = groups == null ? false : true; + boolean isUser = user != null; + boolean isGroup = groups != null; if ((!isUser && !isGroup) || action == null || resource == null) { if (isDebugEnabled) { @@ -149,26 +149,22 @@ public final class SimpleAtlasAuthorizer implements AtlasAuthorizer { case READ: isAccessAllowed = checkAccess(user, resourceTypes, resource, userReadMap); isAccessAllowed = - isAccessAllowed == false ? checkAccessForGroups(groups, resourceTypes, resource, groupReadMap) - : isAccessAllowed; + isAccessAllowed || checkAccessForGroups(groups, resourceTypes, resource, groupReadMap); break; case CREATE: isAccessAllowed = checkAccess(user, resourceTypes, resource, userWriteMap); isAccessAllowed = - isAccessAllowed == false ? checkAccessForGroups(groups, resourceTypes, resource, groupWriteMap) - : isAccessAllowed; + isAccessAllowed || checkAccessForGroups(groups, resourceTypes, resource, groupWriteMap); break; case UPDATE: isAccessAllowed = checkAccess(user, resourceTypes, resource, userUpdateMap); isAccessAllowed = - isAccessAllowed == false - ? checkAccessForGroups(groups, resourceTypes, resource, groupUpdateMap) : isAccessAllowed; + isAccessAllowed || checkAccessForGroups(groups, resourceTypes, resource, groupUpdateMap); break; case DELETE: isAccessAllowed = checkAccess(user, resourceTypes, resource, userDeleteMap); isAccessAllowed = - isAccessAllowed == false - ? checkAccessForGroups(groups, resourceTypes, resource, groupDeleteMap) : isAccessAllowed; + isAccessAllowed || checkAccessForGroups(groups, resourceTypes, resource, groupDeleteMap); break; default: if (isDebugEnabled) { @@ -249,7 +245,7 @@ public final class SimpleAtlasAuthorizer implements AtlasAuthorizer { boolean optWildCard = true; - List<String> policyValues = new ArrayList<String>(); + List<String> policyValues = new ArrayList<>(); if (policyResource != null) { boolean isWildCardPresent = !optWildCard; @@ -302,8 +298,7 @@ public final class SimpleAtlasAuthorizer implements AtlasAuthorizer { } } - if (isMatch == false) { - + if (!isMatch) { if (isDebugEnabled) { StringBuilder sb = new StringBuilder(); sb.append("["); @@ -327,8 +322,7 @@ public final class SimpleAtlasAuthorizer implements AtlasAuthorizer { } private boolean isAllValuesRequested(String resource) { - boolean result = StringUtils.isEmpty(resource) || WILDCARD_ASTERISK.equals(resource); - return result; + return StringUtils.isEmpty(resource) || WILDCARD_ASTERISK.equals(resource); } @Override http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/authorization/src/test/java/org/apache/atlas/authorize/simple/PolicyParserTest.java ---------------------------------------------------------------------- diff --git a/authorization/src/test/java/org/apache/atlas/authorize/simple/PolicyParserTest.java b/authorization/src/test/java/org/apache/atlas/authorize/simple/PolicyParserTest.java index 453364d..3b7869a 100644 --- a/authorization/src/test/java/org/apache/atlas/authorize/simple/PolicyParserTest.java +++ b/authorization/src/test/java/org/apache/atlas/authorize/simple/PolicyParserTest.java @@ -33,42 +33,42 @@ public class PolicyParserTest { @Test public void testParsePoliciesWithAllProperties() { - List<String> policies = new ArrayList<String>(); + List<String> policies = new ArrayList<>(); policies.add("hivePolicy;;usr1:r,usr2:rw;;grp1:rwu,grp2:u;;entity:*abc,operation:*xyz,type:PII"); /* Creating group data */ - Map<String, List<AtlasActionTypes>> groupMap = new HashMap<String, List<AtlasActionTypes>>(); - List<AtlasActionTypes> accessList1 = new ArrayList<AtlasActionTypes>(); + Map<String, List<AtlasActionTypes>> groupMap = new HashMap<>(); + List<AtlasActionTypes> accessList1 = new ArrayList<>(); accessList1.add(AtlasActionTypes.READ); accessList1.add(AtlasActionTypes.CREATE); accessList1.add(AtlasActionTypes.UPDATE); groupMap.put("grp1", accessList1); - List<AtlasActionTypes> accessList2 = new ArrayList<AtlasActionTypes>(); + List<AtlasActionTypes> accessList2 = new ArrayList<>(); accessList2.add(AtlasActionTypes.UPDATE); groupMap.put("grp2", accessList2); /* Creating user data */ - Map<String, List<AtlasActionTypes>> usersMap = new HashMap<String, List<AtlasActionTypes>>(); - List<AtlasActionTypes> usr1AccessList = new ArrayList<AtlasActionTypes>(); + Map<String, List<AtlasActionTypes>> usersMap = new HashMap<>(); + List<AtlasActionTypes> usr1AccessList = new ArrayList<>(); usr1AccessList.add(AtlasActionTypes.READ); usersMap.put("usr1", usr1AccessList); - List<AtlasActionTypes> usr2AccessList = new ArrayList<AtlasActionTypes>(); + List<AtlasActionTypes> usr2AccessList = new ArrayList<>(); usr2AccessList.add(AtlasActionTypes.READ); usr2AccessList.add(AtlasActionTypes.CREATE); usersMap.put("usr2", usr2AccessList); /* Creating resources data */ - Map<AtlasResourceTypes, List<String>> resourceMap = new HashMap<AtlasResourceTypes, List<String>>(); - List<String> resource1List = new ArrayList<String>(); + Map<AtlasResourceTypes, List<String>> resourceMap = new HashMap<>(); + List<String> resource1List = new ArrayList<>(); resource1List.add("*abc"); resourceMap.put(AtlasResourceTypes.ENTITY, resource1List); - List<String> resource2List = new ArrayList<String>(); + List<String> resource2List = new ArrayList<>(); resource2List.add("*xyz"); resourceMap.put(AtlasResourceTypes.OPERATION, resource2List); - List<String> resource3List = new ArrayList<String>(); + List<String> resource3List = new ArrayList<>(); resource3List.add("PII"); resourceMap.put(AtlasResourceTypes.TYPE, resource3List); @@ -86,34 +86,34 @@ public class PolicyParserTest { @Test public void testParsePoliciesWithOutUserProperties() { - List<String> policies = new ArrayList<String>(); + List<String> policies = new ArrayList<>(); policies.add("hivePolicy;;;;grp1:rwu,grp2:u;;entity:*abc,operation:*xyz,type:PII"); // Creating group data - Map<String, List<AtlasActionTypes>> groupMap = new HashMap<String, List<AtlasActionTypes>>(); - List<AtlasActionTypes> accessList1 = new ArrayList<AtlasActionTypes>(); + Map<String, List<AtlasActionTypes>> groupMap = new HashMap<>(); + List<AtlasActionTypes> accessList1 = new ArrayList<>(); accessList1.add(AtlasActionTypes.READ); accessList1.add(AtlasActionTypes.CREATE); accessList1.add(AtlasActionTypes.UPDATE); groupMap.put("grp1", accessList1); - List<AtlasActionTypes> accessList2 = new ArrayList<AtlasActionTypes>(); + List<AtlasActionTypes> accessList2 = new ArrayList<>(); accessList2.add(AtlasActionTypes.UPDATE); groupMap.put("grp2", accessList2); // Creating user data - Map<String, List<AtlasActionTypes>> usersMap = new HashMap<String, List<AtlasActionTypes>>(); + Map<String, List<AtlasActionTypes>> usersMap = new HashMap<>(); // Creating resources data - Map<AtlasResourceTypes, List<String>> resourceMap = new HashMap<AtlasResourceTypes, List<String>>(); - List<String> resource1List = new ArrayList<String>(); + Map<AtlasResourceTypes, List<String>> resourceMap = new HashMap<>(); + List<String> resource1List = new ArrayList<>(); resource1List.add("*abc"); resourceMap.put(AtlasResourceTypes.ENTITY, resource1List); - List<String> resource2List = new ArrayList<String>(); + List<String> resource2List = new ArrayList<>(); resource2List.add("*xyz"); resourceMap.put(AtlasResourceTypes.OPERATION, resource2List); - List<String> resource3List = new ArrayList<String>(); + List<String> resource3List = new ArrayList<>(); resource3List.add("PII"); resourceMap.put(AtlasResourceTypes.TYPE, resource3List); @@ -131,33 +131,33 @@ public class PolicyParserTest { @Test public void testParsePoliciesWithOutGroupProperties() { - List<String> policies = new ArrayList<String>(); + List<String> policies = new ArrayList<>(); policies.add("hivePolicy;;usr1:r,usr2:rw;;;;entity:*abc,operation:*xyz,type:PII"); // Creating group data - Map<String, List<AtlasActionTypes>> groupMap = new HashMap<String, List<AtlasActionTypes>>(); + Map<String, List<AtlasActionTypes>> groupMap = new HashMap<>(); // Creating user data - Map<String, List<AtlasActionTypes>> usersMap = new HashMap<String, List<AtlasActionTypes>>(); - List<AtlasActionTypes> usr1AccessList = new ArrayList<AtlasActionTypes>(); + Map<String, List<AtlasActionTypes>> usersMap = new HashMap<>(); + List<AtlasActionTypes> usr1AccessList = new ArrayList<>(); usr1AccessList.add(AtlasActionTypes.READ); usersMap.put("usr1", usr1AccessList); - List<AtlasActionTypes> usr2AccessList = new ArrayList<AtlasActionTypes>(); + List<AtlasActionTypes> usr2AccessList = new ArrayList<>(); usr2AccessList.add(AtlasActionTypes.READ); usr2AccessList.add(AtlasActionTypes.CREATE); usersMap.put("usr2", usr2AccessList); // Creating resources data - Map<AtlasResourceTypes, List<String>> resourceMap = new HashMap<AtlasResourceTypes, List<String>>(); - List<String> resource1List = new ArrayList<String>(); + Map<AtlasResourceTypes, List<String>> resourceMap = new HashMap<>(); + List<String> resource1List = new ArrayList<>(); resource1List.add("*abc"); resourceMap.put(AtlasResourceTypes.ENTITY, resource1List); - List<String> resource2List = new ArrayList<String>(); + List<String> resource2List = new ArrayList<>(); resource2List.add("*xyz"); resourceMap.put(AtlasResourceTypes.OPERATION, resource2List); - List<String> resource3List = new ArrayList<String>(); + List<String> resource3List = new ArrayList<>(); resource3List.add("PII"); resourceMap.put(AtlasResourceTypes.TYPE, resource3List); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/authorization/src/test/java/org/apache/atlas/authorize/simple/PolicyUtilTest.java ---------------------------------------------------------------------- diff --git a/authorization/src/test/java/org/apache/atlas/authorize/simple/PolicyUtilTest.java b/authorization/src/test/java/org/apache/atlas/authorize/simple/PolicyUtilTest.java index 3453bf0..1cefbcd 100644 --- a/authorization/src/test/java/org/apache/atlas/authorize/simple/PolicyUtilTest.java +++ b/authorization/src/test/java/org/apache/atlas/authorize/simple/PolicyUtilTest.java @@ -35,24 +35,24 @@ public class PolicyUtilTest { @Test public void testCreatePermissionMap() { - HashMap<AtlasResourceTypes, List<String>> resourceMap = new HashMap<AtlasResourceTypes, List<String>>(); - List<String> resource1List = new ArrayList<String>(); + HashMap<AtlasResourceTypes, List<String>> resourceMap = new HashMap<>(); + List<String> resource1List = new ArrayList<>(); resource1List.add("*abc"); resourceMap.put(AtlasResourceTypes.ENTITY, resource1List); - List<String> resource2List = new ArrayList<String>(); + List<String> resource2List = new ArrayList<>(); resource2List.add("*xyz"); resourceMap.put(AtlasResourceTypes.OPERATION, resource2List); - List<String> resource3List = new ArrayList<String>(); + List<String> resource3List = new ArrayList<>(); resource3List.add("PII"); resourceMap.put(AtlasResourceTypes.TYPE, resource3List); Map<String, HashMap<AtlasResourceTypes, List<String>>> permissionMap = - new HashMap<String, HashMap<AtlasResourceTypes, List<String>>>(); + new HashMap<>(); permissionMap.put("grp1", resourceMap); - List<String> policies = new ArrayList<String>(); + List<String> policies = new ArrayList<>(); policies.add("hivePolicy;;usr1:r,usr2:rw;;grp1:rwu,grp2:u;;entity:*abc,operation:*xyz,type:PII"); List<PolicyDef> policyDefList = new PolicyParser().parsePolicies(policies); @@ -66,25 +66,25 @@ public class PolicyUtilTest { @Test public void testMergeCreatePermissionMap() { - HashMap<AtlasResourceTypes, List<String>> resourceMap = new HashMap<AtlasResourceTypes, List<String>>(); - List<String> resource1List = new ArrayList<String>(); + HashMap<AtlasResourceTypes, List<String>> resourceMap = new HashMap<>(); + List<String> resource1List = new ArrayList<>(); resource1List.add("*abc"); resourceMap.put(AtlasResourceTypes.ENTITY, resource1List); - List<String> resource2List = new ArrayList<String>(); + List<String> resource2List = new ArrayList<>(); resource2List.add("*x"); resource2List.add("*xyz"); resourceMap.put(AtlasResourceTypes.OPERATION, resource2List); - List<String> resource3List = new ArrayList<String>(); + List<String> resource3List = new ArrayList<>(); resource3List.add("PII"); resourceMap.put(AtlasResourceTypes.TYPE, resource3List); Map<String, HashMap<AtlasResourceTypes, List<String>>> permissionMap = - new HashMap<String, HashMap<AtlasResourceTypes, List<String>>>(); + new HashMap<>(); permissionMap.put("grp1", resourceMap); - List<String> policies = new ArrayList<String>(); + List<String> policies = new ArrayList<>(); policies.add("hivePolicys;;;;grp1:rwu;;entity:*abc,operation:*xyz,operation:*x"); policies.add("hivePolicy;;;;grp1:rwu;;entity:*abc,operation:*xyz"); policies.add("hivePolicy;;usr1:r,usr2:rw;;grp1:rwu;;entity:*abc,operation:*xyz"); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/authorization/src/test/java/org/apache/atlas/authorize/simple/SimpleAtlasAuthorizerTest.java ---------------------------------------------------------------------- diff --git a/authorization/src/test/java/org/apache/atlas/authorize/simple/SimpleAtlasAuthorizerTest.java b/authorization/src/test/java/org/apache/atlas/authorize/simple/SimpleAtlasAuthorizerTest.java index 8b27e2e..a3fc489 100644 --- a/authorization/src/test/java/org/apache/atlas/authorize/simple/SimpleAtlasAuthorizerTest.java +++ b/authorization/src/test/java/org/apache/atlas/authorize/simple/SimpleAtlasAuthorizerTest.java @@ -38,7 +38,7 @@ public class SimpleAtlasAuthorizerTest { Map<String, Map<AtlasResourceTypes, List<String>>> userReadMap = null; Map<String, Map<AtlasResourceTypes, List<String>>> groupReadMap = null; - List<String> policies = new ArrayList<String>(); + List<String> policies = new ArrayList<>(); policies.add("hivePolicy;;usr1:r,usr2:rw;;grp1:rwu,grp2:u;;type:*abc,type:PII"); List<PolicyDef> policyDefs = new PolicyParser().parsePolicies(policies); @@ -50,13 +50,13 @@ public class SimpleAtlasAuthorizerTest { userReadMap = policyUtil.createPermissionMap(policyDefs, AtlasActionTypes.READ, SimpleAtlasAuthorizer.AtlasAccessorTypes.USER); - Set<AtlasResourceTypes> resourceType = new HashSet<AtlasResourceTypes>(); + Set<AtlasResourceTypes> resourceType = new HashSet<>(); resourceType.add(AtlasResourceTypes.TYPE); String resource = "xsdfhjabc"; AtlasActionTypes action = AtlasActionTypes.READ; String user = "usr1"; - Set<String> userGroups = new HashSet<String>(); + Set<String> userGroups = new HashSet<>(); userGroups.add("grp3"); try { AtlasAccessRequest request = new AtlasAccessRequest(resourceType, @@ -83,7 +83,7 @@ public class SimpleAtlasAuthorizerTest { Map<String, Map<AtlasResourceTypes, List<String>>> userReadMap = null; Map<String, Map<AtlasResourceTypes, List<String>>> groupReadMap = null; - List<String> policies = new ArrayList<String>(); + List<String> policies = new ArrayList<>(); policies.add("hivePolicy;;usr1:r,usr2:rw;;grp1:rwu,grp2:u;;type:PII"); List<PolicyDef> policyDefs = new PolicyParser().parsePolicies(policies); @@ -95,12 +95,12 @@ public class SimpleAtlasAuthorizerTest { userReadMap = policyUtil.createPermissionMap(policyDefs, AtlasActionTypes.READ, SimpleAtlasAuthorizer.AtlasAccessorTypes.USER); - Set<AtlasResourceTypes> resourceType = new HashSet<AtlasResourceTypes>(); + Set<AtlasResourceTypes> resourceType = new HashSet<>(); resourceType.add(AtlasResourceTypes.TYPE); String resource = "PII"; AtlasActionTypes action = AtlasActionTypes.READ; String user = "usr3"; - Set<String> userGroups = new HashSet<String>(); + Set<String> userGroups = new HashSet<>(); userGroups.add("grp1"); AtlasAccessRequest request = new AtlasAccessRequest(resourceType, resource, action, user, userGroups); @@ -126,7 +126,7 @@ public class SimpleAtlasAuthorizerTest { Map<String, Map<AtlasResourceTypes, List<String>>> userReadMap = null; Map<String, Map<AtlasResourceTypes, List<String>>> groupReadMap = null; - List<String> policies = new ArrayList<String>(); + List<String> policies = new ArrayList<>(); policies.add("hivePolicy;;usr1:r,usr2:rw;;grp1:rwu,grp2:u;;type:PII"); List<PolicyDef> policyDefs = new PolicyParser().parsePolicies(policies); @@ -138,12 +138,12 @@ public class SimpleAtlasAuthorizerTest { userReadMap = policyUtil.createPermissionMap(policyDefs, AtlasActionTypes.READ, SimpleAtlasAuthorizer.AtlasAccessorTypes.USER); - Set<AtlasResourceTypes> resourceType = new HashSet<AtlasResourceTypes>(); + Set<AtlasResourceTypes> resourceType = new HashSet<>(); resourceType.add(AtlasResourceTypes.TYPE); String resource = "abc"; AtlasActionTypes action = AtlasActionTypes.READ; String user = "usr1"; - Set<String> userGroups = new HashSet<String>(); + Set<String> userGroups = new HashSet<>(); userGroups.add("grp1"); AtlasAccessRequest request = new AtlasAccessRequest(resourceType, resource, action, user, userGroups); @@ -168,7 +168,7 @@ public class SimpleAtlasAuthorizerTest { Map<String, Map<AtlasResourceTypes, List<String>>> userReadMap = null; Map<String, Map<AtlasResourceTypes, List<String>>> groupReadMap = null; - List<String> policies = new ArrayList<String>(); + List<String> policies = new ArrayList<>(); policies.add("hivePolicy;;usr1:r,usr2:rw;;grp1:rwu,grp2:u;;type:PII"); List<PolicyDef> policyDefs = new PolicyParser().parsePolicies(policies); @@ -180,12 +180,12 @@ public class SimpleAtlasAuthorizerTest { userReadMap = policyUtil.createPermissionMap(policyDefs, AtlasActionTypes.READ, SimpleAtlasAuthorizer.AtlasAccessorTypes.USER); - Set<AtlasResourceTypes> resourceType = new HashSet<AtlasResourceTypes>(); + Set<AtlasResourceTypes> resourceType = new HashSet<>(); resourceType.add(AtlasResourceTypes.TYPE); String resource = "PII"; AtlasActionTypes action = AtlasActionTypes.READ; String user = "usr3"; - Set<String> userGroups = new HashSet<String>(); + Set<String> userGroups = new HashSet<>(); userGroups.add("grp3"); AtlasAccessRequest request = new AtlasAccessRequest(resourceType, resource, action, user, userGroups); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/catalog/src/main/java/org/apache/atlas/catalog/BaseResourceProvider.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/atlas/catalog/BaseResourceProvider.java b/catalog/src/main/java/org/apache/atlas/catalog/BaseResourceProvider.java index ee9fbba..feb9d72 100644 --- a/catalog/src/main/java/org/apache/atlas/catalog/BaseResourceProvider.java +++ b/catalog/src/main/java/org/apache/atlas/catalog/BaseResourceProvider.java @@ -23,8 +23,6 @@ import org.apache.atlas.catalog.exception.InvalidPayloadException; import org.apache.atlas.catalog.exception.ResourceNotFoundException; import org.apache.atlas.catalog.query.QueryFactory; -import java.util.Collections; - /** * Base class for resource providers. */ http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/catalog/src/main/java/org/apache/atlas/catalog/DefaultTypeSystem.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/atlas/catalog/DefaultTypeSystem.java b/catalog/src/main/java/org/apache/atlas/catalog/DefaultTypeSystem.java index f111eb6..726351a 100644 --- a/catalog/src/main/java/org/apache/atlas/catalog/DefaultTypeSystem.java +++ b/catalog/src/main/java/org/apache/atlas/catalog/DefaultTypeSystem.java @@ -85,7 +85,7 @@ public class DefaultTypeSystem implements AtlasTypeSystem { } catch(TypeNotFoundException tne) { //Type not found . Create TypesDef typesDef = TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(), - ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(type), + ImmutableList.of(type), ImmutableList.<HierarchicalTypeDefinition<ClassType>>of()); metadataService.createType(TypesSerialization.toJson(typesDef)); } @@ -198,11 +198,11 @@ public class DefaultTypeSystem implements AtlasTypeSystem { try { HierarchicalTypeDefinition<T> definition = null; if ( isTrait) { - definition = new HierarchicalTypeDefinition<T>(type, name, description, - ImmutableSet.<String>of(TaxonomyResourceProvider.TAXONOMY_TERM_TYPE), attributes.toArray(new AttributeDefinition[attributes.size()])); + definition = new HierarchicalTypeDefinition<>(type, name, description, + ImmutableSet.of(TaxonomyResourceProvider.TAXONOMY_TERM_TYPE), attributes.toArray(new AttributeDefinition[attributes.size()])); } else { - definition = new HierarchicalTypeDefinition<T>(type, name, description, - ImmutableSet.<String>of(), attributes.toArray(new AttributeDefinition[attributes.size()])); + definition = new HierarchicalTypeDefinition<>(type, name, description, + ImmutableSet.<String>of(), attributes.toArray(new AttributeDefinition[attributes.size()])); } metadataService.createType(TypesSerialization.toJson(definition, isTrait)); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/catalog/src/main/java/org/apache/atlas/catalog/TermVertexWrapper.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/atlas/catalog/TermVertexWrapper.java b/catalog/src/main/java/org/apache/atlas/catalog/TermVertexWrapper.java index d60e3f3..14fcca7 100644 --- a/catalog/src/main/java/org/apache/atlas/catalog/TermVertexWrapper.java +++ b/catalog/src/main/java/org/apache/atlas/catalog/TermVertexWrapper.java @@ -20,10 +20,6 @@ package org.apache.atlas.catalog; import com.tinkerpop.blueprints.Vertex; import org.apache.atlas.catalog.definition.EntityTagResourceDefinition; -import org.apache.atlas.catalog.definition.ResourceDefinition; -import org.apache.atlas.repository.Constants; - -import java.util.Collections; /** * Wrapper for term vertices. http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/catalog/src/main/java/org/apache/atlas/catalog/definition/TaxonomyResourceDefinition.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/atlas/catalog/definition/TaxonomyResourceDefinition.java b/catalog/src/main/java/org/apache/atlas/catalog/definition/TaxonomyResourceDefinition.java index 47d182c..434a189 100644 --- a/catalog/src/main/java/org/apache/atlas/catalog/definition/TaxonomyResourceDefinition.java +++ b/catalog/src/main/java/org/apache/atlas/catalog/definition/TaxonomyResourceDefinition.java @@ -20,7 +20,6 @@ package org.apache.atlas.catalog.definition; import com.tinkerpop.pipes.PipeFunction; import com.tinkerpop.pipes.transform.TransformFunctionPipe; -import org.apache.atlas.AtlasConstants; import org.apache.atlas.catalog.Request; import org.apache.atlas.catalog.TaxonomyResourceProvider; import org.apache.atlas.catalog.VertexWrapper; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/catalog/src/main/java/org/apache/atlas/catalog/query/QueryExpression.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/atlas/catalog/query/QueryExpression.java b/catalog/src/main/java/org/apache/atlas/catalog/query/QueryExpression.java index 78436c0..c53b94b 100644 --- a/catalog/src/main/java/org/apache/atlas/catalog/query/QueryExpression.java +++ b/catalog/src/main/java/org/apache/atlas/catalog/query/QueryExpression.java @@ -88,7 +88,7 @@ public interface QueryExpression { * * @param fieldName field name */ - public void setField(String fieldName); + void setField(String fieldName); /** * Get the expected value for the expression. http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/catalog/src/test/java/org/apache/atlas/catalog/EntityTagResourceProviderTest.java ---------------------------------------------------------------------- diff --git a/catalog/src/test/java/org/apache/atlas/catalog/EntityTagResourceProviderTest.java b/catalog/src/test/java/org/apache/atlas/catalog/EntityTagResourceProviderTest.java index 510378e..96cb523 100644 --- a/catalog/src/test/java/org/apache/atlas/catalog/EntityTagResourceProviderTest.java +++ b/catalog/src/test/java/org/apache/atlas/catalog/EntityTagResourceProviderTest.java @@ -30,8 +30,6 @@ import org.testng.annotations.Test; import java.util.*; import static org.easymock.EasyMock.*; -import static org.easymock.EasyMock.createStrictMock; -import static org.easymock.EasyMock.replay; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/client/src/main/java/org/apache/atlas/AtlasAdminClient.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/atlas/AtlasAdminClient.java b/client/src/main/java/org/apache/atlas/AtlasAdminClient.java index 63e9213..19f9575 100644 --- a/client/src/main/java/org/apache/atlas/AtlasAdminClient.java +++ b/client/src/main/java/org/apache/atlas/AtlasAdminClient.java @@ -28,6 +28,8 @@ import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.apache.commons.configuration.Configuration; +import java.util.Arrays; + /** * An application that allows users to run admin commands against an Atlas server. @@ -83,7 +85,7 @@ public class AtlasAdminClient { System.out.println(atlasClient.getAdminStatus()); cmdStatus = 0; } catch (AtlasServiceException e) { - System.err.println("Could not retrieve status of the server at " + atlasServerUri); + System.err.println("Could not retrieve status of the server at " + Arrays.toString(atlasServerUri)); printStandardHttpErrorDetails(e); } } else { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/client/src/main/java/org/apache/atlas/security/SecureClientUtils.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/atlas/security/SecureClientUtils.java b/client/src/main/java/org/apache/atlas/security/SecureClientUtils.java index e13d826..d5392b2 100644 --- a/client/src/main/java/org/apache/atlas/security/SecureClientUtils.java +++ b/client/src/main/java/org/apache/atlas/security/SecureClientUtils.java @@ -30,7 +30,6 @@ import org.apache.hadoop.security.ssl.SSLFactory; import org.apache.hadoop.security.token.delegation.web.DelegationTokenAuthenticatedURL; import org.apache.hadoop.security.token.delegation.web.DelegationTokenAuthenticator; import org.apache.hadoop.security.token.delegation.web.KerberosDelegationTokenAuthenticator; -import org.apache.hadoop.security.token.delegation.web.PseudoDelegationTokenAuthenticator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -56,7 +55,7 @@ import static org.apache.atlas.security.SecurityProperties.TRUSTSTORE_FILE_KEY; */ public class SecureClientUtils { - public final static int DEFAULT_SOCKET_TIMEOUT = 1 * 60 * 1000; // 1 minute + public final static int DEFAULT_SOCKET_TIMEOUT_IN_MSECS = 1 * 60 * 1000; // 1 minute private static final Logger LOG = LoggerFactory.getLogger(SecureClientUtils.class); @@ -120,14 +119,14 @@ public class SecureClientUtils { private final static ConnectionConfigurator DEFAULT_TIMEOUT_CONN_CONFIGURATOR = new ConnectionConfigurator() { @Override public HttpURLConnection configure(HttpURLConnection conn) throws IOException { - setTimeouts(conn, DEFAULT_SOCKET_TIMEOUT); + setTimeouts(conn, DEFAULT_SOCKET_TIMEOUT_IN_MSECS); return conn; } }; private static ConnectionConfigurator newConnConfigurator(Configuration conf) { try { - return newSslConnConfigurator(DEFAULT_SOCKET_TIMEOUT, conf); + return newSslConnConfigurator(DEFAULT_SOCKET_TIMEOUT_IN_MSECS, conf); } catch (Exception e) { LOG.debug("Cannot load customized ssl related configuration. " + "Fallback to system-generic settings.", e); return DEFAULT_TIMEOUT_CONN_CONFIGURATOR; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/client/src/test/java/org/apache/atlas/AtlasClientTest.java ---------------------------------------------------------------------- diff --git a/client/src/test/java/org/apache/atlas/AtlasClientTest.java b/client/src/test/java/org/apache/atlas/AtlasClientTest.java index 3a67689..56c4ae6 100644 --- a/client/src/test/java/org/apache/atlas/AtlasClientTest.java +++ b/client/src/test/java/org/apache/atlas/AtlasClientTest.java @@ -107,8 +107,7 @@ public class AtlasClientTest { private WebResource.Builder setupBuilder(AtlasClient.API api, WebResource webResource) { when(webResource.path(api.getPath())).thenReturn(service); - WebResource.Builder builder = getBuilder(service); - return builder; + return getBuilder(service); } @Test http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/common/src/main/java/org/apache/atlas/groovy/FunctionCallExpression.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/atlas/groovy/FunctionCallExpression.java b/common/src/main/java/org/apache/atlas/groovy/FunctionCallExpression.java index b60edef..dd9b1d5 100644 --- a/common/src/main/java/org/apache/atlas/groovy/FunctionCallExpression.java +++ b/common/src/main/java/org/apache/atlas/groovy/FunctionCallExpression.java @@ -32,7 +32,7 @@ public class FunctionCallExpression extends AbstractGroovyExpression { private GroovyExpression target; private String functionName; - private List<GroovyExpression> arguments = new ArrayList<GroovyExpression>(); + private List<GroovyExpression> arguments = new ArrayList<>(); public FunctionCallExpression(String functionName, List<? extends GroovyExpression> arguments) { this.target = null; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/common/src/main/java/org/apache/atlas/security/InMemoryJAASConfiguration.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/atlas/security/InMemoryJAASConfiguration.java b/common/src/main/java/org/apache/atlas/security/InMemoryJAASConfiguration.java index fb32ff5..ed42aa6 100644 --- a/common/src/main/java/org/apache/atlas/security/InMemoryJAASConfiguration.java +++ b/common/src/main/java/org/apache/atlas/security/InMemoryJAASConfiguration.java @@ -231,7 +231,7 @@ public final class InMemoryJAASConfiguration extends Configuration { String clientId = tokenizer.nextToken(); SortedSet<Integer> indexList = jaasClients.get(clientId); if (indexList == null) { - indexList = new TreeSet<Integer>(); + indexList = new TreeSet<>(); jaasClients.put(clientId, indexList); } String indexStr = tokenizer.nextToken(); @@ -275,20 +275,26 @@ public final class InMemoryJAASConfiguration extends Configuration { AppConfigurationEntry.LoginModuleControlFlag loginControlFlag = null; if (controlFlag != null) { controlFlag = controlFlag.trim().toLowerCase(); - if (controlFlag.equals("optional")) { - loginControlFlag = AppConfigurationEntry.LoginModuleControlFlag.OPTIONAL; - } else if (controlFlag.equals("requisite")) { - loginControlFlag = AppConfigurationEntry.LoginModuleControlFlag.REQUISITE; - } else if (controlFlag.equals("sufficient")) { - loginControlFlag = AppConfigurationEntry.LoginModuleControlFlag.SUFFICIENT; - } else if (controlFlag.equals("required")) { - loginControlFlag = AppConfigurationEntry.LoginModuleControlFlag.REQUIRED; - } else { - String validValues = "optional|requisite|sufficient|required"; - LOG.warn("Unknown JAAS configuration value for (" + keyParam - + ") = [" + controlFlag + "], valid value are [" + validValues - + "] using the default value, REQUIRED"); - loginControlFlag = AppConfigurationEntry.LoginModuleControlFlag.REQUIRED; + switch (controlFlag) { + case "optional": + loginControlFlag = AppConfigurationEntry.LoginModuleControlFlag.OPTIONAL; + break; + case "requisite": + loginControlFlag = AppConfigurationEntry.LoginModuleControlFlag.REQUISITE; + break; + case "sufficient": + loginControlFlag = AppConfigurationEntry.LoginModuleControlFlag.SUFFICIENT; + break; + case "required": + loginControlFlag = AppConfigurationEntry.LoginModuleControlFlag.REQUIRED; + break; + default: + String validValues = "optional|requisite|sufficient|required"; + LOG.warn("Unknown JAAS configuration value for (" + keyParam + + ") = [" + controlFlag + "], valid value are [" + validValues + + "] using the default value, REQUIRED"); + loginControlFlag = AppConfigurationEntry.LoginModuleControlFlag.REQUIRED; + break; } } else { LOG.warn("Unable to find JAAS configuration (" @@ -336,7 +342,7 @@ public final class InMemoryJAASConfiguration extends Configuration { List<AppConfigurationEntry> retList = applicationConfigEntryMap.get(jaasClient); if (retList == null) { - retList = new ArrayList<AppConfigurationEntry>(); + retList = new ArrayList<>(); applicationConfigEntryMap.put(jaasClient, retList); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/common/src/main/java/org/apache/atlas/utils/AuthenticationUtil.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/atlas/utils/AuthenticationUtil.java b/common/src/main/java/org/apache/atlas/utils/AuthenticationUtil.java index bf1175f..6430fb1 100644 --- a/common/src/main/java/org/apache/atlas/utils/AuthenticationUtil.java +++ b/common/src/main/java/org/apache/atlas/utils/AuthenticationUtil.java @@ -46,13 +46,7 @@ public final class AuthenticationUtil { } public static boolean isKerberosAuthenticationEnabled(Configuration atlasConf) { - boolean isKerberosAuthenticationEnabled; - if ("true".equalsIgnoreCase(atlasConf.getString("atlas.authentication.method.kerberos"))) { - isKerberosAuthenticationEnabled = true; - } else { - isKerberosAuthenticationEnabled = false; - } - return isKerberosAuthenticationEnabled; + return atlasConf.getBoolean("atlas.authentication.method.kerberos", false); } public static String[] getBasicAuthenticationInput() { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/common/src/main/java/org/apache/atlas/utils/PropertiesUtil.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/atlas/utils/PropertiesUtil.java b/common/src/main/java/org/apache/atlas/utils/PropertiesUtil.java index 43569c4..d5cf15c 100644 --- a/common/src/main/java/org/apache/atlas/utils/PropertiesUtil.java +++ b/common/src/main/java/org/apache/atlas/utils/PropertiesUtil.java @@ -32,9 +32,9 @@ import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; * Util class for Properties. */ public final class PropertiesUtil extends PropertyPlaceholderConfigurer { - private static Map<String, String> propertiesMap = new HashMap<String, String>(); + private static Map<String, String> propertiesMap = new HashMap<>(); private static Logger logger = Logger.getLogger(PropertiesUtil.class); - protected List<String> xmlPropertyConfigurer = new ArrayList<String>(); + protected List<String> xmlPropertyConfigurer = new ArrayList<>(); private PropertiesUtil() { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/dashboardv2/public/js/views/tag/addTagModalView.js ---------------------------------------------------------------------- diff --git a/dashboardv2/public/js/views/tag/addTagModalView.js b/dashboardv2/public/js/views/tag/addTagModalView.js index fdaea5b..206d826 100644 --- a/dashboardv2/public/js/views/tag/addTagModalView.js +++ b/dashboardv2/public/js/views/tag/addTagModalView.js @@ -103,11 +103,11 @@ define(['require', this.tagsCollection(); }, this); this.listenTo(this.commonCollection, 'reset', function() { - --this.asyncAttrFetchCounter + --this.asyncAttrFetchCounter; this.subAttributeData(); }, this); this.listenTo(this.commonCollection, 'error', function() { - --this.asyncAttrFetchCounter + --this.asyncAttrFetchCounter; this.$('.attrLoader').hide(); }, this); }, http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/graphdb/api/src/main/java/org/apache/atlas/repository/graphdb/AtlasGraphQuery.java ---------------------------------------------------------------------- diff --git a/graphdb/api/src/main/java/org/apache/atlas/repository/graphdb/AtlasGraphQuery.java b/graphdb/api/src/main/java/org/apache/atlas/repository/graphdb/AtlasGraphQuery.java index 5d60c67..bd7b35e 100644 --- a/graphdb/api/src/main/java/org/apache/atlas/repository/graphdb/AtlasGraphQuery.java +++ b/graphdb/api/src/main/java/org/apache/atlas/repository/graphdb/AtlasGraphQuery.java @@ -50,7 +50,7 @@ public interface AtlasGraphQuery<V, E> { * @param value * @return */ - AtlasGraphQuery<V, E> in(String propertyKey, Collection<? extends Object> values); + AtlasGraphQuery<V, E> in(String propertyKey, Collection<?> values); /** http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/graphdb/api/src/main/java/org/apache/atlas/repository/graphdb/AtlasIndexQuery.java ---------------------------------------------------------------------- diff --git a/graphdb/api/src/main/java/org/apache/atlas/repository/graphdb/AtlasIndexQuery.java b/graphdb/api/src/main/java/org/apache/atlas/repository/graphdb/AtlasIndexQuery.java index f2e0f9d..1ff9d5e 100644 --- a/graphdb/api/src/main/java/org/apache/atlas/repository/graphdb/AtlasIndexQuery.java +++ b/graphdb/api/src/main/java/org/apache/atlas/repository/graphdb/AtlasIndexQuery.java @@ -41,7 +41,7 @@ public interface AtlasIndexQuery<V, E> { * @param <V> * @param <E> */ - public interface Result<V, E> { + interface Result<V, E> { /** * Gets the vertex for this result. http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1620284e/graphdb/common/src/main/java/org/apache/atlas/repository/graphdb/titan/query/NativeTitanGraphQuery.java ---------------------------------------------------------------------- diff --git a/graphdb/common/src/main/java/org/apache/atlas/repository/graphdb/titan/query/NativeTitanGraphQuery.java b/graphdb/common/src/main/java/org/apache/atlas/repository/graphdb/titan/query/NativeTitanGraphQuery.java index 39c309d..662a270 100644 --- a/graphdb/common/src/main/java/org/apache/atlas/repository/graphdb/titan/query/NativeTitanGraphQuery.java +++ b/graphdb/common/src/main/java/org/apache/atlas/repository/graphdb/titan/query/NativeTitanGraphQuery.java @@ -46,7 +46,7 @@ public interface NativeTitanGraphQuery<V, E> { * @param propertyName * @param values */ - void in(String propertyName, Collection<? extends Object> values); + void in(String propertyName, Collection<?> values); /** * Adds a has condition to the query.
