Class UrlAliasServiceImpl
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
ConstructorsConstructorDescriptionUrlAliasServiceImpl(UrlAliasRepository repository, de.digitalcollections.commons.web.SlugGenerator slugGenerator, LocaleService localeService) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckPublication(de.digitalcollections.model.identifiable.alias.UrlAlias urlAlias) booleandeleteByIdentifiable(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.LocalizedUrlAliasesfilterForLocale(Locale pLocale, de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases localizedUrlAliases) protected de.digitalcollections.model.identifiable.alias.LocalizedUrlAliasesfilterForLocaleWithFallback(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 UrlAliasesgenerateSlug(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.LocalizedUrlAliasesgetByIdentifiable(de.digitalcollections.model.identifiable.Identifiable identifiable) Returns the LocalizedUrlAliases for an identifiable, identified by its UUIDde.digitalcollections.model.identifiable.alias.LocalizedUrlAliasesgetPrimaryUrlAliases(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.LocalizedUrlAliasesremoveNonmatchingLanguagesForSlug(de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases localizedUrlAliases, String slug) voidsave(de.digitalcollections.model.identifiable.alias.UrlAlias urlAlias, boolean force) Persist anUrlAlias(with optional validation)voidupdate(de.digitalcollections.model.identifiable.alias.UrlAlias urlAlias) Updates an persistedUniqueObjectvoidvalidate(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 existMethods inherited from class de.digitalcollections.cudami.server.business.impl.service.UniqueObjectServiceImpl
count, create, delete, delete, find, getAll, getByExample, getByExampleAndFiltering, getRandom, save, setDefaultSortingMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.digitalcollections.cudami.server.business.api.service.UniqueObjectService
count, create, delete, delete, find, getAll, getByExample, getByExampleAndFiltering, getByExampleAndLocale, getRandomMethods 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:UrlAliasServiceDelete all UrlAliases targetting the passed UUID except those that have already been published.- Specified by:
deleteByIdentifiablein interfaceUrlAliasService- Parameters:
identifiable- the identifiable with thetargetUuidwhose UrlAliases should be deletedforce- iftrueremove 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:
ServiceExceptionConflictException
-
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:UrlAliasServiceFind UrlAliases- Specified by:
findLocalizedUrlAliasesin interfaceUrlAliasService- 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:UrlAliasServiceGenerates 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:
generateSlugin interfaceUrlAliasService- Parameters:
pLocale- The locale for which the slug is generated.label- The label as a stringwebsite- 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:UrlAliasServiceReturns the LocalizedUrlAliases for an identifiable, identified by its UUID- Specified by:
getByIdentifiablein interfaceUrlAliasService- 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:UrlAliasServiceReturns 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 aLocalelanguage to retrieve primary links of this particular target language only.- Specified by:
getPrimaryUrlAliasesin interfaceUrlAliasService- Parameters:
website- the website, the slug belongs to, or nullslug- 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:UrlAliasServiceReturns all primary links of the passed target identifiable.- Specified by:
getPrimaryUrlAliasesByIdentifiablein interfaceUrlAliasService- Parameters:
identifiable- the identifiable that the primaries should be found for- Returns:
List, notnull- 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:UrlAliasServicePersist anUrlAlias(with optional validation)- Specified by:
savein interfaceUrlAliasService- Parameters:
urlAlias- theUrlAlias(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:UniqueObjectServiceUpdates an persistedUniqueObject- Specified by:
updatein interfaceUniqueObjectService<de.digitalcollections.model.identifiable.alias.UrlAlias>- Overrides:
updatein classUniqueObjectServiceImpl<de.digitalcollections.model.identifiable.alias.UrlAlias,UrlAliasRepository> - Parameters:
urlAlias- theUniqueObject(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:UrlAliasServiceValidates 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:
validatein interfaceUrlAliasService- Parameters:
localizedUrlAliases- the LocalizedUrlAliases to validate- Throws:
ValidationException- when the critera are not met
-