Package org.ametys.web.repository.site
Class Site
-
- All Implemented Interfaces:
ACLAmetysObject,AmetysObject,CopiableAmetysObject,DataAwareAmetysObject,ModelAwareDataAwareAmetysObject,ModifiableModelAwareDataAwareAmetysObject,DataHolder,ModelAwareDataHolder,ModifiableDataHolder,ModifiableModelAwareDataHolder,JCRAmetysObject,JCRTraversableAmetysObject,MetadataAwareAmetysObject,ModifiableMetadataAwareAmetysObject,ModifiableACLAmetysObject,ModifiableAmetysObject,ModifiableTraversableAmetysObject,MovableAmetysObject,RemovableAmetysObject,TraversableAmetysObject
public final class Site extends DefaultTraversableAmetysObject<SiteFactory> implements MovableAmetysObject, CopiableAmetysObject, ModifiableModelAwareDataAwareAmetysObject
AmetysObjectfor storing site informations.
-
-
Field Summary
Fields Modifier and Type Field Description private static String__COLOR_PARAMETERConstants for color metadata.private static String__CONTENTS_NODE_NAMEConstants for contents node name.private static String__DESCRIPTION_PARAMETERConstants for description metadata.private static String__DISPLAY_RESTRICTED_PAGES_PARAMETERConstants for restricted page policy metadata.private static String__PLUGINS_NODE_NAMEConstants for plugins node name.private static String__RESOURCES_NODE_NAMEConstants for resources node name.private static String__SITEMAPS_NODE_NAMEConstants for sitemaps node name.private static String__SKIN_PARAMETERConstants for skin metadata.private static String__TITLE_PARAMETERConstants for title metadata.private static String__TYPE_PARAMETERConstants for type metadata.private static String__URL_PARAMETERConstants for URL metadata.static StringILLUSTRATION_PARAMETERParameter name for project's site illustrationstatic StringNODE_TYPESite node type name.-
Fields inherited from interface org.ametys.plugins.repository.data.holder.ModelAwareDataHolder
ALTERNATIVE_SUFFIX, COMMENTS_SUFFIX, STATUS_SUFFIX
-
-
Constructor Summary
Constructors Constructor Description Site(Node node, String parentPath, SiteFactory factory)Creates aSite.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private String[]_getHashedPath(String name)private Node_getParentNode(ModifiableTraversableAmetysObject parent, String siteName)SitemapaddSitemap(String lang)Add a sitemap language to the sitebooleancanMoveTo(AmetysObject newParent)Test if a move can be a success or if it is impossible (e.g.SitecopyTo(ModifiableTraversableAmetysObject parent, String name)Copy the currentAmetysObjectto the given object.AmetysObjectcopyTo(ModifiableTraversableAmetysObject parent, String name, List<String> restrictTo)Copy the currentAmetysObjectto the given object if it is not in the restriction list.Collection<String>getChildrenSiteNames()Returns the sites names.AmetysObjectIterable<Site>getChildrenSites()Returns all children sites, or empty if none.StringgetColor()Retrieves the colorAmetysObjectIterable<Content>getContents()Retrieves contents.ModifiableModelAwareDataHoldergetDataHolder()Returns theDataHolderof thisAmetysObject.StringgetDescription()Retrieves the description.BinarygetIllustration()Returns the illustration of the siteSitegetParentSite()Returns the parent site, if any.AmetysObjectIterable<AmetysObject>getResources()Retrieves resources.RestrictedPagePolicygetRestrictedPagePolicy()Returns theRestrictedPagePolicyassociated with this Site.ModifiableTraversableAmetysObjectgetRootContents()Retrieves root contents.ModifiableTraversableAmetysObjectgetRootPlugins()Get the root for pluginsModifiableTraversableAmetysObjectgetRootResources()Retrieves root resources.SitegetSite(String siteName)Returns the namedSite.SitemapgetSitemap(String sitemapName)Retrieves a sitemap.AmetysObjectIterable<Sitemap>getSitemaps()Retrieves sitemaps.StringgetSitePath()Returns the site pathStringgetSkinId()Returns the skin id for this site.StringgetTitle()Retrieves the title.StringgetType()Retrieves the type.StringgetUrl()Retrieves the main url.String[]getUrlAliases()Retrieves the url aliases.booleanhasAncestor(String siteName)Return true if the given site if an ancestorbooleanhasChildrenSite(String siteName)Returns true if the given site exists.booleanhasDescendant(String siteName)Return true if the given site if a descendantbooleanhasSitemap(String lang)Determines the existence of a sitemapvoidillustrationToSAX(ContentHandler contentHandler)Generates SAX events for the site's illustrationvoidmoveTo(AmetysObject newParent, boolean renameIfExist)Move the current object as a new child of the given object.voidorderBefore(AmetysObject siblingNode)Order a node before another sibling node (or as the last node)voidremove()Removes thisAmetysObjectfrom the Ametys tree.voidsetDescription(String description)Set the description.voidsetIllustration(InputStream is, String mimeType, String filename, ZonedDateTime lastModificationDate)Set the illustration of the sitevoidsetSkinId(String skinId)Set the skin id for this site.voidsetTitle(String title)Set the title.voidsetType(String type)Set the type.voidsetUrl(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, getChild, getChildren, getProfilesForAnonymousAndAnyConnectedUser, getProfilesForGroups, getProfilesForUsers, 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, 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.data.ametysobject.DataAwareAmetysObject
copyTo, dataToSAX, dataToSAX
-
Methods inherited from interface org.ametys.plugins.repository.jcr.JCRAmetysObject
getNode
-
Methods inherited from interface org.ametys.plugins.repository.data.ametysobject.ModelAwareDataAwareAmetysObject
getComments, getDataNames, getDefinition, getExternalValue, getLocalValue, getModel, getStatus, getValue, getValue, hasComments, hasDefinition, hasExternalValue, hasLocalValue, hasNonEmptyExternalValue, hasNonEmptyLocalValue, hasNonEmptyValue, hasValue
-
Methods inherited from interface org.ametys.plugins.repository.data.holder.ModelAwareDataHolder
commentsToSAX, dataToMap, dataToMap, dataToMap, dataToMap, dataToSAX, dataToSAX, dataToSAX, dataToSAX, dataToSAXForEdition, getDataNames, getType, getValue, hasNonEmptyValue, hasValue, isMultiple
-
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.data.ametysobject.ModifiableModelAwareDataAwareAmetysObject
getComposite, getComposite, getExternalComposite, getExternalComposite, getExternalRepeater, getExternalRepeater, getLocalComposite, getLocalComposite, getLocalRepeater, getLocalRepeater, getParentDataHolder, getRepeater, getRepeater, getRepositoryData, getRootDataHolder, removeExternalValue, removeLocalValue, removeValue, setComments, setExternalValue, setLocalValue, setStatus, setValue, synchronizeValues, synchronizeValues, synchronizeValues, synchronizeValues
-
Methods inherited from interface org.ametys.plugins.repository.TraversableAmetysObject
getChildAt, getChildPosition
-
-
-
-
Field Detail
-
NODE_TYPE
public static final String NODE_TYPE
Site node type name.- See Also:
- Constant Field Values
-
ILLUSTRATION_PARAMETER
public static final String ILLUSTRATION_PARAMETER
Parameter name for project's site illustration- See Also:
- Constant Field Values
-
__TITLE_PARAMETER
private static final String __TITLE_PARAMETER
Constants for title metadata.- See Also:
- Constant Field Values
-
__TYPE_PARAMETER
private static final String __TYPE_PARAMETER
Constants for type metadata.- See Also:
- Constant Field Values
-
__DESCRIPTION_PARAMETER
private static final String __DESCRIPTION_PARAMETER
Constants for description metadata.- See Also:
- Constant Field Values
-
__URL_PARAMETER
private static final String __URL_PARAMETER
Constants for URL metadata.- See Also:
- Constant Field Values
-
__COLOR_PARAMETER
private static final String __COLOR_PARAMETER
Constants for color metadata.- See Also:
- Constant Field Values
-
__SKIN_PARAMETER
private static final String __SKIN_PARAMETER
Constants for skin metadata.- See Also:
- Constant Field Values
-
__DISPLAY_RESTRICTED_PAGES_PARAMETER
private static final String __DISPLAY_RESTRICTED_PAGES_PARAMETER
Constants for restricted page policy metadata.- See Also:
- Constant Field Values
-
__SITEMAPS_NODE_NAME
private static final String __SITEMAPS_NODE_NAME
Constants for sitemaps node name.- See Also:
- Constant Field Values
-
__CONTENTS_NODE_NAME
private static final String __CONTENTS_NODE_NAME
Constants for contents node name.- See Also:
- Constant Field Values
-
__RESOURCES_NODE_NAME
private static final String __RESOURCES_NODE_NAME
Constants for resources node name.- See Also:
- Constant Field Values
-
__PLUGINS_NODE_NAME
private static final String __PLUGINS_NODE_NAME
Constants for plugins node name.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Site
public Site(Node node, String parentPath, SiteFactory factory)
Creates aSite.- Parameters:
node- the node backing thisAmetysObject.parentPath- the parent path in the Ametys hierarchy.factory- theSiteFactorywhich creates the AmetysObject.
-
-
Method Detail
-
getTitle
public String getTitle() throws AmetysRepositoryException
Retrieves the title.- Returns:
- the title.
- Throws:
AmetysRepositoryException- if an error occurs.
-
getType
public String getType() throws AmetysRepositoryException
Retrieves the type.- Returns:
- the type.
- Throws:
AmetysRepositoryException- if an error occurs.
-
setType
public void setType(String type) throws AmetysRepositoryException
Set the type.- Parameters:
type- the type.- Throws:
AmetysRepositoryException- if another error occurs.
-
setTitle
public void setTitle(String title) throws AmetysRepositoryException
Set the title.- Parameters:
title- the title.- Throws:
AmetysRepositoryException- if another error occurs.
-
getDescription
public String getDescription() throws AmetysRepositoryException
Retrieves the description.- Returns:
- the description.
- Throws:
AmetysRepositoryException- if an error occurs.
-
setDescription
public void setDescription(String description) throws AmetysRepositoryException
Set the description.- Parameters:
description- the description.- Throws:
AmetysRepositoryException- if an error occurs.
-
getUrl
public String getUrl() throws AmetysRepositoryException
Retrieves the main url.- Returns:
- the main url.
- Throws:
AmetysRepositoryException- if an error occurs.
-
getUrlAliases
public String[] getUrlAliases() throws AmetysRepositoryException
Retrieves the url aliases.- Returns:
- the url.
- Throws:
AmetysRepositoryException- if an error occurs.
-
setUrl
public void setUrl(String url) throws AmetysRepositoryException
Set the url.- Parameters:
url- the url.- Throws:
AmetysRepositoryException- if an error occurs.
-
getColor
public String getColor() throws AmetysRepositoryException
Retrieves the color- Returns:
- The color.
- Throws:
AmetysRepositoryException- if an error occurs.
-
getSitemap
public Sitemap getSitemap(String sitemapName) throws AmetysRepositoryException, UnknownAmetysObjectException
Retrieves a sitemap.- Parameters:
sitemapName- the sitemap name.- Returns:
- the sitemap found.
- Throws:
AmetysRepositoryException- if an error occurs.UnknownAmetysObjectException- if the object does not exist.
-
hasSitemap
public boolean hasSitemap(String lang) throws AmetysRepositoryException
Determines the existence of a sitemap- Parameters:
lang- The sitemap language- Returns:
- true if the sitemap exists
- Throws:
AmetysRepositoryException- if an error occurred
-
addSitemap
public Sitemap addSitemap(String lang) throws AmetysRepositoryException
Add a sitemap language to the site- Parameters:
lang- The sitemap language- Returns:
- The created sitemap
- Throws:
AmetysRepositoryException- if an error occurred or if the sitemap already exists
-
getSitemaps
public AmetysObjectIterable<Sitemap> getSitemaps() throws AmetysRepositoryException
Retrieves sitemaps.- Returns:
- the sitemaps or an empty
AmetysObjectIterable. - Throws:
AmetysRepositoryException- if an error occurs.
-
getRootContents
public ModifiableTraversableAmetysObject getRootContents() throws AmetysRepositoryException
Retrieves root contents.- Returns:
- the root for contents
- Throws:
AmetysRepositoryException- if an error occurs.
-
getContents
public AmetysObjectIterable<Content> getContents() throws AmetysRepositoryException
Retrieves contents.- Returns:
- the contents or an empty
AmetysObjectIterable. - Throws:
AmetysRepositoryException- if an error occurs.
-
getRootResources
public ModifiableTraversableAmetysObject getRootResources() throws AmetysRepositoryException
Retrieves root resources.- Returns:
- the root for resources
- Throws:
AmetysRepositoryException- if an error occurs.
-
getResources
public AmetysObjectIterable<AmetysObject> getResources() throws AmetysRepositoryException
Retrieves resources.- Returns:
- the resources or an empty
AmetysObjectIterable. - Throws:
AmetysRepositoryException- if an error occurs.
-
getRootPlugins
public ModifiableTraversableAmetysObject getRootPlugins() throws AmetysRepositoryException
Get the root for plugins- Returns:
- the root for plugins
- Throws:
AmetysRepositoryException- if an error occurs.
-
setSkinId
public void setSkinId(String skinId)
Set the skin id for this site.- Parameters:
skinId- ths skin id
-
getSkinId
public String getSkinId()
Returns the skin id for this site.- Returns:
- the skin id for this site.
-
getParentSite
public Site getParentSite()
Returns the parent site, if any.- Returns:
- the parent site, if any.
-
getSitePath
public String getSitePath()
Returns the site path- Returns:
- the site path
-
getRestrictedPagePolicy
public RestrictedPagePolicy getRestrictedPagePolicy()
Returns theRestrictedPagePolicyassociated with this Site.- Returns:
- the
RestrictedPagePolicyassociated with this Site.
-
getSite
public Site getSite(String siteName) throws UnknownAmetysObjectException
Returns the namedSite.- Parameters:
siteName- the site name.- Returns:
- the named
Site. - Throws:
UnknownAmetysObjectException- if the named site does not exist.
-
hasAncestor
public boolean hasAncestor(String siteName)
Return true if the given site if an ancestor- Parameters:
siteName- the site name.- Returns:
- true if the given site if an ancestor
-
hasDescendant
public boolean hasDescendant(String siteName)
Return true if the given site if a descendant- Parameters:
siteName- the site name.- Returns:
- true if the given site if a descendant
-
hasChildrenSite
public boolean hasChildrenSite(String siteName)
Returns true if the given site exists.- Parameters:
siteName- the site name.- Returns:
- true if the given site exists.
-
getChildrenSiteNames
public Collection<String> getChildrenSiteNames()
Returns the sites names.- Returns:
- the sites names.
-
getChildrenSites
public AmetysObjectIterable<Site> getChildrenSites() throws AmetysRepositoryException
Returns all children sites, or empty if none.- Returns:
- all children sites, or empty if none.
- Throws:
AmetysRepositoryException- if an error occurs
-
getIllustration
public Binary getIllustration()
Returns the illustration of the site- Returns:
- the illustration of the site
-
illustrationToSAX
public void illustrationToSAX(ContentHandler contentHandler) throws SAXException, IOException
Generates SAX events for the site's illustration- Parameters:
contentHandler- theContentHandlerthat will receive the SAX events- Throws:
SAXException- if error occurs during the SAX events generationIOException- if an I/O error occurs while reading the illustration
-
setIllustration
public void setIllustration(InputStream is, String mimeType, String filename, ZonedDateTime lastModificationDate) throws IOException
Set the illustration of the site- Parameters:
is- The input stream of the illustrationmimeType- The mime type of the illustrationfilename- The filename of the illustrationlastModificationDate- The last modification date of the illustration- Throws:
IOException- if an error occurs while setting the illustration
-
remove
public void remove() throws AmetysRepositoryException, RepositoryIntegrityViolationException
Description copied from interface:RemovableAmetysObjectRemoves thisAmetysObjectfrom the Ametys tree.- Specified by:
removein interfaceRemovableAmetysObject- Overrides:
removein classSimpleAmetysObject<SiteFactory>- Throws:
AmetysRepositoryException- if an error occurs.RepositoryIntegrityViolationException- if thisAmetysObjectis referenced by another objects.
-
canMoveTo
public boolean canMoveTo(AmetysObject newParent) throws AmetysRepositoryException
Description copied from interface:MovableAmetysObjectTest if a move can be a success or if it is impossible (e.g. due to the implementation of the target)- Specified by:
canMoveToin 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, RepositoryIntegrityViolationException
Description copied from interface:MovableAmetysObjectMove 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:
moveToin 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.
-
copyTo
public Site copyTo(ModifiableTraversableAmetysObject parent, String name) throws AmetysRepositoryException
Description copied from interface:CopiableAmetysObjectCopy the currentAmetysObjectto the given object. Be careful, this method save changes.- Specified by:
copyToin interfaceCopiableAmetysObject- Parameters:
parent- The parent of the new object. Can not be null.name- Name of the new object. Can be null. If null, the new name will be get from the copied object- Returns:
- the created object
- Throws:
AmetysRepositoryException- if an error occurs.
-
copyTo
public AmetysObject copyTo(ModifiableTraversableAmetysObject parent, String name, List<String> restrictTo) throws AmetysRepositoryException
Description copied from interface:CopiableAmetysObjectCopy the currentAmetysObjectto the given object if it is not in the restriction list. Be careful, this method save changes.- Specified by:
copyToin interfaceCopiableAmetysObject- Parameters:
parent- The parent of the new object. Can not be null.name- Name of the new object. Can be null. If null, the new name will be get from the copied objectrestrictTo- A restrict list ofCopiableAmetysObjectauthorized to be copied- Returns:
- the created object
- Throws:
AmetysRepositoryException- if an error occurs.
-
_getParentNode
private Node _getParentNode(ModifiableTraversableAmetysObject parent, String siteName) throws AmetysRepositoryException
- Throws:
AmetysRepositoryException
-
_getHashedPath
private String[] _getHashedPath(String name)
-
orderBefore
public void orderBefore(AmetysObject siblingNode) throws AmetysRepositoryException
Description copied from interface:MovableAmetysObjectOrder a node before another sibling node (or as the last node)- Specified by:
orderBeforein interfaceMovableAmetysObject- Parameters:
siblingNode- 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.
-
getDataHolder
public ModifiableModelAwareDataHolder getDataHolder()
Description copied from interface:DataAwareAmetysObjectReturns theDataHolderof thisAmetysObject.- Specified by:
getDataHolderin interfaceDataAwareAmetysObject- Specified by:
getDataHolderin interfaceModelAwareDataAwareAmetysObject- Specified by:
getDataHolderin interfaceModifiableModelAwareDataAwareAmetysObject- Returns:
- the
DataHolderof thisAmetysObject
-
-