Class ResponseUtil


  • public class ResponseUtil
    extends Object
    A basic class for all '/bin/{service}/path/to/resource' servlets.
    • Field Detail

      • JSON_CONTENT_TYPE

        public static final String JSON_CONTENT_TYPE
    • Constructor Detail

      • ResponseUtil

        public ResponseUtil()
    • 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 writer
        node - the JCR node of the referenced resource
        name - the name of the property requested
        Throws:
        javax.jcr.RepositoryException - error on accessing JCR
        IOException - error on write JSON