annotate Lib/IMPL/Web/Application/RestCustomResource.pm @ 200:a9dbe534d236

sync
author sergey
date Tue, 24 Apr 2012 02:34:49 +0400
parents
children 0c018a247c8a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
200
sergey
parents:
diff changeset
1 package IMPL::Web::Application::RestCustomResource;
sergey
parents:
diff changeset
2 use strict;
sergey
parents:
diff changeset
3
sergey
parents:
diff changeset
4 use IMPL::lang qw(:declare :constants);
sergey
parents:
diff changeset
5 use IMPL::declare {
sergey
parents:
diff changeset
6 require => {
sergey
parents:
diff changeset
7 Exception => "IMPL::Exception",
sergey
parents:
diff changeset
8 ArgumentException => '-IMPL::InvalidArgumentException',
sergey
parents:
diff changeset
9 ForbiddenException => 'IMPL::Web::ForbiddenException'
sergey
parents:
diff changeset
10 },
sergey
parents:
diff changeset
11 base => {
sergey
parents:
diff changeset
12 'IMPL::Web::Application::RestBaseResource' => '@_'
sergey
parents:
diff changeset
13 }
sergey
parents:
diff changeset
14 };
sergey
parents:
diff changeset
15
sergey
parents:
diff changeset
16 BEGIN {
sergey
parents:
diff changeset
17 public property get => PROP_GET | PROP_OWNERSET;
sergey
parents:
diff changeset
18 public property put => PROP_GET | PROP_OWNERSET;
sergey
parents:
diff changeset
19 public property post => PROP_GET | PROP_OWNERSET;
sergey
parents:
diff changeset
20 public property delete => PROP_GET | PROP_OWNERSET;
sergey
parents:
diff changeset
21 }
sergey
parents:
diff changeset
22
sergey
parents:
diff changeset
23 sub CTOR {
sergey
parents:
diff changeset
24 my ($this) = @_;
sergey
parents:
diff changeset
25
sergey
parents:
diff changeset
26 die ArgumentException->new("parent") unless $this->parent;
sergey
parents:
diff changeset
27 }
sergey
parents:
diff changeset
28
sergey
parents:
diff changeset
29 sub FetchChildResource {
sergey
parents:
diff changeset
30 my ($this,$id,$action) = @_;
sergey
parents:
diff changeset
31
sergey
parents:
diff changeset
32 return $this->contract->Transform( $this->GetImpl($action), { parent => $this, id => $id } )->FetchChildResource($id,$action);
sergey
parents:
diff changeset
33 }
sergey
parents:
diff changeset
34
sergey
parents:
diff changeset
35 sub GetImpl {
sergey
parents:
diff changeset
36 my ($this,$action) = @_;
sergey
parents:
diff changeset
37
sergey
parents:
diff changeset
38 my $method = $this->get or die ForbiddenException->new();
sergey
parents:
diff changeset
39 return $this->$method($action);
sergey
parents:
diff changeset
40 }
sergey
parents:
diff changeset
41
sergey
parents:
diff changeset
42 sub PutImpl {
sergey
parents:
diff changeset
43 my ($this,$action) = @_;
sergey
parents:
diff changeset
44 my $method = $this->put or die ForbiddenException->new();
sergey
parents:
diff changeset
45 return $this->$method($action);
sergey
parents:
diff changeset
46 }
sergey
parents:
diff changeset
47
sergey
parents:
diff changeset
48 sub PostImpl {
sergey
parents:
diff changeset
49 my ($this,$action) = @_;
sergey
parents:
diff changeset
50 my $method = $this->post or die ForbiddenException->new();
sergey
parents:
diff changeset
51 return $this->$method($action);
sergey
parents:
diff changeset
52 }
sergey
parents:
diff changeset
53
sergey
parents:
diff changeset
54 sub DeleteImpl {
sergey
parents:
diff changeset
55 my ($this,$action) = @_;
sergey
parents:
diff changeset
56 my $method = $this->delete or die ForbiddenException->new();
sergey
parents:
diff changeset
57 return $this->$method($action);
sergey
parents:
diff changeset
58 }
sergey
parents:
diff changeset
59
sergey
parents:
diff changeset
60 1;