Class DefaultLink
- java.lang.Object
-
- org.ametys.plugins.repository.AbstractAmetysObject
-
- org.ametys.plugins.repository.jcr.SimpleAmetysObject<F>
-
- org.ametys.plugins.repository.jcr.DefaultTraversableAmetysObject<DefaultLinkFactory>
-
- org.ametys.plugins.linkdirectory.repository.DefaultLink
-
- All Implemented Interfaces:
Link
,ACLAmetysObject
,AmetysObject
,JCRAmetysObject
,JCRTraversableAmetysObject
,MetadataAwareAmetysObject
,ModifiableMetadataAwareAmetysObject
,ModifiableACLAmetysObject
,ModifiableAmetysObject
,ModifiableTraversableAmetysObject
,MovableAmetysObject
,RemovableAmetysObject
,TraversableAmetysObject
,SiteAwareAmetysObject
public class DefaultLink extends DefaultTraversableAmetysObject<DefaultLinkFactory> implements Link, SiteAwareAmetysObject, MovableAmetysObject
Repository implementation of a directory link.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.ametys.plugins.linkdirectory.Link
Link.LinkStatus, Link.LinkType
-
-
Field Summary
Fields Modifier and Type Field Description static String
PROPERTY_COLOR
Constant for color property.static String
PROPERTY_CONTENT
Constant for title property.static String
PROPERTY_DYNAMIC_INFO_PROVIDER
Constant for id of provider of dynamic information.static String
PROPERTY_INTERNAL_URL
Constant for internal URL property.static String
PROPERTY_PAGE
Constant for page property.static String
PROPERTY_PICTURE
Constant for picture data property.static String
PROPERTY_PICTURE_ALTERNATIVE
Constant for picture alternative property.static String
PROPERTY_PICTURE_GLYPH
Constant for picture glyph property.static String
PROPERTY_PICTURE_ID
Constant for picture id property.static String
PROPERTY_PICTURE_TYPE
Constant for picture type property.static String
PROPERTY_STATUS
Constant for status property.static String
PROPERTY_THEMES
Constant for themes property.static String
PROPERTY_TITLE
Constant for title property.static String
PROPERTY_URL
Constant for URL property.static String
PROPERTY_URL_ALTERNATIVE
Constant for URL alternative property.static String
PROPERTY_URLTYPE
Constant for URL type property.
-
Constructor Summary
Constructors Constructor Description DefaultLink(Node node, String parentPath, DefaultLinkFactory factory)
Create aDefaultLink
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private String[]
_getListFromMetadataName(String metadataName)
Retrieves the list of values corresponding to the metadata name passed as parameterprivate void
_setListWithMetadataName(String[] list, String metadataName)
Sets the list of values to the node corresponding to the metadata name passed as a parameterboolean
canMoveTo(AmetysObject newParent)
Test if a move can be a success or if it is impossible (e.g.String
getAlternative()
Get the link alternative.String
getColor()
Get the color.String
getContent()
Get the link content.String
getDynamicInformationProvider()
Get the id of the provider of dynamic information.BinaryMetadata
getExternalPicture()
Get the picture as a binary metadata.String
getInternalUrl()
Get the internal URL.String
getLanguage()
Get the theme language.String
getPage()
Get the page.String
getPictureAlternative()
Get the picture alternative.String
getPictureGlyph()
Get the picture glyph.String
getPictureType()
Get the picture type.String
getResourcePictureId()
Get the picture resource ID.Site
getSite()
Returns this object's site.String
getSiteName()
Returns this object's site name.Link.LinkStatus
getStatus()
Get the status.String[]
getThemes()
Get the themes.String
getTitle()
Get the link title.String
getUrl()
Get the URL.Link.LinkType
getUrlType()
Retrieves the linked URL type.void
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)protected void
removePictureMetas()
Remove all picture metas (picture ID and picture binary).void
removeTheme(String themeId)
Remove theme if existvoid
setAlternative(String alternative)
Set the link alternative.void
setColor(String color)
Set the color.void
setContent(String content)
Set the content.void
setDynamicInformationProvider(String providerId)
Set the id of the provider of dynamic information.void
setExternalPicture(String mimeType, String filename, InputStream stream)
Set the picture from an external file.void
setInternalUrl(String url)
Set the internal URL.void
setNoPicture()
Removes any picture currently assigned.void
setPage(String page)
Set the page.void
setPictureAlternative(String alternative)
Set the picture alternative.void
setPictureGlyph(String glyph)
Set the picture glyph.void
setPictureType(String type)
Set the picture type.void
setResourcePicture(String resourceId)
Set the picture from an explorer resource.void
setStatus(Link.LinkStatus status)
Set the status.void
setThemes(String[] themes)
Set the themes.void
setTitle(String title)
Set the title.void
setUrl(Link.LinkType urlType, String url)
Set the URL.-
Methods inherited from class org.ametys.plugins.repository.jcr.DefaultTraversableAmetysObject
addAllowedGroups, addAllowedProfilesForAnonymous, addAllowedProfilesForAnyConnectedUser, addAllowedUsers, addDeniedGroups, addDeniedProfilesForAnonymous, addDeniedProfilesForAnyConnectedUser, addDeniedUsers, createChild, disallowInheritance, getAllowedGroups, getAllowedProfilesForAnonymous, getAllowedProfilesForAnyConnectedUser, getAllowedProfilesForGroups, getAllowedProfilesForUser, getAllowedProfilesForUsers, getAllowedUsers, getChild, getChildren, getDeniedGroups, getDeniedProfilesForAnonymous, getDeniedProfilesForAnyConnectedUser, getDeniedProfilesForGroups, getDeniedProfilesForUser, getDeniedProfilesForUsers, getDeniedUsers, hasChild, isInheritanceDisallowed, removeAllowedGroups, removeAllowedGroups, removeAllowedProfilesForAnonymous, removeAllowedProfilesForAnyConnectedUser, removeAllowedUsers, removeAllowedUsers, removeDeniedGroups, removeDeniedGroups, removeDeniedProfilesForAnonymous, removeDeniedProfilesForAnyConnectedUser, removeDeniedUsers, removeDeniedUsers
-
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
-
Methods inherited from interface org.ametys.plugins.repository.jcr.JCRAmetysObject
getNode
-
Methods inherited from interface org.ametys.plugins.repository.ModifiableAmetysObject
needsSave, rename, revertChanges, saveChanges
-
Methods inherited from interface org.ametys.plugins.repository.metadata.ModifiableMetadataAwareAmetysObject
getMetadataHolder
-
Methods inherited from interface org.ametys.plugins.repository.RemovableAmetysObject
remove
-
Methods inherited from interface org.ametys.plugins.repository.TraversableAmetysObject
getChildAt, getChildPosition
-
-
-
-
Field Detail
-
PROPERTY_URL
public static final String PROPERTY_URL
Constant for URL property.- See Also:
- Constant Field Values
-
PROPERTY_DYNAMIC_INFO_PROVIDER
public static final String PROPERTY_DYNAMIC_INFO_PROVIDER
Constant for id of provider of dynamic information.- See Also:
- Constant Field Values
-
PROPERTY_INTERNAL_URL
public static final String PROPERTY_INTERNAL_URL
Constant for internal URL property.- See Also:
- Constant Field Values
-
PROPERTY_URLTYPE
public static final String PROPERTY_URLTYPE
Constant for URL type property.- See Also:
- Constant Field Values
-
PROPERTY_TITLE
public static final String PROPERTY_TITLE
Constant for title property.- See Also:
- Constant Field Values
-
PROPERTY_CONTENT
public static final String PROPERTY_CONTENT
Constant for title property.- See Also:
- Constant Field Values
-
PROPERTY_URL_ALTERNATIVE
public static final String PROPERTY_URL_ALTERNATIVE
Constant for URL alternative property.- See Also:
- Constant Field Values
-
PROPERTY_PICTURE_TYPE
public static final String PROPERTY_PICTURE_TYPE
Constant for picture type property.- See Also:
- Constant Field Values
-
PROPERTY_PICTURE
public static final String PROPERTY_PICTURE
Constant for picture data property.- See Also:
- Constant Field Values
-
PROPERTY_PICTURE_ID
public static final String PROPERTY_PICTURE_ID
Constant for picture id property.- See Also:
- Constant Field Values
-
PROPERTY_PICTURE_GLYPH
public static final String PROPERTY_PICTURE_GLYPH
Constant for picture glyph property.- See Also:
- Constant Field Values
-
PROPERTY_PICTURE_ALTERNATIVE
public static final String PROPERTY_PICTURE_ALTERNATIVE
Constant for picture alternative property.- See Also:
- Constant Field Values
-
PROPERTY_THEMES
public static final String PROPERTY_THEMES
Constant for themes property.- See Also:
- Constant Field Values
-
PROPERTY_COLOR
public static final String PROPERTY_COLOR
Constant for color property.- See Also:
- Constant Field Values
-
PROPERTY_PAGE
public static final String PROPERTY_PAGE
Constant for page property.- See Also:
- Constant Field Values
-
PROPERTY_STATUS
public static final String PROPERTY_STATUS
Constant for status property.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultLink
public DefaultLink(Node node, String parentPath, DefaultLinkFactory factory)
Create aDefaultLink
.- Parameters:
node
- the node backing thisAmetysObject
.parentPath
- the parent path in the Ametys hierarchy.factory
- theDefaultLinkFactory
which creates the AmetysObject.
-
-
Method Detail
-
getUrl
public String getUrl() throws AmetysRepositoryException
Description copied from interface:Link
Get the URL.- Specified by:
getUrl
in interfaceLink
- Returns:
- the link URL.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setUrl
public void setUrl(Link.LinkType urlType, String url) throws AmetysRepositoryException
Description copied from interface:Link
Set the URL.- Specified by:
setUrl
in interfaceLink
- Parameters:
urlType
- The URL typeurl
- the link URL to set.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getInternalUrl
public String getInternalUrl() throws AmetysRepositoryException
Description copied from interface:Link
Get the internal URL.- Specified by:
getInternalUrl
in interfaceLink
- Returns:
- the link internal URL.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setInternalUrl
public void setInternalUrl(String url) throws AmetysRepositoryException
Description copied from interface:Link
Set the internal URL.- Specified by:
setInternalUrl
in interfaceLink
- Parameters:
url
- the link internal URL to set.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getUrlType
public Link.LinkType getUrlType() throws AmetysRepositoryException
Description copied from interface:Link
Retrieves the linked URL type.- Specified by:
getUrlType
in interfaceLink
- Returns:
- the linked URL type.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
getTitle
public String getTitle() throws AmetysRepositoryException
Description copied from interface:Link
Get the link title.- Specified by:
getTitle
in interfaceLink
- Returns:
- the link title.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setTitle
public void setTitle(String title) throws AmetysRepositoryException
Description copied from interface:Link
Set the title.- Specified by:
setTitle
in interfaceLink
- Parameters:
title
- the link title to set.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getContent
public String getContent() throws AmetysRepositoryException
Description copied from interface:Link
Get the link content.- Specified by:
getContent
in interfaceLink
- Returns:
- the link content.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setContent
public void setContent(String content) throws AmetysRepositoryException
Description copied from interface:Link
Set the content.- Specified by:
setContent
in interfaceLink
- Parameters:
content
- the link content to set.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getAlternative
public String getAlternative() throws AmetysRepositoryException
Description copied from interface:Link
Get the link alternative.- Specified by:
getAlternative
in interfaceLink
- Returns:
- the link alternative.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setAlternative
public void setAlternative(String alternative) throws AmetysRepositoryException
Description copied from interface:Link
Set the link alternative.- Specified by:
setAlternative
in interfaceLink
- Parameters:
alternative
- the link alternative to set.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getExternalPicture
public BinaryMetadata getExternalPicture() throws AmetysRepositoryException
Description copied from interface:Link
Get the picture as a binary metadata.- Specified by:
getExternalPicture
in interfaceLink
- Returns:
- the picture as a binary metadata.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setExternalPicture
public void setExternalPicture(String mimeType, String filename, InputStream stream) throws AmetysRepositoryException
Description copied from interface:Link
Set the picture from an external file.- Specified by:
setExternalPicture
in interfaceLink
- Parameters:
mimeType
- the file MIME type.filename
- the file name.stream
- an input stream on the file bytes.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getResourcePictureId
public String getResourcePictureId() throws AmetysRepositoryException
Description copied from interface:Link
Get the picture resource ID.- Specified by:
getResourcePictureId
in interfaceLink
- Returns:
- the resource ID.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setResourcePicture
public void setResourcePicture(String resourceId) throws AmetysRepositoryException
Description copied from interface:Link
Set the picture from an explorer resource.- Specified by:
setResourcePicture
in interfaceLink
- Parameters:
resourceId
- the resource ID.- Throws:
AmetysRepositoryException
- if an error occurs.
-
setNoPicture
public void setNoPicture() throws AmetysRepositoryException
Description copied from interface:Link
Removes any picture currently assigned.- Specified by:
setNoPicture
in interfaceLink
- Throws:
AmetysRepositoryException
- if an error occurs.
-
getPictureType
public String getPictureType() throws AmetysRepositoryException
Description copied from interface:Link
Get the picture type.- Specified by:
getPictureType
in interfaceLink
- Returns:
- the picture type.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setPictureType
public void setPictureType(String type) throws AmetysRepositoryException
Description copied from interface:Link
Set the picture type.- Specified by:
setPictureType
in interfaceLink
- Parameters:
type
- the picture type to set.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getPictureGlyph
public String getPictureGlyph() throws AmetysRepositoryException
Description copied from interface:Link
Get the picture glyph.- Specified by:
getPictureGlyph
in interfaceLink
- Returns:
- the picture glyph.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setPictureGlyph
public void setPictureGlyph(String glyph) throws AmetysRepositoryException
Description copied from interface:Link
Set the picture glyph.- Specified by:
setPictureGlyph
in interfaceLink
- Parameters:
glyph
- the glyph picture to set.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getPictureAlternative
public String getPictureAlternative() throws AmetysRepositoryException
Description copied from interface:Link
Get the picture alternative.- Specified by:
getPictureAlternative
in interfaceLink
- Returns:
- the picture alternative.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setPictureAlternative
public void setPictureAlternative(String alternative) throws AmetysRepositoryException
Description copied from interface:Link
Set the picture alternative.- Specified by:
setPictureAlternative
in interfaceLink
- Parameters:
alternative
- the picture alternative to set.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getThemes
public String[] getThemes() throws AmetysRepositoryException
Description copied from interface:Link
Get the themes.- Specified by:
getThemes
in interfaceLink
- Returns:
- the themes in an Array
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setThemes
public void setThemes(String[] themes) throws AmetysRepositoryException
Description copied from interface:Link
Set the themes.- Specified by:
setThemes
in interfaceLink
- Parameters:
themes
- the themes to set.- Throws:
AmetysRepositoryException
- if an error occurs.
-
removeTheme
public void removeTheme(String themeId) throws AmetysRepositoryException
Description copied from interface:Link
Remove theme if exist- Specified by:
removeTheme
in interfaceLink
- Parameters:
themeId
- The id of theme to remove- Throws:
AmetysRepositoryException
- if an error occurs
-
getSite
public Site getSite() throws AmetysRepositoryException
Description copied from interface:SiteAwareAmetysObject
Returns this object's site.- Specified by:
getSite
in interfaceSiteAwareAmetysObject
- Returns:
- this object's site
- Throws:
AmetysRepositoryException
- if an error occurs.
-
getSiteName
public String getSiteName() throws AmetysRepositoryException
Description copied from interface:SiteAwareAmetysObject
Returns this object's site name.- Specified by:
getSiteName
in interfaceSiteAwareAmetysObject
- Returns:
- this object's site name.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
getLanguage
public String getLanguage()
Get the theme language.- Returns:
- the theme language.
-
removePictureMetas
protected void removePictureMetas() throws RepositoryException
Remove all picture metas (picture ID and picture binary).- Throws:
RepositoryException
- 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.
-
moveTo
public void moveTo(AmetysObject newParent, boolean renameIfExist) throws AmetysRepositoryException, RepositoryIntegrityViolationException
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.
-
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.
-
_getListFromMetadataName
private String[] _getListFromMetadataName(String metadataName)
Retrieves the list of values corresponding to the metadata name passed as parameter- Parameters:
metadataName
- the name of the metadata to retrieve- Returns:
- the list corresponding to the metadata name
-
_setListWithMetadataName
private void _setListWithMetadataName(String[] list, String metadataName)
Sets the list of values to the node corresponding to the metadata name passed as a parameter- Parameters:
list
- the list of value to be setmetadataName
- the name of the metadata
-
getDynamicInformationProvider
public String getDynamicInformationProvider() throws AmetysRepositoryException
Description copied from interface:Link
Get the id of the provider of dynamic information.- Specified by:
getDynamicInformationProvider
in interfaceLink
- Returns:
- the id of provider. Can be null.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setDynamicInformationProvider
public void setDynamicInformationProvider(String providerId) throws AmetysRepositoryException
Description copied from interface:Link
Set the id of the provider of dynamic information.- Specified by:
setDynamicInformationProvider
in interfaceLink
- Parameters:
providerId
- the id of provider- Throws:
AmetysRepositoryException
- if an error occurs.
-
getColor
public String getColor() throws AmetysRepositoryException
Description copied from interface:Link
Get the color.- Specified by:
getColor
in interfaceLink
- Returns:
- the color.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setColor
public void setColor(String color) throws AmetysRepositoryException
Description copied from interface:Link
Set the color.- Specified by:
setColor
in interfaceLink
- Parameters:
color
- the color to set.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getPage
public String getPage() throws AmetysRepositoryException
Description copied from interface:Link
Get the page.- Specified by:
getPage
in interfaceLink
- Returns:
- the page.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setPage
public void setPage(String page) throws AmetysRepositoryException
Description copied from interface:Link
Set the page.- Specified by:
setPage
in interfaceLink
- Parameters:
page
- the page id to set.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getStatus
public Link.LinkStatus getStatus() throws AmetysRepositoryException
Description copied from interface:Link
Get the status.- Specified by:
getStatus
in interfaceLink
- Returns:
- the status.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setStatus
public void setStatus(Link.LinkStatus status) throws AmetysRepositoryException
Description copied from interface:Link
Set the status.- Specified by:
setStatus
in interfaceLink
- Parameters:
status
- the status to set.- Throws:
AmetysRepositoryException
- if an error occurs.
-
-