Skip to content

Commit

Permalink
fix api erasing plugininfo and ingest plugins filtering necessary inf…
Browse files Browse the repository at this point in the history
…o out
  • Loading branch information
SugaryLump committed Feb 3, 2025
1 parent a712e74 commit 6338e89
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -409,11 +409,17 @@ public List<PluginInfo> getPluginsInfo(PluginType pluginType) {
}

public PluginInfoList getPluginsInfo(List<PluginType> pluginTypes) {
return getPluginsInfo(pluginTypes, true);
}

public PluginInfoList getPluginsInfo(List<PluginType> pluginTypes, boolean removeNotListable) {
PluginInfoList pluginsInfo = new PluginInfoList();

for (PluginType pluginType : pluginTypes) {
List<PluginInfo> orDefault = pluginInfoPerType.getOrDefault(pluginType, Collections.emptyList());
orDefault.removeIf(p -> p.getCategories().contains(RodaConstants.PLUGIN_CATEGORY_NOT_LISTABLE));
List<PluginInfo> orDefault = new ArrayList<>(pluginInfoPerType.getOrDefault(pluginType, Collections.emptyList()));
if (removeNotListable) {
orDefault.removeIf(p -> p.getCategories().contains(RodaConstants.PLUGIN_CATEGORY_NOT_LISTABLE));
}
pluginsInfo.addObjects(orDefault);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ public ObjectClassFields retrieveObjectClassFields(String localeString) {
}

@Override
public PluginInfoList retrievePluginsInfo(List<PluginType> types) {
public PluginInfoList retrievePluginsInfo(List<PluginType> types, boolean removeNotListable) {
final ControllerAssistant controllerAssistant = new ControllerAssistant() {};
RequestContext requestContext = RequestUtils.parseHTTPRequest(request);
LogEntryState state = LogEntryState.SUCCESS;
try {
controllerAssistant.checkRoles(requestContext.getUser());

return RodaCoreFactory.getPluginManager().getPluginsInfo(types);
return RodaCoreFactory.getPluginManager().getPluginsInfo(types, removeNotListable);
} catch (AuthorizationDeniedException e) {
state = LogEntryState.UNAUTHORIZED;
throw new RESTException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ private void createPermissionTypesLayout() {
private void createPluginSipToAipLayout() {
List<PluginType> plugins = Arrays.asList(PluginType.SIP_TO_AIP);
Services services = new Services("Retrieve plugin information", "get");
services.configurationsResource(s -> s.retrievePluginsInfo(plugins)).whenComplete((pluginInfoList, throwable) -> {
services.configurationsResource(s -> s.retrievePluginsInfo(plugins, false)).whenComplete((pluginInfoList, throwable) -> {
if (throwable == null) {
Label parameterName = new Label(parameter.getName());
layout.add(parameterName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public CreateDefaultJob() {

Services services = new Services("Retrieve plugin information", "get");
pluginTypes.remove(PluginType.INTERNAL);
services.configurationsResource(s -> s.retrievePluginsInfo(pluginTypes))
services.configurationsResource(s -> s.retrievePluginsInfo(pluginTypes, true))
.whenComplete((pluginInfoList, throwable) -> {
if (throwable == null) {
init(pluginInfoList.getPluginInfoList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public CreateSelectedJob(final List<PluginType> pluginType) {
}

Services services = new Services("Retrieve plugin information", "get");
services.configurationsResource(s -> s.retrievePluginsInfo(pluginType))
services.configurationsResource(s -> s.retrievePluginsInfo(pluginType, true))
.whenComplete((pluginInfoList, throwable) -> {
if (throwable == null) {
init(pluginInfoList.getPluginInfoList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ ObjectClassFields retrieveObjectClassFields(
@ApiResponse(responseCode = "200", description = "Returns a set of plugin information", content = @Content(schema = @Schema(implementation = PluginInfoList.class))),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class))),
@ApiResponse(responseCode = "403", description = "Access forbidden", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class)))})
PluginInfoList retrievePluginsInfo(@RequestParam(name = "type") List<PluginType> types);
PluginInfoList retrievePluginsInfo(@RequestParam(name = "type") List<PluginType> types,
@RequestParam(name = "removeNotListable", defaultValue = "true", required = false) boolean removeNotListable);

@RequestMapping(method = RequestMethod.GET, path = "/plugins/reindex", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Retrieves a list of resources that are used by reindex plugins", responses = {
Expand Down

0 comments on commit 6338e89

Please sign in to comment.