diff --git a/source/java/org/alfresco/web/bean/wcm/DeleteWebsiteDialog.java b/source/java/org/alfresco/web/bean/wcm/DeleteWebsiteDialog.java new file mode 100644 index 0000000000..9903d15db2 --- /dev/null +++ b/source/java/org/alfresco/web/bean/wcm/DeleteWebsiteDialog.java @@ -0,0 +1,98 @@ +package org.alfresco.web.bean.wcm; + +import java.text.MessageFormat; +import java.util.List; + +import javax.faces.context.FacesContext; + +import org.alfresco.model.ContentModel; +import org.alfresco.service.cmr.avm.AVMService; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.namespace.RegexQNamePattern; +import org.alfresco.web.app.Application; +import org.alfresco.web.bean.repository.Node; +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. + * + * @author kevinr + */ +public class DeleteWebsiteDialog extends DeleteSpaceDialog +{ + protected AVMService avmService; + + // ------------------------------------------------------------------------------ + // Bean property getters and setters + + /** + * @param avmService The AVMService to set. + */ + public void setAvmService(AVMService avmService) + { + this.avmService = avmService; + } + + + // ------------------------------------------------------------------------------ + // Dialog implementation + + @Override + protected String finishImpl(FacesContext context, String outcome) throws Exception + { + Node websiteNode = this.browseBean.getActionSpace(); + + // delete all attached website sandboxes in reverse order to the layering + String storeRoot = (String)websiteNode.getProperties().get(ContentModel.PROP_AVMSTORE); + + // get the list of users who have a sandbox in the website + int index = 0; + List userInfoRefs = nodeService.getChildAssocs( + websiteNode.getNodeRef(), ContentModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef ref : userInfoRefs) + { + String username = (String)nodeService.getProperty(ref.getChildRef(), ContentModel.PROP_WEBUSERNAME); + + // delete the preview store for this user + deleteStore(AVMConstants.buildAVMUserPreviewStoreName(storeRoot, username)); + + // delete the main store for this user + deleteStore(AVMConstants.buildAVMUserMainStoreName(storeRoot, username)); + } + + // remove the main staging and preview stores + deleteStore(AVMConstants.buildAVMStagingPreviewStoreName(storeRoot)); + deleteStore(AVMConstants.buildAVMStagingStoreName(storeRoot)); + + // use the super implementation to delete the node itself + return super.finishImpl(context, outcome); + } + + private void deleteStore(String store) + { + // check it exists before we try to remove it + if (this.avmService.getAVMStore(store) != null) + { + this.avmService.purgeAVMStore(store); + } + } + + + // ------------------------------------------------------------------------------ + // Bean Getters and Setters + + /** + * Returns the confirmation to display to the user before deleting the content. + * + * @return The formatted message to display + */ + public String getConfirmMessage() + { + String fileConfirmMsg = Application.getMessage(FacesContext.getCurrentInstance(), + "delete_website_confirm"); + + return MessageFormat.format(fileConfirmMsg, + new Object[] {this.browseBean.getActionSpace().getName()}); + } +} diff --git a/source/web/images/icons/delete_website.gif b/source/web/images/icons/delete_website.gif new file mode 100644 index 0000000000..a42e0c0eae Binary files /dev/null and b/source/web/images/icons/delete_website.gif differ diff --git a/source/web/images/icons/delete_website_large.gif b/source/web/images/icons/delete_website_large.gif new file mode 100644 index 0000000000..e55401f3ff Binary files /dev/null and b/source/web/images/icons/delete_website_large.gif differ