SecurityHeaderHome.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.business.securityheader;


  35. import java.util.Collection;

  36. import fr.paris.lutece.portal.service.spring.SpringContextService;

  37. /**
  38.  * This class provides instances management methods (create, find, ...) for SecurityHeader objects
  39.  */
  40. public final class SecurityHeaderHome
  41. {
  42.     // Static variable pointed at the DAO instance
  43.     private static ISecurityHeaderDAO _dao = SpringContextService.getBean( "securityHeaderDAO" );

  44.     /**
  45.      * Private constructor - this class need not be instantiated
  46.      */
  47.     private SecurityHeaderHome( )
  48.     {
  49.     }

  50.     /**
  51.      * Creation of an instance of Security header
  52.      *
  53.      * @param securityHeader
  54.      *            The instance of the security header which contains the informations to store
  55.      * @return The instance of security header which has been created with its primary key.
  56.      */
  57.     public static SecurityHeader create( SecurityHeader securityheader )
  58.     {
  59.         _dao.insert( securityheader );

  60.         return securityheader;
  61.     }

  62.     /**
  63.      * Update of the security header which is specified in parameter
  64.      *
  65.      * @param securityHeader
  66.      *            The instance of the Security header which contains the data to store
  67.      * @return The instance of the security header which has been updated
  68.      */
  69.     public static void update( SecurityHeader securityHeader )
  70.     {
  71.         _dao.store( securityHeader );
  72.     }

  73.     /**
  74.      * Update of the is_active column value of the security header which is specified in parameter
  75.      *
  76.      * @param nSecurityHeaderId
  77.      *            The securityHeader Id
  78.      * @param isActiveValue
  79.      *            The value to set to is_active column
  80.      */
  81.     public static void updateIsActive( int nSecurityHeaderId, boolean isActiveValue )
  82.     {
  83.         _dao.updateIsActive( nSecurityHeaderId, isActiveValue );
  84.     }
  85.    
  86.     /**
  87.      * Remove the security header whose identifier is specified in parameter
  88.      *
  89.      * @param nSecurityHeaderId
  90.      *            The securityHeader Id
  91.      */
  92.     public static void remove( int nSecurityHeaderId )
  93.     {
  94.         _dao.delete( nSecurityHeaderId );
  95.     }

  96.     // /////////////////////////////////////////////////////////////////////////
  97.     // Finders

  98.     /**
  99.      * Returns an instance of a security header whose identifier is specified in parameter
  100.      *
  101.      * @param nKey
  102.      *            The security header primary key
  103.      * @return an instance of SecurityHeader
  104.      */
  105.     public static SecurityHeader findByPrimaryKey( int nKey )
  106.     {
  107.         return _dao.load( nKey );
  108.     }

  109.     /**
  110.      * Loads the data of all the security headers and returns them in form of a collection.
  111.      *
  112.      * @return the collection which contains the data of all the security headers
  113.      */
  114.     public static Collection<SecurityHeader> findAll( )
  115.     {
  116.         return _dao.selectAll( );
  117.     }

  118.     /**
  119.      * Find all active security headers by type (page or REST api).
  120.      *
  121.      * @param strType
  122.      *            The type
  123.      * @return A security headers collection
  124.      */
  125.     public static Collection<SecurityHeader> findActiveByType( String strType )
  126.     {
  127.         return _dao.selectActiveByType( strType );
  128.     }
  129. }