Package org.ametys.cms.data
Class ContentDataHelper
- java.lang.Object
-
- org.ametys.cms.data.ContentDataHelper
-
public final class ContentDataHelper extends Object
Helper for data of type 'content'
-
-
Constructor Summary
Constructors Modifier Constructor Description private
ContentDataHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
getContentIdFromContentData(ModelAwareDataHolder dataHolder, String dataPath)
Retrieves the content identifier of a content datastatic String
getContentIdFromContentData(ModelAwareDataHolder dataHolder, String dataPath, String defaultValue)
Retrieves the content identifier of a content datastatic String[]
getContentIdsArrayFromMultipleContentData(ModelAwareDataHolder dataHolder, String dataPath)
Retrieves the content identifiers in an array from a multiple content datastatic List<String>
getContentIdsListFromMultipleContentData(ModelAwareDataHolder dataHolder, String dataPath)
Retrieves the content identifiers in aList
from a multiple content datastatic Stream<String>
getContentIdsStreamFromMultipleContentData(ModelAwareDataHolder dataHolder, String dataPath)
Retrieves aStream
of the content identifiers from a multiple content datastatic boolean
isMultipleContentDataEmpty(ModelAwareDataHolder dataHolder, String dataPath)
Retrieves the content identifiers in an array from a multiple content data
-
-
-
Constructor Detail
-
ContentDataHelper
private ContentDataHelper()
-
-
Method Detail
-
getContentIdFromContentData
public static String getContentIdFromContentData(ModelAwareDataHolder dataHolder, String dataPath, String defaultValue) throws BadItemTypeException
Retrieves the content identifier of a content data- Parameters:
dataHolder
- data holder that contains the content datadataPath
- path to the content datadefaultValue
- The default value to return- Returns:
- the content identifier
- Throws:
BadItemTypeException
- if the data at the given path is not a content data
-
getContentIdFromContentData
public static String getContentIdFromContentData(ModelAwareDataHolder dataHolder, String dataPath) throws BadItemTypeException
Retrieves the content identifier of a content data- Parameters:
dataHolder
- data holder that contains the content datadataPath
- path to the content data- Returns:
- the content identifier, empty string if it is invalid
- Throws:
BadItemTypeException
- if the data at the given path is not a content data
-
isMultipleContentDataEmpty
public static boolean isMultipleContentDataEmpty(ModelAwareDataHolder dataHolder, String dataPath) throws BadItemTypeException
Retrieves the content identifiers in an array from a multiple content data- Parameters:
dataHolder
- data holder that contains the multiple content datadataPath
- path to the multiple content data- Returns:
- an array containing the content identifiers
- Throws:
BadItemTypeException
- if the data at the given path is not a content data
-
getContentIdsListFromMultipleContentData
public static List<String> getContentIdsListFromMultipleContentData(ModelAwareDataHolder dataHolder, String dataPath) throws BadItemTypeException
Retrieves the content identifiers in aList
from a multiple content data- Parameters:
dataHolder
- data holder that contains the multiple content datadataPath
- path to the multiple content data- Returns:
- a
List
containing the content identifiers - Throws:
BadItemTypeException
- if the data at the given path is not a content data
-
getContentIdsArrayFromMultipleContentData
public static String[] getContentIdsArrayFromMultipleContentData(ModelAwareDataHolder dataHolder, String dataPath) throws BadItemTypeException
Retrieves the content identifiers in an array from a multiple content data- Parameters:
dataHolder
- data holder that contains the multiple content datadataPath
- path to the multiple content data- Returns:
- an array containing the content identifiers
- Throws:
BadItemTypeException
- if the data at the given path is not a content data
-
getContentIdsStreamFromMultipleContentData
public static Stream<String> getContentIdsStreamFromMultipleContentData(ModelAwareDataHolder dataHolder, String dataPath) throws BadItemTypeException
Retrieves aStream
of the content identifiers from a multiple content data- Parameters:
dataHolder
- data holder that contains the multiple content datadataPath
- path to the multiple content data- Returns:
- a
Stream
of the content identifiers - Throws:
BadItemTypeException
- if the data at the given path is not a content data
-
-