mirror of
https://github.com/apache/lucene.git
synced 2025-02-08 11:05:29 +00:00
SOLR-8692 moved the embedded json out to resources dir
This commit is contained in:
parent
b8f251d8e9
commit
8bcac81a21
@ -27,5 +27,14 @@
|
|||||||
<orderEntry type="module" module-name="queryparser" />
|
<orderEntry type="module" module-name="queryparser" />
|
||||||
<orderEntry type="module" module-name="join" />
|
<orderEntry type="module" module-name="join" />
|
||||||
<orderEntry type="module" module-name="sandbox" />
|
<orderEntry type="module" module-name="sandbox" />
|
||||||
|
<orderEntry type="module-library">
|
||||||
|
<library>
|
||||||
|
<CLASSES>
|
||||||
|
<root url="file://$MODULE_DIR$/resources" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</orderEntry>
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
|
@ -31,5 +31,14 @@
|
|||||||
<orderEntry type="module" scope="TEST" module-name="expressions" />
|
<orderEntry type="module" scope="TEST" module-name="expressions" />
|
||||||
<orderEntry type="module" scope="TEST" module-name="icu" />
|
<orderEntry type="module" scope="TEST" module-name="icu" />
|
||||||
<orderEntry type="module" scope="TEST" module-name="analysis-extras" />
|
<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>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
|
@ -29,5 +29,14 @@
|
|||||||
<orderEntry type="module" scope="TEST" module-name="solr-core" />
|
<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="analysis-common" />
|
||||||
<orderEntry type="module" scope="TEST" module-name="lucene-core" />
|
<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>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
|
@ -170,74 +170,10 @@ public class ConfigOverlay implements MapSerializable {
|
|||||||
private static final Long INT_NODE = 21L;
|
private static final Long INT_NODE = 21L;
|
||||||
private static final Long FLOAT_ATTR = 30L;
|
private static final Long FLOAT_ATTR = 30L;
|
||||||
private static final Long FLOAT_NODE = 31L;*/
|
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
|
//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
|
// 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 {
|
private static Map editable_prop_map = (Map) Utils.fromJSONResource("EditableSolrConfigAttributes.json");
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isEditableProp(String path, boolean isXpath, List<String> hierarchy) {
|
public static boolean isEditableProp(String path, boolean isXpath, List<String> hierarchy) {
|
||||||
return !(checkEditable(path, isXpath, hierarchy) == null);
|
return !(checkEditable(path, isXpath, hierarchy) == null);
|
||||||
@ -331,6 +267,7 @@ public class ConfigOverlay implements MapSerializable {
|
|||||||
public static final String NAME = "overlay";
|
public static final String NAME = "overlay";
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
System.out.println(Utils.toJSONString(editable_prop_map));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import static java.util.Collections.singleton;
|
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.getListValue;
|
||||||
import static org.apache.solr.handler.admin.SecurityConfHandler.getMapValue;
|
import static org.apache.solr.handler.admin.SecurityConfHandler.getMapValue;
|
||||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
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");
|
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(
|
private static final Map<String, Map<String,Object>> well_known_permissions =
|
||||||
" { " +
|
(Map<String, Map<String, Object>>) fromJSONResource("WellKnownPermissions.json");
|
||||||
" 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]}" +
|
|
||||||
"}");
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
((Map) well_known_permissions.get("collection-admin-edit")).put(Predicate.class.getName(), getCollectionActionPredicate(true));
|
((Map) well_known_permissions.get("collection-admin-edit")).put(Predicate.class.getName(), getCollectionActionPredicate(true));
|
||||||
|
56
solr/core/src/resources/EditableSolrConfigAttributes.json
Normal file
56
solr/core/src/resources/EditableSolrConfigAttributes.json
Normal 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}}
|
||||||
|
}
|
47
solr/core/src/resources/WellKnownPermissions.json
Normal file
47
solr/core/src/resources/WellKnownPermissions.json
Normal 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]}
|
||||||
|
}
|
@ -81,8 +81,7 @@ public class TestSolrConfigHandlerConcurrent extends AbstractFullDistribZkTestBa
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
Map editable_prop_map = (Map) new ObjectBuilder(new JSONParser(new StringReader(
|
Map editable_prop_map = (Map) Utils.fromJSONResource("EditableSolrConfigAttributes.json");
|
||||||
ConfigOverlay.MAPPING))).getObject();
|
|
||||||
Map caches = (Map) editable_prop_map.get("query");
|
Map caches = (Map) editable_prop_map.get("query");
|
||||||
|
|
||||||
setupHarnesses();
|
setupHarnesses();
|
||||||
|
@ -18,6 +18,7 @@ package org.apache.solr.common.util;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.lang.invoke.MethodHandles;
|
import java.lang.invoke.MethodHandles;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
@ -120,6 +121,20 @@ public class Utils {
|
|||||||
return propMap;
|
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) {
|
public static Object fromJSONString(String json) {
|
||||||
try {
|
try {
|
||||||
return new ObjectBuilder(new JSONParser(new StringReader(
|
return new ObjectBuilder(new JSONParser(new StringReader(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user