PageIncludeEntry.java

  1. /*
  2.  * Copyright (c) 2002-2022, City of Paris
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  *
  9.  *  1. Redistributions of source code must retain the above copyright notice
  10.  *     and the following disclaimer.
  11.  *
  12.  *  2. Redistributions in binary form must reproduce the above copyright notice
  13.  *     and the following disclaimer in the documentation and/or other materials
  14.  *     provided with the distribution.
  15.  *
  16.  *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
  17.  *     contributors may be used to endorse or promote products derived from
  18.  *     this software without specific prior written permission.
  19.  *
  20.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21.  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23.  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
  24.  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  25.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  26.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  27.  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  28.  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  29.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  30.  * POSSIBILITY OF SUCH DAMAGE.
  31.  *
  32.  * License 1.0
  33.  */
  34. package fr.paris.lutece.portal.service.includes;

  35. import fr.paris.lutece.portal.service.plugin.Plugin;
  36. import fr.paris.lutece.portal.service.plugin.PluginService;

  37. /**
  38.  * PageInclude Entry used by XML plugin file
  39.  */
  40. public class PageIncludeEntry
  41. {
  42.     // Variables declarations
  43.     private String _strId;
  44.     private String _strClassName;
  45.     private String _strPluginName;
  46.     private boolean _bEnabled = true; // defaults to enabled
  47.     private PageInclude _pageInclude;

  48.     /**
  49.      * Returns the Id
  50.      *
  51.      * @return The Id
  52.      */
  53.     public String getId( )
  54.     {
  55.         return _strId;
  56.     }

  57.     /**
  58.      * Sets the Id
  59.      *
  60.      * @param strId
  61.      *            The Id
  62.      */
  63.     public void setId( String strId )
  64.     {
  65.         _strId = strId;
  66.     }

  67.     /**
  68.      * Returns the ClassName
  69.      *
  70.      * @return The ClassName
  71.      */
  72.     public String getClassName( )
  73.     {
  74.         return _strClassName;
  75.     }

  76.     /**
  77.      * Sets the ClassName
  78.      *
  79.      * @param strClassName
  80.      *            The ClassName
  81.      */
  82.     public void setClassName( String strClassName )
  83.     {
  84.         _strClassName = strClassName;
  85.     }

  86.     /**
  87.      * Return the name of the plugin
  88.      *
  89.      * @return The name of the plugin
  90.      */
  91.     public String getPluginName( )
  92.     {
  93.         return _strPluginName;
  94.     }

  95.     /**
  96.      * Set the plugin name
  97.      *
  98.      * @param strPluginName
  99.      *            the plugin name
  100.      */
  101.     public void setPluginName( String strPluginName )
  102.     {
  103.         _strPluginName = strPluginName;
  104.     }

  105.     /**
  106.      * Sets the enabled state of this PageInclude
  107.      *
  108.      * @param enabled
  109.      *            <code>true</code> if this PageInclude is enabled, <code>false</code> otherwise
  110.      * @since 5.1
  111.      */
  112.     public void setEnabled( boolean enabled )
  113.     {
  114.         _bEnabled = enabled;
  115.     }

  116.     /**
  117.      * Tells if the PageInclude is enabled, independently of the plugin's status
  118.      *
  119.      * @return <code>true</code> if this PageInclude is enabled, <code>false</code> otherwise
  120.      * @since 5.1
  121.      */
  122.     public boolean isEnabled( )
  123.     {
  124.         return _bEnabled;
  125.     }

  126.     /**
  127.      * Tells if the PageInclude is enabled (plugin enabled and this particular PageInclude is enabled)
  128.      *
  129.      * @return True if the PageInclude is enabled, otherwise false
  130.      */
  131.     public boolean isEnable( )
  132.     {
  133.         return PluginService.isPluginEnable( _strPluginName ) && _bEnabled;
  134.     }

  135.     /**
  136.      * Gets the plugin instance associated to the application
  137.      *
  138.      * @return the plugin
  139.      */
  140.     public Plugin getPlugin( )
  141.     {
  142.         return PluginService.getPlugin( _strPluginName );
  143.     }

  144.     /**
  145.      * Sets the PageInclude object
  146.      *
  147.      * @param pageInclude
  148.      *            the PageInclude object
  149.      */
  150.     public void setPageInclude( PageInclude pageInclude )
  151.     {
  152.         _pageInclude = pageInclude;
  153.     }

  154.     /**
  155.      * Gets the PageInclude object
  156.      *
  157.      * @return The PageInclude object
  158.      */
  159.     public PageInclude getPageInclude( )
  160.     {
  161.         return _pageInclude;
  162.     }
  163. }