Package org.ametys.web.alias
Class DefaultAlias
- java.lang.Object
-
- org.ametys.plugins.repository.AbstractAmetysObject
-
- org.ametys.plugins.repository.jcr.SimpleAmetysObject<DefaultAliasFactory>
-
- org.ametys.web.alias.DefaultAlias
-
- All Implemented Interfaces:
AmetysObject
,JCRAmetysObject
,MetadataAwareAmetysObject
,ModifiableMetadataAwareAmetysObject
,ModifiableAmetysObject
,MovableAmetysObject
,RemovableAmetysObject
,Alias
public class DefaultAlias extends SimpleAmetysObject<DefaultAliasFactory> implements Alias, MovableAmetysObject
ADefaultAlias
is a URL redirection to an existing page or a module URL
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.ametys.web.alias.Alias
Alias.TargetType
-
-
Field Summary
Fields Modifier and Type Field Description static String
METADATA_CREATED_AT
Constant for origin metadata.static String
METADATA_EXPIRATION_DATE
Constant for period metadata.static String
METADATA_TARGET
Constant for target metadata.static String
METADATA_TYPE
Constant for type metadata.static String
METADATA_URL
Constant for origin metadata.
-
Constructor Summary
Constructors Constructor Description DefaultAlias(Node node, String parentPath, DefaultAliasFactory factory)
Creates aDefaultAlias
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canMoveTo(AmetysObject newParent)
Test if a move can be a success or if it is impossible (e.g.Date
getCreationDate()
Get the creation dateDate
getExpirationDate()
Get the expiration dateString
getTarget()
Get the target URLAlias.TargetType
getType()
Retrieves the target type.String
getUrl()
Get the origin URLvoid
moveTo(AmetysObject newParent, boolean renameIfExist)
Move the current object as a new child of the given object.void
orderBefore(AmetysObject siblingObject)
Order a node before another sibling node (or as the last node)void
removeExpirationDate()
Remove the expiration datevoid
setCreationDate(Date date)
Set the creation datevoid
setExpirationDate(Date date)
Set the expiration datevoid
setTarget(String url)
Set the target URLvoid
setType(Alias.TargetType type)
Set the type.void
setUrl(String url)
Set the origin URL-
Methods inherited from class org.ametys.plugins.repository.jcr.SimpleAmetysObject
_getFactory, _invalidateName, _invalidateParentPath, getId, getMetadataHolder, getName, getNode, getParent, getParentPath, getPath, needsSave, remove, rename, revertChanges, saveChanges
-
Methods inherited from class org.ametys.plugins.repository.AbstractAmetysObject
equals, hashCode, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.ametys.plugins.repository.AmetysObject
equals, getId, getName, getParent, getParentPath, getPath, hashCode
-
-
-
-
Field Detail
-
METADATA_CREATED_AT
public static final String METADATA_CREATED_AT
Constant for origin metadata.- See Also:
- Constant Field Values
-
METADATA_URL
public static final String METADATA_URL
Constant for origin metadata.- See Also:
- Constant Field Values
-
METADATA_TARGET
public static final String METADATA_TARGET
Constant for target metadata.- See Also:
- Constant Field Values
-
METADATA_TYPE
public static final String METADATA_TYPE
Constant for type metadata.- See Also:
- Constant Field Values
-
METADATA_EXPIRATION_DATE
public static final String METADATA_EXPIRATION_DATE
Constant for period metadata.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultAlias
public DefaultAlias(Node node, String parentPath, DefaultAliasFactory factory)
Creates aDefaultAlias
.- Parameters:
node
- the node backing thisAmetysObject
.parentPath
- the parent path in the Ametys hierarchy.factory
- theDefaultZoneItemFactory
which creates the AmetysObject.
-
-
Method Detail
-
getUrl
public String getUrl() throws AmetysRepositoryException
Description copied from interface:Alias
Get the origin URL- Specified by:
getUrl
in interfaceAlias
- Returns:
- the origin URL
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setUrl
public void setUrl(String url) throws AmetysRepositoryException
Description copied from interface:Alias
Set the origin URL- Specified by:
setUrl
in interfaceAlias
- Parameters:
url
- the origin URL- Throws:
AmetysRepositoryException
- if an error occurs.
-
getTarget
public String getTarget() throws AmetysRepositoryException
Description copied from interface:Alias
Get the target URL- Specified by:
getTarget
in interfaceAlias
- Returns:
- the target URL
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setTarget
public void setTarget(String url) throws AmetysRepositoryException
Description copied from interface:Alias
Set the target URL- Specified by:
setTarget
in interfaceAlias
- Parameters:
url
- the target URL- Throws:
AmetysRepositoryException
- if an error occurs.
-
getExpirationDate
public Date getExpirationDate() throws AmetysRepositoryException
Description copied from interface:Alias
Get the expiration date- Specified by:
getExpirationDate
in interfaceAlias
- Returns:
- the expiration date
- Throws:
AmetysRepositoryException
- if an error occurs.
-
removeExpirationDate
public void removeExpirationDate()
Description copied from interface:Alias
Remove the expiration date- Specified by:
removeExpirationDate
in interfaceAlias
-
setExpirationDate
public void setExpirationDate(Date date) throws AmetysRepositoryException
Description copied from interface:Alias
Set the expiration date- Specified by:
setExpirationDate
in interfaceAlias
- Parameters:
date
- the expiration date- Throws:
AmetysRepositoryException
- if an error occurs.
-
getType
public Alias.TargetType getType() throws AmetysRepositoryException
Description copied from interface:Alias
Retrieves the target type.- Specified by:
getType
in interfaceAlias
- Returns:
- the type.
- Throws:
AmetysRepositoryException
- if an error occurs.- See Also:
Alias.TargetType
-
setType
public void setType(Alias.TargetType type) throws AmetysRepositoryException
Description copied from interface:Alias
Set the type.- Specified by:
setType
in interfaceAlias
- Parameters:
type
- the type.- Throws:
AmetysRepositoryException
- if an error occurs.- See Also:
Alias.TargetType
-
getCreationDate
public Date getCreationDate() throws AmetysRepositoryException
Description copied from interface:Alias
Get the creation date- Specified by:
getCreationDate
in interfaceAlias
- Returns:
- the creation date
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setCreationDate
public void setCreationDate(Date date) throws AmetysRepositoryException
Description copied from interface:Alias
Set the creation date- Specified by:
setCreationDate
in interfaceAlias
- Parameters:
date
- the date to set- Throws:
AmetysRepositoryException
- if an error occurs.
-
orderBefore
public void orderBefore(AmetysObject siblingObject) throws AmetysRepositoryException
Description copied from interface:MovableAmetysObject
Order a node before another sibling node (or as the last node)- Specified by:
orderBefore
in interfaceMovableAmetysObject
- Parameters:
siblingObject
- The node that will be the next sibling node of the current node. Must have the same parent as the current node. Can be null to set the current node as the last node.- Throws:
AmetysRepositoryException
- if an error occurs.
-
canMoveTo
public boolean canMoveTo(AmetysObject newParent) throws AmetysRepositoryException
Description copied from interface:MovableAmetysObject
Test if a move can be a success or if it is impossible (e.g. due to the implementation of the target)- Specified by:
canMoveTo
in interfaceMovableAmetysObject
- Parameters:
newParent
- See moveTo.- Returns:
- true if the move operation may succeed. If false is returned and you call moveTo anyway, you may encontered a RuntimeException (such as UnsupportedOperationException)
- Throws:
AmetysRepositoryException
- if an error occurs.
-
moveTo
public void moveTo(AmetysObject newParent, boolean renameIfExist) throws AmetysRepositoryException
Description copied from interface:MovableAmetysObject
Move the current object as a new child of the given object. This node will be the last child. You should call canMoveTo to know if this is a supported operation.- Specified by:
moveTo
in interfaceMovableAmetysObject
- Parameters:
newParent
- The new parent for the current object. Can not be null. Can not be a child of the current node. Must be a TraversableAmetyObject.renameIfExist
- true to rename moved page if a page with same name already exist- Throws:
AmetysRepositoryException
- if an error occurs.RepositoryIntegrityViolationException
- if a page with the same name already exists.
-
-