CUDAction.java
4.57 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.day.cq.wcm.api.WCMException
* com.day.cq.wcm.msm.api.ActionConfig
* com.day.cq.wcm.msm.api.LiveAction
* com.day.cq.wcm.msm.api.LiveRelationship
* com.day.cq.wcm.msm.commons.BaseAction
* com.day.cq.wcm.msm.commons.BaseActionFactory
* javax.jcr.RepositoryException
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Properties
* org.apache.felix.scr.annotations.Property
* org.apache.felix.scr.annotations.Service
* org.apache.sling.api.resource.Resource
* org.apache.sling.api.resource.ResourceResolver
* org.apache.sling.api.resource.ValueMap
* org.osgi.framework.BundleContext
* org.osgi.framework.ServiceReference
* org.osgi.service.component.ComponentContext
*/
package com.day.cq.wcm.msm.impl.actions;
import com.day.cq.wcm.api.WCMException;
import com.day.cq.wcm.msm.api.ActionConfig;
import com.day.cq.wcm.msm.api.LiveAction;
import com.day.cq.wcm.msm.api.LiveRelationship;
import com.day.cq.wcm.msm.commons.BaseAction;
import com.day.cq.wcm.msm.commons.BaseActionFactory;
import java.util.Arrays;
import javax.jcr.RepositoryException;
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.Service;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ValueMap;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.component.ComponentContext;
@Deprecated
@Component(metatype=0, name="com.day.cq.wcm.msm.impl.actions.CUDAction")
@Service(value={LiveAction.class})
@Properties(value={@Property(name="cq.wcm.msm.action.name", label="%cq.wcm.msm.action.name.label", description="%cq.wcm.msm.action.name.description", value={"updateContent"}), @Property(name="cq.wcm.msm.action.title", label="%cq.wcm.msm.action.title.label", description="%cq.wcm.msm.action.title.description", value={"Create, update, delete and order content"}), @Property(name="cq.wcm.msm.action.rank", label="%cq.wcm.msm.action.rank.label", description="%cq.wcm.msm.action.rank.description", intValue={301}), @Property(name="cq.wcm.msm.action.properties", label="%cq.wcm.msm.action.properties.label", description="%cq.wcm.msm.action.properties.description", value={"status"}), @Property(name="cq.wcm.msm.action.parameter", label="%cq.wcm.msm.action.parameter.label", description="%cq.wcm.msm.action.parameter.description", value={"msm:actionUpdate"})})
public class CUDAction
extends BaseAction {
private BundleContext bundleContext;
public CUDAction() {
super(null, null);
}
protected boolean handles(Resource source, Resource target, LiveRelationship relation, boolean resetRollout) throws RepositoryException, WCMException {
return true;
}
protected void doExecute(Resource source, Resource target, LiveRelationship relation, boolean isResetRollout) throws RepositoryException, WCMException {
try {
ResourceResolver resolver = source == null ? target.getResourceResolver() : source.getResourceResolver();
this.execute("contentcopy", resolver, relation, false, isResetRollout);
this.execute("contentupdate", resolver, relation, false, isResetRollout);
this.execute("contentdelete", resolver, relation, false, isResetRollout);
this.execute("referencesupdate", resolver, relation, false, isResetRollout);
this.execute("ordering", resolver, relation, false, isResetRollout);
}
catch (Exception re) {
throw new WCMException("Error while execute " + this.getName() + " action", (Throwable)re);
}
}
private void execute(String actionType, ResourceResolver resolver, LiveRelationship relation, boolean autoSave, boolean isResetRollout) throws Exception {
Object[] srs = this.bundleContext.getServiceReferences(LiveAction.class.getName(), "(actiontype=" + actionType + ")");
if (srs != null) {
Arrays.sort(srs);
for (Object sr : srs) {
LiveAction la = (LiveAction)this.bundleContext.getService((ServiceReference)sr);
if (la == null) continue;
la.execute(resolver, relation, null, autoSave, isResetRollout);
this.bundleContext.ungetService((ServiceReference)sr);
}
}
}
protected void activate(ComponentContext context) {
this.bundleContext = context.getBundleContext();
}
}