Skip to content

Commit

Permalink
Add support for volatile workflows, make ca_publish volatile
Browse files Browse the repository at this point in the history
Volatile workflows use a "null persister", they can run as any normal
workflow but dont leave any traces in the workflow tables.
  • Loading branch information
oliwel committed Jan 29, 2015
1 parent 837adc5 commit 291610f
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ head:
prefix: capub
label: I18N_OPENXPKI_WF_TYPE_CA_ISSUANCE
description: I18N_OPENXPKI_WF_TYPE_CA_ISSUANCE_DESC

persister: Volatile

state:
CREATE_QUEUE:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
OpenXPKI:
name: OpenXPKI
class: OpenXPKI::Server::Workflow::Persister::DBI
workflow_table: WORKFLOW
history_table: WORKFLOW_HISTORY

Volatile:
class: OpenXPKI::Server::Workflow::Persister::Null

49 changes: 48 additions & 1 deletion core/server/OpenXPKI/Client/UI/Workflow.pm
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,52 @@ sub init_index {

}

=head2 init_start
Same as init_index but directly creates the workflow and displays the result
of the initial action. Normal workflows will result in a redirect using the
workflow id, volatile workflows are displayed directly. This works only with
workflows that do not require any initial parameters.
=cut
sub init_start {

my $self = shift;
my $args = shift;

my $wf_info = $self->send_command( 'create_workflow_instance', {
WORKFLOW => $self->param('wf_type'), PARAMS => {}, UIINFO => 1
});

if (!$wf_info) {
# todo - handle errors
$self->logger()->error("Create workflow failed");
return $self;
}

$self->logger()->trace("wf info on create: " . Dumper $wf_info );

$self->logger()->info(sprintf "Create new workflow %s, got id %01d", $wf_info->{WORKFLOW}->{TYPE}, $wf_info->{WORKFLOW}->{ID} );

# this duplicates code from action_index
if ($wf_info->{WORKFLOW}->{ID} > 0) {

my $redirect = 'workflow!load!wf_id!'.$wf_info->{WORKFLOW}->{ID};
my @activity = keys %{$wf_info->{ACTIVITY}};
if (scalar @activity == 1) {
$redirect .= '!wf_action!'.$activity[0];
}
$self->redirect($redirect);

} else {
# one shot workflow
$self->__render_from_workflow({ WF_INFO => $wf_info });
}

return $self;

}


=head2 init_load
Expand Down Expand Up @@ -385,7 +431,8 @@ sub action_index {
$self->__purge_wf_token( $wf_token );

# always redirect after create to have the url pointing to the created workflow
$wf_args->{redirect} = 1;
# do not redirect for "one shot workflows"
$wf_args->{redirect} = ($wf_info->{WORKFLOW}->{ID} > 0);

} else {
$self->set_status(i18nGettext('I18N_OPENXPKI_UI_WORKFLOW_INVALID_REQUEST_NO_ACTION!'),'error');
Expand Down
5 changes: 5 additions & 0 deletions core/server/OpenXPKI/Workflow/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ sub __process_workflow {

my $conn = $self->_config();

my $wf_persister = $conn->get( [ 'workflow', 'def', $wf_name , 'head', 'persister' ] );
if ($wf_persister) {
$workflow->{persister} = $wf_persister;
}

my $wf_prefix = $conn->get( [ 'workflow', 'def', $wf_name , 'head', 'prefix' ] );

my @states = $conn->get_keys( ['workflow', 'def', $wf_name, 'state' ] );
Expand Down
14 changes: 0 additions & 14 deletions core/server/OpenXPKI/Workflow/Handler.pm
Original file line number Diff line number Diff line change
Expand Up @@ -381,20 +381,6 @@ sub __get_instance {
}
}
##! 64: 'config added completely'

my $workflow_table = 'WORKFLOW';
my $workflow_history_table = 'WORKFLOW_HISTORY';
# persister configuration should not be user-configurable and is
# static and identical throughout OpenXPKI
$workflow_factory->add_config(
persister => {
name => 'OpenXPKI',
class => 'OpenXPKI::Server::Workflow::Persister::DBI',
workflow_table => $workflow_table,
history_table => $workflow_history_table,
},
);

##! 1: 'end'
return $workflow_factory;
}
Expand Down

0 comments on commit 291610f

Please sign in to comment.