DPSCollectionImpl.java
3.1 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:
* com.day.cq.wcm.api.Page
* org.apache.sling.api.resource.ValueMap
* org.apache.sling.commons.json.JSONArray
* org.apache.sling.commons.json.JSONException
* org.apache.sling.commons.json.JSONObject
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.cq.mobile.dps.impl.metadata;
import com.adobe.cq.mobile.dps.DPSCollection;
import com.adobe.cq.mobile.dps.impl.metadata.AbstractDPSEntityImpl;
import com.adobe.cq.mobile.dps.impl.utils.MetadataJSONUtil;
import com.day.cq.wcm.api.Page;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.commons.json.JSONArray;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DPSCollectionImpl
extends AbstractDPSEntityImpl
implements DPSCollection {
private static final Logger LOGGER = LoggerFactory.getLogger(DPSCollectionImpl.class);
public DPSCollectionImpl(Page page) {
super(page);
if (!this.getDPSResourceType().equals("dps:Collection")) {
throw new IllegalArgumentException("Underlying page, " + page.getPath() + ", is not a " + "dps:Collection" + ".");
}
}
@Override
public String getProductId() {
return (String)this.page.getProperties().get("dps-productId", String.class);
}
@Override
public String getReadingPosition() {
return (String)this.page.getProperties().get("dps-readingPosition", String.class);
}
@Override
public boolean getEnableHorizontalSwipe() {
return (Boolean)this.page.getProperties().get("dps-horizontalSwipe", (Object)false);
}
@Override
public boolean getAllowDownload() {
return (Boolean)this.page.getProperties().get("dps-allowDownload", (Object)false);
}
@Override
public String getOpenDefault() {
return (String)this.page.getProperties().get("dps-openDefault", String.class);
}
@Override
public String getLayout() {
return (String)this.page.getProperties().get("dps-layout", String.class);
}
@Override
public String getLayoutTitle() {
return (String)this.page.getProperties().get("dps-layoutTitle", String.class);
}
@Override
public JSONObject toJSON() throws JSONException {
return MetadataJSONUtil.getCollectionJSON(this);
}
@Override
public JSONArray getContentLinks() {
JSONArray links = new JSONArray();
try {
String[] jsonStrings = (String[])this.page.getProperties().get("dps-contentLinks", String[].class);
if (jsonStrings != null) {
for (String jsonString : jsonStrings) {
links.put((Object)new JSONObject(jsonString));
}
}
}
catch (JSONException ex) {
LOGGER.error("Failed to load content links for " + this, (Throwable)ex);
}
return links;
}
@Override
public String getBackgroundImagePath() {
return this.getImagePath("./background-image");
}
}