java.lang.Object
de.digitalcollections.cudami.server.business.impl.service.UniqueObjectServiceImpl<de.digitalcollections.model.identifiable.alias.UrlAlias,UrlAliasRepository>
de.digitalcollections.cudami.server.business.impl.service.identifiable.alias.UrlAliasServiceImpl
All Implemented Interfaces:
UrlAliasService, UniqueObjectService<de.digitalcollections.model.identifiable.alias.UrlAlias>

@Service public class UrlAliasServiceImpl extends UniqueObjectServiceImpl<de.digitalcollections.model.identifiable.alias.UrlAlias,UrlAliasRepository> implements UrlAliasService
Service implementation for UrlAlias handling.
  • Field Summary

    Fields inherited from class de.digitalcollections.cudami.server.business.impl.service.UniqueObjectServiceImpl

    repository
  • 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)
     
    boolean
    deleteByIdentifiable(de.digitalcollections.model.identifiable.Identifiable identifiable, 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.list.paging.PageResponse<de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases>
    findLocalizedUrlAliases(de.digitalcollections.model.list.paging.PageRequest pageRequest)
    Find UrlAliases
    generateSlug(Locale pLocale, String label, de.digitalcollections.model.identifiable.entity.Website website)
    Generates a not yet existing slug for the provided label, language and websiteUuid.
    de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases
    getByIdentifiable(de.digitalcollections.model.identifiable.Identifiable identifiable)
    Returns the LocalizedUrlAliases for an identifiable, identified by its UUID
    de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases
    getPrimaryUrlAliases(de.digitalcollections.model.identifiable.entity.Website website, 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>
    getPrimaryUrlAliasesByIdentifiable(de.digitalcollections.model.identifiable.Identifiable identifiable)
    Returns all primary links of the passed target identifiable.
    protected de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases
    removeNonmatchingLanguagesForSlug(de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases localizedUrlAliases, String slug)
     
    void
    save(de.digitalcollections.model.identifiable.alias.UrlAlias urlAlias, boolean force)
    Persist an UrlAlias (with optional validation)
    void
    update(de.digitalcollections.model.identifiable.alias.UrlAlias urlAlias)
    Updates an persisted UniqueObject
    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 de.digitalcollections.cudami.server.business.impl.service.UniqueObjectServiceImpl

    count, create, delete, delete, find, getAll, getByExample, getByExampleAndFiltering, getRandom, save, setDefaultSorting

    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.UniqueObjectService

    count, create, delete, delete, find, getAll, getByExample, getByExampleAndFiltering, getByExampleAndLocale, getRandom

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

    deleteByIdentifiable, save
  • Constructor Details

    • UrlAliasServiceImpl

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

    • checkPublication

      protected void checkPublication(de.digitalcollections.model.identifiable.alias.UrlAlias urlAlias) throws ServiceException
      Throws:
      ServiceException
    • deleteByIdentifiable

      @Transactional(rollbackFor={java.lang.RuntimeException.class,ServiceException.class}) public boolean deleteByIdentifiable(de.digitalcollections.model.identifiable.Identifiable identifiable, boolean force) throws ServiceException, ConflictException
      Description copied from interface: UrlAliasService
      Delete all UrlAliases targetting the passed UUID except those that have already been published.
      Specified by:
      deleteByIdentifiable in interface UrlAliasService
      Parameters:
      identifiable - the identifiable with 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:
      ServiceException
      ConflictException
    • filterForLocale

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

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

      public de.digitalcollections.model.list.paging.PageResponse<de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases> findLocalizedUrlAliases(de.digitalcollections.model.list.paging.PageRequest pageRequest) throws ServiceException
      Description copied from interface: UrlAliasService
      Find UrlAliases
      Specified by:
      findLocalizedUrlAliases in interface UrlAliasService
      Parameters:
      pageRequest - the PageRequest
      Returns:
      a SearchPageResponse with the found LocalizedUrlAliases as paged content
      Throws:
      ServiceException - in case of an error
    • generateSlug

      public String generateSlug(Locale pLocale, String label, de.digitalcollections.model.identifiable.entity.Website website) throws ServiceException
      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
      website - 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:
      ServiceException
    • getByIdentifiable

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

      public de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases getPrimaryUrlAliases(de.digitalcollections.model.identifiable.entity.Website website, String slug, Locale pLocale) throws ServiceException
      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. Additionally you can provide a Locale language to retrieve primary links of this particular target language only.
      Specified by:
      getPrimaryUrlAliases in interface UrlAliasService
      Parameters:
      website - 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:
      ServiceException - in case of an error
    • getPrimaryUrlAliasesByIdentifiable

      public List<de.digitalcollections.model.identifiable.alias.UrlAlias> getPrimaryUrlAliasesByIdentifiable(de.digitalcollections.model.identifiable.Identifiable identifiable) throws ServiceException
      Description copied from interface: UrlAliasService
      Returns all primary links of the passed target identifiable.
      Specified by:
      getPrimaryUrlAliasesByIdentifiable in interface UrlAliasService
      Parameters:
      identifiable - the identifiable that the primaries should be found for
      Returns:
      List, not null
      Throws:
      ServiceException - in case of an error
    • removeNonmatchingLanguagesForSlug

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

      public void save(de.digitalcollections.model.identifiable.alias.UrlAlias urlAlias, boolean force) throws ServiceException
      Description copied from interface: UrlAliasService
      Persist an UrlAlias (with optional validation)
      Specified by:
      save in interface UrlAliasService
      Parameters:
      urlAlias - the UrlAlias (not yet stored)
      Throws:
      ServiceException - in case of an error
    • update

      public void update(de.digitalcollections.model.identifiable.alias.UrlAlias urlAlias) throws ServiceException
      Description copied from interface: UniqueObjectService
      Updates an persisted UniqueObject
      Specified by:
      update in interface UniqueObjectService<de.digitalcollections.model.identifiable.alias.UrlAlias>
      Overrides:
      update in class UniqueObjectServiceImpl<de.digitalcollections.model.identifiable.alias.UrlAlias,UrlAliasRepository>
      Parameters:
      urlAlias - the UniqueObject (with set UUID)
      Throws:
      ServiceException - in case of an error
    • 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