lib/openwfe/rudefinitions.rb in openwferu-0.9.6 vs lib/openwfe/rudefinitions.rb in openwferu-0.9.7

- old
+ new

@@ -35,10 +35,12 @@ # # "made in Japan" # +require 'fileutils' + require 'openwfe/utils' require 'openwfe/version' module OpenWFE @@ -48,10 +50,11 @@ S_LOGGER = :logger S_ENGINE = 'engine' S_EXPRESSION_MAP = 'expressionMap' + S_WFID_GENERATOR = 'wfidGenerator' S_EXPRESSION_POOL = 'expressionPool' S_EXPRESSION_STORAGE = 'expressionStorage' S_PARTICIPANT_MAP = 'participantMap' S_SCHEDULER = 'scheduler' @@ -69,10 +72,25 @@ # some file storage default values DEFAULT_WORK_DIRECTORY = './work' # + # Returns the work directory for the OpenWFE[ru] application context + # (if any). + # + def OpenWFE.get_work_directory (dir=nil) + + dir = DEFAULT_WORK_DIRECTORY unless @application_context + dir = @application_context[:work_directory] unless dir + dir = DEFAULT_WORK_DIRECTORY unless dir + + FileUtils.makedirs(dir) unless File.exist?(dir) + + dir + end + + # # A mixin for easy OpenWFE service lookup # (assumes the presence of an application context instance var) # module OwfeServiceLocator @@ -82,9 +100,12 @@ def get_scheduler return @application_context[S_SCHEDULER] end def get_expression_map return @application_context[S_EXPRESSION_MAP] + end + def get_wfid_generator + return @application_context[S_WFID_GENERATOR] end def get_expression_pool return @application_context[S_EXPRESSION_POOL] end def get_expression_storage