Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
micstriit committed Nov 7, 2012
1 parent 7741b21 commit 0dc0d8f
Show file tree
Hide file tree
Showing 14 changed files with 550 additions and 249 deletions.
4 changes: 4 additions & 0 deletions railo-cfml/railo-admin/admin/resources/language/de.xml
Expand Up @@ -573,6 +573,10 @@ sct[""bracketNotation""] --> keyname: "bracketNotation"</data>
<data key="setting.showversiondescription">Railo Version im Response Header zurückgeben</data>
<data key="setting.allowCompression">Kompression</data>
<data key="setting.allowCompressionDescription">Kompression (GZip) für den Response Stream einschalten, sofern dies vom Client (Browser) unterstützt ist</data>
<data key="setting.cfmlWriterReg">Kein white space management</data>
<data key="setting.cfmlWriterWS">Einfaches white space management, jeder white space welcher einem white space folgt witd ignoriert</data>
<data key="setting.cfmlWriterWSPref">Schlaues whitespace management, analog zu einfachem whitespace management, aber ignoriert zusätzlich white spaces in den folgenden Tags: code, pre and textarea</data>

<data key="setting.componentcache">Komponentenpfad Cache</data>
<data key="setting.ctcache">Custom Tag Pfad Cache</data>
<data key="setting.inspecttemplateneverShort">Nie</data>
Expand Down
4 changes: 4 additions & 0 deletions railo-cfml/railo-admin/admin/resources/language/en.xml
Expand Up @@ -636,6 +636,10 @@ sct[""bracketNotation""] --> keyname: "bracketNotation"</data>
<data key="setting.showversiondescription">Return the Railo version in the response header</data>
<data key="setting.allowCompression">Compression</data>
<data key="setting.allowCompressionDescription">Enable compression (Gzip) for the Railo Response stream, if supported by the client (Browser)</data>

<data key="setting.cfmlWriterReg">No white space management</data>
<data key="setting.cfmlWriterWS">Simple white space management, every whitespace following a whitespace is removed</data>
<data key="setting.cfmlWriterWSPref">Smart whitespace management, same as the simple one, but ignore spaces inside the tags: code, pre and textarea</data>
<data key="setting.server">Railo output control</data>
<data key="setting.inspecttemplatealwaysdesc">When checked, any requested files found to currently reside in the template cache will always be inspected for potential updates. For sites where templates are updated during the life of the server or within request.</data>
<data key="setting.querycacheclearcount">Clear query cache ( {count} element(s) )</data>
Expand Down
20 changes: 14 additions & 6 deletions railo-cfml/railo-admin/admin/server.output.cfm
Expand Up @@ -33,7 +33,7 @@ Defaults --->
type="#request.adminType#"
password="#session["password"&request.adminType]#"

suppressWhiteSpace="#isDefined('form.suppressWhitespace') and form.suppressWhitespace#"
cfmlWriter="#form.cfmlWriter#"
suppressContent="#isDefined('form.suppressContent') and form.suppressContent#"
allowCompression="#isDefined('form.allowCompression') and form.allowCompression#"
contentLength=""
Expand All @@ -48,7 +48,7 @@ Defaults --->
type="#request.adminType#"
password="#session["password"&request.adminType]#"

suppressWhiteSpace=""
cfmlWriter=""
suppressContent=""
showVersion=""
allowCompression=""
Expand Down Expand Up @@ -92,13 +92,21 @@ Redirtect to entry --->
<tr>
<th scope="row">#stText.setting.whitespace#</th>
<td>
<cfset desc={
'regular':stText.setting.cfmlWriterReg,
'white-space':stText.setting.cfmlWriterWS,
'white-space-pref':stText.setting.cfmlWriterWSPref
}>

<cfif hasAccess>
<input type="checkbox" name="suppressWhitespace" class="checkbox" value="true" <cfif setting.suppressWhitespace>checked="checked"</cfif>>
<cfloop list="regular,white-space,white-space-pref" index="k">
<input type="radio" class="checkbox" name="cfmlWriter" value="#k#" <cfif setting.cfmlWriter EQ k>checked="checked"</cfif>>
<div class="comment">#desc[k]#</div><br>
</cfloop>
<cfelse>
<b>#yesNoFormat(setting.suppressWhitespace)#</b>
<!---<input type="hidden" name="suppressWhitespace" value="#setting.suppressWhitespace#">--->
<b>#desc[setting.cfmlWriter]#
<input type="hidden" name="cfmlWriter" value="#setting.cfmlWriter#">
</cfif>
<div class="comment">#stText.setting.whitespaceDescription#</div>
</td>
</tr>
<!--- Allow Compression --->
Expand Down
Expand Up @@ -8,6 +8,7 @@
import railo.runtime.writer.CFMLWriter;
import railo.runtime.writer.CFMLWriterImpl;
import railo.runtime.writer.CFMLWriterWhiteSpace;
import railo.runtime.writer.CFMLWriterWhiteSpacePref;
import railo.runtime.writer.DevNullBodyContent;

/**
Expand All @@ -34,12 +35,8 @@ public BodyContentStack() {
* initialize the BodyContentStack
* @param rsp
*/
public void init(HttpServletRequest req, HttpServletResponse rsp, boolean suppresswhitespace, boolean closeConn, boolean showVersion, boolean contentLength,boolean allowCompression) {
// this.base=new JSPWriterWhiteSpace(rsp,-1,false);
if(suppresswhitespace)
this.base=new CFMLWriterWhiteSpace(req,rsp,-1,false,closeConn,showVersion,contentLength,allowCompression);
else
this.base=new CFMLWriterImpl(req,rsp,-1,false,closeConn,showVersion,contentLength,allowCompression);
public void init(CFMLWriter writer) {
this.base=writer;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions railo-java/railo-core/src/railo/runtime/PageContextImpl.java
Expand Up @@ -423,7 +423,7 @@ public PageContextImpl initialize(
this.servlet=servlet;

// Writers
bodyContentStack.init(req,rsp,config.isSuppressWhitespace(),config.closeConnection(),config.isShowVersion(),config.contentLength(),config.allowCompression());
bodyContentStack.init(config.getCFMLWriter(req,rsp));
writer=bodyContentStack.getWriter();
forceWriter=writer;

Expand Down Expand Up @@ -898,8 +898,8 @@ public synchronized void copyStateTo(PageContextImpl other) {
other.undefined=new UndefinedImpl(other,(short)other.undefined.getType());

// writers
other.bodyContentStack.init(other.req,other.rsp,other.config.isSuppressWhitespace(),other.config.closeConnection(),
other.config.isShowVersion(),config.contentLength(),config.allowCompression());
other.bodyContentStack.init(config.getCFMLWriter(other.req,other.rsp));
//other.bodyContentStack.init(other.req,other.rsp,other.config.isSuppressWhitespace(),other.config.closeConnection(), other.config.isShowVersion(),config.contentLength(),config.allowCompression());
other.writer=other.bodyContentStack.getWriter();
other.forceWriter=other.writer;

Expand Down
18 changes: 18 additions & 0 deletions railo-java/railo-core/src/railo/runtime/config/ConfigImpl.java
Expand Up @@ -138,6 +138,12 @@ public abstract class ConfigImpl implements Config {
public static final int MODE_CUSTOM = 1;
public static final int MODE_STRICT = 2;


public static final int CFML_WRITER_REFULAR=1;
public static final int CFML_WRITER_WS=2;
public static final int CFML_WRITER_WS_PREF=3;


private int mode=MODE_CUSTOM;

private PhysicalClassLoader rpcClassLoader;
Expand Down Expand Up @@ -365,6 +371,8 @@ public abstract class ConfigImpl implements Config {
private LogAndSource scopeLogger;
private railo.runtime.rest.Mapping[] restMappings;

protected int writerType=CFML_WRITER_REFULAR;



/**
Expand Down Expand Up @@ -3453,5 +3461,15 @@ protected void setMode(int mode) {
public int getMode() {
return mode;
}

// do not move to Config interface, do instead getCFMLWriterClass
protected void setCFMLWriterType(int writerType) {
this.writerType=writerType;
}

// do not move to Config interface, do instead setCFMLWriterClass
public int getCFMLWriterType() {
return writerType;
}

}
20 changes: 17 additions & 3 deletions railo-java/railo-core/src/railo/runtime/config/ConfigWebAdmin.java
Expand Up @@ -1892,17 +1892,31 @@ public void updateClientTimeout(TimeSpan span) throws SecurityException {

}



public void updateSuppressWhitespace(Boolean value) throws SecurityException {
public void updateCFMLWriterType(String writerType) throws SecurityException, ApplicationException {
checkWriteAccess();
boolean hasAccess=ConfigWebUtil.hasAccess(config,SecurityManager.TYPE_SETTING);
if(!hasAccess) throw new SecurityException("no access to update scope setting");
writerType=writerType.trim();
if(!"white-space".equalsIgnoreCase(writerType) &&
!"white-space-pref".equalsIgnoreCase(writerType) &&
!"regular".equalsIgnoreCase(writerType))
throw new ApplicationException("invalid writer type defintion ["+writerType+"], valid types are [white-space, white-space-pref, regular]");

Element scope=_getRootElement("setting");
scope.setAttribute("cfml-writer",writerType.toLowerCase());
}

/*public void updateSuppressWhitespace(Boolean value) throws SecurityException {
checkWriteAccess();
boolean hasAccess=ConfigWebUtil.hasAccess(config,SecurityManager.TYPE_SETTING);
if(!hasAccess) throw new SecurityException("no access to update scope setting");
Element scope=_getRootElement("setting");
scope.setAttribute("suppress-whitespace",Caster.toString(value,""));
}
}*/

public void updateSuppressContent(Boolean value) throws SecurityException {
checkWriteAccess();
boolean hasAccess=ConfigWebUtil.hasAccess(config,SecurityManager.TYPE_SETTING);
Expand Down
Expand Up @@ -2811,11 +2811,10 @@ private static void loadSetting(ConfigServerImpl configServer, ConfigImpl config

Element setting=hasAccess?getChildByName(doc.getDocumentElement(),"setting"):null;
boolean hasCS=configServer!=null;


String str=null;

// suppress whitespace
String str=null;
str=null;
if(setting!=null){
str=setting.getAttribute("suppress-content");
}
Expand All @@ -2824,17 +2823,35 @@ private static void loadSetting(ConfigServerImpl configServer, ConfigImpl config
}
else if(hasCS)config.setSuppressContent(configServer.isSuppressContent());


// CFML Writer
if(setting!=null){
str=setting.getAttribute("cfml-writer");
}
if(!StringUtil.isEmpty(str) && hasAccess) {
if("white-space".equalsIgnoreCase(str))
config.setCFMLWriterType(ConfigImpl.CFML_WRITER_WS);
else if("white-space-pref".equalsIgnoreCase(str))
config.setCFMLWriterType(ConfigImpl.CFML_WRITER_WS_PREF);
else if("regular".equalsIgnoreCase(str))
config.setCFMLWriterType(ConfigImpl.CFML_WRITER_REFULAR);
// FUTURE add support for classes implementing CFMLWriter interface
}
else if(hasCS)config.setCFMLWriterType(configServer.getCFMLWriterType());

// No longer supported, replaced with code above
// suppress whitespace
str=null;
/*str=null;
if(setting!=null){
str=setting.getAttribute("suppress-whitespace");
if(StringUtil.isEmpty(str))str=setting.getAttribute("suppresswhitespace");
}
if(!StringUtil.isEmpty(str) && hasAccess) {
config.setSuppressWhitespace(toBoolean(str,false));
}
else if(hasCS)config.setSuppressWhitespace(configServer.isSuppressWhitespace());

else if(hasCS)config.setSuppressWhitespace(configServer.isSuppressWhitespace());*/


// show version
str=null;
if(setting!=null){
Expand Down
17 changes: 17 additions & 0 deletions railo-java/railo-core/src/railo/runtime/config/ConfigWebImpl.java
Expand Up @@ -7,6 +7,8 @@

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.collections.map.ReferenceMap;
import org.xml.sax.SAXException;
Expand Down Expand Up @@ -45,6 +47,10 @@
import railo.runtime.security.SecurityManagerImpl;
import railo.runtime.tag.TagHandlerPool;
import railo.runtime.type.scope.Cluster;
import railo.runtime.writer.CFMLWriter;
import railo.runtime.writer.CFMLWriterImpl;
import railo.runtime.writer.CFMLWriterWhiteSpace;
import railo.runtime.writer.CFMLWriterWhiteSpacePref;
import railo.transformer.library.function.FunctionLibException;
import railo.transformer.library.tag.TagLibException;

Expand All @@ -67,6 +73,7 @@ public final class ConfigWebImpl extends ConfigImpl implements ServletConfig, Co
private LogAndSource gatewayLogger=null;//new LogAndSourceImpl(LogConsole.getInstance(Log.LEVEL_INFO),"");private DebuggerPool debuggerPool;
private DebuggerPool debuggerPool;



//private File deployDirectory;

Expand Down Expand Up @@ -440,4 +447,14 @@ public Map<String, String> getAllLabels() {
public boolean allowRequestTimeout() {
return configServer.allowRequestTimeout();
}

public CFMLWriter getCFMLWriter(HttpServletRequest req, HttpServletResponse rsp) {
// FUTURE move interface CFMLWriter to Loader and load dynaicly from railo-web.xml
if(writerType==CFML_WRITER_WS)
return new CFMLWriterWhiteSpace (req,rsp,-1,false,closeConnection(),isShowVersion(),contentLength(),allowCompression());
else if(writerType==CFML_WRITER_REFULAR)
return new CFMLWriterImpl (req,rsp,-1,false,closeConnection(),isShowVersion(),contentLength(),allowCompression());
else
return new CFMLWriterWhiteSpacePref (req,rsp,-1,false,closeConnection(),isShowVersion(),contentLength(),allowCompression());
}
}
9 changes: 6 additions & 3 deletions railo-java/railo-core/src/railo/runtime/tag/Admin.java
Expand Up @@ -3706,7 +3706,7 @@ private void doUpdateApplicationSettings() throws PageException {
}

private void doUpdateOutputSettings() throws PageException {
admin.updateSuppressWhitespace(getBoolObject("admin",action, "suppressWhitespace"));
admin.updateCFMLWriterType(getString("admin",action, "cfmlWriter"));
admin.updateSuppressContent(getBoolObject("admin",action, "suppressContent"));
//admin.updateShowVersion(getBoolObject("admin",action, "showVersion"));
admin.updateAllowCompression(getBoolObject("admin",action, "allowCompression"));
Expand Down Expand Up @@ -3868,13 +3868,16 @@ private void doGetOutputSetting() throws PageException {

Struct sct=new StructImpl();
pageContext.setVariable(getString("admin",action,"returnVariable"),sct);
sct.set("suppressWhitespace",Caster.toBoolean(config.isSuppressWhitespace()));
sct.set("suppressContent",Caster.toBoolean(config.isSuppressContent()));
sct.set("contentLength",Caster.toBoolean(config.contentLength()));
//sct.set("showVersion",Caster.toBoolean(config.isShowVersion()));
sct.set("allowCompression",Caster.toBoolean(config.allowCompression()));
int wt = config.getCFMLWriterType();
String cfmlWriter="regular";
if(wt==ConfigImpl.CFML_WRITER_WS) cfmlWriter="white-space";
else if(wt==ConfigImpl.CFML_WRITER_WS_PREF) cfmlWriter="white-space-pref";


sct.set("cfmlWriter",cfmlWriter);
}

/**
Expand Down

0 comments on commit 0dc0d8f

Please sign in to comment.