Package org.apache.ofbiz.content.data
Class DataResourceWorker
- java.lang.Object
-
- org.apache.ofbiz.content.data.DataResourceWorker
-
- All Implemented Interfaces:
DataResourceWorkerInterface
public class DataResourceWorker extends java.lang.Object implements DataResourceWorkerInterface
DataResourceWorker Class
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
err_resource
static java.lang.String
module
-
Constructor Summary
Constructors Constructor Description DataResourceWorker()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static byte[]
acquireImage(Delegator delegator, java.lang.String dataResourceId)
Gets image data from ImageDataResource and returns it as a byte array.static byte[]
acquireImage(Delegator delegator, GenericValue dataResource)
static void
buildList(java.util.Map<java.lang.String,java.lang.Object> nd, java.util.List<java.util.Map<java.lang.String,java.lang.Object>> lst, int depth)
Takes a DataCategory structure and builds a list of maps, one value (id) is the dataCategoryId value and the other is an indented string suitable for use in a drop-down pick list.static java.lang.String
buildRequestPrefix(Delegator delegator, java.util.Locale locale, java.lang.String webSiteId, java.lang.String https)
static java.lang.String
callDataResourcePermissionCheck(Delegator delegator, LocalDispatcher dispatcher, java.util.Map<java.lang.String,java.lang.Object> context)
callDataResourcePermissionCheck Formats data for a call to the checkContentPermission service.static java.util.Map<java.lang.String,java.lang.Object>
callDataResourcePermissionCheckResult(Delegator delegator, LocalDispatcher dispatcher, java.util.Map<java.lang.String,java.lang.Object> context)
callDataResourcePermissionCheck Formats data for a call to the checkContentPermission service.static void
clearAssociatedRenderCache(Delegator delegator, java.lang.String dataResourceId)
static java.nio.ByteBuffer
getContentAsByteBuffer(Delegator delegator, java.lang.String dataResourceId, java.lang.String https, java.lang.String webSiteId, java.util.Locale locale, java.lang.String rootDir)
static java.io.File
getContentFile(java.lang.String dataResourceTypeId, java.lang.String objectInfo, java.lang.String contextRoot)
static void
getDataCategoryAncestry(Delegator delegator, java.lang.String dataCategoryId, java.util.List<java.lang.String> categoryTypeIds)
Finds the parents of DataCategory entity and puts them in a list, the start entity at the top.static java.lang.String
getDataCategoryMap(Delegator delegator, int depth, java.util.Map<java.lang.String,java.lang.Object> categoryNode, java.util.List<java.lang.String> categoryTypeIds, boolean getAll)
Traverses the DataCategory parent/child structure and put it in categoryNode.static java.lang.String
getDataResourceContentUploadPath()
static java.lang.String
getDataResourceContentUploadPath(boolean absolute)
static java.lang.String
getDataResourceContentUploadPath(java.lang.String initialPath, double maxFiles)
static java.lang.String
getDataResourceContentUploadPath(java.lang.String initialPath, double maxFiles, boolean absolute)
Handles creating sub-directories for file storage; using a max number of files per directorystatic java.lang.String
getDataResourceContentUploadPath(Delegator delegator, boolean absolute)
static java.lang.String
getDataResourceMimeType(Delegator delegator, java.lang.String dataResourceId, GenericValue view)
static java.util.Map<java.lang.String,java.lang.Object>
getDataResourceStream(GenericValue dataResource, java.lang.String https, java.lang.String webSiteId, java.util.Locale locale, java.lang.String contextRoot, boolean cache)
getDataResourceStream - gets an InputStream and Content-Length of a DataResourcestatic java.lang.String
getDataResourceText(GenericValue dataResource, java.lang.String mimeTypeId, java.util.Locale locale, java.util.Map<java.lang.String,java.lang.Object> context, Delegator delegator, boolean cache)
static java.lang.String
getMimeType(GenericValue dataResource)
static java.lang.String
getMimeTypeFromImageFileName(java.lang.String imageFileName)
static java.lang.String
getMimeTypeWithByteBuffer(java.nio.ByteBuffer buffer)
static java.lang.String
renderDataResourceAsText(LocalDispatcher dispatcher, java.lang.String dataResourceId, java.lang.Appendable out, java.util.Map<java.lang.String,java.lang.Object> templateContext, java.util.Locale locale, java.lang.String targetMimeTypeId, boolean cache)
static void
renderDataResourceAsText(LocalDispatcher dispatcher, Delegator delegator, java.lang.String dataResourceId, java.lang.Appendable out, java.util.Map<java.lang.String,java.lang.Object> templateContext, java.util.Locale locale, java.lang.String targetMimeTypeId, boolean cache, java.util.List<GenericValue> webAnalytics)
static java.lang.String
renderDataResourceAsText(LocalDispatcher dispatcher, Delegator delegator, java.lang.String dataResourceId, java.util.Map<java.lang.String,java.lang.Object> templateContext, java.util.Locale locale, java.lang.String targetMimeTypeId, boolean cache)
java.lang.String
renderDataResourceAsTextExt(Delegator delegator, java.lang.String dataResourceId, java.util.Map<java.lang.String,java.lang.Object> templateContext, java.util.Locale locale, java.lang.String targetMimeTypeId, boolean cache)
static void
renderFile(java.lang.String dataResourceTypeId, java.lang.String objectInfo, java.lang.String rootDir, java.lang.Appendable out)
static java.lang.String
renderMimeTypeTemplate(GenericValue mimeTypeTemplate, java.util.Map<java.lang.String,java.lang.Object> context)
static java.lang.String
uploadAndStoreImage(javax.servlet.http.HttpServletRequest request, java.lang.String idField, java.lang.String uploadField)
Uploads image data from a form and stores it in ImageDataResource.static void
writeDataResourceText(GenericValue dataResource, java.lang.String mimeTypeId, java.util.Locale locale, java.util.Map<java.lang.String,java.lang.Object> templateContext, Delegator delegator, java.lang.Appendable out, boolean cache)
static void
writeText(GenericValue dataResource, java.lang.String textData, java.util.Map<java.lang.String,java.lang.Object> context, java.lang.String targetMimeTypeId, java.util.Locale locale, java.lang.Appendable out)
-
-
-
Field Detail
-
module
public static final java.lang.String module
-
err_resource
public static final java.lang.String err_resource
- See Also:
- Constant Field Values
-
-
Method Detail
-
getDataCategoryMap
public static java.lang.String getDataCategoryMap(Delegator delegator, int depth, java.util.Map<java.lang.String,java.lang.Object> categoryNode, java.util.List<java.lang.String> categoryTypeIds, boolean getAll) throws GenericEntityException
Traverses the DataCategory parent/child structure and put it in categoryNode. Returns non-null error string if there is an error.- Parameters:
depth
- The place on the categoryTypesIds to start collecting.getAll
- Indicates that all descendants are to be gotten. Used as "true" to populate an indented select list.- Throws:
GenericEntityException
-
getDataCategoryAncestry
public static void getDataCategoryAncestry(Delegator delegator, java.lang.String dataCategoryId, java.util.List<java.lang.String> categoryTypeIds) throws GenericEntityException
Finds the parents of DataCategory entity and puts them in a list, the start entity at the top.- Throws:
GenericEntityException
-
buildList
public static void buildList(java.util.Map<java.lang.String,java.lang.Object> nd, java.util.List<java.util.Map<java.lang.String,java.lang.Object>> lst, int depth)
Takes a DataCategory structure and builds a list of maps, one value (id) is the dataCategoryId value and the other is an indented string suitable for use in a drop-down pick list.
-
uploadAndStoreImage
public static java.lang.String uploadAndStoreImage(javax.servlet.http.HttpServletRequest request, java.lang.String idField, java.lang.String uploadField)
Uploads image data from a form and stores it in ImageDataResource. Expects key data in a field identified by the "idField" value and the binary data to be in a field id'd by uploadField.
-
getMimeTypeFromImageFileName
public static java.lang.String getMimeTypeFromImageFileName(java.lang.String imageFileName)
-
callDataResourcePermissionCheck
public static java.lang.String callDataResourcePermissionCheck(Delegator delegator, LocalDispatcher dispatcher, java.util.Map<java.lang.String,java.lang.Object> context)
callDataResourcePermissionCheck Formats data for a call to the checkContentPermission service.
-
callDataResourcePermissionCheckResult
public static java.util.Map<java.lang.String,java.lang.Object> callDataResourcePermissionCheckResult(Delegator delegator, LocalDispatcher dispatcher, java.util.Map<java.lang.String,java.lang.Object> context)
callDataResourcePermissionCheck Formats data for a call to the checkContentPermission service.
-
acquireImage
public static byte[] acquireImage(Delegator delegator, java.lang.String dataResourceId) throws GenericEntityException
Gets image data from ImageDataResource and returns it as a byte array.- Throws:
GenericEntityException
-
acquireImage
public static byte[] acquireImage(Delegator delegator, GenericValue dataResource) throws GenericEntityException
- Throws:
GenericEntityException
-
getMimeType
public static java.lang.String getMimeType(GenericValue dataResource)
-
getMimeTypeWithByteBuffer
public static java.lang.String getMimeTypeWithByteBuffer(java.nio.ByteBuffer buffer) throws java.io.IOException
- Throws:
java.io.IOException
-
buildRequestPrefix
public static java.lang.String buildRequestPrefix(Delegator delegator, java.util.Locale locale, java.lang.String webSiteId, java.lang.String https)
-
getContentFile
public static java.io.File getContentFile(java.lang.String dataResourceTypeId, java.lang.String objectInfo, java.lang.String contextRoot) throws GeneralException, java.io.FileNotFoundException
- Throws:
GeneralException
java.io.FileNotFoundException
-
getDataResourceMimeType
public static java.lang.String getDataResourceMimeType(Delegator delegator, java.lang.String dataResourceId, GenericValue view) throws GenericEntityException
- Throws:
GenericEntityException
-
getDataResourceContentUploadPath
public static java.lang.String getDataResourceContentUploadPath()
-
getDataResourceContentUploadPath
public static java.lang.String getDataResourceContentUploadPath(boolean absolute)
-
getDataResourceContentUploadPath
public static java.lang.String getDataResourceContentUploadPath(Delegator delegator, boolean absolute)
-
getDataResourceContentUploadPath
public static java.lang.String getDataResourceContentUploadPath(java.lang.String initialPath, double maxFiles)
-
getDataResourceContentUploadPath
public static java.lang.String getDataResourceContentUploadPath(java.lang.String initialPath, double maxFiles, boolean absolute)
Handles creating sub-directories for file storage; using a max number of files per directory- Parameters:
initialPath
- the top level location where all files should be storedmaxFiles
- the max number of files to place in a directory- Returns:
- the absolute path to the directory where the file should be placed
-
clearAssociatedRenderCache
public static void clearAssociatedRenderCache(Delegator delegator, java.lang.String dataResourceId) throws GeneralException
- Throws:
GeneralException
-
renderDataResourceAsText
public static java.lang.String renderDataResourceAsText(LocalDispatcher dispatcher, Delegator delegator, java.lang.String dataResourceId, java.util.Map<java.lang.String,java.lang.Object> templateContext, java.util.Locale locale, java.lang.String targetMimeTypeId, boolean cache) throws GeneralException, java.io.IOException
- Throws:
GeneralException
java.io.IOException
-
renderDataResourceAsText
public static java.lang.String renderDataResourceAsText(LocalDispatcher dispatcher, java.lang.String dataResourceId, java.lang.Appendable out, java.util.Map<java.lang.String,java.lang.Object> templateContext, java.util.Locale locale, java.lang.String targetMimeTypeId, boolean cache) throws GeneralException, java.io.IOException
- Throws:
GeneralException
java.io.IOException
-
renderDataResourceAsText
public static void renderDataResourceAsText(LocalDispatcher dispatcher, Delegator delegator, java.lang.String dataResourceId, java.lang.Appendable out, java.util.Map<java.lang.String,java.lang.Object> templateContext, java.util.Locale locale, java.lang.String targetMimeTypeId, boolean cache, java.util.List<GenericValue> webAnalytics) throws GeneralException, java.io.IOException
- Throws:
GeneralException
java.io.IOException
-
getDataResourceText
public static java.lang.String getDataResourceText(GenericValue dataResource, java.lang.String mimeTypeId, java.util.Locale locale, java.util.Map<java.lang.String,java.lang.Object> context, Delegator delegator, boolean cache) throws java.io.IOException, GeneralException
- Throws:
java.io.IOException
GeneralException
-
writeDataResourceText
public static void writeDataResourceText(GenericValue dataResource, java.lang.String mimeTypeId, java.util.Locale locale, java.util.Map<java.lang.String,java.lang.Object> templateContext, Delegator delegator, java.lang.Appendable out, boolean cache) throws java.io.IOException, GeneralException
- Throws:
java.io.IOException
GeneralException
-
writeText
public static void writeText(GenericValue dataResource, java.lang.String textData, java.util.Map<java.lang.String,java.lang.Object> context, java.lang.String targetMimeTypeId, java.util.Locale locale, java.lang.Appendable out) throws GeneralException, java.io.IOException
- Throws:
GeneralException
java.io.IOException
-
renderMimeTypeTemplate
public static java.lang.String renderMimeTypeTemplate(GenericValue mimeTypeTemplate, java.util.Map<java.lang.String,java.lang.Object> context) throws GeneralException, java.io.IOException
- Throws:
GeneralException
java.io.IOException
-
renderFile
public static void renderFile(java.lang.String dataResourceTypeId, java.lang.String objectInfo, java.lang.String rootDir, java.lang.Appendable out) throws GeneralException, java.io.IOException
- Throws:
GeneralException
java.io.IOException
-
getDataResourceStream
public static java.util.Map<java.lang.String,java.lang.Object> getDataResourceStream(GenericValue dataResource, java.lang.String https, java.lang.String webSiteId, java.util.Locale locale, java.lang.String contextRoot, boolean cache) throws java.io.IOException, GeneralException
getDataResourceStream - gets an InputStream and Content-Length of a DataResource- Parameters:
dataResource
-https
-webSiteId
-locale
-contextRoot
-- Returns:
- Map containing 'stream': the InputStream and 'length' a Long containing the content-length
- Throws:
java.io.IOException
GeneralException
-
getContentAsByteBuffer
public static java.nio.ByteBuffer getContentAsByteBuffer(Delegator delegator, java.lang.String dataResourceId, java.lang.String https, java.lang.String webSiteId, java.util.Locale locale, java.lang.String rootDir) throws java.io.IOException, GeneralException
- Throws:
java.io.IOException
GeneralException
-
renderDataResourceAsTextExt
public java.lang.String renderDataResourceAsTextExt(Delegator delegator, java.lang.String dataResourceId, java.util.Map<java.lang.String,java.lang.Object> templateContext, java.util.Locale locale, java.lang.String targetMimeTypeId, boolean cache) throws GeneralException, java.io.IOException
- Specified by:
renderDataResourceAsTextExt
in interfaceDataResourceWorkerInterface
- Throws:
GeneralException
java.io.IOException
-
-