package com.github.dynamicextensionsalfresco.webscripts.resolutions;

import com.github.dynamicextensionsalfresco.webscripts.AnnotationWebScriptRequest;
import com.github.dynamicextensionsalfresco.webscripts.AnnotationWebscriptResponse;

/**
 * @author Laurent Van der Linden
 */
public abstract class JsonResolution implements Resolution {
    public static final String APPLICATION_JSON = "application/json";
    public static final String UTF_8 = "utf-8";

    private int status;

    protected JsonResolution() {
    }

    protected JsonResolution(int status) {
        this.status = status;
    }

    @Override
    public void resolve(AnnotationWebScriptRequest request, AnnotationWebscriptResponse response,
                        ResolutionParameters params) throws Exception {
        response.setContentType(APPLICATION_JSON);
        response.setContentEncoding(UTF_8);
        response.setHeader("Cache-Control", "no-cache");
        response.setStatus(status);
    }
}

@@ -231,16 +231,64 @@
 ponse;%0A%0A
+import javax.servlet.http.HttpServletResponse;%0A%0A
 /**%0A * @
@@ -523,16 +523,44 @@
 t status
+ = HttpServletResponse.SC_OK
 ;%0A%0A    p

set default HTTP status