ResourceChange
Code IndexAdd Codota to your IDE (free)

Best code snippets using org.apache.sling.api.resource.observation.ResourceChange(Showing top 15 results out of 315)

origin: org.apache.sling/org.apache.sling.rewriter

  @Override
  public void run() {
    if (change.getType() == ChangeType.REMOVED) {
      removeProcessor(configPath);
    } else {
      updateProcessor(configPath);
    }
  }
};
origin: apache/sling

/**
 * Post a change event for a resource provider change
 * @param type The change type
 * @param info The resource provider
 */
private void postResourceProviderChange(final ProviderEvent event) {
  final ObservationReporter or = this.providerReporter;
  if ( or != null ) {
    final ResourceChange change = new ResourceChange(event.isAdd ? ChangeType.PROVIDER_ADDED : ChangeType.PROVIDER_REMOVED,
        event.path, false);
    or.reportChanges(Collections.singletonList(change), false);
  }
}
origin: apache/sling

  @Override
  public String toString() {
    StringBuilder b = new StringBuilder();
    b.append("ResourceChange[type=")
     .append(this.getType())
     .append(", path=")
     .append(this.getPath())
     .append(", external=")
     .append(this.isExternal)
     .append("]");
    return b.toString();
  }
}
origin: org.apache.sling/org.apache.sling.rewriter

@Override
public void run() {
  checkRemoval(change.getPath());
}
origin: stackoverflow.com

 IResourceChangeListener resourceChange = new ResourceChange();

ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChange, IResourceChangeEvent.POST_CHANGE);
origin: apache/sling

  /**
   * Match a change against the configuration
   * @param change The change
   * @param config The configuration
   * @return {@code true} whether it matches
   */
  private boolean matches(final ResourceChange change, final ResourceChangeListenerInfo config) {
    if (!config.getResourceChangeTypes().contains(change.getType()) && !config.getProviderChangeTypes().contains(change.getType())) {
      return false;
    }
    if (!config.isExternal() && change.isExternal()) {
      return false;
    }
    return true;
  }
}
origin: apache/sling

/**
 * Match a change against the configuration
 * @param change The change
 * @param config The configuration
 * @return {@code true} whether it matches
 */
private boolean matches(final ResourceChange change, final ObserverConfiguration config) {
  if (!config.getChangeTypes().contains(change.getType())) {
    return false;
  }
  if (!config.includeExternal() && change.isExternal()) {
    return false;
  }
  if (config.getPaths().matches(change.getPath()) == null ) {
    return false;
  }
  if ( config.getExcludedPaths().matches(change.getPath()) != null ) {
    return false;
  }
  return true;
}
origin: org.apache.sling/org.apache.sling.event

logger.debug("Received event {}", resourceChange);
final String path = resourceChange.getPath();
origin: Adobe-Consulting-Services/acs-aem-tools

public void refresh(String path) {
  if (resourceProviderRegistration != null) {
    // Only execute for non-legacy RP's
    if (getProviderContext() != null) {
      final List<ResourceChange> resourceChangeList = new ArrayList<ResourceChange>();
      final ResourceChange resourceChange = new ResourceChange(
          ResourceChange.ChangeType.CHANGED,
          path,
          false,
          Collections.<String>emptySet(),
          Collections.<String>emptySet(),
          Collections.<String>emptySet()
      );
      resourceChangeList.add(resourceChange);
      getProviderContext().getObservationReporter().reportChanges(resourceChangeList, false);
    } else {
      log.warn("Unable to obtain a Observation Changer for AEM Fiddle script resource provider");
    }
  } else {
     // AEM 6.2 Support - Legacy Sling Resource Provider Implementation
    final Map<String, String> props = Collections.singletonMap(SlingConstants.PROPERTY_PATH, path);
    eventAdmin.sendEvent(new Event(SlingConstants.TOPIC_RESOURCE_CHANGED, props));
  }
}
origin: org.apache.sling/org.apache.sling.event

  /**
   * @see org.apache.sling.api.resource.observation.ResourceChangeListener#onChange(java.util.List)
   */
  @Override
  public void onChange(List<ResourceChange> changes) {
    for(final ResourceChange change : changes ) {
      if ( change.getPath() != null && change.getPath().startsWith(this.configuration.getScheduledJobsPath(true)) ) {
        if ( change.getType() == ResourceChange.ChangeType.REMOVED ) {
          // removal
          logger.debug("Remove scheduled job {}", change.getPath());
          this.scheduledJobHandler.handleRemove(change.getPath());
        } else {
          // add or update
          logger.debug("Add or update scheduled job {}, event {}", change.getPath(), change.getType());
          this.scheduledJobHandler.handleAddUpdate(change.getPath());
        }
      }
    }
  }
}
origin: Adobe-Consulting-Services/acs-aem-samples

if (change.isExternal()) {
switch (change.getType()) {
  case ADDED:
    log.debug("Change Type ADDED: {}", change);
    if (change.getAddedPropertyNames().contains("someProperty")) {
      props.put("path", change.getPath());
      props.put("userId", change.getUserId());
      jobManager.addJob("com/adobe/acs/commons/samples/somePropertyAdded", props);
  case CHANGED:
    log.debug("Change Type CHANGED: {}", change);
    if (change.getChangedPropertyNames().contains("someOtherProperty")) {
origin: org.apache.sling/org.apache.sling.i18n

final Resource resource = resourceResolver.getResource(change.getPath());
if (resource == null) {
  log.trace("Could not get resource for '{}' for event {}", change.getPath(), change.getType());
  return false;
  log.debug("Found new dictionary entry: New {} resource in '{}' detected", JcrResourceBundle.RT_MESSAGE_ENTRY, change.getPath());
  return true;
  log.debug("Found new dictionary entry: New {} resource in '{}' detected", JcrResourceBundle.MIXIN_MESSAGE, change.getPath());
  return true;
if (change.getPath().endsWith(".json")) {
    log.debug("Found new dictionary: New {} resource in '{}' detected", JcrResourceBundle.MIXIN_LANGUAGE, change.getPath());
    return true;
origin: apache/sling

Dictionary<String, Object> props = new Hashtable<String, Object>();
String topic;
switch (change.getType()) {
case ADDED:
  topic = SlingConstants.TOPIC_RESOURCE_ADDED;
props.put(SlingConstants.PROPERTY_PATH, change.getPath());
if (change.getUserId() != null) {
  props.put(SlingConstants.PROPERTY_USERID, change.getUserId());
if (change.getAddedPropertyNames() != null ) {
  props.put(SlingConstants.PROPERTY_ADDED_ATTRIBUTES, change.getAddedPropertyNames().toArray(new String[change.getAddedPropertyNames().size()]));
if (change.getChangedPropertyNames() != null) {
  props.put(SlingConstants.PROPERTY_CHANGED_ATTRIBUTES, change.getChangedPropertyNames().toArray(new String[change.getChangedPropertyNames().size()]));
if ( change.getRemovedPropertyNames() != null ) {
  props.put(SlingConstants.PROPERTY_REMOVED_ATTRIBUTES, change.getRemovedPropertyNames().toArray(new String[change.getRemovedPropertyNames().size()]));
if (change.getType() != ChangeType.REMOVED) {
  Resource resource = resolver.getResource(change.getPath());
  if (resource == null) {
    resolver.refresh();
    resource = resolver.getResource(change.getPath());
if (change.isExternal()) {
  props.put("event.application", "unknown");
origin: org.apache.sling/org.apache.sling.i18n

private void onChange(ResourceChange change) {
  log.trace("handleChange: Detecting change {} for path '{}'", change.getType(), change.getPath());
  if (languageRootPaths.contains(change.getPath())) {
    log.debug(
        "handleChange: Detected change of cached language root '{}', removing all cached ResourceBundles",
        change.getPath());
    scheduleReloadBundles(true);
  } else {
    for (final String root : languageRootPaths) {
      if (change.getPath().startsWith(root)) {
          log.debug("handleChange: Refreshed all affected resource bundles for path '{}'", change.getPath());
          return;
origin: org.apache.sling/org.apache.sling.api

  @Override
  public String toString() {
    StringBuilder b = new StringBuilder();
    b.append("ResourceChange[type=")
     .append(this.getType())
     .append(", path=")
     .append(this.getPath())
     .append(", external=")
     .append(this.isExternal)
     .append("]");
    return b.toString();
  }
}
org.apache.sling.api.resource.observationResourceChange

Javadoc

A resource change event is immutable. A change event can either be local or external. Local changes happened on the same instance, while external changes happened on a different instance. Resource listeners only receive external changes if they mark themselves as a ExternalResourceChangeListener. For all events (local and external), the path and the type of change is set. Resource provider events are always local events and only provide the path. Local events for resources provide the names of the properties that have been added, removed or changed. This information might be missing for external events.

Most used methods

  • getPath
    Get the resource path.
  • getType
    Get the type of change
  • <init>
    Create a new change object
  • getAddedPropertyNames
    Optional information about added properties. The application code can not rely on getting the correc
  • getChangedPropertyNames
    Optional information about changed properties. The application code can not rely on getting the corr
  • getUserId
    Get the user id of the user initiating the change
  • isExternal
    Is this an external event?
  • getRemovedPropertyNames
    Optional information about removed properties. The application code can not rely on getting the corr

Popular classes and methods

  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • notifyDataSetChanged (ArrayAdapter)
  • scheduleAtFixedRate (Timer)
    Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • RandomAccessFile (java.io)
    Saves binary data to the local storage; currently using hex encoding. The string is prefixed with "h
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Permission (java.security)
    Abstract class for representing access to a system resource. All permissions have a name (whose inte
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • BoxLayout (javax.swing)

For IntelliJ IDEA and
Android Studio

  • Codota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutContact Us
  • Terms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)