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.security;
021
022import static org.jboss.seam.ScopeType.CONVERSATION;
023
024import java.io.Serializable;
025import java.util.List;
026
027import org.jboss.seam.annotations.In;
028import org.jboss.seam.annotations.Name;
029import org.jboss.seam.annotations.Scope;
030import org.nuxeo.ecm.core.api.CoreSession;
031import org.nuxeo.ecm.core.api.DocumentModel;
032import org.nuxeo.ecm.core.api.security.SecurityConstants;
033import org.nuxeo.ecm.platform.ui.web.api.NavigationContext;
034import org.nuxeo.ecm.webapp.documentsLists.DocumentsListsManager;
035
036@Name("massSecurityModifierActions")
037@Scope(CONVERSATION)
038public class MassSecurityModifierActions implements Serializable {
039
040    private static final long serialVersionUID = 4978984433628773791L;
041
042    @In(create = true)
043    protected transient NavigationContext navigationContext;
044
045    @In(create = true)
046    protected transient DocumentsListsManager documentsListsManager;
047
048    @In(create = true, required = false)
049    protected transient CoreSession documentManager;
050
051    private Boolean blockRightInheritance;
052
053    @In(create = true)
054    private PermissionActionListManager permissionActionListManager;
055
056    @In(create = true)
057    private PermissionListManager permissionListManager;
058
059    @In(create = true)
060    private PrincipalListManager principalListManager;
061
062    private final SecurityData securityData = null;
063
064    public Boolean getBlockRightInheritance() {
065        return blockRightInheritance;
066    }
067
068    public void setBlockRightInheritance(Boolean blockRightInheritance) {
069        this.blockRightInheritance = blockRightInheritance;
070    }
071
072    // Really used?
073    public String applySecurity(String listName) {
074        // get the list
075        List<DocumentModel> docs2Modify = documentsListsManager.getWorkingList(listName);
076        int nbModifiedDocs = 0;
077
078        for (DocumentModel doc : docs2Modify) {
079            if (!documentManager.hasPermission(doc.getParentRef(), SecurityConstants.WRITE_PROPERTIES)) {
080                continue;
081            }
082        }
083
084        /*
085         * Object[] params = { nb_published_docs }; facesMessages.add(FacesMessage.SEVERITY_INFO, "#0 " +
086         * resourcesAccessor.getMessages().get("n_published_docs"), params); if (nb_published_docs <
087         * docs2Publish.size()) { facesMessages.add(FacesMessage.SEVERITY_WARN, resourcesAccessor.getMessages().get(
088         * "selection_contains_non_publishable_docs")); }
089         */
090        // check rights on the lists
091
092        // apply security
093
094        // navigate
095        return navigationContext.navigateToDocument(navigationContext.getCurrentDocument());
096    }
097
098}