PayloadMapCache.java
29.4 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.granite.workflow.WorkflowException
* com.adobe.granite.workflow.WorkflowSession
* com.adobe.granite.workflow.collection.ResourceCollection
* com.adobe.granite.workflow.collection.ResourceCollectionManager
* com.adobe.granite.workflow.exec.Workflow
* com.adobe.granite.workflow.exec.Workflow$State
* com.adobe.granite.workflow.exec.WorkflowData
* com.adobe.granite.workflow.model.WorkflowModel
* javax.jcr.Item
* javax.jcr.ItemNotFoundException
* javax.jcr.Node
* javax.jcr.Property
* javax.jcr.RepositoryException
* javax.jcr.Session
* org.apache.felix.scr.annotations.Activate
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Deactivate
* 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.api.adapter.AdapterManager
* org.apache.sling.commons.threads.ThreadPool
* org.apache.sling.commons.threads.ThreadPoolManager
* org.apache.sling.jcr.api.SlingRepository
* org.osgi.service.component.ComponentContext
* org.osgi.service.event.Event
* org.osgi.service.event.EventHandler
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.granite.workflow.core;
import com.adobe.granite.workflow.WorkflowException;
import com.adobe.granite.workflow.WorkflowSession;
import com.adobe.granite.workflow.collection.ResourceCollection;
import com.adobe.granite.workflow.collection.ResourceCollectionManager;
import com.adobe.granite.workflow.core.WorkflowConfig;
import com.adobe.granite.workflow.core.collection.ResourceCollectionUtil;
import com.adobe.granite.workflow.core.exec.WorkflowDataImpl;
import com.adobe.granite.workflow.core.util.ServiceLoginUtil;
import com.adobe.granite.workflow.exec.Workflow;
import com.adobe.granite.workflow.exec.WorkflowData;
import com.adobe.granite.workflow.model.WorkflowModel;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import javax.jcr.Item;
import javax.jcr.ItemNotFoundException;
import javax.jcr.Node;
import javax.jcr.Property;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
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.api.adapter.AdapterManager;
import org.apache.sling.commons.threads.ThreadPool;
import org.apache.sling.commons.threads.ThreadPoolManager;
import org.apache.sling.jcr.api.SlingRepository;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Component(metatype=1, label="Adobe Granite Workflow PayloadMapCache", description="PayloadMap Cache to speedup workflow-related operations")
@Service(value={PayloadMapCache.class, EventHandler.class})
@org.apache.felix.scr.annotations.Property(name="event.topics", value={"com/adobe/granite/workflow/event"}, propertyPrivate=1)
public class PayloadMapCache
implements EventHandler {
private static final Logger log = LoggerFactory.getLogger(PayloadMapCache.class);
@org.apache.felix.scr.annotations.Property(value={"/etc/workflow/models/scheduled_activation/jcr:content/model", "/etc/workflow/models/scheduled_deactivation/jcr:content/model"}, label="%cq.workflow.payload.map.system.workflow.model.name", description="%cq.workflow.payload.map.system.workflow.model.description")
public static final String SYSTEM_WORKFLOW_MODELS = "cq.workflow.payload.map.system.workflow.model";
@org.apache.felix.scr.annotations.Property(value={"/etc/workflow/packages"}, label="%cq.workflow.payload.map.workflow.packages.root.path", description="%cq.workflow.payload.map.workflow.packages.root.path.description")
public static final String WF_PACKAGES_ROOT_PATH = "cq.workflow.payload.map.workflow.packages.root.path";
public static final String THREADPOOL_NAME = "payload-map-cache";
@Reference(policy=ReferencePolicy.STATIC)
private SlingRepository repository;
@Reference(policy=ReferencePolicy.STATIC)
private ResourceCollectionManager rcManager;
@Reference(policy=ReferencePolicy.STATIC)
private AdapterManager adapterManager;
@Reference
WorkflowConfig workflowConfig;
@Reference
private ThreadPoolManager threadPoolManager;
private volatile boolean isInitialized;
private final Map<String, Map<String, String>> cache = new HashMap<String, Map<String, String>>();
private final Map<String, String> systemWorkflowModelsMap = new HashMap<String, String>();
private final Map<String, Set<String>> resourceColls = new HashMap<String, Set<String>>();
private final ReadWriteLock lock = new ReentrantReadWriteLock();
private Set<String> workflowPackageRootPaths;
private String debugCombinedRootPaths;
private ThreadPool threadPool;
public boolean isInWorkflow(String path, boolean excludeSystemWorkflows) {
return this.exists(path, excludeSystemWorkflows);
}
public List<Workflow> getWorkflowInstances(WorkflowSession aUserSession, String path, boolean excludeSystemWorkflows) {
if (this.exists(path, excludeSystemWorkflows)) {
ArrayList<Workflow> list = new ArrayList<Workflow>();
Set<String> instances = this.get(path, excludeSystemWorkflows).keySet();
for (String instance : instances) {
try {
list.add(aUserSession.getWorkflow(instance));
}
catch (WorkflowException we) {
log.warn("Unable to get workflow instance: " + we.getMessage());
}
}
return list;
}
return new ArrayList<Workflow>();
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public void payloadMoved(String sourcePath, String destPath, boolean includeSystemWorflows) throws WorkflowException {
this.lock.writeLock().lock();
try {
WorkflowSession workflowSession = null;
try {
workflowSession = ServiceLoginUtil.getRepositoryReadWorkflowSession(this.repository, this.adapterManager);
String[] payloads = new String[this.cache.keySet().size()];
for (String payload : payloads = this.cache.keySet().toArray(payloads)) {
Map<String, String> instances;
if (!payload.equals(sourcePath) && !payload.startsWith(sourcePath) || (instances = this.cache.get(payload)) == null) continue;
String[] workflowIds = new String[instances.keySet().size()];
for (String workflowId : workflowIds = this.cache.get(payload).keySet().toArray(workflowIds)) {
Workflow instance = workflowSession.getWorkflow(workflowId);
this.index(instance, true, (Session)workflowSession.adaptTo(Session.class));
Session workflowInstanceSession = null;
try {
workflowInstanceSession = ServiceLoginUtil.getWorkflowInstanceDataSession(this.repository);
PayloadMapCache.updatePayload(instance, sourcePath, destPath, workflowInstanceSession);
}
finally {
if (workflowInstanceSession != null && workflowInstanceSession.isLive()) {
workflowInstanceSession.logout();
}
}
instance = workflowSession.getWorkflow(workflowId);
this.index(instance, false, (Session)workflowSession.adaptTo(Session.class));
}
}
}
finally {
workflowSession.logout();
}
}
catch (RepositoryException e) {
throw new WorkflowException(e.getMessage(), (Throwable)e);
}
finally {
this.lock.writeLock().unlock();
}
}
private static void updatePayload(Workflow workflow, String srcPath, String destPath, Session session) throws RepositoryException {
String payloadPath;
String currentPayload;
Node payloadNode;
Node instanceNode;
String instancePath = workflow.getId();
if (session.nodeExists(instancePath) && (instanceNode = session.getNode(instancePath)).hasNode(payloadPath = "data/payload") && ((currentPayload = (payloadNode = instanceNode.getNode(payloadPath)).getProperty("path").getString()).equals(srcPath) || currentPayload.startsWith(srcPath))) {
String newPayload = currentPayload.replace(srcPath, destPath);
payloadNode.getProperty("path").setValue(newPayload);
session.save();
}
}
public void handleEvent(final Event event) {
Runnable task = new Runnable(){
@Override
public void run() {
PayloadMapCache.this.processEvent(event);
}
};
this.threadPool.execute(task);
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public boolean processEvent(Event event) {
log.debug("Received event of topic: " + event.getTopic());
String topic = event.getTopic();
WorkflowSession wfSession = ServiceLoginUtil.getRepositoryReadWorkflowSession(this.repository, this.adapterManager);
try {
if (topic.equals("com/adobe/granite/workflow/event")) {
Object eventType = event.getProperty("EventType");
if (eventType.equals("WorkflowStarted") || eventType.equals("WorkflowResumed")) {
String instanceId = (String)event.getProperty("WorkflowInstanceId");
try {
Workflow instance = wfSession.getWorkflow(instanceId);
this.lock.writeLock().lock();
try {
this.index(instance, false, (Session)wfSession.adaptTo(Session.class));
this.checkResourceCollection(instance, false, (Session)wfSession.adaptTo(Session.class));
}
finally {
this.lock.writeLock().unlock();
}
}
catch (WorkflowException we) {
log.warn("Unable to load workflow instance", (Throwable)we);
}
} else if (eventType.equals("WorkflowAborted") || eventType.equals("WorkflowCompleted") || eventType.equals("WorkflowSuspended")) {
String instanceId = (String)event.getProperty("WorkflowInstanceId");
try {
Workflow instance = wfSession.getWorkflow(instanceId);
this.lock.writeLock().lock();
try {
this.index(instance, true, (Session)wfSession.adaptTo(Session.class));
this.checkResourceCollection(instance, true, (Session)wfSession.adaptTo(Session.class));
}
finally {
this.lock.writeLock().unlock();
}
}
catch (WorkflowException we) {
log.warn("Unable to load workflow instance", (Throwable)we);
}
} else {
if (eventType.equals("ResourceCollectionModified")) {
this.lock.writeLock().lock();
try {
this.handleResourceCollMods(event, wfSession);
}
finally {
this.lock.writeLock().unlock();
}
}
if (eventType.equals("WorkflowPayloadModified")) {
this.lock.writeLock().lock();
try {
String instanceId = (String)event.getProperty("WorkflowInstanceId");
try {
Workflow instance = wfSession.getWorkflow(instanceId);
this.lock.writeLock().lock();
try {
String oldPayloadPath = (String)event.getProperty("oldPayloadPath");
if (instance != null && instance.getWorkflowData() != null && "JCR_PATH".equals(instance.getWorkflowData().getPayloadType()) && instance.getWorkflowData() instanceof WorkflowDataImpl && (oldPayloadPath == null || oldPayloadPath.equals(instance.getWorkflowData().getPayload()))) {
String payloadPath = (String)event.getProperty("payloadPath");
((WorkflowDataImpl)instance.getWorkflowData()).setPayload(payloadPath);
}
this.index(instance, oldPayloadPath, false, (Session)wfSession.adaptTo(Session.class));
this.checkResourceCollection(instance, false, (Session)wfSession.adaptTo(Session.class));
}
finally {
this.lock.writeLock().unlock();
}
}
catch (WorkflowException we) {
log.warn("Unable to load workflow instance", (Throwable)we);
}
}
finally {
this.lock.writeLock().unlock();
}
}
}
}
}
finally {
wfSession.logout();
}
return true;
}
@Activate
protected void activate(ComponentContext context) throws RepositoryException {
this.threadPool = this.threadPoolManager.get("payload-map-cache");
String[] systemWorkflowModels = (String[])context.getProperties().get("cq.workflow.payload.map.system.workflow.model");
String legacyRootPathValue = null;
if (context.getProperties().get("cq.workflow.payload.map.workflow.packages.root.path") != null && (legacyRootPathValue = (String)context.getProperties().get("cq.workflow.payload.map.workflow.packages.root.path")) != null && legacyRootPathValue.trim().length() == 0) {
legacyRootPathValue = null;
}
for (String model : systemWorkflowModels) {
this.systemWorkflowModelsMap.put(model, model);
}
this.workflowPackageRootPaths = this.workflowConfig.getWorkflowPackageRootPaths();
if (legacyRootPathValue != null && !this.workflowPackageRootPaths.contains(legacyRootPathValue)) {
this.workflowPackageRootPaths.add(legacyRootPathValue);
log.warn("Workflow Package root path {} from PayloadMapCache should be configured in the WorkflowConfig component", (Object)legacyRootPathValue);
}
boolean first = true;
StringBuffer tempOutput = new StringBuffer();
for (String path : this.workflowConfig.getWorkflowPackageRootPaths()) {
if (!first) {
tempOutput.append(",");
}
tempOutput.append(path);
first = false;
}
this.debugCombinedRootPaths = tempOutput.toString();
log.debug("Workflow package root path contains: " + this.debugCombinedRootPaths);
this.isInitialized = false;
}
@Deactivate
public void deactivate() {
this.threadPoolManager.release(this.threadPool);
}
private void add(String path, String workflowId, String workflowModelId) {
if (this.cache.containsKey(path)) {
Map<String, String> instanceMap = this.cache.get(path);
instanceMap.put(workflowId, workflowModelId);
log.debug(String.format("updated cache entry for path %s with instance %s for model %s", path, workflowId, workflowModelId));
} else {
HashMap<String, String> instanceMap = new HashMap<String, String>();
instanceMap.put(workflowId, workflowModelId);
this.cache.put(path, instanceMap);
log.debug(String.format("added new cache entry for path %s with instance %s for model %s", path, workflowId, workflowModelId));
}
}
private void remove(String path, String workflowId) {
if (this.cache.containsKey(path)) {
Map<String, String> instanceMap = this.cache.get(path);
instanceMap.remove(workflowId);
log.debug("removed entry for path %s and workflowId %s", (Object)path, (Object)workflowId);
if (instanceMap.size() == 0) {
this.cache.remove(path);
log.debug("removed entry for path %s", (Object)path);
}
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
private boolean exists(String path, boolean excludeSystemWorkflows) {
block6 : {
this.init();
this.lock.readLock().lock();
try {
if (excludeSystemWorkflows) {
if (!this.cache.containsKey(path)) break block6;
Set<String> instances = this.cache.get(path).keySet();
for (String instance : instances) {
if (this.systemWorkflowModelsMap.containsKey(this.cache.get(path).get(instance))) continue;
boolean bl = true;
return bl;
}
break block6;
}
boolean instances = this.cache.containsKey(path);
return instances;
}
finally {
this.lock.readLock().unlock();
}
}
return false;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
private Map<String, String> get(String path, boolean excludeSystemWorkflows) {
this.init();
this.lock.readLock().lock();
try {
if (excludeSystemWorkflows) {
Object instances;
HashMap<String, String> instancesMap = new HashMap<String, String>();
if (this.cache.containsKey(path)) {
instances = this.cache.get(path).keySet();
Iterator i$ = instances.iterator();
while (i$.hasNext()) {
String instance = (String)i$.next();
if (this.systemWorkflowModelsMap.containsKey(this.cache.get(path).get(instance))) continue;
instancesMap.put(instance, this.cache.get(path).get(instance));
}
}
instances = instancesMap;
return instances;
}
Map<String, String> instancesMap = this.cache.get(path);
return instancesMap;
}
finally {
this.lock.readLock().unlock();
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
private void init() {
if (this.isInitialized) {
return;
}
this.lock.writeLock().lock();
WorkflowSession wfSession = null;
try {
wfSession = ServiceLoginUtil.getRepositoryReadWorkflowSession(this.repository, this.adapterManager);
if (this.isInitialized) {
return;
}
try {
long startTime = System.currentTimeMillis();
Workflow[] workflows = wfSession.getWorkflows(new String[]{Workflow.State.RUNNING.name()});
log.info("Getting all running workflows (" + workflows.length + ") for cache population took: " + (System.currentTimeMillis() - startTime) + "ms");
for (Workflow instance : workflows) {
this.index(instance, false, (Session)wfSession.adaptTo(Session.class));
this.checkResourceCollection(instance, false, (Session)wfSession.adaptTo(Session.class));
}
this.isInitialized = true;
long resultingTime = System.currentTimeMillis() - startTime;
log.info("Initial workflow payload cache population took " + resultingTime + "ms");
}
catch (WorkflowException we) {
log.error("Cannot init workflow payload cache", (Throwable)we);
}
}
finally {
if (wfSession != null) {
wfSession.logout();
}
this.lock.writeLock().unlock();
}
}
private void index(Workflow workflow, boolean doRemove, Session admin) {
this.index(workflow, null, doRemove, admin);
}
private void index(Workflow workflow, String oldPayloadPath, boolean doRemove, Session admin) {
try {
WorkflowData data = workflow.getWorkflowData();
String type = data.getPayloadType();
String path = null;
if (type != null) {
if (type.equals("JCR_PATH") && data.getPayload() != null) {
path = (String)data.getPayload();
} else if (data.getPayload() != null && type.equals("JCR_UUID")) {
Node node = admin.getNodeByUUID((String)data.getPayload());
path = node.getPath();
}
}
if (oldPayloadPath != null) {
this.remove(oldPayloadPath, workflow.getId());
}
if (path != null) {
if (doRemove) {
this.remove(path, workflow.getId());
} else {
this.add(path, workflow.getId(), workflow.getWorkflowModel().getId());
}
}
}
catch (ItemNotFoundException infe) {
log.warn("The referenced payload node does not exist: " + infe.getMessage());
}
catch (RepositoryException re) {
log.warn("An error occured while trying to load payload object: " + re.getMessage());
}
catch (Throwable t) {
log.warn("Cannot index " + workflow.getId(), t);
}
}
private void handleResourceCollMods(Event event, WorkflowSession wfAdminSession) {
Session admin = (Session)wfAdminSession.adaptTo(Session.class);
String collectionPath = (String)event.getProperty("Path");
boolean inWf = true;
if (!this.exists(collectionPath, false)) {
try {
ResourceCollection collection = this.rcManager.createCollection((Node)admin.getItem(collectionPath));
Node node = ResourceCollectionUtil.getContainingPage(collection, admin);
if (!this.exists(node.getPath(), false)) {
inWf = false;
}
}
catch (RepositoryException re) {
inWf = false;
}
}
log.debug("ResourceCollection " + collectionPath + "has been modified. " + "The Resource collection is subject of a workflow:" + inWf);
if (inWf) {
try {
ResourceCollection re = this.rcManager.createCollection((Node)admin.getItem(collectionPath));
List<Workflow> instances = this.getWorkflowInstances(wfAdminSession, collectionPath, false);
if (instances.size() == 0) {
Node n = ResourceCollectionUtil.getContainingPage(re, admin);
instances = this.getWorkflowInstances(wfAdminSession, n.getPath(), false);
}
List members = re.list(new String[]{"nt:hierarchyNode"});
HashSet removedSet = new HashSet();
removedSet.addAll(this.resourceColls.get(re.getPath()));
for (Node m2 : members) {
String mPath = m2.getPath();
if (!removedSet.contains(mPath)) continue;
removedSet.remove(mPath);
}
for (Node m2 : members) {
if (this.exists(m2.getPath(), false)) continue;
this.add(m2.getPath(), instances.get(0).getId(), instances.get(0).getWorkflowModel().getId());
}
for (String key : removedSet) {
this.remove(key, instances.get(0).getId());
}
HashSet<String> currentMembers = new HashSet<String>();
for (Node m3 : members) {
currentMembers.add(m3.getPath());
}
this.resourceColls.put(re.getPath(), currentMembers);
}
catch (RepositoryException re) {
log.warn("Cannot update payload cache within a resource collection" + collectionPath);
}
}
}
private void checkResourceCollection(Workflow workflow, boolean doRemove, Session admin) {
WorkflowData data = workflow.getWorkflowData();
String type = data.getPayloadType();
String path = null;
if (type != null && type.equals("JCR_PATH") && data.getPayload() != null) {
path = (String)data.getPayload();
}
try {
if (path != null && this.isWorkflowPackageRootPath(path)) {
Set<String> paths;
if (admin.itemExists(path)) {
ResourceCollection collection = ResourceCollectionUtil.getResourceCollection((Node)admin.getItem(path), this.rcManager);
if (collection != null) {
List members = collection.list(new String[]{"nt:hierarchyNode"});
HashSet<String> resourceList = new HashSet<String>();
for (Node member : members) {
String mPath = member.getPath();
if (doRemove) {
this.remove(mPath, workflow.getId());
continue;
}
this.add(mPath, workflow.getId(), workflow.getWorkflowModel().getId());
resourceList.add(mPath);
}
if (doRemove) {
this.resourceColls.remove(collection.getPath());
} else {
this.resourceColls.put(collection.getPath(), resourceList);
}
}
} else if (doRemove && (paths = this.resourceColls.get(path)) != null) {
for (String collectionEntry : paths) {
this.remove(collectionEntry, workflow.getId());
}
this.resourceColls.remove(path);
}
} else {
log.debug(path + "is either not existing or does not point to the workflow package lookup path: " + this.debugCombinedRootPaths);
}
}
catch (RepositoryException re) {
log.warn("Cannot check payload for a resource collection:" + re.getMessage());
}
}
private boolean isWorkflowPackageRootPath(String path) {
if (path != null) {
for (String rootPath : this.workflowConfig.getWorkflowPackageRootPaths()) {
if (!path.startsWith(rootPath)) continue;
return true;
}
}
return false;
}
protected void bindRepository(SlingRepository slingRepository) {
this.repository = slingRepository;
}
protected void unbindRepository(SlingRepository slingRepository) {
if (this.repository == slingRepository) {
this.repository = null;
}
}
protected void bindRcManager(ResourceCollectionManager resourceCollectionManager) {
this.rcManager = resourceCollectionManager;
}
protected void unbindRcManager(ResourceCollectionManager resourceCollectionManager) {
if (this.rcManager == resourceCollectionManager) {
this.rcManager = null;
}
}
protected void bindAdapterManager(AdapterManager adapterManager) {
this.adapterManager = adapterManager;
}
protected void unbindAdapterManager(AdapterManager adapterManager) {
if (this.adapterManager == adapterManager) {
this.adapterManager = null;
}
}
protected void bindWorkflowConfig(WorkflowConfig workflowConfig) {
this.workflowConfig = workflowConfig;
}
protected void unbindWorkflowConfig(WorkflowConfig workflowConfig) {
if (this.workflowConfig == workflowConfig) {
this.workflowConfig = null;
}
}
protected void bindThreadPoolManager(ThreadPoolManager threadPoolManager) {
this.threadPoolManager = threadPoolManager;
}
protected void unbindThreadPoolManager(ThreadPoolManager threadPoolManager) {
if (this.threadPoolManager == threadPoolManager) {
this.threadPoolManager = null;
}
}
}