Mercurial > pub > Impl
view Lib/IMPL/Web/Application/RestBaseResource.pm @ 206:c8fe3f84feba
+IMPL::Web::Handlers::ViewSelector
+IMPL::Web::Handlers::ErrorHandler
*IMPL::Web::Handlers::RestController moved types mappings to ViewSelector
author | sergey |
---|---|
date | Thu, 03 May 2012 16:48:39 +0400 |
parents | 5146e17a7b76 |
children |
line wrap: on
line source
package IMPL::Web::Application::RestBaseResource; use strict; use IMPL::lang qw(:declare :constants); use IMPL::declare { require => { Exception => 'IMPL::Exception', ArgumentException => '-IMPL::InvalidArgumentException', NotImplException => '-IMPL::NotImplementedException', ForbiddenException => 'IMPL::Web::ForbiddenException', TTransform => '-IMPL::Transform' }, base => { 'IMPL::Object' => undef, 'IMPL::Object::Autofill' => '@_' } }; BEGIN { public property id => PROP_GET | PROP_OWNERSET; public property parent => PROP_GET | PROP_OWNERSET; public property contract => PROP_GET | PROP_OWNERSET; protected property final => PROP_ALL; } sub target { shift; } sub CTOR { my ($this) = @_; die ArgumentException->new("id","Identifier is required for non-root resources") if $this->id and not length $this->id; die ArgumentException->new("A contract is required") unless $this->contract; } sub GetHttpImpl { my($this,$method) = @_; my %map = ( GET => 'GetImpl', PUT => 'PutImpl', POST => 'PostImpl', DELETE => 'DeleteImpl' ); return $map{$method}; } sub InvokeHttpMethod { my ($this,$method,$action) = @_; my $impl = $this->GetHttpImpl($method) || 'HttpFallbackImpl'; return $this->$impl($action); } sub GetImpl { die NotImplException->new(); } sub PutImpl { die NotImplException->new(); } sub PostImpl { die NotImplException->new(); } sub DeleteImpl { die NotImplException->new(); } sub HttpFallbackImpl { die ForbiddenException->new(); } sub FetchChildResource { return undef; } 1; __END__ =pod =cut