001package fr.ifremer.adagio.core.service.administration.user;
002
003/*
004 * #%L
005 * SIH-Adagio :: Core
006 * $Id:$
007 * $HeadURL:$
008 * %%
009 * Copyright (C) 2012 - 2014 Ifremer
010 * %%
011 * This program is free software: you can redistribute it and/or modify
012 * it under the terms of the GNU Affero General Public License as published by
013 * the Free Software Foundation, either version 3 of the License, or
014 * (at your option) any later version.
015 * 
016 * This program is distributed in the hope that it will be useful,
017 * but WITHOUT ANY WARRANTY; without even the implied warranty of
018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
019 * GNU General Public License for more details.
020 * 
021 * You should have received a copy of the GNU Affero General Public License
022 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
023 * #L%
024 */
025
026import org.springframework.beans.factory.annotation.Autowired;
027import org.springframework.context.annotation.Lazy;
028import org.springframework.stereotype.Service;
029
030import fr.ifremer.adagio.core.dao.administration.user.PersonSessionExtendDao;
031
032@Service("personSessionService")
033@Lazy
034public class PersonSessionServiceImpl implements PersonSessionService {
035
036    @Autowired
037    private PersonSessionExtendDao personSessionDao;
038
039    @Override
040    public int initPersonSession(int personId) throws UserNotFoundException {
041        Integer sessionId = personSessionDao.initPersonSession(personId);
042        if (sessionId == null) {
043            throw new UserNotFoundException(String.format("User not exists, with id=%s", personId));
044        }
045        return sessionId.intValue();
046    }
047}