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
AmetysObject
for storing site informations.
-
-
Field Summary
Fields Modifier and Type Field Description static String
ILLUSTRATION_PARAMETER
Parameter name for project's site illustrationstatic String
NODE_TYPE
Site 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 Sitemap
addSitemap(String lang)
Add a sitemap language to the siteboolean
canMoveTo(AmetysObject newParent)
Test if a move can be a success or if it is impossible (e.g.Site
copyTo(ModifiableTraversableAmetysObject parent, String name)
Copy the currentAmetysObject
to the given object.AmetysObject
copyTo(ModifiableTraversableAmetysObject parent, String name, List<String> restrictTo)
Copy the currentAmetysObject
to 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.String
getColor()
Retrieves the colorAmetysObjectIterable<Content>
getContents()
Retrieves contents.ModifiableModelAwareDataHolder
getDataHolder()
Returns theDataHolder
of thisAmetysObject
.String
getDescription()
Retrieves the description.Binary
getIllustration()
Returns the illustration of the siteSite
getParentSite()
Returns the parent site, if any.AmetysObjectIterable<AmetysObject>
getResources()
Retrieves resources.RestrictedPagePolicy
getRestrictedPagePolicy()
Returns theRestrictedPagePolicy
associated with this Site.ModifiableTraversableAmetysObject
getRootContents()
Retrieves root contents.ModifiableTraversableAmetysObject
getRootPlugins()
Get the root for pluginsModifiableTraversableAmetysObject
getRootResources()
Retrieves root resources.Site
getSite(String siteName)
Returns the namedSite
.Sitemap
getSitemap(String sitemapName)
Retrieves a sitemap.AmetysObjectIterable<Sitemap>
getSitemaps()
Retrieves sitemaps.String
getSitePath()
Returns the site pathString
getSkinId()
Returns the skin id for this site.String
getTitle()
Retrieves the title.String
getType()
Retrieves the type.String
getUrl()
Retrieves the main url.String[]
getUrlAliases()
Retrieves the url aliases.boolean
hasAncestor(String siteName)
Return true if the given site if an ancestorboolean
hasChildrenSite(String siteName)
Returns true if the given site exists.boolean
hasDescendant(String siteName)
Return true if the given site if a descendantboolean
hasSitemap(String lang)
Determines the existence of a sitemapvoid
illustrationToSAX(ContentHandler contentHandler)
Generates SAX events for the site's illustrationvoid
moveTo(AmetysObject newParent, boolean renameIfExist)
Move the current object as a new child of the given object.void
orderBefore(AmetysObject siblingNode)
Order a node before another sibling node (or as the last node)void
remove()
Removes thisAmetysObject
from the Ametys tree.void
setDescription(String description)
Set the description.void
setIllustration(InputStream is, String mimeType, String filename, ZonedDateTime lastModificationDate)
Set the illustration of the sitevoid
setSkinId(String skinId)
Set the skin id for this site.void
setTitle(String title)
Set the title.void
setType(String type)
Set the type.void
setUrl(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, hasExternalValueOrEmpty, hasLocalValue, hasLocalValueOrEmpty, hasValue, hasValueOrEmpty
-
Methods inherited from interface org.ametys.plugins.repository.data.holder.ModelAwareDataHolder
commentsToSAX, dataToMap, dataToMap, dataToMap, dataToMap, dataToSAX, dataToSAX, dataToSAX, dataToSAX, dataToSAXForEdition, getDataNames, getType, getValue, hasValue, hasValueOrEmpty, 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, removeExternalizableMetadataIfExists, 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
-
-
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
- theSiteFactory
which 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 theRestrictedPagePolicy
associated with this Site.- Returns:
- the
RestrictedPagePolicy
associated 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
- theContentHandler
that 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:RemovableAmetysObject
Removes thisAmetysObject
from the Ametys tree.- Specified by:
remove
in interfaceRemovableAmetysObject
- Overrides:
remove
in classSimpleAmetysObject<SiteFactory>
- Throws:
AmetysRepositoryException
- if an error occurs.RepositoryIntegrityViolationException
- if thisAmetysObject
is referenced by another objects.
-
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, 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.
-
copyTo
public Site copyTo(ModifiableTraversableAmetysObject parent, String name) throws AmetysRepositoryException
Description copied from interface:CopiableAmetysObject
Copy the currentAmetysObject
to the given object. Be careful, this method save changes.- Specified by:
copyTo
in 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:CopiableAmetysObject
Copy the currentAmetysObject
to the given object if it is not in the restriction list. Be careful, this method save changes.- Specified by:
copyTo
in 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 ofCopiableAmetysObject
authorized to be copied- Returns:
- the created object
- Throws:
AmetysRepositoryException
- if an error occurs.
-
orderBefore
public void orderBefore(AmetysObject siblingNode) 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:
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:DataAwareAmetysObject
Returns theDataHolder
of thisAmetysObject
.- Specified by:
getDataHolder
in interfaceDataAwareAmetysObject
- Specified by:
getDataHolder
in interfaceModelAwareDataAwareAmetysObject
- Specified by:
getDataHolder
in interfaceModifiableModelAwareDataAwareAmetysObject
- Returns:
- the
DataHolder
of thisAmetysObject
-
-