diff --git a/haxelib.xml b/haxelib.xml index e13a353..3500615 100644 --- a/haxelib.xml +++ b/haxelib.xml @@ -3,9 +3,9 @@ - + MVC Framework for server-side development - fixes for haxe svn + changed to use the new NullArgument.throwIfNull syntax \ No newline at end of file diff --git a/src/neko/ufront/web/FileSession.hx b/src/neko/ufront/web/FileSession.hx index e5ca4c0..e3461b6 100644 --- a/src/neko/ufront/web/FileSession.hx +++ b/src/neko/ufront/web/FileSession.hx @@ -1,9 +1,10 @@ +package neko.ufront.web; + /** * ... * @author Andreas Söderlund */ -package neko.ufront.web; import ufront.web.IHttpSessionState; import thx.sys.Lib; diff --git a/src/neko/ufront/web/HttpRequest.hx b/src/neko/ufront/web/HttpRequest.hx index ecbc0a5..3c9fb9e 100644 --- a/src/neko/ufront/web/HttpRequest.hx +++ b/src/neko/ufront/web/HttpRequest.hx @@ -1,10 +1,10 @@ +package neko.ufront.web; + /** * ... * @author Franco Ponticelli */ -package neko.ufront.web; - import haxe.io.Bytes; import thx.error.Error; import thx.sys.Lib; diff --git a/src/ufront/acl/Acl.hx b/src/ufront/acl/Acl.hx index 33eb9ee..4b985d7 100644 --- a/src/ufront/acl/Acl.hx +++ b/src/ufront/acl/Acl.hx @@ -1,13 +1,14 @@ package ufront.acl; -import thx.error.NullArgument; -import thx.error.Error; -import thx.collections.Set; -using Iterators; /** * @todo remove loops over keys for removal */ +import thx.error.NullArgument; +import thx.error.Error; +import thx.collections.Set; +using Iterators; + typedef Combo = { type : AccessType, assert : Null String -> String -> String -> Bool> @@ -128,7 +129,7 @@ class Acl public function addResource(resource : String, ?parent : String) { - NullArgument.throwIfNull(resource, "resource"); + NullArgument.throwIfNull(resource); if(existsResource(resource)) throw new Error("Resource '{0}' already exists in the ACL", resource); if(null != parent) @@ -153,8 +154,8 @@ class Acl public function inheritsResource(resource : String, inherit : String, onlyParent = false) { - NullArgument.throwIfNull(resource, "resource"); - NullArgument.throwIfNull(inherit, "inherit"); + NullArgument.throwIfNull(resource); + NullArgument.throwIfNull(inherit); var r = _resources.get(resource); if(null == r) @@ -178,7 +179,7 @@ class Acl public function removeResource(resource : String) { - NullArgument.throwIfNull(resource, "resource"); + NullArgument.throwIfNull(resource); if(!existsResource(resource)) return false; @@ -420,7 +421,7 @@ class Acl function _roleDFSOnePrivilege(role : String, resource : String, privilege : String) : Null { - NullArgument.throwIfNull(privilege, "privilege"); + NullArgument.throwIfNull(privilege); var dfs = { visited : new Set(), @@ -447,7 +448,7 @@ class Acl function _roleDFSVisitOnePrivilege(role : String, resource : String, privilege : String, dfs) : Null { - NullArgument.throwIfNull(privilege, "privilege"); + NullArgument.throwIfNull(privilege); var result = _getRuleType(resource, role, privilege); if(null != result) diff --git a/src/ufront/acl/Registry.hx b/src/ufront/acl/Registry.hx index 19170a7..86ceaf7 100644 --- a/src/ufront/acl/Registry.hx +++ b/src/ufront/acl/Registry.hx @@ -1,4 +1,5 @@ package ufront.acl; + import thx.collections.Set; import thx.error.NullArgument; import thx.error.Error; @@ -55,8 +56,8 @@ class Registry public function inherits(role : String, inherit : String, onlyParents = false) { - NullArgument.throwIfNull(role, "role"); - NullArgument.throwIfNull(inherit, "inherit"); + NullArgument.throwIfNull(role); + NullArgument.throwIfNull(inherit); var r = _roles.get(role); if(null == r) diff --git a/src/ufront/auth/adapter/Digest.hx b/src/ufront/auth/adapter/Digest.hx index 1f2bf39..8b6fe77 100644 --- a/src/ufront/auth/adapter/Digest.hx +++ b/src/ufront/auth/adapter/Digest.hx @@ -27,10 +27,10 @@ class Digest implements IAuthAdapter public function authenticate() { - NullArgument.throwIfNull(filename, "filename"); - NullArgument.throwIfNull(realm, "realm"); - NullArgument.throwIfNull(username, "username"); - NullArgument.throwIfNull(password, "password"); + NullArgument.throwIfNull(filename); + NullArgument.throwIfNull(realm); + NullArgument.throwIfNull(username); + NullArgument.throwIfNull(password); if(!FileSystem.exists(filename)) throw new Error("authentication file '{0}' does not exists", filename); diff --git a/src/ufront/auth/storage/SessionStorage.hx b/src/ufront/auth/storage/SessionStorage.hx index 52407de..8dc83fe 100644 --- a/src/ufront/auth/storage/SessionStorage.hx +++ b/src/ufront/auth/storage/SessionStorage.hx @@ -10,7 +10,7 @@ class SessionStorage implements IAuthStorage var _session : IHttpSessionState; public function new(session : IHttpSessionState, ?name : String) { - NullArgument.throwIfNull(session, "session"); + NullArgument.throwIfNull(session); _session = session; if(null == name) _name = DEFAULT_VARIABLE_NAME; diff --git a/src/ufront/web/DirectoryUrlFilter.hx b/src/ufront/web/DirectoryUrlFilter.hx index f4a22f4..248de64 100644 --- a/src/ufront/web/DirectoryUrlFilter.hx +++ b/src/ufront/web/DirectoryUrlFilter.hx @@ -10,7 +10,7 @@ class DirectoryUrlFilter implements IUrlFilter public var directory(default, null) : String; public function new(directory : String) { - NullArgument.throwIfNull(directory, "directory"); + NullArgument.throwIfNull(directory); if(directory.endsWith("/")) directory = directory.substr(0, directory.length-1); this.directory = directory; diff --git a/src/ufront/web/HttpContext.hx b/src/ufront/web/HttpContext.hx index 5470a06..2ccd773 100755 --- a/src/ufront/web/HttpContext.hx +++ b/src/ufront/web/HttpContext.hx @@ -54,7 +54,7 @@ class HttpContext public function addUrlFilter(filter : IUrlFilter) { - NullArgument.throwIfNull(filter, "filter"); + NullArgument.throwIfNull(filter); _requestUri = null; _urlFilters.push(filter); return this; diff --git a/src/ufront/web/HttpContextImpl.hx b/src/ufront/web/HttpContextImpl.hx index 9b86e4f..356aa20 100755 --- a/src/ufront/web/HttpContextImpl.hx +++ b/src/ufront/web/HttpContextImpl.hx @@ -19,19 +19,19 @@ class HttpContextImpl extends HttpContext public function setRequest(request : HttpRequest) { - NullArgument.throwIfNull(request, "request"); + NullArgument.throwIfNull(request); this.request = request; } public function setResponse(response : HttpResponse) { - NullArgument.throwIfNull(response, "response"); + NullArgument.throwIfNull(response); this.response = response; } public function setSession(session : IHttpSessionState) { - NullArgument.throwIfNull(session, "session"); + NullArgument.throwIfNull(session); this.session = session; } diff --git a/src/ufront/web/HttpResponse.hx b/src/ufront/web/HttpResponse.hx index ba9703c..bef3fb2 100644 --- a/src/ufront/web/HttpResponse.hx +++ b/src/ufront/web/HttpResponse.hx @@ -100,8 +100,8 @@ class HttpResponse public function setHeader(name : String, value : String) { - NullArgument.throwIfNull(name, "name"); - NullArgument.throwIfNull(value, "value"); + NullArgument.throwIfNull(name); + NullArgument.throwIfNull(value); _headers.set(name, value); } diff --git a/src/ufront/web/mvc/ContentResult.hx b/src/ufront/web/mvc/ContentResult.hx index 9f8ccf9..9e715af 100644 --- a/src/ufront/web/mvc/ContentResult.hx +++ b/src/ufront/web/mvc/ContentResult.hx @@ -14,7 +14,7 @@ class ContentResult extends ActionResult override function executeResult(controllerContext : ControllerContext) { - NullArgument.throwIfNull(controllerContext, "controllerContext"); + NullArgument.throwIfNull(controllerContext); if(null != contentType) controllerContext.response.contentType = contentType; diff --git a/src/ufront/web/mvc/ControllerBase.hx b/src/ufront/web/mvc/ControllerBase.hx index 1ea36a0..b460e40 100644 --- a/src/ufront/web/mvc/ControllerBase.hx +++ b/src/ufront/web/mvc/ControllerBase.hx @@ -40,7 +40,7 @@ class ControllerBase implements IController, implements haxe.rtti.Infos public function execute(requestContext : RequestContext, async : hxevents.Async) : Void { - NullArgument.throwIfNull(requestContext, "requestContext"); + NullArgument.throwIfNull(requestContext); if(controllerContext == null) controllerContext = new ControllerContext(this, requestContext); diff --git a/src/ufront/web/mvc/ControllerBuilder.hx b/src/ufront/web/mvc/ControllerBuilder.hx index 0621a75..a1fd0b8 100644 --- a/src/ufront/web/mvc/ControllerBuilder.hx +++ b/src/ufront/web/mvc/ControllerBuilder.hx @@ -28,7 +28,7 @@ class ControllerBuilder public function setControllerFactory(controllerFactory : IControllerFactory) { - NullArgument.throwIfNull(controllerFactory, "controllerFactory"); + NullArgument.throwIfNull(controllerFactory); this._controllerFactory = controllerFactory; return controllerFactory; diff --git a/src/ufront/web/mvc/DefaultControllerFactory.hx b/src/ufront/web/mvc/DefaultControllerFactory.hx index 3f1bed5..7a0cd57 100644 --- a/src/ufront/web/mvc/DefaultControllerFactory.hx +++ b/src/ufront/web/mvc/DefaultControllerFactory.hx @@ -11,7 +11,7 @@ class DefaultControllerFactory implements IControllerFactory { // TODO: IControllerActivator as ControllerBuilder public function new(controllerBuilder : ControllerBuilder, dependencyResolver : IDependencyResolver) { - NullArgument.throwIfNull(controllerBuilder, "controllerBuilder"); + NullArgument.throwIfNull(controllerBuilder); _controllerBuilder = controllerBuilder; _dependencyResolver = dependencyResolver; diff --git a/src/ufront/web/mvc/FormValueProviderFactory.hx b/src/ufront/web/mvc/FormValueProviderFactory.hx index 0e9d219..fdd37f6 100644 --- a/src/ufront/web/mvc/FormValueProviderFactory.hx +++ b/src/ufront/web/mvc/FormValueProviderFactory.hx @@ -1,13 +1,14 @@ package ufront.web.mvc; -import thx.error.NullArgument; -import ufront.web.mvc.ControllerContext; -import ufront.web.mvc.IValueProvider; /** * ... * @author Andreas Soderlund */ +import thx.error.NullArgument; +import ufront.web.mvc.ControllerContext; +import ufront.web.mvc.IValueProvider; + class FormValueProviderFactory extends ValueProviderFactory { public function new() @@ -17,7 +18,7 @@ class FormValueProviderFactory extends ValueProviderFactory override public function getValueProvider(controllerContext : ControllerContext) : IValueProvider { - NullArgument.throwIfNull(controllerContext, "controllerContext"); + NullArgument.throwIfNull(controllerContext); return new FormValueProvider(controllerContext); } } \ No newline at end of file diff --git a/src/ufront/web/mvc/ForwardResult.hx b/src/ufront/web/mvc/ForwardResult.hx index cc63b01..5c067ed 100644 --- a/src/ufront/web/mvc/ForwardResult.hx +++ b/src/ufront/web/mvc/ForwardResult.hx @@ -21,7 +21,7 @@ class ForwardResult extends ActionResult override function executeResult(controllerContext : ControllerContext) { - NullArgument.throwIfNull(controllerContext, "controllerContext"); + NullArgument.throwIfNull(controllerContext); var url = new UrlHelperInst(controllerContext.requestContext).route(params); var redirect = new RedirectResult(url, false); diff --git a/src/ufront/web/mvc/JsonResult.hx b/src/ufront/web/mvc/JsonResult.hx index 7e591ae..fc448b7 100644 --- a/src/ufront/web/mvc/JsonResult.hx +++ b/src/ufront/web/mvc/JsonResult.hx @@ -15,15 +15,12 @@ class JsonResult extends ActionResult override function executeResult(controllerContext : ControllerContext) { - NullArgument.throwIfNull(controllerContext, "controllerContext"); + NullArgument.throwIfNull(controllerContext); controllerContext.response.contentType = "application/json"; var serialized = Json.encode(content); - -// if(null != fileDownloadName) -// controllerContext.response.setHeader("content-disposition", "attachment; filename=" + fileDownloadName); -// controllerContext.response.writeBytes(content); + controllerContext.response.write(serialized); } } \ No newline at end of file diff --git a/src/ufront/web/mvc/MvcHandler.hx b/src/ufront/web/mvc/MvcHandler.hx index 20e5949..8e81b40 100644 --- a/src/ufront/web/mvc/MvcHandler.hx +++ b/src/ufront/web/mvc/MvcHandler.hx @@ -12,7 +12,7 @@ class MvcHandler implements IHttpHandler { public var controllerBuilder(getControllerBuilder, setControllerBuilder) : ControllerBuilder; public function new(requestContext : RequestContext) { - NullArgument.throwIfNull(requestContext, "requestContext"); + NullArgument.throwIfNull(requestContext); this.requestContext = requestContext; } diff --git a/src/ufront/web/mvc/QueryStringValueProviderFactory.hx b/src/ufront/web/mvc/QueryStringValueProviderFactory.hx index 378b3e0..bba12f6 100644 --- a/src/ufront/web/mvc/QueryStringValueProviderFactory.hx +++ b/src/ufront/web/mvc/QueryStringValueProviderFactory.hx @@ -17,7 +17,7 @@ class QueryStringValueProviderFactory extends ValueProviderFactory override public function getValueProvider(controllerContext : ControllerContext) : IValueProvider { - NullArgument.throwIfNull(controllerContext, "controllerContext"); + NullArgument.throwIfNull(controllerContext); return new QueryStringValueProvider(controllerContext); } } \ No newline at end of file diff --git a/src/ufront/web/mvc/RedirectResult.hx b/src/ufront/web/mvc/RedirectResult.hx index c732ea7..75ede35 100644 --- a/src/ufront/web/mvc/RedirectResult.hx +++ b/src/ufront/web/mvc/RedirectResult.hx @@ -10,14 +10,14 @@ class RedirectResult extends ActionResult public function new(url : String, permanentRedirect = false) { - NullArgument.throwIfNull(url, "url"); + NullArgument.throwIfNull(url); this.url = url; this.permanentRedirect = permanentRedirect; } override function executeResult(controllerContext : ControllerContext) { - NullArgument.throwIfNull(controllerContext, "controllerContext"); + NullArgument.throwIfNull(controllerContext); controllerContext.response.clear(); if(permanentRedirect) controllerContext.response.permanentRedirect(url); diff --git a/src/ufront/web/mvc/RouteDataValueProviderFactory.hx b/src/ufront/web/mvc/RouteDataValueProviderFactory.hx index 29cb087..8aad39d 100644 --- a/src/ufront/web/mvc/RouteDataValueProviderFactory.hx +++ b/src/ufront/web/mvc/RouteDataValueProviderFactory.hx @@ -17,7 +17,7 @@ class RouteDataValueProviderFactory extends ValueProviderFactory override public function getValueProvider(controllerContext : ControllerContext) : IValueProvider { - NullArgument.throwIfNull(controllerContext, "controllerContext"); + NullArgument.throwIfNull(controllerContext); return new RouteDataValueProvider(controllerContext); } } \ No newline at end of file diff --git a/src/ufront/web/mvc/ViewResult.hx b/src/ufront/web/mvc/ViewResult.hx index 6ef36b3..5bcae87 100644 --- a/src/ufront/web/mvc/ViewResult.hx +++ b/src/ufront/web/mvc/ViewResult.hx @@ -27,7 +27,7 @@ class ViewResult extends ActionResult override function executeResult(context : ControllerContext) { - NullArgument.throwIfNull(context, "context"); + NullArgument.throwIfNull(context); if(null == viewName || "" == viewName) viewName = context.routeData.getRequired("action"); @@ -59,7 +59,7 @@ class ViewResult extends ActionResult function findView(context : ControllerContext, viewName : String) : ViewEngineResult { - NullArgument.throwIfNull(viewName, "viewName"); + NullArgument.throwIfNull(viewName); for(engine in ViewEngines.engines) { var result = engine.findView(context, viewName); diff --git a/src/ufront/web/mvc/view/UrlHelper.hx b/src/ufront/web/mvc/view/UrlHelper.hx index f74e00f..46cd4c1 100644 --- a/src/ufront/web/mvc/view/UrlHelper.hx +++ b/src/ufront/web/mvc/view/UrlHelper.hx @@ -1,6 +1,5 @@ package ufront.web.mvc.view; import thx.error.Error; -import thx.error.NullArgument; import ufront.web.mvc.IViewHelper; import ufront.web.routing.RequestContext; import ufront.web.routing.Route; @@ -78,7 +77,8 @@ class UrlHelperInst if (null == route) throw new Error("unable to find a controller for {0}", Std.string(hash)); hash.set("controller", route.defaults.get("controller")); - NullArgument.throwIfNull(hash.get("controller"), "controller"); + if (null == hash.get("controller")) + throw new Error("the routed data doesn't include the 'controller' parameter"); } for(route in __req.routeData.route.routes.iterator()) diff --git a/src/ufront/web/routing/PatternConstraint.hx b/src/ufront/web/routing/PatternConstraint.hx index c0f8187..b1ebc77 100755 --- a/src/ufront/web/routing/PatternConstraint.hx +++ b/src/ufront/web/routing/PatternConstraint.hx @@ -16,9 +16,9 @@ class PatternConstraint implements IRouteConstraint var validateDefault : Bool; public function new(parametername : String, pattern : String, options = "", validatedefault = false) { - NullArgument.throwIfNull(parametername, "parametername"); - NullArgument.throwIfNull(pattern, "pattern"); - NullArgument.throwIfNull(options, "options"); + NullArgument.throwIfNull(parametername); + NullArgument.throwIfNull(pattern); + NullArgument.throwIfNull(options); this.parameterName = parametername; this.pattern = new EReg(pattern, options); this.validateDefault = validatedefault; diff --git a/src/ufront/web/routing/Route.hx b/src/ufront/web/routing/Route.hx index 3f2c911..db51199 100644 --- a/src/ufront/web/routing/Route.hx +++ b/src/ufront/web/routing/Route.hx @@ -36,11 +36,11 @@ class Route extends RouteBase */ public function new(url : String, handler : IRouteHandler, ?defaults : Hash, ?constraints : Array) { - NullArgument.throwIfNull(url, "url"); + NullArgument.throwIfNull(url); if (!url.startsWith("/")) throw new Error("invalid route url '{0}'; url must begin with '/'", url); this.url = url; - NullArgument.throwIfNull(handler, "handler"); + NullArgument.throwIfNull(handler); this.handler = handler; if (null == defaults) this.defaults = new Hash(); diff --git a/src/ufront/web/routing/RouteParamExtractor.hx b/src/ufront/web/routing/RouteParamExtractor.hx index 8876d7d..c25c29f 100644 --- a/src/ufront/web/routing/RouteParamExtractor.hx +++ b/src/ufront/web/routing/RouteParamExtractor.hx @@ -14,13 +14,13 @@ class RouteParamExtractor var data : Hash; public function new(ast : UriSegments) { - NullArgument.throwIfNull(ast, "ast"); + NullArgument.throwIfNull(ast); this.ast = ast; } public function extract(uri : String) : Hash { - NullArgument.throwIfNull(uri, "uri"); + NullArgument.throwIfNull(uri); var segments = uri.split("/"); if(segments.length <= 1) diff --git a/src/ufront/web/routing/RouteUriParser.hx b/src/ufront/web/routing/RouteUriParser.hx index 7e3b422..ffa6901 100644 --- a/src/ufront/web/routing/RouteUriParser.hx +++ b/src/ufront/web/routing/RouteUriParser.hx @@ -13,7 +13,7 @@ class RouteUriParser public function parse(uri : String, implicitOptionals : Set) : UriSegments { - NullArgument.throwIfNull(uri, "uri"); + NullArgument.throwIfNull(uri); var segments = uri.split("/"); if(segments.length <= 1) throw new Error("a uri must start with a slash");