input
stringlengths
10
828
output
stringlengths
5
107
public void set error string error string this error string error string
set the error string used from within scripts to trip up the processing
private string get script throws pipeline exception string script this get options script code string script file this get options script file if script null script file null if script file null try script variable processor expand file script file catch ioexception e throw new pipeline exception i18n get 100294 e else throw new com babeldoc core pipeline pipeline exception i18n get 100294 if log service get instance is debug enabled log service get instance log debug script to process log service get instance log debug script return script
either load the script or get child the included script
protected int get log max size if log max size 0 log max size number utils string to int get info get str value journal maxsize default logsize system out println setting log max size log max size return log max size
get the maximum size of the log file before it is rolled
public set keys return map key set
get the enumeration of get children name set
protected properties get config properties string option keys string get info get options to array new string 0 com babeldoc core name value pair options this get option list option keys properties config properties new properties for int i 0 i options length i config properties put options i get name options i get value return config properties
convert the options list into a properties object suitable for configuring
protected string get tracker dir if tracker dir null tracker dir variable processor expand string get info get str value journal dir if tracker dir ends with file separator tracker dir file separator system out println setting tracker dir tracker dir return tracker dir
get the tracker directory
public void put string name object value map put name value
get the object reference
public pipeline document get document return this document
get the document
public void set name pipeline stage string name pipeline stage this name pipeline stage name pipeline stage
set the name
public string get name pipeline stage return this name pipeline stage
get the name of the processing pipeline stage
public string to string return new to string builder this append attributes this get attributes append buffer buffer to string
to xml to a string
public void test pipeline and stage string input pipeline stage com babeldoc core pair pair pipeline command get pipeline and stage input assert equals pair get first pipeline assert equals pair get second stage
setup the test pipeline and stage
protected void set up throws exception environment loader load environment
setup the test
public int get queue size return queue capacity
get the queue size
public void set up system out println setup system set property babeldoc home system get property user dir string buffer text new string buffer for int i 0 i 5000 i text append doctext document new feed document test doctext get bytes new hash map true true document new scan document test case new long system current time millis some path text to string get bytes try queue new disk queue test catch exception e e print stack trace queue empty queue
setup the test
public void do pipeline list throws exception string names pipeline factory factory get all pipeline names for int i 0 i names length i string name names i string entry pipeline factory factory get pipeline stage factory name get entry stage name system out println i18n get 008001 name entry
process list all the pipelines in the system
public void test repeated add get document system out println test repeated add get document for int i 0 i 100 i feed document document to add new feed document test this is test document number i that will be added to queue get bytes new hash map false true queue add document to add add 101th document queue add document for int i 0 i 100 i queue remove feed document document101 queue remove assert equals document document101
test repeated adding getting document
public boolean is empty return get queue size 0
return true if the queue is empty
public object copy return new pipeline document this get bytes
copy content of the object
public void set binary boolean binary is binary binary
set the binary flag on the document
protected void do config string pipeline stage throws exception get the pipline name and the stage name from the input com babeldoc core pair pair get pipeline and stage pipeline stage ipipeline stage factory pfactory get pipeline stage factory pair string stage string pair get second if stage null iconfig data config pfactory get config stage if config null output config config else log service get instance log error i18n get 008008 pipeline stage null else log service get instance log error i18n get 008009 pipeline stage null
list all the configuratiooptions for the named pipeline stage
public void initialize iconfig data data throws general exception int pool size 1 if data null config qtype data pool size number utils string to int data get value poolsize 1 thread pool new pooled executor pool size setup thread pool pool size
initialize this object this sets up the queue and the threadpool
public void add feed document feed doc try file file this serialize document feed doc queue add first file catch exception e e print stack trace
add a document to the queue
public void set no journal boolean no journal this no journal no journal
set the no journal flag
private void check options throws pipeline exception if has option resource name throw new pipeline exception i18n get sql 201 has option where row names if get option list new string where row names null throw new pipeline exception i18n get sql 1005 if has option table name throw new pipeline exception i18n get sql 1006 if has option schema url throw new pipeline exception sql 1007
check mandatory options
public boolean is no journal return no journal
get the state of the no journal flag
public void empty queue queue clear delete temp files
remove all elements from the queue
public void set pipeline name string pipeline name this pipeline name pipeline name
set the name of the pipeline to process this feed document
public void set ticket ijournal ticket ticket this ticket ticket
set the ticket for this feeddocument
protected void initialize queue string name file tmp if tmp exists tmp is directory tmp mkdirs tmp folder tmp this set name name load queue
setup the queue check the directory etc
public ijournal ticket get ticket return ticket
get the ticket
protected void do type string pipeline stage throws exception get the pipline name and the stage name from the input com babeldoc core pair pair get pipeline and stage pipeline stage ipipeline stage factory pfactory get pipeline stage factory pair string stage string pair get second pipeline stage type pstage type pfactory get resolver get pipeline stage type stage if pstage type null system out println i18n get 008022 stage pstage type else log service get instance log error i18n get 008009 pipeline stage null
get the type information for the pipeline stage name
private void config qtype iconfig data data throws general exception string qtype data get value q type if q type disk equals qtype config disk queue data else this queue new memory queue
configure the queuing implementation
private void delete temp files file files tmp folder list files if files null for int i 0 i files length i files i delete
delete the temporary files
public string get encoding if encoding null if log service get instance is debug enabled log service get instance log debug pipeline document get encoding encoding return encoding else if log service get instance is debug enabled log service get instance log debug pipeline document get encoding null encoding return system get property file encoding return system get property file encoding
returns the encoding
private void config disk queue iconfig data data throws general exception string qname data get value q dir name string qdir data get value q disk dir if qname null qname equals throw new general exception i18n get core pipeline feeder asyncfeeder disk queuename if qdir null qdir equals throw new general exception i18n get core pipeline feeder asyncfeeder disk queuedir try this queue new disk queue qname new file qdir catch ioexception e throw new general exception i18n get core pipeline feeder asyncfeeder disk error e
the queue is a disk queue this method configures the disk queue and
public string get error stage name throws pipeline exception if this has option error stage return this get options error stage else return next stage if no error stage defined return this get next pipeline stage name
get the name of the stage if error occurred
public pipeline document create pipeline document feed document feed doc pipeline document doc new pipeline document feed doc get data if feed doc get attributes null for iterator keys feed doc get attributes key set iterator keys has next string key string keys next object value feed doc get attributes get key doc put key value doc set binary feed doc is binary return doc
create a pipeline document from the string and the properties
private void load queue file files tmp folder list files new filename filter public boolean accept file dir string name if name starts with get name name ends with tmp return true else return false add files to queue queue add all arrays as list files
this method will fill queue with filenames that exist in tmp folder
protected void output config string indent iconfig data config data system out println indent i18n get 008006 config data get name if config data get value null system out println indent i18n get 008007 config data get value if config data get children name set null for iterator keys config data get children name set iterator keys has next string key string keys next if key null output config indent config data get child key
output the configuration information
public iconfig info get info return new feeder config info this method returns type specific options return comments public collection get type specific options return new array list return description of this worker return description public string get description return synchronously feed the documents to the pipeline return the name return public string get name return sync
get the configuration iformation for this class
public boolean get fail on error return false equals ignore case this get options fail on error
return true if document should fail in case of error
public string get sink stage return string this get second
get the sink stage
public void terminate this stop running true this thread pool shutdown after processing currently queued tasks
this method stops the processing on this feeder
public string get source stage return string this get first
get the source stage
public string get description return synchronously feed the documents to the pipeline
return description of this worker
public void set connections collection connections this connections connections
set the connections
protected void setup config data iunmarshaller unmarshaller stage config unmarshaller get root config set entry stage name stage config get value pipeline stage connection connections unmarshaller get pipeline stage connections for int i 0 i connections length i setup next stages connections i get source stage connections i get sink stage
operate on the data from the unmarshaller
public void set entry stage string entry stage this entry stage entry stage
set the entry stage
public void set dynamic dynamic dynamic this dynamic dynamic
set the dynamic option
public void set stage insts array list stage insts this stage insts stage insts
set the stage insts
public int get max threads if this has option max threads return integer parse int this get options max threads else return 0
return the max threads for the next stages
public collection get type specific options collection options new array list options add new config option poolsize iconfig option type integer 1 false i18n get core pipeline feeder asyncfeeder config poolsize options add new config option keep alive iconfig option type integer 500 false i18n get core pipeline feeder asyncfeeder config inactivetime return options
this method returns type specific options
public void add connection connection connection this connections add connection
add a connection
public void add stage inst stage inst stage inst this stage insts add stage inst
add a stage instance
public void set options collection options this options options
set the options
public void set sub options collection sub options this sub options sub options
set the suboptions
public string get description return i18n get core pipeline feeder asyncfeeder config desc
return description of this worker
public ijournal get journal throws pipeline exception return journal factory get journal
get the journal
public void add sub option option option this sub options add option
add an option as a suboption
public void set sink string sink this sink sink
set the sink stage
public map get pipelines return pipelines
get the map of pipelines
private iconfig data get pipeline stage config option option iconfig data config new config data option get name option get value if option get sub options size 0 collection suboptions option get sub options for iterator i suboptions iterator i has next option suboption option i next config add child get pipeline stage config suboption return config
get the pipeline stage configuration data from the option
public ipipeline stage resolver get resolver if resolver null string file name get info get str value xml filename try resolver new xml pipeline stage resolver file name catch ioexception e get log log error e return resolver
get the resolver
public iconfig info get info if info null info new pipeline stage factory info this method returns type specific options return comments public collection get type specific options collection specific new array list specific add new config option xml filename iconfig option type string null true configuration data filename return specific return description of this worker return description public string get description return xml pipeline stage factory reads its pipeline configuration from an xml file return the name return public string get name return xml return info
get the configuration iformation for this class
public iconfig data get config string name return stage config get child name
get the value of the option provided by the key
public collection get type specific options collection specific new array list specific add new config option xml filename iconfig option type string null true configuration data filename return specific
this method returns type specific options
public void clear cache get pipelines clear log service get instance log debug clearing entire pipeline cache config service clear cache
clear the cached pipeline information this is necessary if the datafiles
public string get description return xml pipeline stage factory reads its pipeline configuration from an xml file
return description of this worker
public string get entry stage name return entry stage name
get the entry point into the pipelinestage
public void clear cache string name get pipelines remove name log service get instance log debug clearing pipeline cache for name config service clear cache name
clear the cached pipeline information identified by the name this is
public string get next pipeline stage name throws pipeline exception try return this get resolver get next pipeline stage name this get name catch exception e throw new pipeline exception i18n get 020002 this get name e
get the name of the next stage in the pipeline
protected void set entry stage name string entry stage name this entry stage name entry stage name
set the entry stage name
public string get pipeline return string get first
get the pipeline name
public void initialize variable processor add to context module new velocity sql context
add the sql processor to the
public string get next pipeline stage name string name throws pipeline exception string next stage name string next stages get name if next stage name null next stage name trim length 0 return next stage name else log service get instance log warn i18n get 019011 name return null
get the name of the next pipeline stage
public void test bad user resource throws exception user resource resource new user resource null string components resource get components assert not null testing the number of components in resource components
test 2 test user resources
public string get stage return string get second
get the stage name
public void log error string message throwable e if logger is debug enabled logger error get class method 3 message e else throwable rootcause e null null get root cause e throwable report exception rootcause null rootcause e string except msg report exception null report exception get message logger error message except msg
log an error condition
public void test good user resource throws exception user resource resource new user resource resource1 string components resource get components assert equals testing the number of components in resource components length 7 assert equals components 0 root assert equals components 6 resource
test 1 test user resources
public string get options string key boolean templatization try string value string get info get option key get value return templatization templatize this get document this get ticket value value catch exception e if log service get instance is debug enabled log service get instance log debug error resolving this get name key do nothing this assumes that missing a configuration item is not a critical error return null
get the option with optional templatization
protected void set up throws exception com babeldoc core environment loader load environment resource factory new sql user resource factory factory new sql user factory
setup the tests
public void log error throwable e this log error e
log an error condition
public string to string return new to string builder this append stage config stage config append next stages next stages append prev stages prev stages to string
convert this object to a string
public throwable get root cause throwable e return exception utils get root cause e if e instanceof general exception general exception ge general exception e return get root cause ge get cause else return e
gets the root cause in all the nestable exceptions
protected void setup next stages string source string sink system out println source source sink sink next stages put source sink object o prev stages get sink if o null array list vec new array list vec add source prev stages put sink vec else array list o add source
setup the next and previous stages for the source and sink stagenames this
public iorganization get parent if parent id 1 return null else if parent null parent factory get organization parent id return parent
get child the parent organization object
public string get options string key templetization is true by default return get options key true
get the option
public void test add user to organization throws exception iorganization parent factory get organization org2 name iuser context context1 factory create user new sql user user1 name 1 sql organization parent get id 1 new password user credential password assert not null context1 iuser context context2 factory create user new sql user user2 name 1 sql organization parent get id 1 new password user credential password assert not null context2
test number 9
protected void setup connection pool string connect uri throws exception object pool connection pool new generic object pool null connection factory connection factory new driver manager connection factory connect uri get db name get db passwd poolable connection factory poolable connection factory new poolable connection factory connection factory connection pool null null false true driver register pool get name connection pool to xml to the url that talks to the connection pool set db url jdbc apache commons dbcp get name
now setup the connection pool this means rewriting the url to point instead
protected void setup throws resource exception super setup try setup connection pool get db url catch exception e throw new resource exception e
setup the jdbc stuff
public void test clean up organization throws exception factory delete user new sql user user1 name factory delete user new sql user user2 name factory delete organization factory get organization org2 name factory delete organization factory get organization org1 name
test number 20
public iconfig info get info if info null info new simple jdbc config info return description of this worker return description public string get description return pooled jdbc connection resource check in and checkouts operate on a pool of connections return the name return public string get name return pooled return info
get the configuration iformation for this class
public string get description return pooled jdbc connection resource check in and checkouts operate on a pool of connections
return description of this worker
public string get global preference string key throws user exception connection connection null prepared statement pstmt null result set results null try connection connection resource check out pstmt sql query manager prepare statement connection pref gbl select pstmt set string 1 key if results pstmt execute query next return results get string 1 catch exception e com babeldoc core log service get instance log error sql user factory get global preference exception e finally try results close catch exception e try pstmt close catch exception e try connection close catch exception e return null
get the global preference string for the organization
public string get name return pooled
return the name
public void test create duplicate organization throws exception try iorganization organization factory create organization org1 name 1 assert not null organization catch exception e return fail cant create duplicate orgs
test number 6 test creating duplicate organizations
protected void setup throws resource exception if get db name null get db passwd null get db driver null get db url null try class for name get db driver new instance catch exception x set db url null throw new resource exception jdbc driver exception x else throw new resource exception the resource is not completely specified
setup the jdbc stuff
public void test create organization throws exception iorganization organization factory create organization org1 name 1 assert not null organization
test number 5 test creating organizations
protected string get db name if db name null db name get info get str value db user return db name
get the db user name get from the config if not provided