001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://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, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://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.webdav;
029
030import org.opencms.repository.I_CmsRepositorySession;
031
032import java.util.ArrayList;
033import java.util.List;
034
035import org.apache.jackrabbit.webdav.DavSession;
036
037/**
038 * DavSession implementation for Jackrabbit WebDAV, mostly just a wrapper for I_CmsRepositorySession.
039 */
040public class CmsDavSession implements DavSession {
041
042    /** The underlying repository session. */
043    private I_CmsRepositorySession m_repoSession;
044
045    /** Lock tokens. */
046    private List<String> m_lockTokens = new ArrayList<>();
047
048    /**
049     * Creates a new DAV session.
050     *
051     * @param session the underlying repository session
052     */
053    public CmsDavSession(I_CmsRepositorySession session) {
054
055        m_repoSession = session;
056
057    }
058
059    /**
060     * @see org.apache.jackrabbit.webdav.DavSession#addLockToken(java.lang.String)
061     */
062    public void addLockToken(String token) {
063
064        m_lockTokens.add(token);
065    }
066
067    /**
068     * @see org.apache.jackrabbit.webdav.DavSession#addReference(java.lang.Object)
069     */
070    public void addReference(Object reference) {
071
072        throw new UnsupportedOperationException();
073    }
074
075    /**
076     * @see org.apache.jackrabbit.webdav.DavSession#getLockTokens()
077     */
078    public String[] getLockTokens() {
079
080        return m_lockTokens.toArray(new String[] {});
081    }
082
083    /**
084     * Gets the OpenCms repository session.
085     *
086     * @return the OpenCms repository session
087     */
088    public I_CmsRepositorySession getRepositorySession() {
089
090        return m_repoSession;
091
092    }
093
094    /**
095     * @see org.apache.jackrabbit.webdav.DavSession#removeLockToken(java.lang.String)
096     */
097    public void removeLockToken(String token) {
098
099        m_lockTokens.remove(token);
100    }
101
102    /**
103     * @see org.apache.jackrabbit.webdav.DavSession#removeReference(java.lang.Object)
104     */
105    public void removeReference(Object reference) {
106
107        throw new UnsupportedOperationException();
108    }
109
110}