public class ScrapingSessionServiceImpl extends RemoteServiceServlet implements ScrapingSessionService, WebConstants
Modifier and Type | Field and Description |
---|---|
static Logger |
log |
APD_LOG_CONTENTS, APD_NUM_LOG_LINES_TO_DISPLAY, APD_RUN_RUNNING_SESSION_TAB, APD_RUNNABLE_SESSION_TAB, APD_SCHEDULED_SCRAPING_SESSION_DATA, APD_SCHEDULED_SESSION_TAB, APD_SCRAPEABLE_SESSION_ID, APD_SCRAPING_SESSION_ID, APD_TAB_TO_SELECT, APE_DISPLAY_ENTER_REGISTRATION_INFORMATION_DIALOG, APE_DISPLAY_IMPORT_DIALOG, APE_DISPLAY_NOTES_DIALOG, APE_DISPLAY_PEEK_LOG_DIALOG, APE_DISPLAY_SCRAPING_SESSION_SCHEDULER_DIALOG, APE_DISPLAY_SETTINGS_DIALOG, APE_HIDE_REGISTRATION_BUTTON, APE_REFRESH_TABLE, APE_SCHEDULE_SCRAPING_SESSION, APE_SELECT_RUN_RUNNING_TAB_AND_REFRESH_TABLE, APE_SELECT_RUNNABLE_TAB_AND_REFRESH_TABLE, APE_SELECT_SHEDULED_TAB_AND_REFRESH_TABLE, APE_SELECT_TAB, DEFAULT_REPEAT_DAYS, DEFAULT_REPEAT_HOURS, DEFAULT_REPEAT_MINUTES, DEFAULT_REPEAT_SECONDS, DEFAULT_THRESHOLD_RECORD_COUNT, DEFAULT_THRESHOLD_TIME, DEFAULT_TIMEOUT, DOWNLOAD_FILE_TYPE_SCRAPING_SESSION, ENABLED, ERROR_MESSAGE, FOLDER_NAME, GUI_DIALOG_BOX_SCHEDULE_SCRAPING_SESSION, GUI_PANEL_MAIN_CONTENT, GUI_PANEL_RUN_RUNNING_SCRAPING_SESSIONS, GUI_PANEL_RUNNABLE_SCRAPING_SESSIONS, GUI_PANEL_SCHEDULED_SCRAPING_SESSIONS, GUI_PANEL_TOP_NAV, GUI_SCREENSCRAPER_WEB, GUI_SETTINGS_DIALOG, IS_ERROR, NUM_RECORDS, PREVIOUS_NUM_RECORDS, PREVIOUS_RUNNING_TIME, PREVIOUS_RUNNING_TIME_MACHINE_READABLE, REPEAT_DAYS, REPEAT_HOURS, REPEAT_MINUTES, REPEAT_SECONDS, RUNNING_TIME, RUNNING_TIME_MACHINE_READABLE, SCHEDULE_DATE, SCHEDULE_TIME, SCHEDULED_SCRAPING_SESSION_ID, SCRAPEABLE_SESSION_ID, SCRAPING_SESSION_ID, SCRAPING_SESSION_NAME, SCRAPING_SESSIONS, SECONDS_IN_A_DAY, SECONDS_IN_A_MINUTE, SECONDS_IN_AN_HOUR, SETTABLE_SESSION_VARIABLES, START_TIME, START_TIME_MACHINE_READABLE, STATUS, STATUS_COMPLETED, STATUS_IN_PROCESS, STATUS_INTERRUPTED, STATUS_NOT_STARTED, STATUS_UNKNOWN, THRESHOLD_RECORD_COUNT, THRESHOLD_TIME, TIMEOUT
Constructor and Description |
---|
ScrapingSessionServiceImpl() |
Modifier and Type | Method and Description |
---|---|
void |
disableEnableScheduledScrapingSession(java.lang.String id,
boolean enable)
Disables the
ScheduledScrapingSession with the given name. |
java.lang.String |
finalizeScrapeableSession(java.lang.String id)
Finalizes and resets the
ScrapeableSession identified. |
int |
getCpuUsage()
Gets the current cpu usage (averaged over the last short while -- about 20 seconds) as a percentage.
|
int |
getDiskUsage()
Gets the current hard disk usage as a percentage.
|
int |
getMemoryUsage()
Gets the current memory usage as a percentage.
|
java.util.ArrayList |
getRunnableScrapingSessions()
Returns data about scraping sessions that can be run.
|
java.util.ArrayList |
getRunnableScrapingSessionsInFolders()
Returns data about scraping sessions that can be run, and gives them within folders..
|
java.util.ArrayList |
getScheduledScrapingSessions()
Returns data about scraping sessions that are scheduled to be run.
|
java.util.ArrayList |
getScrapeableSessions()
Gets scraping sessions that have run or are currently running.
|
java.lang.String |
getScrapingSessionNotes(java.lang.String scrapingSessionID)
Gets notes for the scraping session identified by the given ID.
|
java.lang.String |
getSessionVariableOnScrapeableSession(java.lang.String id,
java.lang.String key)
Gets a session variable from a running scrapeable session.
|
java.util.HashMap |
getSettings()
Gets the default settings in a
HashMap . |
boolean |
hasBeenVal()
Indicates whether or not this instance has already beeen registered.
|
java.lang.String |
peekLog(java.lang.String id,
int numLines)
Peeks at the log for the
ScrapingSession associated with the ScrapeableSession identified. |
void |
reloadSettings()
Reloads settings from the properties file.
|
void |
removeCompletedScrapeableSessions()
Removes
ScrapeableSession objects that don't have an in-process status. |
void |
removeScheduledScrapingSession(java.lang.String id)
Remove the
ScheduledScrapingSession with the given name. |
void |
removeScrapeableSession(java.lang.String id)
Removes the
ScrapeableSession identified. |
void |
removeScrapingSession(java.lang.String name)
Removes the
ScrapingSession with the given name. |
int |
runScrapingSession(java.lang.String name,
java.lang.String settableSessionVariables)
Runs the
ScrapingSession with the given name. |
int |
runScrapingSession(java.lang.String name,
java.lang.String settableSessionVariables,
boolean doLazyScrape)
Runs the
ScrapingSession with the given name. |
void |
runScrapingSessions(java.util.ArrayList scrapingSessionIDs)
Runs a series of scraping sessions.
|
void |
runScrapingSessionsForFolder(java.lang.String name)
Runs scraping sessions found within a folder.
|
void |
saveSettings(java.util.HashMap settings)
Saves settings.
|
int |
setScheduledScrapingSession(java.util.HashMap params)
Saves a scheduled scraping session to the database.
|
void |
setSessionVariableOnScrapeableSession(java.lang.String id,
java.lang.String key,
java.lang.String value)
Sets a session variable on a running scrapeable session.
|
void |
stopAllRunningScrapingSessions()
Stops all running scraping sessions.
|
void |
stopRunningScrapingSession(java.lang.String id)
Stops the running
ScrapingSession associated with the ScrapeableSession identified. |
boolean |
valEA(java.lang.String em)
Validates a license using a given email address.
|
public java.util.ArrayList getRunnableScrapingSessions() throws java.lang.Exception
ArrayList
will hold HashMap
objects containing the data.getRunnableScrapingSessions
in interface ScrapingSessionService
ArrayList
.java.lang.Exception
public java.util.ArrayList getRunnableScrapingSessionsInFolders() throws java.lang.Exception
ArrayList
will hold HashMap
objects
containing the data.getRunnableScrapingSessionsInFolders
in interface ScrapingSessionService
ArrayList
.java.lang.Exception
public java.util.ArrayList getScrapeableSessions() throws java.lang.Exception
getScrapeableSessions
in interface ScrapingSessionService
java.lang.Exception
public void runScrapingSessionsForFolder(java.lang.String name) throws java.lang.Exception
runScrapingSessionsForFolder
in interface ScrapingSessionService
name
- The name of the folder containing the scraping sessions.java.lang.Exception
public int runScrapingSession(java.lang.String name, java.lang.String settableSessionVariables) throws java.lang.Exception
ScrapingSession
with the given name.runScrapingSession
in interface ScrapingSessionService
name
- The name of the ScrapingSession
to run.settableSessionVariables
- A key/value encoded string of session variables to set. This parameter is optional.ScrapeableSession
object.java.lang.Exception
public int runScrapingSession(java.lang.String name, java.lang.String settableSessionVariables, boolean doLazyScrape) throws java.lang.Exception
ScrapingSession
with the given name.name
- The name of the ScrapingSession
to run.settableSessionVariables
- A key/value encoded string of sessiondoLazyScrape
- A boolean indicating whether or not it's to be a lazy scrape. variables to set. This parameter is optional.ScrapeableSession
object.java.lang.Exception
public void runScrapingSessions(java.util.ArrayList scrapingSessionIDs)
runScrapingSessions
in interface ScrapingSessionService
scrapingSessionIDs
- An ArrayList
containing scraping session ID's as String
objects.public int setScheduledScrapingSession(java.util.HashMap params) throws java.lang.Exception
setScheduledScrapingSession
in interface ScrapingSessionService
params
- A HashMap
containing data about the scraping session to be saved.ScrapeableSession
object.java.lang.Exception
public java.util.ArrayList getScheduledScrapingSessions()
ArrayList
will hold HashMap
objects containing the data.getScheduledScrapingSessions
in interface ScrapingSessionService
ArrayList
.public void disableEnableScheduledScrapingSession(java.lang.String id, boolean enable) throws java.lang.Exception
ScheduledScrapingSession
with the given name.disableEnableScheduledScrapingSession
in interface ScrapingSessionService
id
- The ID of the ScheduledScrapingSession
to disable.enable
- Whether or not the ScheduledScrapingSession
should be enabled.java.lang.Exception
public void removeScheduledScrapingSession(java.lang.String id) throws java.lang.Exception
ScheduledScrapingSession
with the given name.removeScheduledScrapingSession
in interface ScrapingSessionService
id
- The name of the ScheduledScrapingSession
to be removed.java.lang.Exception
public void removeCompletedScrapeableSessions() throws java.lang.Exception
ScrapeableSession
objects that don't have an in-process status.removeCompletedScrapeableSessions
in interface ScrapingSessionService
java.lang.Exception
public void removeScrapeableSession(java.lang.String id) throws java.lang.Exception
ScrapeableSession
identified.removeScrapeableSession
in interface ScrapingSessionService
id
- The ID of the ScrapeableSession
to remove.java.lang.Exception
public void removeScrapingSession(java.lang.String name) throws java.lang.Exception
ScrapingSession
with the given name.removeScrapingSession
in interface ScrapingSessionService
name
- The name of the ScrapingSession
to deleted.java.lang.Exception
public java.lang.String finalizeScrapeableSession(java.lang.String id)
ScrapeableSession
identified.id
- The ID of the ScrapeableSession
to finalize.public java.lang.String peekLog(java.lang.String id, int numLines)
ScrapingSession
associated with the ScrapeableSession
identified.peekLog
in interface ScrapingSessionService
id
- The ID of the ScrapeableSession
to view.numLines
- The number of lines from the end of the log to return.public java.lang.String getScrapingSessionNotes(java.lang.String scrapingSessionID)
getScrapingSessionNotes
in interface ScrapingSessionService
scrapingSessionID
- The ID of the scraping session.public void stopRunningScrapingSession(java.lang.String id) throws java.lang.Exception
ScrapingSession
associated with the ScrapeableSession
identified.stopRunningScrapingSession
in interface ScrapingSessionService
id
- The ID of the ScrapeableSession
to stop.java.lang.Exception
public void stopAllRunningScrapingSessions() throws java.lang.Exception
stopAllRunningScrapingSessions
in interface ScrapingSessionService
java.lang.Exception
public void saveSettings(java.util.HashMap settings) throws java.lang.Exception
saveSettings
in interface ScrapingSessionService
settings
- A HashMap
containing the settings.java.lang.Exception
public void reloadSettings() throws java.lang.Exception
reloadSettings
in interface ScrapingSessionService
java.lang.Exception
public java.util.HashMap getSettings()
HashMap
.getSettings
in interface ScrapingSessionService
public boolean valEA(java.lang.String em)
valEA
in interface ScrapingSessionService
em
- The email address to use.public boolean hasBeenVal()
hasBeenVal
in interface ScrapingSessionService
public int getMemoryUsage() throws java.lang.Exception
getMemoryUsage
in interface ScrapingSessionService
java.lang.Exception
- On error getting the value (shouldn't every happen)public int getCpuUsage() throws java.lang.Exception
getCpuUsage
in interface ScrapingSessionService
java.lang.Exception
- On error getting the value (shouldn't every happen)public int getDiskUsage() throws java.lang.Exception
getDiskUsage
in interface ScrapingSessionService
java.lang.Exception
- On error getting the value (shouldn't every happen)public java.lang.String getSessionVariableOnScrapeableSession(java.lang.String id, java.lang.String key) throws java.lang.Exception
getSessionVariableOnScrapeableSession
in interface ScrapingSessionService
id
- The ID of the scrapeable session.key
- The variable name.java.lang.Exception
public void setSessionVariableOnScrapeableSession(java.lang.String id, java.lang.String key, java.lang.String value) throws java.lang.Exception
setSessionVariableOnScrapeableSession
in interface ScrapingSessionService
id
- The ID of the scrapeable session.key
- The variable name.value
- The value to be set.java.lang.Exception