Permalink
Browse files

initial cut of 6.2 compatibility

  • Loading branch information...
justinedelson committed Jan 20, 2016
1 parent d499bbb commit d633dd4db10dfc20cd19a89ec9aaa4b7819242c9
@@ -105,7 +105,8 @@
</dependency>
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>aem-api</artifactId>
<artifactId>uber-jar</artifactId>
<classifier>apis</classifier>
</dependency>
<dependency>
<groupId>org.twitter4j</groupId>
@@ -257,9 +257,22 @@
<version>1.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-core</artifactId>
<version>2.10.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-imaging</artifactId>
<version>1.0-R1534292</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>aem-api</artifactId>
<artifactId>uber-jar</artifactId>
<classifier>apis</classifier>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
@@ -26,7 +26,6 @@
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;
import org.apache.sling.commons.osgi.PropertiesUtil;
import org.apache.sling.event.EventUtil;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.event.Event;
@@ -246,7 +245,7 @@ protected static Object convertValue(Object val) throws JSONException {
*/
@Override
public void handleEvent(Event event) {
if (EventUtil.isLocal(event) && this.isLoggerEnabled()) {
if (event.getProperty("event.application") == null && this.isLoggerEnabled()) {
logEvent(event);
}
}
@@ -47,8 +47,9 @@
import org.apache.sling.api.resource.ResourceUtil;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.commons.osgi.PropertiesUtil;
import org.apache.sling.event.jobs.JobProcessor;
import org.apache.sling.event.jobs.JobUtil;
import org.apache.sling.event.jobs.Job;
import org.apache.sling.event.jobs.JobManager;
import org.apache.sling.event.jobs.consumer.JobConsumer;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventConstants;
import org.osgi.service.event.EventHandler;
@@ -60,6 +61,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -84,10 +86,16 @@
value = "(" + ReplicationAction.PROPERTY_TYPE + "=ACTIVATE)",
name = EventConstants.EVENT_FILTER,
propertyPrivate = true
),
@Property(
name = JobConsumer.PROPERTY_TOPICS,
value = JcrPackageReplicationStatusEventHandler.JOB_TOPIC
)
})
@Service
public class JcrPackageReplicationStatusEventHandler implements JobProcessor, EventHandler, ClusterAware {
public class JcrPackageReplicationStatusEventHandler implements JobConsumer, EventHandler, ClusterAware {
private static final String PROPERTY_PATHS = "paths";
private static final Logger log = LoggerFactory.getLogger(JcrPackageReplicationStatusEventHandler.class);
private enum ReplicatedAt {
@@ -119,6 +127,8 @@
})
public static final String PROP_REPLICATION_STATUS_NODE_TYPES = "node-types";
protected static final String JOB_TOPIC = "acs-commons/replication/package";
@Reference
private Packaging packaging;
@@ -131,6 +141,9 @@
@Reference
private PackageHelper packageHelper;
@Reference
private JobManager jobManager;
private ResourceResolver adminResourceResolver;
private boolean isMaster = false;
@@ -163,25 +176,25 @@ public final void handleEvent(final Event event) {
if (this.isMaster) {
// Only run on master
final String[] paths = (String[]) event.getProperty("paths");
final String[] paths = (String[]) event.getProperty(PROPERTY_PATHS);
if (this.containsJcrPackagePath(paths) && !CollectionUtils.isEmpty(this.getJcrPackages(paths))) {
JobUtil.processJob(event, this);
jobManager.addJob(JOB_TOPIC, Collections.<String, Object>singletonMap(PROPERTY_PATHS, paths));
}
}
}
@Override
public final boolean process(final Event event) {
final String[] paths = (String[]) event.getProperty("paths");
public final JobResult process(final Job job) {
final String[] paths = (String[]) job.getProperty(PROPERTY_PATHS);
log.debug("Processing Replication Status Update for JCR Package: {}", paths);
final List<JcrPackage> jcrPackages = this.getJcrPackages(paths);
if (CollectionUtils.isEmpty(jcrPackages)) {
log.warn("JCR Package is unavailable for Replication Status Update at: {}", paths);
return true;
return JobResult.OK;
}
for (final JcrPackage jcrPackage : jcrPackages) {
@@ -221,7 +234,7 @@ public final boolean process(final Event event) {
}
}
return true;
return JobResult.OK;
}
/**
@@ -23,7 +23,6 @@
import com.adobe.acs.commons.workflow.synthetic.impl.exceptions.SyntheticCompleteWorkflowException;
import com.adobe.acs.commons.workflow.synthetic.impl.exceptions.SyntheticRestartWorkflowException;
import com.adobe.acs.commons.workflow.synthetic.impl.exceptions.SyntheticTerminateWorkflowException;
import com.day.cq.security.Authorizable;
import com.day.cq.workflow.WorkflowException;
import com.day.cq.workflow.WorkflowService;
import com.day.cq.workflow.WorkflowSession;
@@ -36,6 +35,8 @@
import com.day.cq.workflow.exec.filter.WorkItemFilter;
import com.day.cq.workflow.model.WorkflowModel;
import com.day.cq.workflow.model.WorkflowModelFilter;
import org.apache.jackrabbit.api.security.user.Authorizable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -112,7 +113,6 @@ public final boolean isSuperuser() {
return true;
}
@Deprecated
@Override
public final Authorizable getUser() {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION_MESSAGE);
@@ -289,13 +289,11 @@ public final WorkflowData newWorkflowData(final String payloadType, final Object
return new SyntheticWorkflowData(payloadType, payload);
}
@Deprecated
@Override
public final List<Authorizable> getDelegatees(final WorkItem workItem) throws WorkflowException {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION_MESSAGE);
}
@Deprecated
@Override
public final void delegateWorkItem(final WorkItem workItem, final Authorizable authorizable)
throws WorkflowException {
@@ -11,6 +11,7 @@
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.api.wrappers.ValueMapDecorator;
import org.apache.sling.event.jobs.Job;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -91,10 +92,8 @@ public void testProcess() throws Exception {
final String[] paths = new String[] { packagePath };
final Map<String, Object> map = new HashMap<String, Object>();
map.put("paths", paths);
final Event event = new Event("MOCK", map);
final Job job = mock(Job.class);
when(job.getProperty("paths")).thenReturn(paths);
when(adminResourceResolver.getResource(packagePath)).thenReturn(packageResource);
when(packageResource.adaptTo(Node.class)).thenReturn(packageNode);
@@ -126,7 +125,7 @@ public void testProcess() throws Exception {
when(contentResource3parent.adaptTo(Node.class)).thenReturn(contentNode3parent);
when(contentNode3parent.isNodeType("sling:OrderedFolder")).thenReturn(true);
jcrPackageReplicationStatusEventHandler.process(event);
jcrPackageReplicationStatusEventHandler.process(job);
verify(replicationStatusManager, times(1)).setReplicationStatus(
eq(adminResourceResolver),
@@ -184,7 +184,8 @@
</dependency>
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>aem-api</artifactId>
<artifactId>uber-jar</artifactId>
<classifier>apis</classifier>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
@@ -256,8 +256,9 @@
</dependency>
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>aem-api</artifactId>
<version>6.0.0.1</version>
<artifactId>uber-jar</artifactId>
<version>6.2.0-SNAPSHOT</version>
<classifier>apis</classifier>
<scope>provided</scope>
</dependency>
<dependency>

0 comments on commit d633dd4

Please sign in to comment.