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 * Nuxeo - initial API and implementation 016 * 017 * $Id: JOOoConvertPluginImpl.java 18651 2007-05-13 20:28:53Z sfermigier $ 018 */ 019 020package org.nuxeo.ecm.webapp.contentbrowser; 021 022import static org.jboss.seam.ScopeType.*; 023 024import java.security.Principal; 025import java.util.ArrayList; 026import java.util.List; 027 028import org.jboss.seam.annotations.In; 029import org.jboss.seam.annotations.Name; 030import org.jboss.seam.annotations.Scope; 031import org.nuxeo.ecm.core.api.security.SecurityConstants; 032import org.nuxeo.ecm.platform.usermanager.UserManager; 033import org.nuxeo.ecm.webapp.documenttemplates.DocumentTemplatesActions; 034import org.nuxeo.ecm.webapp.security.SecurityActions; 035 036@Name("isolatedWorkspaceCreator") 037@Scope(STATELESS) 038public class IsolatedWorkspaceCreatorBean { 039 040 @In(create = true) 041 protected transient Principal currentUser; 042 043 @In(create = true) 044 protected transient DocumentTemplatesActions documentTemplatesActions; 045 046 @In(create = true) 047 protected transient UserManager userManager; 048 049 @In(create = true) 050 protected transient SecurityActions securityActions; 051 052 public String createIsolatedWorkspace() { 053 054 String result = documentTemplatesActions.createDocumentFromTemplate(); 055 // String result = documentActions.saveDocument(); 056 List<String> principalsName = new ArrayList<String>(); 057 principalsName.add(currentUser.getName()); 058 principalsName.addAll(userManager.getAdministratorsGroups()); 059 060 // Grant to principalList 061 for (String principalName : principalsName) { 062 securityActions.addPermission(principalName, SecurityConstants.EVERYTHING, true); 063 } 064 065 // DENY at root 066 securityActions.addPermission(SecurityConstants.EVERYONE, SecurityConstants.EVERYTHING, false); 067 securityActions.updateSecurityOnDocument(); 068 069 return result; 070 } 071 072}