Tabnine Logo
AuditorAware
Code IndexAdd Tabnine to your IDE (free)

How to use
AuditorAware
in
org.springframework.data.domain

Best Java code snippets using org.springframework.data.domain.AuditorAware (Showing top 8 results out of 315)

origin: eclipse/hawkbit

private void setAssignedDistributionSetAndTargetUpdateStatus(final AbstractDsAssignmentStrategy assignmentStrategy,
    final JpaDistributionSet set, final List<List<Long>> targetIdsChunks) {
  final String currentUser = auditorProvider.getCurrentAuditor().orElse(null);
  assignmentStrategy.updateTargetStatus(set, targetIdsChunks, currentUser);
}
origin: apache/servicemix-bundles

/**
 * Sets modifying and creating auditor. Creating auditor is only set on new auditables.
 *
 * @param auditable
 * @return
 */
private Optional<Object> touchAuditor(AuditableBeanWrapper<?> wrapper, boolean isNew) {
  Assert.notNull(wrapper, "AuditableBeanWrapper must not be null!");
  return auditorAware.map(it -> {
    Optional<?> auditor = it.getCurrentAuditor();
    Assert.notNull(auditor,
        () -> String.format("Auditor must not be null! Returned by: %s!", AopUtils.getTargetClass(it)));
    auditor.filter(__ -> isNew).ifPresent(foo -> wrapper.setCreatedBy(foo));
    auditor.filter(__ -> !isNew || modifyOnCreation).ifPresent(foo -> wrapper.setLastModifiedBy(foo));
    return auditor;
  });
}
origin: hatunet/spring-data-mybatis

/**
 * Sets modifying and creating auditor. Creating auditor is only set on new
 * auditables.
 * @return
 */
private Optional<Object> touchAuditor(AuditableBeanWrapper<?> wrapper,
    boolean isNew) {
  Assert.notNull(wrapper, "AuditableBeanWrapper must not be null!");
  return auditorAware.map(it -> {
    Optional<?> auditor = it.getCurrentAuditor();
    Assert.notNull(auditor,
        () -> String.format("Auditor must not be null! Returned by: %s!",
            AopUtils.getTargetClass(it)));
    auditor.filter(__ -> isNew).ifPresent(foo -> wrapper.setCreatedBy(foo));
    auditor.filter(__ -> !isNew || modifyOnCreation)
        .ifPresent(foo -> wrapper.setLastModifiedBy(foo));
    return auditor;
  });
}
origin: org.eclipse.hawkbit/hawkbit-repository-jpa

@Override
@Transactional
@Retryable(include = {
    ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
public void delete(final Collection<Long> ids) {
  final List<JpaSoftwareModule> swModulesToDelete = softwareModuleRepository.findByIdIn(ids);
  if (swModulesToDelete.size() < ids.size()) {
    throw new EntityNotFoundException(SoftwareModule.class, ids,
        swModulesToDelete.stream().map(SoftwareModule::getId).collect(Collectors.toList()));
  }
  final Set<Long> assignedModuleIds = new HashSet<>();
  swModulesToDelete.forEach(swModule -> {
    // delete binary data of artifacts
    deleteGridFsArtifacts(swModule);
    if (isUnassigned(swModule.getId())) {
      softwareModuleRepository.delete(swModule.getId());
    } else {
      assignedModuleIds.add(swModule.getId());
    }
  });
  if (!assignedModuleIds.isEmpty()) {
    String currentUser = null;
    if (auditorProvider != null) {
      currentUser = auditorProvider.getCurrentAuditor();
    }
    softwareModuleRepository.deleteSoftwareModule(System.currentTimeMillis(), currentUser,
        assignedModuleIds.toArray(new Long[0]));
  }
}
origin: eclipse/hawkbit

@Override
@Transactional
@Retryable(include = {
    ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
public void delete(final Collection<Long> ids) {
  final List<JpaSoftwareModule> swModulesToDelete = softwareModuleRepository.findByIdIn(ids);
  if (swModulesToDelete.size() < ids.size()) {
    throw new EntityNotFoundException(SoftwareModule.class, ids,
        swModulesToDelete.stream().map(SoftwareModule::getId).collect(Collectors.toList()));
  }
  final Set<Long> assignedModuleIds = new HashSet<>();
  swModulesToDelete.forEach(swModule -> {
    // delete binary data of artifacts
    deleteGridFsArtifacts(swModule);
    if (isUnassigned(swModule.getId())) {
      softwareModuleRepository.deleteById(swModule.getId());
    } else {
      assignedModuleIds.add(swModule.getId());
    }
  });
  if (!assignedModuleIds.isEmpty()) {
    String currentUser = null;
    if (auditorProvider != null) {
      currentUser = auditorProvider.getCurrentAuditor().orElse(null);
    }
    softwareModuleRepository.deleteSoftwareModule(System.currentTimeMillis(), currentUser,
        assignedModuleIds.toArray(new Long[0]));
  }
}
origin: com.mmnaseri.utils/spring-data-mock

@SuppressWarnings("unchecked")
@Override
public void onEvent(DataStoreEvent event) {
  if (event instanceof BeforeInsertDataStoreEvent) {
    final Object entity = ((BeforeInsertDataStoreEvent) event).getEntity();
    final Auditable wrapper = getAuditable(entity, event.getRepositoryMetadata());
    wrapper.setCreatedBy(auditorAware == null ? null : auditorAware.getCurrentAuditor());
    wrapper.setCreatedDate(DateTime.now());
  } else if (event instanceof BeforeUpdateDataStoreEvent) {
    final Object entity = ((BeforeUpdateDataStoreEvent) event).getEntity();
    final Auditable wrapper = getAuditable(entity, event.getRepositoryMetadata());
    wrapper.setLastModifiedBy(auditorAware == null ? null : auditorAware.getCurrentAuditor());
    wrapper.setLastModifiedDate(DateTime.now());
  }
}
origin: mmnaseri/spring-data-mock

@SuppressWarnings("unchecked")
@Override
public void onEvent(DataStoreEvent event) {
  if (event instanceof BeforeInsertDataStoreEvent) {
    final Object entity = ((BeforeInsertDataStoreEvent) event).getEntity();
    final Auditable wrapper = getAuditable(entity, event.getRepositoryMetadata());
    wrapper.setCreatedBy(auditorAware == null ? null : auditorAware.getCurrentAuditor());
    wrapper.setCreatedDate(DateTime.now());
  } else if (event instanceof BeforeUpdateDataStoreEvent) {
    final Object entity = ((BeforeUpdateDataStoreEvent) event).getEntity();
    final Auditable wrapper = getAuditable(entity, event.getRepositoryMetadata());
    wrapper.setLastModifiedBy(auditorAware == null ? null : auditorAware.getCurrentAuditor());
    wrapper.setLastModifiedDate(DateTime.now());
  }
}
origin: org.eclipse.hawkbit/hawkbit-repository-jpa

  currentUser = auditorProvider.getCurrentAuditor();
} else {
  currentUser = null;
org.springframework.data.domainAuditorAware

Javadoc

Interface for components that are aware of the application's current auditor. This will be some kind of user mostly.

Most used methods

  • getCurrentAuditor
    Returns the current auditor of the application.

Popular in Java

  • Making http requests using okhttp
  • setScale (BigDecimal)
  • onRequestPermissionsResult (Fragment)
  • getSupportFragmentManager (FragmentActivity)
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • JTextField (javax.swing)
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now