Class DownloadJob
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
EPUBDownloadJob
,PDFDownloadJob
Abstract DownloadJob class.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
ConstantDATETIME_FORMAT="yyyy-MM-dd'T'HH:mm:ss'Z'"
protected String
Description field for stack traces, etc.protected Long
protected String
Unique identifier for the download (e.g. a combination of PI and LOGID for PDFs).protected LocalDateTime
Timestamp of the last request for this download.protected String
protected String
protected String
protected JobStatus
protected long
protected static final String
ConstantTTL_FORMAT="dd'T'HH:mm:ss"
protected String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic DownloadJob
checkDownload
(String type, String email, String pi, String logId, String downloadIdentifier, long ttl) Deprecated.boolean
Deletes the file associated with this job.abstract void
generateDownloadIdentifier.static String
generateDownloadJobId
(String... criteria) generateDownloadJobId.Getter for the fielddescription
.abstract String
getDisplayName.getDownloadFile
(String pi, String logId, String type) getDownloadFile.getFile()
getFile.abstract String
getFileExtension.getId()
Getter for the fieldid
.Getter for the fieldidentifier
.Getter for the fieldlastRequested
.getLogId()
Getter for the fieldlogId
.Getter for the fieldmessage
.abstract String
getMimeType.Getter for the fieldobservers
.getPi()
Getter for the fieldpi
.protected abstract String
Getter for the fieldstatus
.getTimeToLive.long
getTtl()
Getter for the fieldttl
.getType()
Getter for the fieldtype
.boolean
isExpired.boolean
notifyObservers
(JobStatus status, String messageId, String message) notifyObservers.static boolean
ocrFolderExists.static javax.ws.rs.core.Response
postJobRequest
(String url, AbstractTaskManagerRequest body) Deprecated.jobs are now handled via queuesvoid
Empties the complete observer list.void
setDescription
(String description) Setter for the fielddescription
.void
Setter for the fieldid
.void
setIdentifier
(String identifier) Setter for the fieldidentifier
.void
setLastRequested
(LocalDateTime lastRequested) Setter for the fieldlastRequested
.void
Setter for the fieldlogId
.void
setMessage
(String message) Setter for the fieldmessage
.void
setObservers
(List<String> observers) Setter for the fieldobservers
.void
Setter for the fieldpi
.void
Setter for the fieldstatus
.void
setTtl
(long ttl) Setter for the fieldttl
.toString()
protected abstract void
Deprecated.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
- aString
object.logId
- aString
object.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
- aString
object.- 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
String
object.
-
getFileExtension
getFileExtension.
- Returns:
- a
String
object.
-
getDisplayName
getDisplayName.
- Returns:
- a
String
object.
-
getFile
getFile.
- Returns:
- a
Path
object.
-
notifyObservers
public boolean notifyObservers(JobStatus status, String messageId, String message) throws UnsupportedEncodingException, jakarta.mail.MessagingException notifyObservers.
- Parameters:
status
- aJobStatus
object.message
- aString
object.messageId
- Id of the MQ message to link to- 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
String
object.
-
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 javax.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)