# Copyright (c) 1999-2009 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: Request.pm,v 2.9 2011/02/06 01:45:29 nagler Exp $ package Bivio::Agent::Job::Request; use strict; use Bivio::Base 'Agent.Request'; our($VERSION) = sprintf('%d.%02d', q$Revision: 2.9 $ =~ /\d+/g); my($_IGNORE_REDIRECTS) = __PACKAGE__.'.ignore_redirects'; sub client_redirect { # (self, ...) : undef # Will set redirect values but not throw the exception if # L was called. # Otherwise passes off to SUPER. my($self) = shift; return $self->unsafe_get($_IGNORE_REDIRECTS) ? $self->internal_server_redirect(@_) : $self->SUPER::client_redirect(@_); } sub ignore_redirects { # (self, boolean) : undef # Sets internal state to ignore redirects if I is true. # This can be dangerous. # # Will set the new state, but not throw the exception. # # B my($self, $state) = @_; $self->put_durable($_IGNORE_REDIRECTS => $state); return; } sub new { # (proto, hash_ref) : Job.Request # Creates a Request from the queued I. my($proto, $params) = @_; my($start_time) = Bivio::Type::DateTime->gettimeofday(); #TODO: Need to handle Facades! my($self) = $proto->internal_new({ # We set the params here, because we want to override values %$params, start_time => $start_time, form => undef, query => undef, path_info => undef, # Needed by Task->execute, but not used here reply => b_use('Agent.Reply')->new, }); Bivio::Type::UserAgent->execute_job($self); $self->put_durable( %$params, start_time => $self->get('start_time'), form => $self->get('form'), query => $self->get('query'), reply => $self->get('reply'), ); $self->get('Bivio::Type::UserAgent')->put_on_request($self, 1); my($realm) = $params->{auth_id} && $params->{auth_id} != b_use('Auth.RealmType')->GENERAL->as_default_owner_id ? b_use('Auth.Realm')->new($params->{auth_id}, $self) : b_use('Auth.Realm')->get_general; $self->internal_set_current(); my($auth_user); if ($params->{auth_user_id}) { $auth_user = Bivio::Biz::Model->new($self, 'RealmOwner') ->unauth_load_or_die(realm_id => $params->{auth_user_id}); } $self->internal_initialize($realm, $auth_user); return $self; } sub server_redirect { # (self, ...) : undef # Will set redirect values but not throw the exception if # L was called. # Otherwise passes off to SUPER. my($self) = shift; return $self->unsafe_get($_IGNORE_REDIRECTS) ? $self->internal_server_redirect(@_) : $self->SUPER::server_redirect(@_); } 1;