1 /* 2 * Copyright (c) 2002-2021, 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.plugins.subscribe.business; 35 36 import javax.validation.constraints.Size; 37 38 import org.hibernate.validator.constraints.NotEmpty; 39 40 /** 41 * This is the business class for subscriptions. Users can subscribe to resources (identified by their id) with a subscription key for a provider.<br /> 42 * The provider is used to prevent collisions between subscriptions lists of different plugins. The subscription key is used to differentiate several 43 * subscription lists from a same provider. The subscribed resource id is used to configure subscriptions. <br /> 44 * Users are identified by their subscriber id. The subscriber id of a LuteceUser can be retrieved by calling the method 45 * {@link fr.paris.lutece.plugins.subscribe.service.SubscriptionService#getIdSubscriberFromLuteceUser(fr.paris.lutece.portal.service.security.LuteceUser) 46 * SubscriptionService#getIdSubscriberFromLuteceUser( LuteceUser )} <br /> 47 * Every string fields of this class be less than 255 characters long 48 */ 49 public class Subscription 50 { 51 // Variables declarations 52 53 @NotEmpty( message = "#i18n{portal.validation.message.notEmpty}" ) 54 private int _nIdSubscription; 55 @NotEmpty( message = "#i18n{portal.validation.message.notEmpty}" ) 56 private String _strUserId; 57 @NotEmpty( message = "#i18n{portal.validation.message.notEmpty}" ) 58 @Size( max = 255, message = "#i18n{portal.validation.message.sizeMax}" ) 59 private String _strSubscriptionProvider; 60 @NotEmpty( message = "#i18n{portal.validation.message.notEmpty}" ) 61 @Size( max = 255, message = "#i18n{portal.validation.message.sizeMax}" ) 62 private String _strSubscriptionKey; 63 @Size( max = 255, message = "#i18n{portal.validation.message.sizeMax}" ) 64 private String _strIdSubscribedResource; 65 private int _nOrder; 66 67 /** 68 * Returns the technical id of the subscription 69 * 70 * @return The technical id of the subscription 71 */ 72 public int getIdSubscription( ) 73 { 74 return _nIdSubscription; 75 } 76 77 /** 78 * Sets the technical id of the subscription 79 * 80 * @param nIdSubscription 81 * The technical id of the subscription 82 */ 83 public void setIdSubscription( int nIdSubscription ) 84 { 85 _nIdSubscription = nIdSubscription; 86 } 87 88 /** 89 * Get the id of the subscriber. Subscribers id can be retrieved by calling the method 90 * {@link fr.paris.lutece.plugins.subscribe.service.SubscriptionService#getIdSubscriberFromLuteceUser(fr.paris.lutece.portal.service.security.LuteceUser) 91 * SubscriptionService#getIdSubscriberFromLuteceUser( LuteceUser )} 92 * 93 * @return The id of the subscriber 94 */ 95 public String getUserId( ) 96 { 97 return _strUserId; 98 } 99 100 /** 101 * Get the id of the subscriber. Subscribers id can be retrieved by calling the method 102 * {@link fr.paris.lutece.plugins.subscribe.service.SubscriptionService#getIdSubscriberFromLuteceUser(fr.paris.lutece.portal.service.security.LuteceUser) 103 * SubscriptionService#getIdSubscriberFromLuteceUser( LuteceUser )} 104 * 105 * @param strUserId 106 * The id of the subscriber 107 */ 108 public void setUserId( String strUserId ) 109 { 110 this._strUserId = strUserId; 111 } 112 113 /** 114 * Returns the provider of the subscription 115 * 116 * @return The provider of the subscription 117 */ 118 public String getSubscriptionProvider( ) 119 { 120 return _strSubscriptionProvider; 121 } 122 123 /** 124 * Sets the SubscriptionProvider 125 * 126 * @param strSubscriptionProvider 127 * The SubscriptionProvider 128 */ 129 public void setSubscriptionProvider( String strSubscriptionProvider ) 130 { 131 _strSubscriptionProvider = strSubscriptionProvider; 132 } 133 134 /** 135 * Returns the subscription key. The subscription key is used to differentiates several subscription lists of a same provider 136 * 137 * @return The subscription key 138 */ 139 public String getSubscriptionKey( ) 140 { 141 return _strSubscriptionKey; 142 } 143 144 /** 145 * Sets the subscription key. The subscription key is used to differentiates several subscription lists of a same provider 146 * 147 * @param strSubscriptionKey 148 * The ActionKey 149 */ 150 public void setSubscriptionKey( String strSubscriptionKey ) 151 { 152 _strSubscriptionKey = strSubscriptionKey; 153 } 154 155 /** 156 * Returns the id of the subscribed resource 157 * 158 * @return The id of the subscribed resource 159 */ 160 public String getIdSubscribedResource( ) 161 { 162 return _strIdSubscribedResource; 163 } 164 165 /** 166 * Sets the id of the subscribed resource 167 * 168 * @param strIdSubscribedResource 169 * The id of the subscribed resource 170 */ 171 public void setIdSubscribedResource( String strIdSubscribedResource ) 172 { 173 _strIdSubscribedResource = strIdSubscribedResource; 174 } 175 176 /** 177 * @return the _nOrder 178 */ 179 public int getOrder( ) 180 { 181 return _nOrder; 182 } 183 184 /** 185 * @param nOrder the _nOrder to set 186 */ 187 public void setOrder( int nOrder ) 188 { 189 this._nOrder = nOrder; 190 } 191 192 }