# Copyright (c) 2002-2010 bivio Software, Inc. All Rights Reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: EmptyReply.pm,v 1.10 2010/09/08 21:32:03 nagler Exp $ package Bivio::Biz::Action::EmptyReply; use strict; use Bivio::Base 'Biz.Action'; our($VERSION) = sprintf('%d.%02d', q$Revision: 1.10 $ =~ /\d+/g); my($_AC) = b_use('Ext.ApacheConstants'); b_use('Agent.Task')->register(__PACKAGE__); b_use('Action.BasicAuthorization'); sub execute { my($proto, $req, $status, $output) = @_; $status ||= 'HTTP_OK'; $status = 'NOT_FOUND' if $status =~ /NOT_FOUND/; $status = 'SERVER_ERROR' if $status eq 'UPDATE_COLLISION'; my($reply) = $req->get('reply')->set_http_status($_AC->$status()); return if $reply->unsafe_get_output; $output ||= ''; $reply->set_output(\$output); return 1; } sub execute_forbidden { return shift->execute(shift, 'FORBIDDEN'); } sub execute_no_resources { return shift->execute(shift, 'HTTP_SERVICE_UNAVAILABLE'); } sub execute_not_found { return shift->execute(shift, 'NOT_FOUND'); } sub execute_server_error { return shift->execute(shift, 'SERVER_ERROR'); } sub execute_task_item { my($self, $error, $req) = @_; return $error =~ /^execute/ ? $self->$error($req) : $self->execute($req, uc($error)); } 1;