Class UrlAliasServiceImpl
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 voidcheckPublication(de.digitalcollections.model.identifiable.alias.UrlAlias urlAlias)de.digitalcollections.model.identifiable.alias.UrlAliascreate(de.digitalcollections.model.identifiable.alias.UrlAlias urlAlias, boolean force)Create an UrlAlias in the databasebooleandelete(java.util.List<java.util.UUID> uuids)Delete a list of UrlAliases by their UUIDsbooleandeleteAllForTarget(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.LocalizedUrlAliasesfilterForLocale(java.util.Locale pLocale, de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases localizedUrlAliases)protected de.digitalcollections.model.identifiable.alias.LocalizedUrlAliasesfilterForLocaleWithFallback(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 UrlAliasesde.digitalcollections.model.identifiable.alias.LocalizedUrlAliasesfindLocalizedUrlAliases(java.util.UUID uuid)Returns the LocalizedUrlAliases for an identifiable, identified by its UUIDde.digitalcollections.model.identifiable.alias.UrlAliasfindOne(java.util.UUID uuid)Retrieve one UrlAlias by its UUIDde.digitalcollections.model.identifiable.alias.LocalizedUrlAliasesfindPrimaryLinks(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.StringgenerateSlug(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.LocalizedUrlAliasesremoveNonmatchingLanguagesForSlug(de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases localizedUrlAliases, java.lang.String slug)de.digitalcollections.model.identifiable.alias.UrlAliasupdate(de.digitalcollections.model.identifiable.alias.UrlAlias urlAlias)Updates an UrlAlias in the databasevoidvalidate(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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.digitalcollections.cudami.server.business.api.service.identifiable.alias.UrlAliasService
create, delete, deleteAllForTarget
-
Constructor Details
-
UrlAliasServiceImpl
@Autowired public UrlAliasServiceImpl(UrlAliasRepository repository, de.digitalcollections.commons.web.SlugGenerator slugGenerator, LocaleService localeService)
-
-
Method Details
-
create
public de.digitalcollections.model.identifiable.alias.UrlAlias create(de.digitalcollections.model.identifiable.alias.UrlAlias urlAlias, boolean force) throws CudamiServiceExceptionDescription copied from interface:UrlAliasServiceCreate an UrlAlias in the database- Specified by:
createin interfaceUrlAliasService- 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
Description copied from interface:UrlAliasServiceDelete a list of UrlAliases by their UUIDs- Specified by:
deletein interfaceUrlAliasService- 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 CudamiServiceExceptionDescription copied from interface:UrlAliasServiceDelete all UrlAliases targetting the passed UUID except those that have already been published.- Specified by:
deleteAllForTargetin interfaceUrlAliasService- Parameters:
uuid- 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:
CudamiServiceException
-
find
public de.digitalcollections.model.paging.SearchPageResponse<de.digitalcollections.model.identifiable.alias.LocalizedUrlAliases> find(de.digitalcollections.model.paging.SearchPageRequest searchPageRequest) throws CudamiServiceExceptionDescription copied from interface:UrlAliasServiceFind UrlAliases- Specified by:
findin interfaceUrlAliasService- 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 CudamiServiceExceptionDescription copied from interface:UrlAliasServiceReturns the LocalizedUrlAliases for an identifiable, identified by its UUID- Specified by:
findLocalizedUrlAliasesin interfaceUrlAliasService- 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 CudamiServiceExceptionDescription copied from interface:UrlAliasServiceRetrieve one UrlAlias by its UUID- Specified by:
findOnein interfaceUrlAliasService- 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 CudamiServiceExceptionDescription 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.- Specified by:
findPrimaryLinksin interfaceUrlAliasService- Parameters:
websiteUuid- the UUID of 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:
CudamiServiceException- in case of an error
-
findPrimaryLinksForTarget
public java.util.List<de.digitalcollections.model.identifiable.alias.UrlAlias> findPrimaryLinksForTarget(java.util.UUID targetUuid) throws CudamiServiceExceptionDescription copied from interface:UrlAliasServiceReturns all primary links of the passed target identifiable.- Specified by:
findPrimaryLinksForTargetin interfaceUrlAliasService- Parameters:
targetUuid- UUID of the identifiable that the primaries should be found for- Returns:
List, notnull- 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 CudamiServiceExceptionDescription 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 stringwebsiteUuid- 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 CudamiServiceExceptionDescription copied from interface:UrlAliasServiceUpdates an UrlAlias in the database- Specified by:
updatein interfaceUrlAliasService- 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 ValidationExceptionDescription 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
-