Browse files

Merge branch 'development' of https://github.com/ColdBox/coldbox-plat…

  • Loading branch information...
2 parents 07159e7 + d1a33df commit 4cb8c041d039c7568d92ee5c6bab45e1dc83383f Michael McKellip committed Nov 23, 2011
Showing with 2,065 additions and 297 deletions.
  1. +9 −7 ApplicationTemplates/Advanced/config/Coldbox.cfc
  2. +0 −3 ApplicationTemplates/Advanced/config/Routes.cfm
  3. +7 −10 ApplicationTemplates/Advanced/modules/forgebox/ModuleConfig.cfc
  4. +11 −0 ApplicationTemplates/Advanced/modules/forgebox/config/routes.cfm
  5. +4 −2 ApplicationTemplates/Advanced/modules/forgebox/plugins/ForgeBox.cfc
  6. +621 −0 ApplicationTemplates/Advanced/modules/forgebox/plugins/JSON.cfc
  7. +14 −4 ApplicationTemplates/FlexAirRemote/config/Coldbox.cfc
  8. +0 −2 ApplicationTemplates/Simple/config/Coldbox.cfc
  9. +0 −3 ApplicationTemplates/Simple/config/Routes.cfm
  10. +7 −10 ApplicationTemplates/Simple/modules/forgebox/ModuleConfig.cfc
  11. +11 −0 ApplicationTemplates/Simple/modules/forgebox/config/routes.cfm
  12. +4 −2 ApplicationTemplates/Simple/modules/forgebox/plugins/ForgeBox.cfc
  13. +621 −0 ApplicationTemplates/Simple/modules/forgebox/plugins/JSON.cfc
  14. +1 −4 ApplicationTemplates/SuperSimple/config/Coldbox.cfc
  15. +7 −86 system/interceptors/Autowire.cfc
  16. +22 −5 system/interceptors/SES.cfc
  17. +31 −2 system/orm/hibernate/EventHandler.cfc
  18. +28 −1 system/web/loader/CFCApplicationLoader.cfc
  19. +1 −1 system/web/services/ModuleService.cfc
  20. +0 −1 testharness/Application.cfc
  21. +22 −16 testharness/config/Coldbox.cfc
  22. +0 −1 testharness/model/EventHandler.cfc
  23. +7 −10 testharness/modules/forgebox/ModuleConfig.cfc
  24. +11 −0 testharness/modules/forgebox/config/routes.cfm
  25. +4 −2 testharness/modules/forgebox/plugins/ForgeBox.cfc
  26. +621 −0 testharness/modules/forgebox/plugins/JSON.cfc
  27. +0 −4 testing/StandAloneTests/EventCachingLoad/config/Coldbox.cfc
  28. +0 −4 testing/StandAloneTests/LoadTester/config/Coldbox.cfc
  29. +0 −117 testing/cases/interceptors/AutowireTest.cfc
  30. +1 −0 testing/testmodel/entities/User.cfc
View
16 ApplicationTemplates/Advanced/config/Coldbox.cfc
@@ -138,10 +138,6 @@ Optional Methods
//Register interceptors as an array, we need order
interceptors = [
- //Autowire
- {class="coldbox.system.interceptors.Autowire",
- properties={}
- },
//SES
{class="coldbox.system.interceptors.SES",
properties={}
@@ -153,9 +149,15 @@ Optional Methods
// ORM services, injection, etc
orm = {
- entityInjection = true, // enable/disable entity dependency injection via the ColdBox ORM Event Handler
- entityInclude = "", // A list of entity names to ONLY include for injections
- entityExclude = "" // A list of entity names to exclude from injections
+ // entity injection
+ injection = {
+ // enable it
+ enabled = true,
+ // the include list for injection
+ include = "",
+ // the exclude list for injection
+ exclude = ""
+ }
};
// flash scope configuration
View
3 ApplicationTemplates/Advanced/config/Routes.cfm
@@ -18,9 +18,6 @@
setBaseURL("http://#cgi.HTTP_HOST#/#getSetting('AppMapping')#/index.cfm");
}
- // Module Routing Added
- addModuleRoutes(pattern="/forgebox",module="forgebox");
-
// Your Application Routes
addRoute(pattern=":handler/:action?");
View
17 ApplicationTemplates/Advanced/modules/forgebox/ModuleConfig.cfc
@@ -60,7 +60,7 @@ Optional Methods
this.author = "Luis Majano";
this.webURL = "http://www.coldbox.org";
this.description = "A module that interacts with forgebox";
- this.version = "1.2";
+ this.version = "1.3";
this.viewParentLookup = true;
this.layoutParentLookup = true;
this.entryPoint = "forgebox";
@@ -69,7 +69,6 @@ Optional Methods
* Configure the ForgeBox Module
*/
function configure(){
-
settings = {
version = this.version
};
@@ -79,12 +78,9 @@ Optional Methods
defaultLayout = "forgebox.main.cfm"
};
- // SES Routes ORDER MATTERS
+ // SES Routes
routes = [
- {pattern="/", handler="manager",action="index", orderby="POPULAR"},
- {pattern="/install/results/:entrySlug", handler="manager", action="installResults"},
- {pattern="/install", handler="manager", action="install"},
- {pattern="/manager/:orderby/:typeSlug?", handler="manager",action="index"}
+ "config/routes.cfm"
];
// WireBox Binder configuration
@@ -95,9 +91,10 @@ Optional Methods
* Called when the module is activated and application has loaded
*/
function onLoad(){
- if( controller.settingExists("sesBaseURL") ){
- this.entryPoint = "forgebox:manager";
- }
+ // change entry point if SES loaded
+ if( NOT controller.settingExists("sesBaseURL") ){
+ controller.getSetting("modules").forgebox.entryPoint = "forgebox:manager.index";
+ }
}
</cfscript>
</cfcomponent>
View
11 ApplicationTemplates/Advanced/modules/forgebox/config/routes.cfm
@@ -0,0 +1,11 @@
+<cfscript>
+ addRoute(pattern="/", handler="manager",action="index", orderby="POPULAR");
+
+ with(pattern="/install",handler="manager")
+ .addRoute(pattern="/results/:entrySlug", action="installResults")
+ .addRoute(pattern="/",action="install")
+ .endWith();
+
+ addRoute(pattern="/manager/:orderby/:typeSlug?", handler="manager",action="index");
+ addRoute(pattern="/:handler/:action?");
+</cfscript>
View
6 ApplicationTemplates/Advanced/modules/forgebox/plugins/ForgeBox.cfc
@@ -31,7 +31,6 @@ Settings:
};
</cfscript>
-
<cffunction name="init" access="public" returnType="ForgeBox" output="false" hint="Constructor">
<cfargument name="controller" type="any"/>
<cfscript>
@@ -47,6 +46,9 @@ Settings:
// Setup Properties
instance.APIURL = "http://www.coldbox.org/index.cfm/api/forgebox";
+ // JSON compatibility to forgebox api 1.0
+ instance.oJSON = createObject("component","JSON").init();
+
return this;
</cfscript>
</cffunction>
@@ -183,7 +185,7 @@ Settings:
if( len(HTTPResults.errorDetail) ){ results.error = true; }
// Try to inflate JSON
- results.response = getPlugin("JSON").decode(results.rawResponse);
+ results.response = instance.oJSON.decode(results.rawResponse);
return results;
</cfscript>
View
621 ApplicationTemplates/Advanced/modules/forgebox/plugins/JSON.cfc
@@ -0,0 +1,621 @@
+<!-----------------------------------------------------------------------
+********************************************************************************
+Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp
+www.coldbox.org | www.luismajano.com | www.ortussolutions.com
+********************************************************************************
+Serialize and deserialize JSON data into native ColdFusion objects
+http://www.epiphantastic.com/cfjson/
+
+Authors: Jehiah Czebotar (jehiah@gmail.com)
+ Thomas Messier (thomas@epiphantastic.com)
+Version: 1.9 February 20, 2008
+
+Modifications:
+ - Contributed by Ernst van der Linden (evdlinden@gmail.com) ]
+ - Sana Ullah (adjusted the compatibility with coldbox plugins).
+ - Luis Majano (adaptations & best practices)
+----------------------------------------------------------------------->
+<cfcomponent name="JSON"
+ hint="JSON Object used to serialize and deserialize JSON data to/from native ColdFusion objects."
+ output="false">
+
+<!------------------------------------------- CONSTRUCTOR ------------------------------------------->
+
+ <cffunction name="init" access="public" returntype="JSON" output="false">
+ <cfscript>
+ return this;
+ </cfscript>
+ </cffunction>
+
+<!------------------------------------------- PUBLIC ------------------------------------------->
+
+ <!--- Decode from JSON to CF --->
+ <cffunction name="decode" access="public" returntype="any" output="no" hint="Converts data from JSON to CF format">
+ <!--- ************************************************************* --->
+ <cfargument name="data" type="string" required="Yes" hint="JSON Packet" />
+ <!--- ************************************************************* --->
+ <!--- DECLARE VARIABLES --->
+ <cfset var ar = ArrayNew(1) />
+ <cfset var st = StructNew() />
+ <cfset var dataType = "" />
+ <cfset var inQuotes = false />
+ <cfset var startPos = 1 />
+ <cfset var nestingLevel = 0 />
+ <cfset var dataSize = 0 />
+ <cfset var i = 1 />
+ <cfset var skipIncrement = false />
+ <cfset var j = 0 />
+ <cfset var char = "" />
+ <cfset var dataStr = "" />
+ <cfset var structVal = "" />
+ <cfset var structKey = "" />
+ <cfset var colonPos = "" />
+ <cfset var qRows = 0 />
+ <cfset var qCol = "" />
+ <cfset var qData = "" />
+ <cfset var curCharIndex = "" />
+ <cfset var curChar = "" />
+ <cfset var result = "" />
+ <cfset var unescapeVals = "\\,\"",\/,\b,\t,\n,\f,\r" />
+ <cfset var unescapeToVals = "\,"",/,#Chr(8)#,#Chr(9)#,#Chr(10)#,#Chr(12)#,#Chr(13)#" />
+ <cfset var unescapeVals2 = '\,",/,b,t,n,f,r' />
+ <cfset var unescapetoVals2 = '\,",/,#Chr(8)#,#Chr(9)#,#Chr(10)#,#Chr(12)#,#Chr(13)#' />
+ <cfset var dJSONString = "" />
+ <cfset var _data = Trim(arguments.data) />
+ <cfset var pos = 0>
+
+ <!--- NUMBER --->
+ <cfif IsNumeric(_data)>
+ <cfreturn _data />
+
+ <!--- NULL --->
+ <cfelseif _data EQ "null">
+ <cfreturn "" />
+
+ <!--- BOOLEAN --->
+ <cfelseif ListFindNoCase("true,false", _data)>
+ <cfreturn _data />
+
+ <!--- EMPTY STRING --->
+ <cfelseif _data EQ "''" OR _data EQ '""'>
+ <cfreturn "" />
+
+ <!--- STRING --->
+ <cfelseif ReFind('^"[^\\"]*(?:\\.[^\\"]*)*"$', _data) EQ 1 OR ReFind("^'[^\\']*(?:\\.[^\\']*)*'$", _data) EQ 1>
+ <cfset _data = mid(_data, 2, Len(_data)-2) />
+ <!--- If there are any \b, \t, \n, \f, and \r, do extra processing
+ (required because ReplaceList() won't work with those) --->
+ <cfif Find("\b", _data) OR Find("\t", _data) OR Find("\n", _data) OR Find("\f", _data) OR Find("\r", _data)>
+ <cfset curCharIndex = 0 />
+ <cfset curChar = ""/>
+ <cfset dJSONString = createObject("java", "java.lang.StringBuffer").init("") />
+ <cfloop condition="true">
+ <cfset curCharIndex = curCharIndex + 1 />
+ <cfif curCharIndex GT len(_data)>
+ <cfbreak />
+ <cfelse>
+ <cfset curChar = mid(_data, curCharIndex, 1) />
+ <cfif curChar EQ "\">
+ <cfset curCharIndex = curCharIndex + 1 />
+ <cfset curChar = mid(_data, curCharIndex,1) />
+ <cfset pos = listFind(unescapeVals2, curChar) />
+ <cfif pos>
+ <cfset dJSONString.append(ListGetAt(unescapetoVals2, pos)) />
+ <cfelse>
+ <cfset dJSONString.append("\" & curChar) />
+ </cfif>
+ <cfelse>
+ <cfset dJSONString.append(curChar) />
+ </cfif>
+ </cfif>
+ </cfloop>
+
+ <cfreturn dJSONString.toString() />
+ <cfelse>
+ <cfreturn ReplaceList(_data, unescapeVals, unescapeToVals) />
+ </cfif>
+
+ <!--- ARRAY, STRUCT, OR QUERY --->
+ <cfelseif ( Left(_data, 1) EQ "[" AND Right(_data, 1) EQ "]" )
+ OR ( Left(_data, 1) EQ "{" AND Right(_data, 1) EQ "}" )>
+
+ <!--- Store the data type we're dealing with --->
+ <cfif Left(_data, 1) EQ "[" AND Right(_data, 1) EQ "]">
+ <cfset dataType = "array" />
+ <!--- original regex seemed unecessary: \{("[^"]+":\[[^]]*\],?)+\}\}$ --->
+ <cfelseif ReFindNoCase('^\{"recordcount":[0-9]+,"columnlist":"[^"]+","data":[^}].*}', _data, 0) EQ 1>
+ <cfset dataType = "query" />
+ <cfelse>
+ <cfset dataType = "struct" />
+ </cfif>
+
+ <!--- Remove the brackets --->
+ <cfset _data = Trim( Mid(_data, 2, Len(_data)-2) ) />
+
+ <!--- Deal with empty array/struct --->
+ <cfif Len(_data) EQ 0>
+ <cfif dataType EQ "array">
+ <cfreturn ar />
+ <cfelse>
+ <cfreturn st />
+ </cfif>
+ </cfif>
+
+ <!--- Loop through the string characters --->
+ <cfset dataSize = Len(_data) + 1 />
+ <cfloop condition="#i# LTE #dataSize#">
+ <cfset skipIncrement = false />
+ <!--- Save current character --->
+ <cfset char = Mid(_data, i, 1) />
+
+ <!--- If char is a quote, switch the quote status --->
+ <cfif char EQ '"'>
+ <cfset inQuotes = NOT inQuotes />
+ <!--- If char is escape character, skip the next character --->
+ <cfelseif char EQ "\" AND inQuotes>
+ <cfset i = i + 2 />
+ <cfset skipIncrement = true />
+ <!--- If char is a comma and is not in quotes, or if end of string, deal with data --->
+ <cfelseif (char EQ "," AND NOT inQuotes AND nestingLevel EQ 0) OR i EQ Len(_data)+1>
+ <cfset dataStr = Mid(_data, startPos, i-startPos) />
+
+ <!--- If data type is array, append data to the array --->
+ <cfif dataType EQ "array">
+ <cfset arrayappend( ar, decode(dataStr) ) />
+ <!--- If data type is struct or query... --->
+ <cfelseif dataType EQ "struct" OR dataType EQ "query">
+ <cfset dataStr = Mid(_data, startPos, i-startPos) />
+ <cfset colonPos = Find('":', dataStr) />
+ <cfif colonPos>
+ <cfset colonPos = colonPos + 1 />
+ <cfelse>
+ <cfset colonPos = Find(":", dataStr) />
+ </cfif>
+ <cfset structKey = Trim( Mid(dataStr, 1, colonPos-1) ) />
+
+ <!--- If needed, remove quotes from keys --->
+ <cfif Left(structKey, 1) EQ "'" OR Left(structKey, 1) EQ '"'>
+ <cfset structKey = Mid( structKey, 2, Len(structKey)-2 ) />
+ </cfif>
+
+ <cfset structVal = Mid( dataStr, colonPos+1, Len(dataStr)-colonPos ) />
+
+ <!--- If struct, add to the structure --->
+ <cfif dataType EQ "struct">
+ <cfset StructInsert( st, structKey, decode(structVal) ) />
+
+ <!--- If query, build the query --->
+ <cfelse>
+ <cfif structKey EQ "recordcount">
+ <cfset qRows = decode(structVal) />
+ <cfelseif structKey EQ "columnlist">
+ <!--- build query with columns --->
+ <cfset st = QueryNew( decode(structVal) ) />
+ <!--- Add Number of Rows to Query if > 0 found --->
+ <cfif qRows>
+ <cfset QueryAddRow(st, qRows) />
+ </cfif>
+ <cfelseif structKey EQ "data">
+ <cfset qData = decode(structVal) />
+
+ <!--- Determine if qData is an Array or Structure --->
+ <cfif isArray(qData)>
+ <!--- It is an array, so rebuild to a query --->
+ <cfset ar = StructKeyArray(qData) />
+ <cfloop from="1" to="#ArrayLen(ar)#" index="j">
+ <cfloop from="1" to="#st.recordcount#" index="qRows">
+ <cfset qCol = ar[j] />
+ <cfset QuerySetCell(st, qCol, qData[qCol][qRows], qRows) />
+ </cfloop>
+ </cfloop>
+ <cfelse>
+ <cfscript>
+ // iterate over structure and create query out of it
+ for(j in qData){
+ for(qRows=1; qRows lte arrayLen(qData[j]); qRows=qRows+1){
+ qCol = j;
+ querySetCell(st, qCol, qData[j][qRows], qRows);
+ }
+ }
+ </cfscript>
+ </cfif>
+ </cfif>
+ </cfif>
+ </cfif>
+
+ <cfset startPos = i + 1 />
+ <!--- If starting a new array or struct, add to nesting level --->
+ <cfelseif "{[" CONTAINS char AND NOT inQuotes>
+ <cfset nestingLevel = nestingLevel + 1 />
+ <!--- If ending an array or struct, subtract from nesting level --->
+ <cfelseif "]}" CONTAINS char AND NOT inQuotes>
+ <cfset nestingLevel = nestingLevel - 1 />
+ </cfif>
+
+ <cfif NOT skipIncrement>
+ <cfset i = i + 1 />
+ </cfif>
+ </cfloop>
+
+ <!--- Return appropriate value based on data type --->
+ <cfif dataType EQ "array">
+ <cfreturn ar />
+ <cfelse>
+ <cfreturn st />
+ </cfif>
+
+ <!--- INVALID JSON --->
+ <cfelse>
+ <cfthrow message="Invalid JSON" detail="The document you are trying to decode is not in valid JSON format" type="JSON.InvalidJSON" />
+ </cfif>
+ </cffunction>
+
+ <!--- CONVERTS DATA FROM CF TO JSON FORMAT --->
+ <cffunction name="encode" access="public" returntype="string" output="No" hint="Converts data from CF to JSON format">
+ <!--- ************************************************************* --->
+ <cfargument name="data" type="any" required="Yes" hint="The CF structure" />
+ <cfargument name="queryFormat" type="string" required="No" default="query" hint="query or array" />
+ <cfargument name="queryKeyCase" type="string" required="No" default="lower" hint="lower or upper"/>
+ <cfargument name="stringNumbers" type="boolean" required="No" default="false" >
+ <cfargument name="formatDates" type="boolean" required="No" default="false" >
+ <cfargument name="columnListFormat" type="string" required="No" default="string" hint="string or array" >
+ <cfargument name="keyCase" type="string" required="No" default="lower" hint="lower, none or upper"/>
+ <!--- ************************************************************* --->
+
+ <!--- VARIABLE DECLARATION --->
+ <cfset var JSONString = "" />
+ <cfset var tempVal = "" />
+ <cfset var arKeys = "" />
+ <cfset var arKey = "" />
+ <cfset var colPos = 1 />
+ <cfset var i = 1 />
+ <cfset var column = ""/>
+ <cfset var datakey = ""/>
+ <cfset var recordcountkey = ""/>
+ <cfset var columnlist = ""/>
+ <cfset var columnlistkey = ""/>
+ <cfset var dJSONString = "" />
+ <cfset var escapeToVals = "\\,\"",\/,\b,\t,\n,\f,\r" />
+ <cfset var escapeVals = "\,"",/,#Chr(8)#,#Chr(9)#,#Chr(10)#,#Chr(12)#,#Chr(13)#" />
+ <cfset var _data = arguments.data />
+
+ <!--- BOOLEAN --->
+ <cfif IsBoolean(_data) AND NOT IsNumeric(_data)>
+ <cfif _data>
+ <cfreturn LCase(ToString(true)) />
+ <cfelse>
+ <cfreturn LCase(ToString(false)) />
+ </cfif>
+
+ <!--- NUMBER --->
+ <cfelseif NOT stringNumbers AND IsNumeric(_data) AND NOT REFind("^0+[^\.]",_data)>
+ <cfreturn ToString(_data) />
+
+ <!--- DATE --->
+ <cfelseif IsDate(_data) AND arguments.formatDates>
+ <cfreturn '"#DateFormat(_data, "medium")# #TimeFormat(_data, "medium")#"' />
+
+ <!--- STRING --->
+ <cfelseif IsSimpleValue(_data)>
+ <cfreturn '"' & ReplaceList(_data, escapeVals, escapeToVals) & '"' />
+
+ <!--- ARRAY --->
+ <cfelseif IsArray(_data)>
+ <cfset dJSONString = createObject('java','java.lang.StringBuffer').init("") />
+ <cfloop from="1" to="#ArrayLen(_data)#" index="i">
+ <!--- Null Checks --->
+ <cfparam name="_data[i]" default="_INVALID_"/>
+ <cfif isSimpleValue(_data[i]) and _data[i] EQ "_INVALID_">
+ <cfset tempVal = "null">
+ <cfelse>
+ <cfset tempVal = encode( _data[i], arguments.queryFormat, arguments.queryKeyCase, arguments.stringNumbers, arguments.formatDates, arguments.columnListFormat, arguments.keyCase ) />
+ </cfif>
+
+ <cfif dJSONString.toString() EQ "">
+ <cfset dJSONString.append(tempVal) />
+ <cfelse>
+ <cfset dJSONString.append("," & tempVal) />
+ </cfif>
+ </cfloop>
+
+ <cfreturn "[" & dJSONString.toString() & "]" />
+ <!--- Object --->
+ <cfelseif isObject(_data)>
+ <!--- Let CF Handle IT --->
+ <cfif listFirst(server.coldfusion.productVersion) gte 8>
+ <cfreturn '{"#listLast(getMetaData(_data).name,".")#": #serializeJSON( _data )#}'>
+ <cfelse>
+ <cfreturn '{"#listLast(getMetaData(_data).name,".")#": "#getMetaData(_data).name#"}'>
+ </cfif>
+ <!--- STRUCT --->
+ <cfelseif IsStruct(_data)>
+ <cfset dJSONString = createObject('java','java.lang.StringBuffer').init("") />
+ <cfset arKeys = StructKeyArray(_data) />
+ <cfloop from="1" to="#ArrayLen(arKeys)#" index="i">
+
+ <!--- Null Checks --->
+ <cfif NOT structKeyExists(_data, arKeys[i])>
+ <cfset tempVal = "null">
+ <cfelse>
+ <!--- Get Encoded Value --->
+ <cfset tempVal = encode( _data[ arKeys[i] ], arguments.queryFormat, arguments.queryKeyCase, arguments.stringNumbers, arguments.formatDates, arguments.columnListFormat, arguments.keyCase ) />
+ </cfif>
+
+ <!--- Key to lower Case? --->
+ <cfif arguments.keyCase EQ "lower">
+ <cfset arKey = LCASE(arKeys[i]) />
+ <cfelseif arguments.keyCase EQ "none">
+ <cfset arKey = arKeys[i] />
+ <cfelse>
+ <cfset arKey = UCASE(arKeys[i]) />
+ </cfif>
+
+ <cfif dJSONString.toString() EQ "">
+ <cfset dJSONString.append('"' & arKey & '":' & tempVal) />
+ <cfelse>
+ <cfset dJSONString.append("," & '"' & arKey & '":' & tempVal) />
+ </cfif>
+ </cfloop>
+
+ <cfreturn "{" & dJSONString.toString() & "}" />
+
+ <!--- QUERY --->
+ <cfelseif IsQuery(_data)>
+ <cfset dJSONString = createObject('java','java.lang.StringBuffer').init("") />
+
+ <!--- Add query meta data --->
+ <cfif arguments.queryKeyCase EQ "lower">
+ <cfset recordcountKey = "recordcount" />
+ <cfset columnlistKey = "columnlist" />
+ <cfset columnlist = LCase(_data.columnlist) />
+ <cfset dataKey = "data" />
+ <cfelse>
+ <cfset recordcountKey = "RECORDCOUNT" />
+ <cfset columnlistKey = "COLUMNLIST" />
+ <cfset columnlist = _data.columnlist />
+ <cfset dataKey = "DATA" />
+ </cfif>
+
+ <cfset dJSONString.append('"#recordcountKey#":' & _data.recordcount) />
+
+ <cfif arguments.columnListFormat EQ "array">
+ <cfset columnlist = "[" & ListQualify(columnlist, '"') & "]" />
+ <cfset dJSONString.append(',"#columnlistKey#":' & columnlist) />
+ <cfelse>
+ <cfset dJSONString.append(',"#columnlistKey#":"' & columnlist & '"') />
+ </cfif>
+
+ <cfset dJSONString.append(',"#dataKey#":') />
+
+ <!--- Make query a structure of arrays --->
+ <cfif arguments.queryFormat EQ "query">
+ <cfset dJSONString.append("{") />
+ <cfset colPos = 1 />
+
+ <cfloop list="#_data.columnlist#" delimiters="," index="column">
+ <cfif colPos GT 1>
+ <cfset dJSONString.append(",") />
+ </cfif>
+ <cfif arguments.queryKeyCase EQ "lower">
+ <cfset column = LCase(column) />
+ </cfif>
+ <cfset dJSONString.append('"' & column & '":[') />
+
+ <cfloop from="1" to="#_data.recordcount#" index="i">
+ <!--- Get cell value; recurse to get proper format depending on string/number/boolean data type --->
+ <cfset tempVal = encode( _data[column][i], arguments.queryFormat, arguments.queryKeyCase, arguments.stringNumbers, arguments.formatDates, arguments.columnListFormat, arguments.keyCase ) />
+
+ <cfif i GT 1>
+ <cfset dJSONString.append(",") />
+ </cfif>
+ <cfset dJSONString.append(tempVal) />
+ </cfloop>
+
+ <cfset dJSONString.append("]") />
+
+ <cfset colPos = colPos + 1 />
+ </cfloop>
+ <cfset dJSONString.append("}") />
+ <!--- Make query an array of structures --->
+ <cfelse>
+ <cfset dJSONString.append("[") />
+ <cfloop query="_data">
+ <cfif CurrentRow GT 1>
+ <cfset dJSONString.append(",") />
+ </cfif>
+ <cfset dJSONString.append("{") />
+ <cfset colPos = 1 />
+ <cfloop list="#columnlist#" delimiters="," index="column">
+ <cfset tempVal = encode( _data[column][CurrentRow], arguments.queryFormat, arguments.queryKeyCase, arguments.stringNumbers, arguments.formatDates, arguments.columnListFormat, arguments.keyCase ) />
+
+ <cfif colPos GT 1>
+ <cfset dJSONString.append(",") />
+ </cfif>
+
+ <cfif arguments.queryKeyCase EQ "lower">
+ <cfset column = LCase(column) />
+ </cfif>
+ <cfset dJSONString.append('"' & column & '":' & tempVal) />
+
+ <cfset colPos = colPos + 1 />
+ </cfloop>
+ <cfset dJSONString.append("}") />
+ </cfloop>
+ <cfset dJSONString.append("]") />
+ </cfif>
+
+ <!--- Wrap all query data into an object --->
+ <cfreturn "{" & dJSONString.toString() & "}" />
+
+ <!--- UNKNOWN OBJECT TYPE --->
+ <cfelse>
+ <cfreturn '"' & "unknown-obj" & '"' />
+ </cfif>
+ </cffunction>
+
+ <!--- Validate a JSON document --->
+ <cffunction name="validate" access="remote" output="yes" returntype="boolean" hint="I validate a JSON document against a JSON schema">
+ <!--- ************************************************************* --->
+ <cfargument name="doc" type="string" required="No" />
+ <cfargument name="schema" type="string" required="No" />
+ <cfargument name="errorVar" type="string" required="No" default="JSONSchemaErrors" />
+ <cfargument name="stopOnError" type="boolean" required="No" default=true />
+ <!--- These arguments are for internal use only --->
+ <cfargument name="_doc" type="any" required="No" />
+ <cfargument name="_schema" type="any" required="No" />
+ <cfargument name="_item" type="string" required="No" default="root" />
+ <!--- ************************************************************* --->
+
+ <cfset var schemaRules = "" />
+ <cfset var JSONDoc = "" />
+ <cfset var i = 0 />
+ <cfset var key = "" />
+ <cfset var isValid = true />
+ <cfset var msg = "" />
+
+ <cfif StructKeyExists(arguments, "doc")>
+ <cfif FileExists(arguments.doc)>
+ <cffile action="READ" file="#arguments.doc#" variable="arguments.doc" />
+ </cfif>
+
+ <cfif FileExists(arguments.schema)>
+ <cffile action="READ" file="#arguments.schema#" variable="arguments.schema" />
+ </cfif>
+
+ <cfset JSONDoc = decode(arguments.doc) />
+ <cfset schemaRules = decode(arguments.schema) />
+
+ <cfset request[arguments.errorVar] = ArrayNew(1) />
+ <cfelseif StructKeyExists(arguments, "_doc")>
+ <cfset JSONDoc = arguments._doc />
+ <cfset schemaRules = arguments._schema />
+ </cfif>
+
+ <!--- See if the document matches the rules from the schema --->
+ <cfif schemaRules.type EQ "struct">
+ <cfif NOT IsStruct(JSONDoc)>
+ <cfset ArrayPrepend(request[arguments.errorVar], "#arguments._item# should be a struct") />
+ <cfif arguments.stopOnError>
+ <cfreturn false />
+ </cfif>
+ <cfelse>
+ <!--- If specific keys are set to be required, check if they exist --->
+ <cfif StructKeyExists(schemaRules, "keys")>
+ <cfloop from="1" to="#ArrayLen(schemaRules.keys)#" index="i">
+ <cfif NOT StructKeyExists(JSONDoc, schemaRules.keys[i])>
+ <cfset ArrayPrepend(request[arguments.errorVar], "#arguments._item# should have a key named #schemaRules.keys[i]#") />
+ <cfif arguments.stopOnError>
+ <cfreturn false />
+ </cfif>
+ </cfif>
+ </cfloop>
+ </cfif>
+
+ <!--- Loop over all the keys for the structure and see if they are valid (if items key is specified) by recursing the validate function --->
+ <cfif StructKeyExists(schemaRules, "items")>
+ <cfloop collection="#JSONDoc#" item="key">
+ <cfif StructKeyExists(schemaRules.items, key)>
+ <cfset isValid = validate(_doc=JSONDoc[key], _schema=schemaRules.items[key], _item="#arguments._item#['#key#']", errorVar=arguments.errorVar, stopOnError=arguments.stopOnError) />
+ <cfif arguments.stopOnError AND NOT isValid>
+ <cfreturn false />
+ </cfif>
+ </cfif>
+ </cfloop>
+ </cfif>
+ </cfif>
+ <cfelseif schemaRules.type EQ "array">
+ <cfif NOT IsArray(JSONDoc)>
+ <cfset ArrayPrepend(request[arguments.errorVar], "#arguments._item# should be an array") />
+ <cfif arguments.stopOnError>
+ <cfreturn false />
+ </cfif>
+ <cfelse>
+ <cfparam name="schemaRules.minlength" default="0" />
+ <cfparam name="schemaRules.maxlength" default="9999999999" />
+
+ <!--- If there are length requirements for the array make sure they are valid --->
+ <cfif ArrayLen(JSONDoc) LT schemaRules.minlength>
+ <cfset ArrayPrepend(request[arguments.errorVar], "#arguments._item# is an array that should have at least #schemaRules.minlength# elements") />
+ <cfif arguments.stopOnError>
+ <cfreturn false />
+ </cfif>
+ <cfelseif ArrayLen(JSONDoc) GT schemaRules.maxlength>
+ <cfset ArrayPrepend(request[arguments.errorVar], "#arguments._item# is an array that should have at the most #schemaRules.maxlength# elements") />
+ <cfif arguments.stopOnError>
+ <cfreturn false />
+ </cfif>
+ </cfif>
+
+ <!--- Loop over the array elements and if there are rules for the array items recurse to enforce them --->
+ <cfif StructKeyExists(schemaRules, "items")>
+ <cfloop from="1" to="#ArrayLen(JSONDoc)#" index="i">
+ <cfset isValid = validate(_doc=JSONDoc[i], _schema=schemaRules.items, _item="#arguments._item#[#i#]", errorVar=arguments.errorVar, stopOnError=arguments.stopOnError) />
+ <cfif arguments.stopOnError AND NOT isValid>
+ <cfreturn false />
+ </cfif>
+ </cfloop>
+ </cfif>
+ </cfif>
+ <cfelseif schemaRules.type EQ "number">
+ <cfif NOT IsNumeric(JSONDoc)>
+ <cfset ArrayPrepend(request[arguments.errorVar], "#arguments._item# should be numeric") />
+ <cfif arguments.stopOnError>
+ <cfreturn false />
+ </cfif>
+ <cfelseif StructKeyExists(schemaRules, "min") AND JSONDoc LT schemaRules.min>
+ <cfset ArrayPrepend(request[arguments.errorVar], "#arguments._item# cannot be a number less than #schemaRules.min#") />
+ <cfif arguments.stopOnError>
+ <cfreturn false />
+ </cfif>
+ <cfelseif StructKeyExists(schemaRules, "max") AND JSONDoc GT schemaRules.max>
+ <cfset ArrayPrepend(request[arguments.errorVar], "#arguments._item# cannot be a number greater than #schemaRules.max#") />
+ <cfif arguments.stopOnError>
+ <cfreturn false />
+ </cfif>
+ </cfif>
+ <cfelseif schemaRules.type EQ "boolean" AND ( NOT IsBoolean(JSONDoc) OR ListFindNoCase("Yes,No", JSONDoc) OR IsNumeric(JSONDoc) )>
+ <cfset ArrayPrepend(request[arguments.errorVar], "#arguments._item# should be a boolean") />
+ <cfif arguments.stopOnError>
+ <cfreturn false />
+ </cfif>
+ <cfelseif schemaRules.type EQ "date">
+ <cfif NOT IsSimpleValue(JSONDoc) OR NOT IsDate(JSONDoc)
+ OR ( StructKeyExists(schemaRules, "mask") AND CompareNoCase( JSONDoc, DateFormat(JSONDoc, schemaRules.mask) ) NEQ 0 )>
+ <cfif StructKeyExists(schemaRules, "mask")>
+ <cfset msg = " in #schemaRules.mask# format" />
+ </cfif>
+ <cfset ArrayPrepend(request[arguments.errorVar], "#arguments._item# should be a date#msg#") />
+ <cfif arguments.stopOnError>
+ <cfreturn false />
+ </cfif>
+ </cfif>
+ <cfelseif schemaRules.type EQ "string">
+ <cfif NOT IsSimpleValue(JSONDoc)>
+ <cfset ArrayPrepend(request[arguments.errorVar], "#arguments._item# should be a string") />
+ <cfif arguments.stopOnError>
+ <cfreturn false />
+ </cfif>
+ <cfelseif StructKeyExists(schemaRules, "minlength") AND Len(JSONDoc) LT schemaRules.minlength>
+ <cfset ArrayPrepend(request[arguments.errorVar], "#arguments._item# should have a minimum length of #schemaRules.minlength#") />
+ <cfif arguments.stopOnError>
+ <cfreturn false />
+ </cfif>
+ <cfelseif StructKeyExists(schemaRules, "maxlength") AND Len(JSONDoc) GT schemaRules.maxlength>
+ <cfset ArrayPrepend(request[arguments.errorVar], "#arguments._item# should have a maximum length of #schemaRules.maxlength#") />
+ <cfif arguments.stopOnError>
+ <cfreturn false />
+ </cfif>
+ </cfif>
+ </cfif>
+
+ <cfif ArrayLen(request[arguments.errorVar])>
+ <cfreturn false />
+ <cfelse>
+ <cfreturn true />
+ </cfif>
+ </cffunction>
+
+<!------------------------------------------- PRIVATE ------------------------------------------->
+
+
+</cfcomponent>
View
18 ApplicationTemplates/FlexAirRemote/config/Coldbox.cfc
@@ -138,10 +138,20 @@ function configure(){
};
//Register interceptors as an array, we need order
- interceptors = [
- //Autowire
- {class="coldbox.system.interceptors.Autowire"}
- ];
+ interceptors = [];
+
+ // ORM services, injection, etc
+ orm = {
+ // entity injection
+ injection = {
+ // enable it
+ enabled = true,
+ // the include list for injection
+ include = "",
+ // the exclude list for injection
+ exclude = ""
+ }
+ };
}
View
2 ApplicationTemplates/Simple/config/Coldbox.cfc
@@ -103,8 +103,6 @@ function configure(){
//Register interceptors as an array, we need order
interceptors = [
- //Autowire
- {class="coldbox.system.interceptors.Autowire"},
//SES
{class="coldbox.system.interceptors.SES"}
];
View
3 ApplicationTemplates/Simple/config/Routes.cfm
@@ -18,9 +18,6 @@
setBaseURL("http://#cgi.HTTP_HOST#/#getSetting('AppMapping')#/index.cfm");
}
- // Add Module Routing Here
- addModuleRoutes(pattern="/forgebox",module="forgebox");
-
// Your Application Routes
addRoute(pattern=":handler/:action?");
</cfscript>
View
17 ApplicationTemplates/Simple/modules/forgebox/ModuleConfig.cfc
@@ -60,7 +60,7 @@ Optional Methods
this.author = "Luis Majano";
this.webURL = "http://www.coldbox.org";
this.description = "A module that interacts with forgebox";
- this.version = "1.2";
+ this.version = "1.3";
this.viewParentLookup = true;
this.layoutParentLookup = true;
this.entryPoint = "forgebox";
@@ -69,7 +69,6 @@ Optional Methods
* Configure the ForgeBox Module
*/
function configure(){
-
settings = {
version = this.version
};
@@ -79,12 +78,9 @@ Optional Methods
defaultLayout = "forgebox.main.cfm"
};
- // SES Routes ORDER MATTERS
+ // SES Routes
routes = [
- {pattern="/", handler="manager",action="index", orderby="POPULAR"},
- {pattern="/install/results/:entrySlug", handler="manager", action="installResults"},
- {pattern="/install", handler="manager", action="install"},
- {pattern="/manager/:orderby/:typeSlug?", handler="manager",action="index"}
+ "config/routes.cfm"
];
// WireBox Binder configuration
@@ -95,9 +91,10 @@ Optional Methods
* Called when the module is activated and application has loaded
*/
function onLoad(){
- if( controller.settingExists("sesBaseURL") ){
- this.entryPoint = "forgebox:manager";
- }
+ // change entry point if SES loaded
+ if( NOT controller.settingExists("sesBaseURL") ){
+ controller.getSetting("modules").forgebox.entryPoint = "forgebox:manager.index";
+ }
}
</cfscript>
</cfcomponent>
View
11 ApplicationTemplates/Simple/modules/forgebox/config/routes.cfm
@@ -0,0 +1,11 @@
+<cfscript>
+ addRoute(pattern="/", handler="manager",action="index", orderby="POPULAR");
+
+ with(pattern="/install",handler="manager")
+ .addRoute(pattern="/results/:entrySlug", action="installResults")
+ .addRoute(pattern="/",action="install")
+ .endWith();
+
+ addRoute(pattern="/manager/:orderby/:typeSlug?", handler="manager",action="index");
+ addRoute(pattern="/:handler/:action?");
+</cfscript>
View
6 ApplicationTemplates/Simple/modules/forgebox/plugins/ForgeBox.cfc
@@ -31,7 +31,6 @@ Settings:
};
</cfscript>
-
<cffunction name="init" access="public" returnType="ForgeBox" output="false" hint="Constructor">
<cfargument name="controller" type="any"/>
<cfscript>
@@ -47,6 +46,9 @@ Settings:
// Setup Properties
instance.APIURL = "http://www.coldbox.org/index.cfm/api/forgebox";
+ // JSON compatibility to forgebox api 1.0
+ instance.oJSON = createObject("component","JSON").init();
+
return this;
</cfscript>
</cffunction>
@@ -183,7 +185,7 @@ Settings:
if( len(HTTPResults.errorDetail) ){ results.error = true; }
// Try to inflate JSON
- results.response = getPlugin("JSON").decode(results.rawResponse);
+ results.response = instance.oJSON.decode(results.rawResponse);
return results;
</cfscript>
View
621 ApplicationTemplates/Simple/modules/forgebox/plugins/JSON.cfc
@@ -0,0 +1,621 @@
+<!-----------------------------------------------------------------------
+********************************************************************************
+Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp
+www.coldbox.org | www.luismajano.com | www.ortussolutions.com
+********************************************************************************
+Serialize and deserialize JSON data into native ColdFusion objects
+http://www.epiphantastic.com/cfjson/
+
+Authors: Jehiah Czebotar (jehiah@gmail.com)
+ Thomas Messier (thomas@epiphantastic.com)
+Version: 1.9 February 20, 2008
+
+Modifications:
+ - Contributed by Ernst van der Linden (evdlinden@gmail.com) ]
+ - Sana Ullah (adjusted the compatibility with coldbox plugins).
+ - Luis Majano (adaptations & best practices)
+----------------------------------------------------------------------->
+<cfcomponent name="JSON"
+ hint="JSON Object used to serialize and deserialize JSON data to/from native ColdFusion objects."
+ output="false">
+
+<!------------------------------------------- CONSTRUCTOR ------------------------------------------->
+
+ <cffunction name="init" access="public" returntype="JSON" output="false">
+ <cfscript>
+ return this;
+ </cfscript>
+ </cffunction>
+
+<!------------------------------------------- PUBLIC ------------------------------------------->
+
+ <!--- Decode from JSON to CF --->
+ <cffunction name="decode" access="public" returntype="any" output="no" hint="Converts data from JSON to CF format">
+ <!--- ************************************************************* --->
+ <cfargument name="data" type="string" required="Yes" hint="JSON Packet" />
+ <!--- ************************************************************* --->
+ <!--- DECLARE VARIABLES --->
+ <cfset var ar = ArrayNew(1) />
+ <cfset var st = StructNew() />
+ <cfset var dataType = "" />
+ <cfset var inQuotes = false />
+ <cfset var startPos = 1 />
+ <cfset var nestingLevel = 0 />
+ <cfset var dataSize = 0 />
+ <cfset var i = 1 />
+ <cfset var skipIncrement = false />
+ <cfset var j = 0 />
+ <cfset var char = "" />
+ <cfset var dataStr = "" />
+ <cfset var structVal = "" />
+ <cfset var structKey = "" />
+ <cfset var colonPos = "" />
+ <cfset var qRows = 0 />
+ <cfset var qCol = "" />
+ <cfset var qData = "" />
+ <cfset var curCharIndex = "" />
+ <cfset var curChar = "" />
+ <cfset var result = "" />
+ <cfset var unescapeVals = "\\,\"",\/,\b,\t,\n,\f,\r" />
+ <cfset var unescapeToVals = "\,"",/,#Chr(8)#,#Chr(9)#,#Chr(10)#,#Chr(12)#,#Chr(13)#" />
+ <cfset var unescapeVals2 = '\,",/,b,t,n,f,r' />
+ <cfset var unescapetoVals2 = '\,",/,#Chr(8)#,#Chr(9)#,#Chr(10)#,#Chr(12)#,#Chr(13)#' />
+ <cfset var dJSONString = "" />
+ <cfset var _data = Trim(arguments.data) />
+ <cfset var pos = 0>
+
+ <!--- NUMBER --->
+ <cfif IsNumeric(_data)>
+ <cfreturn _data />
+
+ <!--- NULL --->
+ <cfelseif _data EQ "null">
+ <cfreturn "" />
+
+ <!--- BOOLEAN --->
+ <cfelseif ListFindNoCase("true,false", _data)>
+ <cfreturn _data />
+
+ <!--- EMPTY STRING --->
+ <cfelseif _data EQ "''" OR _data EQ '""'>
+ <cfreturn "" />
+
+ <!--- STRING --->
+ <cfelseif ReFind('^"[^\\"]*(?:\\.[^\\"]*)*"$', _data) EQ 1 OR ReFind("^'[^\\']*(?:\\.[^\\']*)*'$", _data) EQ 1>
+ <cfset _data = mid(_data, 2, Len(_data)-2) />
+ <!--- If there are any \b, \t, \n, \f, and \r, do extra processing
+ (required because ReplaceList() won't work with those) --->
+ <cfif Find("\b", _data) OR Find("\t", _data) OR Find("\n", _data) OR Find("\f", _data) OR Find("\r", _data)>
+ <cfset curCharIndex = 0 />
+ <cfset curChar = ""/>
+ <cfset dJSONString = createObject("java", "java.lang.StringBuffer").init("") />
+ <cfloop condition="true">
+ <cfset curCharIndex = curCharIndex + 1 />
+ <cfif curCharIndex GT len(_data)>
+ <cfbreak />
+ <cfelse>
+ <cfset curChar = mid(_data, curCharIndex, 1) />
+ <cfif curChar EQ "\">
+ <cfset curCharIndex = curCharIndex + 1 />
+ <cfset curChar = mid(_data, curCharIndex,1) />
+ <cfset pos = listFind(unescapeVals2, curChar) />
+ <cfif pos>
+ <cfset dJSONString.append(ListGetAt(unescapetoVals2, pos)) />
+ <cfelse>
+ <cfset dJSONString.append("\" & curChar) />
+ </cfif>
+ <cfelse>
+ <cfset dJSONString.append(curChar) />
+ </cfif>
+ </cfif>
+ </cfloop>
+
+ <cfreturn dJSONString.toString() />
+ <cfelse>
+ <cfreturn ReplaceList(_data, unescapeVals, unescapeToVals) />
+ </cfif>
+
+ <!--- ARRAY, STRUCT, OR QUERY --->
+ <cfelseif ( Left(_data, 1) EQ "[" AND Right(_data, 1) EQ "]" )
+ OR ( Left(_data, 1) EQ "{" AND Right(_data, 1) EQ "}" )>
+
+ <!--- Store the data type we're dealing with --->
+ <cfif Left(_data, 1) EQ "[" AND Right(_data, 1) EQ "]">
+ <cfset dataType = "array" />
+ <!--- original regex seemed unecessary: \{("[^"]+":\[[^]]*\],?)+\}\}$ --->
+ <cfelseif ReFindNoCase('^\{"recordcount":[0-9]+,"columnlist":"[^"]+","data":[^}].*}', _data, 0) EQ 1>
+ <cfset dataType = "query" />
+ <cfelse>
+ <cfset dataType = "struct" />
+ </cfif>
+
+ <!--- Remove the brackets --->
+ <cfset _data = Trim( Mid(_data, 2, Len(_data)-2) ) />
+
+ <!--- Deal with empty array/struct --->
+ <cfif Len(_data) EQ 0>
+ <cfif dataType EQ "array">
+ <cfreturn ar />
+ <cfelse>
+ <cfreturn st />
+ </cfif>
+ </cfif>
+
+ <!--- Loop through the string characters --->
+ <cfset dataSize = Len(_data) + 1 />
+ <cfloop condition="#i# LTE #dataSize#">
+ <cfset skipIncrement = false />
+ <!--- Save current character --->
+ <cfset char = Mid(_data, i, 1) />
+
+ <!--- If char is a quote, switch the quote status --->
+ <cfif char EQ '"'>
+ <cfset inQuotes = NOT inQuotes />
+ <!--- If char is escape character, skip the next character --->
+ <cfelseif char EQ "\" AND inQuotes>
+ <cfset i = i + 2 />
+ <cfset skipIncrement = true />
+ <!--- If char is a comma and is not in quotes, or if end of string, deal with data --->
+ <cfelseif (char EQ "," AND NOT inQuotes AND nestingLevel EQ 0) OR i EQ Len(_data)+1>
+ <cfset dataStr = Mid(_data, startPos, i-startPos) />
+
+ <!--- If data type is array, append data to the array --->
+ <cfif dataType EQ "array">
+ <cfset arrayappend( ar, decode(dataStr) ) />
+ <!--- If data type is struct or query... --->
+ <cfelseif dataType EQ "struct" OR dataType EQ "query">
+ <cfset dataStr = Mid(_data, startPos, i-startPos) />
+ <cfset colonPos = Find('":', dataStr) />
+ <cfif colonPos>
+ <cfset colonPos = colonPos + 1 />
+ <cfelse>
+ <cfset colonPos = Find(":", dataStr) />
+ </cfif>
+ <cfset structKey = Trim( Mid(dataStr, 1, colonPos-1) ) />
+
+ <!--- If needed, remove quotes from keys --->
+ <cfif Left(structKey, 1) EQ "'" OR Left(structKey, 1) EQ '"'>
+ <cfset structKey = Mid( structKey, 2, Len(structKey)-2 ) />
+ </cfif>
+
+ <cfset structVal = Mid( dataStr, colonPos+1, Len(dataStr)-colonPos ) />
+
+ <!--- If struct, add to the structure --->
+ <cfif dataType EQ "struct">
+ <cfset StructInsert( st, structKey, decode(structVal) ) />
+
+ <!--- If query, build the query --->
+ <cfelse>
+ <cfif structKey EQ "recordcount">
+ <cfset qRows = decode(structVal) />
+ <cfelseif structKey EQ "columnlist">
+ <!--- build query with columns --->
+ <cfset st = QueryNew( decode(structVal) ) />
+ <!--- Add Number of Rows to Query if > 0 found --->
+ <cfif qRows>
+ <cfset QueryAddRow(st, qRows) />
+ </cfif>
+ <cfelseif structKey EQ "data">
+ <cfset qData = decode(structVal) />
+
+ <!--- Determine if qData is an Array or Structure --->
+ <cfif isArray(qData)>
+ <!--- It is an array, so rebuild to a query --->
+ <cfset ar = StructKeyArray(qData) />
+ <cfloop from="1" to="#ArrayLen(ar)#" index="j">
+ <cfloop from="1" to="#st.recordcount#" index="qRows">
+ <cfset qCol = ar[j] />
+ <cfset QuerySetCell(st, qCol, qData[qCol][qRows], qRows) />
+ </cfloop>
+ </cfloop>
+ <cfelse>
+ <cfscript>
+ // iterate over structure and create query out of it
+ for(j in qData){
+ for(qRows=1; qRows lte arrayLen(qData[j]); qRows=qRows+1){
+ qCol = j;
+ querySetCell(st, qCol, qData[j][qRows], qRows);
+ }
+ }
+ </cfscript>
+ </cfif>
+ </cfif>
+ </cfif>
+ </cfif>
+
+ <cfset startPos = i + 1 />
+ <!--- If starting a new array or struct, add to nesting level --->
+ <cfelseif "{[" CONTAINS char AND NOT inQuotes>
+ <cfset nestingLevel = nestingLevel + 1 />
+ <!--- If ending an array or struct, subtract from nesting level --->
+ <cfelseif "]}" CONTAINS char AND NOT inQuotes>
+ <cfset nestingLevel = nestingLevel - 1 />
+ </cfif>
+
+ <cfif NOT skipIncrement>
+ <cfset i = i + 1 />
+ </cfif>
+ </cfloop>
+
+ <!--- Return appropriate value based on data type --->
+ <cfif dataType EQ "array">
+ <cfreturn ar />
+ <cfelse>
+ <cfreturn st />
+ </cfif>
+
+ <!--- INVALID JSON --->
+ <cfelse>
+ <cfthrow message="Invalid JSON" detail="The document you are trying to decode is not in valid JSON format" type="JSON.InvalidJSON" />
+ </cfif>
+ </cffunction>
+
+ <!--- CONVERTS DATA FROM CF TO JSON FORMAT --->
+ <cffunction name="encode" access="public" returntype="string" output="No" hint="Converts data from CF to JSON format">
+ <!--- ************************************************************* --->
+ <cfargument name="data" type="any" required="Yes" hint="The CF structure" />
+ <cfargument name="queryFormat" type="string" required="No" default="query" hint="query or array" />
+ <cfargument name="queryKeyCase" type="string" required="No" default="lower" hint="lower or upper"/>
+ <cfargument name="stringNumbers" type="boolean" required="No" default="false" >
+ <cfargument name="formatDates" type="boolean" required="No" default="false" >
+ <cfargument name="columnListFormat" type="string" required="No" default="string" hint="string or array" >
+ <cfargument name="keyCase" type="string" required="No" default="lower" hint="lower, none or upper"/>
+ <!--- ************************************************************* --->
+
+ <!--- VARIABLE DECLARATION --->
+ <cfset var JSONString = "" />
+ <cfset var tempVal = "" />
+ <cfset var arKeys = "" />
+ <cfset var arKey = "" />
+ <cfset var colPos = 1 />
+ <cfset var i = 1 />
+ <cfset var column = ""/>
+ <cfset var datakey = ""/>
+ <cfset var recordcountkey = ""/>
+ <cfset var columnlist = ""/>
+ <cfset var columnlistkey = ""/>
+ <cfset var dJSONString = "" />
+ <cfset var escapeToVals = "\\,\"",\/,\b,\t,\n,\f,\r" />
+ <cfset var escapeVals = "\,"",/,#Chr(8)#,#Chr(9)#,#Chr(10)#,#Chr(12)#,#Chr(13)#" />
+ <cfset var _data = arguments.data />
+
+ <!--- BOOLEAN --->
+ <cfif IsBoolean(_data) AND NOT IsNumeric(_data)>
+ <cfif _data>
+ <cfreturn LCase(ToString(true)) />
+ <cfelse>
+ <cfreturn LCase(ToString(false)) />
+ </cfif>
+
+ <!--- NUMBER --->
+ <cfelseif NOT stringNumbers AND IsNumeric(_data) AND NOT REFind("^0+[^\.]",_data)>
+ <cfreturn ToString(_data) />
+
+ <!--- DATE --->
+ <cfelseif IsDate(_data) AND arguments.formatDates>
+ <cfreturn '"#DateFormat(_data, "medium")# #TimeFormat(_data, "medium")#"' />
+
+ <!--- STRING --->
+ <cfelseif IsSimpleValue(_data)>
+ <cfreturn '"' & ReplaceList(_data, escapeVals, escapeToVals) & '"' />
+
+ <!--- ARRAY --->
+ <cfelseif IsArray(_data)>
+ <cfset dJSONString = createObject('java','java.lang.StringBuffer').init("") />
+ <cfloop from="1" to="#ArrayLen(_data)#" index="i">
+ <!--- Null Checks --->
+ <cfparam name="_data[i]" default="_INVALID_"/>
+ <cfif isSimpleValue(_data[i]) and _data[i] EQ "_INVALID_">
+ <cfset tempVal = "null">
+ <cfelse>
+ <cfset tempVal = encode( _data[i], arguments.queryFormat, arguments.queryKeyCase, arguments.stringNumbers, arguments.formatDates, arguments.columnListFormat, arguments.keyCase ) />
+ </cfif>
+
+ <cfif dJSONString.toString() EQ "">
+ <cfset dJSONString.append(tempVal) />
+ <cfelse>
+ <cfset dJSONString.append("," & tempVal) />
+ </cfif>
+ </cfloop>
+
+ <cfreturn "[" & dJSONString.toString() & "]" />
+ <!--- Object --->
+ <cfelseif isObject(_data)>
+ <!--- Let CF Handle IT --->
+ <cfif listFirst(server.coldfusion.productVersion) gte 8>
+ <cfreturn '{"#listLast(getMetaData(_data).name,".")#": #serializeJSON( _data )#}'>
+ <cfelse>
+ <cfreturn '{"#listLast(getMetaData(_data).name,".")#": "#getMetaData(_data).name#"}'>
+ </cfif>
+ <!--- STRUCT --->
+ <cfelseif IsStruct(_data)>
+ <cfset dJSONString = createObject('java','java.lang.StringBuffer').init("") />
+ <cfset arKeys = StructKeyArray(_data) />
+ <cfloop from="1" to="#ArrayLen(arKeys)#" index="i">
+
+ <!--- Null Checks --->
+ <cfif NOT structKeyExists(_data, arKeys[i])>
+ <cfset tempVal = "null">
+ <cfelse>
+ <!--- Get Encoded Value --->
+ <cfset tempVal = encode( _data[ arKeys[i] ], arguments.queryFormat, arguments.queryKeyCase, arguments.stringNumbers, arguments.formatDates, arguments.columnListFormat, arguments.keyCase ) />
+ </cfif>
+
+ <!--- Key to lower Case? --->
+ <cfif arguments.keyCase EQ "lower">
+ <cfset arKey = LCASE(arKeys[i]) />
+ <cfelseif arguments.keyCase EQ "none">
+ <cfset arKey = arKeys[i] />
+ <cfelse>
+ <cfset arKey = UCASE(arKeys[i]) />
+ </cfif>
+
+ <cfif dJSONString.toString() EQ "">
+ <cfset dJSONString.append('"' & arKey & '":' & tempVal) />
+ <cfelse>
+ <cfset dJSONString.append("," & '"' & arKey & '":' & tempVal) />
+ </cfif>
+ </cfloop>
+
+ <cfreturn "{" & dJSONString.toString() & "}" />
+
+ <!--- QUERY --->
+ <cfelseif IsQuery(_data)>
+ <cfset dJSONString = createObject('java','java.lang.StringBuffer').init("") />
+
+ <!--- Add query meta data --->
+ <cfif arguments.queryKeyCase EQ "lower">
+ <cfset recordcountKey = "recordcount" />
+ <cfset columnlistKey = "columnlist" />
+ <cfset columnlist = LCase(_data.columnlist) />
+ <cfset dataKey = "data" />
+ <cfelse>
+ <cfset recordcountKey = "RECORDCOUNT" />
+ <cfset columnlistKey = "COLUMNLIST" />
+ <cfset columnlist = _data.columnlist />
+ <cfset dataKey = "DATA" />
+ </cfif>
+
+ <cfset dJSONString.append('"#recordcountKey#":' & _data.recordcount) />
+
+ <cfif arguments.columnListFormat EQ "array">
+ <cfset columnlist = "[" & ListQualify(columnlist, '"') & "]" />
+ <cfset dJSONString.append(',"#columnlistKey#":' & columnlist) />
+ <cfelse>
+ <cfset dJSONString.append(',"#columnlistKey#":"' & columnlist & '"') />
+ </cfif>
+
+ <cfset dJSONString.append(',"#dataKey#":') />
+
+ <!--- Make query a structure of arrays --->
+ <cfif arguments.queryFormat EQ "query">
+ <cfset dJSONString.append("{") />
+ <cfset colPos = 1 />
+
+ <cfloop list="#_data.columnlist#" delimiters="," index="column">
+ <cfif colPos GT 1>
+ <cfset dJSONString.append(",") />
+ </cfif>
+ <cfif arguments.queryKeyCase EQ "lower">
+ <cfset column = LCase(column) />
+ </cfif>
+ <cfset dJSONString.append('"' & column & '":[') />
+
+ <cfloop from="1" to="#_data.recordcount#" index="i">
+ <!--- Get cell value; recurse to get proper format depending on string/number/boolean data type --->
+ <cfset tempVal = encode( _data[column][i], arguments.queryFormat, arguments.queryKeyCase, arguments.stringNumbers, arguments.formatDates, arguments.columnListFormat, arguments.keyCase ) />
+
+ <cfif i GT 1>
+ <cfset dJSONString.append(",") />
+ </cfif>
+ <cfset dJSONString.append(tempVal) />
+ </cfloop>
+
+ <cfset dJSONString.append("]") />
+
+ <cfset colPos = colPos + 1 />
+ </cfloop>
+ <cfset dJSONString.append("}") />
+ <!--- Make query an array of structures --->
+ <cfelse>
+ <cfset dJSONString.append("[") />
+ <cfloop query="_data">
+ <cfif CurrentRow GT 1>
+ <cfset dJSONString.append(",") />
+ </cfif>
+ <cfset dJSONString.append("{") />
+ <cfset colPos = 1 />
+ <cfloop list="#columnlist#" delimiters="," index="column">
+ <cfset tempVal = encode( _data[column][CurrentRow], arguments.queryFormat, arguments.queryKeyCase, arguments.stringNumbers, arguments.formatDates, arguments.columnListFormat, arguments.keyCase ) />
+
+ <cfif colPos GT 1>
+ <cfset dJSONString.append(",") />
+ </cfif>
+
+ <cfif arguments.queryKeyCase EQ "lower">
+ <cfset column = LCase(column) />
+ </cfif>
+ <cfset dJSONString.append('"' & column & '":' & tempVal) />
+
+ <cfset colPos = colPos + 1 />
+ </cfloop>
+ <cfset dJSONString.append("}") />
+ </cfloop>
+ <cfset dJSONString.append("]") />
+ </cfif>
+
+ <!--- Wrap all query data into an object --->
+ <cfreturn "{" & dJSONString.toString() & "}" />
+
+ <!--- UNKNOWN OBJECT TYPE --->
+ <cfelse>
+ <cfreturn '"' & "unknown-obj" & '"' />
+ </cfif>
+ </cffunction>
+
+ <!--- Validate a JSON document --->
+ <cffunction name="validate" access="remote" output="yes" returntype="boolean" hint="I validate a JSON document against a JSON schema">
+ <!--- ************************************************************* --->
+ <cfargument name="doc" type="string" required="No" />
+ <cfargument name="schema" type="string" required="No" />
+ <cfargument name="errorVar" type="string" required="No" default="JSONSchemaErrors" />
+ <cfargument name="stopOnError" type="boolean" required="No" default=true />
+ <!--- These arguments are for internal use only --->
+ <cfargument name="_doc" type="any" required="No" />
+ <cfargument name="_schema" type="any" required="No" />
+ <cfargument name="_item" type="string" required="No" default="root" />
+ <!--- ************************************************************* --->
+
+ <cfset var schemaRules = "" />
+ <cfset var JSONDoc = "" />
+ <cfset var i = 0 />
+ <cfset var key = "" />
+ <cfset var isValid = true />
+ <cfset var msg = "" />
+
+ <cfif StructKeyExists(arguments, "doc")>
+ <cfif FileExists(arguments.doc)>
+ <cffile action="READ" file="#arguments.doc#" variable="arguments.doc" />
+ </cfif>
+
+ <cfif FileExists(arguments.schema)>
+ <cffile action="READ" file="#arguments.schema#" variable="arguments.schema" />
+ </cfif>
+
+ <cfset JSONDoc = decode(arguments.doc) />
+ <cfset schemaRules = decode(arguments.schema) />
+
+ <cfset request[arguments.errorVar] = ArrayNew(1) />
+ <cfelseif StructKeyExists(arguments, "_doc")>
+ <cfset JSONDoc = arguments._doc />
+ <cfset schemaRules = arguments._schema />
+ </cfif>
+
+ <!--- See if the document matches the rules from the schema --->
+ <cfif schemaRules.type EQ "struct">
+ <cfif NOT IsStruct(JSONDoc)>
+ <cfset ArrayPrepend(request[arguments.errorVar], "#arguments._item# should be a struct") />
+ <cfif arguments.stopOnError>
+ <cfreturn false />
+ </cfif>
+ <cfelse>
+ <!--- If specific keys are set to be required, check if they exist --->
+ <cfif StructKeyExists(schemaRules, "keys")>
+ <cfloop from="1" to="#ArrayLen(schemaRules.keys)#" index="i">
+ <cfif NOT StructKeyExists(JSONDoc, schemaRules.keys[i])>
+ <cfset ArrayPrepend(request[arguments.errorVar], "#arguments._item# should have a key named #schemaRules.keys[i]#") />
+ <cfif arguments.stopOnError>
+ <cfreturn false />
+ </cfif>
+ </cfif>
+ </cfloop>
+ </cfif>
+
+ <!--- Loop over all the keys for the structure and see if they are valid (if items key is specified) by recursing the validate function --->
+ <cfif StructKeyExists(schemaRules, "items")>
+ <cfloop collection="#JSONDoc#" item="key">
+ <cfif StructKeyExists(schemaRules.items, key)>
+ <cfset isValid = validate(_doc=JSONDoc[key], _schema=schemaRules.items[key], _item="#arguments._item#['#key#']", errorVar=arguments.errorVar, stopOnError=arguments.stopOnError) />
+ <cfif arguments.stopOnError AND NOT isValid>
+ <cfreturn false />
+ </cfif>
+ </cfif>
+ </cfloop>
+ </cfif>
+ </cfif>
+ <cfelseif schemaRules.type EQ "array">
+ <cfif NOT IsArray(JSONDoc)>
+ <cfset ArrayPrepend(request[arguments.errorVar], "#arguments._item# should be an array") />
+ <cfif arguments.stopOnError>
+ <cfreturn false />
+ </cfif>
+ <cfelse>
+ <cfparam name="schemaRules.minlength" default="0" />
+ <cfparam name="schemaRules.maxlength" default="9999999999" />
+
+ <!--- If there are length requirements for the array make sure they are valid --->
+ <cfif ArrayLen(JSONDoc) LT schemaRules.minlength>
+ <cfset ArrayPrepend(request[arguments.errorVar], "#arguments._item# is an array that should have at least #schemaRules.minlength# elements") />
+ <cfif arguments.stopOnError>
+ <cfreturn false />
+ </cfif>
+ <cfelseif ArrayLen(JSONDoc) GT schemaRules.maxlength>
+ <cfset ArrayPrepend(request[arguments.errorVar], "#arguments._item# is an array that should have at the most #schemaRules.maxlength# elements") />
+ <cfif arguments.stopOnError>
+ <cfreturn false />
+ </cfif>
+ </cfif>
+
+ <!--- Loop over the array elements and if there are rules for the array items recurse to enforce them --->
+ <cfif StructKeyExists(schemaRules, "items")>
+ <cfloop from="1" to="#ArrayLen(JSONDoc)#" index="i">
+ <cfset isValid = validate(_doc=JSONDoc[i], _schema=schemaRules.items, _item="#arguments._item#[#i#]", errorVar=arguments.errorVar, stopOnError=arguments.stopOnError) />
+ <cfif arguments.stopOnError AND NOT isValid>
+ <cfreturn false />
+ </cfif>
+ </cfloop>
+ </cfif>
+ </cfif>
+ <cfelseif schemaRules.type EQ "number">
+ <cfif NOT IsNumeric(JSONDoc)>
+ <cfset ArrayPrepend(request[arguments.errorVar], "#arguments._item# should be numeric") />
+ <cfif arguments.stopOnError>
+ <cfreturn false />
+ </cfif>
+ <cfelseif StructKeyExists(schemaRules, "min") AND JSONDoc LT schemaRules.min>
+ <cfset ArrayPrepend(request[arguments.errorVar], "#arguments._item# cannot be a number less than #schemaRules.min#") />
+ <cfif arguments.stopOnError>
+ <cfreturn false />
+ </cfif>
+ <cfelseif StructKeyExists(schemaRules, "max") AND JSONDoc GT schemaRules.max>
+ <cfset ArrayPrepend(request[arguments.errorVar], "#arguments._item# cannot be a number greater than #schemaRules.max#") />
+ <cfif arguments.stopOnError>
+ <cfreturn false />
+ </cfif>
+ </cfif>
+ <cfelseif schemaRules.type EQ "boolean" AND ( NOT IsBoolean(JSONDoc) OR ListFindNoCase("Yes,No", JSONDoc) OR IsNumeric(JSONDoc) )>
+ <cfset ArrayPrepend(request[arguments.errorVar], "#arguments._item# should be a boolean") />
+ <cfif arguments.stopOnError>
+ <cfreturn false />
+ </cfif>
+ <cfelseif schemaRules.type EQ "date">
+ <cfif NOT IsSimpleValue(JSONDoc) OR NOT IsDate(JSONDoc)
+ OR ( StructKeyExists(schemaRules, "mask") AND CompareNoCase( JSONDoc, DateFormat(JSONDoc, schemaRules.mask) ) NEQ 0 )>
+ <cfif StructKeyExists(schemaRules, "mask")>
+ <cfset msg = " in #schemaRules.mask# format" />
+ </cfif>
+ <cfset ArrayPrepend(request[arguments.errorVar], "#arguments._item# should be a date#msg#") />
+ <cfif arguments.stopOnError>
+ <cfreturn false />
+ </cfif>
+ </cfif>
+ <cfelseif schemaRules.type EQ "string">
+ <cfif NOT IsSimpleValue(JSONDoc)>
+ <cfset ArrayPrepend(request[arguments.errorVar], "#arguments._item# should be a string") />
+ <cfif arguments.stopOnError>
+ <cfreturn false />
+ </cfif>
+ <cfelseif StructKeyExists(schemaRules, "minlength") AND Len(JSONDoc) LT schemaRules.minlength>
+ <cfset ArrayPrepend(request[arguments.errorVar], "#arguments._item# should have a minimum length of #schemaRules.minlength#") />
+ <cfif arguments.stopOnError>
+ <cfreturn false />
+ </cfif>
+ <cfelseif StructKeyExists(schemaRules, "maxlength") AND Len(JSONDoc) GT schemaRules.maxlength>
+ <cfset ArrayPrepend(request[arguments.errorVar], "#arguments._item# should have a maximum length of #schemaRules.maxlength#") />
+ <cfif arguments.stopOnError>
+ <cfreturn false />
+ </cfif>
+ </cfif>
+ </cfif>
+
+ <cfif ArrayLen(request[arguments.errorVar])>
+ <cfreturn false />
+ <cfelse>
+ <cfreturn true />
+ </cfif>
+ </cffunction>
+
+<!------------------------------------------- PRIVATE ------------------------------------------->
+
+
+</cfcomponent>
View
5 ApplicationTemplates/SuperSimple/config/Coldbox.cfc
@@ -46,10 +46,7 @@ function configure(){
};
//Register interceptors as an array, we need order
- interceptors = [
- //Autowire
- {class="coldbox.system.interceptors.Autowire"}
- ];
+ interceptors = [];
}
</cfscript>
View
93 system/interceptors/Autowire.cfc
@@ -6,27 +6,20 @@ www.coldbox.org | www.luismajano.com | www.ortussolutions.com
Author : Luis Majano
Description :
- This interceptor is used to autowire plugins, handlers and interceptors.
- Plugins and handlers are autowired after creation. Intreceptors will always
- be autowired after the aspects load. This is to give chance for all the correct
- application aspects to be in place.
+ DEPRECATED, LEFT FOR COMPATIBILITY
----------------------------------------------------------------------->
-<cfcomponent hint="This is an autowire interceptor" output="false" extends="coldbox.system.Interceptor">
+<cfcomponent hint="This is an autowire interceptor DEPRECATED DO NOT USE" output="false" extends="coldbox.system.Interceptor">
<!------------------------------------------- CONSTRUCTOR ------------------------------------------->
<!--- configure --->
<cffunction name="configure" access="public" returntype="void" output="false" >
<cfscript>
+ var ormSettings = getSetting("orm").injection;
// Prepare Autowire Settings
- // Annotation Check
- if( NOT propertyExists("annotationCheck") or NOT isBoolean(getProperty("annotationCheck")) ){
- setProperty("annotationCheck",false);
- }
-
// Enable Entity Injection
if(NOT propertyExists("entityInjection") or NOT isBoolean(getProperty("entityInjection"))){
setProperty("entityInjection",false);
@@ -40,84 +33,12 @@ Description :
setProperty("entityExclude",'');
}
- // Get bean factory
- beanFactory = getPlugin("BeanFactory");
-
- </cfscript>
- </cffunction>
-
-<!------------------------------------------- INTERCEPTION POINTS ------------------------------------------->
-
- <!--- After EntityNew --->
- <cffunction name="ORMPostNew" access="public" returntype="void" output="false" >
- <!--- ************************************************************* --->
- <cfargument name="event" required="true" type="any" hint="The event object.">
- <cfargument name="interceptData" required="true" type="any" hint="A structure containing intercepted data = [entity=The created entity]">
- <!--- ************************************************************* --->
- <cfset processEntityInjection(argumentCollection=arguments)>
- </cffunction>
-
- <!--- ORMPostLoad --->
- <cffunction name="ORMPostLoad" access="public" returntype="void" output="false" >
- <!--- ************************************************************* --->
- <cfargument name="event" required="true" type="any" hint="The event object.">
- <cfargument name="interceptData" required="true" type="any" hint="A structure containing intercepted data = [entity=The created entity]">
- <!--- ************************************************************* --->
- <cfset processEntityInjection(argumentCollection=arguments)>
- </cffunction>
-
- <!--- processAutowire --->
- <cffunction name="processAutowire" access="public" returntype="void" output="false" hint="Process autowiring using a targetype and data.">
- <!--- ************************************************************* --->
- <cfargument name="target" type="any" required="true" hint="The target object to autowire" >
- <cfargument name="targetID" type="any" required="true" hint="The target identifier to use for wiring"/>
- <!--- ************************************************************* --->
- <cfscript>
- try{
- // Process Autowire
- beanFactory.autowire(target=arguments.target,
- annotationCheck=getProperty("annotationCheck"),
- targetID=arguments.targetID);
- }
- catch(Any e){
- log.error("Error autowiring #getmetadata(arguments.target).name#. #e.message# #e.detail#");
- $throw(message="Error autowiring #getmetadata(arguments.target).name#. #e.message# #e.detail#",detail="#e.stacktrace#",type="Autowire.AutowireException");
- }
- </cfscript>
- </cffunction>
-
-<!------------------------------------------- PRIVATE METHDOS ------------------------------------------->
-
- <cffunction name="processEntityInjection" access="private" returntype="void" output="false" >
- <!--- ************************************************************* --->
- <cfargument name="event" required="true" type="any" hint="The event object.">
- <cfargument name="interceptData" required="true" type="any" hint="A structure containing intercepted data = [entity=The created entity]">
- <!--- ************************************************************* --->
- <cfscript>
- var entityName = arguments.interceptData.entityName;
- var injectorInclude = getProperty("entityInclude");
- var injectorExclude = getProperty("entityExclude");
-
- // Enabled?
- if( NOT getProperty("entityInjection") ){
- return;
- }
+ // setup property compat
+ ormSettings.enabled = getProperty("entityInjection");
+ ormSettings.include = getProperty("entityInclude");
+ ormSettings.exclude = getProperty("entityExclude");
- // Include,Exclude?
- if( (len(injectorInclude) AND listContainsNoCase(injectorInclude,entityName))
- OR
- (len(injectorExclude) AND NOT listContainsNoCase(injectorExclude,entityName))
- OR
- (NOT len(injectorInclude) AND NOT len(injectorExclude) ) ){
-
- // Process DI
- processAutowire(target=arguments.interceptData.entity,targetID="ORMEntity-#entityName#");
- }
</cfscript>
</cffunction>
-
- <cffunction name="getUtil" access="private" output="false" returntype="any" hint="Create and return a util object" colddoc:generic="coldbox.system.core.util.Util">
- <cfreturn CreateObject("component","coldbox.system.core.util.Util")/>
- </cffunction>
</cfcomponent>
View
27 system/interceptors/SES.cfc
@@ -21,6 +21,8 @@ Description :
<cfscript>
// with closure
instance.withClosure = {};
+ // module closure
+ instance.withModule = "";
// STATIC Reserved Keys as needed for cleanups
instance.RESERVED_KEYS = "handler,action,view,viewNoLayout,module,moduleRouting";
@@ -196,9 +198,21 @@ Description :
// Iterate through module routes and process them
for(x=1; x lte ArrayLen(mConfig[arguments.module].routes); x=x+1){
- args = mConfig[arguments.module].routes[x];
- args.module = arguments.module;
- addRoute(argumentCollection=args);
+ // Verify if simple value, then treat it as an include
+ if( isSimpleValue( mConfig[arguments.module].routes[x] ) ){
+ // prepare module pivot
+ instance.withModule = arguments.module;
+ // Include it via conventions using declared route
+ includeRoutes(location=mConfig[arguments.module].mapping & "/" & mConfig[arguments.module].routes[x]);
+ // Remove pivot
+ instance.withModule = "";
+ }
+ // else, normal routing
+ else{
+ args = mConfig[arguments.module].routes[x];
+ args.module = arguments.module;
+ addRoute(argumentCollection=args);
+ }
}
return this;
@@ -345,6 +359,9 @@ Description :
if( NOT structIsEmpty( instance.withClosure ) ){
processWith( arguments );
}
+
+ // module closure
+ if( len( instance.withModule ) ){ arguments.module = instance.withModule; }
// Process all incoming arguments into the route to store
for(arg in arguments){
@@ -1038,10 +1055,10 @@ Description :
contextRouting = { action=reReplaceNoCase(requestString,foundRoute.regexpattern,""), event=arguments.event };
// add module or namespace
if( len( foundRoute.moduleRouting ) ){
- contextRouting.module = arguments.module;
+ contextRouting.module = foundRoute.moduleRouting;
}
else{
- contextRouting.namespace = arguments.namespace;
+ contextRouting.namespace = foundRoute.namespaceRouting;
}
// Try to Populate the params from the module pattern if any
View
33 system/orm/hibernate/EventHandler.cfc
@@ -22,7 +22,9 @@ component extends="coldbox.system.remote.ColdboxProxy" implements="CFIDE.orm.IEv
* postNew called by ColdBox which in turn announces a coldbox interception: ORMPostNew
*/
public void function postNew(any entity,any entityName){
- announceInterception("ORMPostNew",{entity = arguments.entity, entityName