mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merge WCM-SERVICES to HEAD
Changes 11272-11536 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@11562 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2008 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
|
||||
@@ -24,17 +24,9 @@
|
||||
*/
|
||||
package org.alfresco.web.bean.wcm;
|
||||
|
||||
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;
|
||||
import org.alfresco.wcm.webproject.WebProjectService;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.bean.spaces.DeleteSpaceDialog;
|
||||
@@ -48,27 +40,23 @@ public class DeleteWebsiteDialog extends DeleteSpaceDialog
|
||||
{
|
||||
private static final long serialVersionUID = -3598950865168230942L;
|
||||
|
||||
transient private AVMService avmService;
|
||||
transient private WebProjectService wpService;
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean property getters and setters
|
||||
|
||||
/**
|
||||
* @param avmService
|
||||
* The AVMService to set.
|
||||
*/
|
||||
public void setAvmService(AVMService avmService)
|
||||
public void setWebProjectService(WebProjectService wpService)
|
||||
{
|
||||
this.avmService = avmService;
|
||||
this.wpService = wpService;
|
||||
}
|
||||
|
||||
protected AVMService getAvmService()
|
||||
protected WebProjectService getWebProjectService()
|
||||
{
|
||||
if (avmService == null)
|
||||
{
|
||||
avmService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getAVMService();
|
||||
}
|
||||
return avmService;
|
||||
if (wpService == null)
|
||||
{
|
||||
wpService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getWebProjectService();
|
||||
}
|
||||
return wpService;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
@@ -80,88 +68,14 @@ public class DeleteWebsiteDialog extends DeleteSpaceDialog
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
Node websiteNode = this.browseBean.getActionSpace();
|
||||
Node websiteNode = this.browseBean.getActionSpace();
|
||||
|
||||
if (websiteNode != null)
|
||||
{
|
||||
// delete all attached website sandboxes in reverse order to the layering
|
||||
String storeRoot = (String) websiteNode.getProperties().get(WCMAppModel.PROP_AVMSTORE);
|
||||
|
||||
if (storeRoot != null)
|
||||
{
|
||||
// Notifiy virtualization server about removing this website
|
||||
//
|
||||
// Implementation note:
|
||||
//
|
||||
// Because the removal of virtual webapps in the virtualization
|
||||
// server is recursive, it only needs to be given the name of
|
||||
// the main staging store.
|
||||
//
|
||||
// This notification must occur *prior* to purging content
|
||||
// within the AVM because the virtualization server must list
|
||||
// the avm_webapps dir in each store to discover which
|
||||
// virtual webapps must be unloaded. The virtualization
|
||||
// server traverses the sandbox's stores in most-to-least
|
||||
// dependent order, so clients don't have to worry about
|
||||
// accessing a preview layer whose main layer has been torn
|
||||
// out from under it.
|
||||
//
|
||||
// It does not matter what webapp name we give here, so "/ROOT"
|
||||
// is as sensible as anything else. It's all going away.
|
||||
|
||||
String sandbox = AVMUtil.buildStagingStoreName(storeRoot);
|
||||
String path = AVMUtil.buildStoreWebappPath(sandbox, "/ROOT");
|
||||
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);
|
||||
for (ChildAssociationRef ref : userInfoRefs)
|
||||
{
|
||||
String username = (String) getNodeService().getProperty(ref.getChildRef(), WCMAppModel.PROP_WEBUSERNAME);
|
||||
|
||||
// delete the preview store for this user
|
||||
deleteStore(AVMUtil.buildUserPreviewStoreName(storeRoot, username));
|
||||
|
||||
// delete the main store for this user
|
||||
deleteStore(AVMUtil.buildUserMainStoreName(storeRoot, username));
|
||||
}
|
||||
|
||||
// remove the main staging and preview stores
|
||||
deleteStore(AVMUtil.buildStagingPreviewStoreName(storeRoot));
|
||||
deleteStore(AVMUtil.buildStagingStoreName(storeRoot));
|
||||
}
|
||||
}
|
||||
|
||||
// use the super implementation to delete the node itself
|
||||
return super.finishImpl(context, outcome);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a store, checking for its existance first.
|
||||
*
|
||||
* @param store
|
||||
*/
|
||||
private void deleteStore(final String store)
|
||||
{
|
||||
// check it exists before we try to remove it
|
||||
if (this.getAvmService().getStore(store) != null)
|
||||
{
|
||||
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");
|
||||
}
|
||||
}
|
||||
if (websiteNode != null)
|
||||
{
|
||||
getWebProjectService().deleteWebProject(websiteNode.getNodeRef());
|
||||
}
|
||||
|
||||
return super.finishImpl(context, outcome);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user