Copyright© 2008-2022 Sitevision AB, all rights reserved.
@Requireable(value="ArticleUtil") public interface ArticleUtil extends VelocityAccess.ArticleUtilConstants
sv:article
.
Note! This interface is used to create and update articles. You would typically use
StructureUtil
to move an article
and TrashcanUtil
to delete an article.
WebContentUtil
can be used to update the content
of an article.
Important note! Methods in this interface operates in the
VersionUtil.OFFLINE_VERSION
.
Hence, if you create an article, updates the name of a article or such, the article must be published
(see PublishingUtil
)
to have any effect in the VersionUtil.ONLINE_VERSION
An instance of the Sitevision class implementing this interface can be obtained via
Utils.getArticleUtil()
.
See Utils
for how to obtain an instance of the Utils
interface.
Modifier and Type | Field and Description |
---|---|
static String |
PROPERTY_CREATED_BY
Name of the property specifying the creator of an article.
|
static String |
PROPERTY_CREATION_DATE
Name of the property specifying the creation date of an article.
|
static String |
PROPERTY_LAST_MODIFIED_BY
Name of the property specifying the last modifier of an article.
|
static String |
PROPERTY_LAST_MODIFIED_DATE
Name of the property specifying the last modified date of an article.
|
static String |
PROPERTY_LAST_PUBLISH_DATE
Name of the property specifying the last published date of an article.
|
static String |
PROPERTY_LAST_PUBLISHED_BY
Name of the property specifying the last publisher of an article.
|
static String |
PROPERTY_LOCALE
Name of the property specifying the locale used by an article.
|
static String |
PROPERTY_PUBLISH_DATE
Name of the property specifying the published date of an article.
|
static String |
PROPERTY_PUBLISHED_BY
Name of the property specifying the publisher of an article.
|
static String |
PROPERTY_ROBOTS_INDEX
Name of the property specifying if an article is indexable.
|
static String |
PROPERTY_SHORTID
Name of the property specifying the short id of an article.
|
static String |
PROPERTY_VISIBLE_IN_MENUS
Name of the property specifying if an article is visible in menus.
|
Modifier and Type | Method and Description |
---|---|
Node |
createArticle(Node aParent,
Node aTemplate,
String aName)
Creates an article as sub node to a specified parent.
|
Node |
createArticle(Node aParent,
Node aTemplate,
String aName,
Map<String,Object> properties,
Map<String,String> content)
Creates an article with properties and web content.
|
void |
renameArticle(Node anArticle,
String aName)
Alters the name of an article.
|
void |
updateArticle(Node anArticle,
Map<String,Object> properties)
Updates the properties of an article.
|
getPROPERTY_CREATED_BY, getPROPERTY_CREATION_DATE, getPROPERTY_LAST_MODIFIED_BY, getPROPERTY_LAST_MODIFIED_DATE, getPROPERTY_LAST_PUBLISH_DATE, getPROPERTY_LAST_PUBLISHED_BY, getPROPERTY_LOCALE, getPROPERTY_PUBLISH_DATE, getPROPERTY_PUBLISHED_BY, getPROPERTY_ROBOTS_INDEX, getPROPERTY_SHORTID, getPROPERTY_VISIBLE_IN_MENUS
static final String PROPERTY_VISIBLE_IN_MENUS
visibleInMenus
.
The property value must be of type Boolean
.
static final String PROPERTY_SHORTID
shortId
.
The property value must be of type String
.
static final String PROPERTY_LOCALE
locale
.
The property value must be of type Locale
or a String
that can be resolved to a non-null Locale
via LocaleUtil.getLocaleByString(String)
.
static final String PROPERTY_ROBOTS_INDEX
robotsIndex
.
The property value must be of type Boolean
.
static final String PROPERTY_CREATION_DATE
creationDate
.
The property value must be of type Date
or a String
on format yyyy-MM-dd HH:mm:ss where
HH:mm:ss is optional (defaults to 00:00:00).
static final String PROPERTY_CREATED_BY
createdBy
.
The property value must be a Node
with primary node type sv:user or sv:systemUser.
static final String PROPERTY_LAST_MODIFIED_DATE
lastModifiedDate
.
The property value must be of type Date
or a String
on format yyyy-MM-dd HH:mm:ss, where
HH:mm:ss is optional (defaults to 00:00:00).
static final String PROPERTY_LAST_MODIFIED_BY
lastModifiedBy
.
The property value must be a Node
with primary node type sv:user or sv:systemUser.
static final String PROPERTY_LAST_PUBLISH_DATE
lastPublishDate
.
The property value must be of type Date
or a String
on format yyyy-MM-dd HH:mm:ss, where
HH:mm:ss is optional (defaults to 00:00:00).
static final String PROPERTY_LAST_PUBLISHED_BY
lastPublishedBy
.
The property value must be a Node
with primary node type sv:user or sv:systemUser.
static final String PROPERTY_PUBLISH_DATE
publishDate
.
The property value must be of type Date
or a String
on format yyyy-MM-dd HH:mm:ss, where
HH:mm:ss is optional (defaults to 00:00:00).
static final String PROPERTY_PUBLISHED_BY
publishedBy
.
The property value must be a Node
with primary node type sv:user or sv:systemUser.
Node createArticle(Node aParent, Node aTemplate, String aName) throws RepositoryException
Creates an article as sub node to a specified parent. The parent must be a node with primary
node type sv:archive. If other parent is specified a ConstraintViolationException
is thrown.
Any name can be given a article, it should however not contain the character '/'.
If no parent, no template or no name is specified a NullPointerException
is thrown.
The current user must be authorized to create pages, layouts and to do write operations on the parent node. A
ConstraintViolationException
will be thrown if not.
Note that a new article inherits metadata and permissions from its parent.
Use WebContentUtil.updateContent(javax.jcr.Node, java.util.Map)
to add content to the new article.
aParent
- the parent node of the article. May not be null
aTemplate
- the template used for the article. May not be null
aName
- the name of the sv:article. May not be null
null
ConstraintViolationException
- if an invalid parent is specified or if the current user
is not authorized to create the articleRepositoryException
- if something else goes wrongcreateArticle(javax.jcr.Node, javax.jcr.Node, String, java.util.Map, java.util.Map)
Node createArticle(Node aParent, Node aTemplate, String aName, Map<String,Object> properties, Map<String,String> content) throws RepositoryException
Creates an article with properties and web content. The parent must be a node with primary node type sv:archive.
If other parent is specified a ConstraintViolationException
is thrown. It is possible to provide the web content for the article
as well as article properties.
Properties:
PROPERTY_VISIBLE_IN_MENUS
PROPERTY_SHORTID
- If the short id is already used by an other Sitevision node an IllegalArgumentException
is thrown
PROPERTY_LOCALE
PROPERTY_ROBOTS_INDEX
PROPERTY_CREATION_DATE
PROPERTY_CREATED_BY
PROPERTY_LAST_MODIFIED_DATE
PROPERTY_LAST_MODIFIED_BY
PROPERTY_LAST_PUBLISH_DATE
PROPERTY_LAST_PUBLISHED_BY
PROPERTY_PUBLISH_DATE
PROPERTY_PUBLISHED_BY
If an invalid value is provided for a property, an IllegalArgumentException
is thrown
Default values:
PROPERTY_VISIBLE_IN_MENUS
- truePROPERTY_SHORTID
- "" (a short id will be generated by Sitevision)PROPERTY_LOCALE
- parent localePROPERTY_ROBOTS_INDEX
- truePROPERTY_CREATION_DATE
- current time stampPROPERTY_CREATED_BY
- current userPROPERTY_LAST_MODIFIED_DATE
- current time stampPROPERTY_LAST_MODIFIED_BY
- current userPROPERTY_LAST_PUBLISH_DATE
- null (will not have a value)PROPERTY_LAST_PUBLISHED_BY
- null (will not have a value)PROPERTY_PUBLISH_DATE
- null (will not have a value)PROPERTY_PUBLISHED_BY
- null (will not have a value)The article content is specified using the
content map containing keys corresponding to layout names (e.g. "mittenspalt") on the articel and values containing the
HTML used to generate a portlet structure in the layout. The provided content is converted to
Sitevision text, table and image modules. It is also possible to specify that a horizontal or a vertical
layout should be created. For more information about the HTML to portlet mapping can be found in the
WebContentUtil
javadoc.
If no parent, no template or no name is specified a NullPointerException
is thrown.
The current user must be authorized to create pages, layouts and to do write operations on the parent node or
a ConstraintViolationException
will be thrown.
Note that a new page inherits metadata and permissions from its parent.
aParent
- the parent node of the article. May not be null
aTemplate
- the sv:template node to be used for the article. May not be null
aName
- the name of the sv:article. May not be null
properties
- the article properties. May be null
content
- a map containing the HTML content. The keys must correspond to layout names on the node. May be null
null
ConstraintViolationException
- if an invalid parent is specified or if the current user
is not authorized to create the articleRepositoryException
- if something else goes wrongcreateArticle(javax.jcr.Node, javax.jcr.Node, String)
void updateArticle(Node anArticle, Map<String,Object> properties) throws RepositoryException
Updates the properties of an article. If no article is specified a NullPointerException
is thrown. If the node is not a sv:article an IllegalArgumentException
is thrown.
Properties:
PROPERTY_VISIBLE_IN_MENUS
PROPERTY_SHORTID
- If the short id is already used by an other Sitevision node an IllegalArgumentException
is thrown
PROPERTY_LOCALE
PROPERTY_ROBOTS_INDEX
PROPERTY_CREATION_DATE
PROPERTY_CREATED_BY
PROPERTY_LAST_MODIFIED_DATE
PROPERTY_LAST_MODIFIED_BY
PROPERTY_LAST_PUBLISH_DATE
PROPERTY_LAST_PUBLISHED_BY
PROPERTY_PUBLISH_DATE
PROPERTY_PUBLISHED_BY
If an invalid value is provided for a property, an IllegalArgumentException
is thrown.
The current user must be authorized to do write operations on the article or
a ConstraintViolationException
will be thrown.
If no properties map is specified a NullPointerException
is thrown.
anArticle
- the sv:article that will be altered. May not be null
properties
- the article properties. May not be null
ConstraintViolationException
- if the current user is not authorized to alter the articleRepositoryException
- if something else goes wrongvoid renameArticle(Node anArticle, String aName) throws ConstraintViolationException, RepositoryException
Alters the name of an article. If no article is specified a NullPointerException
is thrown. If the node is not an sv:article an IllegalArgumentException
is thrown.
Any name can be given an article, it should however not contain the character '/'. If null is
provided a NullPointerException
is thrown.
The current user must be authorized to do write operations on the article or
a ConstraintViolationException
will be thrown.
anArticle
- the article that should be renamed. May not be null
aName
- the new name of the article. May not be null
ConstraintViolationException
- if the current user is not authorized to alter the name of the
articleRepositoryException
- if something else goes wrongSitevision - Portal and Content Management Made Easy
Sitevision is an advanced Java enterprise portal product and a portlet container (JSR 286) that implements Java Content Repository (JSR 283).
Copyright© 2008-2022 Sitevision AB, all rights reserved.