Class AbstractDownloadStrategy

java.lang.Object
com.atlassian.bamboo.plugin.servlet.AbstractDownloadStrategy
All Implemented Interfaces:
com.atlassian.plugin.servlet.DownloadStrategy
Direct Known Subclasses:
ArtifactDownloadStrategy, BambooSpecsZipDownloadStrategy, DefaultDownloadStrategy, DeploymentDownloadStrategy, GlobalArtifactDownloadStrategy, SpecLogsDownloadStrategy

public abstract class AbstractDownloadStrategy extends Object implements com.atlassian.plugin.servlet.DownloadStrategy
  • Field Details

  • Constructor Details

  • Method Details

    • matches

      public boolean matches(String requestUri)
      Specified by:
      matches in interface com.atlassian.plugin.servlet.DownloadStrategy
    • getServletPath

      protected abstract String getServletPath()
      Returns the servlet path handled by this download strategy. Includes the leading "/" but no trailing "/", e.g. "/download" or "/artifact".
    • serveFile

      public void serveFile(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse) throws com.atlassian.plugin.servlet.DownloadException
      Specified by:
      serveFile in interface com.atlassian.plugin.servlet.DownloadStrategy
      Throws:
      com.atlassian.plugin.servlet.DownloadException
    • getFileToServe

      @NotNull protected abstract @NotNull TitledFile getFileToServe(RequestPath requestPath, javax.servlet.http.HttpServletRequest request) throws org.acegisecurity.AccessDeniedException, FileNotFoundException, UserNotLoggedInException, WebValidationException
      Returns:
      file to serve, with an optional display name if file is a directory
      Throws:
      org.acegisecurity.AccessDeniedException
      FileNotFoundException
      UserNotLoggedInException
      WebValidationException
    • processRangeHeader

      protected long[] processRangeHeader(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse, long fileLength)
      Processes the Range header from the HTTP request to determine the byte range to be served This method validates the range, calculates the start and content length, and sets the appropriate response headers If the range is invalid or not satisfiable, it sets the response status to 416 (Range Not Satisfiable)
      Parameters:
      httpServletRequest - The servlet request containing the Range header (if present)
      httpServletResponse - The servlet response to set the headers on
      fileLength - The total length of the file being requested
      Returns:
      An array containing the start position and content length to be served, or null if the range is invalid
    • throwPermissionException

      protected void throwPermissionException(RequestPath requestPath) throws UserNotLoggedInException, org.acegisecurity.AccessDeniedException
      Throws an exception indicating that the current user does not have permission to access the requested item. The requestPath parameter may be included in the exception message and/or logs.
      Throws:
      UserNotLoggedInException
      org.acegisecurity.AccessDeniedException
    • isCompressionEnabled

      protected boolean isCompressionEnabled()