Firmware.java
2.82 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
/*************************************************************************
*
* ADOBE CONFIDENTIAL
* __________________
*
* Copyright 2016 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/
package libs.screens.dcc.components.dashboard;
import com.adobe.cq.sightly.WCMUsePojo;
import com.day.cq.search.PredicateGroup;
import com.day.cq.wcm.api.Page;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import com.day.cq.search.Query;
import com.day.cq.search.QueryBuilder;
import javax.jcr.Session;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
public class Firmware extends WCMUsePojo {
private ResourceResolver resolver;
private QueryBuilder queryBuilder;
private Map<String, String> searchProperties;
private List<Page> firmwares;
@Override
public void activate() throws Exception {
resolver = getResourceResolver();
queryBuilder = resolver.adaptTo(QueryBuilder.class);
searchProperties = new HashMap<String, String>();
firmwares = new ArrayList<Page>();
searchProperties.put("path", "/libs/screens/player/content");
searchProperties.put("p.limit", "25");
searchProperties.put("p.offset", "0");
searchProperties.put("group.0_property", "sling:resourceType");
searchProperties.put("group.0_property.value", "screens/player/components/firmware");
searchProperties.put("group.1_property", "sling:resourceSuperType");
searchProperties.put("group.1_property.value", "screens/player/components/firmware");
searchProperties.put("group.p.or", "true");
Query query = queryBuilder.createQuery(PredicateGroup.create(searchProperties), resolver.adaptTo(Session.class));
Iterator<Resource> it = query.getResult().getResources();
while (it.hasNext()) {
Resource firmwareResource = it.next();
Page firmwarePage = firmwareResource.getParent().adaptTo(Page.class);
if (firmwarePage != null) {
firmwares.add(firmwarePage);
}
}
}
/**
* @return List of all available firmwares
*/
public List<Page> getAll() {
return firmwares;
}
}