Package org.ametys.web.alias
Class AliasDAO
- java.lang.Object
 - 
- org.apache.avalon.framework.logger.AbstractLogEnabled
 - 
- org.ametys.web.alias.AliasDAO
 
 
 
- 
- All Implemented Interfaces:
 Component,LogEnabled,Serviceable
public class AliasDAO extends AbstractLogEnabled implements Component, Serviceable
Class managingAliascreation, modification, deletion and moving 
- 
- 
Field Summary
Fields Modifier and Type Field Description private AmetysObjectResolver_ametysObjectResolverThe Ametys object resolverprivate SiteManager_siteManagerThe site managerstatic StringDEFAULT_ALIAS_NAMEThe alias default namestatic PatternPAGE_PATTERNThe PAGE patternstatic StringROLEThe component's rolestatic PatternTARGET_URL_PATTERNThe URL pattern ...static PatternURL_PATTERNThe URL pattern 
- 
Constructor Summary
Constructors Constructor Description AliasDAO() 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean_checkExistence(String siteName, String url)Checks the existence of an aliasprivate boolean_checkExistence(String id, String siteName, String url)Checks the existence of an alias with same URLprivate void_moveDown(DefaultAlias alias)Move down.private void_moveFirst(DefaultAlias alias)Move first.private void_moveLast(DefaultAlias link)Move last.private void_moveUp(DefaultAlias alias)Move up.Map<String,Object>alias2Json(DefaultAlias alias)Represent anAliasin JSONMap<String,String>createAlias(String type, String url, String target, String siteName, String dateStr)Create an aliasMap<String,String>deleteAlias(List<String> ids)Delete an aliasMap<String,Object>getAlias(String id)Get an aliasprivate booleanisValidTargetUrl(String url)Validates the urlprivate booleanisValidUrl(String url)Validates the urlMap<String,Object>moveAlias(String id, String role)Move an aliasvoidservice(ServiceManager smanager)Map<String,String>updateAlias(String id, String type, String url, String target, String siteName, String dateStr)Update an alias- 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger 
 - 
 
 - 
 
- 
- 
Field Detail
- 
PAGE_PATTERN
public static final Pattern PAGE_PATTERN
The PAGE pattern 
- 
URL_PATTERN
public static final Pattern URL_PATTERN
The URL pattern 
- 
TARGET_URL_PATTERN
public static final Pattern TARGET_URL_PATTERN
The URL pattern ... Copy of the regexp in Ametys.plugins.web.alias.AliasActions.js#_delayedInitialize 
- 
DEFAULT_ALIAS_NAME
public static final String DEFAULT_ALIAS_NAME
The alias default name- See Also:
 - Constant Field Values
 
 
- 
_ametysObjectResolver
private AmetysObjectResolver _ametysObjectResolver
The Ametys object resolver 
- 
_siteManager
private SiteManager _siteManager
The site manager 
 - 
 
- 
Constructor Detail
- 
AliasDAO
public AliasDAO()
 
 - 
 
- 
Method Detail
- 
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
 servicein interfaceServiceable- Throws:
 ServiceException
 
- 
getAlias
public Map<String,Object> getAlias(String id)
Get an alias- Parameters:
 id- the id of the alias to get- Returns:
 - the JSON representation of the alias
 
 
- 
createAlias
public Map<String,String> createAlias(String type, String url, String target, String siteName, String dateStr)
Create an alias- Parameters:
 type- the type (page or url)url- the origin urltarget- the target urlsiteName- the site's namedateStr- the optional expiration date of the alias- Returns:
 - a map
 
 
- 
updateAlias
public Map<String,String> updateAlias(String id, String type, String url, String target, String siteName, String dateStr)
Update an alias- Parameters:
 id- the id of the alias to updatetype- the type (page or url)url- the origin urltarget- the target urlsiteName- the site's namedateStr- the optional expiration date of the alias- Returns:
 - a map
 
 
- 
deleteAlias
public Map<String,String> deleteAlias(List<String> ids)
Delete an alias- Parameters:
 ids- the list of ids of aliases to delete- Returns:
 - a map
 
 
- 
moveAlias
public Map<String,Object> moveAlias(String id, String role) throws RepositoryException
Move an alias- Parameters:
 id- the id of the alias to moverole- the action to perform- Returns:
 - an empty map
 - Throws:
 RepositoryException- if an error occurs
 
- 
_moveFirst
private void _moveFirst(DefaultAlias alias) throws RepositoryException
Move first.- Parameters:
 alias- the alias to move- Throws:
 RepositoryException- if an errors occurs while moving
 
- 
_moveDown
private void _moveDown(DefaultAlias alias) throws RepositoryException
Move down.- Parameters:
 alias- the alias to move- Throws:
 RepositoryException- if an errors occurs while moving
 
- 
_moveUp
private void _moveUp(DefaultAlias alias) throws RepositoryException
Move up.- Parameters:
 alias- the alias to move- Throws:
 RepositoryException- if an errors occurs while moving
 
- 
_moveLast
private void _moveLast(DefaultAlias link) throws RepositoryException
Move last.- Parameters:
 link- the alias to move- Throws:
 RepositoryException- if an errors occurs while moving
 
- 
_checkExistence
private boolean _checkExistence(String id, String siteName, String url)
Checks the existence of an alias with same URL- Parameters:
 id- the aliassiteName- The site nameurl- The alias URL- Returns:
 - true if an alias with the same URL exists
 
 
- 
_checkExistence
private boolean _checkExistence(String siteName, String url)
Checks the existence of an alias- Parameters:
 siteName- The site nameurl- The alias URL- Returns:
 - true if an alias with the same URL exists
 
 
- 
isValidUrl
private boolean isValidUrl(String url)
Validates the url- Parameters:
 url- the url to check- Returns:
 - true if the url is valid
 
 
- 
isValidTargetUrl
private boolean isValidTargetUrl(String url)
Validates the url- Parameters:
 url- the url to check- Returns:
 - true if the url is valid
 
 
- 
alias2Json
public Map<String,Object> alias2Json(DefaultAlias alias)
Represent anAliasin JSON- Parameters:
 alias- The alias- Returns:
 - the alias in JSON
 
 
 - 
 
 -