Mercurial > pub > Impl
annotate Lib/IMPL/Web/Application/RestCustomResource.pm @ 212:292226770180
bugfixes
| author | sergey |
|---|---|
| date | Fri, 29 Jun 2012 19:24:15 +0400 |
| parents | 5146e17a7b76 |
| children |
| rev | line source |
|---|---|
| 200 | 1 package IMPL::Web::Application::RestCustomResource; |
| 2 use strict; | |
| 3 | |
| 4 use IMPL::lang qw(:declare :constants); | |
| 5 use IMPL::declare { | |
| 6 require => { | |
| 7 Exception => "IMPL::Exception", | |
| 8 ArgumentException => '-IMPL::InvalidArgumentException', | |
|
201
0c018a247c8a
Reworked REST resource classes to be more transparent and intuitive
sergey
parents:
200
diff
changeset
|
9 ForbiddenException => 'IMPL::Web::ForbiddenException', |
|
0c018a247c8a
Reworked REST resource classes to be more transparent and intuitive
sergey
parents:
200
diff
changeset
|
10 NotFoundException => 'IMPL::Web::NotFoundException' |
| 200 | 11 }, |
| 12 base => { | |
| 13 'IMPL::Web::Application::RestBaseResource' => '@_' | |
| 14 } | |
| 15 }; | |
| 16 | |
| 17 BEGIN { | |
| 18 public property get => PROP_GET | PROP_OWNERSET; | |
| 19 public property put => PROP_GET | PROP_OWNERSET; | |
| 20 public property post => PROP_GET | PROP_OWNERSET; | |
| 21 public property delete => PROP_GET | PROP_OWNERSET; | |
| 22 } | |
| 23 | |
| 24 sub FetchChildResource { | |
| 25 my ($this,$id,$action) = @_; | |
| 26 | |
|
201
0c018a247c8a
Reworked REST resource classes to be more transparent and intuitive
sergey
parents:
200
diff
changeset
|
27 die NotFoundException->new() if $this->final; |
|
0c018a247c8a
Reworked REST resource classes to be more transparent and intuitive
sergey
parents:
200
diff
changeset
|
28 |
| 200 | 29 return $this->contract->Transform( $this->GetImpl($action), { parent => $this, id => $id } )->FetchChildResource($id,$action); |
| 30 } | |
| 31 | |
| 32 sub GetImpl { | |
| 33 my ($this,$action) = @_; | |
| 34 | |
| 35 my $method = $this->get or die ForbiddenException->new(); | |
|
201
0c018a247c8a
Reworked REST resource classes to be more transparent and intuitive
sergey
parents:
200
diff
changeset
|
36 return $this->InvokeMember($method,$action); |
| 200 | 37 } |
| 38 | |
| 39 sub PutImpl { | |
| 40 my ($this,$action) = @_; | |
| 41 my $method = $this->put or die ForbiddenException->new(); | |
|
201
0c018a247c8a
Reworked REST resource classes to be more transparent and intuitive
sergey
parents:
200
diff
changeset
|
42 return $this->InvokeMember($method,$action); |
| 200 | 43 } |
| 44 | |
| 45 sub PostImpl { | |
| 46 my ($this,$action) = @_; | |
| 47 my $method = $this->post or die ForbiddenException->new(); | |
|
201
0c018a247c8a
Reworked REST resource classes to be more transparent and intuitive
sergey
parents:
200
diff
changeset
|
48 return $this->InvokeMember($method,$action); |
| 200 | 49 } |
| 50 | |
| 51 sub DeleteImpl { | |
| 52 my ($this,$action) = @_; | |
| 53 my $method = $this->delete or die ForbiddenException->new(); | |
|
201
0c018a247c8a
Reworked REST resource classes to be more transparent and intuitive
sergey
parents:
200
diff
changeset
|
54 return $this->InvokeMember($method,$action); |
| 200 | 55 } |
| 56 | |
|
202
5146e17a7b76
IMPL::Web::Application::RestResource fixes, documentation
sergey
parents:
201
diff
changeset
|
57 sub InvokeMember { |
|
5146e17a7b76
IMPL::Web::Application::RestResource fixes, documentation
sergey
parents:
201
diff
changeset
|
58 my ($this,$method,$action) = @_; |
|
5146e17a7b76
IMPL::Web::Application::RestResource fixes, documentation
sergey
parents:
201
diff
changeset
|
59 |
|
5146e17a7b76
IMPL::Web::Application::RestResource fixes, documentation
sergey
parents:
201
diff
changeset
|
60 return $this->$method($action); |
|
5146e17a7b76
IMPL::Web::Application::RestResource fixes, documentation
sergey
parents:
201
diff
changeset
|
61 } |
|
5146e17a7b76
IMPL::Web::Application::RestResource fixes, documentation
sergey
parents:
201
diff
changeset
|
62 |
| 200 | 63 1; |
