RolloutExceptionHandlerImpl.java
2.56 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.day.cq.audit.AuditLog
* com.day.cq.audit.AuditLogEntry
* com.day.cq.wcm.msm.api.RolloutExceptionHandler
* com.day.cq.wcm.msm.api.RolloutExceptionHandler$RolloutInfo
* com.day.cq.wcm.msm.api.RolloutManager
* javax.jcr.lock.LockException
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Reference
* org.apache.felix.scr.annotations.Service
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.day.cq.wcm.msm.impl;
import com.day.cq.audit.AuditLog;
import com.day.cq.audit.AuditLogEntry;
import com.day.cq.wcm.msm.api.RolloutExceptionHandler;
import com.day.cq.wcm.msm.api.RolloutManager;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import javax.jcr.lock.LockException;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Component
@Service
public class RolloutExceptionHandlerImpl
implements RolloutExceptionHandler {
private final Logger log;
@Reference
private AuditLog auditLog;
public static final String AUDIT_LOG_CATEGORY = RolloutManager.class.getName();
public static final String AUDIT_LOG_TYPE = "rollout.page.locked";
public RolloutExceptionHandlerImpl() {
this.log = LoggerFactory.getLogger(this.getClass());
}
public boolean handleException(Exception orig, RolloutExceptionHandler.RolloutInfo info) {
boolean result = false;
for (Throwable t = orig; t != null; t = t.getCause()) {
result = t instanceof LockException;
if (!result) continue;
HashMap<String, String> props = new HashMap<String, String>();
props.put("exception", t.toString());
props.put("exceptionMessage", t.getMessage());
props.put("target", info.target);
props.put("operation", info.operation);
this.auditLog.add(new AuditLogEntry(AUDIT_LOG_CATEGORY, new Date(), info.user, info.src, "rollout.page.locked", props));
this.log.info("Exception is (or was caused by) a LockException, info written to AuditLog, rollout can continue", (Throwable)orig);
break;
}
return result;
}
protected void bindAuditLog(AuditLog auditLog) {
this.auditLog = auditLog;
}
protected void unbindAuditLog(AuditLog auditLog) {
if (this.auditLog == auditLog) {
this.auditLog = null;
}
}
}