Class AddOrUpdateResourceHelper
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.explorer.resources.actions.AddOrUpdateResourceHelper
-
- All Implemented Interfaces:
LogEnabled
,Component
,Serviceable
public final class AddOrUpdateResourceHelper extends AbstractLogEnabled implements Component, Serviceable
Dedicated helper in order to add or update an explorer resource
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AddOrUpdateResourceHelper.ResourceOperationMode
Possible add and update modesstatic class
AddOrUpdateResourceHelper.ResourceOperationResult
Class representing the result of a resource operation.
-
Field Summary
Fields Modifier and Type Field Description protected CurrentUserProvider
_currentUserProvider
The current user provider.protected ObservationManager
_observationManager
Observer manager.protected AmetysObjectResolver
_resolver
The ametys resolverprotected ExplorerResourcesDAO
_resourcesDAO
The resource DAOstatic String
ROLE
The Avalon role name
-
Constructor Summary
Constructors Constructor Description AddOrUpdateResourceHelper()
-
Method Summary
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_resourcesDAO
protected ExplorerResourcesDAO _resourcesDAO
The resource DAO
-
_resolver
protected AmetysObjectResolver _resolver
The ametys resolver
-
_currentUserProvider
protected CurrentUserProvider _currentUserProvider
The current user provider.
-
_observationManager
protected ObservationManager _observationManager
Observer manager.
-
-
Constructor Detail
-
AddOrUpdateResourceHelper
public AddOrUpdateResourceHelper()
-
-
Method Detail
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
performResourceOperation
public AddOrUpdateResourceHelper.ResourceOperationResult performResourceOperation(Part part, String parentId, AddOrUpdateResourceHelper.ResourceOperationMode mode)
Perform an add or update resource operation- Parameters:
part
- The part representing the file for this operationparentId
- The identifier of the parent collectionmode
- The operation mode- Returns:
- the result of the operation
-
performResourceOperation
public AddOrUpdateResourceHelper.ResourceOperationResult performResourceOperation(Part part, ModifiableResourceCollection parent, AddOrUpdateResourceHelper.ResourceOperationMode mode)
Perform an add or update resource operation- Parameters:
part
- The part representing the file for this operationparent
- The parent collectionmode
- The operation mode- Returns:
- the result of the operation
-
performResourceOperation
public AddOrUpdateResourceHelper.ResourceOperationResult performResourceOperation(File file, ModifiableResourceCollection parent, AddOrUpdateResourceHelper.ResourceOperationMode mode)
Perform an add or update resource operation- Parameters:
file
- The file for this operationparent
- The parent collectionmode
- The operation mode- Returns:
- the result of the operation
-
performResourceOperation
public AddOrUpdateResourceHelper.ResourceOperationResult performResourceOperation(InputStream inputStream, String fileName, ModifiableResourceCollection parent, AddOrUpdateResourceHelper.ResourceOperationMode mode)
Perform an add or update resource operation- Parameters:
inputStream
- The data for this operationfileName
- file name requestedparent
- The parent collectionmode
- The operation mode- Returns:
- the result of the operation
-
_notifyResourcesCreated
protected void _notifyResourcesCreated(ModifiableResourceCollection parent, List<Resource> resources)
Fire theObservationConstants.EVENT_RESOURCE_CREATED
event- Parameters:
parent
- The parent collection of the resourceresources
- The created resources
-
_notifyResourcesUpdated
protected void _notifyResourcesUpdated(ModifiableResourceCollection parent, Resource resource)
Fire theObservationConstants.EVENT_RESOURCE_UPDATED
event- Parameters:
parent
- The parent collection of the resourceresource
- The updated resource
-
_unzip
private AddOrUpdateResourceHelper.ResourceOperationResult _unzip(ModifiableResourceCollection collection, File file)
Unzip a file- Parameters:
collection
- The collection where to unzipfile
- The zip file- Returns:
- messages
-
_unzip
private List<Resource> _unzip(ModifiableResourceCollection collection, ZipFile zipFile) throws IOException
- Throws:
IOException
-
_addCollection
private ModifiableResourceCollection _addCollection(ModifiableResourceCollection collection, String name)
-
_addZipEntry
private Resource _addZipEntry(ModifiableResourceCollection collection, ZipFile zipFile, ZipArchiveEntry zipEntry, String fileName) throws IOException
- Throws:
IOException
-
-