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