Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Action In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16844/lib/OpenInteract2/Action Modified Files: Common.pm CommonAdd.pm CommonDisplay.pm CommonRemove.pm CommonSearch.pm CommonUpdate.pm Log Message: move common action messages into global message file Index: Common.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Action/Common.pm,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Common.pm 4 Dec 2004 04:13:54 -0000 1.19 --- Common.pm 5 Dec 2004 08:52:55 -0000 1.20 *************** *** 98,106 **** unless ( $object_type ) { $log->warn( "No object type specified" ); ! my $msg = join( '', "Object type is undefined. How can we know ", ! "what to search or return? Please set it in ", ! "your action configuration using the key ", ! "c_object_type." ); ! $self->param_add( error_msg => $msg ); return 1; } --- 98,102 ---- unless ( $object_type ) { $log->warn( "No object type specified" ); ! $self->add_error_key( 'action.error.no_object_type' ); return 1; } *************** *** 108,115 **** if ( $@ or ! $object_class ) { $log->warn( "No object class for '$object_type'" ); ! my $msg = join( '', "Class for given object type '$object_type' ", ! "is undefined. Maybe a typo in your action ", ! "configuration using the key c_object_type." ); ! $self->param_add( error_msg => $msg ); return 1; } --- 104,108 ---- if ( $@ or ! $object_class ) { $log->warn( "No object class for '$object_type'" ); ! $self->add_error_key( 'action.error.no_class_for_type', $object_type ); return 1; } *************** *** 126,134 **** if ( ! $id_field or $@ ) { $log->warn( "No ID field for '$object_class'" ); ! my $msg = join( '', "Object ID field is undefined. We cannot know ", ! "how to fetch an existing object without it. ", ! "Please define the key 'id_field' in your ", ! "object configuration." ); ! $self->param_add( error_msg => $msg ); return 1; } --- 119,123 ---- if ( ! $id_field or $@ ) { $log->warn( "No ID field for '$object_class'" ); ! $self->add_error_key( 'action.error.no_id_field' ); return 1; } *************** *** 185,196 **** } else { ! my $msg = "No value found in action parameters or " . ! "request for ID field '$id_field'"; if ( $alt_id_field ) { ! $msg .= " or alternative ID field '$alt_id_field'"; } - $msg .= '.'; - $log->warn( $msg ); - $self->param_add( error_msg => $msg ); return 1; } --- 174,182 ---- } else { ! $log->warn( "No ID found in '$id_field' or '$alt_id_field'" ); ! $self->add_error_key( 'action.error.no_id_value', $id_field ); if ( $alt_id_field ) { ! $self->add_error_key( 'action.error.no_alt_id_value', $alt_id_field ); } return 1; } *************** *** 207,214 **** unless ( $self->param( $_ ) ) { $log->warn( "No value in template parameter '$_'" ); ! my $msg = join( '', "No template found in '$_' key. This " . ! "template is mandatory for the task to ", ! "function." ); ! $self->param_add( error_msg => $msg ); $num_errors++; } --- 193,197 ---- unless ( $self->param( $_ ) ) { $log->warn( "No value in template parameter '$_'" ); ! $self->add_error_key( 'action.error.no_template', $_ ); $num_errors++; } *************** *** 225,231 **** unless ( $self->param( $_ ) ) { $log->warn( "No value in parameter '$_'" ); ! my $msg = join( '', "Action parameter '$_' is undefined but ", ! "required for the task to function." ); ! $self->param_add( error_msg => $msg ); $num_errors++; } --- 208,212 ---- unless ( $self->param( $_ ) ) { $log->warn( "No value in parameter '$_'" ); ! $self->add_error_key( 'action.error.param_required', $_ ); $num_errors++; } *************** *** 318,333 **** if ( $@ ) { my $error = $@; ! $log->error( "Caught exception fetching object: $@" ); if ( $error->isa( 'SPOPS::Exception::Security' ) ) { ! my $msg = "Security violation: you do not have rights to " . ! "retrieve the requested object."; ! $self->param_add( error_msg => $msg ); ! oi_error $@; } else { ! $self->param_add( error_msg => "Cannot retrieve object: $@" ); ! oi_error $error; } } return $object || $object_class->new; } --- 299,312 ---- if ( $@ ) { my $error = $@; ! $log->error( "Caught exception fetching object: $error" ); if ( $error->isa( 'SPOPS::Exception::Security' ) ) { ! $self->add_error_key( 'action.error.security' ); } else { ! $self->add_error_key( 'action.error.fetch', $error ); } + oi_error $error; } + $self->param( c_id => $id ); return $object || $object_class->new; } Index: CommonAdd.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Action/CommonAdd.pm,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** CommonAdd.pm 1 Dec 2004 05:07:02 -0000 1.20 --- CommonAdd.pm 5 Dec 2004 08:52:55 -0000 1.21 *************** *** 73,77 **** if ( $@ ) { $log->error( "Failed to create object: $@" ); ! $self->param_add( error_msg => "Object creation failed: $@" ); my $fail_task = $self->param( 'c_add_fail_task' ); return $self->execute({ task => $fail_task }); --- 73,77 ---- if ( $@ ) { $log->error( "Failed to create object: $@" ); ! $self->add_error_key( 'action.error.create', $@ ); my $fail_task = $self->param( 'c_add_fail_task' ); return $self->execute({ task => $fail_task }); *************** *** 80,84 **** $self->param( c_id => scalar $object->id ); my $title = "'" . $object->object_description->{title} . "'" || 'Object'; ! $self->param( status_msg => "$title created properly" ); $self->_add_post_action; $self->notify_observers( 'post add', $object ); --- 80,84 ---- $self->param( c_id => scalar $object->id ); my $title = "'" . $object->object_description->{title} . "'" || 'Object'; ! $self->add_status_key( 'action.status.create', $title ); $self->_add_post_action; $self->notify_observers( 'post add', $object ); Index: CommonDisplay.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Action/CommonDisplay.pm,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** CommonDisplay.pm 1 Dec 2004 05:07:02 -0000 1.14 --- CommonDisplay.pm 5 Dec 2004 08:52:55 -0000 1.15 *************** *** 25,29 **** unless ( $object->is_saved ) { my $id = $self->param( 'c_id' ); ! $self->param_add( error_msg => "Object with ID '$id' not found" ); return $self->execute({ task => $fail_task }); } --- 25,29 ---- unless ( $object->is_saved ) { my $id = $self->param( 'c_id' ); ! $self->add_error_key( 'action.error.not_found', $id ); return $self->execute({ task => $fail_task }); } *************** *** 39,48 **** $log->info( "Object [$object_class] [$id] failed ", "'active' check [Status: $status]" ); ! $self->param_add( error_msg => "This object is currently " . ! "inactive. Please check later." ); return $self->execute({ task => $fail_task }); } ! $log->is_debug && ! $log->debug( "Object passed 'active' check" ); } --- 39,46 ---- $log->info( "Object [$object_class] [$id] failed ", "'active' check [Status: $status]" ); ! $self->add_error_key( 'action.error.inactive' ); return $self->execute({ task => $fail_task }); } ! $log->is_debug && $log->debug( "Object passed 'active' check" ); } *************** *** 75,79 **** $self->_common_check_template_specified( 'c_display_template' ); if ( $has_error ) { ! die $self->execute({ task => 'common_error' }); } } --- 73,77 ---- $self->_common_check_template_specified( 'c_display_template' ); if ( $has_error ) { ! die $self->execute({ task => 'common_error' }), "\n"; } } Index: CommonRemove.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Action/CommonRemove.pm,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** CommonRemove.pm 1 Dec 2004 05:07:02 -0000 1.17 --- CommonRemove.pm 5 Dec 2004 08:52:55 -0000 1.18 *************** *** 21,29 **** my $object = eval { $self->_common_fetch_object }; if ( $@ ) { return $self->execute({ task => $fail_task }); } ! unless ( $object and $object->is_saved ) { ! $self->param_add( error_msg => 'Cannot fetch object for removal. ' . ! 'No modifications made.' ); return $self->execute({ task => $fail_task }); } --- 21,34 ---- my $object = eval { $self->_common_fetch_object }; if ( $@ ) { + $self->add_eror_key( 'action.error.fetch_for_remove', $@ ); return $self->execute({ task => $fail_task }); } ! unless ( $object ) { ! $self->add_eror_key( 'action.error.not_found', ! $self->param( 'c_id' ) ); ! return $self->execute({ task => $fail_task }); ! } ! unless ( $object->is_saved ) { ! $self->add_eror_key( 'action.error.remove_not_saved' ); return $self->execute({ task => $fail_task }); } *************** *** 36,42 **** my $sec_fail_task = $self->param( 'c_remove_security_fail_task' ) || $fail_task; ! $self->param_add( ! error_msg => 'Insufficient access rights to remove this ' . ! 'object. No modifications made.' ); return $self->execute({ task => $sec_fail_task }); } --- 41,45 ---- my $sec_fail_task = $self->param( 'c_remove_security_fail_task' ) || $fail_task; ! $self->add_error_key( 'action.error.remove_security' ); return $self->execute({ task => $sec_fail_task }); } *************** *** 47,51 **** eval { $object->remove }; if ( $@ ) { ! $self->param_add( error_msg => "Object removal failed: $@" ); $log->error( "Failed to remove ", $self->param( 'c_object_class' ), "with ID" , $object->id, ": $@" ); --- 50,54 ---- eval { $object->remove }; if ( $@ ) { ! $self->add_error_key( 'action.error.remove', $@ ); $log->error( "Failed to remove ", $self->param( 'c_object_class' ), "with ID" , $object->id, ": $@" ); *************** *** 56,60 **** my $title = "'" . $object->object_description->{title} . "'" || 'Object'; ! $self->param_add( status_msg => "$title successfully removed." ); my $success_task = $self->param( 'c_remove_task' ); return $self->execute({ task => $success_task }); --- 59,63 ---- my $title = "'" . $object->object_description->{title} . "'" || 'Object'; ! $self->add_status_key( 'action.status.remove', $title ); my $success_task = $self->param( 'c_remove_task' ); return $self->execute({ task => $success_task }); Index: CommonSearch.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Action/CommonSearch.pm,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** CommonSearch.pm 1 Dec 2004 05:07:02 -0000 1.16 --- CommonSearch.pm 5 Dec 2004 08:52:55 -0000 1.17 *************** *** 32,40 **** my ( $self ) = @_; unless ( $self->param( 'c_search_form_template' ) ) { ! my $msg = join( '', "Template for search form is undefined. Please ", ! "set it in your action configuration using the ", ! "key 'c_search_form_template'." ); ! $self->param_add( error_msg => $msg ); ! die $self->execute({ task => 'common_error' }); } return undef; --- 32,37 ---- my ( $self ) = @_; unless ( $self->param( 'c_search_form_template' ) ) { ! $self->add_error_key( 'action.error.no_template', 'c_search_form_template' ); ! die $self->execute({ task => 'common_error' }), "\n"; } return undef; *************** *** 168,176 **** unless ( $num_id_links == 2 || $num_id_links == 4 ) { ! my $msg = join( '', "Misconfigured search: there should be ", ! "either two or four entries in the ", ! "'c_search_table_links' section for table ", ! "[$table] under action [", $self->name, "]" ); ! $self->param_add( error_msg => $msg ); $has_error++; } --- 165,170 ---- unless ( $num_id_links == 2 || $num_id_links == 4 ) { ! $self->add_error_key( 'action.error.search_table_links', ! $table, $self->name ); $has_error++; } *************** *** 179,183 **** } if ( $has_error ) { ! die $self->execute({ task => 'common_error' }); } --- 173,177 ---- } if ( $has_error ) { ! die $self->execute({ task => 'common_error' }), "\n"; } *************** *** 197,202 **** my ( $msg, $task ); if ( $caught =~ /^CAP: (.*)$/ ) { ! $msg = join( '', "Your search has returned too many ", ! "results ($1). Please try again." ); $task = $self->param( 'c_search_results_cap_fail_task' ); } --- 191,195 ---- my ( $msg, $task ); if ( $caught =~ /^CAP: (.*)$/ ) { ! $msg = $self->_msg( 'action.error.search_too_many_results', $1 ); $task = $self->param( 'c_search_results_cap_fail_task' ); } *************** *** 205,210 **** $task = $self->param( 'c_search_fail_task' ); } ! $self->param_add( error_msg => $msg ); ! die $self->execute({ task => $task }); } --- 198,203 ---- $task = $self->param( 'c_search_fail_task' ); } ! $self->add_error( $msg ); ! die $self->execute({ task => $task }), "\n"; } Index: CommonUpdate.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Action/CommonUpdate.pm,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** CommonUpdate.pm 1 Dec 2004 05:07:02 -0000 1.19 --- CommonUpdate.pm 5 Dec 2004 08:52:55 -0000 1.20 *************** *** 26,32 **** if ( $@ ) { $log->error( "Failed to fetch object [$object_class: $id]: $@" ); ! $self->param_add( ! error_msg => "Cannot fetch object for update: $@" ); ! return $self->execute( task => $fail_task ); } } --- 26,31 ---- if ( $@ ) { $log->error( "Failed to fetch object [$object_class: $id]: $@" ); ! $self->add_error_key( 'action.error.fetch_for_update', $@ ); ! return $self->execute({ task => $fail_task }); } } *************** *** 58,64 **** unless ( $object and $object->is_saved ) { $log->error( "Object does not exist or is not saved, cannot update" ); ! my $msg = join( '', "You cannot update this object because it ", ! "has not yet been saved." ); ! $self->param_add( error_msg => $msg ); return $self->execute({ task => $fail_task }); } --- 57,61 ---- unless ( $object and $object->is_saved ) { $log->error( "Object does not exist or is not saved, cannot update" ); ! $self->add_error_key( 'action.error.update_not_saved' ); return $self->execute({ task => $fail_task }); } *************** *** 69,75 **** my $sec_fail_task = $self->param( 'c_update_security_fail_task' ) || $fail_task; ! my $msg = join( '', 'You do not have sufficient access to ', ! 'update this object. No modifications made.' ); ! $self->param_add( error_msg => $msg ); return $self->execute({ task => $sec_fail_task }); } --- 66,70 ---- my $sec_fail_task = $self->param( 'c_update_security_fail_task' ) || $fail_task; ! $self->add_error_key( 'action.error.update_security' ); return $self->execute({ task => $sec_fail_task }); } *************** *** 100,108 **** if ( $@ ) { $log->error( "Update of $object_spec failed: $@" ); ! $self->param_add( error_msg => "Object update failed: $@" ); return $self->execute({ task => $fail_task }); } my $title = "'" . $object->object_description->{title} . "'" || 'Object'; ! $self->param( status_msg => "$title updated with changes" ); $self->param( c_object_old_data => $old_data ); $self->_update_post_action; --- 95,103 ---- if ( $@ ) { $log->error( "Update of $object_spec failed: $@" ); ! $self->add_error_key( 'action.error.update', $@ ); return $self->execute({ task => $fail_task }); } my $title = "'" . $object->object_description->{title} . "'" || 'Object'; ! $self->add_status_key( 'action.status.update', $title ); $self->param( c_object_old_data => $old_data ); $self->_update_post_action; |