PublishCatalog.java
2.74 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
61
62
63
64
65
66
67
68
69
70
71
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.day.cq.replication.ReplicationActionType
* com.scene7.is.catalog.CatalogAttributes
* com.scene7.is.catalog.CatalogAttributesBean
* com.scene7.is.catalog.service.publish.atomic.PublishingService
* com.scene7.is.util.ObjectUtil
* javax.jcr.RepositoryException
* org.apache.sling.api.resource.Resource
* org.apache.sling.api.resource.ResourceResolver
*/
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.NodeToCatalogConverter;
import com.day.cq.replication.ReplicationActionType;
import com.scene7.is.catalog.CatalogAttributes;
import com.scene7.is.catalog.CatalogAttributesBean;
import com.scene7.is.catalog.service.publish.atomic.PublishingService;
import com.scene7.is.util.ObjectUtil;
import java.util.Collections;
import java.util.Map;
import javax.jcr.RepositoryException;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
final class PublishCatalog
extends Replicator {
private static final Replicator INSTANCE = new PublishCatalog();
static Replicator instance() {
return INSTANCE;
}
@Override
void build(ReplicationActionType actionType, ResourceResolver resolver, String path, PublishingService delegate) throws RepositoryException {
String tenantId = DamLayout.catalogTenantId(path);
switch (actionType) {
case DELETE:
case DEACTIVATE: {
CatalogAttributesBean defaultCatalog = new CatalogAttributesBean(tenantId);
defaultCatalog.setLastModified(Long.valueOf(System.currentTimeMillis()));
delegate.updateCatalog((CatalogAttributes)defaultCatalog);
break;
}
case ACTIVATE: {
Resource resource = (Resource)ObjectUtil.notNull((Object)resolver.getResource(path));
CatalogAttributesBean catalog = PublishCatalog.getCatalog(resource, tenantId);
catalog.setMacros(Collections.emptyMap());
catalog.setLastModified(Long.valueOf(System.currentTimeMillis()));
delegate.updateCatalog((CatalogAttributes)catalog);
break;
}
default: {
throw new AssertionError((Object)("Unexpected action type: " + (Object)actionType));
}
}
}
private static CatalogAttributesBean getCatalog(Resource resource, String rootId) throws RepositoryException {
return (CatalogAttributesBean)NodeToCatalogConverter.toCatalog(resource, rootId);
}
private PublishCatalog() {
}
}