input
stringlengths
10
828
output
stringlengths
5
107
public void set roles set role set if log is debug2 log debug2 user name set roles role set set changed role set equals get role set this roles string util separated string role set this role set role set
set the users roles
public string get roles return roles null roles
return the users roles as a string
public boolean has user string username return account map contains key username
return true if named user exists
public boolean is user in role string role return get role set contains role
return true if the user has the named role
public user account get user or null string username user account res account map get username log debug2 get user username res return res
return named user account or null
public set get role set if role set null role set set util the set string util break at get roles 1 true true return role set
return a collection of the users roles
public user account get user string username user account res get user or null username return res null res nobody account
return named user account or nobody user
public string get password return current password
return the encrypted password
public file get acct dir return new file config mgr get cache config dir acct rel dir
return parent dir of all user account files
public boolean has password return credential null current password null
return the encrypted password
public long get last password change return last password change
get the time the password was last changed
public long get last user password change return last user password change
get the time the password was last changed by the user
public void set password string new pwd throws illegal password change set password new pwd false
change the password
public boolean compute steps int n throws memory bound function exception if there is no current try create one if path index 0 choose path create path move up to n steps along the path while path index path len n 0 step along path if the current path has ended see if there is a match if path index path len finish path return true if there is more work to do return finished
if there is no current path choose a starting point and set it
public void logged in http session session if alerter null if active size 0 log error alerter null but active size active lockss daemon daemon acct mgr get daemon admin servlet manager admin mgr null try admin mgr admin servlet manager daemon get manager lockss daemon servlet manager catch illegal argument exception e log warning no admin servlet manager not installing alerter task return start alerting task alerter timer queue schedule deadline in alerter interval alerter interval new alerter admin mgr if active contains key session active put session this auditable event logged in else log debug redundant now authenticated
account has logged in
public void logged out http session session if active contains key session active remove session auditable event logged out if alerter null if active size 0 timer queue cancel alerter alerter null else log error logged out but alerter null else log error logged out but not active this
account has logged out
public boolean valid throws memory bound function exception if verify throw new memory bound function exception not verifying if finished throw new memory bound function exception not yet verified return valid
return true if the vote has been verified valid false if it has
public boolean agreeing throws memory bound function exception if verify throw new memory bound function exception not verifying if finished throw new memory bound function exception not yet verified return agreeing
return true if the vote has been verified agreeing false if it has
public void set credential string cred throws no such algorithm exception if credential null throw new unsupported operation exception can t reset credential credential mdcredential make credential cred set changed true
set the credential to a string of the form hash alg encrypted passwd
public credential get credential if credential null string cred string get credential string if cred string null return null try credential mdcredential make credential cred string if log is debug2 log debug2 made credential for credential catch no such algorithm exception e log error no credential account disabled get name e credential new null credential catch runtime exception e log error no credential account disabled get name e credential new null credential return credential
return the credential string alg encrypted pwd
public boolean check object credentials if is enabled return false credential cred get credential if cred null return false boolean res cred check credentials if res handle successful login attempt else handle failed login attempt return res
check the credentials against this accounts password
protected void handle failed login attempt if failed attempt history null shift array up failed attempt history failed attempt history 0 time base now ms store user
respond appropriately to failed login attempt
protected void handle successful login attempt last login time base now ms store user
respond appropriately to successful login attempt
private permission record get string url throws malformed urlexception string key url util get host url to lower case permission record res permission at url get key string per host path if res null per host path get per host permission path null if no permission record for this host but we have a permission path to use on unknown hosts create a record for it string perm url url util resolve uri url util get url prefix url per host path logger debug2 creating permission record perm url res create record perm url return res
get the permission record for the urls host
protected string get permission url string url throws malformed urlexception permission record pr get url if pr null return null return pr get url
get the url of a hosts permission page from a url
public int get status string url throws malformed urlexception permission record pr get url if pr null return permission record permission missing return pr get status
get the hosts permission status from a url
protected boolean is excessive failed attempts long window get failed attempt window return window 0 failed attempt history null failed attempt history 0 failed attempt history failed attempt history length 1 window time base ms since failed attempt history 0 get failed attempt reset interval
true iff a max repeated login failure has been set the time between
private list get rows crawler status status string key collection mime types status get mime types list rows new array list if mime types null string mime type for iterator it mime types iterator it has next mime type string it next rows add make row status mime type key return rows
iterate over the mime types make row for each
private object make ref long value string table name string key return new status table reference new long value table name key
return a reference object to the table displaying the value
protected void do crawl end actions send crawl end report cause the content size and disk usage to be calculated in a background thread au util get au content size au false au util get au disk usage au false
separate method for easy overridability in unit tests where
public void add crawl url data curl string url curl get url if map contains key url throw new illegal argument exception illegal to replace entry map put url curl int size sorted size sorted add curl if sorted size size 1 log error adding curl didn t increase size of crawl queue crawl url comparator must have returned zero
add crawl url data to the queue
public boolean has permission string url return has permission url true
main entry point from crawler etc
public crawl url data first return crawl url data sorted get
return the first crawl url data in the queue
public crawl url data remove crawl url data res crawl url data sorted remove map remove res get url return res
remove the first crawl url data from the queue and return it
public crawl url data get string url return map get url
retun the crawl url data corresponding to the url
public int size return sorted size
return the number of elements in the queue
public boolean encountered at depth int n return encountered at depth n null
if this is a new minimum depth record it and return true else
private boolean encountered at depth int n reduced depth handler rdh if n 0 throw new illegal argument exception if n depth int olddepth depth depth n if children null for crawl url data child children child encountered at depth depth 1 rdh if rdh null rdh depth reduced this olddepth n return true return false
if this is a new minimum depth record it and return true else
public void add child crawl url data child add child child null
add a child node
public url cacher make url cacher string url url cacher uc super make url cacher url uc set redirect scheme url cacher redirect scheme store all in spec if proxy host null uc set proxy proxy host proxy port uc set fetch flags fetch flags return uc
we always want our url cacher to store all redirected copies
public void add child crawl url data child reduced depth handler rdh if children null children new array list crawl url data children add child child encountered at depth depth 1 rdh
add a child node
public void trim children if children null children trim to size
when finished updating the child list converts it into a more
public void clear children children null
reinitialize the child list
public static interface found url callback public void found url string url
callback for a content parser to call each time it finds a url
public void au deleted archival unit deleted au if au deleted au au null
return the au looking it up again from the auid if necessary e
public void add crawler crawler c crawlers add c
add a crawler to the list of those using this crawl rate limiter
public void remove crawler crawler c crawlers remove c
remove a crawler from the list of those using this crawl rate limiter
public int get crawler count return crawlers size
return the number of crawlers actively using this crawl rate
protected oai handler get oai handler return new oai handler
here for the test code to override
public int get repair count int res 0 for crawler c crawlers if c is whole au res return res
return the number of repair crawlers actively using this crawl rate
public int get new content count int res 0 for crawler c crawlers if c is whole au res return res
return the number of new content crawlers actively using this crawl
public void pause before fetch string url string previous content type rate limiter limiter get rate limiter for url previous content type try if log is debug3 log debug3 pausing limiter rate string pause counter limiter fifo wait and signal event catch interrupted exception ignore no action
wait until its time for the next fetch
public string get au id return auid
return the auid
protected string get from time date last crawl date new date aus get last crawl time string last crawl date string iso8601 date formatter format last crawl date logger debug3 from last crawl date string string last crawl date string 2004 09 08 return last crawl date string
getting the last crawl time from au state of the current au
public int get pause counter return pause counter
used to check that rate limiter is actually being invoked
protected string get until time date current date new date string current date string iso8601 date formatter format current date logger debug3 until current date string string current date string 2004 09 14 return current date string
getting the time until when we want all the changed pages
public string get au name return au name
return the aus name
public archival unit get au if au null plugin manager pmgr daemon get plugin manager au pmgr get au from id auid return au
return the au looking it up again from the auid if necessary e
public void populate table status table table if table null throw new illegal argument exception called with null status table crawl manager status cms status source get status string key table get key counts ct new counts boolean include internal aus table get options get status table option debug user table set rows get rows cms key include internal aus ct table set default sort rules sort rules table set column descriptors get col descs cms ct table set summary info get summary info cms ct
fill in the crawl status table
public void signal crawl started start time time base now ms set crawl status crawler status active init counters
signal that crawl has started
public void signal crawl ended end time time base now ms if is crawl error set crawl status crawler status successful
signal that crawl has ended
private object make ref object value string table name string key return new status table reference value table name key
return a reference object to the table displaying the value
protected url cacher make repair url cacher string url url cacher uc make url cacher url uc set redirect scheme url cacher redirect scheme follow in spec bit set fetch flags new bit set fetch flags set url cacher refetch flag uc set fetch flags fetch flags return uc
create a url cacher that follows redirects in crawl spec but stores
public boolean is crawl waiting return start time 1
return true if crawl hasnt started yet
public boolean is crawl active return start time 1 end time 1
return true if crawl is active
protected string get type string return get type to string
return the type of crawl as a string
public boolean is crawl error switch status case crawler status unknown case crawler status successful case crawler status active case crawler status queued return false default return true
return true if any error has been recorded
public string get crawl status msg if start time 1 end time 1 return get default message crawler status active else if start time 1 status null return get default message crawler status queued else return get crawl error msg
return current status of crawl
public string get crawl error msg if status message null return status message else return get default message status
return crawl error message even if crawl is still running
public boolean populate permission map if current config get boolean param param repair needs permission default repair needs permission return super populate permission map return true
if were configured to need permission to repair populate the permission
public void stop service shutting down true disable crawl starter if pool null pool shutdown now if au create destroy handler null plugin mgr unregister au event handler au create destroy handler au create destroy handler null checkpoint here status service status serv get daemon get status service if status serv null status serv unregister status accessor crawl status table name status serv unregister overview accessor crawl status table name status serv unregister status accessor crawl urls status table status serv unregister status accessor single crawl status table super stop service
stop the crawl manager
public url cacher make url cacher string url url cacher uc au make url cacher url if get daemon is clockss uc new clockss url cacher uc uc set connection pool connection pool uc set permission map source this uc set watchdog wdog if previous content type null uc set previous content type previous content type previous content type null crawl rate limiter crl get crawl rate limiter uc set crawl rate limiter crl if crawl from addr null uc set local address crawl from addr return uc
all url cachers should be made via this method so they get their
private void update status mime type cached url cu string con type cu get content type if con type null string mime type header util get mime type from content type con type crawl status signal mime type of url mime type cu get url return
update the crawl
protected void execute runnable run throws interrupted exception pool execute run if logger is debug3 logger debug3 queued started run if param odc if logger is debug3 logger debug3 waiting pool execute null runner if logger is debug3 logger debug3 waited
execute the runnable in a pool thread
private double interp long x point p1 point p2 long deltax p2 x p1 x double deltay p2 y p1 y double fract double x p1 x deltax return deltay fract p1 y
interpolate y value within single slope
public void init config manager get config manager register configuration callback new configuration callback public void configuration changed configuration new config configuration old config configuration differences changed keys set config changed keys try socket new datagram socket catch ioexception ioe ioe print stack trace xxx how should we handle errors here
initialize this log target
public url get resource string name url url find resource name class loader parent get parent if url null parent null url parent get resource name return url
attempt to load the requested resource from this classloader
static private int isbn13 check sum string isbn13 see http en wikipedia org wiki isbn int a 0 b 1 for int i 0 i 12 i b 4 b int digit 0123456789 index of isbn13 char at i if digit 0 return 1 a digit b checksum remainder 10 return 10 a 10
returns the isbn 13 checksum between 1 and 10 of the first 12
static private int isbn10 checksum string isbn10 see http en wikipedia org wiki isbn int a 0 i 0 while i 9 int digit 0123456789 index of isbn10 char at i if digit 0 return 1 a i digit checksum remainder 11 return a 11
returns the isbn 10 checksum between 0 and 10 of the first 9
public boolean take deadline timer throws interrupted exception if timer null don t call any methods on the timer while holding the semaphore s lock or we create a potential deadlock deadline interrupt callback cb new deadline interrupt callback try timer register callback cb while timer expired long sleep timer get sleep time synchronized this if state this wait sleep if state state false return true finally cb disable timer unregister callback cb synchronized this if state state false return true else return false
wait until the semaphore is full or the timer expires
synchronized public void give state true this notify all
fill the semaphore
public char get int n if n size throw new index out of bounds exception tried to get the n element in a ring with size elements return chars head n capacity
returns the nth char from this ring
public void add char kar throws ring full exception if size capacity throw new ring full exception array is full if is trace logger debug2 adding kar to to string chars tail kar tail tail 1 capacity size
add kar to the end of this ring
public void add char new chars throws ring full exception add new chars 0 new chars length
add all chars in new chars to this ring
static private plugin manager get plugin manager get lockss daemon plugin manager if plugin manager null set plugin manager lockss daemon get lockss daemon get plugin manager return plugin manager
returns the plugin manager for the current lockss daemon
public char remove if size 0 throw new index out of bounds exception remove called on empty char ring if is trace logger debug2 removing head from to string char return kar chars head head head 1 capacity size if is trace logger debug2 returning return kar return return kar
remove the next char from the ring and return it
public int remove char return chars return remove return chars 0 return chars length
remove the next return chars
public int remove char return chars int pos int len int num to return len size len size if num to return 0 return 0 number of chars to remove from end of array int chunk1 num to return capacity head num to return capacity head number of chars to remove from start of array int chunk2 num to return chunk1 if chunk1 0 system arraycopy chars head return chars pos chunk1 if chunk2 0 system arraycopy chars 0 return chars pos chunk1 chunk2 head head num to return capacity size num to return return num to return
remove the next len chars from the ring into an array
static public string get volume title from au id string plugin id string au key tdb au tdb au get tdb au from au id plugin id au key return tdb au null null tdb au get name
return the volume title that corresponds to the auid
public int remove string buffer sb int len int num to return len size len size if num to return 0 return 0 number of chars to remove from end of array int chunk1 num to return capacity head num to return capacity head number of chars to remove from start of array int chunk2 num to return chunk1 if chunk1 0 sb append chars head chunk1 if chunk2 0 sb append chars 0 chunk2 head head num to return capacity size num to return return num to return
remove the next len chars from the ring into a string buffer
public void clear skip size
clear the ring
public void skip int num if num 0 throw new index out of bounds exception tried to clear a negative number num if num size throw new index out of bounds exception tried to clear num chars but we only have size head head num capacity size num
skip over the next num chars from the ring
static public string get volume title from article url string article url get the tdb au from the au tdb au tdb au get tdb au from article url article url return tdb au null null tdb au get name
return the journal or series title from that corresponds
static public string get title from au id string plugin id string au key tdb au tdb au get tdb au from au id plugin id au key return tdb au null null tdb au get journal title
return the journal or series title that corresponds to the auid
public boolean skip leading white space if character is whitespace get 0 int idx 0 do idx while idx size character is whitespace get idx skip idx return true return false
skips any leading whitespace and return true if any was found
public boolean starts with ignore case string str return starts with ignore case str 0
return true if the ring starts with the specified string ignoring case
public boolean starts with ignore case string str int start idx if str length start idx size return false for int ix 0 ix str length ix if string util equals ignore case get ix start idx str char at ix return false return true
return true if the ring starts with the specified string ignoring case
static public string get title from article url string article url get the tdb au from the au tdb au tdb au get tdb au from article url article url return tdb au null null tdb au get journal title
return the journal or series title from that corresponds
static public string get publisher from article url string article url get the tdb au from the au tdb au tdb au get tdb au from article url article url return tdb au null null tdb au get tdb publisher get name
return the publisher from the title database that corresponds
static private string unpunctuate string s return s null null s replace all
remove punctuation from a string