Class UrlAliasServiceImpl

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void checkPublication​(de.digitalcollections.model.identifiable.alias.UrlAlias urlAlias)  
      de.digitalcollections.model.identifiable.alias.UrlAlias create​(de.digitalcollections.model.identifiable.alias.UrlAlias urlAlias, boolean force)
      Create an UrlAlias in the database
      boolean delete​(List<UUID> uuids)
      Delete a list of UrlAliases by their UUIDs
      boolean deleteAllForTarget​(UUID uuid, boolean force)
      Delete all UrlAliases targetting the passed UUID except those that have already been published.
      protected de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases filterForLocale​(Locale pLocale, de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases localizedUrlAliases)  
      protected de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases filterForLocaleWithFallback​(Locale pLocale, de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases localizedUrlAliases)  
      de.digitalcollections.model.paging.SearchPageResponse<de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases> find​(de.digitalcollections.model.paging.SearchPageRequest searchPageRequest)
      Find UrlAliases
      de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases findLocalizedUrlAliases​(UUID uuid)
      Returns the LocalizedUrlAliases for an identifiable, identified by its UUID
      de.digitalcollections.model.identifiable.alias.UrlAlias findOne​(UUID uuid)
      Retrieve one UrlAlias by its UUID
      de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases findPrimaryLinks​(UUID websiteUuid, String slug, Locale pLocale)
      Returns the primary Links (one per language) as LocalizedUrlAliases for a given slug for a given website (identified by its uuid).
      List<de.digitalcollections.model.identifiable.alias.UrlAlias> findPrimaryLinksForTarget​(UUID targetUuid)
      Returns all primary links of the passed target identifiable.
      String generateSlug​(Locale pLocale, String label, UUID websiteUuid)
      Generates a not yet existing slug for the provided label, language and websiteUuid.
      protected de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases removeNonmatchingLanguagesForSlug​(de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases localizedUrlAliases, String slug)  
      de.digitalcollections.model.identifiable.alias.UrlAlias update​(de.digitalcollections.model.identifiable.alias.UrlAlias urlAlias)
      Updates an UrlAlias in the database
      void validate​(de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases localizedUrlAliases)
      Validates the given localizedUrlAliases according to the following criteria: For each (website,target,language) tuple, exactly one primary UrlAlias must exist, and as many non primary UrlAliases can exist
    • Constructor Detail

      • UrlAliasServiceImpl

        @Autowired
        public UrlAliasServiceImpl​(UrlAliasRepository repository,
                                   de.digitalcollections.commons.web.SlugGenerator slugGenerator,
                                   LocaleService localeService)
    • Method Detail

      • create

        public de.digitalcollections.model.identifiable.alias.UrlAlias create​(de.digitalcollections.model.identifiable.alias.UrlAlias urlAlias,
                                                                              boolean force)
                                                                       throws CudamiServiceException
        Description copied from interface: UrlAliasService
        Create an UrlAlias in the database
        Specified by:
        create in interface UrlAliasService
        Parameters:
        urlAlias - the UrlAlias (with yet empty UUID)
        force - if true, do not validate
        Returns:
        the persisted UrlAlias with its generated UUID
        Throws:
        CudamiServiceException
      • delete

        public boolean delete​(List<UUID> uuids)
                       throws CudamiServiceException
        Description copied from interface: UrlAliasService
        Delete a list of UrlAliases by their UUIDs
        Specified by:
        delete in interface UrlAliasService
        Parameters:
        uuids - a List of UUIDs
        Returns:
        true if at least one UrlAlias existed and could be deleted or false, if no UrlAlias existed at all and thus nothing could be deleted
        Throws:
        CudamiServiceException
      • find

        public de.digitalcollections.model.paging.SearchPageResponse<de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases> find​(de.digitalcollections.model.paging.SearchPageRequest searchPageRequest)
                                                                                                                                       throws CudamiServiceException
        Description copied from interface: UrlAliasService
        Find UrlAliases
        Specified by:
        find in interface UrlAliasService
        Parameters:
        searchPageRequest - the PageRequest
        Returns:
        a SearchPageResponse with the found LocalizedUrlAliases as paged content
        Throws:
        CudamiServiceException
      • findLocalizedUrlAliases

        public de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases findLocalizedUrlAliases​(UUID uuid)
                                                                                                   throws CudamiServiceException
        Description copied from interface: UrlAliasService
        Returns the LocalizedUrlAliases for an identifiable, identified by its UUID
        Specified by:
        findLocalizedUrlAliases in interface UrlAliasService
        Parameters:
        uuid - the UUID of the identifiable
        Returns:
        the LocalizedUrlAliases, if found, or null
        Throws:
        CudamiServiceException - in case of an error
      • findPrimaryLinks

        public de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases findPrimaryLinks​(UUID websiteUuid,
                                                                                                   String slug,
                                                                                                   Locale pLocale)
                                                                                            throws CudamiServiceException
        Description copied from interface: UrlAliasService
        Returns the primary Links (one per language) as LocalizedUrlAliases for a given slug for a given website (identified by its uuid). The given website can be null.
        Specified by:
        findPrimaryLinks in interface UrlAliasService
        Parameters:
        websiteUuid - the UUID of the website, the slug belongs to, or null
        slug - the slug (=relative path)
        pLocale - the locale for which the result is filtered. Optional.
        Returns:
        LocalizedUrlAliases, if a primary link exists; otherwise: null.
        Throws:
        CudamiServiceException - in case of an error
      • removeNonmatchingLanguagesForSlug

        protected de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases removeNonmatchingLanguagesForSlug​(de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases localizedUrlAliases,
                                                                                                                       String slug)
      • filterForLocaleWithFallback

        protected de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases filterForLocaleWithFallback​(Locale pLocale,
                                                                                                                 de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases localizedUrlAliases)
      • filterForLocale

        protected de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases filterForLocale​(Locale pLocale,
                                                                                                     de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases localizedUrlAliases)
      • generateSlug

        public String generateSlug​(Locale pLocale,
                                   String label,
                                   UUID websiteUuid)
                            throws CudamiServiceException
        Description copied from interface: UrlAliasService
        Generates a not yet existing slug for the provided label, language and websiteUuid. If the websiteUuid is empty, the configured default website uuid is used.

        If for the (locale,label,websiteUuid) triple a slug already exists, a new slug is calculated by appending suffixes to it.

        Specified by:
        generateSlug in interface UrlAliasService
        Parameters:
        pLocale - The locale for which the slug is generated.
        label - The label as a string
        websiteUuid - The uuid of the website, for which the slug is generated. If not set, the UUID of the default website is used
        Returns:
        slug as String, or null, if no website under the provided websiteUuid exists
        Throws:
        CudamiServiceException
      • update

        public de.digitalcollections.model.identifiable.alias.UrlAlias update​(de.digitalcollections.model.identifiable.alias.UrlAlias urlAlias)
                                                                       throws CudamiServiceException
        Description copied from interface: UrlAliasService
        Updates an UrlAlias in the database
        Specified by:
        update in interface UrlAliasService
        Parameters:
        urlAlias - the UrlAlias (with set UUID)
        Returns:
        the updated UrlAlias
        Throws:
        CudamiServiceException
      • validate

        public void validate​(de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases localizedUrlAliases)
                      throws ValidationException
        Description copied from interface: UrlAliasService
        Validates the given localizedUrlAliases according to the following criteria:
        • For each (website,target,language) tuple, exactly one primary UrlAlias must exist, and as many non primary UrlAliases can exist
        Specified by:
        validate in interface UrlAliasService
        Parameters:
        localizedUrlAliases - the LocalizedUrlAliases to validate
        Throws:
        ValidationException - when the critera are not met