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; 025import java.security.Principal; 026 027import org.nuxeo.ecm.core.api.CoreSession; 028import org.nuxeo.ecm.core.api.DocumentModel; 029import org.nuxeo.ecm.core.api.NuxeoPrincipal; 030 031/** 032 * User workspace service class that is used to get the document model for the personal workspace of the current user. 033 * 034 * @author btatar 035 */ 036public interface UserWorkspaceService extends Serializable { 037 038 /** 039 * Gets the current user personal workspace from a lower level. 040 * <p> 041 * If this personal workspace does not exist then a new one will be created for the user who is represented by first 042 * argument. 043 * 044 * @param userName the current user 045 * @param currentDocument the current document on which the user was on 046 * @return the DocumentModel for the personal workspace of the current user 047 */ 048 DocumentModel getCurrentUserPersonalWorkspace(String userName, DocumentModel currentDocument); 049 050 DocumentModel getCurrentUserPersonalWorkspace(CoreSession userCoreSession, DocumentModel context); 051 052 /** 053 * Gets a detached user workspace of a specified user. 054 * 055 * @param userName is the username of the wanted user's workspace owner 056 * @param context is a document to determine the domain 057 * @return the DocumentModel for the personal workspace 058 * @since 5.5 059 */ 060 DocumentModel getUserPersonalWorkspace(String userName, DocumentModel context); 061 062 /** 063 * Gets a detached user workspace of a specified user depending of the passed principal. 064 * 065 * @param principal of the wanted user's workspace owner 066 * @param context is a document to determine the domain 067 * @return the DocumentModel for the personal workspace 068 * @since 5.7 069 */ 070 DocumentModel getUserPersonalWorkspace(NuxeoPrincipal principal, DocumentModel context); 071 072 /** 073 * Checks whether the passed document is under the user's workspace (or is the workspace itself). 074 * 075 * @param principal the user 076 * @param username the username, if principal is not available 077 * @param doc the document 078 * @return {@code true} if the document is under the user's workspace 079 * @since 9.2 080 */ 081 boolean isUnderUserWorkspace(Principal principal, String username, DocumentModel doc); 082 083}