private ResourceChange buildContentResourceChange(final ChangeType changeType, final String path) { return new ResourceChange(changeType, path, false, null, null, null); }
private boolean fileReplaced(ResourceChange change) { Boolean result = false; Set<String> changedPropertyNames = change.getChangedPropertyNames(); if (changedPropertyNames != null) { result = changedPropertyNames.contains(JcrConstants.JCR_UUID); } return result; }
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()); } } }
/** * 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; }
/** * 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 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); } }
/** * Activate this component. * Register an event handler. */ @Activate protected void activate(final BundleContext bundleContext) { final Dictionary<String, Object> properties = new Hashtable<>(); properties.put(Constants.SERVICE_DESCRIPTION, "Apache Sling Job Topic Manager Event Handler"); properties.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation"); properties.put(ResourceChangeListener.CHANGES, ChangeType.ADDED.toString()); properties.put(ResourceChangeListener.PATHS, this.configuration.getLocalJobsPath()); this.listenerRegistration = bundleContext.registerService(ResourceChangeListener.class, this, properties); }
private int compareChangeTypes(final Set<ChangeType> t, final Set<ChangeType> o) { int result = t.size() - o.size(); if ( result == 0 ) { final Iterator<ChangeType> tIter = t.iterator(); final Iterator<ChangeType> oIter = o.iterator(); while ( result == 0 && tIter.hasNext() ) { result = tIter.next().compareTo(oIter.next()); } } return result; }
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(); } } } }; }
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); } }
IResourceChangeListener resourceChange = new ResourceChange(); ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChange, IResourceChangeEvent.POST_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; }
private boolean scriptVerified(ResourceChange change) { Boolean result = false; Set<String> addedPropertyNames = change.getAddedPropertyNames(); if (addedPropertyNames != null) { result = addedPropertyNames.contains(ScriptContent.CQSM_VERIFIED); } return result; }
/** * 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); } }