@ -217,7 +217,7 @@ public class WorkTables extends Tables {
* @param port the port on the host
* @param port the port on the host
* @return a map of the called urls and the http status code of the api call or - 1 if any other IOException occurred
* @return a map of the called urls and the http status code of the api call or - 1 if any other IOException occurred
* /
* /
public Map < String , Integer > execAPICalls ( String host , int port , Collection < String > pks , final String pass) {
public Map < String , Integer > execAPICalls ( String host , int port , Collection < String > pks , final String username, final String pass) {
// now call the api URLs and store the result status
// now call the api URLs and store the result status
final HTTPClient client = new HTTPClient ( ClientIdentification . yacyInternetCrawlerAgent ) ;
final HTTPClient client = new HTTPClient ( ClientIdentification . yacyInternetCrawlerAgent ) ;
client . setTimout ( 120000 ) ;
client . setTimout ( 120000 ) ;
@ -238,7 +238,7 @@ public class WorkTables extends Tables {
url + = "&" + WorkTables . TABLE_API_COL_APICALL_PK + "=" + UTF8 . String ( row . getPK ( ) ) ;
url + = "&" + WorkTables . TABLE_API_COL_APICALL_PK + "=" + UTF8 . String ( row . getPK ( ) ) ;
ConcurrentLog . info ( "WorkTables" , "executing url: " + url ) ;
ConcurrentLog . info ( "WorkTables" , "executing url: " + url ) ;
try {
try {
client . GETbytes ( url , pass) ;
client . GETbytes ( url , username, pass) ;
l . put ( url , client . getStatusCode ( ) ) ;
l . put ( url , client . getStatusCode ( ) ) ;
} catch ( final IOException e ) {
} catch ( final IOException e ) {
ConcurrentLog . logException ( e ) ;
ConcurrentLog . logException ( e ) ;
@ -248,14 +248,14 @@ public class WorkTables extends Tables {
return l ;
return l ;
}
}
public static int execAPICall ( String host , int port , String path , byte [ ] pk , final String pass) {
public static int execAPICall ( String host , int port , String path , byte [ ] pk , final String username, final String pass) {
// now call the api URLs and store the result status
// now call the api URLs and store the result status
final HTTPClient client = new HTTPClient ( ClientIdentification . yacyInternetCrawlerAgent ) ;
final HTTPClient client = new HTTPClient ( ClientIdentification . yacyInternetCrawlerAgent ) ;
client . setTimout ( 120000 ) ;
client . setTimout ( 120000 ) ;
String url = "http://" + host + ":" + port + path ;
String url = "http://" + host + ":" + port + path ;
if ( pk ! = null ) url + = "&" + WorkTables . TABLE_API_COL_APICALL_PK + "=" + UTF8 . String ( pk ) ;
if ( pk ! = null ) url + = "&" + WorkTables . TABLE_API_COL_APICALL_PK + "=" + UTF8 . String ( pk ) ;
try {
try {
client . GETbytes ( url , pass) ;
client . GETbytes ( url , username, pass) ;
return client . getStatusCode ( ) ;
return client . getStatusCode ( ) ;
} catch ( final IOException e ) {
} catch ( final IOException e ) {
ConcurrentLog . logException ( e ) ;
ConcurrentLog . logException ( e ) ;
@ -271,10 +271,10 @@ public class WorkTables extends Tables {
* @param realm authentification realm
* @param realm authentification realm
* @return the http status code of the api call or - 1 if any other IOException occurred
* @return the http status code of the api call or - 1 if any other IOException occurred
* /
* /
public int execAPICall ( String pk , String host , int port , final String pass) {
public int execAPICall ( String pk , String host , int port , final String username, final String pass) {
ArrayList < String > pks = new ArrayList < String > ( ) ;
ArrayList < String > pks = new ArrayList < String > ( ) ;
pks . add ( pk ) ;
pks . add ( pk ) ;
Map < String , Integer > m = execAPICalls ( host , port , pks , pass) ;
Map < String , Integer > m = execAPICalls ( host , port , pks , username, pass) ;
if ( m . isEmpty ( ) ) return - 1 ;
if ( m . isEmpty ( ) ) return - 1 ;
return m . values ( ) . iterator ( ) . next ( ) . intValue ( ) ;
return m . values ( ) . iterator ( ) . next ( ) . intValue ( ) ;
}
}