Пример #1
0
  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;
        });
  }
Пример #2
0
 @Override
 public CreateRequest process(CreateRequest input)
     throws PluginExecutionException, StopProcessingException {
   List<Metacard> updatedMetacardList =
       input
           .getMetacards()
           .stream()
           .filter(
               m ->
                   !HistoryMetacardImpl.getVersionHistoryMetacardType()
                       .equals(m.getMetacardType()))
           .map(
               m ->
                   new HistoryMetacardImpl(
                       m, HistoryMetacardImpl.Action.CREATED, SecurityUtils.getSubject()))
           .collect(Collectors.toList());
   updatedMetacardList.addAll(input.getMetacards());
   return new CreateRequestImpl(updatedMetacardList, input.getProperties());
 }