SOLR-8692 moved the embedded json out to resources dir

This commit is contained in:
Noble Paul 2016-02-18 14:59:09 -08:00
parent b8f251d8e9
commit 8bcac81a21
9 changed files with 151 additions and 101 deletions

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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));
}
}

View File

@ -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));

View File

@ -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}}
}

View File

@ -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]}
}

View File

@ -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();

View File

@ -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(