Commit c4fc5b4f by Suma Shivaprasad Committed by Madhan Neethiraj

ATLAS-1744: updated to address review comments and ATLAS startup failure

parent ca64ef4e
...@@ -25,6 +25,8 @@ import org.apache.atlas.model.typedef.AtlasBaseTypeDef; ...@@ -25,6 +25,8 @@ import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import org.apache.atlas.model.typedef.AtlasStructDef; import org.apache.atlas.model.typedef.AtlasStructDef;
import org.apache.atlas.query.QueryParser; import org.apache.atlas.query.QueryParser;
import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.type.AtlasTypeRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List; import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
...@@ -34,13 +36,14 @@ import java.util.regex.Pattern; ...@@ -34,13 +36,14 @@ import java.util.regex.Pattern;
* Abstract typedef-store for v1 format. * Abstract typedef-store for v1 format.
*/ */
public abstract class AtlasAbstractDefStoreV1 { public abstract class AtlasAbstractDefStoreV1 {
private static final Logger LOG = LoggerFactory.getLogger(AtlasAbstractDefStoreV1.class);
protected final AtlasTypeDefGraphStoreV1 typeDefStore; protected final AtlasTypeDefGraphStoreV1 typeDefStore;
protected final AtlasTypeRegistry typeRegistry; protected final AtlasTypeRegistry typeRegistry;
private static final String NAME_REGEX = "[a-zA-Z][a-zA-Z0-9_ ]*"; private static final String NAME_REGEX = "[a-zA-Z][a-zA-Z0-9_ ]*";
private static final Pattern NAME_PATTERN = Pattern.compile(NAME_REGEX); private static final Pattern NAME_PATTERN = Pattern.compile(NAME_REGEX);
private static final String ALLOW_RESERVED_KEYWORDS = "atlas.types.allowReservedKeywords"; public static final String ALLOW_RESERVED_KEYWORDS = "atlas.types.allowReservedKeywords";
public AtlasAbstractDefStoreV1(AtlasTypeDefGraphStoreV1 typeDefStore, AtlasTypeRegistry typeRegistry) { public AtlasAbstractDefStoreV1(AtlasTypeDefGraphStoreV1 typeDefStore, AtlasTypeRegistry typeRegistry) {
this.typeDefStore = typeDefStore; this.typeDefStore = typeDefStore;
...@@ -53,7 +56,7 @@ public abstract class AtlasAbstractDefStoreV1 { ...@@ -53,7 +56,7 @@ public abstract class AtlasAbstractDefStoreV1 {
} }
try { try {
final boolean allowReservedKeywords = ApplicationProperties.get().getBoolean(ALLOW_RESERVED_KEYWORDS, false); final boolean allowReservedKeywords = ApplicationProperties.get().getBoolean(ALLOW_RESERVED_KEYWORDS, true);
if (!allowReservedKeywords && typeDef instanceof AtlasStructDef) { if (!allowReservedKeywords && typeDef instanceof AtlasStructDef) {
final List<AtlasStructDef.AtlasAttributeDef> attributeDefs = ((AtlasStructDef) typeDef).getAttributeDefs(); final List<AtlasStructDef.AtlasAttributeDef> attributeDefs = ((AtlasStructDef) typeDef).getAttributeDefs();
...@@ -64,6 +67,7 @@ public abstract class AtlasAbstractDefStoreV1 { ...@@ -64,6 +67,7 @@ public abstract class AtlasAbstractDefStoreV1 {
} }
} }
} catch (AtlasException e) { } catch (AtlasException e) {
LOG.error("Exception while loading configuration ", e);
throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, "Could not load configuration"); throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, "Could not load configuration");
} }
} }
......
...@@ -422,9 +422,6 @@ object QueryParser extends StandardTokenParsers with QueryKeywords with Expressi ...@@ -422,9 +422,6 @@ object QueryParser extends StandardTokenParsers with QueryKeywords with Expressi
} }
def isKeyword(s: String) = queryreservedWords.contains(s) def isKeyword(s: String) = queryreservedWords.contains(s)
def isDelimiter(s: String) = querydelims.contains(s)
} }
class QueryLexer(val keywords: Seq[String], val delims: Seq[String]) extends StdLexical with ImplicitConversions { class QueryLexer(val keywords: Seq[String], val delims: Seq[String]) extends StdLexical with ImplicitConversions {
......
...@@ -19,11 +19,14 @@ package org.apache.atlas.repository.store.graph; ...@@ -19,11 +19,14 @@ package org.apache.atlas.repository.store.graph;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.inject.Inject; import com.google.inject.Inject;
import org.apache.atlas.ApplicationProperties;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.AtlasException;
import org.apache.atlas.RepositoryMetadataModule; import org.apache.atlas.RepositoryMetadataModule;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.typedef.AtlasEntityDef; import org.apache.atlas.model.typedef.AtlasEntityDef;
import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.repository.graph.AtlasGraphProvider;
import org.apache.atlas.repository.store.graph.v1.AtlasAbstractDefStoreV1;
import org.apache.atlas.type.AtlasTypeUtil; import org.apache.atlas.type.AtlasTypeUtil;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterClass;
...@@ -58,8 +61,9 @@ public class AtlasEntityDefStoreV1Test { ...@@ -58,8 +61,9 @@ public class AtlasEntityDefStoreV1Test {
} }
@Test(dataProvider = "invalidAttributeNameWithReservedKeywords") @Test(dataProvider = "invalidAttributeNameWithReservedKeywords")
public void testCreateTypeWithReservedKeywords(AtlasEntityDef atlasEntityDef) { public void testCreateTypeWithReservedKeywords(AtlasEntityDef atlasEntityDef) throws AtlasException {
try { try {
ApplicationProperties.get().setProperty(AtlasAbstractDefStoreV1.ALLOW_RESERVED_KEYWORDS, false);
entityDefStore.create(atlasEntityDef, null); entityDefStore.create(atlasEntityDef, null);
} catch (AtlasBaseException e) { } catch (AtlasBaseException e) {
Assert.assertEquals(e.getAtlasErrorCode(), AtlasErrorCode.ATTRIBUTE_NAME_INVALID); Assert.assertEquals(e.getAtlasErrorCode(), AtlasErrorCode.ATTRIBUTE_NAME_INVALID);
......
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