public class CSContributorActions extends CSItem
The CSContributorActions
class only identifies the set of actions that a specific site user may
perform on a specific article. Both the user and the article must be specified via their respective accessor methods
before the set of possible actions that may be taken on that article may be retrieved.
All database access/connectivity is handled internally by the CSContributorActions
class.
EXAMPLES
If the (site) user is allowed to edit the article, take some appropriate action :
try
{
CSContributorActions caContributor = new CSContributorActions("dbprops.dat");
caContributor.setSiteUserID( nLoggedInUserID );
caContributor.setArticleID( nCurrentArticleID );
caContributor.get();
String strAllowedActions = caContributor.getActions();
if (strAllowedActions.indexOf( CSContributor.ACTION_EDIT ) >= 0)
{
// Do editing actions...
}
}
catch ( CSException e )
{
System.err.println("ERROR : " + e.getMessage());
}
CSUser
,
CSArticle
,
Serialized FormModifier and Type | Field and Description |
---|---|
static java.lang.String |
ACTION_ADDCHILD
A string value that may be returned by the
getActions method. |
static java.lang.String |
ACTION_ADDSIBLING
A string value that may be returned by the
getActions method. |
static java.lang.String |
ACTION_DELETE
A string value that may be returned by the
getActions method. |
static java.lang.String |
ACTION_EDIT
A string value that may be returned by the
getActions method. |
ACCESS_GRANTED, DOES_NOT_EXIST, EMPTY, EXISTS, SECURE_ACCESS_DENIED, SECURE_ACCESS_GRANTED, UPDATE_ACTION_INSERTED, UPDATE_ACTION_UPDATED
LEVEL_ALL, LEVEL_ALL_PLUS_RELATED, LEVEL_DETAIL, LEVEL_ID, LEVEL_SUMMARY
Constructor and Description |
---|
CSContributorActions()
Creates an empty
CSContributorActions object. |
CSContributorActions(java.lang.String strPropertyFile)
Creates an empty
CSContributorActions object, specifying a property file that contains all of the
database connection details. |
Modifier and Type | Method and Description |
---|---|
void |
get()
Retrieves the allowed contributor actions from the database.
|
java.lang.String |
getActions()
Gets the set of actions that the specified user may perform on the specified article.
|
int |
getArticleID()
Gets the ID of the article currently specified as key information.
|
int |
getSiteUserID()
Gets the ID of the site user currently specified as key information.
|
void |
setArticleID(int nArticleID)
Sets the article ID to be used as key information.
|
void |
setDetailLevel(int nDetailLevel)
Sets the level of detail to be handled by the
get method. |
void |
setSiteUserID(int nUserID)
Sets the user ID to be used as key information.
|
java.lang.String |
toString()
Outputs the contents of this
CSContributorActions object to a String object in a
user-friendly format. |
delete, equals, exist, getID, getStatus, hashCode, jsonString, serialiseWithTypes, setID, setStatus, unset, update
clearRecordedGatewayMessages, clone, count, getCache, getCachingEnabled, getDatabaseVersion, getDatabaseVersion, getDebugOutput, getDetailLevel, getPreview, getPropertyFile, getPropertyFileExtension, getPropertyFilePathname, getRecordedGatewayMessages, getRecordGatewayMessages, getSendGatewayMessages, getUseCache, setDebugOutput, setPreview, setPropertyFile, setRecordGatewayMessages, setSendGatewayMessages, setUseCache
public static final java.lang.String ACTION_ADDSIBLING
getActions
method.
ACTION_ADDSIBLING
indicates that the user is permitted to add sibling articles to the specified
article.public static final java.lang.String ACTION_ADDCHILD
getActions
method. ACTION_ADDCHILD
indicates that the user is permitted to add child articles to the specified article.public static final java.lang.String ACTION_EDIT
getActions
method. ACTION_EDIT
indicates that the user is permitted to edit the specified article.public static final java.lang.String ACTION_DELETE
getActions
method. ACTION_DELETE
indicates that the user is permitted to delete the specified article.public CSContributorActions()
CSContributorActions
object.
Use the various set methods provided to initialise the CSContributorActions
object prior to
invoking its query method.
public CSContributorActions(java.lang.String strPropertyFile)
CSContributorActions
object, specifying a property file that contains all of the
database connection details.
Use the various set methods provided to initialise the CSContributorActions
object prior to
invoking any of its query method.
strPropertyFile
- the name of the property file from which the database connection details are to be read.public void setDetailLevel(int nDetailLevel) throws CSParameterException
get
method.
Valid detail levels for a user are :
LEVEL_ALL - get all possible actions on the specified article
.
setDetailLevel
in class CSDatabaseItem
nDetailLevel
- the detail level to be used.CSParameterException
- if an invalid detail level is specified.public void setSiteUserID(int nUserID)
setSiteUserID
followed by a call to get
will populate this
CSContributorActions
object with the actions that the site user may perform on a specified
article.
Setting a site user ID of zero is permitted as this normally represents the anonymous user but the
getActions
method will always return an empty actions list in this case.
nUserID
- the numeric identifier of the site user.public int getSiteUserID()
public void setArticleID(int nArticleID)
setArticleID
followed by a call to get
will populate this
CSContributorActions
object with the actions that the specified site user may perform this
article.
The get
method will throw a CSNotFound
exception if the specified article does not
exist on the database.
nArticleID
- the numeric identifier of the article.public int getArticleID()
public java.lang.String getActions()
get
.ACTION_EDIT
, ACTION_DELETE
,
ACTION_ADDCHILD
, ACTION_ADDSIBLING
. An empty string
indicates that the specified site user may do nothing with the specified articlepublic void get() throws CSException
Use setSiteUserID
and setArticleID
followed by
get
to populate this CSContributorActions
object with the details of the actions
that the specified site user may perform on the specified article.
get
in class CSItem
CSParameterException
- if an invalid combination of key information has been supplied.CSDatabaseException
- if there are problems accessing the database.CSNotFoundException
- if the specified article cannot be found on the database.CSSecurityException
- if security has been breached.CSException
- the base class for exceptions thrown by this method.Copyright © 2022 Goss Interactive Ltd. All Rights Reserved.