FolderResourceConverter.java
2.33 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.granite.rest.converter.ResourceConverter
* com.adobe.granite.rest.converter.ResourceConverterContext
* com.adobe.granite.rest.converter.ResourceConverterException
* com.adobe.granite.rest.converter.siren.AbstractPageableSirenConverter
* com.adobe.reef.siren.Entity
* com.adobe.reef.siren.Link
* com.adobe.reef.siren.builder.BuilderException
* org.apache.sling.api.resource.Resource
* org.slf4j.Logger
*/
package com.adobe.cq.screens.impl.rest;
import com.adobe.cq.screens.impl.rest.FolderResource;
import com.adobe.granite.rest.converter.ResourceConverter;
import com.adobe.granite.rest.converter.ResourceConverterContext;
import com.adobe.granite.rest.converter.ResourceConverterException;
import com.adobe.granite.rest.converter.siren.AbstractPageableSirenConverter;
import com.adobe.reef.siren.Entity;
import com.adobe.reef.siren.Link;
import com.adobe.reef.siren.builder.BuilderException;
import java.util.List;
import org.apache.sling.api.resource.Resource;
import org.slf4j.Logger;
public class FolderResourceConverter
extends AbstractPageableSirenConverter {
public FolderResourceConverter(Resource resource) {
super(resource);
}
protected String[] getClazz() {
return new String[]{"screens/folder"};
}
protected Entity getEntity(ResourceConverterContext context, Resource child) throws ResourceConverterException {
if (child instanceof FolderResource) {
ResourceConverter renderer = (ResourceConverter)child.adaptTo(ResourceConverter.class);
if (renderer != null) {
return (Entity)renderer.toSubEntity(context);
}
this.log.error("Could not adapt FolderResource to ResourceConverter");
}
return null;
}
protected List<Link> getLinks(ResourceConverterContext context) throws BuilderException, ResourceConverterException {
String prevPageURL;
List links = super.getLinks(context);
String nextPageURL = this.getNextPageURL(context);
if (nextPageURL != null) {
links.add(this.getLink("next", nextPageURL, null));
}
if ((prevPageURL = this.getPrevPageURL(context)) != null) {
links.add(this.getLink("prev", prevPageURL, null));
}
return links;
}
}