mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V2.9 to HEAD
9194:Merged V2.2 to V2.9 8557: Fix for WCM-1120 8580: Fix remainder of WCM-1120 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9200 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -164,6 +164,7 @@
|
||||
<permissions>
|
||||
<permission allow="true">CreateChildren</permission>
|
||||
</permissions>
|
||||
<evaluator>org.alfresco.web.action.evaluator.WCMContentManagerEvaluator</evaluator>
|
||||
<label-id>create_webapp</label-id>
|
||||
<image>/images/icons/create_webapp.gif</image>
|
||||
<action>dialog:createWebappFolder</action>
|
||||
|
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing
|
||||
*/
|
||||
package org.alfresco.web.action.evaluator;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.WCMAppModel;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.web.action.ActionEvaluator;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.bean.wcm.SandboxFactory;
|
||||
|
||||
/**
|
||||
* Evaluator to return true if the current user is a content manager for the current website.
|
||||
*
|
||||
* @author Gavin Cornwell
|
||||
*/
|
||||
public class WCMContentManagerEvaluator extends BaseActionEvaluator
|
||||
{
|
||||
private static final long serialVersionUID = 2588681368739253602L;
|
||||
|
||||
/**
|
||||
* @return true if the item is not locked by another user
|
||||
*/
|
||||
public boolean evaluate(final Node node)
|
||||
{
|
||||
FacesContext facesContext = FacesContext.getCurrentInstance();
|
||||
NodeService nodeService = Repository.getServiceRegistry(facesContext).getNodeService();
|
||||
|
||||
String storeId = (String)nodeService.getProperty(node.getNodeRef(), WCMAppModel.PROP_AVMSTORE);
|
||||
|
||||
return SandboxFactory.isContentManager(storeId);
|
||||
}
|
||||
}
|
@@ -30,8 +30,11 @@ import org.alfresco.model.ApplicationModel;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.model.WCMAppModel;
|
||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
|
||||
/**
|
||||
* Bean implementation for the AVM "Create Webapp Folder" dialog.
|
||||
@@ -54,22 +57,37 @@ public class CreateWebappDialog extends CreateFolderDialog
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
final String stagingStore = this.avmBrowseBean.getStagingStore();
|
||||
final String parent = AVMUtil.buildSandboxRootPath( stagingStore );
|
||||
this.getAvmService().createDirectory(parent, this.name);
|
||||
|
||||
this.path = AVMNodeConverter.ExtendAVMPath(parent, this.name);
|
||||
this.getAvmService().addAspect(this.path, ApplicationModel.ASPECT_UIFACETS);
|
||||
this.getAvmService().addAspect(this.path, WCMAppModel.ASPECT_WEBAPP);
|
||||
if (this.description != null && this.description.length() != 0)
|
||||
if (SandboxFactory.isContentManager(stagingStore))
|
||||
{
|
||||
this.getAvmService().setNodeProperty(path,
|
||||
AuthenticationUtil.runAs(new RunAsWork<Object>(){
|
||||
|
||||
public Object doWork() throws Exception
|
||||
{
|
||||
final String parent = AVMUtil.buildSandboxRootPath( stagingStore );
|
||||
CreateWebappDialog.this.getAvmService().createDirectory(parent, CreateWebappDialog.this.name);
|
||||
|
||||
CreateWebappDialog.this.path = AVMNodeConverter.ExtendAVMPath(parent, CreateWebappDialog.this.name);
|
||||
CreateWebappDialog.this.getAvmService().addAspect(CreateWebappDialog.this.path, ApplicationModel.ASPECT_UIFACETS);
|
||||
CreateWebappDialog.this.getAvmService().addAspect(CreateWebappDialog.this.path, WCMAppModel.ASPECT_WEBAPP);
|
||||
if (CreateWebappDialog.this.description != null && CreateWebappDialog.this.description.length() != 0)
|
||||
{
|
||||
CreateWebappDialog.this.getAvmService().setNodeProperty(path,
|
||||
ContentModel.PROP_DESCRIPTION,
|
||||
new PropertyValue(DataTypeDefinition.TEXT,
|
||||
this.description));
|
||||
CreateWebappDialog.this.description));
|
||||
}
|
||||
|
||||
// Snapshot the store with the empty webapp
|
||||
this.getAvmService().createSnapshot(stagingStore, null, null);
|
||||
CreateWebappDialog.this.getAvmService().createSnapshot(stagingStore, null, null);
|
||||
return null;
|
||||
}}, AuthenticationUtil.getSystemUserName());
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AccessDeniedException("Only content managers may create new webapp folders");
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
@@ -29,6 +29,9 @@ import java.util.List;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.WCMAppModel;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
import org.alfresco.service.cmr.avm.AVMService;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
@@ -37,8 +40,7 @@ import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.bean.spaces.DeleteSpaceDialog;
|
||||
|
||||
/**
|
||||
* Bean implementation for the "Delete Website" dialog.
|
||||
* Removes all user stores and the main staging and preview stores.
|
||||
* Bean implementation for the "Delete Website" dialog. Removes all user stores and the main staging and preview stores.
|
||||
*
|
||||
* @author kevinr
|
||||
*/
|
||||
@@ -52,7 +54,8 @@ public class DeleteWebsiteDialog extends DeleteSpaceDialog
|
||||
// Bean property getters and setters
|
||||
|
||||
/**
|
||||
* @param avmService The AVMService to set.
|
||||
* @param avmService
|
||||
* The AVMService to set.
|
||||
*/
|
||||
public void setAvmService(AVMService avmService)
|
||||
{
|
||||
@@ -68,7 +71,6 @@ public class DeleteWebsiteDialog extends DeleteSpaceDialog
|
||||
return avmService;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Dialog implementation
|
||||
|
||||
@@ -112,8 +114,7 @@ public class DeleteWebsiteDialog extends DeleteSpaceDialog
|
||||
AVMUtil.removeAllVServerWebapps(path, true);
|
||||
|
||||
// get the list of users who have a sandbox in the website
|
||||
List<ChildAssociationRef> userInfoRefs = getNodeService().getChildAssocs(
|
||||
websiteNode.getNodeRef(), WCMAppModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL);
|
||||
List<ChildAssociationRef> userInfoRefs = getNodeService().getChildAssocs(websiteNode.getNodeRef(), WCMAppModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL);
|
||||
for (ChildAssociationRef ref : userInfoRefs)
|
||||
{
|
||||
String username = (String) getNodeService().getProperty(ref.getChildRef(), WCMAppModel.PROP_WEBUSERNAME);
|
||||
@@ -140,18 +141,31 @@ public class DeleteWebsiteDialog extends DeleteSpaceDialog
|
||||
*
|
||||
* @param store
|
||||
*/
|
||||
private void deleteStore(String store)
|
||||
private void deleteStore(final String store)
|
||||
{
|
||||
// check it exists before we try to remove it
|
||||
if (this.getAvmService().getStore(store) != null)
|
||||
{
|
||||
this.getAvmService().purgeStore(store);
|
||||
if (SandboxFactory.isContentManager(store))
|
||||
{
|
||||
AuthenticationUtil.runAs(new RunAsWork<Object>(){
|
||||
|
||||
public Object doWork() throws Exception
|
||||
{
|
||||
DeleteWebsiteDialog.this.getAvmService().purgeStore(store);
|
||||
return null;
|
||||
}}, AuthenticationUtil.getSystemUserName());
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AccessDeniedException("Only content managers may delete websites");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the message bundle id of the confirmation message to display to
|
||||
* the user before deleting the website.
|
||||
* Returns the message bundle id of the confirmation message to display to the user before deleting the website.
|
||||
*
|
||||
* @return The message bundle id
|
||||
*/
|
||||
|
@@ -33,6 +33,7 @@ import org.alfresco.config.JNDIConstants;
|
||||
import org.alfresco.model.WCMAppModel;
|
||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.sandbox.SandboxConstants;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.avm.AVMService;
|
||||
@@ -251,6 +252,52 @@ public final class SandboxFactory
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isContentManager(String storeId)
|
||||
{
|
||||
ServiceRegistry services = Repository.getServiceRegistry(FacesContext.getCurrentInstance());
|
||||
AVMService avmService = services.getAVMService();
|
||||
NodeService nodeService = services.getNodeService();
|
||||
|
||||
String userName = AuthenticationUtil.getCurrentUserName();
|
||||
|
||||
String storeName = extractStagingAreaName(storeId);
|
||||
PropertyValue pValue = avmService.getStoreProperty(storeName, SandboxConstants.PROP_WEB_PROJECT_NODE_REF);
|
||||
|
||||
if (pValue != null)
|
||||
{
|
||||
NodeRef webProjectNodeRef = (NodeRef) pValue.getValue(DataTypeDefinition.NODE_REF);
|
||||
|
||||
// Apply sepcific user permissions as set on the web project
|
||||
List<ChildAssociationRef> userInfoRefs = nodeService.getChildAssocs(webProjectNodeRef, WCMAppModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL);
|
||||
for (ChildAssociationRef ref : userInfoRefs)
|
||||
{
|
||||
NodeRef userInfoRef = ref.getChildRef();
|
||||
String user = (String) nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERNAME);
|
||||
String role = (String) nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERROLE);
|
||||
|
||||
if(userName.equals(user) && role.equals(AVMUtil.ROLE_CONTENT_MANAGER))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static String extractStagingAreaName(String name)
|
||||
{
|
||||
int index = name.indexOf("--");
|
||||
if (index == -1)
|
||||
{
|
||||
return name;
|
||||
}
|
||||
return name.substring(0, index);
|
||||
}
|
||||
|
||||
public static void addStagingAreaUser(String storeId, String authority, String role)
|
||||
{
|
||||
// The stores have the mask set in updateSandboxManagers
|
||||
|
Reference in New Issue
Block a user