Package de.xima.fc.gui.bean.resource
Class ABasicResourceBean<E extends IFileDataEntity<?>,T extends IFileProviding<?,E> & INameProviding & IDescriptionProviding>
- java.lang.Object
-
- de.xima.fc.gui.common.utils.msg.I18nUtils
-
- de.xima.fc.gui.common.utils.msg.MessageUtils
-
- de.xima.fc.gui.common.utils.msg.AMessaging
-
- de.xima.fc.gui.common.utils.msg.AJSFContext
-
- de.xima.fc.gui.bean.ABackendJSFContext
-
- de.xima.fc.gui.bean.FCContextBean
-
- de.xima.fc.gui.bean.resource.ABasicResourceBean<E,T>
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ClientResourceBean
,ProjectResourceBean
public abstract class ABasicResourceBean<E extends IFileDataEntity<?>,T extends IFileProviding<?,E> & INameProviding & IDescriptionProviding> extends FCContextBean
- Author:
- XIMA MEDIA GmbH
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class de.xima.fc.gui.common.utils.msg.AJSFContext
AJSFContext.RedirectOptions, AJSFContext.RedirectOptionsBuilder
-
-
Field Summary
Fields Modifier and Type Field Description static String
FILENAME_RESOURCES_SUFFIX
static String
FILENAME_RESOURCES_ZIP
protected boolean
forceTextEdit
If true, show an editor for text files even if they are binary files or very large.protected IEntityListModel<T>
model
protected ResourceContentBean
resourceContentBean
protected org.primefaces.model.file.UploadedFile
upload
protected String
uploadFileName
protected Integer
uploadFileSize
-
Fields inherited from class de.xima.fc.gui.bean.FCContextBean
systemUC
-
Fields inherited from class de.xima.fc.gui.common.utils.msg.AJSFContext
localeBean
-
-
Constructor Summary
Constructors Constructor Description ABasicResourceBean()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected abstract boolean
checkResourceNameExist(String name)
void
checkResourceUploads(UploadInfo uploadInfo)
Before the files are uploaded, this checks for possible conflicts and other decisions the user has to make.void
cleanup()
protected abstract T
createResource(String resourceName, String description, String fileName, byte[] data, String userName)
List<FileConflict>
getFileConflicts()
String
getGeneratedUrl()
abstract String
getGeneratedUrl(T resource)
org.primefaces.model.StreamedContent
getMarkedResources()
GeneratesStreamedContent
from the List of all the marked resources contained within the model.IEntityListModel<T>
getModel()
protected abstract IEntityListModel<T>
getNewModel()
EContentType
getPreviewType()
ResourceContentBean
getResourceContentBean()
String
getResourceName()
protected org.primefaces.model.StreamedContent
getStreamedContent(List<T> resources, String zipFileName)
GeneratesStreamedContent
from the given List of resources.String
getUploadFileName()
Integer
getUploadFileSize()
boolean
hasResourceData()
boolean
isForceTextEdit()
boolean
isImageResource(T resource)
boolean
isPreviewResource(T resource)
boolean
isReaderResource(T resource)
boolean
isShowImagePreview()
boolean
isShowPreview()
boolean
isShowReaderPreview()
boolean
isShowTextPreview()
Deprecated.Use a more specific editor (JS, CSS etc.)boolean
isShowTextPreviewBinary()
boolean
isSourceCodeResource(T resource)
boolean
isTextPreviewSizeExceeded()
boolean
isTextResource(T resource)
void
onConflictsDialogClose()
Resumes the file upload once all file conflicts have been resolved.protected abstract void
openResourceConflictDialog()
protected void
resetUploadValues()
void
resolveConflicts()
Resolves all file conflicts by using the currently selected resolution.void
resolveConflicts(EFileConflictResolution resolution)
Resolves all current file conflicts by applying the given resolution to all conflicts.void
setForceTextEdit(boolean forceTextEdit)
void
setModel(IEntityListModel<T> model)
void
setResourceContentBean(ResourceContentBean resourceContentBean)
void
setResourceName(String resourceName)
void
updateModel()
protected void
updateResource(byte[] data)
Processes uploaded resourceprotected abstract T
updateResource(String resourceName, String newResourceName, String description, String fileName, byte[] data, String userName)
void
upload(org.primefaces.event.FileUploadEvent event)
Uploads resource to Beanvoid
uploadAndPersist(org.primefaces.event.FileUploadEvent event)
Uploads a file and persists it as a new resource-
Methods inherited from class de.xima.fc.gui.bean.FCContextBean
getNavigationBean, getSessionBean, isSetupUser, redirectToDashboard, setNavigationBean, setSessionBean, switchMainView, switchMainView, switchSubView, switchSubView
-
Methods inherited from class de.xima.fc.gui.bean.ABackendJSFContext
ec, findEntityContext, isDetached, isHasDB
-
Methods inherited from class de.xima.fc.gui.common.utils.msg.AJSFContext
destroySessionBean, encodeURL, findBean, findBean, findBean, findBean, findBean, findBean, findBean, findCurrentView, findUserContext, getBeanName, getBeanName, getContext, getCurrentViewBean, getLocaleBean, getRequest, getResponse, getSession, getSession, getSessionAttribute, isMasterServerContext, loadLazy, redirect, redirect, redirect, redirect, redirectToDashboard, redirectToDashboard, setLocaleBean, setSessionAttribute, uc
-
Methods inherited from class de.xima.fc.gui.common.utils.msg.MessageUtils
addErrorMsg, addErrorMsg, addErrorMsg, addErrorMsg, addErrorMsg, addErrorMsg, addErrorMsgFromString, addErrorMsgFromString, addErrorMsgToComponent, addErrorMsgToComponent, addErrorMsgToComponent, addErrorMsgToComponent, addErrorMsgToComponent, addErrorMsgToComponent, addInfoMsg, addInfoMsg, addInfoMsg, addInfoMsg, addInfoMsgFromString, addInfoMsgFromString, addInfoMsgToComponent, addInfoMsgToComponent, addInfoMsgToComponent, addInfoMsgToComponent, addMsg, addMsg, addMsg, addMsg, addMsgs, addMsgToComponent, addMsgToComponent, addWarnMsg, addWarnMsg, addWarnMsg, addWarnMsg, addWarnMsgFromString, addWarnMsgFromString, addWarnMsgToComponent, addWarnMsgToComponent, addWarnMsgToComponent, addWarnMsgToComponent, cleanErrorMsg, getErrorMessage, getNewErrorMsg, getNewErrorMsg, getNewErrorMsg, getNewInfoMsg, getNewInfoMsg, getNewMsg, getNewWarnMsg, getNewWarnMsg
-
-
-
-
Field Detail
-
FILENAME_RESOURCES_ZIP
public static final String FILENAME_RESOURCES_ZIP
- See Also:
- Constant Field Values
-
FILENAME_RESOURCES_SUFFIX
public static final String FILENAME_RESOURCES_SUFFIX
- See Also:
- Constant Field Values
-
resourceContentBean
@Inject protected ResourceContentBean resourceContentBean
-
forceTextEdit
protected boolean forceTextEdit
If true, show an editor for text files even if they are binary files or very large.
-
model
protected IEntityListModel<T extends IFileProviding<?,E> & INameProviding & IDescriptionProviding> model
-
upload
protected org.primefaces.model.file.UploadedFile upload
-
uploadFileName
protected String uploadFileName
-
uploadFileSize
protected Integer uploadFileSize
-
-
Method Detail
-
getResourceContentBean
public ResourceContentBean getResourceContentBean()
-
setResourceContentBean
public void setResourceContentBean(ResourceContentBean resourceContentBean)
-
getResourceName
public String getResourceName()
-
setResourceName
public void setResourceName(String resourceName)
-
getUploadFileName
public String getUploadFileName()
-
getUploadFileSize
public Integer getUploadFileSize()
-
updateModel
public void updateModel()
-
getModel
public IEntityListModel<T> getModel()
- Returns:
- the model
-
setModel
public void setModel(IEntityListModel<T> model)
- Parameters:
model
- the model to set
-
hasResourceData
public boolean hasResourceData()
-
isShowPreview
public boolean isShowPreview()
-
getPreviewType
public EContentType getPreviewType()
-
isShowImagePreview
public boolean isShowImagePreview()
-
isShowReaderPreview
public boolean isShowReaderPreview()
-
isShowTextPreview
@Deprecated public boolean isShowTextPreview()
Deprecated.Use a more specific editor (JS, CSS etc.)
-
isShowTextPreviewBinary
public boolean isShowTextPreviewBinary()
- Returns:
- Whether the currently selected resource should be displayed in a plain text / source code (according to its file extension), but cannot be displayed because it contains binary content (invalid UTF-8).
-
isTextPreviewSizeExceeded
public boolean isTextPreviewSizeExceeded()
- Returns:
- Whether the currently selected resource should be displayed in a plain text / source code (according to its file extension), but cannot be displayed because it is too large.
-
isForceTextEdit
public boolean isForceTextEdit()
-
setForceTextEdit
public void setForceTextEdit(boolean forceTextEdit)
-
isPreviewResource
public boolean isPreviewResource(T resource)
-
isImageResource
public boolean isImageResource(T resource)
-
isReaderResource
public boolean isReaderResource(T resource)
-
isTextResource
public boolean isTextResource(T resource)
-
isSourceCodeResource
public boolean isSourceCodeResource(T resource)
-
getFileConflicts
public List<FileConflict> getFileConflicts()
-
checkResourceUploads
public void checkResourceUploads(UploadInfo uploadInfo)
Before the files are uploaded, this checks for possible conflicts and other decisions the user has to make.- Parameters:
uploadInfo
- Details about the files that are to be uploaded, such as the file name and the file size.
-
resolveConflicts
public void resolveConflicts()
Resolves all file conflicts by using the currently selected resolution.
-
resolveConflicts
public void resolveConflicts(EFileConflictResolution resolution)
Resolves all current file conflicts by applying the given resolution to all conflicts.- Parameters:
resolution
- Conflict resolution that is applied to all conflicts.
-
onConflictsDialogClose
public void onConflictsDialogClose()
Resumes the file upload once all file conflicts have been resolved. When the conflict resolution was canceled, aborts the file upload.
-
getMarkedResources
public org.primefaces.model.StreamedContent getMarkedResources()
GeneratesStreamedContent
from the List of all the marked resources contained within the model. If this list contains only a single entry theStreamedContent
for this resource will be returned. If the list contains more than one entry the resources will be packed into a zip file and the generatedStreamedContent
of the zip file will be returned.- Returns:
- the
StreamedContent
of all the marked model resources
-
upload
public void upload(org.primefaces.event.FileUploadEvent event)
Uploads resource to Bean- Parameters:
event
-FileUploadEvent
containing the resource
-
uploadAndPersist
public void uploadAndPersist(org.primefaces.event.FileUploadEvent event)
Uploads a file and persists it as a new resource- Parameters:
event
-FileUploadEvent
containing the new resource
-
getStreamedContent
protected org.primefaces.model.StreamedContent getStreamedContent(List<T> resources, String zipFileName)
GeneratesStreamedContent
from the given List of resources. If this list contains only a single entry theStreamedContent
for this resource will be returned. If the list contains more than one entry the resources will be packed into a zip file with the specified filename and the generatedStreamedContent
of the zip file will be returned.
-
updateResource
protected void updateResource(byte[] data)
Processes uploaded resource
-
resetUploadValues
protected void resetUploadValues()
-
getNewModel
protected abstract IEntityListModel<T> getNewModel()
-
createResource
protected abstract T createResource(String resourceName, String description, String fileName, byte[] data, String userName) throws Exception
- Throws:
Exception
-
updateResource
protected abstract T updateResource(String resourceName, String newResourceName, String description, String fileName, byte[] data, String userName) throws Exception
- Throws:
Exception
-
checkResourceNameExist
protected abstract boolean checkResourceNameExist(String name)
-
openResourceConflictDialog
protected abstract void openResourceConflictDialog()
-
cleanup
@PreDestroy public void cleanup()
-
getGeneratedUrl
public String getGeneratedUrl()
-
-