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 StringFILENAME_RESOURCES_SUFFIXstatic StringFILENAME_RESOURCES_ZIPprotected booleanforceTextEditIf true, show an editor for text files even if they are binary files or very large.protected IEntityListModel<T>modelprotected ResourceContentBeanresourceContentBeanprotected SessionUserManageruserManager-
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 booleancheckResourceNameExist(String name)protected abstract booleancheckResourceNameExist(String name, T itemToExclude)voidcheckResourceUploads(UploadInfo uploadInfo)Before the files are uploaded, this checks for possible conflicts and other decisions the user has to make.voidcleanup()protected abstract TcreateResource(String fileName, byte[] data, String userName)List<FileConflict>getFileConflicts()StringgetGeneratedUrl()abstract StringgetGeneratedUrl(T resource)org.primefaces.model.StreamedContentgetMarkedResources()GeneratesStreamedContentfrom the List of all the marked resources contained within the model.IEntityListModel<T>getModel()protected abstract IEntityListModel<T>getNewModel()EContentTypegetPreviewType()protected org.primefaces.model.StreamedContentgetStreamedContent(List<T> resources, String zipFileName)GeneratesStreamedContentfrom the given List of resources.booleanhasResourceData()booleanisForceTextEdit()booleanisImageResource(T resource)booleanisPreviewResource(T resource)booleanisReaderResource(T resource)booleanisShowImagePreview()booleanisShowPreview()booleanisShowReaderPreview()booleanisShowTextPreview()Deprecated.Use a more specific editor (JS, CSS etc.)booleanisShowTextPreviewBinary()booleanisSourceCodeResource(T resource)booleanisTextPreviewSizeExceeded()booleanisTextResource(T resource)voidonConflictsDialogClose()Resumes the file upload once all file conflicts have been resolved.protected abstract voidopenResourceConflictDialog()protected voidpreCreate(T resource)protected voidpreUpdate(T resource)voidresolveConflicts()Resolves all file conflicts by using the currently selected resolution.voidresolveConflicts(EFileConflictResolution resolution)Resolves all current file conflicts by applying the given resolution to all conflicts.voidsetForceTextEdit(boolean forceTextEdit)voidsetModel(IEntityListModel<T> model)voidupdateModel()protected abstract TupdateResource(String fileName, byte[] data, String userName)voidupload(org.primefaces.event.FileUploadEvent event)Uploads resource to BeanvoiduploadAndPersist(org.primefaces.event.FileUploadEvent event)Uploads a file and persists it as a new resource if possible.-
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, 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, addMsgs, addMsgToComponent, addMsgToComponent, addWarnMsg, addWarnMsg, addWarnMsg, addWarnMsg, addWarnMsgFromString, addWarnMsgFromString, addWarnMsgToComponent, addWarnMsgToComponent, addWarnMsgToComponent, addWarnMsgToComponent, cleanErrorMsg, errorMsg, errorMsg, getErrorMessage, getNewErrorMsg, getNewErrorMsg, getNewErrorMsg, getNewInfoMsg, getNewInfoMsg, getNewMsg, getNewWarnMsg, getNewWarnMsg, msg
-
Methods inherited from class de.xima.fc.gui.common.utils.msg.I18nUtils
getFacesContext, getLocale, rbValue, rbValue, rbValue, rbValueOrDefault, rbValueOrDefault
-
-
-
-
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
-
userManager
@Inject protected SessionUserManager userManager
-
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
-
-
Method Detail
-
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()
GeneratesStreamedContentfrom the List of all the marked resources contained within the model. If this list contains only a single entry theStreamedContentfor this resource will be returned. If the list contains more than one entry the resources will be packed into a zip file and the generatedStreamedContentof the zip file will be returned.- Returns:
- the
StreamedContentof all the marked model resources
-
upload
public void upload(org.primefaces.event.FileUploadEvent event)
Uploads resource to Bean- Parameters:
event-FileUploadEventcontaining the resource
-
uploadAndPersist
public void uploadAndPersist(org.primefaces.event.FileUploadEvent event)
Uploads a file and persists it as a new resource if possible. If conflicts arise, a dialog will be shown for resolving the conflicts.- Parameters:
event-FileUploadEventcontaining the new resource
-
getStreamedContent
protected org.primefaces.model.StreamedContent getStreamedContent(List<T> resources, String zipFileName)
GeneratesStreamedContentfrom the given List of resources. If this list contains only a single entry theStreamedContentfor 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 generatedStreamedContentof the zip file will be returned.
-
preCreate
protected void preCreate(T resource)
-
preUpdate
protected void preUpdate(T resource)
-
getNewModel
protected abstract IEntityListModel<T> getNewModel()
-
checkResourceNameExist
protected abstract boolean checkResourceNameExist(String name)
-
checkResourceNameExist
protected abstract boolean checkResourceNameExist(String name, T itemToExclude)
-
openResourceConflictDialog
protected abstract void openResourceConflictDialog()
-
cleanup
@PreDestroy public void cleanup()
-
getGeneratedUrl
public String getGeneratedUrl()
-
-