Skip to content

Commit 4109c6b

Browse files
committed
Remove separate /plugins endpoint. Fixes.
1 parent da2974a commit 4109c6b

14 files changed

Lines changed: 91 additions & 219 deletions

File tree

common/src/main/java/nl/inl/blacklab/webservice/WebserviceOperation.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ public enum WebserviceOperation {
4141
WRITE_INPUT_FORMAT("write-input-format", HttpMethod.POST, BlsPath.INPUT_FORMATS),
4242
DELETE_INPUT_FORMAT("delete-input-format", HttpMethod.DELETE, BlsPath.INPUT_FORMATS),
4343

44-
LIST_PLUGINS("list-plugins", BlsPath.PLUGINS),
45-
4644
ADD_TO_CORPUS("add-to-corpus", HttpMethod.POST, BlsPath.EMPTY),
4745
DELETE_DOCUMENT("delete-document", HttpMethod.DELETE, BlsPath.DOCS),
4846

engine/src/main/java/nl/inl/blacklab/plugins/PluginManager.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ record UnloadedGroovyPlugin(File scriptFile, BLConfigPlugins pluginConfig) {}
169169
QueryFunctionSymbol.class,
170170
QueryFunctionUnion.class
171171
));
172-
QueryExtensions.registerAll(); // register e.g. rspan(), debug functions, etc.
173172
}
174173

175174
public static synchronized void addWebSafePlugins(List<Class<? extends Plugin>> pluginClasses) {
@@ -195,8 +194,8 @@ public static File getPluginsDir() {
195194
}
196195

197196
public static synchronized void addPluginType(Class<? extends Plugin> pluginType) {
198-
pluginTypes.add(pluginType);
199197
URLClassLoader cl = getPluginsDirClassLoader(PluginManager.class.getClassLoader());
198+
pluginTypes.add(pluginType);
200199
pluginsByType.put(pluginType, new PluginsOfType<>(pluginType, BlackLab.config().getPlugins(), cl));
201200
}
202201

@@ -225,6 +224,8 @@ public static synchronized void ensureInitialized() {
225224
pluginsByType.put(pluginClass, new PluginsOfType<>(pluginClass, pluginConfig, cl));
226225
}
227226

227+
QueryExtensions.registerAll(); // register e.g. rspan(), debug functions, etc.
228+
228229
findGroovyScripts(pluginConfig);
229230

230231
// Some plugins take a LONG time to init, if we block, we block the loading of the config
@@ -244,6 +245,7 @@ public static synchronized void ensureInitialized() {
244245
}
245246

246247
private static URLClassLoader getPluginsDirClassLoader(ClassLoader parent) {
248+
ensureInitialized();
247249
List<URL> urlList = new ArrayList<>();
248250
FilenameFilter filenameFilter = (dir, name) -> name.toLowerCase().endsWith(".jar");
249251
File[] files = pluginsDir.listFiles(filenameFilter);

engine/src/main/java/nl/inl/blacklab/search/extensions/XFRelations.java

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import nl.inl.blacklab.search.lucene.SpansAndFilterFactoryUniqueRelations;
3030
import nl.inl.blacklab.search.matchfilter.ConstraintValue;
3131
import nl.inl.blacklab.search.results.QueryInfo;
32-
import nl.inl.blacklab.search.textpattern.TextPattern;
3332
import nl.inl.blacklab.search.textpattern.TextPatternRelationMatch;
3433

3534
/**
@@ -122,22 +121,21 @@ public void register() {
122121
});
123122

124123
// rmatch: Perform an AND operation with the additional requirement that clauses match unique relations.
125-
QueryExtensions.register(new QueryFunction("rmatch", List.of(
126-
PList.optional("queries", PList.Validator.ALL_QUERIES)),
127-
List.of(QueryFunction.VALUE_QUERY_ANY_NGRAM), false) {
128-
@Override
129-
protected TextPattern.EvalResult applyFunc(QueryExecutionContext context, List<Object> parameters) {
130-
if (parameters.isEmpty())
131-
throw new IllegalArgumentException("rmatch() requires one or more queries as arguments");
132-
List<BLSpanQuery> tps = ((List<?>)parameters.get(0)).stream().map(o -> {
133-
if (o instanceof BLSpanQuery p)
134-
return p;
135-
throw new InvalidQuery("Non-query parameter to rmatch(): " + o);
136-
}).toList();
137-
return TextPatternRelationMatch.createRelMatchQuery(context, tps);
124+
QueryExtensions.register(
125+
"rmatch",
126+
List.of(PList.optional("queries", PList.Validator.ALL_QUERIES)),
127+
List.of(QueryFunction.VALUE_QUERY_ANY_NGRAM),
128+
(QueryInfo queryInfo, QueryExecutionContext context, List<Object> parameters) -> {
129+
if (parameters.isEmpty())
130+
throw new IllegalArgumentException("rmatch() requires one or more queries as arguments");
131+
List<BLSpanQuery> tps = ((List<?>)parameters.get(0)).stream().map(o -> {
132+
if (o instanceof BLSpanQuery p)
133+
return p;
134+
throw new InvalidQuery("Non-query parameter to rmatch(): " + o);
135+
}).toList();
136+
return TextPatternRelationMatch.createRelMatchQuery(context, tps);
138137
}
139-
140-
});
138+
);
141139

142140
/*
143141
* rspan: change span mode of a query with an active relation.

server/src/main/java/nl/inl/blacklab/server/BlackLabServer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ protected void doOptions(HttpServletRequest request, HttpServletResponse respons
143143
}
144144

145145
private String optAddAllowOriginHeader(HttpServletResponse responseObject) {
146-
String allowOrigin = BlsMain.get() == null ? "*" :
147-
BlsMain.get().getSearchManager().config().getProtocol().getAccessControlAllowOrigin();
146+
String allowOrigin = BlsMain.getInstance() == null ? "*" :
147+
BlsMain.getInstance().getSearchManager().config().getProtocol().getAccessControlAllowOrigin();
148148
if (allowOrigin != null)
149149
responseObject.addHeader("Access-Control-Allow-Origin", allowOrigin);
150150
return allowOrigin;

server/src/main/java/nl/inl/blacklab/server/requesthandlers/RequestHandler.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,6 @@ public static RequestHandler create(UserRequestBls userRequest, DataFormat outpu
279279
requestHandler = new RequestHandlerCacheInfo(userRequest);
280280
} else if (isInputFormatsRequest) {
281281
requestHandler = new RequestHandlerListInputFormats(userRequest);
282-
} else if (!isNewCorporaEndpoint && indexName.equals(ENDPOINT_PLUGINS)) {
283-
if (resourceOrPathGiven) {
284-
return errorObj.unknownOperation(indexName);
285-
}
286-
requestHandler = new RequestHandlerListPlugins(userRequest);
287282
} else if (!isNewCorporaEndpoint && indexName.equals(ENDPOINT_SHARED_WITH_ME)) {
288283
if (!user.isLoggedIn())
289284
return errorObj.unauthorized("You are not logged in. Log in to see corpora shared with you.");

server/src/main/java/nl/inl/blacklab/server/requesthandlers/RequestHandlerListPlugins.java

Lines changed: 0 additions & 23 deletions
This file was deleted.

site/docs/server/030_rest-api/005_information/010_server-info.md

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Server information
22

3-
List available corpora and general information about the server environment, such as BlackLab version and whether a user is logged-in.
3+
List available corpora and general information about the server environment, such as BlackLab version, available corpora and plugins and whether a user is logged-in.
44

55
**URL**
66
- `/blacklab-server/`
@@ -52,6 +52,8 @@ A server with one corpus named *BaB* and no logged-in user might show this resul
5252
5353
=== API `v5`
5454
55+
(some parts of the response are omitted for brevity)
56+
5557
```jsonc
5658
{
5759
"apiVersion": "5.0",
@@ -73,6 +75,61 @@ A server with one corpus named *BaB* and no logged-in user might show this resul
7375
"loggedIn": false,
7476
"canCreateIndex": false,
7577
"debugMode": false
78+
},
79+
"plugins": {
80+
"FileConverter": {
81+
},
82+
"DocTaskType": {
83+
},
84+
"HitGroupScorerType": {
85+
"coll-dice": {
86+
"params": []
87+
},
88+
"coll-groupsize": {
89+
"params": []
90+
},
91+
"coll-salience": {
92+
"params": []
93+
}
94+
},
95+
"IndexSourceType": {
96+
},
97+
"ProcessingInstruction": [
98+
// ...
99+
],
100+
"QueryFunction": [
101+
"gap": {
102+
"params": [
103+
{
104+
"name": "first",
105+
"type": "matchInfo",
106+
"required": true
107+
},
108+
{
109+
"name": "second",
110+
"type": "matchInfo",
111+
"required": true
112+
},
113+
{
114+
"name": "directional",
115+
"type": "boolean",
116+
"required": false
117+
}
118+
]
119+
},
120+
// ...
121+
],
122+
"QueryParserProvider": [
123+
"corpusql": {
124+
"params": []
125+
},
126+
"contextql": {
127+
"params": []
128+
},
129+
"json-bql": {
130+
"params": []
131+
}
132+
]
76133
}
77134
}
78135
```
@@ -85,4 +142,3 @@ The major differences between API `v4` and `v5` are:
85142

86143
- API `v4` includes both `corpora` and `indices`. API `v5` only has `corpora`, which doesn't include custom properties like `displayName` and `description` unless you specify `custom=true`.
87144
- API `v5` has a `count` object with `tokens` and `documents`, while API `v4` has `tokenCount` and no document count.
88-
- API `v5` includes `plugins` information as well. For the format, see [here](plugins).

site/docs/server/030_rest-api/005_information/080_plugins.md

Lines changed: 0 additions & 134 deletions
This file was deleted.

site/docs/server/030_rest-api/005_information/index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ Endpoints that provide information about the server and corpora.
88
* [Field information](field-info) : `GET /blacklab-server/<corpus-name>/fields/<fieldname>`<br>Information about a (metadata or annotated) field in the corpus, such as a list of values. Also includes spans/relations.
99
* [Span and relation types](relations): `GET /blacklab-server/<corpus-name>/relations`<br>What span and relation types occur in the corpus? (now also available on corpus and field info pages)
1010
* [Schemas](schemas) : `GET /blacklab-server/<corpus-name>/schemas`<br>JSON schemas for (file) formats related to BlackLab.
11-
* [Plugins](plugins) : `GET /blacklab-server/plugins/`<br>Information about available (web-safe) plugins.

solr/src/main/java/org/ivdnt/blacklab/solr/BlackLabSearchComponent.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import nl.inl.blacklab.Constants;
2424
import nl.inl.blacklab.instrumentation.RequestInstrumentationProvider;
2525
import nl.inl.blacklab.search.BlackLabIndex;
26-
import nl.inl.blacklab.server.BlsMain;
2726
import nl.inl.blacklab.server.config.BLSConfig;
2827
import nl.inl.blacklab.server.config.BLSConfigDebug;
2928
import nl.inl.blacklab.server.datastream.DataStream;
@@ -85,9 +84,6 @@ public void inform(SolrCore core) {
8584

8685
BLSConfig config = getConfig(core);
8786

88-
// Before the plugin system is initialized, add our plugin type to it
89-
BlsMain.setUpBlsPlugins();
90-
9187
// Instantiate our search manager from the config
9288
config.setIsSolr(true);
9389
searchManager = new SearchManager(config, false);

0 commit comments

Comments
 (0)