Class DownloadJob
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
EPUBDownloadJob,PDFDownloadJob
Abstract DownloadJob class.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringConstantDATETIME_FORMAT="yyyy-MM-dd'T'HH:mm:ss'Z'"protected StringDescription field for stack traces, etc.protected Longprotected StringUnique identifier for the download (e.g. a combination of PI and LOGID for PDFs).protected LocalDateTimeTimestamp of the last request for this download.protected Stringprotected Stringprotected Stringprotected JobStatusprotected longprotected static final StringConstantTTL_FORMAT="dd'T'HH:mm:ss"protected String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DownloadJobcheckDownload(String type, String email, String pi, String logId, String downloadIdentifier, long ttl) Deprecated.booleanDeletes the file associated with this job.abstract voidgenerateDownloadIdentifier.static StringgenerateDownloadJobId(String... criteria) generateDownloadJobId.Getter for the fielddescription.abstract StringgetDisplayName.getDownloadFile(String pi, String logId, String type) getDownloadFile.getFile()getFile.abstract StringgetFileExtension.getId()Getter for the fieldid.Getter for the fieldidentifier.Getter for the fieldlastRequested.getLogId()Getter for the fieldlogId.Getter for the fieldmessage.abstract StringgetMimeType.Getter for the fieldobservers.getPi()Getter for the fieldpi.protected abstract StringGetter for the fieldstatus.getTimeToLive.longgetTtl()Getter for the fieldttl.getType()Getter for the fieldtype.booleanisExpired.booleannotifyObservers(JobStatus status, String messageId, String message) notifyObservers.static booleanocrFolderExists.static jakarta.ws.rs.core.ResponsepostJobRequest(String url, AbstractTaskManagerRequest body) Deprecated.jobs are now handled via queuesvoidEmpties the complete observer list.voidsetDescription(String description) Setter for the fielddescription.voidSetter for the fieldid.voidsetIdentifier(String identifier) Setter for the fieldidentifier.voidsetLastRequested(LocalDateTime lastRequested) Setter for the fieldlastRequested.voidSetter for the fieldlogId.voidsetMessage(String message) Setter for the fieldmessage.voidsetObservers(List<String> observers) Setter for the fieldobservers.voidSetter for the fieldpi.voidSetter for the fieldstatus.voidsetTtl(long ttl) Setter for the fieldttl.toString()protected abstract voidDeprecated.Only used in deprecated methodcheckDownload(String, String, String, String, String, long)
-
Field Details
-
DATETIME_FORMAT
ConstantDATETIME_FORMAT="yyyy-MM-dd'T'HH:mm:ss'Z'"- See Also:
-
TTL_FORMAT
ConstantTTL_FORMAT="dd'T'HH:mm:ss"- See Also:
-
id
-
type
-
identifier
Unique identifier for the download (e.g. a combination of PI and LOGID for PDFs). -
pi
-
logId
-
message
-
lastRequested
Timestamp of the last request for this download. This can be the time of the initial request, the time of generation completion or any subsequent requests. This + TTL is the time of expiration. -
ttl
protected long ttl -
status
-
description
Description field for stack traces, etc.
-
-
Constructor Details
-
DownloadJob
public DownloadJob()
-
-
Method Details
-
generateDownloadIdentifier
public abstract void generateDownloadIdentifier()generateDownloadIdentifier.
-
generateDownloadJobId
generateDownloadJobId.
-
checkDownload
@Deprecated(since="24.10") public static DownloadJob checkDownload(String type, String email, String pi, String logId, String downloadIdentifier, long ttl) throws DAOException, PresentationException, IndexUnreachableException Deprecated.only used in deprecated methodDownloadResource.getOrCreateDownloadJob(String, String, String, String)checkDownload.
- Parameters:
type- For now just 'pdf'.email- Optional e-mail address to be notified.pi- aStringobject.logId- aStringobject.downloadIdentifier- Identifier has (Construct via DownloadJob.generateDownloadJobId()).ttl- Number of ms before the job expires.- Returns:
- a boolean.
- Throws:
DAOException- if any.PresentationException- if any.IndexUnreachableException- if any.
-
triggerCreation
@Deprecated(since="24.10") protected abstract void triggerCreation() throws PresentationException, IndexUnreachableExceptionDeprecated.Only used in deprecated methodcheckDownload(String, String, String, String, String, long)triggerCreation.
- Throws:
PresentationException- if any.IndexUnreachableException- if any.
-
ocrFolderExists
public static boolean ocrFolderExists(String pi) throws PresentationException, IndexUnreachableException ocrFolderExists.
- Parameters:
pi- aStringobject.- Returns:
- a boolean.
- Throws:
PresentationException- if any.IndexUnreachableException- if any.
-
isExpired
public boolean isExpired()isExpired.
- Returns:
- a boolean.
-
deleteFile
public boolean deleteFile()Deletes the file associated with this job.- Returns:
- true if file successfully deleted; false otherwise
-
getMimeType
getMimeType.
- Returns:
- a
Stringobject.
-
getFileExtension
getFileExtension.
- Returns:
- a
Stringobject.
-
getDisplayName
getDisplayName.
- Returns:
- a
Stringobject.
-
getFile
getFile.
- Returns:
- a
Pathobject.
-
notifyObservers
public boolean notifyObservers(JobStatus status, String messageId, String message) throws UnsupportedEncodingException, jakarta.mail.MessagingException notifyObservers.
- Parameters:
status- aJobStatusobject.messageId- Id of the MQ message to link tomessage- aStringobject.- Returns:
- a boolean.
- Throws:
UnsupportedEncodingException- if any.jakarta.mail.MessagingException- if any.
-
getDownloadFile
getDownloadFile.
- Parameters:
pi- The pi of the work to download.logId- the logId of the structure element to download. Is ignored if it is null, empty, blank or equals "-"type- either "pdf" or "epub"- Returns:
- The Download location file, ending with ".pdf" or ".epub" depending on type
- Throws:
IllegalArgumentException- If the pi is null, empty or blank, or if the type is not "epub" or "pdf"
-
getId
Getter for the field
id.- Returns:
- the id
-
setId
Setter for the field
id.- Parameters:
id- the id to set
-
getType
Getter for the field
type.- Returns:
- the type
-
getPi
Getter for the field
pi.- Returns:
- the pi
-
setPi
Setter for the field
pi.- Parameters:
pi- the pi to set
-
getLogId
Getter for the field
logId.- Returns:
- the logId
-
setLogId
Setter for the field
logId.- Parameters:
logId- the logId to set
-
getIdentifier
Getter for the field
identifier.- Returns:
- the identifier
-
setIdentifier
Setter for the field
identifier.- Parameters:
identifier- the identifier to set
-
getLastRequested
Getter for the field
lastRequested.- Returns:
- the lastRequested
-
setLastRequested
Setter for the field
lastRequested.- Parameters:
lastRequested- the lastRequested to set
-
getTtl
public long getTtl()Getter for the field
ttl.- Returns:
- the ttl
-
getTimeToLive
getTimeToLive.
- Returns:
- a
Stringobject.
-
setTtl
public void setTtl(long ttl) Setter for the field
ttl.- Parameters:
ttl- the ttl to set
-
getStatus
Getter for the field
status.- Returns:
- the status
-
setStatus
Setter for the field
status.- Parameters:
status- the status to set
-
getDescription
Getter for the field
description.- Returns:
- the description
-
setDescription
Setter for the field
description.- Parameters:
description- the description to set
-
getObservers
Getter for the field
observers.- Returns:
- the observers
-
setObservers
Setter for the field
observers.- Parameters:
observers- the observers to set
-
resetObservers
public void resetObservers()Empties the complete observer list. Should be used after observers have been notified to avoid repeat notifications -
getMessage
Getter for the field
message.- Returns:
- the message
-
setMessage
Setter for the field
message.- Parameters:
message- the message to set
-
postJobRequest
@Deprecated(since="24.10") public static jakarta.ws.rs.core.Response postJobRequest(String url, AbstractTaskManagerRequest body) throws IOException Deprecated.jobs are now handled via queues- Parameters:
url-body-- Returns:
- a response
- Throws:
IOException
-
getRestApiPath
- Returns:
String
-
toString
-
DownloadResource.getOrCreateDownloadJob(String, String, String, String)