@Override public DeleteResponse processPostDelete(DeleteResponse input) throws StopProcessingException { if (input.getRequest() == null || input.getRequest().getProperties() == null) { throw new StopProcessingException( "Unable to filter contents of current message, no user Subject available."); } Subject subject = getSubject(input); List<Metacard> results = input.getDeletedMetacards(); List<Metacard> newResults = new ArrayList<>(results.size()); KeyValueCollectionPermission securityPermission = new KeyValueCollectionPermission(CollectionPermission.READ_ACTION); int filteredMetacards = 0; for (Metacard metacard : results) { Attribute attr = metacard.getAttribute(Metacard.SECURITY); if (!checkPermissions(attr, securityPermission, subject, CollectionPermission.READ_ACTION)) { for (FilterStrategy filterStrategy : filterStrategies.values()) { FilterResult filterResult = filterStrategy.process(input, metacard); if (filterResult.processed()) { if (filterResult.metacard() != null) { newResults.add(filterResult.metacard()); } break; // returned responses are ignored for deletes } } filteredMetacards++; } else { newResults.add(metacard); } } LOGGER.info("Filtered {} metacards, returned {}", filteredMetacards, newResults.size()); SecurityLogger.logInfo( "Filtered " + filteredMetacards + " metacards, returned " + newResults.size()); input.getDeletedMetacards().clear(); input.getDeletedMetacards().addAll(newResults); newResults.clear(); return input; }
@Override public DeleteResponse process(DeleteResponse input) throws PluginExecutionException { getVersionedMetacards(input.getDeletedMetacards(), HistoryMetacardImpl.Action.DELETED); return input; }