RnCJcrPathBuilder.java
3.82 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.day.cq.workflow.exec.WorkItem
* com.day.cq.workflow.exec.WorkflowData
* com.day.cq.workflow.ui.JcrPayloadPathBuilder
* javax.jcr.Node
* javax.jcr.Session
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Properties
* org.apache.felix.scr.annotations.Property
* org.apache.felix.scr.annotations.Reference
* org.apache.felix.scr.annotations.ReferencePolicy
* org.apache.felix.scr.annotations.Service
* org.apache.sling.jcr.api.SlingRepository
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.aem.formsndocuments.rnc;
import com.adobe.aem.formsndocuments.util.FMConstants;
import com.adobe.aem.formsndocuments.util.FMUtils;
import com.day.cq.workflow.exec.WorkItem;
import com.day.cq.workflow.exec.WorkflowData;
import com.day.cq.workflow.ui.JcrPayloadPathBuilder;
import javax.jcr.Node;
import javax.jcr.Session;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferencePolicy;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.jcr.api.SlingRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Component(metatype=0, immediate=1)
@Service
@Properties(value={@Property(name="service.ranking", intValue={-5})})
public class RnCJcrPathBuilder
implements JcrPayloadPathBuilder {
public static final String TYPE_JCR_PATH = "JCR_PATH";
private static final String GENERIC_FORMS_N_DOCUMENTS_PREFIX = "/aem/formdetails.html";
private static final String FORMSET_PREFIX = "/aem/viewformset.html";
@Reference(policy=ReferencePolicy.STATIC)
private SlingRepository repository;
private static Logger logger = LoggerFactory.getLogger(RnCJcrPathBuilder.class);
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public String buildPath(WorkItem item) {
logger.trace("Entering RncJcrPathBuilder buildPath.");
if (item.getWorkflowData().getPayloadType().equals("JCR_PATH")) {
String path = item.getWorkflowData().getPayload().toString();
logger.trace("Payload Path for RncJcrPathBuilder : " + path);
Session bundleSession = null;
try {
Node assetNode;
if (path.startsWith("/content/dam/formsanddocuments") && (assetNode = (bundleSession = FMUtils.getFnDServiceUserSession(this.repository)).getNode(path)) != null) {
FMConstants.CoreAssetType assetType = FMUtils.getAssetType(bundleSession, path);
if (assetType.equals((Object)FMConstants.CoreAssetType.FORMSET)) {
String string = "/aem/viewformset.html" + path;
return string;
}
if (!assetType.equals((Object)FMConstants.CoreAssetType.NONFMASSET)) {
String string = "/aem/formdetails.html" + path;
return string;
}
}
}
catch (Exception e) {
logger.trace("Error while retrieving type for asset " + path, (Throwable)e);
}
finally {
if (bundleSession != null) {
bundleSession.logout();
}
}
}
logger.trace("Exiting RncJcrPathBuilder buildPath.");
return null;
}
protected void bindRepository(SlingRepository slingRepository) {
this.repository = slingRepository;
}
protected void unbindRepository(SlingRepository slingRepository) {
if (this.repository == slingRepository) {
this.repository = null;
}
}
}