Class ClassifiedFeature
java.lang.Object
com.jalios.jcms.security.classified.ClassifiedFeature
Representantion of an application feature whose access may be limited to
publications with a classification level lower than or equal to a specific level.
Core features constants are declared in ClassifiedFeatures.
You can manage your own plugin feature in your plugin's properties and API :
1) Declare an empty property, prefixed with "classification.feature." in your plugin.prop file :
classification.feature.plugin.myplugin.some-feat:2) Declare the I18N label of your feature in your I18N properties files :
en.propclassification.feature.plugin.myplugin.some-feat: My wonderful feature
fr.propclassification.feature.plugin.myplugin.some-feat: Ma super fonctionnalité
- ...
ClassifiedFeature(String) :
public static final ClassifiedFeature MY_PLUGIN_FEAT = new ClassifiedFeature("plugin.myplugin.some-feat");
4) Check feature access authorization using canBeUsedFor(Publication),
when you want to propose your feature (in the user interface) AND
when validating a request to use the feature (in a java handler or API).
To explain the operation refusal to the end user, you can either return a failed controller
status using getControllerStatus() (it will include an I18N explanation message),
or add an I18N explanation message using getMessage(String).
Optionnally, you can provide a log message for diagnostic purpose, using getLogMessage().
if (!MY_PLUGIN_FEAT.canBeUsedFor(somePublication)) {
if (logger.isDebugEnabled() {
logger.debug(MessageFormat.format("Feature access refused for publication {0} : {1}",
JcmsUtil.dataToString(somePublication),
MY_PLUGIN_FEAT.getLogMessage());
);
}
return MY_PLUGIN_FEAT.getControllerStatus();
}
... // provide acces to feature
- Since:
- 10.0.8 / JCMS-10746
-
Constructor Summary
ConstructorsConstructorDescriptionClassifiedFeature(String featureName) Create a new ClassifiedFeature with the specified name. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanBeUsedFor(Publication pub) Check if this feature can be used for the specified publication.Retrieve a failed ControllerStatus suitable to explain the feature limit relative to classified publication.Retrieve the technical name of this feature.getIcon()Retrieve the icon of this feature.Retrieve the I18Ned label of this feature.Retrieve an english message explaining the feature limit relative to classified publication.intRetrieve the maximum authorized classification level of this feature.getMessage(String lang) Retrieve the I18Ned message explaining the feature limit relative to classified publication.Retrieve the plugin in which this feature was declared (if it is not a core feature)toString()
-
Constructor Details
-
ClassifiedFeature
Create a new ClassifiedFeature with the specified name.- Parameters:
featureName- the technical name of this feature, as declared in properties prefixed with "classification.feature.".Examples :
"core.share.public-link"or"plugin.jdrive.add-in-jdrive".Must not be null.
- Throws:
NullPointerException- iffeatureNameisnull
-
-
Method Details
-
getFeatureName
Retrieve the technical name of this feature.- Returns:
- the feature's name, as declared in property prefixed with "classification.feature.".
-
canBeUsedFor
Check if this feature can be used for the specified publication.- Parameters:
pub- a publication, null accepted.- Returns:
trueif feature can be used or when classification is disabled.falseif publication is null, or has a classification level higher than what is authorized for the specified feature.
-
getMaxLevel
public int getMaxLevel()Retrieve the maximum authorized classification level of this feature.- Returns:
- the maximum classification level which is allowed to used this feature (inclusive)
-
getLabel
Retrieve the I18Ned label of this feature.- Parameters:
lang- the ISO-639 code language to use to retrieve the label- Returns:
- an I18Ned label such as
"Public link","Add to my JDrive"
-
getMessage
Retrieve the I18Ned message explaining the feature limit relative to classified publication.- Parameters:
lang- the ISO-639 code language to use to retrieve the message- Returns:
- an I18Ned message such as
"The 'Public link' feature can only be used for publication with a classification level less than or equal to 'Confidential'."
-
getControllerStatus
Retrieve a failed ControllerStatus suitable to explain the feature limit relative to classified publication.- Returns:
- a ControllerStatus instance, never return null
-
getLogMessage
Retrieve an english message explaining the feature limit relative to classified publication.- Returns:
- an english message suitable for logging of behavior explanation, such as
"The 'Public link' feature can only be used for publication with a classification level less than or equal to 'Confidential'."
-
toString
-
getIcon
Retrieve the icon of this feature.- Returns:
- an icon property name.
-
getPlugin
Retrieve the plugin in which this feature was declared (if it is not a core feature)- Returns:
- a Plugin instance, or null if it is a core feature.
-