ViewerPreset.java
2.02 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.scene7.is.catalog.CatalogRecord
* com.scene7.is.catalog.util.ObjectTypeEnum
* com.scene7.is.provider.UserData
* com.scene7.is.util.callbacks.Option
* javax.jcr.Node
* javax.jcr.RepositoryException
*/
package com.adobe.cq.dam.s7imaging.impl.catalog;
import com.adobe.cq.dam.s7imaging.impl.catalog.Constants;
import com.adobe.cq.dam.s7imaging.impl.catalog.JcrUserData;
import com.adobe.cq.dam.s7imaging.impl.catalog.JcrUtil;
import com.adobe.cq.dam.s7imaging.impl.jcr.props.JcrProps;
import com.adobe.cq.dam.s7imaging.impl.jcr.props.PropKey;
import com.scene7.is.catalog.CatalogRecord;
import com.scene7.is.catalog.util.ObjectTypeEnum;
import com.scene7.is.provider.UserData;
import com.scene7.is.util.callbacks.Option;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
public class ViewerPreset {
private static final String VIEWER_PRESET = "ViewerPreset";
private static final Pattern tenantViewerPreset = Pattern.compile("/etc/dam/(tenants/[^/]+/)?presets/.+");
public static Option<CatalogRecord> viewerPreset(String rootId, String recordId, Node node) throws RepositoryException {
if (ViewerPreset.isViewerPresetPath(node.getPath())) {
for (Node jcrContent : JcrUtil.getNode(node, "jcr:content")) {
if (!Option.some((Object)"ViewerPreset").equals(JcrProps.jcrProps(jcrContent).get(Constants.S7DamType))) continue;
CatalogRecord result = CatalogRecord.catalogRecord((String)rootId, (String)recordId, (ObjectTypeEnum)ObjectTypeEnum.IS);
for (UserData userData : JcrUserData.jcrUserData(jcrContent)) {
result.setUserData(userData);
}
return Option.some((Object)result);
}
}
return Option.none();
}
private static boolean isViewerPresetPath(String path) {
return tenantViewerPreset.matcher(path).matches();
}
}