Commit dbfca622 by nixonrodrigues Committed by kevalbhatt

ATLAS-1502 - Fix for not getting atlas application properties using…

ATLAS-1502 - Fix for not getting atlas application properties using PropertiesConfiguration sometimes, so changed to ApplicationProperties
parent f5f9fa09
...@@ -9,6 +9,12 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al ...@@ -9,6 +9,12 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al
ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai) ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai)
ALL CHANGES: ALL CHANGES:
ATLAS-1502 - Fix for not getting atlas application properties using PropertiesConfiguration sometimes, so changed to ApplicationProperties (nixonrodrigues via kevalbhatt)
ATLAS-1586: type search improvement by avoiding unnecessary instantiation of type objects (mneethiraj)
ATLAS-1583: fix incorrect metrics by import API (ashutoshm via mneethiraj)
ATLAS-1571: fix for incorrect v1->v2 conversion of enum-type value (mneethiraj)
ATLAS-1576: fix for NPE while handling unknown attributes (mneethiraj)
ATLAS-1577: audit event generated for an entity overwrites previous event for the entity (mneethiraj)
ATLAS-1546: Changed to LOG.warn instead error in Hive hook should choose appropriate JAAS config if host uses kerberos ticket-cache (nixonrodrigues via kevalbhatt) ATLAS-1546: Changed to LOG.warn instead error in Hive hook should choose appropriate JAAS config if host uses kerberos ticket-cache (nixonrodrigues via kevalbhatt)
ATLAS-1569 Clear contents of RequestContextV1 at the end of the request (mneethiraj) ATLAS-1569 Clear contents of RequestContextV1 at the end of the request (mneethiraj)
ATLAS-1570 Fix for Taxonomy service test failures (apoorvnaik via mneethiraj) ATLAS-1570 Fix for Taxonomy service test failures (apoorvnaik via mneethiraj)
......
...@@ -19,8 +19,10 @@ ...@@ -19,8 +19,10 @@
package org.apache.atlas.web.resources; package org.apache.atlas.web.resources;
import com.google.inject.Inject; import com.google.inject.Inject;
import org.apache.atlas.ApplicationProperties;
import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasClient;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.AtlasException;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.impexp.AtlasExportRequest; import org.apache.atlas.model.impexp.AtlasExportRequest;
import org.apache.atlas.model.impexp.AtlasExportResult; import org.apache.atlas.model.impexp.AtlasExportResult;
...@@ -68,6 +70,7 @@ import java.util.Collection; ...@@ -68,6 +70,7 @@ import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import org.apache.commons.configuration.Configuration;
import static org.apache.atlas.repository.converters.AtlasInstanceConverter.toAtlasBaseException; import static org.apache.atlas.repository.converters.AtlasInstanceConverter.toAtlasBaseException;
...@@ -96,7 +99,7 @@ public class AdminResource { ...@@ -96,7 +99,7 @@ public class AdminResource {
private static final String isEntityUpdateAllowed = "atlas.entity.update.allowed"; private static final String isEntityUpdateAllowed = "atlas.entity.update.allowed";
private static final String isEntityCreateAllowed = "atlas.entity.create.allowed"; private static final String isEntityCreateAllowed = "atlas.entity.create.allowed";
private static final String editableEntityTypes = "atlas.ui.editable.entity.types"; private static final String editableEntityTypes = "atlas.ui.editable.entity.types";
private static final String DEFAULT_EDITABLE_ENTITY_TYPES = "hdfs_path,hdfs_path,hbase_table,hbase_column,hbase_column_family,kafka_topic"; private static final String DEFAULT_EDITABLE_ENTITY_TYPES = "hdfs_path,hbase_table,hbase_column,hbase_column_family,kafka_topic";
private Response version; private Response version;
private final ServiceState serviceState; private final ServiceState serviceState;
...@@ -104,6 +107,15 @@ public class AdminResource { ...@@ -104,6 +107,15 @@ public class AdminResource {
private final AtlasTypeRegistry typeRegistry; private final AtlasTypeRegistry typeRegistry;
private final AtlasTypeDefStore typesDefStore; private final AtlasTypeDefStore typesDefStore;
private final AtlasEntityStore entityStore; private final AtlasEntityStore entityStore;
private static Configuration atlasProperties;
static {
try {
atlasProperties = ApplicationProperties.get();
} catch (Exception e) {
LOG.info("Failed to load application properties", e);
}
}
@Inject @Inject
public AdminResource(ServiceState serviceState, MetricsService metricsService, public AdminResource(ServiceState serviceState, MetricsService metricsService,
...@@ -225,10 +237,12 @@ public class AdminResource { ...@@ -225,10 +237,12 @@ public class AdminResource {
} }
Response response; Response response;
Boolean enableTaxonomy = false;
try { try {
PropertiesConfiguration configProperties = new PropertiesConfiguration("atlas-application.properties"); if(atlasProperties != null) {
Boolean enableTaxonomy = configProperties.getBoolean(isTaxonomyEnabled, false); enableTaxonomy = atlasProperties.getBoolean(isTaxonomyEnabled, false);
}
boolean isEntityUpdateAccessAllowed = false; boolean isEntityUpdateAccessAllowed = false;
boolean isEntityCreateAccessAllowed = false; boolean isEntityCreateAccessAllowed = false;
Authentication auth = SecurityContextHolder.getContext().getAuthentication(); Authentication auth = SecurityContextHolder.getContext().getAuthentication();
...@@ -255,12 +269,12 @@ public class AdminResource { ...@@ -255,12 +269,12 @@ public class AdminResource {
responseData.put(isTaxonomyEnabled, enableTaxonomy); responseData.put(isTaxonomyEnabled, enableTaxonomy);
responseData.put(isEntityUpdateAllowed, isEntityUpdateAccessAllowed); responseData.put(isEntityUpdateAllowed, isEntityUpdateAccessAllowed);
responseData.put(isEntityCreateAllowed, isEntityCreateAccessAllowed); responseData.put(isEntityCreateAllowed, isEntityCreateAccessAllowed);
responseData.put(editableEntityTypes, getEditableEntityTypes(configProperties)); responseData.put(editableEntityTypes, getEditableEntityTypes(atlasProperties));
responseData.put("userName", userName); responseData.put("userName", userName);
responseData.put("groups", groups); responseData.put("groups", groups);
response = Response.ok(responseData).build(); response = Response.ok(responseData).build();
} catch (JSONException | ConfigurationException e) { } catch (JSONException e) {
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
} }
...@@ -411,10 +425,10 @@ public class AdminResource { ...@@ -411,10 +425,10 @@ public class AdminResource {
return result; return result;
} }
private String getEditableEntityTypes(PropertiesConfiguration config) { private String getEditableEntityTypes(Configuration config) {
String ret = DEFAULT_EDITABLE_ENTITY_TYPES; String ret = DEFAULT_EDITABLE_ENTITY_TYPES;
if (config.containsKey(editableEntityTypes)) { if (config != null && config.containsKey(editableEntityTypes)) {
Object value = config.getProperty(editableEntityTypes); Object value = config.getProperty(editableEntityTypes);
if (value instanceof String) { if (value instanceof String) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment