@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(); } }
/** * @see org.apache.sling.api.resource.observation.ResourceChangeListener#onChange(java.util.List) */ @Override public void onChange(final List<ResourceChange> changes) { for(final ResourceChange c : changes) { if ( !c.getPath().startsWith(this.ownRootPathWithSlash) ) { try { this.queue.put(c.getPath()); } catch (final InterruptedException ex) { this.ignoreException(ex); Thread.currentThread().interrupt(); } } } }
/** * @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()); } } } } }
private void onChange(final ChangeStatus status, final ResourceChange change) throws LoginException { log.debug("onChange: Detecting change {} for path '{}'", change.getType(), change.getPath()); if (languageRootPaths.contains(change.getPath())) { log.debug( "onChange: Detected change of cached language root '{}', removing all cached ResourceBundles", change.getPath()); status.reloadAll = true; } else { for (final String root : languageRootPaths) { if (change.getPath().startsWith(root)) {
@Override public void onChange(@NotNull List<ResourceChange> changes) { for (ResourceChange change : changes) { String path = change.getPath(); ResourceChange.ChangeType changeType = change.getType(); switch (changeType) { case CHANGED: if (slyJavaUseMap.containsKey(path)) { slyJavaUseMap.put(path, System.currentTimeMillis()); } break; case REMOVED: if (slyJavaUseMap.containsKey(path)) { slyJavaUseMap.remove(path); } break; default: break; } LOG.debug("Java Use Object {} was {}.", path, changeType.toString()); } } }
private void processChange(ResourceChange change) { String path = change.getPath(); if (isPublish() && (scriptAdded(change) || scriptChanged(change))) { Map<String, Object> eventProperties = ImmutableMap.<String, Object>builder() .put(SlingConstants.PROPERTY_PATH, path) .build(); jobManager.addJob(JOB_NAME, eventProperties); } }
final Resource resource = resolver.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;
private void processChange(ResourceChange change) { String path = change.getPath(); if (isPublish() && (scriptAdded(change) || scriptChanged(change))) { Map<String, Object> eventProperties = ImmutableMap.<String, Object>builder() .put(SlingConstants.PROPERTY_PATH, path) .build(); jobManager.addJob(JOB_NAME, eventProperties); } }
logger.debug("Received event {}", resourceChange); final String path = resourceChange.getPath();
private ResourceChangeListener resourceChangeListener() { return resourceChanges -> { for (final ResourceChange resourceChange : resourceChanges) { if (path.equals(resourceChange.getPath())) { final ChangeType type = resourceChange.getType(); logger.info("change for {} observed: {}", path, type); if (type == ChangeType.ADDED) { unregisterResourcePresence(); registerResourcePresence(); } else if (type == ChangeType.REMOVED) { unregisterResourcePresence(); } } } }; }
props.put("path", change.getPath()); props.put("userId", change.getUserId()); jobManager.addJob("com/adobe/acs/commons/samples/somePropertyAdded", props);
/** * Send the event async via the event admin. */ private void sendEvents(final Monitorable monitorable, final ChangeType changeType, final ObservationReporter reporter) { if (log.isDebugEnabled()) { log.debug("Detected change for resource {} : {}", transformPath(monitorable.path), changeType); } List<ResourceChange> changes = null; for (final ObserverConfiguration config : reporter.getObserverConfigurations()) { if (config.matches(transformPath(monitorable.path))) { if (changes == null) { changes = collectResourceChanges(monitorable, changeType); } if (log.isTraceEnabled()) { for (ResourceChange change : changes) { log.debug("Send change for resource {}: {} to {}", change.getPath(), change.getType(), config); } } } } if (changes != null) { reporter.reportChanges(changes, false); } }
/** * 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; }
props.put(SlingConstants.PROPERTY_PATH, change.getPath()); if (change.getUserId() != null) { props.put(SlingConstants.PROPERTY_USERID, change.getUserId()); Resource resource = resolver.getResource(change.getPath()); if (resource == null) { resolver.refresh(); resource = resolver.getResource(change.getPath());
for(final ResourceChange rc : changes) { final String path = rc.getPath(); log.debug("onChange, type={}, path={}", rc.getType(), path);