private ResourceChange buildContentResourceChange(final ChangeType changeType, final String path) { return new ResourceChange(changeType, path, false, null, null, null); }
private boolean scriptVerified(ResourceChange change) { Boolean result = false; Set<String> addedPropertyNames = change.getAddedPropertyNames(); if (addedPropertyNames != null) { result = addedPropertyNames.contains(ScriptContent.CQSM_VERIFIED); } return result; }
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")) {
/** * 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; }
/** * @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(); } } } }
private boolean scriptAdded(ResourceChange change) { return ResourceChange.ChangeType.ADDED.equals(change.getType()) && scriptVerified(change); }
/** * 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; } }
private boolean fileReplaced(ResourceChange change) { Boolean result = false; Set<String> changedPropertyNames = change.getChangedPropertyNames(); if (changedPropertyNames != null) { result = changedPropertyNames.contains(JcrConstants.JCR_UUID); } return result; }
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");
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); } }
private boolean scriptAdded(ResourceChange change) { return ResourceChange.ChangeType.ADDED.equals(change.getType()) && scriptVerified(change); }
private boolean fileReplaced(ResourceChange change) { Boolean result = false; Set<String> changedPropertyNames = change.getChangedPropertyNames(); if (changedPropertyNames != null) { result = changedPropertyNames.contains(JcrConstants.JCR_UUID); } return result; }
/** * @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 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); } }
private boolean scriptChanged(ResourceChange change) { return ResourceChange.ChangeType.CHANGED.equals(change.getType()) && (fileReplaced(change)); }
IResourceChangeListener resourceChange = new ResourceChange(); ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChange, IResourceChangeEvent.POST_CHANGE);
private boolean scriptVerified(ResourceChange change) { Boolean result = false; Set<String> addedPropertyNames = change.getAddedPropertyNames(); if (addedPropertyNames != null) { result = addedPropertyNames.contains(ScriptContent.CQSM_VERIFIED); } return result; }
@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()); } } }
logger.debug("Received event {}", resourceChange); final String path = resourceChange.getPath();