Package org.silverpeas.core.web.http
Class RestFileResponse
- java.lang.Object
-
- org.silverpeas.core.web.http.FileResponse
-
- org.silverpeas.core.web.http.RestFileResponse
-
public class RestFileResponse extends FileResponse
Centralizing the code which permits to send a file, and if necessary or asked to send it partially.- Author:
- Yohann Chastagnier
-
-
Field Summary
-
Fields inherited from class org.silverpeas.core.web.http.FileResponse
DOWNLOAD_CONTEXT_PARAM
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RestFileResponseforceCharacterEncoding(String forcedCharacterEncoding)Forces the character encoding of the response.RestFileResponseforceFileId(String fileId)Forces the file identifier.
If not forced, the absolute path of the file into Base64 is computed.RestFileResponseforceFileName(String fileName)Forces the file name into the response.
If not forced, the file name is computed from the file itself.
Even if a file name has been forced, if the request contains into headers a valuatedforceFileNameparameter, the file name from the request is taken into account.RestFileResponseforceMimeType(String mimeType)Forces the mime type of the response.
If not forced, the mime type is computed from the file itself.
Even if a mime type has been forced, if the request contains into headers a valuatedforceMimeTypeparameter, the mime type from the request is taken into account.RestFileResponsenoCache()Sets into response that no cache MUST be handled.javax.ws.rs.core.Response.ResponseBuildersilverpeasFile(SilverpeasFile file)Centralization of getting of silverpeas file content.javax.ws.rs.core.Response.ResponseBuildersilverpeasFile(SilverpeasFile file, boolean downloadContext)Centralization of getting of silverpeas file content.-
Methods inherited from class org.silverpeas.core.web.http.FileResponse
encodeAttachmentFilenameAsUtf8, encodeInlineFilenameAsUtf8, fromRest, fromServlet
-
-
-
-
Method Detail
-
silverpeasFile
public javax.ws.rs.core.Response.ResponseBuilder silverpeasFile(SilverpeasFile file)
Centralization of getting of silverpeas file content.A download context flag is verified from parameters and attributes of the request.
- Parameters:
file- the silverpeas file to send.- Returns:
- the response builder.
-
silverpeasFile
public javax.ws.rs.core.Response.ResponseBuilder silverpeasFile(SilverpeasFile file, boolean downloadContext)
Centralization of getting of silverpeas file content.Using directly this method means that the request downloadContext flag is ignored.
- Parameters:
file- the silverpeas file to send.downloadContext- indicating a download context in order to specify rightly response headers.- Returns:
- the response builder.
-
forceFileId
public RestFileResponse forceFileId(String fileId)
Description copied from class:FileResponseForces the file identifier.
If not forced, the absolute path of the file into Base64 is computed.- Overrides:
forceFileIdin classFileResponse- Parameters:
fileId- the file identifier.- Returns:
- itself.
-
forceMimeType
public RestFileResponse forceMimeType(String mimeType)
Description copied from class:FileResponseForces the mime type of the response.
If not forced, the mime type is computed from the file itself.
Even if a mime type has been forced, if the request contains into headers a valuatedforceMimeTypeparameter, the mime type from the request is taken into account.- Overrides:
forceMimeTypein classFileResponse- Parameters:
mimeType- the mime type to set.- Returns:
- itself.
-
forceCharacterEncoding
public RestFileResponse forceCharacterEncoding(String forcedCharacterEncoding)
Description copied from class:FileResponseForces the character encoding of the response.- Overrides:
forceCharacterEncodingin classFileResponse- Parameters:
forcedCharacterEncoding- the character encoding to set.- Returns:
- itself.
-
forceFileName
public RestFileResponse forceFileName(String fileName)
Description copied from class:FileResponseForces the file name into the response.
If not forced, the file name is computed from the file itself.
Even if a file name has been forced, if the request contains into headers a valuatedforceFileNameparameter, the file name from the request is taken into account.- Overrides:
forceFileNamein classFileResponse- Parameters:
fileName- the file name to set.- Returns:
- itself.
-
noCache
public RestFileResponse noCache()
Description copied from class:FileResponseSets into response that no cache MUST be handled.- Overrides:
noCachein classFileResponse- Returns:
- itself.
-
-