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 SessionUserManager
userManager
-
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)
protected abstract boolean
checkResourceNameExist(String name, T itemToExclude)
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 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()
protected org.primefaces.model.StreamedContent
getStreamedContent(List<T> resources, String zipFileName)
GeneratesStreamedContent
from the given List of resources.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
preCreate(T resource)
protected void
preUpdate(T resource)
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
updateModel()
protected abstract T
updateResource(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 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
-
-
-
-
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()
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 if possible. If conflicts arise, a dialog will be shown for resolving the conflicts.- 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.
-
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()
-
-