@@ -271,6 +271,10 @@ global.TRY = function(fn, err) {
271271 }
272272} ;
273273
274+ global . OBSOLETE = function ( name , message ) {
275+ console . log ( ':: OBSOLETE / IMPORTANT ---> "' + name + '"' , message ) ;
276+ } ;
277+
274278if ( global . setImmediate === undefined ) {
275279 global . setImmediate = function ( cb ) {
276280 process . nextTick ( cb ) ;
@@ -1825,7 +1829,7 @@ Framework.prototype.file = function(name, fnValidation, fnExecute, middleware, o
18251829 self . routes . files . push ( {
18261830 controller : ! _controller ? 'unknown' : _controller ,
18271831 name : name ,
1828- onValidation : fnValidation ,
1832+ onValidate : fnValidation ,
18291833 execute : fnExecute || fnValidation ,
18301834 middleware : middleware ,
18311835 options : options
@@ -2589,7 +2593,7 @@ Framework.prototype.install = function(type, name, declaration, options, callbac
25892593
25902594 if ( typeof ( obj . install ) === TYPE_FUNCTION ) {
25912595 if ( framework . config [ 'allow-compatibility' ] || obj . install . toString ( ) . indexOf ( 'function (framework' ) === 0 ) {
2592- console . log ( ' OBSOLETE ' + key + ': exports.install = function(framework <-- REMOVE ARGUMENT, options, name) { ... ') ;
2596+ OBSOLETE ( key , ' exports.install = function(framework <--- REMOVE THE ARGUMENT framework ') ;
25932597 obj . install ( self , options , name ) ;
25942598 } else
25952599 obj . install ( options , name ) ;
@@ -2802,7 +2806,7 @@ Framework.prototype.install_make = function(key, name, obj, options, callback, s
28022806
28032807 if ( typeof ( obj . install ) === TYPE_FUNCTION ) {
28042808 if ( framework . config [ 'allow-compatibility' ] || obj . install . toString ( ) . indexOf ( 'function (framework' ) === 0 ) {
2805- console . log ( ' OBSOLETE ' + key + ': exports.install = function(framework <-- REMOVE ARGUMENT, options, name) { ... ') ;
2809+ OBSOLETE ( key , ' exports.install = function(framework <--- REMOVE THE ARGUMENT framework ') ;
28062810 obj . install ( self , options , name ) ;
28072811 }
28082812 else
@@ -3087,6 +3091,40 @@ Framework.prototype.snapshot = function(url, filename, callback) {
30873091*/
30883092Framework . prototype . onValidation = null ;
30893093
3094+ /**
3095+ * Global validation
3096+ * @param {Function(name, value) } delegate
3097+ * @type {Boolean or StringErrorMessage }
3098+ */
3099+ Framework . prototype . onValidate = null ;
3100+
3101+ /**
3102+ * Global XML parsing
3103+ * @param {String } value
3104+ * @return {Object }
3105+ */
3106+ Framework . prototype . onParseXML = function ( value ) {
3107+ return framework_utils . parseXML ( value ) ;
3108+ } ;
3109+
3110+ /**
3111+ * Global JSON parsing
3112+ * @param {String } value
3113+ * @return {Object }
3114+ */
3115+ Framework . prototype . onParseJSON = function ( value ) {
3116+ return JSON . parse ( value ) ;
3117+ } ;
3118+
3119+ /**
3120+ * Global JSON parsing
3121+ * @param {String } value
3122+ * @return {Object }
3123+ */
3124+ Framework . prototype . onParseQuery = function ( value ) {
3125+ return qs . parse ( value ) ;
3126+ } ;
3127+
30903128/**
30913129 * Schema parser delegate
30923130 * @param {Request } req
@@ -5179,6 +5217,11 @@ Framework.prototype.load = function(debug, types, path) {
51795217 delete framework . assert ;
51805218 } , 500 ) ;
51815219
5220+ setTimeout ( function ( ) {
5221+ if ( self . onValidation )
5222+ OBSOLETE ( 'framework.onValidation()' , 'The function was renamed to "framework.onValidate()' ) ;
5223+ } , 2000 ) ;
5224+
51825225 self . $load ( types , directory ) ;
51835226 return self ;
51845227} ;
@@ -6209,7 +6252,7 @@ Framework.prototype.mail = function(address, subject, view, model, callback, lan
62096252 if ( language . indexOf ( '@' ) !== - 1 ) {
62106253 replyTo = language ;
62116254 language = undefined ;
6212- console . log ( 'OBSOLETE: F.mail(..., ..., [replyTo] --> has been replaced for [language]). ') ;
6255+ OBSOLETE ( 'F.mail' , ' F.mail(..., ..., [replyTo] --> the argument was replaced for [language])') ;
62136256 } else
62146257 controller . language = language ;
62156258 }
@@ -7371,12 +7414,12 @@ Framework.prototype._configure = function(arr, rewrite) {
73717414 break ;
73727415
73737416 case 'allow-compile-js' :
7374- console . log ( 'CONFIG: allow-compile-js is obsolete, use: allow-compile-script') ;
7417+ OBSOLETE ( 'config' , 'Instead of " allow-compile-js" use " allow-compile-script" ') ;
73757418 obj [ 'allow-compile-script' ] = value . toLowerCase ( ) === 'true' || value === '1' || value === 'on' ;
73767419 break ;
73777420
73787421 case 'allow-compile-css' :
7379- console . log ( 'CONFIG: allow-compile-css is obsolete, use: allow-compile-style') ;
7422+ OBSOLETE ( 'config' , 'Instead of " allow-compile-css" use " allow-compile-style" ') ;
73807423 obj [ 'allow-compile-style' ] = value . toLowerCase ( ) === 'true' || value === '1' || value === 'on' ;
73817424 break ;
73827425
@@ -7400,12 +7443,12 @@ Framework.prototype._configure = function(arr, rewrite) {
74007443 break ;
74017444
74027445 case 'static-url-css' :
7403- console . log ( 'OBSOLETE "config. static-url-css": use "config. static-url-style"') ;
7446+ OBSOLETE ( 'config' , 'Instead of " static-url-css" use "static-url-style"') ;
74047447 obj [ 'static-url-style' ] = value ;
74057448 break ;
74067449
74077450 case 'static-url-js' :
7408- console . log ( 'OBSOLETE "config. static-url-js": use "config. static-url-script"') ;
7451+ OBSOLETE ( 'config' , 'Instead of " static-url-js" use "static-url-script"') ;
74097452 obj [ 'static-url-script' ] = value ;
74107453 break ;
74117454
@@ -7447,7 +7490,7 @@ Framework.prototype._configure = function(arr, rewrite) {
74477490 * @return {String }
74487491 */
74497492Framework . prototype . routeJS = function ( name ) {
7450- console . log ( 'OBSOLETE framework.routeJS(): use framework.routeScript()') ;
7493+ OBSOLETE ( 'framework.routeJS()' , 'Instead of " framework.routeJS()" use " framework.routeScript()" ') ;
74517494 return this . routeScript ( name ) ;
74527495} ;
74537496
@@ -7472,7 +7515,7 @@ Framework.prototype.routeScript = function(name) {
74727515 * @return {String }
74737516 */
74747517Framework . prototype . routeCSS = function ( name ) {
7475- console . log ( 'OBSOLETE framework.routeCSS(): use framework.routeStyle()') ;
7518+ OBSOLETE ( 'framework.routeCSS()' , 'Instead of " framework.routeCSS()" use " framework.routeStyle()" ') ;
74767519 return this . routeStyle ( name ) ;
74777520} ;
74787521
@@ -9141,7 +9184,7 @@ Subscribe.prototype.doEnd = function() {
91419184 }
91429185
91439186 try {
9144- req . body = utils . parseXML ( req . buffer_data . trim ( ) ) ;
9187+ req . body = framework . onParseXML ( req . buffer_data . trim ( ) ) ;
91459188 req . buffer_data = null ;
91469189 self . prepare ( req . flags , req . uri . pathname ) ;
91479190 } catch ( err ) {
@@ -9164,13 +9207,13 @@ Subscribe.prototype.doEnd = function() {
91649207
91659208 if ( req . $type === 1 ) {
91669209 try {
9167- req . body = JSON . parse ( req . buffer_data ) ;
9210+ req . body = framework . onParseJSON ( req . buffer_data ) ;
91689211 } catch ( e ) {
91699212 self . route400 ( new Error ( 'Not valid JSON data.' ) ) ;
91709213 return self ;
91719214 }
91729215 } else
9173- req . body = qs . parse ( req . buffer_data ) ;
9216+ req . body = framework . onParseQuery ( req . buffer_data ) ;
91749217
91759218 if ( ! route . schema ) {
91769219 self . prepare ( req . flags , req . uri . pathname ) ;
@@ -9222,7 +9265,7 @@ Subscribe.prototype.doEndfile = function() {
92229265 var file = framework . routes . files [ i ] ;
92239266 try {
92249267
9225- if ( file . onValidation . call ( framework , req , res , true ) ) {
9268+ if ( file . onValidate . call ( framework , req , res , true ) ) {
92269269
92279270 if ( file . middleware === null )
92289271 file . execute . call ( framework , req , res , false ) ;
@@ -9736,7 +9779,7 @@ Controller.prototype.validate = function(model, properties, prefix, name) {
97369779 return builders . validate ( properties , model , prefix ) ;
97379780
97389781 var error = new builders . ErrorBuilder ( resource ) ;
9739- return utils . validate . call ( self , model , properties , framework . onValidation , error ) ;
9782+ return utils . validate . call ( self , model , properties , framework . onValidate || framework . onValidation , error ) ;
97409783} ;
97419784
97429785/*
@@ -10222,7 +10265,7 @@ Controller.prototype.sitemap = function(name, url, index) {
1022210265 if ( ! url )
1022310266 return self . repository [ REPOSITORY_SITEMAP ] ;
1022410267
10225- console . log ( 'OBSOLETE sitemap: The newest version supports new sitemap mechanism.') ;
10268+ OBSOLETE ( ' sitemap' , ' The newest version supports new sitemap mechanism.') ;
1022610269
1022710270 if ( self . repository . sitemap === undefined )
1022810271 self . repository . sitemap = [ ] ;
@@ -11223,7 +11266,7 @@ Controller.prototype._routeHelper = function(current, name, fn) {
1122311266 * @return {String }
1122411267 */
1122511268Controller . prototype . routeJS = function ( name , tag ) {
11226- console . log ( 'OBSOLETE controller.routeJS(): use controller.routeScript()') ;
11269+ OBSOLETE ( 'controller.routeJS()' , 'Instead of " controller.routeJS()" use " controller.routeScript()" ') ;
1122711270 return this . routeScript ( name , tag ) ;
1122811271} ;
1122911272
@@ -11248,7 +11291,7 @@ Controller.prototype.routeScript = function(name, tag) {
1124811291 * @return {String }
1124911292 */
1125011293Controller . prototype . routeCSS = function ( name , tag ) {
11251- console . log ( 'OBSOLETE controller.routeCSS(): use controller.routeStyle()') ;
11294+ OBSOLETE ( 'controller.routeCSS()' , 'Instead of " controller.routeCSS()" use " controller.routeStyle()" ') ;
1125211295 return this . routeStyle ( name , tag ) ;
1125311296} ;
1125411297
@@ -12276,7 +12319,7 @@ Controller.prototype.proxy = function(url, obj, fnCallback, timeout) {
1227612319 return ;
1227712320
1227812321 if ( ( headers [ 'content-type' ] || '' ) . indexOf ( 'application/json' ) !== - 1 )
12279- data = JSON . parse ( data ) ;
12322+ data = framework . onParseJSON ( data ) ;
1228012323
1228112324 fnCallback . call ( self , error , data , code , headers ) ;
1228212325
@@ -12930,7 +12973,7 @@ WebSocket.prototype.proxy = function(url, obj, fnCallback) {
1293012973 return ;
1293112974
1293212975 if ( ( headers [ 'content-type' ] || '' ) . indexOf ( 'application/json' ) !== - 1 )
12933- data = JSON . parse ( data ) ;
12976+ data = framework . onParseJSON ( data ) ;
1293412977
1293512978 fnCallback . call ( self , error , data , code , headers ) ;
1293612979
@@ -13103,7 +13146,7 @@ WebSocket.prototype.validate = function(model, properties, prefix, name) {
1310313146 } ;
1310413147
1310513148 var error = new builders . ErrorBuilder ( resource ) ;
13106- return utils . validate . call ( self , model , properties , framework . onValidation , error ) ;
13149+ return utils . validate . call ( self , model , properties , framework . onValidate || framework . onValidation , error ) ;
1310713150} ;
1310813151
1310913152/*
@@ -13362,7 +13405,7 @@ WebSocketClient.prototype.parse = function() {
1336213405 // JSON
1336313406 if ( self . type === 3 ) {
1336413407 try {
13365- self . container . emit ( 'message' , self , JSON . parse ( self . container . config [ 'default-websocket-encodedecode' ] === true ? $decodeURIComponent ( output ) : output ) ) ;
13408+ self . container . emit ( 'message' , self , framework . onParseJSON ( self . container . config [ 'default-websocket-encodedecode' ] === true ? $decodeURIComponent ( output ) : output ) ) ;
1336613409 } catch ( ex ) {
1336713410 self . errors ++ ;
1336813411 self . container . emit ( 'error' , new Error ( 'JSON parser: ' + ex . toString ( ) ) , self ) ;
@@ -14063,7 +14106,7 @@ http.IncomingMessage.prototype = {
1406314106 var self = this ;
1406414107 if ( self . _dataGET )
1406514108 return self . _dataGET ;
14066- self . _dataGET = qs . parse ( self . uri . query ) ;
14109+ self . _dataGET = framework . onParseQuery ( self . uri . query ) ;
1406714110 return self . _dataGET ;
1406814111 } ,
1406914112
0 commit comments