RenditionsResourceConverter.java
2.74 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
64
/*
* 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.Action
* com.adobe.reef.siren.Action$Method
* com.adobe.reef.siren.Entity
* com.adobe.reef.siren.Field
* com.adobe.reef.siren.Field$FieldType
* com.adobe.reef.siren.builder.ActionBuilder
* com.adobe.reef.siren.builder.BuilderException
* com.adobe.reef.siren.builder.FieldBuilder
* org.apache.sling.api.resource.Resource
* org.slf4j.Logger
*/
package com.adobe.granite.rest.assets.impl;
import com.adobe.granite.rest.assets.impl.RenditionResource;
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.Action;
import com.adobe.reef.siren.Entity;
import com.adobe.reef.siren.Field;
import com.adobe.reef.siren.builder.ActionBuilder;
import com.adobe.reef.siren.builder.BuilderException;
import com.adobe.reef.siren.builder.FieldBuilder;
import java.util.List;
import org.apache.sling.api.resource.Resource;
import org.slf4j.Logger;
public class RenditionsResourceConverter
extends AbstractPageableSirenConverter {
public RenditionsResourceConverter(Resource resource) {
super(resource);
}
protected String[] getClazz() {
return new String[]{"assets/asset/renditions"};
}
protected Entity getEntity(ResourceConverterContext context, Resource child) throws ResourceConverterException {
if (child instanceof RenditionResource) {
ResourceConverter converter = (ResourceConverter)child.adaptTo(ResourceConverter.class);
if (converter != null) {
return (Entity)converter.toSubEntity(context);
}
this.log.error("Could not adapt RenditionResource to ResourceConverter");
}
return null;
}
protected List<Action> getActions(ResourceConverterContext context) throws BuilderException, ResourceConverterException {
List actions = super.getActions(context);
actions.add(new ActionBuilder().setName("add-rendition").setHref(this.buildURL(context, this.resource.getPath() + "/renditions/*", null)).setMethod(Action.Method.POST).setTitle("Add Rendition").addField((Field)new FieldBuilder().setName("name").build()).addField((Field)new FieldBuilder().setName("file").setType(Field.FieldType.FILE).build()).build());
return actions;
}
}