You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2016/02/19 00:01:29 UTC
lucene-solr git commit: SOLR-8692 moved the embedded json out to
resources dir
Repository: lucene-solr
Updated Branches:
refs/heads/master b8f251d8e -> 8bcac81a2
SOLR-8692 moved the embedded json out to resources dir
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/8bcac81a
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/8bcac81a
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/8bcac81a
Branch: refs/heads/master
Commit: 8bcac81a219f685ea2e92901e9bec05954de90df
Parents: b8f251d
Author: Noble Paul <no...@gmail.com>
Authored: Thu Feb 18 14:59:09 2016 -0800
Committer: Noble Paul <no...@gmail.com>
Committed: Thu Feb 18 14:59:09 2016 -0800
----------------------------------------------------------------------
dev-tools/idea/solr/core/src/java/solr-core.iml | 9 +++
.../idea/solr/core/src/solr-core-tests.iml | 9 +++
dev-tools/idea/solr/solrj/src/solrj-tests.iml | 9 +++
.../org/apache/solr/core/ConfigOverlay.java | 69 +-------------------
.../security/RuleBasedAuthorizationPlugin.java | 37 +----------
.../resources/EditableSolrConfigAttributes.json | 56 ++++++++++++++++
.../src/resources/WellKnownPermissions.json | 47 +++++++++++++
.../TestSolrConfigHandlerConcurrent.java | 3 +-
.../java/org/apache/solr/common/util/Utils.java | 15 +++++
9 files changed, 152 insertions(+), 102 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8bcac81a/dev-tools/idea/solr/core/src/java/solr-core.iml
----------------------------------------------------------------------
diff --git a/dev-tools/idea/solr/core/src/java/solr-core.iml b/dev-tools/idea/solr/core/src/java/solr-core.iml
index 9ec3eb6..eb54942 100644
--- a/dev-tools/idea/solr/core/src/java/solr-core.iml
+++ b/dev-tools/idea/solr/core/src/java/solr-core.iml
@@ -27,5 +27,14 @@
<orderEntry type="module" module-name="queryparser" />
<orderEntry type="module" module-name="join" />
<orderEntry type="module" module-name="sandbox" />
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="file://$MODULE_DIR$/resources" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
</component>
</module>
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8bcac81a/dev-tools/idea/solr/core/src/solr-core-tests.iml
----------------------------------------------------------------------
diff --git a/dev-tools/idea/solr/core/src/solr-core-tests.iml b/dev-tools/idea/solr/core/src/solr-core-tests.iml
index eb27c57..6e2bb6f 100644
--- a/dev-tools/idea/solr/core/src/solr-core-tests.iml
+++ b/dev-tools/idea/solr/core/src/solr-core-tests.iml
@@ -31,5 +31,14 @@
<orderEntry type="module" scope="TEST" module-name="expressions" />
<orderEntry type="module" scope="TEST" module-name="icu" />
<orderEntry type="module" scope="TEST" module-name="analysis-extras" />
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="file://$MODULE_DIR$/resources" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
</component>
</module>
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8bcac81a/dev-tools/idea/solr/solrj/src/solrj-tests.iml
----------------------------------------------------------------------
diff --git a/dev-tools/idea/solr/solrj/src/solrj-tests.iml b/dev-tools/idea/solr/solrj/src/solrj-tests.iml
index 13cdb58..0b3c252 100644
--- a/dev-tools/idea/solr/solrj/src/solrj-tests.iml
+++ b/dev-tools/idea/solr/solrj/src/solrj-tests.iml
@@ -29,5 +29,14 @@
<orderEntry type="module" scope="TEST" module-name="solr-core" />
<orderEntry type="module" scope="TEST" module-name="analysis-common" />
<orderEntry type="module" scope="TEST" module-name="lucene-core" />
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="file://$MODULE_DIR$/../../core/src/resources" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
</component>
</module>
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8bcac81a/solr/core/src/java/org/apache/solr/core/ConfigOverlay.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/core/ConfigOverlay.java b/solr/core/src/java/org/apache/solr/core/ConfigOverlay.java
index 0252bd5..ae3e055 100644
--- a/solr/core/src/java/org/apache/solr/core/ConfigOverlay.java
+++ b/solr/core/src/java/org/apache/solr/core/ConfigOverlay.java
@@ -170,74 +170,10 @@ public class ConfigOverlay implements MapSerializable {
private static final Long INT_NODE = 21L;
private static final Long FLOAT_ATTR = 30L;
private static final Long FLOAT_NODE = 31L;*/
-
- private static Map editable_prop_map;
//The path maps to the xml xpath and value of 1 means it is a tag with a string value and value
// of 0 means it is an attribute with string value
- public static final String MAPPING = "{" +
- " updateHandler:{" +
- " autoCommit:{" +
- " maxDocs:20," +
- " maxTime:20," +
- " openSearcher:11}," +
- " autoSoftCommit:{" +
- " maxDocs:20," +
- " maxTime:20}," +
- " commitWithin:{softCommit:11}," +
- " indexWriter:{closeWaitsForMerges:11}}," +
- " query:{" +
- " filterCache:{" +
- " class:0," +
- " size:0," +
- " initialSize:20," +
- " autowarmCount:20," +
- " maxRamMB:20," +
- " regenerator:0}," +
- " queryResultCache:{" +
- " class:0," +
- " size:20," +
- " initialSize:20," +
- " autowarmCount:20," +
- " maxRamMB:20," +
- " regenerator:0}," +
- " documentCache:{" +
- " class:0," +
- " size:20," +
- " initialSize:20," +
- " autowarmCount:20," +
- " regenerator:0}," +
- " fieldValueCache:{" +
- " class:0," +
- " size:20," +
- " initialSize:20," +
- " autowarmCount:20," +
- " regenerator:0}," +
- " useFilterForSortedQuery:1," +
- " queryResultWindowSize:1," +
- " queryResultMaxDocsCached:1," +
- " enableLazyFieldLoading:1," +
- " boolTofilterOptimizer:1," +
- " maxBooleanClauses:1}," +
- " jmx:{" +
- " agentId:0," +
- " serviceUrl:0," +
- " rootName:0}," +
- " requestDispatcher:{" +
- " handleSelect:0," +
- " requestParsers:{" +
- " multipartUploadLimitInKB:0," +
- " formdataUploadLimitInKB:0," +
- " enableRemoteStreaming:0," +
- " addHttpRequestToContext:0}}}";
-
- static {
- try {
- editable_prop_map = (Map) new ObjectBuilder(new JSONParser(new StringReader(
- MAPPING))).getObject();
- } catch (IOException e) {
- throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "error parsing mapping ", e);
- }
- }
+
+ private static Map editable_prop_map = (Map) Utils.fromJSONResource("EditableSolrConfigAttributes.json");
public static boolean isEditableProp(String path, boolean isXpath, List<String> hierarchy) {
return !(checkEditable(path, isXpath, hierarchy) == null);
@@ -331,6 +267,7 @@ public class ConfigOverlay implements MapSerializable {
public static final String NAME = "overlay";
public static void main(String[] args) {
+ System.out.println(Utils.toJSONString(editable_prop_map));
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8bcac81a/solr/core/src/java/org/apache/solr/security/RuleBasedAuthorizationPlugin.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/security/RuleBasedAuthorizationPlugin.java b/solr/core/src/java/org/apache/solr/security/RuleBasedAuthorizationPlugin.java
index fa13e7c..1d4a9b8 100644
--- a/solr/core/src/java/org/apache/solr/security/RuleBasedAuthorizationPlugin.java
+++ b/solr/core/src/java/org/apache/solr/security/RuleBasedAuthorizationPlugin.java
@@ -40,6 +40,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static java.util.Collections.singleton;
+import static org.apache.solr.common.util.Utils.fromJSONResource;
import static org.apache.solr.handler.admin.SecurityConfHandler.getListValue;
import static org.apache.solr.handler.admin.SecurityConfHandler.getMapValue;
import static org.apache.solr.common.params.CommonParams.NAME;
@@ -437,40 +438,8 @@ public class RuleBasedAuthorizationPlugin implements AuthorizationPlugin, Config
public static final Set<String> HTTP_METHODS = ImmutableSet.of("GET", "POST", "DELETE", "PUT", "HEAD");
- private static final Map<String, Map<String,Object>> well_known_permissions = (Map) Utils.fromJSONString(
- " { " +
- " security-edit :{" +
- " path:['/admin/authentication','/admin/authorization']," +
- " collection:null," +
- " method:POST }," +
- " security-read :{" +
- " path:['/admin/authentication','/admin/authorization']," +
- " collection:null," +
- " method:GET}," +
- " schema-edit :{" +
- " method:POST," +
- " path:'/schema/*'}," +
- " collection-admin-edit :{" +
- " collection:null," +
- " path:'/admin/collections'}," +
- " collection-admin-read :{" +
- " collection:null," +
- " path:'/admin/collections'}," +
- " schema-read :{" +
- " method:GET," +
- " path:'/schema/*'}," +
- " config-read :{" +
- " method:GET," +
- " path:'/config/*'}," +
- " update :{" +
- " path:'/update/*'}," +
- " read :{" +
- " path:['/select', '/get','/browse','/tvrh','/terms','/clustering','/elevate', '/export','/spell','/clustering']}," +
- " config-edit:{" +
- " method:POST," +
- " path:'/config/*'}," +
- " all:{collection:['*', null]}" +
- "}");
+ private static final Map<String, Map<String,Object>> well_known_permissions =
+ (Map<String, Map<String, Object>>) fromJSONResource("WellKnownPermissions.json");
static {
((Map) well_known_permissions.get("collection-admin-edit")).put(Predicate.class.getName(), getCollectionActionPredicate(true));
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8bcac81a/solr/core/src/resources/EditableSolrConfigAttributes.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/EditableSolrConfigAttributes.json b/solr/core/src/resources/EditableSolrConfigAttributes.json
new file mode 100644
index 0000000..394d634
--- /dev/null
+++ b/solr/core/src/resources/EditableSolrConfigAttributes.json
@@ -0,0 +1,56 @@
+{
+ "updateHandler":{
+ "autoCommit":{
+ "maxDocs":20,
+ "maxTime":20,
+ "openSearcher":11},
+ "autoSoftCommit":{
+ "maxDocs":20,
+ "maxTime":20},
+ "commitWithin":{"softCommit":11},
+ "indexWriter":{"closeWaitsForMerges":11}},
+ "query":{
+ "filterCache":{
+ "class":0,
+ "size":0,
+ "initialSize":20,
+ "autowarmCount":20,
+ "maxRamMB":20,
+ "regenerator":0},
+ "queryResultCache":{
+ "class":0,
+ "size":20,
+ "initialSize":20,
+ "autowarmCount":20,
+ "maxRamMB":20,
+ "regenerator":0},
+ "documentCache":{
+ "class":0,
+ "size":20,
+ "initialSize":20,
+ "autowarmCount":20,
+ "regenerator":0},
+ "fieldValueCache":{
+ "class":0,
+ "size":20,
+ "initialSize":20,
+ "autowarmCount":20,
+ "regenerator":0},
+ "useFilterForSortedQuery":1,
+ "queryResultWindowSize":1,
+ "queryResultMaxDocsCached":1,
+ "enableLazyFieldLoading":1,
+ "boolTofilterOptimizer":1,
+ "maxBooleanClauses":1},
+ "jmx":{
+ "agentId":0,
+ "serviceUrl":0,
+ "rootName":0},
+ "requestDispatcher":{
+ "handleSelect":0,
+ "requestParsers":{
+ "multipartUploadLimitInKB":0,
+ "formdataUploadLimitInKB":0,
+ "enableRemoteStreaming":0,
+ "addHttpRequestToContext":0}}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8bcac81a/solr/core/src/resources/WellKnownPermissions.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/WellKnownPermissions.json b/solr/core/src/resources/WellKnownPermissions.json
new file mode 100644
index 0000000..026e511
--- /dev/null
+++ b/solr/core/src/resources/WellKnownPermissions.json
@@ -0,0 +1,47 @@
+{
+ "security-edit":{
+ "path":[
+ "/admin/authentication",
+ "/admin/authorization"],
+ "collection":null,
+ "method":"POST"},
+ "security-read":{
+ "path":[
+ "/admin/authentication",
+ "/admin/authorization"],
+ "collection":null,
+ "method":"GET"},
+ "schema-edit":{
+ "method":"POST",
+ "path":"/schema/*"},
+ "collection-admin-edit":{
+ "collection":null,
+ "path":"/admin/collections"},
+ "collection-admin-read":{
+ "collection":null,
+ "path":"/admin/collections"},
+ "schema-read":{
+ "method":"GET",
+ "path":"/schema/*"},
+ "config-read":{
+ "method":"GET",
+ "path":"/config/*"},
+ "update":{"path":"/update/*"},
+ "read":{"path":[
+ "/select",
+ "/get",
+ "/browse",
+ "/tvrh",
+ "/terms",
+ "/clustering",
+ "/elevate",
+ "/export",
+ "/spell",
+ "/clustering"]},
+ "config-edit":{
+ "method":"POST",
+ "path":"/config/*"},
+ "all":{"collection":[
+ "*",
+ null]}
+}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8bcac81a/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerConcurrent.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerConcurrent.java b/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerConcurrent.java
index 4f37568..43b83e2 100644
--- a/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerConcurrent.java
+++ b/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerConcurrent.java
@@ -81,8 +81,7 @@ public class TestSolrConfigHandlerConcurrent extends AbstractFullDistribZkTestBa
@Test
public void test() throws Exception {
- Map editable_prop_map = (Map) new ObjectBuilder(new JSONParser(new StringReader(
- ConfigOverlay.MAPPING))).getObject();
+ Map editable_prop_map = (Map) Utils.fromJSONResource("EditableSolrConfigAttributes.json");
Map caches = (Map) editable_prop_map.get("query");
setupHarnesses();
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8bcac81a/solr/solrj/src/java/org/apache/solr/common/util/Utils.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/Utils.java b/solr/solrj/src/java/org/apache/solr/common/util/Utils.java
index 03b8b2c..ecc63ac 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/Utils.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/Utils.java
@@ -18,6 +18,7 @@ package org.apache.solr.common.util;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.StringReader;
import java.lang.invoke.MethodHandles;
import java.nio.charset.StandardCharsets;
@@ -120,6 +121,20 @@ public class Utils {
return propMap;
}
+ public static Object fromJSON(InputStream is){
+ try {
+ return new ObjectBuilder(new JSONParser(new InputStreamReader(is, StandardCharsets.UTF_8))).getObject();
+ } catch (IOException e) {
+ throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Parse error", e);
+ }
+ }
+
+ public static Object fromJSONResource(String resourceName){
+ return fromJSON(Thread.currentThread()
+ .getContextClassLoader().getResourceAsStream(resourceName));
+
+ }
+
public static Object fromJSONString(String json) {
try {
return new ObjectBuilder(new JSONParser(new StringReader(