public class AssetRepository<T extends Identifiable & Assetable> extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
COMPONENT_ID_REQUIRED |
| Constructor and Description |
|---|
AssetRepository(Repository<T> repository,
BeanValidator validator) |
| Modifier and Type | Method and Description |
|---|---|
void |
delete(Asset asset)
Remove an asset
|
List<Asset> |
findAssetInPath(T component,
AssetType type,
Path directory)
Return the list of assets found in a repository
|
List<Asset> |
findAssetInPathWhithoutComponentId(T component,
AssetType type,
Path directory)
refreshAssets(T) need to not set componentId for asset otherwise it makes page creation failing
AssetImporter need it
// TODO : to be refactored
|
Path |
findAssetPath(String componentId,
String filename,
AssetType assetType)
Return the asset path used by a component
|
byte[] |
readAllBytes(Asset asset)
Read resource content
|
byte[] |
readAllBytes(String componentId,
Asset asset)
Read resource content
|
void |
refreshAssets(T component) |
protected Path |
resolveAssetPath(Asset asset) |
protected Path |
resolveAssetPath(String componentId,
Asset asset) |
protected Path |
resolveComponentPath(String componentId) |
protected Path |
resolveExistingAssetPath(Asset asset) |
protected Path |
resolveExistingAssetPath(String componentId,
Asset asset) |
void |
save(Asset asset,
byte[] content)
Add a file asset to a component
|
void |
save(String componentId,
Asset asset,
byte[] content)
Add a file asset to a component
|
public static final String COMPONENT_ID_REQUIRED
@Inject public AssetRepository(Repository<T> repository, BeanValidator validator)
public void save(Asset asset, byte[] content) throws IOException
IOExceptionpublic void save(String componentId, Asset asset, byte[] content) throws IOException
IOExceptionpublic void delete(Asset asset) throws IOException
IOExceptionpublic byte[] readAllBytes(Asset asset) throws IOException
IOExceptionpublic byte[] readAllBytes(String componentId, Asset asset) throws IOException
IOExceptionpublic Path findAssetPath(String componentId, String filename, AssetType assetType) throws IOException
NotFoundException - when component not existsIOExceptionpublic List<Asset> findAssetInPath(T component, AssetType type, Path directory) throws IOException
IOExceptionpublic List<Asset> findAssetInPathWhithoutComponentId(T component, AssetType type, Path directory) throws IOException
IOExceptionpublic void refreshAssets(T component)
Copyright © 2021. All rights reserved.