Interface UploadHook

All Superinterfaces:
Public
All Known Subinterfaces:
ExifUploadHook

public interface UploadHook extends Public
Media upload hook hot spot interface of FirstSpirit. Used to modify the current input-stream or extract some data.

This hook methods MUST BE EXECUTED SYNCHRONOUS at a time. Means if this hook does some concurrent execution inside the hook methods preProcess(de.espirit.firstspirit.access.BaseContext, de.espirit.firstspirit.access.store.mediastore.Media, de.espirit.firstspirit.access.store.mediastore.File, java.io.InputStream, long) or preProcess(de.espirit.firstspirit.access.BaseContext, de.espirit.firstspirit.access.store.mediastore.Media, de.espirit.firstspirit.access.store.mediastore.Picture, de.espirit.firstspirit.access.project.Resolution, java.io.InputStream, long) and postProcess(de.espirit.firstspirit.access.BaseContext, de.espirit.firstspirit.access.store.mediastore.Media, de.espirit.firstspirit.access.store.mediastore.Picture, long) or postProcess(de.espirit.firstspirit.access.BaseContext, de.espirit.firstspirit.access.store.mediastore.Media, de.espirit.firstspirit.access.store.mediastore.File, long) the hook is responsible for blocking the current thread until the concurrent execution is finished.

NOTE: this hook is only called if a Media is currently holding a lock.

IMPORTANT: All UploadHook methods are called with privileged access. Meaning a hook runs with ALL permissions. If any user permission evaluation is necessary the hook implementation its self is responsible to do that.
The User can be obtained by:

     baseContext.requestSpecialist(UserAgent.TYPE).getUser()
 
Get the element permissions:
     StoreElement.getPermission()
     StoreElement.getPermission(de.espirit.firstspirit.access.User)
     StoreElement.getPermission()
     StoreElement.getPermission(de.espirit.firstspirit.access.User)
     StoreElement.getPermission()
     StoreElement.getPermission(de.espirit.firstspirit.access.User)
 
Since:
5.0
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    postProcess(@NotNull BaseContext baseContext, @NotNull Media media, @NotNull File file, long length)
    Hook method will be called on media upload AFTER the uploaded file is transmitted into the FirstSpirit-Server-Repository.
    void
    postProcess(@NotNull BaseContext baseContext, @NotNull Media media, @NotNull Picture picture, long length)
    Hook method will be called on media upload AFTER the uploaded file is transmitted into the FirstSpirit-Server-Repository.
    void
    preProcess(@NotNull BaseContext baseContext, @NotNull Media media, @NotNull File file, @NotNull InputStream inputStream, long length)
    Hook method will be called on media upload BEFORE the uploaded file will be transmitted to the FirstSpirit-Server-Repository.
    void
    preProcess(@NotNull BaseContext baseContext, @NotNull Media media, @NotNull Picture picture, Resolution resolution, @NotNull InputStream inputStream, long length)
    Hook method will be called on media upload BEFORE the uploaded file will be transmitted to the FirstSpirit-Server-Repository.
    void
    uploadAborted(@NotNull BaseContext baseContext, @NotNull Media media, @NotNull MediaElement mediaElement)
    This method will be called if an upload has been rejected by any upload-hook instance and this hook has been already executed.
  • Method Details

    • preProcess

      void preProcess(@NotNull @NotNull BaseContext baseContext, @NotNull @NotNull Media media, @NotNull @NotNull File file, @NotNull @NotNull InputStream inputStream, long length) throws UploadRejectedException, IOException
      Hook method will be called on media upload BEFORE the uploaded file will be transmitted to the FirstSpirit-Server-Repository. If the media should be rejected for upload and as a consequence the save in the repository should be be completely rejected a UploadRejectedException must be thrown.

      NOTE:

      This hook methods MUST BE EXECUTED SYNCHRONOUS at a time. Means if this method performs concurrent execution, the method is responsible for blocking the current thread until the concurrent execution is finished. This methods is only called if a Media is currently holding a lock.

      IMPORTANT: All UploadHook methods are called with privileged access. Meaning a hook runs with ALL permissions. If any user permission evaluation is necessary the hook implementation its self is responsible to do that.

      Parameters:
      baseContext - a simple context used for firstspirit hotspots
      media - the current media value holder
      file - the current media file
      inputStream - the data input-stream
      length - the content length
      Throws:
      IOException - on error
      UploadRejectedException - on media rejection
      Since:
      5.0
    • preProcess

      void preProcess(@NotNull @NotNull BaseContext baseContext, @NotNull @NotNull Media media, @NotNull @NotNull Picture picture, Resolution resolution, @NotNull @NotNull InputStream inputStream, long length) throws UploadRejectedException, IOException
      Hook method will be called on media upload BEFORE the uploaded file will be transmitted to the FirstSpirit-Server-Repository. If the media should be rejected for upload and as a consequence the save in the repository should be be completely rejected a UploadRejectedException must be thrown.

      NOTE:

      This hook methods MUST BE EXECUTED SYNCHRONOUS at a time. Means if this method performs concurrent execution, the method is responsible for blocking the current thread until the concurrent execution is finished. This methods is only called if a Media is currently holding a lock.

      IMPORTANT: All UploadHook methods are called with privileged access. Meaning a hook runs with ALL permissions. If any user permission evaluation is necessary the hook implementation its self is responsible to do that.

      Parameters:
      baseContext - a simple context used for firstspirit hotspots
      media - the current media value holder
      picture - the current media picture
      resolution - the current uploaded resolution
      inputStream - the data input-stream
      length - the content length
      Throws:
      IOException - on error
      UploadRejectedException - on media rejection
      Since:
      5.0
    • postProcess

      void postProcess(@NotNull @NotNull BaseContext baseContext, @NotNull @NotNull Media media, @NotNull @NotNull File file, long length)
      Hook method will be called on media upload AFTER the uploaded file is transmitted into the FirstSpirit-Server-Repository. All saving operations are done by FirstSpirit. So there's no need to explicit save the media.

      NOTE:

      This hook method MUST BE EXECUTED SYNCHRONOUS at a time. Means if this method performs concurrent execution, the method is responsible for blocking the current thread until the concurrent execution is finished. This methods is only called if a Media is currently holding a lock.

      IMPORTANT: All UploadHook methods are called with privileged access. Meaning a hook runs with ALL permissions. If any user permission evaluation is necessary the hook implementation its self is responsible to do that.

      Parameters:
      baseContext - a simple context used for firstspirit hotspots
      media - the current media value holder
      file - the current media file
      length - the content length
      Since:
      5.0
    • postProcess

      void postProcess(@NotNull @NotNull BaseContext baseContext, @NotNull @NotNull Media media, @NotNull @NotNull Picture picture, long length)
      Hook method will be called on media upload AFTER the uploaded file is transmitted into the FirstSpirit-Server-Repository. All saving operations are done by FirstSpirit. So there's no need to explicit save the media.

      NOTE:

      This hook method MUST BE EXECUTED SYNCHRONOUS at a time. Means if this method performs concurrent execution, the method is responsible for blocking the current thread until the concurrent execution is finished. This methods is only called if a Media is currently holding a lock.

      IMPORTANT: All UploadHook methods are called with privileged access. Meaning a hook runs with ALL permissions. If any user permission evaluation is necessary the hook implementation its self is responsible to do that.

      Parameters:
      baseContext - a simple context used for firstspirit hotspots
      media - the current media value holder
      picture - the current media picture
      length - the content length
      Since:
      5.0
    • uploadAborted

      void uploadAborted(@NotNull @NotNull BaseContext baseContext, @NotNull @NotNull Media media, @NotNull @NotNull MediaElement mediaElement)
      This method will be called if an upload has been rejected by any upload-hook instance and this hook has been already executed. Mainly used to perform some cleanup (remove data, dispose resource ...),.

      NOTE:

      This hook method MUST BE EXECUTED SYNCHRONOUS at a time. Means if this method does some concurrent execution, the method is responsible for blocking the current thread until the concurrent execution is finished. This methods is only called if a Media is currently holding a lock.

      IMPORTANT: All UploadHook methods are called with privileged access. Meaning a hook runs with ALL permissions. If any user permission evaluation is necessary the hook implementation its self is responsible to do that.

      Parameters:
      baseContext - a simple context used for firstspirit hotspots
      media - the current media value holder
      mediaElement - the current media element of type File or Picture
      Since:
      5.0