package innovimax.mixthem.rest.request;

import innovimax.mixthem.Rule;
import innovimax.mixthem.rest.ErrorResponse;

import javax.ws.rs.core.Response;

import org.glassfish.jersey.media.multipart.FormDataContentDisposition;

public abstract class AbstractParamsCheck {

    private ErrorResponse error = null;
    private Rule rule = null;

    public Response getErrorResponse() {        
        return Response.status(this.error.getCode()).entity(this.error).build();            
    }

    public Rule getRule() {
        return this.rule;
    }

    private void setRule(Rule rule) {
        this.rule = rule;
    }

    protected boolean checkTextMissing(String text) {
        if (text == null || text.trim().equals("")) {
            this.error = RequestErrorResponse.createMissingParamTextError();
            return false;
        }
        return true;
    }

    protected boolean checkFileMissing(FormDataContentDisposition fileDetail) {     
        if (fileDetail.getFileName().equals("")) {
            this.error = RequestErrorResponse.createMissingParamFileError();
            return false;
        }      
        return true;
    }

    protected boolean checkAlternateMode(String mode) {
        if (!AlternateMode.accept(mode)) {
            this.error = RequestErrorResponse.createWrongParamAltModeError();
            return false;
        }
        return true;
    }

    protected boolean checkZipMode(String mode) {
        if (!ZipMode.accept(mode)) {
            this.error = RequestErrorResponse.createWrongParamZipModeError();
            return false;
        }
        return true;
    }

}

@@ -1618,10 +1618,1185 @@
 %0A    %7D%0A%0A
+    protected boolean checkAddRule() %7B%0A        setRule(Rule._ADD);%0A        return true;%0A    %7D%0A%0A    protected boolean checkAlternateRule(String type) %7B%0A        switch (AlternateMode.findByName(type)) %7B%0A            case _CHAR: %0A                setRule(Rule._ALT_CHAR);%0A                break;%0A            default:%0A                setRule(Rule._ALT_LINE);%0A        %7D%0A        return true;%0A    %7D%0A%0A    protected boolean checkRandomAltRule(Integer seed) %7B%0A        setRule(Rule._RANDOM_ALT_LINE);%0A        //TODO set extra param seed%0A        return true;%0A    %7D%0A%0A    protected boolean checkJoinRule(Integer col1, Integer col2) %7B%0A        setRule(Rule._JOIN);%0A        //TODO set extra params col1 & col2%0A        return true;%0A    %7D%0A%0A    protected boolean checkZipRule(String type, String sep) %7B%0A        /*%0A        switch (ZipMode.findByName(type)) %7B%0A            case _CHAR: %0A                setRule(Rule._ZIP_CHAR);%0A                break;%0A            case _CELL: %0A                setRule(Rule._ZIP_CELL);%0A                break;                %0A            default:%0A                setRule(Rule._ZIP_LINE);%0A        %7D%0A        */%0A        //TODO set extra param sep%0A        return true;%0A    %7D%0A%0A
 %7D%0A

Update AbstractParamsCheck.java