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