input
stringlengths
10
828
output
stringlengths
5
107
public boolean cluster delete string name synchronized members if members contains key name members remove name return true return false
delete a cluster
public boolean cluster exists string name synchronized members if members contains key name return true return false
does this cluster exist
private void put cluster member member string cluster name member get cluster name list member list synchronized members if members contains key cluster name cluster create cluster name member list list members get cluster name member list add member
add a member to the specified cluster
private void remove cluster member member list member list synchronized members if member list list members get member get cluster name null member list remove member
remove a member from the specified cluster
public string get default cluster set name synchronized members if members size 1 return null name members string key set return string name iterator next
get the default cluster
public int cluster count synchronized members return members size
count of available clusters
public int cluster size string cluster name list member list synchronized members if member list list members get cluster name null return member list size throw new cluster not found exception cluster name
size of this cluster
public iterator cluster iterator return members string key set iterator
iterate through the cluster names
public iterator member iterator string cluster name array list array list array list member list cluster name return array list iterator
iterate through a copy of the cluster member list
public list member list string cluster name array list member list synchronized members if member list array list members get cluster name null return list member list clone throw new cluster not found exception cluster name
fetch a copy of the cluster member list
public boolean populate command throws xml exception set command name no xml details are required create command ap command getinfo return true
populate command name and details
public boolean populate command throws xml exception set the command name create command ap command noop return true
populate command name and details
public boolean populate command throws xml exception element element set the command name create command ap command echo populate the xml details document element cb xml utils create element cb root ap e comment cb xml utils add text element echotext return true
set up the command name and associated details document
public boolean command equals string command return this command equals ignore case command
do these parameters match up with the specified command
private void clear parameters if parameters null parameters clear parameters null
cleanup delete the parameter list
private void reset throws xml exception connection null response raw null response document null if command parameters initialized reset command command parameters initialized true
initialize for a new transaction
public document get document verify server state return response document
get a dom rendition of the server response
public element get root verify server state return response document get document element
get the root element of the server response document
public string buffer get raw verify server state return response raw
get the unfiltered response as sent by the server debug
private void reset command throws xml exception clear parameters add parameter ap param command command if command document null add parameter ap param xml xml utils serialize command document
set up for a new transaction
private void post parameters throws ioexception writer writer null try writer new output stream writer connection get output stream utf 8 if parameters null string separator set entry set parameters entry set map entry entry for iterator it entry set iterator it has next entry map entry it next writer write separator entry get key urlencoder encode string entry get value if separator length 0 separator finally try if writer null writer close catch exception ignore
post provided parameters
public void put string name string value keyed list put name value
put a named parameter into the list
public urlconnection get connection throws ioexception set up the target url once return url open connection
get a urlconnection for this transaction
public void do transaction url url throws ioexception xml exception this url url do transaction
perform one command transaction
public void do transaction throws ioexception xml exception get connection set http characteristics verify set up reset connection get connection connection set do output true connection set do input true connection set request property user agent com user agent connection set request property accept text xml connection set request property accept charset utf 8 post our request read the server reply post parameters read response
perform one command transaction
private void verify server state if response raw null string message no response has been received from the server has a command been issued throw new illegal state exception message
verify weve recieved some sort of server response even if invalid
public void set credentials string username string password reset this username username this password password to char array
establish realm login credentials
public string get string name return string keyed list get name
fetch a the first occurance of a named parameter from the list
public void reset tries 0
reset for a fresh login attempt
protected password authentication get password authentication log debug r n realm get requesting prompt scheme get requesting scheme site get requesting site if the login has been rejected once quit now this avoids a redirect loop with the server authentication fails try to login in authentication fails try to log in etc if tries 0 log debug authorization refused return null log debug returning credentials for authorization return new password authentication username password
override the default implementation to provide the credentials required
public xml utils get xml utils return cb xml utils
get the xml utils object
public document get document return cb document
get a dom rendition of the command details
public element get root return cb root
get the root element of the command details document
public element get command root return cb command root
get the command element of the command details document
public string get version element root get root return root null cb xml utils get attribute root com xml versionname
get the xml version of the command details document
public element create document throws xml exception cb document cb xml utils create document cb root cb xml utils create root cb document ap requestroot cb command root cb xml utils create element cb root get command return cb root
create an empty command details document
public string get name int index return string keyed list get key index
fetch a name by index
public string get command return cb command
get the command name
public void set command string command cb command command cb xml null
set the command name
public void set command string command string xml cb command command cb xml xml
set the command name
public void create command string command throws xml exception set command command create document
create the initial command structures
public string get value int index return string keyed list get value index
fetch a value by index
public void finish boolean write page super finish write page
finish up the rendering process
public void verify active cluster if cluster utils is active cluster defined servlet interface throw new illegal argument exception cluster undefined
verify the cluster name is set up
public int size return keyed list size
fetch the size of the list
public void send error string text exception exception page render base renderer don t try to verify the active cluster just render the error cluster utils set verification state off servlet interface if exception null exception instanceof cluster not found exception no cluster is active reset to the initial state cluster utils reset verification state servlet interface render the error page renderer new error page renderer initialize this get command text exception renderer do page header renderer do page body renderer do page footer
send an error message
public void finish boolean write page if write page try page write writer catch throwable ignore super finish write page
finish up the rendering process
public void send error string text send error text null
return error status in an appropriate manner
public void finish boolean write page try writer flush writer close servlet interface flush catch throwable ignore
finish up the rendering process
public xml utils get xml utils return xml utils
get the xml utils object for this response
public output stream writer get writer return writer
get our configured writer for this response
public servlet interface get servlet interface return servlet interface
get the servlet interface object for this command
public string get command return client command
return client command name
public void set external command boolean is external external command is external
set command type internal or external
public boolean is external command return external command
is this an external command
public int do local setup and verification if verify minimum parameters set response status message supply an archival unit id and name and a target system return do remote setup only return local success
verify required user input fields are present
public command targets get command targets array list target list select only the requested target system target list parse utils get element text list get xml utils get request document ap e target return select targets and setup target list
select target systems for command execution
public void add response document document response list add response document
add a response document to the to be rendered list
public int do local setup and verification if verify minimum parameters set response status message supply a journal name plugin name or plugin class name return do remote setup only if verify defining parameters set response status message required information is missing supply all required fields return do remote setup only if verify target set response status message please select one or more caches return do remote setup only success permit all remote activities return local success
verify user input fields
public command targets get command targets array list target list initial page setup or missing argument select all systems if is create command verify target return select all targets and setup creating an au select all of the requested target systems target list parse utils get element text list get xml utils get request document ap e target return select targets and get setup from cluster target list
select target systems for command execution
public document get status message document return response list get status message document
get the status message document
private boolean verify title return string util is null string get parameter ap e title
verify that the client provided a lockss title
private boolean verify minimum parameters int count 0 if string util is null string get parameter ap e publication count if string util is null string get parameter ap e classname count if string util is null string get parameter ap e plugin count if count 0 return false return true
did the client provide the minimal parameters required
private boolean verify target if is create command return true return string util is null string get parameter ap e target
a target system is required to create an au was it provided
public document get setup document return response list get setup document
get the setup document for this command null if none
private boolean verify defining parameters keyed list parameters int size if is create command return true parameters parse utils get dynamic fields get xml utils get request document ap md audefining size parameters size for int i 0 i size i if string util is null string string parameters get value i return false return true
are all of the defining parameters required to create an au available
public void clear response list clear
clear the to be rendered list
public boolean do command throws exception create cluster if is create command return add cluster set default lockss password if is set command return set password return true
add and remove clusters
public iterator get iterator return response list get iterator
get an iterator for the response list
private boolean add cluster throws exception cluster cache cluster cache null try servlet interface servlet interface string name cluster name specified if not no further action is possible name get parameter ap e newmember if string util is null string name return true create the cluster cluster cache new cluster cache if cluster cache cluster create name set response status message cluster name to upper case already exists return false success this is now the active cluster cluster utils set active cluster get servlet interface name finally if cluster cache null cluster cache close return true
add a new cluster
private boolean set password string pw1 get parameter ap e pw1 string pw2 get parameter ap e pw2 string user get parameter ap e user if string util is null string user set response status message provide both username and password return false if string util is null string pw1 string util is null string pw2 set response status message provide both password and confirmation return false if pw1 equals pw2 set response status message password and confirmation do not match return false return write password to database user pw1
establish the default lockss password
private boolean write password to database string username string password boolean status true try authentication utils set default api credentials username password catch sqlexception exception set response detail message failed to save api credentials exception get message status false return status
write the default lockss password to the database for subsequent use
public document get response document return document response list get response document
get the first response document useful when implementing internal
public void add response document document list add document
add a response document to the render list
public boolean do command throws xml exception try return true finally
populate response with lockss build and version information
public int do local setup and verification string title get parameter ap e title if string util is null string title throw new response exception a journal title is required return local success
verify user input fields none required
public void set status message document document document this message document document xml utils set attribute message document get document element ap a type ap type message
add a status message for subsequent rendering
public command targets get command targets array list target list parse utils get element text list get xml utils get request document ap e target return select targets in any cluster target list
select target systems for command execution
public int do local setup and verification return local success
verify all expected input fields
public command targets get command targets return select all targets and setup
select target systems for command execution
public void set setup document document document this setup document document xml utils set attribute setup document get document element ap a type ap type setup
add the setup document for subsequent use
private void redirect to details page string title throws ioexception string buffer url new string buffer ap command journaldetail iterator it add parameters journal title url append url append ap e title url append url append java net urlencoder encode title au cache systems it get journal host iterator title while it has next url append url append ap e target url append url append string java net urlencoder encode string it next log debug url url to string get servlet interface redirect page render base new href url to string
redirect to the journal detail page
private boolean is go action return go equals ignore case get parameter ap e action
is this a go
public void clear message document null list clear
clear the to be rendered list
public iterator get iterator return list iterator
get an iterator for the response list
public document get response document if list is empty return null return document list get 0
get the first response document useful when implementing internal
public document find response document containing element string name return find response document containing element name false
get the first response document which contains the requested element
public int do local setup and verification if super do local setup and verification local success set response status message supply the archival unit status table name return local fail if verify minimum parameters set response status message supply an archival unit id and target system return local fail return local success
verify required user input fields are present
public command targets get command targets array list target list select only the requested target system target list parse utils get element text list get xml utils get request document ap e target return select targets in any cluster target list
select target systems for command execution
public string get title return admin title
return the page title
public void get bread crumb detail set admin crumb detail append bread crumb detail ccp command aumenu au menu page page banner
return bread crumb information describe the path to this page
public string get title return search title
return the page title
public void get bread crumb detail set empty crumb detail
return bread crumb information describe the path to this page
public string get title return status title
return the page title
public void get bread crumb detail set status crumb detail
return bread crumb information describe the path to this page
public void do page activity string parameter try parameter get parameter ap e field1 field1 iterator get metadata fieldname iterator set field values parameter parameter get parameter ap e field2 field2 iterator get metadata fieldname iterator set field values parameter catch sqlexception exception string error text failed to lookup field names log error error text exception add status text error text exception to string
set up the field name iterators
private long parse long string value try return long parse long value catch number format exception ignore log warning the api returned an invalid disk space value value return 1
parse a diskspace value text version of a long integer
public void add bread crumb trail table table
override standard bread crumb rendering do nothing
public void get bread crumb detail set admin crumb detail append bread crumb detail ccp command setmember set cluster member page page banner
return bread crumb information describe the path to this page
private string normalize input string name string value get parameter name return value null value
normalize text input defaults preserve previous value