Package com.composum.sling.core.util
Class ResponseUtil
- java.lang.Object
-
- com.composum.sling.core.util.ResponseUtil
-
public class ResponseUtil extends Object
A basic class for all '/bin/{service}/path/to/resource' servlets.
-
-
Field Summary
Fields Modifier and Type Field Description static String
JSON_CONTENT_TYPE
-
Constructor Summary
Constructors Constructor Description ResponseUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static MappingRules
getDefaultJsonMapping()
the default rule set for general import an export featuresstatic com.google.gson.stream.JsonWriter
getJsonWriter(org.apache.sling.api.SlingHttpServletResponse response)
static String
getMessage(Throwable ex)
static void
writeEmptyArray(org.apache.sling.api.SlingHttpServletResponse response)
static void
writeEmptyObject(org.apache.sling.api.SlingHttpServletResponse response)
static void
writeJsonProperty(@NotNull org.apache.sling.api.resource.Resource resource, @NotNull org.apache.sling.api.SlingHttpServletResponse response, @NotNull javax.jcr.Node node, @NotNull String name)
Write one JCR property as JSON object back using the writer of the response (used for GET and PUT).
-
-
-
Field Detail
-
JSON_CONTENT_TYPE
public static final String JSON_CONTENT_TYPE
-
-
Method Detail
-
getDefaultJsonMapping
public static MappingRules getDefaultJsonMapping()
the default rule set for general import an export features
-
getJsonWriter
public static com.google.gson.stream.JsonWriter getJsonWriter(org.apache.sling.api.SlingHttpServletResponse response) throws IOException
- Throws:
IOException
-
writeEmptyObject
public static void writeEmptyObject(org.apache.sling.api.SlingHttpServletResponse response) throws IOException
- Throws:
IOException
-
writeEmptyArray
public static void writeEmptyArray(org.apache.sling.api.SlingHttpServletResponse response) throws IOException
- Throws:
IOException
-
writeJsonProperty
public static void writeJsonProperty(@NotNull @NotNull org.apache.sling.api.resource.Resource resource, @NotNull @NotNull org.apache.sling.api.SlingHttpServletResponse response, @NotNull @NotNull javax.jcr.Node node, @NotNull @NotNull String name) throws javax.jcr.RepositoryException, IOException
Write one JCR property as JSON object back using the writer of the response (used for GET and PUT).- Parameters:
response
- the HTTP response with the writernode
- the JCR node of the referenced resourcename
- the name of the property requested- Throws:
javax.jcr.RepositoryException
- error on accessing JCRIOException
- error on write JSON
-
-