001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.runtime.tag; 020 021import lucee.runtime.exp.AbortException; 022import lucee.runtime.exp.ApplicationException; 023import lucee.runtime.exp.PageException; 024import lucee.runtime.ext.tag.TagImpl; 025 026/** 027* Stops processing of a page at the tag location. Lucee returns everything that was processed before the cfabort tag. The cfabort tag is often used with conditional logic to stop processing a page when a condition occurs. 028* 029* 030* 031**/ 032public final class Abort extends TagImpl { 033 034 /** The error to display when cfabort executes. 035 ** The error message displays in the standard CFML error page. */ 036 private String showerror; 037 private int type=lucee.runtime.exp.Abort.SCOPE_REQUEST; 038 039 /** set the value showerror 040 * The error to display when cfabort executes. 041 * The error message displays in the standard CFML error page. 042 * @param showerror value to set 043 **/ 044 public void setShowerror(String showerror) { 045 this.showerror=showerror; 046 } 047 048 049 /** 050 * sets the type of the abort (page,request) 051 * @param type 052 * @throws ApplicationException 053 */ 054 public void setType(String type) throws ApplicationException { 055 type=type.toLowerCase().trim(); 056 if(type.equals("page"))this.type=lucee.runtime.exp.Abort.SCOPE_PAGE; 057 else if(type.equals("request"))this.type=lucee.runtime.exp.Abort.SCOPE_REQUEST; 058 else throw new ApplicationException("attribute type has an invalid value ["+type+"], valid values are [page,request]"); 059 } 060 061 062 @Override 063 public int doStartTag() throws PageException { 064 if(showerror!=null) throw new AbortException(showerror); 065 throw new lucee.runtime.exp.Abort(type); 066 } 067 068 @Override 069 public int doEndTag() { 070 return EVAL_PAGE; 071 } 072 073 @Override 074 public void release() { 075 super.release(); 076 showerror=null; 077 this.type=lucee.runtime.exp.Abort.SCOPE_REQUEST; 078 } 079}