DurboImportConfigurationProviderService.java
5.27 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.felix.scr.annotations.Activate
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Deactivate
* org.apache.felix.scr.annotations.Modified
* org.apache.felix.scr.annotations.Property
* org.apache.felix.scr.annotations.Service
* org.apache.sling.commons.osgi.PropertiesUtil
* org.osgi.service.component.ComponentContext
*/
package com.day.cq.replication.impl.content.durbo;
import com.day.cq.replication.impl.content.durbo.DurboImportConfiguration;
import com.day.cq.replication.impl.content.durbo.DurboImportConfigurationProvider;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Dictionary;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
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.Modified;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.commons.osgi.PropertiesUtil;
import org.osgi.service.component.ComponentContext;
@Component(metatype=1)
@Service(value={DurboImportConfigurationProvider.class})
public class DurboImportConfigurationProviderService
implements DurboImportConfigurationProvider {
@Property(boolValue={0})
private static final String PRESERVE_HIERARCHYNODES = "preserve.hierarchy.nodes";
@Property(label="Ignore versioning", description="Ignore mix:versionable node type on import", boolValue={0})
private static final String IGNORE_VERSIONING_NODETYPES = "ignore.versioning";
@Property(label="Import ACL", description="Flag to import ACL. Default false", boolValue={0})
private static final String IMPORT_ACL = "import.acl";
@Property(label="Save threshold", description="Number of nodes to import before issuing an intermediate save", intValue={-1})
private static final String SAVE_THRESHOLD = "save.threshold";
@Property(label="Preserve User Paths", description="Flag to preserve user paths when importing user nodes. Default false", boolValue={0})
private static final String PRESERVE_USER_PATHS = "preserve.user.paths";
@Property(label="Preserve UUIDs", description="Flag to preserve jcr:uuid property when importing nodes. Default true", boolValue={1})
private static final String PRESERVE_UUID = "preserve.uuid";
@Property(value={"dam:Asset"}, label="Preserve UUIDs for nodetypes", description="Preserve UUIDs for nodes imported with specified (primary) node-types ONLY")
public static final String PRESERVE_UUID_NODETYPES = "preserve.uuid.nodetypes";
@Property(value={"/content/dam/"}, label="Preserve UUIDs in subtree", description="Preserve UUIDs for nodes imported under specified repository-paths ONLY")
public static final String PRESERVE_UUID_SUBTREE = "preserve.uuid.subtrees";
private DurboImportConfiguration configuration;
@Activate
protected void activate(ComponentContext context) throws Exception {
this.readConfiguration(context);
}
@Modified
protected void modified(ComponentContext context) throws Exception {
this.readConfiguration(context);
}
@Deactivate
protected void deactivate() {
this.configuration = null;
}
private void readConfiguration(ComponentContext context) {
List<String> preservedNodeTypes;
boolean preserveHierarchyNodes = Boolean.valueOf(String.valueOf(context.getProperties().get("preserve.hierarchy.nodes")));
if (preserveHierarchyNodes) {
preservedNodeTypes = new ArrayList(1);
preservedNodeTypes.add("{http://www.jcp.org/jcr/nt/1.0}hierarchyNode");
} else {
preservedNodeTypes = Collections.emptyList();
}
boolean ignoreVersioningNodeTypes = Boolean.valueOf(String.valueOf(context.getProperties().get("ignore.versioning")));
ArrayList<String> ignoredNodeTypes = new ArrayList<String>(1);
if (ignoreVersioningNodeTypes) {
ignoredNodeTypes.add("mix:versionable");
}
boolean importAcl = Boolean.valueOf(String.valueOf(context.getProperties().get("import.acl")));
int saveThreshold = Integer.valueOf(String.valueOf(context.getProperties().get("save.threshold")));
boolean preserveUserPaths = Boolean.valueOf(String.valueOf(context.getProperties().get("preserve.user.paths")));
boolean preserveUUID = Boolean.valueOf(String.valueOf(context.getProperties().get("preserve.uuid")));
HashSet<String> preserveUUIDForNodeTypes = new HashSet<String>(Arrays.asList(PropertiesUtil.toStringArray(context.getProperties().get("preserve.uuid.nodetypes"))));
HashSet<String> preserveUUIDInSubtrees = new HashSet<String>(Arrays.asList(PropertiesUtil.toStringArray(context.getProperties().get("preserve.uuid.subtrees"))));
this.configuration = new DurboImportConfiguration(Collections.<String>emptyList(), preservedNodeTypes, ignoredNodeTypes, importAcl, saveThreshold, preserveUserPaths, preserveUUID, preserveUUIDForNodeTypes, preserveUUIDInSubtrees);
}
@Override
public DurboImportConfiguration getConfiguration() {
return this.configuration;
}
}