001/*
002 * (C) Copyright 2006-2007 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     btatar
016 *
017 * $Id$
018 */
019
020package org.nuxeo.ecm.platform.userworkspace.api;
021
022import java.io.Serializable;
023
024import org.nuxeo.ecm.core.api.CoreSession;
025import org.nuxeo.ecm.core.api.DocumentModel;
026import org.nuxeo.ecm.core.api.NuxeoPrincipal;
027
028/**
029 * User workspace service class that is used to get the document model for the personal workspace of the current user.
030 *
031 * @author btatar
032 */
033public interface UserWorkspaceService extends Serializable {
034
035    /**
036     * Gets the current user personal workspace from a lower level.
037     * <p>
038     * If this personal workspace does not exist then a new one will be created for the user who is represented by first
039     * argument.
040     *
041     * @param userName the current user
042     * @param currentDocument the current document on which the user was on
043     * @return the DocumentModel for the personal workspace of the current user
044     */
045    DocumentModel getCurrentUserPersonalWorkspace(String userName, DocumentModel currentDocument);
046
047    DocumentModel getCurrentUserPersonalWorkspace(CoreSession userCoreSession, DocumentModel context);
048
049    /**
050     * Gets a detached user workspace of a specified user.
051     *
052     * @param userName is the username of the wanted user's workspace owner
053     * @param context is a document to determine the domain
054     * @return the DocumentModel for the personal workspace
055     * @since 5.5
056     */
057    DocumentModel getUserPersonalWorkspace(String userName, DocumentModel context);
058
059    /**
060     * Gets a detached user workspace of a specified user depending of the passed principal.
061     *
062     * @param principal of the wanted user's workspace owner
063     * @param context is a document to determine the domain
064     * @return the DocumentModel for the personal workspace
065     * @since 5.7
066     */
067    DocumentModel getUserPersonalWorkspace(NuxeoPrincipal principal, DocumentModel context);
068
069}