Changeset 409


Ignore:
Timestamp:
03/14/12 14:52:29 (12 years ago)
Author:
vmipsl
Message:

backoffice

Location:
tapas
Files:
26 added
18 edited
23 copied

Legend:

Unmodified
Added
Removed
  • tapas/common/implementation/com/ether/ParameterConstants.java

    r376 r409  
    99    public static final String PARAMETER_DATE_BEGIN = "dateBegin"; 
    1010    public static final String PARAMETER_DATE_END = "dateEnd"; 
     11    public static final String PARAMETER_LOGIN = "login"; 
     12    public static final String PARAMETER_PWD = "pwd"; 
     13    public static final String PARAMETER_FIRST_NAME = "firstName"; 
     14    public static final String PARAMETER_EMAIL = "email"; 
     15    public static final String PARAMETER_ROLE = "role"; 
     16    public static final String PARAMETER_STATE = "state"; 
     17    public static final String PARAMETER_HAS_ACCESS = "hasAccess"; 
     18    public static final String PARAMETER_KEEP_SAME_PASSWORD = "keepSamePassword"; 
     19    public static final String PARAMETER_MAX_RESULTS = "maxResults"; 
     20    public static final String PARAMETER_PAGE = "page"; 
    1121} 
  • tapas/domain/interface/com/ether/user/User.java

    r278 r409  
    1616    } 
    1717 
    18     public User( @NotNull final String lastName, @Nullable final String firstName, @NotNull final String email, @NotNull final String password, @Nullable final UserRole role, @NotNull final UserState state, final boolean hasAccessToBO, @NotNull final Date creationDate ) 
     18    public User( @NotNull final String lastName, @Nullable final String firstName, @NotNull final String email, @NotNull final String password, @Nullable final UserRole role, final boolean hasAccessToBO, @NotNull final Date creationDate ) 
    1919    { 
    2020        _lastName = lastName; 
     
    2323        _password = password; 
    2424        _role = role; 
    25         _state = state; 
    2625        _accessToBO = hasAccessToBO; 
    2726        _creationDate = creationDate; 
    2827    } 
    2928 
    30     public User( @NotNull final String lastName, @Nullable final String firstName, @NotNull final String email, @NotNull final String pwd, @Nullable final String role, @NotNull final String state, final Boolean hasAccessToBO, @NotNull final Date date ) 
     29    public User( @NotNull final String lastName, @Nullable final String firstName, @NotNull final String email, @NotNull final String pwd, @Nullable final String role, final Boolean hasAccessToBO, @NotNull final Date date ) 
    3130    { 
    32         this( lastName, firstName, email, pwd, UserRole.valueOf( role ), UserState.valueOf( state ), hasAccessToBO, date ); 
     31        this( lastName, firstName, email, pwd, UserRole.valueOf( role ), hasAccessToBO, date ); 
    3332    } 
    3433 
     
    9897    } 
    9998 
    100     @NotNull 
    101     public UserState getState() 
    102     { 
    103         return _state; 
    104     } 
    105  
    106     public void setState( @NotNull final UserState state ) 
    107     { 
    108         _state = state; 
    109     } 
    110  
    11199    public boolean isAccessToBO() 
    112100    { 
     
    141129    @Nullable 
    142130    private UserRole _role; 
    143     @NotNull 
    144     private UserState _state; 
    145131    private boolean _accessToBO; 
    146132    @NotNull 
  • tapas/domain/interface/com/ether/user/UserFilter.java

    r308 r409  
    4141 
    4242    @Nullable 
    43     public UserState getSortState() 
    44     { 
    45         return _sortState; 
    46     } 
    47  
    48     public void setSortState( @Nullable final UserState sortState ) 
    49     { 
    50         _sortState = sortState; 
    51     } 
    52  
    53     @Nullable 
    5443    public String getSearchText() 
    5544    { 
     
    8776    private UserRole _sortRole; 
    8877    @Nullable 
    89     private UserState _sortState; 
    90     @Nullable 
    9178    private String _searchText; 
    9279    private boolean _sortAccessBoFalse; 
  • tapas/domain/interface/com/ether/user/UserRole.java

    r281 r409  
    33/** 
    44 * User: vmipsl 
    5  * Date: 25 nov. 2011 
     5 * Date: 12 march 2012 
    66 */ 
    77public enum UserRole 
    88{ 
    9     COORDINATOR, 
     9    USER, 
    1010    ADMINISTRATOR, 
    11     TECHNICIEN, 
    1211} 
  • tapas/persistence/implementation/com/ether/dao/DomainAccessObjectImpl.java

    r376 r409  
    11package com.ether.dao; 
    22 
    3 import static com.ether.PersistenceHelper.convert; 
    4 import static com.ether.PersistenceHelper.uniqueResult; 
     3import com.ether.LikeExpression; 
     4import com.ether.PersistenceException; 
     5import com.ether.PersistenceHelper; 
     6import org.hibernate.Criteria; 
     7import org.hibernate.Session; 
     8import org.hibernate.SessionFactory; 
     9import org.hibernate.criterion.Criterion; 
     10import org.hibernate.criterion.DetachedCriteria; 
     11import org.hibernate.criterion.Example; 
     12import org.hibernate.criterion.MatchMode; 
     13import org.hibernate.criterion.Projections; 
     14import org.jetbrains.annotations.NotNull; 
     15import org.jetbrains.annotations.Nullable; 
     16import org.springframework.dao.DataAccessException; 
     17import org.springframework.transaction.annotation.Propagation; 
     18import org.springframework.transaction.annotation.Transactional; 
    519 
    620import java.io.Serializable; 
     
    1024import java.util.List; 
    1125 
    12 import org.hibernate.Criteria; 
    13 import org.hibernate.Session; 
    14 import org.hibernate.SessionFactory; 
    15 import org.hibernate.criterion.DetachedCriteria; 
    16 import org.hibernate.criterion.Example; 
    17 import org.hibernate.criterion.Projections; 
    18 import org.jetbrains.annotations.NotNull; 
    19 import org.jetbrains.annotations.Nullable; 
    20 import org.springframework.dao.DataAccessException; 
    21  
    22 import com.ether.PersistenceException; 
     26import static com.ether.PersistenceHelper.convert; 
     27import static com.ether.PersistenceHelper.uniqueResult; 
    2328 
    2429public class DomainAccessObjectImpl<DO, PK extends Serializable> 
    25         implements DomainAccessObject<DO, PK> 
     30        implements DomainAccessObject<DO, PK> 
    2631{ 
    27     public DomainAccessObjectImpl(final Class<DO> domainObjectClass) { 
    28         _domainObjectClass = domainObjectClass; 
     32    public DomainAccessObjectImpl( final Class<DO> domainObjectClass ) 
     33    { 
     34        _domainObjectClass = domainObjectClass; 
     35    } 
     36 
     37    public DomainAccessObjectImpl( final Class<DO> domainObjectClass, final Class<PK> primaryKeyClass ) 
     38    { 
     39        _domainObjectClass = domainObjectClass; 
     40        _primaryKeyClass = primaryKeyClass; 
    2941    } 
    3042 
     
    3345    // ************************************************************************** // 
    3446 
    35     // ******************************* SELECT BY CRITERIA **//     
     47    // ******************************* SELECT BY CRITERIA **// 
    3648    @Nullable 
    37     public final DO selectByCriteria(final DetachedCriteria criteria) 
    38             throws PersistenceException 
    39     { 
    40         return selectByCriteria(getDomainObjectClass(), criteria); 
     49    public final DO selectByCriteria( final DetachedCriteria criteria ) 
     50            throws PersistenceException 
     51    { 
     52        return selectByCriteria( getDomainObjectClass(), criteria ); 
    4153    } 
    4254 
    4355    @Nullable 
    44     public final <O> O selectByCriteria(final Class<O> objectClass, final DetachedCriteria criteria) throws PersistenceException 
    45     { 
    46         return (O) criteria.getExecutableCriteria(_sessionFactory.getCurrentSession()).uniqueResult();   
     56    public final <O> O selectByCriteria( final Class<O> objectClass, final DetachedCriteria criteria ) 
     57            throws PersistenceException 
     58    { 
     59        return (O) criteria.getExecutableCriteria( _sessionFactory.getCurrentSession() ).uniqueResult(); 
    4760    } 
    4861 
    4962    @NotNull 
    50     public final <O> List<O> selectAllByCriteria(final Class<O> objectClass, final DetachedCriteria criteria) throws PersistenceException 
    51     { 
    52         final List<O> result =  (List<O>) criteria.getExecutableCriteria(_sessionFactory.getCurrentSession()).list(); 
    53         return null != result ? result : new ArrayList<O>(); 
     63    public final <O> List<O> selectAllByCriteria( final Class<O> objectClass, final DetachedCriteria criteria ) 
     64            throws PersistenceException 
     65    { 
     66        final List<O> result = (List<O>) criteria.getExecutableCriteria( _sessionFactory.getCurrentSession() ).list(); 
     67        return null != result ? result : new ArrayList<O>(); 
    5468    } 
    5569 
    5670    @NotNull 
    57     public final List<DO> selectAllByCriteria(final DetachedCriteria criteria) 
    58             throws PersistenceException 
    59     { 
    60         return selectAllByCriteria(getDomainObjectClass(), criteria); 
    61     } 
    62  
    63      
    64     // ******************************* INSERT **//     
     71    public final List<DO> selectAllByCriteria( final DetachedCriteria criteria ) 
     72            throws PersistenceException 
     73    { 
     74        return selectAllByCriteria( getDomainObjectClass(), criteria ); 
     75    } 
     76 
     77    @Transactional(propagation = Propagation.MANDATORY) 
     78    public final <O> O execute( final PersistenceHelper.Operation<O> operation ) 
     79            throws PersistenceException 
     80    { 
     81        return PersistenceHelper.execute( operation, _sessionFactory ); 
     82    } 
     83 
     84    // ******************************* INSERT **// 
    6585    @NotNull 
    66     public final PK insert(final DO domainObject) throws PersistenceException 
    67     { 
    68         try 
    69         { 
    70             final Session session = _sessionFactory.getCurrentSession(); 
    71             final PK primaryKey = (PK) session.save(domainObject); 
    72             session.flush(); 
    73             return primaryKey; 
    74         } 
    75         catch (DataAccessException e) 
    76         { 
    77             throw convert(e); 
    78         } 
    79     } 
    80  
    81     public final void insertAll(@NotNull final Collection<DO> domainObjects) 
    82             throws PersistenceException 
    83     { 
    84         try 
    85         { 
    86             final Session session = _sessionFactory.getCurrentSession(); 
    87             int i = 0; 
    88             for (final DO domainObject : domainObjects) 
    89             { 
    90                 session.save(domainObject); 
    91                 // Avoid OutOfMemoryError 
    92                 if (i >= 500) 
    93                 { 
    94                     session.flush(); 
    95                     session.clear(); 
    96                     i = 0; 
    97                 } 
    98             } 
    99             session.flush(); 
    100         } 
    101         catch (DataAccessException e) 
    102         { 
    103             throw convert(e); 
    104         } 
    105     } 
    106  
    107     // ******************************* UPDATE **//     
    108     public void update(@NotNull final DO domainObject) 
    109             throws PersistenceException 
    110     { 
    111         try 
    112         { 
    113             final Session session = _sessionFactory.getCurrentSession(); 
    114             session.update(domainObject); 
    115             session.flush(); 
    116         } 
    117         catch (DataAccessException e) 
    118         { 
    119             throw convert(e); 
    120         } 
    121     } 
    122  
    123     public final void updateAll(final Collection<? extends DO> domainObjects) 
    124             throws PersistenceException 
    125     { 
    126         try 
    127         { 
    128             final Session session = _sessionFactory.getCurrentSession(); 
    129             for (final DO domainObject : domainObjects) 
    130                 session.saveOrUpdate(domainObject); 
    131             session.flush(); 
    132         } 
    133         catch (DataAccessException e) 
    134         { 
    135             throw convert(e); 
    136         } 
    137     } 
    138  
    139     // ******************************* UPGRADE **//     
    140     public final void upgrade(final DO domainObject) 
    141             throws PersistenceException 
    142     { 
    143         try 
    144         { 
    145             final Session session = _sessionFactory.getCurrentSession(); 
    146             session.refresh(domainObject); 
    147             session.flush(); 
    148         } 
    149         catch (DataAccessException e) 
    150         { 
    151             throw convert(e); 
    152         } 
    153     } 
    154  
    155     public final void upgradeAll(final Collection<DO> domainObjects) 
    156             throws PersistenceException 
    157     { 
    158         try 
    159         { 
    160             final Session session = _sessionFactory.getCurrentSession(); 
    161             for (final DO domainObject : domainObjects) 
    162             { 
    163                 session.refresh(domainObject); 
    164             } 
    165             session.flush(); 
    166         } 
    167         catch (DataAccessException e) 
    168         { 
    169             throw convert(e); 
    170         } 
    171     } 
    172  
    173     // ******************************* DELETE **//     
    174     public void deleteByPrimaryKey(final PK primaryKey) 
    175             throws PersistenceException 
    176     { 
    177         try 
    178         { 
    179             final Session session = _sessionFactory.getCurrentSession(); 
    180             final Object domainObject = session.get(getDomainObjectClass(), primaryKey); 
    181             if(null != domainObject) 
    182                 session.delete(domainObject); 
    183             else 
    184                 throw new PersistenceException(PersistenceException.PersistenceCode.OBJECT_TO_DELETE_NOT_FOUND); 
    185             session.flush(); 
    186         } 
    187         catch (DataAccessException e) 
    188         { 
    189             throw convert(e); 
    190         } 
    191     } 
    192  
    193     public final void delete(@NotNull final DO domainObject) 
    194             throws PersistenceException 
    195     { 
    196         try 
    197         { 
    198             final Session session = _sessionFactory.getCurrentSession(); 
    199             session.delete(domainObject); 
    200             session.flush(); 
    201         } 
    202         catch (DataAccessException e) 
    203         { 
    204             throw convert(e); 
    205         } 
    206     } 
    207  
    208     public final void deleteAll(final Collection<DO> domainObjects) 
    209             throws PersistenceException 
    210     { 
    211         try 
    212         { 
    213             final Session session = _sessionFactory.getCurrentSession(); 
    214             for (final DO domainObject : domainObjects) 
    215                 session.delete(domainObject); 
    216             session.flush(); 
    217         } 
    218         catch (DataAccessException e) 
    219         { 
    220             throw convert(e); 
    221         } 
    222     } 
    223  
    224     // ******************************* SELECT **//     
    225     public final DO selectByPrimaryKey(@NotNull final PK primaryKey) 
    226             throws PersistenceException 
    227     { 
    228         try 
    229         { 
    230             final Session session = _sessionFactory.getCurrentSession(); 
    231             return (DO) session.get(getDomainObjectClass(), primaryKey); 
    232         } 
    233         catch (DataAccessException e) 
    234         { 
    235             throw convert(e); 
    236         } 
    237     } 
    238  
    239     public final DO selectByExample(final DO domainObject) 
    240             throws PersistenceException 
    241     { 
    242         final Session session = _sessionFactory.getCurrentSession(); 
    243         final Criteria executableCriteria = session.createCriteria(domainObject.getClass()); 
    244         executableCriteria.add(Example.create(domainObject)); 
    245         return uniqueResult((Collection<DO>) executableCriteria.list()); 
    246     } 
    247  
    248     public final List<DO> selectAllByExample(final DO domainObject) 
    249             throws PersistenceException 
    250     { 
    251         final Session session = _sessionFactory.getCurrentSession(); 
    252         final Criteria executableCriteria = session.createCriteria(domainObject.getClass()); 
    253         executableCriteria.add(Example.create(domainObject)); 
    254         return (List<DO>) executableCriteria.list(); 
    255     } 
    256  
    257     public final List<DO> selectAll() throws PersistenceException 
    258     { 
    259         try 
    260         { 
    261             final Session session = _sessionFactory.getCurrentSession(); 
    262             final Criteria executableCriteria = session.createCriteria(getDomainObjectClass());      
    263             return (List<DO>) executableCriteria.list(); 
    264         } 
    265         catch (DataAccessException e) 
    266         { 
    267             throw convert(e); 
    268         } 
     86    public final PK insert( final DO domainObject ) 
     87            throws PersistenceException 
     88    { 
     89        try 
     90        { 
     91            final Session session = _sessionFactory.getCurrentSession(); 
     92            final PK primaryKey = (PK) session.save( domainObject ); 
     93            session.flush(); 
     94            return primaryKey; 
     95        } 
     96        catch( DataAccessException e ) 
     97        { 
     98            throw convert( e ); 
     99        } 
     100    } 
     101 
     102    public final void insertAll( @NotNull final Collection<DO> domainObjects ) 
     103            throws PersistenceException 
     104    { 
     105        try 
     106        { 
     107            final Session session = _sessionFactory.getCurrentSession(); 
     108            int i = 0; 
     109            for( final DO domainObject : domainObjects ) 
     110            { 
     111                session.save( domainObject ); 
     112                // Avoid OutOfMemoryError 
     113                if( i >= 500 ) 
     114                { 
     115                    session.flush(); 
     116                    session.clear(); 
     117                    i = 0; 
     118                } 
     119            } 
     120            session.flush(); 
     121        } 
     122        catch( DataAccessException e ) 
     123        { 
     124            throw convert( e ); 
     125        } 
     126    } 
     127 
     128    // ******************************* UPDATE **// 
     129    public void update( @NotNull final DO domainObject ) 
     130            throws PersistenceException 
     131    { 
     132        try 
     133        { 
     134            final Session session = _sessionFactory.getCurrentSession(); 
     135            session.update( domainObject ); 
     136            session.flush(); 
     137        } 
     138        catch( DataAccessException e ) 
     139        { 
     140            throw convert( e ); 
     141        } 
     142    } 
     143 
     144    public final void updateAll( final Collection<? extends DO> domainObjects ) 
     145            throws PersistenceException 
     146    { 
     147        try 
     148        { 
     149            final Session session = _sessionFactory.getCurrentSession(); 
     150            for( final DO domainObject : domainObjects ) 
     151                session.saveOrUpdate( domainObject ); 
     152            session.flush(); 
     153        } 
     154        catch( DataAccessException e ) 
     155        { 
     156            throw convert( e ); 
     157        } 
     158    } 
     159 
     160    // ******************************* UPGRADE **// 
     161    public final void upgrade( final DO domainObject ) 
     162            throws PersistenceException 
     163    { 
     164        try 
     165        { 
     166            final Session session = _sessionFactory.getCurrentSession(); 
     167            session.refresh( domainObject ); 
     168            session.flush(); 
     169        } 
     170        catch( DataAccessException e ) 
     171        { 
     172            throw convert( e ); 
     173        } 
     174    } 
     175 
     176    public final void upgradeAll( final Collection<DO> domainObjects ) 
     177            throws PersistenceException 
     178    { 
     179        try 
     180        { 
     181            final Session session = _sessionFactory.getCurrentSession(); 
     182            for( final DO domainObject : domainObjects ) 
     183            { 
     184                session.refresh( domainObject ); 
     185            } 
     186            session.flush(); 
     187        } 
     188        catch( DataAccessException e ) 
     189        { 
     190            throw convert( e ); 
     191        } 
     192    } 
     193 
     194    // ******************************* DELETE **// 
     195    public void deleteByPrimaryKey( final PK primaryKey ) 
     196            throws PersistenceException 
     197    { 
     198        try 
     199        { 
     200            final Session session = _sessionFactory.getCurrentSession(); 
     201            final Object domainObject = session.get( getDomainObjectClass(), primaryKey ); 
     202            if( null != domainObject ) 
     203                session.delete( domainObject ); 
     204            else 
     205                throw new PersistenceException( PersistenceException.PersistenceCode.OBJECT_TO_DELETE_NOT_FOUND ); 
     206            session.flush(); 
     207        } 
     208        catch( DataAccessException e ) 
     209        { 
     210            throw convert( e ); 
     211        } 
     212    } 
     213 
     214    public final void delete( @NotNull final DO domainObject ) 
     215            throws PersistenceException 
     216    { 
     217        try 
     218        { 
     219            final Session session = _sessionFactory.getCurrentSession(); 
     220            session.delete( domainObject ); 
     221            session.flush(); 
     222        } 
     223        catch( DataAccessException e ) 
     224        { 
     225            throw convert( e ); 
     226        } 
     227    } 
     228 
     229    public final void deleteAll( final Collection<DO> domainObjects ) 
     230            throws PersistenceException 
     231    { 
     232        try 
     233        { 
     234            final Session session = _sessionFactory.getCurrentSession(); 
     235            for( final DO domainObject : domainObjects ) 
     236                session.delete( domainObject ); 
     237            session.flush(); 
     238        } 
     239        catch( DataAccessException e ) 
     240        { 
     241            throw convert( e ); 
     242        } 
     243    } 
     244 
     245    // ******************************* SELECT **// 
     246    public final DO selectByPrimaryKey( @NotNull final PK primaryKey ) 
     247            throws PersistenceException 
     248    { 
     249        try 
     250        { 
     251            final Session session = _sessionFactory.getCurrentSession(); 
     252            return (DO) session.get( getDomainObjectClass(), primaryKey ); 
     253        } 
     254        catch( DataAccessException e ) 
     255        { 
     256            throw convert( e ); 
     257        } 
     258    } 
     259 
     260    public final DO selectByExample( final DO domainObject ) 
     261            throws PersistenceException 
     262    { 
     263        final Session session = _sessionFactory.getCurrentSession(); 
     264        final Criteria executableCriteria = session.createCriteria( domainObject.getClass() ); 
     265        executableCriteria.add( Example.create( domainObject ) ); 
     266        return uniqueResult( (Collection<DO>) executableCriteria.list() ); 
     267    } 
     268 
     269    public final List<DO> selectAllByExample( final DO domainObject ) 
     270            throws PersistenceException 
     271    { 
     272        final Session session = _sessionFactory.getCurrentSession(); 
     273        final Criteria executableCriteria = session.createCriteria( domainObject.getClass() ); 
     274        executableCriteria.add( Example.create( domainObject ) ); 
     275        return (List<DO>) executableCriteria.list(); 
     276    } 
     277 
     278    public final List<DO> selectAll() 
     279            throws PersistenceException 
     280    { 
     281        try 
     282        { 
     283            final Session session = _sessionFactory.getCurrentSession(); 
     284            final Criteria executableCriteria = session.createCriteria( getDomainObjectClass() ); 
     285            return (List<DO>) executableCriteria.list(); 
     286        } 
     287        catch( DataAccessException e ) 
     288        { 
     289            throw convert( e ); 
     290        } 
    269291    } 
    270292 
    271293    // ******************************* PAGINATE **// 
    272     protected <T> List<T> selectPage(@Nullable final Integer firstResult, @Nullable final Integer maxResults, final DetachedCriteria detachedCriteria) 
    273             throws PersistenceException 
    274     { 
    275         final Session session = _sessionFactory.getCurrentSession(); 
    276         final Criteria criteria = detachedCriteria.getExecutableCriteria(session); 
    277  
    278         if (null != maxResults) 
    279         { 
    280             criteria.setMaxResults(maxResults); 
    281             if (null != firstResult) 
    282                 criteria.setFirstResult(firstResult); 
    283         } 
    284         return (List<T>) criteria.list(); 
    285     } 
    286  
    287     protected Integer count(final DetachedCriteria detachedCriteria) 
    288             throws PersistenceException 
    289     { 
    290         final Session session = _sessionFactory.getCurrentSession(); 
    291         final Criteria executableCriteria = detachedCriteria.getExecutableCriteria(session); 
    292         executableCriteria.setProjection(Projections.rowCount()); 
    293         return (Integer) executableCriteria.uniqueResult(); 
    294     } 
     294    protected <T> List<T> selectPage( @Nullable final Integer firstResult, @Nullable final Integer maxResults, final DetachedCriteria detachedCriteria ) 
     295            throws PersistenceException 
     296    { 
     297        final Session session = _sessionFactory.getCurrentSession(); 
     298        final Criteria criteria = detachedCriteria.getExecutableCriteria( session ); 
     299 
     300        if( null != maxResults ) 
     301        { 
     302            criteria.setMaxResults( maxResults ); 
     303            if( null != firstResult ) 
     304                criteria.setFirstResult( firstResult ); 
     305        } 
     306        return (List<T>) criteria.list(); 
     307    } 
     308 
     309    protected Integer count( final DetachedCriteria detachedCriteria ) 
     310            throws PersistenceException 
     311    { 
     312        final Session session = _sessionFactory.getCurrentSession(); 
     313        final Criteria executableCriteria = detachedCriteria.getExecutableCriteria( session ); 
     314        executableCriteria.setProjection( Projections.rowCount() ); 
     315        if( executableCriteria.uniqueResult() instanceof Long ) 
     316            return ( (Long) executableCriteria.uniqueResult() ).intValue(); 
     317        else 
     318            return (Integer) executableCriteria.uniqueResult(); 
     319 
     320    } 
     321 
     322    // ******************************* SELECT **// 
     323    public static Criterion escapedLike( final String fieldName, final String value ) 
     324    { 
     325        return new LikeExpression( fieldName, value, MatchMode.ANYWHERE, null, true ); 
     326    } 
     327 
    295328    // ************************************************************************** // 
    296329    // ************************************************************************** // 
    297      
     330 
    298331    @SuppressWarnings("unchecked") 
    299332    public final Class<DO> getDomainObjectClass() 
    300333    { 
    301         if (_domainObjectClass == null) 
    302         { 
    303             if (getClass().getGenericSuperclass() instanceof ParameterizedType) 
    304                 _domainObjectClass = (Class<DO>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]; 
    305             else 
    306                 throw new IllegalArgumentException("domain class is not null and DAO is not parameterized !"); 
    307         } 
    308  
    309         return _domainObjectClass; 
    310     } 
    311  
    312     public final void setDomainObjectClass(final Class<DO> domainObjectClass) 
    313     { 
    314         _domainObjectClass = domainObjectClass; 
    315     } 
    316  
    317     public final void setSessionFactory(final SessionFactory sessionFactory) 
    318     { 
    319         _sessionFactory = sessionFactory; 
     334        if( _domainObjectClass == null ) 
     335        { 
     336            if( getClass().getGenericSuperclass() instanceof ParameterizedType ) 
     337                _domainObjectClass = (Class<DO>) ( (ParameterizedType) getClass().getGenericSuperclass() ).getActualTypeArguments()[0]; 
     338            else 
     339                throw new IllegalArgumentException( "domain class is not null and DAO is not parameterized !" ); 
     340        } 
     341 
     342        return _domainObjectClass; 
     343    } 
     344 
     345    public final void setDomainObjectClass( final Class<DO> domainObjectClass ) 
     346    { 
     347        _domainObjectClass = domainObjectClass; 
     348    } 
     349 
     350    public final Class<PK> getPrimaryKeyClass() 
     351    { 
     352        if( _primaryKeyClass == null ) 
     353        { 
     354            if( getClass().getGenericSuperclass() instanceof ParameterizedType ) 
     355                _primaryKeyClass = (Class<PK>) ( (ParameterizedType) getClass().getGenericSuperclass() ).getActualTypeArguments()[1]; 
     356            else 
     357                throw new IllegalArgumentException( "primary key class is not null and DAO is not parameterized !" ); 
     358        } 
     359 
     360        return _primaryKeyClass; 
     361    } 
     362 
     363    public final void setPrimaryKeyClass( final Class<PK> primaryKeyClass ) 
     364    { 
     365        _primaryKeyClass = primaryKeyClass; 
     366    } 
     367 
     368    public final void setSessionFactory( final SessionFactory sessionFactory ) 
     369    { 
     370        _sessionFactory = sessionFactory; 
    320371    } 
    321372 
    322373    public final SessionFactory getSessionFactory() 
    323374    { 
    324         return _sessionFactory; 
     375        return _sessionFactory; 
    325376    } 
    326377 
     
    329380    private SessionFactory _sessionFactory; 
    330381    private Class<DO> _domainObjectClass; 
     382    private Class<PK> _primaryKeyClass; 
    331383} 
  • tapas/persistence/implementation/dao-context.xml

    r378 r409  
    44<!-- Application context DAO layer --> 
    55<beans> 
    6         <bean id="refPlateformDAO" class="com.ether.dao.PlateformDAOImpl"> 
    7                 <property name="sessionFactory"> 
    8                         <ref bean="sessionFactory" /> 
    9                 </property> 
    10         </bean> 
     6    <bean id="refPlateformDAO" class="com.ether.dao.PlateformDAOImpl"> 
     7        <property name="sessionFactory"> 
     8            <ref bean="sessionFactory"/> 
     9        </property> 
     10    </bean> 
    1111 
    1212    <bean id="refParameterDAO" class="com.ether.dao.ParameterDAOImpl"> 
    1313        <property name="sessionFactory"> 
    14             <ref bean="sessionFactory" /> 
     14            <ref bean="sessionFactory"/> 
     15        </property> 
     16    </bean> 
     17 
     18    <bean id="refUserDAO" class="com.ether.dao.user.UserDAOImpl"> 
     19        <property name="sessionFactory"> 
     20            <ref bean="sessionFactory"/> 
    1521        </property> 
    1622    </bean> 
  • tapas/persistence/implementation/hibernate-domain.cfg.xml

    r378 r409  
    66<hibernate-configuration> 
    77    <session-factory> 
    8         <mapping resource="com/ether/dao/Plateform.hbm.xml"/> 
    9         <mapping resource="com/ether/dao/Parameter.hbm.xml"/> 
     8        <mapping resource="com/ether/dao/user/User.hbm.xml"/> 
    109    </session-factory> 
    1110</hibernate-configuration> 
  • tapas/persistence/implementation/hibernate.cfg.xml

    r378 r409  
    1717                                <prop key="hibernate.bytecode.use_reflection_optimizer">false</prop> 
    1818                                <prop key="hibernate.connection.driver_class">org.postgresql.Driver</prop> 
    19                                 <prop key="hibernate.connection.url">jdbc:postgresql://darkstar.ipslnet:5432/PROJECT_SOURCE</prop> 
     19                                <prop key="hibernate.connection.url">jdbc:postgresql://darkstar.ipslnet:5432/tapas_bdd</prop> 
    2020                                <prop key="hibernate.connection.username">postgres</prop> 
    2121                                <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop> 
  • tapas/persistence/interface/com/ether/PersistenceHelper.java

    r376 r409  
    11package com.ether; 
    2  
    3 import java.util.Collection; 
    4 import com.ether.PersistenceException; 
    52 
    63import org.apache.commons.logging.Log; 
    74import org.apache.commons.logging.LogFactory; 
     5import org.hibernate.HibernateException; 
     6import org.hibernate.Session; 
     7import org.hibernate.SessionFactory; 
    88import org.springframework.dao.CleanupFailureDataAccessException; 
    99import org.springframework.dao.DataAccessException; 
     10import org.springframework.transaction.annotation.Propagation; 
     11import org.springframework.transaction.annotation.Transactional; 
     12 
     13import java.util.Collection; 
    1014 
    1115public final class PersistenceHelper 
     
    1317    /** 
    1418     * Returns an unique result from a collection of results. 
    15      *  
     19     * 
    1620     * @throws PersistenceException : if more than one result is contained in the collection an exception is thrown. 
    1721     */ 
    18     public static <O> O uniqueResult(final Collection<O> results) 
    19             throws PersistenceException 
     22    public static <O> O uniqueResult( final Collection<O> results ) 
     23            throws PersistenceException 
    2024    { 
    21         if (results == null || results.isEmpty()) 
    22             return null; 
    23         else if (results.size() > 1) 
    24             throw new PersistenceException(PersistenceException.PersistenceCode.INVALID_API_USAGE, "unique result expected !"); 
    25         else 
    26             return results.iterator().next(); 
     25        if( results == null || results.isEmpty() ) 
     26            return null; 
     27        else if( results.size() > 1 ) 
     28            throw new PersistenceException( PersistenceException.PersistenceCode.INVALID_API_USAGE, "unique result expected !" ); 
     29        else 
     30            return results.iterator().next(); 
    2731    } 
    2832 
    29     public static <O> O firstResult(final Collection<O> results) 
     33    public static <O> O firstResult( final Collection<O> results ) 
    3034    { 
    31         if (results == null || results.isEmpty()) return null; 
    32         return results.iterator().next(); 
     35        if( results == null || results.isEmpty() ) return null; 
     36        return results.iterator().next(); 
    3337    } 
    34    
     38 
    3539    /** 
    3640     * Converts an exception to a DAO exception. 
    37      *  
     41     * 
    3842     * @param exception : the exception. 
    3943     * @return the DAO exception. 
    4044     */ 
    41     public static PersistenceException convert(final Exception exception) 
     45    public static PersistenceException convert( final Exception exception ) 
    4246    { 
    43         // Propagates the exception if exception is persistence exception 
    44         if (exception instanceof PersistenceException) 
    45             return (PersistenceException) exception; 
     47        // Propagates the exception if exception is persistence exception 
     48        if( exception instanceof PersistenceException ) 
     49            return (PersistenceException) exception; 
    4650 
    47         // Rewraps exception if data access exception 
    48         final PersistenceException.PersistenceCode code; 
     51        // Rewraps exception if data access exception 
     52        final PersistenceException.PersistenceCode code; 
    4953 
    50         if (exception instanceof DataAccessException) 
    51         { 
    52             if (exception instanceof CleanupFailureDataAccessException) 
    53             { 
    54                 code = PersistenceException.PersistenceCode.CLEANUP_FAILURE; 
    55             } 
    56             else if (exception instanceof org.springframework.dao.ConcurrencyFailureException) 
    57             { 
    58                 code = PersistenceException.PersistenceCode.CONCURRENCY_FAILURE; 
    59             } 
    60             else if (exception instanceof org.springframework.dao.DataAccessResourceFailureException) 
    61             { 
    62                 code = PersistenceException.PersistenceCode.RESOURCE_FAILURE; 
    63             } 
    64             else if (exception instanceof org.springframework.dao.DataIntegrityViolationException) 
    65             { 
    66                 code = PersistenceException.PersistenceCode.INTEGRITY_VIOLATION; 
    67             } 
    68             else if (exception instanceof org.springframework.dao.DataRetrievalFailureException) 
    69             { 
    70                 code = PersistenceException.PersistenceCode.RETRIEVAL_FAILURE; 
    71             } 
    72             else if (exception instanceof org.springframework.jdbc.datasource.lookup.DataSourceLookupFailureException) 
    73             { 
    74                 code = PersistenceException.PersistenceCode.DATA_SOURCE_LOOKUP_FAILURE; 
    75             } 
    76             else if (exception instanceof org.springframework.dao.InvalidDataAccessApiUsageException) 
    77             { 
    78                 code = PersistenceException.PersistenceCode.INVALID_API_USAGE; 
    79             } 
    80             else if (exception instanceof org.springframework.dao.PermissionDeniedDataAccessException) 
    81             { 
    82                 code = PersistenceException.PersistenceCode.PERMISSION_DENIED; 
    83             } 
    84             else 
    85             { 
    86                 code = PersistenceException.PersistenceCode.UNKNOWN_FAILURE; 
    87             } 
    88         } 
    89         else 
    90         { 
    91             code = PersistenceException.PersistenceCode.UNKNOWN_FAILURE; 
    92         } 
     54        if( exception instanceof DataAccessException ) 
     55        { 
     56            if( exception instanceof CleanupFailureDataAccessException ) 
     57            { 
     58                code = PersistenceException.PersistenceCode.CLEANUP_FAILURE; 
     59            } 
     60            else if( exception instanceof org.springframework.dao.ConcurrencyFailureException ) 
     61            { 
     62                code = PersistenceException.PersistenceCode.CONCURRENCY_FAILURE; 
     63            } 
     64            else if( exception instanceof org.springframework.dao.DataAccessResourceFailureException ) 
     65            { 
     66                code = PersistenceException.PersistenceCode.RESOURCE_FAILURE; 
     67            } 
     68            else if( exception instanceof org.springframework.dao.DataIntegrityViolationException ) 
     69            { 
     70                code = PersistenceException.PersistenceCode.INTEGRITY_VIOLATION; 
     71            } 
     72            else if( exception instanceof org.springframework.dao.DataRetrievalFailureException ) 
     73            { 
     74                code = PersistenceException.PersistenceCode.RETRIEVAL_FAILURE; 
     75            } 
     76            else if( exception instanceof org.springframework.jdbc.datasource.lookup.DataSourceLookupFailureException ) 
     77            { 
     78                code = PersistenceException.PersistenceCode.DATA_SOURCE_LOOKUP_FAILURE; 
     79            } 
     80            else if( exception instanceof org.springframework.dao.InvalidDataAccessApiUsageException ) 
     81            { 
     82                code = PersistenceException.PersistenceCode.INVALID_API_USAGE; 
     83            } 
     84            else if( exception instanceof org.springframework.dao.PermissionDeniedDataAccessException ) 
     85            { 
     86                code = PersistenceException.PersistenceCode.PERMISSION_DENIED; 
     87            } 
     88            else 
     89            { 
     90                code = PersistenceException.PersistenceCode.UNKNOWN_FAILURE; 
     91            } 
     92        } 
     93        else 
     94        { 
     95            code = PersistenceException.PersistenceCode.UNKNOWN_FAILURE; 
     96        } 
    9397 
    94         final StringBuilder message = new StringBuilder(); 
    95         message.append(exception.getMessage()); 
     98        final StringBuilder message = new StringBuilder(); 
     99        message.append( exception.getMessage() ); 
    96100 
    97         final Throwable cause = exception.getCause(); 
    98         if (null != cause) 
    99         { 
    100             message.append(" : ").append(cause.getMessage()); 
    101         } 
     101        final Throwable cause = exception.getCause(); 
     102        if( null != cause ) 
     103        { 
     104            message.append( " : " ).append( cause.getMessage() ); 
     105        } 
    102106 
    103         return new PersistenceException(code, message.toString(), 
    104                 exception); 
     107        return new PersistenceException( code, message.toString(), 
     108                exception ); 
    105109    } 
    106110 
    107     private static final Log LOGGER = LogFactory.getLog(PersistenceHelper.class); 
     111    @Transactional(propagation = Propagation.MANDATORY) 
     112    public static <O> O execute( final Operation<O> operation, final SessionFactory sessionFactory ) 
     113            throws PersistenceException 
     114    { 
     115        try 
     116        { 
     117            final Session session = sessionFactory.getCurrentSession(); 
     118            return operation.operate( session ); 
     119        } 
     120        catch( org.hibernate.exception.LockAcquisitionException e ) 
     121        { 
     122            LOGGER.fatal( e.getMessage(), e ); 
     123            throw convert( e ); 
     124        } 
     125        catch( DataAccessException e ) 
     126        { 
     127            throw convert( e ); 
     128        } 
     129        catch( HibernateException e ) 
     130        { 
     131            throw convert( e ); 
     132        } 
     133    } 
     134 
     135    public interface Operation<O> 
     136    { 
     137        /** 
     138         * Executes an operation on a session (delete, update, ...) with no return statement. 
     139         * 
     140         * @param session the session. 
     141         * @return the operation result. 
     142         * @throws org.hibernate.HibernateException 
     143         *                               if an hibernate exception occurs. 
     144         * @throws java.sql.SQLException if an SQL exception occurs. 
     145         * @throws PersistenceException  if a DAO exception is thrown. 
     146         */ 
     147        O operate( Session session ) 
     148                throws PersistenceException; 
     149    } 
     150 
     151    private static final Log LOGGER = LogFactory.getLog( PersistenceHelper.class ); 
    108152} 
  • tapas/persistence/interface/com/ether/dao/UserDAO.java

    r287 r409  
    44import com.ether.user.User; 
    55import com.ether.user.UserFilter; 
    6 import com.ether.user.UserState; 
    76import org.jetbrains.annotations.NotNull; 
    87import org.jetbrains.annotations.Nullable; 
     
    2221 
    2322    @NotNull 
    24     List<User> getUsersByState( @NotNull final UserState userState ) 
    25             throws PersistenceException; 
    26  
    27     @NotNull 
    2823    List<User> getAllUsersByNameOrder() 
    2924            throws PersistenceException; 
  • tapas/service/implementation/com/ether/BackofficeServiceImpl.java

    r402 r409  
    11package com.ether; 
    22 
    3 import com.ether.dao.ParameterDAO; 
    4 import com.ether.dao.PlateformDAO; 
    5 import com.ether.tapas.Tapas; 
     3import com.ether.dao.UserDAO; 
     4import com.ether.user.User; 
     5import com.ether.user.UserFilter; 
    66import org.apache.commons.logging.Log; 
    77import org.apache.commons.logging.LogFactory; 
    8 import org.jdom.Attribute; 
    9 import org.jdom.Document; 
    10 import org.jdom.Element; 
    11 import org.jdom.output.Format; 
    12 import org.jdom.output.XMLOutputter; 
    138import org.jetbrains.annotations.NotNull; 
    149import org.jetbrains.annotations.Nullable; 
    15 import org.springframework.beans.factory.annotation.Required; 
    1610import org.springframework.transaction.annotation.Transactional; 
    1711 
    18 import java.io.FileOutputStream; 
    1912import java.util.List; 
    2013 
    2114/** 
    22  * @author rboipsl 
    23  * @date 2 mars 2012 
     15 * @author vmipsl 
     16 * @date 12 march 2012 
    2417 */ 
    25 public class TapasServiceImpl 
    26         implements TapasService 
     18public class BackofficeServiceImpl 
     19        implements BackofficeService 
    2720{ 
    28  
    29     public void createXMLRequest( @NotNull final Tapas tapas ) 
    30     { 
    31         String idF = "Ether_TAPAS_0000001"; 
    32         String idRF = "1"; 
    33         String validFF = "ASCII"; 
    34         String validRF = "YES"; 
    35  
    36         String xvalidFF = "ASCII,FITS,NETCDF"; 
    37         String xvalidRF = "YES,NO"; 
    38         String fichier = "request1.xml"; 
    39  
    40         final Element racine = new Element( "tapas" ); 
    41         final Element request = new Element( "request" ); 
    42         final Element preferences = new Element( "preferences" ); 
    43         final Element format = new Element( "format" ); 
    44         final Element rayleighExtinction = new Element( "rayleigh_extinction" ); 
    45  
    46         //On crée un nouveau Document JDOM basé sur la racine que l'on vient de créer 
    47         final Document document = new Document( racine ); 
    48  
    49         final Attribute id = new Attribute( "Id", idF ); 
    50         racine.setAttribute( id ); 
    51  
    52         final Attribute idR = new Attribute( "Id", idRF ); 
    53         request.setAttribute( idR ); 
    54  
    55         racine.addContent( request ); 
    56         request.addContent( preferences ); 
    57  
    58         final Attribute validF = new Attribute( "valid", xvalidFF ); 
    59         format.setAttribute( validF ); 
    60         format.setText( validFF ); 
    61  
    62         final Attribute validR = new Attribute( "valid", xvalidRF ); 
    63         rayleighExtinction.setAttribute( validR ); 
    64         rayleighExtinction.setText( validRF ); 
    65  
    66         createXMLFile( fichier, document ); 
    67     } 
    68  
    69     public void createXMLFile( final String fichier, final Document document ) 
    70     { 
    71         try 
    72         { 
    73             //On utilise ici un affichage classique avec getPrettyFormat() 
    74             final XMLOutputter sortie = new XMLOutputter( Format.getPrettyFormat() ); 
    75             //Remarquez qu'il suffit simplement de créer une instance de FileOutputStream 
    76             //avec en argument le nom du fichier pour effectuer la sérialisation. 
    77             sortie.output( document, new FileOutputStream( fichier ) ); 
    78         } 
    79         catch( java.io.IOException ignored ) 
    80         { 
    81         } 
    82     } 
    83  
    84  
    85     // TODO : supprimer cette méthode --> EXEMPLE 
    8621    @Nullable 
    8722    @Transactional(readOnly = true) 
    88     public List<Plateform> getAllPlateforms() 
     23    public User getUserById( @NotNull final Integer userId ) 
    8924            throws ServiceException 
    9025    { 
    9126        try 
    9227        { 
    93             return _plateformDAO.getAllPlateforms(); 
     28            return _userDAO.selectByPrimaryKey( userId ); 
    9429        } 
    9530        catch( PersistenceException e ) 
    9631        { 
    97             throw new ServiceException( ServiceException.ServiceCode.PLATEFORM_NOT_FOUND, e ); 
     32            throw new ServiceException( ServiceException.ServiceCode.USER_NOT_FOUND, e ); 
    9833        } 
    9934    } 
    10035 
    101     // TODO : supprimer cette méthode --> EXEMPLE 
    10236    @Nullable 
    10337    @Transactional(readOnly = true) 
    104     public Plateform getPlateformById( @Nullable final Integer plateformId ) 
    105             throws ServiceException 
    106     { 
    107         if( null == plateformId ) 
    108             return null; 
    109         try 
    110         { 
    111             return _plateformDAO.getPlateformById( plateformId ); 
    112         } 
    113         catch( PersistenceException e ) 
    114         { 
    115             throw new ServiceException( ServiceException.ServiceCode.PLATEFORM_NOT_FOUND, e ); 
    116         } 
    117     } 
    118  
    119     // TODO : supprimer cette méthode --> EXEMPLE 
    120     @Nullable 
    121     @Transactional(readOnly = true) 
    122     public List<Parameter> getAllParametersByPlateformId( @NotNull final Integer plateformId ) 
     38    public User getUserByEmail( @NotNull final String userEmail ) 
    12339            throws ServiceException 
    12440    { 
    12541        try 
    12642        { 
    127             return _parameterDAO.getAllParametersByPlateformId( plateformId ); 
     43            return _userDAO.getUserByEmail( userEmail ); 
    12844        } 
    12945        catch( PersistenceException e ) 
    13046        { 
    131             throw new ServiceException( ServiceException.ServiceCode.PARAMETER_NOT_FOUND, e ); 
     47            throw new ServiceException( ServiceException.ServiceCode.USER_NOT_FOUND, e ); 
    13248        } 
    13349    } 
    13450 
    135     // TODO : supprimer cette méthode --> EXEMPLE 
    136     @Required 
    137     public void setPlateformDAO( final PlateformDAO plateformDAO ) 
     51    @NotNull 
     52    @Transactional(rollbackFor = Exception.class) 
     53    public Integer createUser( @NotNull final User user ) 
     54            throws ServiceException 
    13855    { 
    139         _plateformDAO = plateformDAO; 
     56        try 
     57        { 
     58            return _userDAO.insert( user ); 
     59        } 
     60        catch( PersistenceException e ) 
     61        { 
     62            throw new ServiceException( ServiceException.ServiceCode.PERSISTENCE, e ); 
     63        } 
    14064    } 
    14165 
    142     // TODO : supprimer cette méthode --> EXEMPLE 
    143     @Required 
    144     public void setParameterDAO( final ParameterDAO parameterDAO ) 
     66    @NotNull 
     67    @Transactional(readOnly = true) 
     68    public List<User> getAllUsers() 
     69            throws ServiceException 
    14570    { 
    146         _parameterDAO = parameterDAO; 
     71        try 
     72        { 
     73            return _userDAO.selectAll(); 
     74        } 
     75        catch( PersistenceException e ) 
     76        { 
     77            throw new ServiceException( ServiceException.ServiceCode.PERSISTENCE, e ); 
     78        } 
    14779    } 
    14880 
    149     private static final Log LOGGER = LogFactory.getLog( TapasServiceImpl.class ); 
     81    @NotNull 
     82    @Transactional(readOnly = true) 
     83    public List<User> getAllUsersByNameOrder() 
     84            throws ServiceException 
     85    { 
     86        try 
     87        { 
     88            return _userDAO.getAllUsersByNameOrder(); 
     89        } 
     90        catch( PersistenceException e ) 
     91        { 
     92            throw new ServiceException( ServiceException.ServiceCode.USER_NOT_FOUND, e ); 
     93        } 
     94    } 
    15095 
    151     // TODO : supprimer ces DAO --> EXEMPLES 
    152     private PlateformDAO _plateformDAO; 
    153     private ParameterDAO _parameterDAO; 
     96    @Transactional(rollbackFor = Exception.class) 
     97    public void removeUserById( @NotNull final Integer userId ) 
     98            throws ServiceException 
     99    { 
     100        try 
     101        { 
     102            _userDAO.deleteByPrimaryKey( userId ); 
     103        } 
     104        catch( PersistenceException e ) 
     105        { 
     106            throw new ServiceException( ServiceException.ServiceCode.PERSISTENCE, e ); 
     107        } 
     108    } 
    154109 
     110    @Transactional(rollbackFor = Exception.class) 
     111    public void updateUser( @NotNull final User user ) 
     112            throws ServiceException 
     113    { 
     114        try 
     115        { 
     116            _userDAO.update( user ); 
     117        } 
     118        catch( PersistenceException e ) 
     119        { 
     120            throw new ServiceException( ServiceException.ServiceCode.PERSISTENCE, e ); 
     121        } 
     122    } 
     123 
     124    @Transactional(readOnly = true) 
     125    public PaginatedResult<User> searchUsers( final UserFilter filter ) 
     126            throws ServiceException 
     127    { 
     128        try 
     129        { 
     130            return _userDAO.search( filter ); 
     131        } 
     132        catch( PersistenceException e ) 
     133        { 
     134            throw new ServiceException( ServiceException.ServiceCode.USER_NOT_FOUND, e ); 
     135        } 
     136    } 
     137 
     138    public void setUserDAO( final UserDAO userDAO ) 
     139    { 
     140        _userDAO = userDAO; 
     141    } 
     142 
     143    private static final Log LOGGER = LogFactory.getLog( BackofficeServiceImpl.class ); 
     144 
     145    private UserDAO _userDAO; 
    155146} 
  • tapas/service/implementation/com/ether/TapasServiceImpl.java

    r402 r409  
    8282    } 
    8383 
    84  
    8584    // TODO : supprimer cette méthode --> EXEMPLE 
    8685    @Nullable 
     
    118117 
    119118    // TODO : supprimer cette méthode --> EXEMPLE 
    120     @Nullable 
    121     @Transactional(readOnly = true) 
    122     public List<Parameter> getAllParametersByPlateformId( @NotNull final Integer plateformId ) 
    123             throws ServiceException 
    124     { 
    125         try 
    126         { 
    127             return _parameterDAO.getAllParametersByPlateformId( plateformId ); 
    128         } 
    129         catch( PersistenceException e ) 
    130         { 
    131             throw new ServiceException( ServiceException.ServiceCode.PARAMETER_NOT_FOUND, e ); 
    132         } 
    133     } 
    134  
    135     // TODO : supprimer cette méthode --> EXEMPLE 
    136119    @Required 
    137120    public void setPlateformDAO( final PlateformDAO plateformDAO ) 
     
    152135    private PlateformDAO _plateformDAO; 
    153136    private ParameterDAO _parameterDAO; 
    154  
    155137} 
  • tapas/service/implementation/service-context.xml

    r389 r409  
    33 
    44<beans> 
    5         <bean id="tapasServiceTarget" class="com.ether.TapasServiceImpl"> 
    6                 <!--<property name="plateformDAO" ref="refPlateformDAO" /> 
    7                 <property name="parameterDAO" ref="refParameterDAO" />--> 
    8         </bean> 
     5    <bean id="tapasServiceTarget" class="com.ether.TapasServiceImpl"> 
     6        <!--<property name="plateformDAO" ref="refPlateformDAO" /> 
     7          <property name="parameterDAO" ref="refParameterDAO" />--> 
     8    </bean> 
    99 
    10         <bean id="tapasService" parent="transactionProxy"> 
    11                 <property name="target"> 
    12                         <ref bean="tapasServiceTarget" /> 
    13                 </property> 
    14                 <property name="transactionAttributeSource"> 
    15                         <bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource" /> 
    16                 </property> 
    17         </bean> 
     10    <bean id="tapasService" parent="transactionProxy"> 
     11        <property name="target"> 
     12            <ref bean="tapasServiceTarget"/> 
     13        </property> 
     14        <property name="transactionAttributeSource"> 
     15            <bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"/> 
     16        </property> 
     17    </bean> 
     18 
     19    <bean id="backofficeServiceTarget" class="com.ether.BackofficeServiceImpl"> 
     20        <property name="userDAO" ref="refUserDAO"/> 
     21    </bean> 
     22 
     23    <bean id="backofficeService" parent="transactionProxy"> 
     24        <property name="target"> 
     25            <ref bean="backofficeServiceTarget"/> 
     26        </property> 
     27        <property name="transactionAttributeSource"> 
     28            <bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"/> 
     29        </property> 
     30    </bean> 
    1831 
    1932</beans> 
  • tapas/service/interface/com/ether/BackofficeService.java

    r402 r409  
    22 
    33import com.ether.tapas.Tapas; 
     4import com.ether.user.User; 
     5import com.ether.user.UserFilter; 
    46import org.jdom.Document; 
    57import org.jetbrains.annotations.NotNull; 
     
    911 
    1012/** 
    11  * @author rboipsl 
    12  * @date 02 march 2012 
     13 * @author vmipsl 
     14 * @date 12 march 2012 
    1315 */ 
    14 public interface TapasService 
     16public interface BackofficeService 
    1517        extends Service 
    1618{ 
    17     public void createXMLRequest( @NotNull final Tapas tapas ); 
     19    @Nullable 
     20    User getUserById( @NotNull final Integer userId ) 
     21            throws ServiceException; 
    1822 
    19     public void createXMLFile( final String fichier, final Document document ); 
     23    @Nullable 
     24    User getUserByEmail( @NotNull final String userEmail ) 
     25            throws ServiceException; 
     26 
     27    @NotNull 
     28    Integer createUser( @NotNull User user ) 
     29            throws ServiceException; 
     30 
     31    @NotNull 
     32    List<User> getAllUsers() 
     33            throws ServiceException; 
     34 
     35    @NotNull 
     36    List<User> getAllUsersByNameOrder() 
     37            throws ServiceException; 
     38 
     39    void removeUserById( @NotNull final Integer userId ) 
     40            throws ServiceException; 
     41 
     42    void updateUser( @NotNull final User user ) 
     43            throws ServiceException; 
     44 
     45    PaginatedResult<User> searchUsers( UserFilter filter ) 
     46            throws ServiceException; 
    2047} 
  • tapas/service/interface/com/ether/ServiceException.java

    r376 r409  
    2525        PLATEFORM_NOT_FOUND, 
    2626        PARAMETER_NOT_FOUND, 
     27        USER_NOT_FOUND, 
    2728    } 
    2829} 
  • tapas/web/WEB-INF/servlet-context.xml

    r384 r409  
    3939            <props> 
    4040                <prop key="/project">controller</prop> 
     41                <prop key="/backoffice">controllerBackoffice</prop> 
    4142            </props> 
    4243        </property> 
     
    5758        <property name="jsonHelper" ref="jsonHelper"/> 
    5859        <property name="methodNameResolver" ref="myMethodNameResolver"/> 
    59     </bean> 
    60  
    61     <bean id="controller" class="com.ether.Controller" parent="controllerEther"> 
    6260        <property name="tapasService" ref="tapasService"/> 
    6361    </bean> 
    6462 
     63    <bean id="controller" class="com.ether.Controller" parent="controllerEther"/> 
     64    <bean id="controllerBackoffice" class="com.ether.ControllerBackoffice" parent="controllerEther"> 
     65        <property name="backofficeService" ref="backofficeService"/> 
     66    </bean> 
    6567</beans> 
  • tapas/web/resources/css/backoffice.css

    r308 r409  
    1616 
    1717.containerTitle { 
    18     color: #778899; 
     18    color: #be0026; 
    1919    padding-left: 236px; 
    2020} 
     
    3838.containerTitleContent { 
    3939    background-image: none; 
    40     color: #778899; 
     40    color: #be0026; 
    4141} 
    4242 
  • tapas/web/resources/css/tapas.css

    r388 r409  
    1616/** ********************** CONTAINER ******************** **/ 
    1717/** ***************************************************** **/ 
     18.containerLinkLogoEther { 
     19    position: absolute; 
     20    top: 0; 
     21    left: 127px; 
     22    width: 10px; 
     23    height: 99px; 
     24    background-image: url("../images/link_logo_Ether.png"); 
     25    background-repeat: repeat-y; 
     26} 
     27 
     28.containerLogoEther { 
     29    position: absolute; 
     30    top: 100px; 
     31    left: 50px; 
     32    -moz-border-radius: 4px 4px 4px 4px; 
     33    -moz-box-shadow: 0 0 4px rgba(0, 0, 0, 0.3); 
     34    -webkit-border-radius: 4px 4px 4px 4px; 
     35    -webkit-box-shadow: 0 0 4px rgba(0, 0, 0, 0.3); 
     36    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3); 
     37    width: 80px; 
     38    height: 80px; 
     39    padding: 15px; 
     40} 
     41 
    1842.containerTapas { 
    1943    -moz-border-radius: 4px 4px 4px 4px; 
     
    170194/** ************************ OTHER ********************** **/ 
    171195/** ***************************************************** **/ 
     196#tools .complexButton { 
     197    float: right; 
     198} 
     199 
    172200.roundTable { 
    173201    -moz-border-radius: 4px; 
     
    209237} 
    210238 
     239.loading-classic { 
     240    background-image: url(../../resources/icons/transparent_loading.gif); 
     241    height: 16px; 
     242    width: 16px; 
     243} 
     244 
    211245/** ***************************************************** **/ 
    212246/** ************************ PAGES ********************** **/ 
  • tapas/web/resources/templates/templateBackoffice.jsp

    r366 r409  
    1 <%@ page language="java" import="com.medias.Context" %> 
     1<%@ page contentType="text/html;charset=UTF-8" language="java" %> 
    22<%@ page import="com.ether.user.UserRole" %> 
    3 <%@ taglib uri="/WEB-INF/tlds/struts-tiles.tld" prefix="tiles" %> 
    4 <%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %> 
    5 <%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %> 
    6 <%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %> 
     3<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 
     4<%@ taglib prefix="tiles" uri="/WEB-INF/tlds/struts-tiles.tld" %> 
    75<%@ taglib prefix="ether" tagdir="/WEB-INF/tags" %> 
     6<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 
    87 
    98<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
     
    1514 
    1615    <title><tiles:getAsString name="title"/></title> 
    17     <link rel="shortcut icon" href="<html:rewrite page='/resources/images/megapoli/favicon.ico'/>"> 
     16    <link rel="shortcut icon" href=""> 
    1817 
    19     <ether:htmlCss cssFile="apycom.com-4-steel-blue/menu"/> 
    2018    <ether:htmlCss cssFile="button"/> 
    2119    <ether:htmlCss cssFile="complexButton"/> 
    2220    <ether:htmlCss cssFile="TwitterLogin/front"/> 
    23     <ether:htmlCss cssFile="ether"/> 
    24     <ether:htmlCss cssFile="megapoli"/> 
     21    <ether:htmlCss cssFile="mainEther"/> 
     22    <ether:htmlCss cssFile="tapas"/> 
    2523    <ether:htmlCss cssFile="backoffice"/> 
    2624 
     
    3230    <ether:htmlJs jsFile="classesForJQuery/ComplexButton"/> 
    3331    <ether:htmlJs jsFile="classesForJQuery/LoginButton"/> 
    34     <ether:htmlJs jsFile="apycom.com-4-steel-blue/menu"/> 
    3532    <ether:htmlJs jsFile="TwitterLogin/javascripts/jquery.tipsy"/> 
    3633 
     
    4946 
    5047<div id="logoEther" class="containerLogoEther"> 
    51     <html:link href="http://ether.ipsl.jussieu.fr" target="help"><img src="resources/images/logo_Ether.jpg" width="80px" height="80px"/></html:link> 
     48    <a href="http://ether.ipsl.jussieu.fr" target="help"><img src="resources/images/logo_Ether.jpg" width="80px" height="80px"/></a> 
    5249</div> 
    5350 
     
    5956 
    6057    <%-- ****************** TITLE & TOOLS ****************** --%> 
    61     <div id="title_tools" class="containerMegapoli"> 
     58    <div id="title_tools" class="containerTapas"> 
    6259        <div id="title"></div> 
    6360 
     
    7067    <%-- ****************** LOGO ****************** --%> 
    7168    <div id="logo" class="containerLogo"> 
    72         <html:link href="http://megapoli.dmi.dk/" target="help" titleKey="app.linkmegapoli"> 
    73             <html:img page="/resources/images/logo_Megapoli_white.png" height="110px" width="110px" altKey="app.home"/> 
    74         </html:link> 
     69        <a href="#"><img src="resources/images/logo_tapas.jpg" height="110px" width="110px"></a> 
    7570    </div> 
    7671 
     
    8479 
    8580    <%-- ****************** CONTENT ****************** --%> 
    86     <div id="containerCenter" class="containerMegapoli containerCenter"> 
     81    <div id="containerCenter" class="containerTapas containerCenter"> 
    8782        <tiles:insert attribute="body"/> 
    8883    </div> 
    8984 
    9085    <%-- ****************** BOTTOM ****************** --%> 
    91     <div id="containerBottom" class="containerMegapoli containerBottom" align="right"> 
    92         &copy; 2010-2011 <html:link href="http://ether.ipsl.jussieu.fr" target="help">ETHER&nbsp;</html:link>/ CNRS 
     86    <div id="containerBottom" class="containerTapas containerBottom" align="right"> 
     87        &copy; 2012 <a href="http://ether.ipsl.jussieu.fr" target="help">ETHER&nbsp;</a>/ CNRS 
    9388    </div> 
    9489 
     
    9792<script type="text/javascript"> 
    9893    var templateTexts = $A( "" ); 
    99     templateTexts["app.home"] = '<bean:message key="app.home"/>'; 
    100     templateTexts["bo.fulltitle"] = '<bean:message key="bo.fulltitle"/>'; 
    101     templateTexts["app.en"] = '<bean:message key="app.en"/>'; 
    102     templateTexts["app.fr"] = '<bean:message key="app.fr"/>'; 
    103     templateTexts["data.upload.metadata.contact.mail"] = '<bean:message key="data.upload.metadata.contact.mail"/>'; 
    104     templateTexts["bo.user"] = '<bean:message key="bo.user"/>'; 
    105     templateTexts["bo.site"] = '<bean:message key="bo.site"/>'; 
     94    templateTexts["app.home"] = '<spring:message code="label.home"/>'; 
     95    templateTexts["bo.fulltitle"] = '<spring:message code="bo.fulltitle"/>'; 
     96    templateTexts["bo.user"] = '<spring:message code="bo.user"/>'; 
     97    templateTexts["bo.site"] = '<spring:message code="bo.site"/>'; 
    10698 
    10799    // Needed texts if you use the library LoginButton.js 
    108100    var loginTexts = $A( "" ); 
    109     loginTexts["app.connexion"] = '<bean:message key="app.connexion"/>'; 
    110     loginTexts["login"] = '<bean:message key="login"/>'; 
    111     loginTexts["login.password"] = '<bean:message key="login.password"/>'; 
    112     loginTexts["login.sign"] = '<bean:message key="login.sign"/>'; 
    113     loginTexts["login.pwdForget"] = '<bean:message key="login.pwdForget"/>'; 
    114     loginTexts["login.loginForget.help"] = '<bean:message key="login.loginForget.help"/>'; 
    115     loginTexts["login.loginForget"] = '<bean:message key="login.loginForget"/>'; 
    116     loginTexts["login.error.notFound"] = "<bean:message key='login.error.notFound' arg0="<%=Context.getWebmaster( request )%>"/>"; 
    117     loginTexts["login.error.wrongPassword"] = "<bean:message key='login.error.wrongPassword'/>"; 
    118     loginTexts["login.error.failed"] = "<bean:message key='login.error.failed' arg0="<%=Context.getWebmaster( request )%>"/>"; 
    119     loginTexts["login.error.notAccepted"] = "<bean:message key='login.error.notAccepted'/>"; 
    120     loginTexts["<%=UserRole.ADMINISTRATOR%>"] = '<bean:message key="app.administrator"/>'; 
    121     loginTexts["<%=UserRole.TECHNICIEN%>"] = '<bean:message key="app.technician"/>'; 
    122     loginTexts["<%=UserRole.COORDINATOR%>"] = '<bean:message key="app.coordinator"/>'; 
     101    loginTexts["app.connexion"] = '<spring:message code="app.connexion"/>'; 
     102    loginTexts["login"] = '<spring:message code="login"/>'; 
     103    loginTexts["login.password"] = '<spring:message code="login.password"/>'; 
     104    loginTexts["login.sign"] = '<spring:message code="login.sign"/>'; 
     105    loginTexts["login.pwdForget"] = '<spring:message code="login.pwdForget"/>'; 
     106    loginTexts["login.loginForget.help"] = '<spring:message code="login.loginForget.help"/>'; 
     107    loginTexts["login.loginForget"] = '<spring:message code="login.loginForget"/>'; 
     108    loginTexts["login.error.notFound"] = "<spring:message code='login.error.notFound'/>"; 
     109    loginTexts["login.error.wrongPassword"] = "<spring:message code='login.error.wrongPassword'/>"; 
     110    loginTexts["login.error.failed"] = "<spring:message code='login.error.failed'/>"; 
     111    loginTexts["login.error.notAccepted"] = "<spring:message code='login.error.notAccepted'/>"; 
     112    loginTexts["<%=UserRole.ADMINISTRATOR%>"] = '<spring:message code="app.administrator"/>'; 
    123113 
    124114    var interfaceTemplate = new InterfaceTemplate(); 
  • tapas/web/resources/templates/templateBackoffice_script.jsp

    r366 r409  
    1 <%@ page import="com.medias.Context" %> 
    2  
    31<script type="text/javascript"> 
    42    var InterfaceTemplate = Class.create( { 
     
    1311 
    1412            /** *********** VARIABLES *********** **/ 
    15             this.isLanguageFr = <%=Context.getLangue(request).equals( "fr" )%>; 
     13            <%--this.isLanguageFr = <%=Context.getLangue(request).equals( "fr" )%>;--%> 
    1614            this.path = "<%=request.getContextPath()%>"; 
    17             this.webmaster = "<%=Context.getWebmaster(request)%>"; 
    18             this.relativePageUri = <%=request.getQueryString() != null%> ? "<%=Context.getRelativePath( request )%>?<%=request.getQueryString()%>" : "<%=Context.getRelativePageURI(request)%>"; 
    19             this.jSONUser = <%=Context.getJSONUser( request )%> ? <%=Context.getJSONUser( request )%> : false; 
    20             this.screenWidthLimit = 1336; 
     15            <%--this.webmaster = "<%=Context.getWebmaster(request)%>";--%> 
     16            <%--this.relativePageUri = <%=request.getQueryString() != null%> ? "<%=Context.getRelativePath( request )%>?<%=request.getQueryString()%>" : "<%=Context.getRelativePageURI(request)%>";--%> 
     17            <%--this.jSONUser = <%=Context.getJSONUser( request )%> ? <%=Context.getJSONUser( request )%> : false;--%> 
    2118 
    2219            /** ************ CREATE ************ **/ 
     
    3532            var interfaceButton = new Button( {value:templateTexts["bo.site"], parent:this.containerTools, id:"button_interface", className: "gray_button", classNameText:"blue_button_text", onClick:this.onClickMegapoli} ); 
    3633            var homeButton = new Button( {value:templateTexts["app.home"], parent:this.containerTools, id:"button_home", className: "gray_button", classNameText:"blue_button_text", onClick:this.onClickHome} ); 
    37  
    38             var divSmallLogoEther = $( document.createElement( "div" ) ); 
    39             divSmallLogoEther.attr( {id:"smallLogoEther", class:"containerSmallLogoEther"} ); 
    40             divSmallLogoEther.append( '<a href="http://ether.ipsl.jussieu.fr" target="help"><img src="resources/images/logo_Ether.jpg" width="40px" height="40px"/></a>' ); 
    41             this.containerTools.append( divSmallLogoEther ); 
    42             $( "#smallLogoEther" ).show(); 
    43  
    44             this.updateLogoEther(); 
    4534        }, 
    4635 
     
    7160        { 
    7261            document.location.href = "backoffice?methodName=viewUser"; 
    73         }, 
    74  
    75         /** 
    76          * This method display a small Ether logo if the screen is too small to contain the big one 
    77          */ 
    78         updateLogoEther: function() 
    79         { 
    80             if( this.screenWidthLimit > innerWidth ) 
    81             { 
    82                 $( "#logoEther" ).hide(); 
    83                 $( "#linkLogoEther" ).hide(); 
    84                 $( "#smallLogoEther" ).show(); 
    85             } 
    86             else 
    87             { 
    88                 $( "#logoEther" ).show(); 
    89                 $( "#linkLogoEther" ).show(); 
    90                 $( "#smallLogoEther" ).hide(); 
    91             } 
    9262        } 
    9363 
  • tapas/web/resources/templates/templateEther.jsp

    r406 r409  
    128128    templateTexts["label.mail"] = '<spring:message code="label.mail"/>'; 
    129129    templateTexts["label.map"] = '<spring:message code="label.map"/>'; 
    130  
     130    templateTexts["label.backoffice"] = '<spring:message code="label.backoffice"/>'; 
    131131 
    132132    var interfaceTemplate = new InterfaceTemplate(); 
  • tapas/web/resources/templates/templateEther_script.jsp

    r407 r409  
    2020        createTools: function() 
    2121        { 
     22            var backofficeButton = new Button( {value:templateTexts["label.backoffice"], parent:this.containerTools, id:"button_bo", className: "red_button", classNameText:"red_button_text", onClick:jQuery.proxy( this.onClickBO, this )} ); 
     23 
    2224            var mailButton = new Button( {value:templateTexts["label.mail"], parent:this.containerTools, id:"button_mail", className: "red_button", classNameText:"red_button_text", onClick:jQuery.proxy( this.onClickMail, this )} ); 
    2325            var languageButton = new Button( {value:templateTexts["label.language.to.switch"], parent:this.containerTools, id:"button_language", className: "red_button", classNameText:"red_button_text", onClick:jQuery.proxy( this.onClickLanguage, this )} ); 
     
    4042 
    4143        // EVENTS ******************************************************** 
     44        onClickBO: function() 
     45        { 
     46            document.location.href = "backoffice?methodName=home"; 
     47        }, 
     48 
    4249        onClickHome: function() 
    4350        { 
  • tapas/web/src/com/ether/Controller.java

    r406 r409  
    2626    /** *********************** VIEWS ***************************** **/ 
    2727    /** *********************************************************** **/ 
    28     @ControllerMethod(view = VIEW_INIT) 
    29     public Map<String, Object> home() 
     28    @ControllerMethod(view = VIEW_INIT)public Map<String, Object> home() 
    3029            throws WebException 
    3130    { 
     
    5049 
    5150        //appel a createxml 
    52         _tapasService.createXMLRequest( jsonTapas ); 
     51        getTapasService().createXMLRequest( jsonTapas ); 
    5352 
    5453        final JSONObject result = new JSONObject(); 
     
    5756    } 
    5857 
    59  
    60     @Required 
    61     public void setTapasService( @NotNull final TapasService tapasService ) 
    62     { 
    63         _tapasService = tapasService; 
    64     } 
    65  
    6658    private static final Log LOGGER = LogFactory.getLog( Controller.class ); 
    6759 
    6860    private static final String VIEW_INIT = "init"; 
    6961    private static final String VIEW_FORM_TAPAS = "project/formTapas"; 
    70  
    71     private TapasService _tapasService; 
    7262} 
  • tapas/web/src/com/ether/ControllerBackoffice.java

    r308 r409  
    66import com.ether.user.UserFilter; 
    77import com.ether.user.UserRole; 
    8 import com.ether.user.UserState; 
    9 import com.medias.mail.Mail; 
    10 import com.medias.mail.MailFactory; 
    118import net.sf.json.JSONObject; 
    129import org.apache.commons.logging.Log; 
     
    1411import org.jetbrains.annotations.NotNull; 
    1512import org.jetbrains.annotations.Nullable; 
    16  
    17 import javax.mail.MessagingException; 
     13import org.springframework.beans.factory.annotation.Required; 
     14 
    1815import java.security.DigestException; 
    1916import java.security.NoSuchAlgorithmException; 
     
    4542            throws ServiceException, WebException 
    4643    { 
    47         final JSONObject jsonObject = sortUser( "lastName", null, "ALL", "ALL", true, true, 5, 1 ); 
    48         jsonObject.put( "jSonUserStates", getJSONUserStates() ); 
     44        final JSONObject jsonObject = sortUser( "lastName", null, "ALL", true, true, 5, 1 ); 
    4945        jsonObject.put( "jSonUserRoles", getJSONUserRoles() ); 
    5046        return jsonObject; 
     
    6056                               @NotNull @ParamName(ParameterConstants.PARAMETER_PWD) final String pwd, 
    6157                               @Nullable @ParamName(ParameterConstants.PARAMETER_ROLE) final String role, 
    62                                @NotNull @ParamName(ParameterConstants.PARAMETER_STATE) final String state, 
    6358                               @NotNull @ParamName(ParameterConstants.PARAMETER_HAS_ACCESS) final Boolean hasAccessToBO ) 
    6459            throws WebException, ServiceException 
     
    6661        try 
    6762        { 
    68             final User existingUser = getEtherService().getUserByEmail( email ); 
     63            final User existingUser = _backofficeService.getUserByEmail( email ); 
    6964            if( null == existingUser ) 
    7065            { 
    7166                final Date creationDate = new Date(); 
    7267                final String encryptedPassword = EtherHelper.encryptPassword( pwd ); 
    73                 final User user = new User( lastName, firstName, email, encryptedPassword, role, state, hasAccessToBO, creationDate ); 
    74  
    75                 getEtherService().createUser( user ); 
     68                final User user = new User( lastName, firstName, email, encryptedPassword, role, hasAccessToBO, creationDate ); 
     69 
     70                _backofficeService.createUser( user ); 
    7671            } 
    7772            else 
     
    8883        } 
    8984 
    90         return getAllAndWaitingUsers(); 
     85        return getAllUsers(); 
    9186    } 
    9287 
     
    9590            throws WebException, ServiceException 
    9691    { 
    97         getEtherService().removeUserById( userId ); 
    98  
    99         return getAllAndWaitingUsers(); 
     92        _backofficeService.removeUserById( userId ); 
     93 
     94        return getAllUsers(); 
    10095    } 
    10196 
     
    107102                                  @Nullable @ParamName(ParameterConstants.PARAMETER_PWD) final String pwd, 
    108103                                  @Nullable @ParamName(ParameterConstants.PARAMETER_ROLE) final String role, 
    109                                   @NotNull @ParamName(ParameterConstants.PARAMETER_STATE) final String state, 
    110104                                  @NotNull @ParamName(ParameterConstants.PARAMETER_HAS_ACCESS) final Boolean hasAccessToBO, 
    111105                                  @NotNull @ParamName(ParameterConstants.PARAMETER_KEEP_SAME_PASSWORD) final Boolean keepSamePassword ) 
     
    114108        try 
    115109        { 
    116             final User existingUser = getEtherService().getUserByEmail( email ); 
     110            final User existingUser = _backofficeService.getUserByEmail( email ); 
    117111            if( null == existingUser || userId.equals( existingUser.getId() ) ) 
    118112            { 
    119                 final User user = getEtherService().getUserById( userId ); 
     113                final User user = _backofficeService.getUserById( userId ); 
    120114                user.setLastName( lastName ); 
    121115                user.setFirstName( firstName ); 
     
    127121                } 
    128122                user.setRole( UserRole.valueOf( role ) ); 
    129                 user.setState( UserState.valueOf( state ) ); 
    130123                user.setAccessToBO( hasAccessToBO ); 
    131124 
    132                 getEtherService().updateUser( user ); 
     125                _backofficeService.updateUser( user ); 
    133126            } 
    134127            else 
     
    144137        } 
    145138 
    146         return getAllAndWaitingUsers(); 
    147     } 
    148  
    149     /** 
    150      * This method changes the state user and sends an email to inform of the administrator decision. 
    151      * If the email can't be sent, the state will be not changed 
    152      * 
    153      * @param userId 
    154      * @param isAccepted 
    155      * @return 
    156      * @throws WebException 
    157      * @throws ServiceException 
    158      */ 
    159     @ControllerMethod(jsonResult = true) 
    160     public JSONObject acceptOrRefuseUser( @NotNull @ParamName(ParameterConstants.PARAMETER_ID) final Integer userId, 
    161                                           @ParamName(ParameterConstants.PARAMETER_OK) final boolean isAccepted ) 
    162             throws WebException, ServiceException 
    163     { 
    164         final User user = getEtherService().getUserById( userId ); 
    165         try 
    166         { 
    167             sendEmailToUser( user, isAccepted ); 
    168             getEtherService().acceptOrRefuseUser( userId, isAccepted ); 
    169         } 
    170         catch( MessagingException e ) 
    171         { 
    172             throw new WebException( WebException.WebCode.ERROR_EMAIL_CANNOT_BE_SEND, "The email cannot be send to the user : " + user.getEmail(), WebException.getExceptionThrowable() ); 
    173         } 
    174  
    175         return getAllAndWaitingUsers(); 
     139        return getAllUsers(); 
    176140    } 
    177141 
     
    180144                                @Nullable @ParamName("searchText") final String searchText, 
    181145                                @NotNull @ParamName("sortRole") final String sortRole, 
    182                                 @NotNull @ParamName("sortState") final String sortState, 
    183146                                @NotNull @ParamName("sortAccessBoTrue") final Boolean sortAccessBoTrue, 
    184147                                @NotNull @ParamName("sortAccessBoFalse") final Boolean sortAccessBoFalse, 
     
    191154            filter.setSortRole( UserRole.valueOf( sortRole ) ); 
    192155 
    193         if( !"ALL".equals( sortState ) ) 
    194             filter.setSortState( UserState.valueOf( sortState ) ); 
    195  
    196         final List<User> waitingUsers = getEtherService().getUsersByState( UserState.WAITING ); 
    197         final PaginatedResult<User> users = getEtherService().searchUsers( filter ); 
     156        final PaginatedResult<User> users = _backofficeService.searchUsers( filter ); 
    198157 
    199158        final JSONObject result = new JSONObject(); 
    200         result.put( "jSonWaitingUsers", getJsonHelper().toJSON( waitingUsers ) ); 
    201159        result.put( "jSonUsers", getJsonHelper().toJSON( users.getPaginatedResults() ) ); 
    202160        result.put( "usersNumber", users.getTotalCount() ); 
     
    204162    } 
    205163 
    206     /** 
    207      * This method create and send an email to the user to inform of the administrator decision 
    208      * 
    209      * @param user 
    210      * @param isAccepted 
    211      * @throws WebException 
    212      */ 
    213     private void sendEmailToUser( @NotNull final User user, final boolean isAccepted ) 
    214             throws MessagingException 
    215     { 
    216         final MailFactory mailFactory = (MailFactory) getServletContext().getAttribute( "APP_MAILFACTORY" ); 
    217         final String from = (String) getServletContext().getAttribute( "APP_WEBMASTER" ); 
    218         final String subject = "[MEGAPOLI] User inscription"; 
    219         String content = "Dear user, \n\nThe Megapoli administrator has "; 
    220         if( isAccepted ) 
    221             content += "accepted your inscription. You can now access to data with you login (" + user.getEmail() + ") and the password you gave during inscription.\n"; 
    222         else 
    223             content += "refused your inscription. You can reply to this email if you want more information.\n"; 
    224  
    225         content += "\nBest regards,\nMegapoli administrator"; 
    226  
    227         final Mail mail = new Mail( from, user.getEmail(), null, content, subject ); 
    228         mailFactory.sendMail( mail ); 
    229     } 
    230  
    231  
    232     private JSONObject getAllAndWaitingUsers() 
     164    private JSONObject getAllUsers() 
    233165            throws ServiceException 
    234166    { 
    235         final List<User> waitingUsers = getEtherService().getUsersByState( UserState.WAITING ); 
    236         final List<User> users = getEtherService().getAllUsersByNameOrder(); 
     167        final List<User> users = _backofficeService.getAllUsersByNameOrder(); 
    237168 
    238169        final JSONObject result = new JSONObject(); 
    239         result.put( "jSonWaitingUsers", getJsonHelper().toJSON( waitingUsers ) ); 
    240170        result.put( "jSonUsers", getJsonHelper().toJSON( users ) ); 
    241171        return result; 
    242     } 
    243  
    244     private List<JSONObject> getJSONUserStates() 
    245     { 
    246         final UserState[] userStates = UserState.values(); 
    247  
    248         final List<JSONObject> jsonUserStates = new ArrayList<JSONObject>( userStates.length ); 
    249  
    250         for( final UserState userState : userStates ) 
    251         { 
    252             final JSONObject jsonUserState = new JSONObject(); 
    253             jsonUserState.put( "text", userState.name() ); 
    254             jsonUserState.put( "value", userState.name() ); 
    255             jsonUserStates.add( jsonUserState ); 
    256         } 
    257         return jsonUserStates; 
    258172    } 
    259173 
     
    274188    } 
    275189 
     190    @Required 
     191    public void setBackofficeService( final BackofficeService backofficeService ) 
     192    { 
     193        _backofficeService = backofficeService; 
     194    } 
     195 
    276196    private static final Log LOGGER = LogFactory.getLog( ControllerBackoffice.class ); 
    277197 
    278198    private static final String VIEW_BO_INDEX = "backoffice/index"; 
    279199    private static final String VIEW_BO_USER = "backoffice/user"; 
     200 
     201    private BackofficeService _backofficeService; 
    280202} 
  • tapas/web/src/com/ether/ControllerEther.java

    r406 r409  
    289289    } 
    290290 
     291    @Required 
     292    public void setTapasService( @NotNull final TapasService tapasService ) 
     293    { 
     294        _tapasService = tapasService; 
     295    } 
     296 
     297    public TapasService getTapasService() 
     298    { 
     299        return _tapasService; 
     300    } 
     301 
    291302    private static final Log LOGGER = LogFactory.getLog( ControllerEther.class ); 
    292303 
     
    295306    private Map<String, MethodDescription> _methods = new HashMap<String, MethodDescription>(); 
    296307    private boolean _initialized; /*=false*/ 
     308 
     309    private TapasService _tapasService; 
    297310} 
  • tapas/web/src/com/ether/WebException.java

    r402 r409  
    4444        ERROR_NUMBER_OF_PARAM_TYPES_NOT_EQUAL_TO_PARAM_ANNOTATIONS, 
    4545        ERROR_JSON_TAPAS_IS_NULL, 
     46        USER_ALREADY_EXISTS, 
     47        ERROR_ENCRYPT_PASSWORD, 
     48        ERROR_EMAIL_CANNOT_BE_SEND 
    4649    } 
    4750 
  • tapas/web/src/messages_en.properties

    r406 r409  
    66app.title=Tapas 
    77app.fulltitle=Full title de Tapas 
     8app.connexion=Connection 
     9app.administrator=Administrator 
     10app.yes=Yes 
     11app.no=No 
    812 
    913title.home=Tapas data 
     
    1216label.map=Map 
    1317label.mail=Email 
     18label.backoffice=Backoffice 
    1419 
    1520error.ERROR_JSON_TAPAS_IS_NULL=Error to create the form 
    1621 
    1722label.submitButton=RUN 
     23 
     24################################################################ 
     25####################### LOGIN ################################## 
     26################################################################ 
     27login.authentification=Authentification 
     28login.intro=Please login to access the protected areas of this website. 
     29login=Login 
     30login.password=Password 
     31login.sign=Sign in 
     32login.loginForget=Forgot your username ? 
     33login.loginForget.help=If you remember your password, try logging in with your email 
     34login.pwdForget=Forgot your password ? 
     35login.inscription=New inscription 
     36login.text=Please login to access the protected areas of this website. 
     37 
     38login.dataProtocolAccept=You have to accept the data protocol to ask for an account 
     39login.dataProtocolFields=Fields 'LastName', 'Email' and 'Password' must be filled 
     40login.dataProtocol.account=Your account is waiting for administrator validation. You will receive an email when it will be activated. 
     41login.dataProtocol.alreadyExist=This email is already used, you have to give another one 
     42 
     43login.error.notAccepted=You are not allowed to access to protected areas. 
     44login.error.bo.notAccepted=You are not authorized to access to backoffice. 
     45login.error.notFound=Unknown login.<br> To register and access the protected areas of this site, please click on 'New inscription'.<br> 
     46login.error.wrongPassword=Wrong password. 
     47login.error.failed=The logon transaction failed. Please contact the <a href\='mailto\:{0}?subject\=[TAPAS]'>webmaster</a> to report this problem.<br> 
     48login.error.unknown=You are not authentified or you lost your session, please register. 
     49 
     50 
     51 
     52################################################################ 
     53##################### BACKOFFICE ############################### 
     54################################################################ 
     55bo.fulltitle=TAPAS Backoffice 
     56bo.site=Tapas 
     57bo.id=Id 
     58bo.action=Action 
     59bo.actions=Actions 
     60bo.modify=Modify 
     61bo.remove=Remove 
     62bo.add=Add 
     63bo.accept=Accept 
     64bo.refuse=Refuse 
     65bo.init=Init 
     66bo.go=Go 
     67bo.all=All 
     68bo.total.number=Total number 
     69bo.previous=Previous 
     70bo.next=Next 
     71bo.sortBy=Sort by 
     72bo.viewBy=View by 
     73bo.sort.asc=Sort asc by 
     74bo.user=Users 
     75bo.user.waitinglist=List of users waiting to have an access to data 
     76bo.user.waitinglist.help=(an email will be sent to the user with your choice (accept or refuse)) 
     77bo.user.list=List of users 
     78bo.noUser=No user 
     79bo.user.lastName=Lastname 
     80bo.user.firstName=Firstname 
     81bo.user.email=Email 
     82bo.user.password=Password 
     83bo.user.password.same=Keep same password 
     84bo.user.password.same.help=(only to modify a password) 
     85bo.user.role=Role 
     86bo.user.creationDate=Creation date 
     87bo.user.state=State 
     88bo.user.state.help=Inscription state (can be removed, unactif, refused, ...) 
     89bo.user.boAccess=BO 
     90bo.user.boAccess.help=Access to the backoffice 
     91bo.user.add=Add a new user 
     92bo.user.modify=Modify the user 
     93bo.user.remove.confirm=Do you really want to remove the user 
     94 
     95bo.user.accepted=Accepted 
     96bo.user.refused=Refused 
     97bo.user.waiting=Waiting 
     98bo.user.administrator=Administrator 
     99bo.user.user=User 
     100 
     101bo.field.lastName=The field lastName must be filled 
     102bo.field.email=The field email must be filled 
     103bo.field.password=The field password must be filled 
     104 
     105bo.user.emailNotSend=The email to the user cannot be sent, the email seems not valid : 
  • tapas/web/src/messages_fr.properties

    r406 r409  
    66app.title=Tapas 
    77app.fulltitle=Titre complet de Tapas 
     8app.connexion=Connexion 
     9app.administrator=Administrateur 
     10app.yes=Oui 
     11app.no=Non 
    812 
    913title.home=Les données Tapas 
     
    1216label.map=Plan 
    1317label.mail=Email 
     18label.backoffice=Backoffice 
    1419 
    1520error.ERROR_JSON_TAPAS_IS_NULL=Erreur de création du formulaire Tapas 
    1621 
    1722label.submitButton=COURIR 
     23 
     24################################################################ 
     25####################### LOGIN ################################## 
     26################################################################ 
     27login.authentification=Authentification 
     28login.intro=Veuillez vous identifier afin d'acc\u00E9der aux zones prot\u00E9g\u00E9es de ce site. 
     29login=Login 
     30login.password=Mot de passe 
     31login.sign=Connection 
     32login.loginForget=Oubli du login ? 
     33login.loginForget.help=Si vous vous souvenez de votre mot de passe, essayez de vous connecter avec votre email 
     34login.pwdForget=Oubli du mot de passe ? 
     35login.inscription=Nouvelle inscription 
     36login.text=Veuillez vous identifier afin d'acc\u00E9der aux zones prot\u00E9g\u00E9es de ce site. 
     37 
     38login.dataProtocolAccept=Vous devez accepter le protocole d'utilisation des donn\u00E9es pour demander un compte 
     39login.dataProtocolFields=Les champs 'Nom', 'Email' et 'Mot de passe' sont incomplets 
     40login.dataProtocol.account=Votre compte est en attente de validation par l'administrateur. Vous recevrez un email lors de son activation. 
     41login.dataProtocol.alreadyExist=Cette email est d\u00E9j\u00E0 utilis\u00E9 par un compte, veuillez en fournir un autre. 
     42 
     43login.error.notAccepted=Vous n'\u00EAtes pas autoris\u00E9 \u00E0 acc\u00E9der aux zones prot\u00E9g\u00E9s. 
     44login.error.bo.notAccepted=Vous n'\u00EAtes pas autoris\u00E9 \u00E0 acc\u00E9der au backoffice. 
     45login.error.notFound=Ce login est inconnu.<br> Si vous voulez vous enregistrer pour obtenir l'acc\u00E8s aux zones prot\u00E9g\u00E9es du site, veuillez cliquez sur 'Nouvelle inscription'. <br> 
     46login.error.wrongPassword=Ce mot de passe est incorrect. 
     47login.error.failed=Echec de l\'op\u00E9ration d'authentification.<br> Veuillez contacter le <a href\='mailto\:{0}?subject\=[TAPAS]'>webmaster</a> pour lui signaler le probl\u00E8me.<br> 
     48login.error.unknown=Vous n'\u00EAtes pas identifi\u00E9 ou vous avez perdu votre session, veuillez vous connecter. 
     49 
     50 
     51################################################################ 
     52##################### BACKOFFICE ############################### 
     53################################################################ 
     54bo.fulltitle=TAPAS Backoffice 
     55bo.site=Tapas 
     56bo.id=Id 
     57bo.action=Action 
     58bo.actions=Actions 
     59bo.modify=Modify 
     60bo.remove=Remove 
     61bo.add=Add 
     62bo.accept=Accept 
     63bo.refuse=Refuse 
     64bo.init=Init 
     65bo.go=Go 
     66bo.all=All 
     67bo.total.number=Total number 
     68bo.previous=Previous 
     69bo.next=Next 
     70bo.sortBy=Sort by 
     71bo.viewBy=View by 
     72bo.sort.asc=Sort asc by 
     73bo.user=Users 
     74#bo.user.waitinglist=List of users waiting to have an access to data 
     75#bo.user.waitinglist.help=(an email will be sent to the user with your choice (accept or refuse)) 
     76bo.user.list=List of users 
     77bo.noUser=No user 
     78bo.user.lastName=Lastname 
     79bo.user.firstName=Firstname 
     80bo.user.email=Email 
     81bo.user.password=Password 
     82bo.user.password.same=Keep same password 
     83bo.user.password.same.help=(only to modify a password) 
     84bo.user.role=Role 
     85bo.user.creationDate=Creation date 
     86bo.user.state=State 
     87bo.user.state.help=Inscription state (can be removed, unactif, refused, ...) 
     88bo.user.boAccess=BO 
     89bo.user.boAccess.help=Access to the backoffice 
     90bo.user.add=Add a new user 
     91bo.user.modify=Modify the user 
     92bo.user.remove.confirm=Do you really want to remove the user 
     93 
     94bo.user.accepted=Accepted 
     95bo.user.refused=Refused 
     96bo.user.waiting=Waiting 
     97bo.user.administrator=Administrator 
     98bo.user.user=User 
     99 
     100bo.field.lastName=The field lastName must be filled 
     101bo.field.email=The field email must be filled 
     102bo.field.password=The field password must be filled 
     103 
     104bo.user.emailNotSend=The email to the user cannot be sent, the email seems not valid : 
Note: See TracChangeset for help on using the changeset viewer.