BaseResponse.java 3.23 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.day.jcr.vault.fs.api.ProgressTrackerListener
 *  com.day.jcr.vault.fs.api.ProgressTrackerListener$Mode
 *  javax.servlet.http.HttpServletResponse
 */
package com.day.crx.packaging.impl.response;

import com.day.crx.packaging.impl.RequestWrapper;
import com.day.crx.packaging.impl.response.Response;
import com.day.jcr.vault.fs.api.ProgressTrackerListener;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

public abstract class BaseResponse
implements Response {
    protected RequestWrapper crxRequest;
    protected HttpServletResponse crxResponse;
    protected boolean success = true;
    protected String message = "";
    protected Throwable throwable;
    protected String path = "";
    protected String alertMsg = "";
    protected long startTime;

    @Override
    public void setCRXRequestResponse(RequestWrapper req, HttpServletResponse resp) {
        this.crxRequest = req;
        this.crxResponse = resp;
    }

    @Override
    public RequestWrapper getServletRequest() {
        return this.crxRequest;
    }

    @Override
    public HttpServletResponse getServletResponse() {
        return this.crxResponse;
    }

    @Override
    public void setPath(String path) throws IOException {
        this.path = path;
    }

    @Override
    public void init() throws IOException {
    }

    public void startTimer() {
        this.startTime = System.currentTimeMillis();
    }

    @Override
    public void start(String title) throws IOException {
        this.startTimer();
    }

    protected long getElapsedTime() {
        return System.currentTimeMillis() - this.startTime;
    }

    @Override
    public /* varargs */ void log(String msg, Object ... args) {
    }

    public void setSuccess(boolean success, String message, Throwable t) {
        this.success = success;
        this.message = message;
        this.throwable = t;
    }

    @Override
    public void setAlertMessage(String alertMsg) {
        this.alertMsg = alertMsg;
    }

    @Override
    public void success(String message) throws IOException {
        this.success(message, null);
    }

    @Override
    public void success(String message, String longMessage) throws IOException {
        this.setSuccess(true, message, null);
    }

    @Override
    public void error(String message) throws IOException {
        this.error(message, null);
    }

    @Override
    public void error(String message, Throwable t) throws IOException {
        this.setSuccess(false, message, t);
    }

    public boolean successful() {
        return this.success;
    }

    public void onError(ProgressTrackerListener.Mode mode, String path, Exception e) {
    }

    public void onMessage(ProgressTrackerListener.Mode mode, String action, String path) {
    }

    @Override
    public Response.ShareTracker getTracker(String status, String pid) {
        return new Response.ShareTracker(){

            @Override
            public void onProgress(long progress, long max) {
            }

            @Override
            public void onStatus(String status) {
            }

            @Override
            public void message(String status, String msg) {
            }
        };
    }

}