001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (https://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software GmbH & Co. KG, please see the
018 * company website: https://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: https://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.main;
029
030import org.opencms.util.CmsUUID;
031
032import java.util.List;
033
034/**
035 * This interface is used to define the session storage implementation provider.<p>
036 *
037 * @since 6.5.5
038 */
039public interface I_CmsSessionStorageProvider {
040
041    /**
042     * Returns the stored session info object with the given id.<p>
043     *
044     * @param sessionId the id to lookup
045     *
046     * @return the stored session info object, or <code>null</code> if not found
047     */
048    CmsSessionInfo get(CmsUUID sessionId);
049
050    /**
051     * Returns all current stored session info objects.<p>
052     *
053     * @return all current stored session info objects
054     */
055    List<CmsSessionInfo> getAll();
056
057    /**
058     * Returns all current stored session info objects for the given user.<p>
059     *
060     * @param userId the id of the user to retrieve the session info objects for
061     *
062     * @return all current stored session info objects for the given user
063     */
064    List<CmsSessionInfo> getAllOfUser(CmsUUID userId);
065
066    /**
067     * Returns the current number of stored session info objects.<p>
068     *
069     * @return the current number of stored session info objects, or zero if empty
070     */
071    int getSize();
072
073    /**
074     * Initializes the storage.<p>
075     *
076     * @throws CmsInitException if initialization fails
077     */
078    void initialize() throws CmsInitException;
079
080    /**
081     * Stores the given session info object.<p>
082     *
083     * @param sessionInfo the session info object to be stored
084     *
085     * @return the session info object previously stored with the same session id, or <code>null</code> if none
086     */
087    CmsSessionInfo put(CmsSessionInfo sessionInfo);
088
089    /**
090     * Removes the stored session info object identified by the given session id.<p>
091     *
092     * @param sessionId the id that identifies the stored session info object to remove
093     *
094     * @return the removed cached entry or <code>null</code> if none
095     */
096    CmsSessionInfo remove(CmsUUID sessionId);
097
098    /**
099     * Last cleanup possibility.<p>
100     *
101     * @throws Exception if something goes wrong
102     */
103    void shutdown() throws Exception;
104
105    /**
106     * Validates all session info objects removing any session that have became invalidated.<p>
107     */
108    void validate();
109}