private void getVersionedMetacards( List<Metacard> metacards, final HistoryMetacardImpl.Action action) throws PluginExecutionException { final List<Metacard> versionedMetacards = metacards .stream() .filter( metacard -> !metacard .getMetacardType() .equals(HistoryMetacardImpl.getVersionHistoryMetacardType())) .map(metacard -> new HistoryMetacardImpl(metacard, action, SecurityUtils.getSubject())) .collect(Collectors.toList()); if (versionedMetacards.isEmpty()) { return; } Subject system = Security.getSystemSubject(); if (system == null) { LOGGER.warn("Could not get system subject to create versioned metacards."); return; } system.execute( () -> { this.store(versionedMetacards); return true; }); }
protected Subject getSystemSubject() { return Security.getSystemSubject(); }