Class DownloadJob

java.lang.Object
io.goobi.viewer.model.job.download.DownloadJob
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
EPUBDownloadJob, PDFDownloadJob

@Entity public abstract class DownloadJob extends Object implements Serializable

Abstract DownloadJob class.

See Also:
  • Field Details

    • DATETIME_FORMAT

      protected static final String DATETIME_FORMAT
      Constant DATETIME_FORMAT="yyyy-MM-dd'T'HH:mm:ss'Z'"
      See Also:
    • TTL_FORMAT

      protected static final String TTL_FORMAT
      Constant TTL_FORMAT="dd'T'HH:mm:ss"
      See Also:
    • id

      protected Long id
    • type

      protected String type
    • identifier

      protected String identifier
      Unique identifier for the download (e.g. a combination of PI and LOGID for PDFs).
    • pi

      protected String pi
    • logId

      protected String logId
    • message

      protected String message
    • lastRequested

      protected LocalDateTime 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

      protected JobStatus status
    • description

      protected String description
      Description field for stack traces, etc.
  • Constructor Details

    • DownloadJob

      public DownloadJob()
  • Method Details

    • generateDownloadIdentifier

      public abstract void generateDownloadIdentifier()

      generateDownloadIdentifier.

    • generateDownloadJobId

      public static String generateDownloadJobId(String... criteria)

      generateDownloadJobId.

      Parameters:
      criteria - a String object.
      Returns:
      a String object.
    • ocrFolderExists

      public static boolean ocrFolderExists(String pi) throws PresentationException, IndexUnreachableException

      ocrFolderExists.

      Parameters:
      pi - a String 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

      public abstract String getMimeType()

      getMimeType.

      Returns:
      a String object.
    • getFileExtension

      public abstract String getFileExtension()

      getFileExtension.

      Returns:
      a String object.
    • getDisplayName

      public abstract String getDisplayName()

      getDisplayName.

      Returns:
      a String object.
    • getFile

      public Path getFile()

      getFile.

      Returns:
      a Path object.
    • notifyObservers

      public boolean notifyObservers(JobStatus status, String message) throws UnsupportedEncodingException, jakarta.mail.MessagingException

      notifyObservers.

      Parameters:
      status - a io.goobi.viewer.model.job.download.DownloadJob.JobStatus object.
      message - a String object.
      Returns:
      a boolean.
      Throws:
      UnsupportedEncodingException - if any.
      javax.mail.MessagingException - if any.
      jakarta.mail.MessagingException
    • getDownloadFile

      public File getDownloadFile(String pi, String logId, String type)

      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

      public Long getId()

      Getter for the field id.

      Returns:
      the id
    • setId

      public void setId(Long id)

      Setter for the field id.

      Parameters:
      id - the id to set
    • getType

      public String getType()

      Getter for the field type.

      Returns:
      the type
    • getPi

      public String getPi()

      Getter for the field pi.

      Returns:
      the pi
    • setPi

      public void setPi(String pi)

      Setter for the field pi.

      Parameters:
      pi - the pi to set
    • getLogId

      public String getLogId()

      Getter for the field logId.

      Returns:
      the logId
    • setLogId

      public void setLogId(String logId)

      Setter for the field logId.

      Parameters:
      logId - the logId to set
    • getIdentifier

      public String getIdentifier()

      Getter for the field identifier.

      Returns:
      the identifier
    • setIdentifier

      public void setIdentifier(String identifier)

      Setter for the field identifier.

      Parameters:
      identifier - the identifier to set
    • getLastRequested

      public LocalDateTime getLastRequested()

      Getter for the field lastRequested.

      Returns:
      the lastRequested
    • setLastRequested

      public void setLastRequested(LocalDateTime lastRequested)

      Setter for the field lastRequested.

      Parameters:
      lastRequested - the lastRequested to set
    • getTtl

      public long getTtl()

      Getter for the field ttl.

      Returns:
      the ttl
    • getTimeToLive

      public String getTimeToLive()

      getTimeToLive.

      Returns:
      a String object.
    • setTtl

      public void setTtl(long ttl)

      Setter for the field ttl.

      Parameters:
      ttl - the ttl to set
    • getStatus

      public JobStatus getStatus()

      Getter for the field status.

      Returns:
      the status
    • setStatus

      public void setStatus(JobStatus status)

      Setter for the field status.

      Parameters:
      status - the status to set
    • getDescription

      public String getDescription()

      Getter for the field description.

      Returns:
      the description
    • setDescription

      public void setDescription(String description)

      Setter for the field description.

      Parameters:
      description - the description to set
    • getObservers

      public List<String> getObservers()

      Getter for the field observers.

      Returns:
      the observers
    • setObservers

      public void setObservers(List<String> observers)

      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

      public String getMessage()

      Getter for the field message.

      Returns:
      the message
    • setMessage

      public void setMessage(String message)

      Setter for the field message.

      Parameters:
      message - the message to set
    • postJobRequest

      public static javax.ws.rs.core.Response postJobRequest(String url, AbstractTaskManagerRequest body) throws IOException
      Throws:
      IOException
    • getJobStatus

      public String getJobStatus(String identifier)

      getJobStatus.

      Parameters:
      identifier - a String object.
      Returns:
      a String object.
    • getRestApiPath

      protected abstract String getRestApiPath()
      Returns:
      String
    • updateStatus

      public void updateStatus()

      updateStatus.

    • toString

      public String toString()
      Overrides:
      toString in class Object