Class FileResourceImpl
- java.lang.Object
-
- nl.gx.webmanager.api.implementation.FileResourceImpl
-
- All Implemented Interfaces:
FileResource
public class FileResourceImpl extends Object implements FileResource
This class implements a resource.
-
-
Constructor Summary
Constructors Constructor Description FileResourceImpl(javax.jcr.Node node)
The node and the serverName to construct the resource fromFileResourceImpl(org.springframework.web.multipart.MultipartFile file)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InputStream
getData()
Return the inputStream for the resourceString
getFileName()
Return the filename for the resourceString
getId()
Get the unique id (UUID) of this fileCalendar
getLastModified()
Return the last modified date of the resourceString
getMimeType()
Return the mimetype of the resourceorg.springframework.web.multipart.MultipartFile
getMultipartFile()
This method returns the belonging MultipartFileString
getServerName()
Return the servername on which the resource is stored.long
getSize()
Returns the size in bytes of the resourceString
getURL()
Return the URL that serves the fileString
getURL(String ownerUUID)
Return the URL that serves the file for the given file ownerboolean
isPublic()
Sets if the file resource is public or notboolean
mayView(javax.servlet.http.HttpServletRequest request)
This method is invoked when a not public file is requested.void
setPublic(boolean isPublic)
Sets whether this file is 'public'.
-
-
-
Constructor Detail
-
FileResourceImpl
public FileResourceImpl(org.springframework.web.multipart.MultipartFile file)
Constructor- Parameters:
file
- The multiPart file to construct the resource from
-
FileResourceImpl
public FileResourceImpl(javax.jcr.Node node)
The node and the serverName to construct the resource from- Parameters:
node
- The node
-
-
Method Detail
-
getId
public String getId()
Get the unique id (UUID) of this file- Specified by:
getId
in interfaceFileResource
- Returns:
- The id of this file
-
getData
public InputStream getData()
Return the inputStream for the resource- Specified by:
getData
in interfaceFileResource
- Returns:
- InputStream of the resource
-
getFileName
public String getFileName()
Return the filename for the resource- Specified by:
getFileName
in interfaceFileResource
- Returns:
- File name of the resource
-
isPublic
public boolean isPublic()
Sets if the file resource is public or not- Specified by:
isPublic
in interfaceFileResource
- Parameters:
isPublic
- true if it is public- Returns:
- true if the file is public, false otherwise
-
getLastModified
public Calendar getLastModified()
Return the last modified date of the resource- Specified by:
getLastModified
in interfaceFileResource
- Returns:
- Calendar with the last modified date of the resource
-
getMimeType
public String getMimeType()
Return the mimetype of the resource- Specified by:
getMimeType
in interfaceFileResource
- Returns:
- Mimetype of the resource
-
getSize
public long getSize()
Returns the size in bytes of the resource- Specified by:
getSize
in interfaceFileResource
- Returns:
- Size in bytes of the resource
-
getServerName
public String getServerName()
Return the servername on which the resource is stored.- Specified by:
getServerName
in interfaceFileResource
- Returns:
-
getURL
public String getURL()
Return the URL that serves the file- Specified by:
getURL
in interfaceFileResource
- Returns:
- URL that serves the file
-
getURL
public String getURL(String ownerUUID)
Return the URL that serves the file for the given file owner- Specified by:
getURL
in interfaceFileResource
- Parameters:
ownerUUID
- UUID of the JCR wrapper class that implements the FileResourceSecurityCheck interface. This class determines if the user is allowed to retrieve the file.- Returns:
- URL that serves the file
-
mayView
public boolean mayView(javax.servlet.http.HttpServletRequest request)
Description copied from interface:FileResource
This method is invoked when a not public file is requested.- Specified by:
mayView
in interfaceFileResource
- Returns:
- true is the user requesting the file is authorized for doing so, false otherwise
-
setPublic
public void setPublic(boolean isPublic)
Description copied from interface:FileResource
Sets whether this file is 'public'. This method should not be used to change the public state of a FileResource.- Specified by:
setPublic
in interfaceFileResource
-
getMultipartFile
public org.springframework.web.multipart.MultipartFile getMultipartFile()
Description copied from interface:FileResource
This method returns the belonging MultipartFile- Specified by:
getMultipartFile
in interfaceFileResource
- Returns:
- The encapsulated MultipartFile if present, else null
-
-