ApiEndpointResourceConverter.java
1.57 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:
* com.adobe.reef.siren.Link
* com.adobe.reef.siren.builder.BuilderException
* org.apache.sling.api.resource.Resource
*/
package com.adobe.granite.rest.impl;
import com.adobe.granite.rest.ApiResourceProviderFactory;
import com.adobe.granite.rest.converter.ResourceConverterContext;
import com.adobe.granite.rest.converter.ResourceConverterException;
import com.adobe.granite.rest.converter.siren.AbstractSirenConverter;
import com.adobe.granite.rest.impl.ApiEndpointResource;
import com.adobe.reef.siren.Link;
import com.adobe.reef.siren.builder.BuilderException;
import java.util.Collection;
import java.util.List;
import org.apache.sling.api.resource.Resource;
public class ApiEndpointResourceConverter
extends AbstractSirenConverter {
public ApiEndpointResourceConverter(Resource resource) {
super(resource);
}
@Override
protected String[] getClazz() {
return new String[]{"core/services"};
}
@Override
protected List<Link> getLinks(ResourceConverterContext context) throws BuilderException, ResourceConverterException {
List<Link> links = super.getLinks(context);
if (this.resource instanceof ApiEndpointResource) {
for (ApiResourceProviderFactory factory : ((ApiEndpointResource)this.resource).getProviderFactories()) {
links.add(this.getLink(factory.getContextPath(), this.buildURL(context, this.resource.getPath() + "/" + factory.getContextPath(), ".json"), null));
}
}
return links;
}
}