diff --git a/bundle/src/main/java/com/adobe/acs/commons/wcm/notifications/impl/SystemNotificationsImpl.java b/bundle/src/main/java/com/adobe/acs/commons/wcm/notifications/impl/SystemNotificationsImpl.java index f602c09227..44c61f8c1f 100644 --- a/bundle/src/main/java/com/adobe/acs/commons/wcm/notifications/impl/SystemNotificationsImpl.java +++ b/bundle/src/main/java/com/adobe/acs/commons/wcm/notifications/impl/SystemNotificationsImpl.java @@ -58,9 +58,11 @@ import java.io.PrintWriter; import java.util.ArrayList; import java.util.Calendar; +import java.util.Collections; import java.util.Hashtable; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; @Component(immediate = true) @@ -78,6 +80,8 @@ public class SystemNotificationsImpl extends AbstractHtmlRequestInjector impleme private static final String PN_ENABLED = "enabled"; + private static final String REP_POLICY = "rep:policy"; + private static final String INJECT_TEXT = ""; + private static final String SERVICE_NAME = "system-notifications"; + private static final Map AUTH_INFO; + static { + AUTH_INFO = Collections.singletonMap(ResourceResolverFactory.SUBSERVICE, (Object) SERVICE_NAME); + } + private AtomicBoolean isFilter = new AtomicBoolean(false); private ComponentContext osgiComponentContext; @@ -194,7 +204,8 @@ public String getMessage(String message, String onTime, String offTime) { private boolean isActiveNotification(final SlingHttpServletRequest request, final Resource resource) { - if (JcrConstants.JCR_CONTENT.equals(resource.getName())) { + if (JcrConstants.JCR_CONTENT.equals(resource.getName()) || + REP_POLICY.equals(resource.getName())) { return false; } @@ -255,19 +266,20 @@ private boolean hasNotifications() { ResourceResolver resourceResolver = null; try { - resourceResolver = resourceResolverFactory.getAdministrativeResourceResolver(null); + resourceResolver = resourceResolverFactory.getServiceResourceResolver(AUTH_INFO); final Resource notificationsFolder = resourceResolver.getResource(PATH_NOTIFICATIONS); final Iterator resources = notificationsFolder.listChildren(); while (resources.hasNext()) { final Resource resource = resources.next(); - if (!JcrConstants.JCR_CONTENT.equals(resource.getName())) { + if (!JcrConstants.JCR_CONTENT.equals(resource.getName()) && + !REP_POLICY.equals(resource.getName())) { return true; } } } catch (LoginException e) { - log.error("Could not get an admin ResourceResolver", e); + log.error("Could not get an service ResourceResolver", e); } finally { if (resourceResolver != null) { resourceResolver.close(); @@ -320,25 +332,14 @@ public void handleEvent(final Event event) { return; } - ResourceResolver resourceResolver = null; - try { - resourceResolver = resourceResolverFactory.getAdministrativeResourceResolver(null); - - if (this.hasNotifications()) { - if (!this.isFilter.getAndSet(true)) { - this.registerAsFilter(); - } - } else { - if (this.isFilter.getAndSet(false)) { - this.unregisterFilter(); - log.debug("Unregistered System Notifications Sling Filter"); - } + if (this.hasNotifications()) { + if (!this.isFilter.getAndSet(true)) { + this.registerAsFilter(); } - } catch (LoginException e) { - log.error("Could not get an admin ResourceResolver", e); - } finally { - if (resourceResolver != null) { - resourceResolver.close(); + } else { + if (this.isFilter.getAndSet(false)) { + this.unregisterFilter(); + log.debug("Unregistered System Notifications Sling Filter"); } } diff --git a/content/src/main/content/jcr_root/apps/acs-commons/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-acs-commons.xml b/content/src/main/content/jcr_root/apps/acs-commons/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-acs-commons.xml index deb79d9273..e79150bffd 100644 --- a/content/src/main/content/jcr_root/apps/acs-commons/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-acs-commons.xml +++ b/content/src/main/content/jcr_root/apps/acs-commons/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-acs-commons.xml @@ -1,4 +1,4 @@ + user.mapping="[com.adobe.acs.acs-aem-commons-bundle:ensure-oak-index=acs-commons-ensure-oak-index-service,com.adobe.acs.acs-aem-commons-bundle:email-service=acs-commons-email-service,com.adobe.acs.acs-aem-commons-bundle:review-task-asset-mover=acs-commons-review-task-asset-mover-service,com.adobe.acs.acs-aem-commons-bundle:error-page-handler=acs-commons-error-page-handler-service,com.adobe.acs.acs-aem-commons-bundle:form-helper=acs-commons-form-helper-service,com.adobe.acs.acs-aem-commons-bundle:dispatcher-flush=acs-commons-dispatcher-flush-service,com.adobe.acs.acs-aem-commons-bundle:package-replication-status-event-listener=acs-commons-package-replication-status-event-service,com.adobe.acs.acs-aem-commons-bundle:component-error-handler=acs-commons-component-error-handler-service,com.adobe.acs.acs-aem-commons-bundle:system-notifications=acs-commons-system-notifications-service]"/> diff --git a/content/src/main/content/jcr_root/etc/acs-commons/notifications/_rep_policy.xml b/content/src/main/content/jcr_root/etc/acs-commons/notifications/_rep_policy.xml new file mode 100644 index 0000000000..9dd3de388d --- /dev/null +++ b/content/src/main/content/jcr_root/etc/acs-commons/notifications/_rep_policy.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/content/src/main/content/jcr_root/home/users/system/acs-commons/system-notifications/.content.xml b/content/src/main/content/jcr_root/home/users/system/acs-commons/system-notifications/.content.xml new file mode 100644 index 0000000000..6bcd2856b9 --- /dev/null +++ b/content/src/main/content/jcr_root/home/users/system/acs-commons/system-notifications/.content.xml @@ -0,0 +1,6 @@ + + diff --git a/generate-user-uuid.groovy b/generate-user-uuid.groovy new file mode 100755 index 0000000000..4921731b38 --- /dev/null +++ b/generate-user-uuid.groovy @@ -0,0 +1,8 @@ +#!/usr/bin/env groovy + +if (this.args.length != 1) { + System.err.println("[ERROR] Must provide a userId") + return +} + +println java.util.UUID.nameUUIDFromBytes(this.args[0].getBytes("UTF-8")).toString(); \ No newline at end of file