001/* 002 * (C) Copyright 2006-2012 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 */ 017package org.nuxeo.ecm.automation.core.operations.services; 018 019import org.nuxeo.ecm.automation.AutomationService; 020import org.nuxeo.ecm.automation.OperationContext; 021import org.nuxeo.ecm.automation.core.Constants; 022import org.nuxeo.ecm.automation.core.annotations.Context; 023import org.nuxeo.ecm.automation.core.annotations.Operation; 024import org.nuxeo.ecm.automation.core.annotations.OperationMethod; 025import org.nuxeo.ecm.core.api.CoreSession; 026import org.nuxeo.ecm.core.api.DocumentModel; 027import org.nuxeo.ecm.platform.filemanager.api.FileManager; 028import org.nuxeo.ecm.platform.userworkspace.api.UserWorkspaceService; 029import org.nuxeo.runtime.api.Framework; 030 031/** 032 * Simple operation to get the User's personal Workspace 033 * 034 * @author Tiry (tdelprat@nuxeo.com) 035 * @since 5.5 036 */ 037@Operation(id = UserWorkspace.ID, category = Constants.CAT_USERS_GROUPS, label = "Get Home", description = "Retrieve user's personal workspace.", aliases = { "UserWorkspace.Get" }) 038public class UserWorkspace { 039 040 public static final String ID = "User.GetUserWorkspace"; 041 042 @Context 043 protected CoreSession session; 044 045 @Context 046 protected FileManager fileManager; 047 048 @Context 049 protected AutomationService as; 050 051 @Context 052 protected OperationContext context; 053 054 @OperationMethod 055 public DocumentModel run() { 056 UserWorkspaceService uws = Framework.getLocalService(UserWorkspaceService.class); 057 DocumentModel home = uws.getUserPersonalWorkspace(session.getPrincipal().getName(), session.getRootDocument()); 058 return home; 059 } 060}