DevicesResource.java
1.75 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.commons.collections.Predicate
* org.apache.sling.api.resource.Resource
* org.apache.sling.api.resource.ResourceResolver
* org.apache.sling.api.resource.SyntheticResource
*/
package com.adobe.cq.screens.impl.rest;
import com.adobe.cq.screens.device.Device;
import com.adobe.cq.screens.device.impl.DeviceService;
import com.adobe.cq.screens.impl.rest.DeviceResource;
import java.util.Iterator;
import org.apache.commons.collections.Predicate;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.SyntheticResource;
public class DevicesResource
extends SyntheticResource {
public static final String RESOURCE_TYPE = "screens/core/components/devices";
private final DeviceService svc;
public DevicesResource(ResourceResolver resolver, String path, DeviceService svc) {
super(resolver, path, "screens/core/components/devices");
this.svc = svc;
}
public Iterator<Resource> listChildren() {
final Iterator<Device> iter = this.svc.getDevices(this.getResourceResolver(), null);
return new Iterator<Resource>(){
@Override
public boolean hasNext() {
return iter.hasNext();
}
@Override
public Resource next() {
Device device = (Device)iter.next();
return new DeviceResource(DevicesResource.this.getResourceResolver(), DevicesResource.this.getPath() + "/" + device.getId(), device);
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
}