Class ClassifiedFeature


  • public class ClassifiedFeature
    extends java.lang.Object
    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.prop
      classification.feature.plugin.myplugin.some-feat: My wonderful feature
    • fr.prop
      classification.feature.plugin.myplugin.some-feat: Ma super fonctionnalité
    • ...
    3) Declare a constant referencing your feature name in your API using the constructor 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

      Constructors 
      Constructor Description
      ClassifiedFeature​(java.lang.String featureName)
      Create a new ClassifiedFeature with the specified name.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean canBeUsedFor​(Publication pub)
      Check if this feature can be used for the specified publication.
      ControllerStatus getControllerStatus()
      Retrieve a failed ControllerStatus suitable to explain the feature limit relative to classified publication.
      java.lang.String getFeatureName()
      Retrieve the technical name of this feature.
      java.lang.String getIcon()
      Retrieve the icon of this feature.
      java.lang.String getLabel​(java.lang.String lang)
      Retrieve the I18Ned label of this feature.
      java.lang.String getLogMessage()
      Retrieve an english message explaining the feature limit relative to classified publication.
      int getMaxLevel()
      Retrieve the maximum authorized classification level of this feature.
      java.lang.String getMessage​(java.lang.String lang)
      Retrieve the I18Ned message explaining the feature limit relative to classified publication.
      Plugin getPlugin()
      Retrieve the plugin in which this feature was declared (if it is not a core feature)
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ClassifiedFeature

        public ClassifiedFeature​(java.lang.String featureName)
        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:
        java.lang.NullPointerException - if featureName is null
    • Method Detail

      • getFeatureName

        public java.lang.String getFeatureName()
        Retrieve the technical name of this feature.
        Returns:
        the feature's name, as declared in property prefixed with "classification.feature.".
      • canBeUsedFor

        public boolean canBeUsedFor​(Publication pub)
        Check if this feature can be used for the specified publication.
        Parameters:
        pub - a publication, null accepted.
        Returns:
        true if feature can be used or when classification is disabled. false if 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

        public java.lang.String getLabel​(java.lang.String lang)
        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

        public java.lang.String getMessage​(java.lang.String lang)
        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

        public ControllerStatus getControllerStatus()
        Retrieve a failed ControllerStatus suitable to explain the feature limit relative to classified publication.
        Returns:
        a ControllerStatus instance, never return null
      • getLogMessage

        public java.lang.String 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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getIcon

        public java.lang.String getIcon()
        Retrieve the icon of this feature.
        Returns:
        an icon property name.
      • getPlugin

        public Plugin 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.