| 1 | # -*- perl -*- | ||
| 2 | |||
| 3 | # Copyright (c) 2010 AdCopy | ||
| 4 | # Author: Jeff Weisberg | ||
| 5 | # Created: 2010-Jan-13 12:11 (EST) | ||
| 6 | # Function: | ||
| 7 | # | ||
| 8 | # $Id: TaskCreate.pm,v 1.3 2011/01/10 15:23:00 jaw Exp $ | ||
| 9 | |||
| 10 | package AC::MrGamoo::API::TaskCreate; | ||
| 11 | use AC::MrGamoo::Debug 'api_task'; | ||
| 12 | use AC::MrGamoo::Config; | ||
| 13 | use AC::MrGamoo::Protocol; | ||
| 14 | |||
| 15 | use AC::MrGamoo::API::Simple; | ||
| 16 | |||
| 17 | use strict; | ||
| 18 | |||
| 19 | sub handler { | ||
| 20 | my $class = shift; | ||
| 21 | my $io = shift; | ||
| 22 | my $proto = shift; | ||
| 23 | my $req = shift; | ||
| 24 | my $content = shift; | ||
| 25 | |||
| 26 | debug("new task $req->{jobid}/$req->{taskid}"); | ||
| 27 | my $x = AC::MrGamoo::Task->new( %$req ); | ||
| 28 | my $r = $x ? $x->start() : undef; | ||
| 29 | |||
| 30 | if( $r ){ | ||
| 31 | reply( 200, 'OK', $io, $proto, $req ); | ||
| 32 | }else{ | ||
| 33 | reply( 500, 'Error', $io, $proto, $req ); | ||
| 34 | } | ||
| 35 | } | ||
| 36 | |||
| 37 | 1; |