Package org.apache.ofbiz.content.data
Class DataResourceWorker
java.lang.Object
org.apache.ofbiz.content.data.DataResourceWorker
- All Implemented Interfaces:
DataResourceWorkerInterface
DataResourceWorker Class
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
acquireImage
(Delegator delegator, String dataResourceId) Gets image data from ImageDataResource and returns it as a byte array.static byte[]
acquireImage
(Delegator delegator, GenericValue dataResource) static void
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 String
buildRequestPrefix
(Delegator delegator, Locale locale, String webSiteId, String https) static String
callDataResourcePermissionCheck
(Delegator delegator, LocalDispatcher dispatcher, Map<String, Object> context) callDataResourcePermissionCheck Formats data for a call to the checkContentPermission service.callDataResourcePermissionCheckResult
(Delegator delegator, LocalDispatcher dispatcher, Map<String, Object> context) callDataResourcePermissionCheck Formats data for a call to the checkContentPermission service.static void
clearAssociatedRenderCache
(Delegator delegator, String dataResourceId) static ByteBuffer
getContentAsByteBuffer
(Delegator delegator, String dataResourceId, String https, String webSiteId, Locale locale, String rootDir) static File
getContentFile
(String dataResourceTypeId, String objectInfo, String contextRoot) static void
getDataCategoryAncestry
(Delegator delegator, String dataCategoryId, List<String> categoryTypeIds) Finds the parents of DataCategory entity and puts them in a list, the start entity at the top.static String
getDataCategoryMap
(Delegator delegator, int depth, Map<String, Object> categoryNode, List<String> categoryTypeIds, boolean getAll) Traverses the DataCategory parent/child structure and put it in categoryNode.static String
static String
getDataResourceContentUploadPath
(boolean absolute) static String
getDataResourceContentUploadPath
(String initialPath, double maxFiles) static String
getDataResourceContentUploadPath
(String initialPath, double maxFiles, boolean absolute) Handles creating sub-directories for file storage; using a max number of files per directorystatic String
getDataResourceContentUploadPath
(Delegator delegator, boolean absolute) static String
getDataResourceMimeType
(Delegator delegator, String dataResourceId, GenericValue view) getDataResourceStream
(GenericValue dataResource, String https, String webSiteId, Locale locale, String contextRoot, boolean cache) getDataResourceStream - gets an InputStream and Content-Length of a DataResourcestatic String
getDataResourceText
(GenericValue dataResource, String mimeTypeId, Locale locale, Map<String, Object> context, Delegator delegator, boolean cache) static String
getMimeType
(Delegator delegator, String fileName, String defaultMimeTypeId) Gets the MIME-Type from a given filename.static String
getMimeType
(GenericValue dataResource) Gets the MIME-Type from a given data resource, using the default value set in properties as fallback.static String
getMimeType
(GenericValue dataResource, String defaultMimeTypeId) Gets the MIME-Type from a given data resource.static String
getMimeTypeFromImageFileName
(String imageFileName) static String
getMimeTypeWithByteBuffer
(ByteBuffer buffer) static String
renderDataResourceAsText
(LocalDispatcher dispatcher, String dataResourceId, Appendable out, Map<String, Object> templateContext, Locale locale, String targetMimeTypeId, boolean cache) static void
renderDataResourceAsText
(LocalDispatcher dispatcher, Delegator delegator, String dataResourceId, Appendable out, Map<String, Object> templateContext, Locale locale, String targetMimeTypeId, boolean cache, List<GenericValue> webAnalytics) static String
renderDataResourceAsText
(LocalDispatcher dispatcher, Delegator delegator, String dataResourceId, Map<String, Object> templateContext, Locale locale, String targetMimeTypeId, boolean cache) renderDataResourceAsTextExt
(Delegator delegator, String dataResourceId, Map<String, Object> templateContext, Locale locale, String targetMimeTypeId, boolean cache) static void
renderFile
(String dataResourceTypeId, String objectInfo, String rootDir, Appendable out) static String
renderMimeTypeTemplate
(GenericValue mimeTypeTemplate, Map<String, Object> context) static String
uploadAndStoreImage
(HttpServletRequest request, String idField, String uploadField) Uploads image data from a form and stores it in ImageDataResource.static void
writeDataResourceText
(GenericValue dataResource, String mimeTypeId, Locale locale, Map<String, Object> templateContext, Delegator delegator, Appendable out, boolean cache) static void
writeText
(GenericValue dataResource, String textData, Map<String, Object> context, String targetMimeTypeId, Locale locale, Appendable out)
-
Constructor Details
-
DataResourceWorker
public DataResourceWorker()
-
-
Method Details
-
getDataCategoryMap
public static String getDataCategoryMap(Delegator delegator, int depth, Map<String, Object> categoryNode, List<String> categoryTypeIds, boolean getAll) throws GenericEntityExceptionTraverses 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, String dataCategoryId, List<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
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 String uploadAndStoreImage(HttpServletRequest request, String idField, 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's by uploadField. -
getMimeTypeFromImageFileName
-
callDataResourcePermissionCheck
public static String callDataResourcePermissionCheck(Delegator delegator, LocalDispatcher dispatcher, Map<String, Object> context) callDataResourcePermissionCheck Formats data for a call to the checkContentPermission service. -
callDataResourcePermissionCheckResult
public static Map<String,Object> callDataResourcePermissionCheckResult(Delegator delegator, LocalDispatcher dispatcher, Map<String, Object> context) callDataResourcePermissionCheck Formats data for a call to the checkContentPermission service. -
acquireImage
public static byte[] acquireImage(Delegator delegator, 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
Gets the MIME-Type from a given data resource, using the default value set in properties as fallback.- Parameters:
dataResource
-- Returns:
- MIME-Type
-
getMimeType
Gets the MIME-Type from a given data resource.- Parameters:
dataResource
-defaultMimeTypeId
-- Returns:
- MIME-Type
-
getMimeType
Gets the MIME-Type from a given filename.- Parameters:
delegator
-fileName
-defaultMimeTypeId
-- Returns:
- MIME-Type
-
getMimeTypeWithByteBuffer
- Throws:
IOException
-
buildRequestPrefix
-
getContentFile
public static File getContentFile(String dataResourceTypeId, String objectInfo, String contextRoot) throws GeneralException, FileNotFoundException -
getDataResourceMimeType
public static String getDataResourceMimeType(Delegator delegator, String dataResourceId, GenericValue view) throws GenericEntityException - Throws:
GenericEntityException
-
getDataResourceContentUploadPath
-
getDataResourceContentUploadPath
-
getDataResourceContentUploadPath
-
getDataResourceContentUploadPath
-
getDataResourceContentUploadPath
public static String getDataResourceContentUploadPath(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, String dataResourceId) throws GeneralException - Throws:
GeneralException
-
renderDataResourceAsText
public static String renderDataResourceAsText(LocalDispatcher dispatcher, Delegator delegator, String dataResourceId, Map<String, Object> templateContext, Locale locale, String targetMimeTypeId, boolean cache) throws GeneralException, IOException- Throws:
GeneralException
IOException
-
renderDataResourceAsText
public static String renderDataResourceAsText(LocalDispatcher dispatcher, String dataResourceId, Appendable out, Map<String, Object> templateContext, Locale locale, String targetMimeTypeId, boolean cache) throws GeneralException, IOException- Throws:
GeneralException
IOException
-
renderDataResourceAsText
public static void renderDataResourceAsText(LocalDispatcher dispatcher, Delegator delegator, String dataResourceId, Appendable out, Map<String, Object> templateContext, Locale locale, String targetMimeTypeId, boolean cache, List<GenericValue> webAnalytics) throws GeneralException, IOException- Throws:
GeneralException
IOException
-
getDataResourceText
public static String getDataResourceText(GenericValue dataResource, String mimeTypeId, Locale locale, Map<String, Object> context, Delegator delegator, boolean cache) throws IOException, GeneralException- Throws:
IOException
GeneralException
-
writeDataResourceText
public static void writeDataResourceText(GenericValue dataResource, String mimeTypeId, Locale locale, Map<String, Object> templateContext, Delegator delegator, Appendable out, boolean cache) throws IOException, GeneralException- Throws:
IOException
GeneralException
-
writeText
public static void writeText(GenericValue dataResource, String textData, Map<String, Object> context, String targetMimeTypeId, Locale locale, Appendable out) throws GeneralException, IOException- Throws:
GeneralException
IOException
-
renderMimeTypeTemplate
public static String renderMimeTypeTemplate(GenericValue mimeTypeTemplate, Map<String, Object> context) throws GeneralException, IOException- Throws:
GeneralException
IOException
-
renderFile
public static void renderFile(String dataResourceTypeId, String objectInfo, String rootDir, Appendable out) throws GeneralException, IOException - Throws:
GeneralException
IOException
-
getDataResourceStream
public static Map<String,Object> getDataResourceStream(GenericValue dataResource, String https, String webSiteId, Locale locale, String contextRoot, boolean cache) throws 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:
IOException
GeneralException
-
getContentAsByteBuffer
public static ByteBuffer getContentAsByteBuffer(Delegator delegator, String dataResourceId, String https, String webSiteId, Locale locale, String rootDir) throws IOException, GeneralException - Throws:
IOException
GeneralException
-
renderDataResourceAsTextExt
public String renderDataResourceAsTextExt(Delegator delegator, String dataResourceId, Map<String, Object> templateContext, Locale locale, String targetMimeTypeId, boolean cache) throws GeneralException, IOException- Specified by:
renderDataResourceAsTextExt
in interfaceDataResourceWorkerInterface
- Throws:
GeneralException
IOException
-