PublishMacro.java
2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.day.cq.replication.ReplicationActionType
* com.scene7.is.catalog.service.publish.atomic.PublishingService
* com.scene7.is.util.ObjectUtil
* javax.jcr.Node
* javax.jcr.RepositoryException
* org.apache.sling.api.resource.Resource
* org.apache.sling.api.resource.ResourceResolver
* scala.Tuple2
*/
package com.adobe.cq.dam.aod.replication.helpers;
import com.adobe.cq.dam.aod.replication.DamLayout;
import com.adobe.cq.dam.aod.replication.helpers.Replicator;
import com.adobe.cq.dam.s7imaging.impl.catalog.JcrModifierList;
import com.day.cq.replication.ReplicationActionType;
import com.scene7.is.catalog.service.publish.atomic.PublishingService;
import com.scene7.is.util.ObjectUtil;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import scala.Tuple2;
class PublishMacro
extends Replicator {
private static Replicator INSTANCE = new PublishMacro();
static Replicator instance() {
return INSTANCE;
}
@Override
void build(ReplicationActionType actionType, ResourceResolver resolver, String path, PublishingService delegate) throws RepositoryException {
Tuple2<String, String> parts = DamLayout.macroParts(path);
String tenantId = (String)parts._1();
String macroName = (String)parts._2();
switch (actionType) {
case DEACTIVATE:
case DELETE: {
delegate.deleteMacro(tenantId, macroName, System.currentTimeMillis());
break;
}
case ACTIVATE: {
Resource resource = (Resource)ObjectUtil.notNull((Object)resolver.getResource(path + "/jcr:content"));
Node node = (Node)ObjectUtil.notNull((Object)resource.adaptTo(Node.class));
String value = JcrModifierList.jcrModifierList(node);
delegate.updateMacro(tenantId, macroName, value, System.currentTimeMillis());
}
}
}
private PublishMacro() {
}
}