java.lang.Object
de.digitalcollections.cudami.server.business.impl.service.identifiable.alias.UrlAliasServiceImpl
All Implemented Interfaces:
UrlAliasService

@Service
@Transactional(rollbackFor=java.lang.Exception.class)
public class UrlAliasServiceImpl
extends java.lang.Object
implements UrlAliasService
Service implementation for UrlAlias handling.
  • Constructor Summary

    Constructors 
    Constructor Description
    UrlAliasServiceImpl​(UrlAliasRepository repository, de.digitalcollections.commons.web.SlugGenerator slugGenerator, LocaleService localeService)  
  • Method Summary

    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​(java.util.List<java.util.UUID> uuids)
    Delete a list of UrlAliases by their UUIDs
    boolean deleteAllForTarget​(java.util.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​(java.util.Locale pLocale, de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases localizedUrlAliases)  
    protected de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases filterForLocaleWithFallback​(java.util.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​(java.util.UUID uuid)
    Returns the LocalizedUrlAliases for an identifiable, identified by its UUID
    de.digitalcollections.model.identifiable.alias.UrlAlias findOne​(java.util.UUID uuid)
    Retrieve one UrlAlias by its UUID
    de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases findPrimaryLinks​(java.util.UUID websiteUuid, java.lang.String slug, java.util.Locale pLocale)
    Returns the primary Links (one per language) as LocalizedUrlAliases for a given slug for a given website (identified by its uuid).
    java.util.List<de.digitalcollections.model.identifiable.alias.UrlAlias> findPrimaryLinksForTarget​(java.util.UUID targetUuid)
    Returns all primary links of the passed target identifiable.
    java.lang.String generateSlug​(java.util.Locale pLocale, java.lang.String label, java.util.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, java.lang.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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface de.digitalcollections.cudami.server.business.api.service.identifiable.alias.UrlAliasService

    create, delete, deleteAllForTarget
  • Constructor Details

  • Method Details

    • 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​(java.util.List<java.util.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
    • deleteAllForTarget

      @Transactional(rollbackFor={java.lang.RuntimeException.class,CudamiServiceException.class}) public boolean deleteAllForTarget​(java.util.UUID uuid, boolean force) throws CudamiServiceException
      Description copied from interface: UrlAliasService
      Delete all UrlAliases targetting the passed UUID except those that have already been published.
      Specified by:
      deleteAllForTarget in interface UrlAliasService
      Parameters:
      uuid - the targetUuid whose UrlAliases should be deleted
      force - if true remove published ones as well
      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​(java.util.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
    • findOne

      public de.digitalcollections.model.identifiable.alias.UrlAlias findOne​(java.util.UUID uuid) throws CudamiServiceException
      Description copied from interface: UrlAliasService
      Retrieve one UrlAlias by its UUID
      Specified by:
      findOne in interface UrlAliasService
      Parameters:
      uuid - the UUID
      Returns:
      the UrlAlias or null
      Throws:
      CudamiServiceException - in case of an error
    • findPrimaryLinks

      public de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases findPrimaryLinks​(java.util.UUID websiteUuid, java.lang.String slug, java.util.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
    • findPrimaryLinksForTarget

      public java.util.List<de.digitalcollections.model.identifiable.alias.UrlAlias> findPrimaryLinksForTarget​(java.util.UUID targetUuid) throws CudamiServiceException
      Description copied from interface: UrlAliasService
      Returns all primary links of the passed target identifiable.
      Specified by:
      findPrimaryLinksForTarget in interface UrlAliasService
      Parameters:
      targetUuid - UUID of the identifiable that the primaries should be found for
      Returns:
      List, not null
      Throws:
      CudamiServiceException
    • removeNonmatchingLanguagesForSlug

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

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

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

      public java.lang.String generateSlug​(java.util.Locale pLocale, java.lang.String label, java.util.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
    • checkPublication

      protected void checkPublication​(de.digitalcollections.model.identifiable.alias.UrlAlias urlAlias) throws CudamiServiceException
      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