RegistrationResource.java
1.58 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.sling.api.resource.ResourceResolver
* org.apache.sling.api.resource.SyntheticResource
* org.apache.sling.api.resource.ValueMap
* org.apache.sling.api.wrappers.ValueMapDecorator
*/
package com.adobe.cq.screens.impl.rest;
import com.adobe.cq.screens.device.registration.PendingDevice;
import java.util.HashMap;
import java.util.Map;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.SyntheticResource;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.api.wrappers.ValueMapDecorator;
public class RegistrationResource
extends SyntheticResource {
public static final String RESOURCE_TYPE = "screens/core/components/registration";
private final PendingDevice device;
public RegistrationResource(ResourceResolver resolver, String path, PendingDevice device) {
super(resolver, path, "screens/core/components/registration");
this.device = device;
}
public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
if (type == ValueMap.class) {
HashMap<String, String> map = new HashMap<String, String>();
map.put("token", this.device.getToken());
String code = this.device.getRegistrationCode();
if (code != null) {
map.put("code", code);
}
map.put("state", this.device.getState().name());
return (AdapterType)new ValueMapDecorator(map);
}
return (AdapterType)super.adaptTo(type);
}
}