PutRequest.java
1.6 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.sling.api.SlingHttpServletRequest
* org.apache.sling.api.resource.Resource
* org.apache.sling.api.resource.ResourceUtil
* org.apache.sling.servlets.post.Modification
* org.apache.sling.servlets.post.PostResponse
*/
package com.adobe.granite.rest.impl.servlet;
import com.adobe.granite.rest.RequestException;
import com.adobe.granite.rest.impl.servlet.ModifyingRequest;
import java.util.List;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceUtil;
import org.apache.sling.servlets.post.Modification;
import org.apache.sling.servlets.post.PostResponse;
public class PutRequest
extends ModifyingRequest {
@Override
protected void doHandle(SlingHttpServletRequest request, PostResponse response, List<Modification> changes) throws UnsupportedOperationException, RequestException, Exception {
Resource resource = request.getResource();
if (this.isMultipartRequest(request)) {
throw new RequestException(400, "PUT does not support requests of type multipart/data.");
}
if (ResourceUtil.isNonExistingResource((Resource)resource)) {
throw new RequestException(404, "No resource found at " + resource.getPath());
}
Resource updatedResource = this.createOrModifyResource(request, changes);
changes.add(Modification.onModified((String)updatedResource.getPath()));
response.setLocation(this.externalizePath(request, updatedResource.getPath()));
}
}