Class PageOperationsInterceptor

  • All Implemented Interfaces:
    org.springframework.web.servlet.AsyncHandlerInterceptor, org.springframework.web.servlet.HandlerInterceptor

    public class PageOperationsInterceptor
    extends org.springframework.web.servlet.handler.HandlerInterceptorAdapter
    Default interceptor to run before controllers' execution to extract the catalogId and sourceCatalogVersion and targetCatalogVersion from the request URI to determine if the current user has required sync permissions.
    • Constructor Detail

      • PageOperationsInterceptor

        public PageOperationsInterceptor()
    • Method Detail

      • preHandle

        public boolean preHandle​(javax.servlet.http.HttpServletRequest request,
                                 javax.servlet.http.HttpServletResponse response,
                                 java.lang.Object handler)
                          throws java.lang.Exception
        Determines if the current user has permissions to sync from source catalog version to target catalog version. In the case that the user does not have permission, we return an error in the HTTP response using the status code 403 - Forbidden.
        Specified by:
        preHandle in interface org.springframework.web.servlet.HandlerInterceptor
        Overrides:
        preHandle in class org.springframework.web.servlet.handler.HandlerInterceptorAdapter
        Throws:
        java.lang.Exception -
      • getSyncItemJob

        protected java.util.Optional<SyncItemJobModel> getSyncItemJob​(java.lang.String catalogId,
                                                                      java.lang.String sourceCatalgVersion,
                                                                      java.lang.String targetCatalogVersion)
        Returns first active synchronization job from source catalog.
        Parameters:
        catalogId - the catalog name
        sourceCatalgVersion - the source catalog version name
        targetCatalgVersion - the target catalog version name
        Returns:
        Optional synchronization job
      • getCatalogVersionModel

        protected CatalogVersionModel getCatalogVersionModel​(java.lang.String catalog,
                                                             java.lang.String catalogVersion)
        Gets the catalogVersionModel
        Parameters:
        catalog - the catalog name
        catalogVersion - the catalog version name
        Returns:
        the catalogVersionModel
      • setCatalogVersionService

        public void setCatalogVersionService​(CatalogVersionService catalogVersionService)
      • getUserService

        protected UserService getUserService()
      • setUserService

        public void setUserService​(UserService userService)
      • setCatalogSynchronizationService

        public void setCatalogSynchronizationService​(CatalogSynchronizationService catalogSynchronizationService)