001/*
002 * (C) Copyright 2006-2007 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     btatar
018 *
019 * $Id$
020 */
021
022package org.nuxeo.ecm.platform.userworkspace.api;
023
024import java.io.Serializable;
025
026import org.nuxeo.ecm.core.api.CoreSession;
027import org.nuxeo.ecm.core.api.DocumentModel;
028import org.nuxeo.ecm.core.api.NuxeoPrincipal;
029
030/**
031 * User workspace service class that is used to get the document model for the personal workspace of the current user.
032 *
033 * @author btatar
034 */
035public interface UserWorkspaceService extends Serializable {
036
037    /**
038     * Gets the current user personal workspace from a lower level.
039     * <p>
040     * If this personal workspace does not exist then a new one will be created for the user who is represented by first
041     * argument.
042     *
043     * @param userName the current user
044     * @param currentDocument the current document on which the user was on
045     * @return the DocumentModel for the personal workspace of the current user
046     */
047    DocumentModel getCurrentUserPersonalWorkspace(String userName, DocumentModel currentDocument);
048
049    DocumentModel getCurrentUserPersonalWorkspace(CoreSession userCoreSession, DocumentModel context);
050
051    /**
052     * Gets a detached user workspace of a specified user.
053     *
054     * @param userName is the username of the wanted user's workspace owner
055     * @param context is a document to determine the domain
056     * @return the DocumentModel for the personal workspace
057     * @since 5.5
058     */
059    DocumentModel getUserPersonalWorkspace(String userName, DocumentModel context);
060
061    /**
062     * Gets a detached user workspace of a specified user depending of the passed principal.
063     *
064     * @param principal of the wanted user's workspace owner
065     * @param context is a document to determine the domain
066     * @return the DocumentModel for the personal workspace
067     * @since 5.7
068     */
069    DocumentModel getUserPersonalWorkspace(NuxeoPrincipal principal, DocumentModel context);
070
071}