sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject [1/2] git commit: SENTRY-34 - Create sentry-core-model-search module (Gregory Chanan via Brock Noland)
Date Wed, 09 Oct 2013 22:50:00 GMT
Updated Branches:
  refs/heads/master 1b2bbeb67 -> 224aa8c8b


SENTRY-34 - Create sentry-core-model-search module (Gregory Chanan via Brock Noland)


Project: http://git-wip-us.apache.org/repos/asf/incubator-sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-sentry/commit/d1b14ba2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-sentry/tree/d1b14ba2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-sentry/diff/d1b14ba2

Branch: refs/heads/master
Commit: d1b14ba295f888156c3c2b07d28d10101e8184b1
Parents: 1b2bbeb
Author: Brock Noland <brock@apache.org>
Authored: Wed Oct 9 17:18:20 2013 -0500
Committer: Brock Noland <brock@apache.org>
Committed: Wed Oct 9 17:18:20 2013 -0500

----------------------------------------------------------------------
 pom.xml                                         |  5 ++
 sentry-core/pom.xml                             |  1 +
 sentry-core/sentry-core-model-search/pom.xml    | 43 +++++++++++++++++
 .../sentry/core/model/search/Collection.java    | 51 ++++++++++++++++++++
 .../sentry/core/model/search/SolrConstants.java | 25 ++++++++++
 .../core/model/search/SolrModelAction.java      | 39 +++++++++++++++
 .../model/search/SolrModelAuthorizable.java     | 28 +++++++++++
 .../sentry/core/search/TestCollection.java      | 49 +++++++++++++++++++
 sentry-dist/pom.xml                             |  4 ++
 sentry-dist/src/main/assembly/src.xml           |  1 +
 10 files changed, 246 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/d1b14ba2/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 56d22b5..d266e26 100644
--- a/pom.xml
+++ b/pom.xml
@@ -162,6 +162,11 @@ limitations under the License.
         <version>${project.version}</version>
       </dependency>
       <dependency>
+        <groupId>org.apache.sentry</groupId>
+        <artifactId>sentry-core-model-search</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
         <groupId>org.apache.hive</groupId>
         <artifactId>hive-jdbc</artifactId>
         <version>${hive.version}</version>

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/d1b14ba2/sentry-core/pom.xml
----------------------------------------------------------------------
diff --git a/sentry-core/pom.xml b/sentry-core/pom.xml
index 109d09f..d3f9785 100644
--- a/sentry-core/pom.xml
+++ b/sentry-core/pom.xml
@@ -31,6 +31,7 @@ limitations under the License.
   <modules>
     <module>sentry-core-common</module>
     <module>sentry-core-model-db</module>
+    <module>sentry-core-model-search</module>
   </modules>
 
 </project>

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/d1b14ba2/sentry-core/sentry-core-model-search/pom.xml
----------------------------------------------------------------------
diff --git a/sentry-core/sentry-core-model-search/pom.xml b/sentry-core/sentry-core-model-search/pom.xml
new file mode 100644
index 0000000..70898c0
--- /dev/null
+++ b/sentry-core/sentry-core-model-search/pom.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.sentry</groupId>
+    <artifactId>sentry-core</artifactId>
+    <version>1.3.0-incubating-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>sentry-core-model-search</artifactId>
+  <name>Sentry Core Model Solr</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.sentry</groupId>
+      <artifactId>sentry-core-common</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/d1b14ba2/sentry-core/sentry-core-model-search/src/main/java/org/apache/sentry/core/model/search/Collection.java
----------------------------------------------------------------------
diff --git a/sentry-core/sentry-core-model-search/src/main/java/org/apache/sentry/core/model/search/Collection.java
b/sentry-core/sentry-core-model-search/src/main/java/org/apache/sentry/core/model/search/Collection.java
new file mode 100644
index 0000000..a35a9c2
--- /dev/null
+++ b/sentry-core/sentry-core-model-search/src/main/java/org/apache/sentry/core/model/search/Collection.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sentry.core.model.search;
+
+public class Collection implements SolrModelAuthorizable {
+
+  /**
+   * Represents all tables
+   */
+  public static final Collection ALL = new Collection(SolrConstants.ALL);
+
+  private final String name;
+
+  public Collection(String name) {
+    this.name = name;
+  }
+
+  @Override
+  public String getName() {
+    return name;
+  }
+
+  @Override
+  public String toString() {
+    return "Collection [name=" + name + "]";
+  }
+
+  @Override
+  public AuthorizableType getAuthzType() {
+    return AuthorizableType.Collection;
+  }
+
+  @Override
+  public String getTypeName() {
+    return getAuthzType().name();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/d1b14ba2/sentry-core/sentry-core-model-search/src/main/java/org/apache/sentry/core/model/search/SolrConstants.java
----------------------------------------------------------------------
diff --git a/sentry-core/sentry-core-model-search/src/main/java/org/apache/sentry/core/model/search/SolrConstants.java
b/sentry-core/sentry-core-model-search/src/main/java/org/apache/sentry/core/model/search/SolrConstants.java
new file mode 100644
index 0000000..a100526
--- /dev/null
+++ b/sentry-core/sentry-core-model-search/src/main/java/org/apache/sentry/core/model/search/SolrConstants.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sentry.core.model.search;
+
+public class SolrConstants {
+
+  public static final String ALL = "*";
+  public static final String QUERY = "query";
+  public static final String UPDATE = "update";
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/d1b14ba2/sentry-core/sentry-core-model-search/src/main/java/org/apache/sentry/core/model/search/SolrModelAction.java
----------------------------------------------------------------------
diff --git a/sentry-core/sentry-core-model-search/src/main/java/org/apache/sentry/core/model/search/SolrModelAction.java
b/sentry-core/sentry-core-model-search/src/main/java/org/apache/sentry/core/model/search/SolrModelAction.java
new file mode 100644
index 0000000..ed9a2f3
--- /dev/null
+++ b/sentry-core/sentry-core-model-search/src/main/java/org/apache/sentry/core/model/search/SolrModelAction.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sentry.core.model.search;
+
+import org.apache.sentry.core.common.Action;
+
+/**
+ * Represents actions in the Solr model.
+ */
+public enum SolrModelAction implements Action {
+
+  UPDATE(SolrConstants.UPDATE),
+  QUERY(SolrConstants.QUERY),
+  ALL(SolrConstants.ALL);
+
+  private final String value;
+  private SolrModelAction(String value) {
+    this.value = value;
+  }
+
+  @Override
+  public String getValue() {
+    return value;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/d1b14ba2/sentry-core/sentry-core-model-search/src/main/java/org/apache/sentry/core/model/search/SolrModelAuthorizable.java
----------------------------------------------------------------------
diff --git a/sentry-core/sentry-core-model-search/src/main/java/org/apache/sentry/core/model/search/SolrModelAuthorizable.java
b/sentry-core/sentry-core-model-search/src/main/java/org/apache/sentry/core/model/search/SolrModelAuthorizable.java
new file mode 100644
index 0000000..d7d5fb3
--- /dev/null
+++ b/sentry-core/sentry-core-model-search/src/main/java/org/apache/sentry/core/model/search/SolrModelAuthorizable.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sentry.core.model.search;
+
+import org.apache.sentry.core.common.Authorizable;
+
+public interface SolrModelAuthorizable extends Authorizable {
+
+  public enum AuthorizableType {
+    Collection
+  };
+
+  public AuthorizableType getAuthzType();
+}

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/d1b14ba2/sentry-core/sentry-core-model-search/src/test/java/org/apache/sentry/core/search/TestCollection.java
----------------------------------------------------------------------
diff --git a/sentry-core/sentry-core-model-search/src/test/java/org/apache/sentry/core/search/TestCollection.java
b/sentry-core/sentry-core-model-search/src/test/java/org/apache/sentry/core/search/TestCollection.java
new file mode 100644
index 0000000..bc00b62
--- /dev/null
+++ b/sentry-core/sentry-core-model-search/src/test/java/org/apache/sentry/core/search/TestCollection.java
@@ -0,0 +1,49 @@
+package org.apache.sentry.core.search;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.sentry.core.model.search.Collection;
+import org.junit.Test;
+import junit.framework.Assert;
+
+public class TestCollection {
+
+  @Test
+  public void testSimple() {
+    String name = "simple";
+    Collection simple = new Collection(name);
+    Assert.assertEquals(simple.getName(), name);
+  }
+
+  @Test
+  public void testCollectionAuthzType() {
+    Collection collection1 = new Collection("collection1");
+    Collection collection2 = new Collection("collection2");
+    Assert.assertEquals(collection1.getAuthzType(), collection2.getAuthzType());
+    Assert.assertEquals(collection1.getTypeName(), collection2.getTypeName());
+  }
+
+  // just test it doesn't throw NPE
+  @Test
+  public void testNullCollection() {
+    Collection nullCollection = new Collection(null);
+    nullCollection.getName();
+    nullCollection.toString();
+    nullCollection.getAuthzType();
+    nullCollection.getTypeName();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/d1b14ba2/sentry-dist/pom.xml
----------------------------------------------------------------------
diff --git a/sentry-dist/pom.xml b/sentry-dist/pom.xml
index b8207f7..e9fbdfd 100644
--- a/sentry-dist/pom.xml
+++ b/sentry-dist/pom.xml
@@ -36,6 +36,10 @@ limitations under the License.
     </dependency>
     <dependency>
       <groupId>org.apache.sentry</groupId>
+      <artifactId>sentry-core-model-search</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.sentry</groupId>
       <artifactId>sentry-binding-hive</artifactId>
     </dependency>
     <dependency>

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/d1b14ba2/sentry-dist/src/main/assembly/src.xml
----------------------------------------------------------------------
diff --git a/sentry-dist/src/main/assembly/src.xml b/sentry-dist/src/main/assembly/src.xml
index bf78976..2bd52e7 100644
--- a/sentry-dist/src/main/assembly/src.xml
+++ b/sentry-dist/src/main/assembly/src.xml
@@ -41,6 +41,7 @@
         <include>org.apache.sentry:sentry-core</include>
         <include>org.apache.sentry:sentry-core-common</include>
         <include>org.apache.sentry:sentry-core-model-db</include>
+        <include>org.apache.sentry:sentry-core-model-search</include>
         <include>org.apache.sentry:sentry-provider</include>
         <include>org.apache.sentry:sentry-provider-file</include>
         <include>org.apache.sentry:sentry-provider-policy-db</include>


Mime
View raw message