Merged V3.2 to HEAD

15596: Merged V3.1 to V3.2
        14017: Fix ETHREEOH-1880 - remove (double-)reverse of WCM staging snapshot order
        14112: Fix ETHREEOH-1758 - apply contributed patch
        14447: Merged V2.2 to V3.1
            14276: ETWOTWO-1224 / WCM-948 - browsing staging area during (commit of) large submit can cause AVMNotFoundException: Path /www/avm_webapps not found.
       14452: Add WCM services-based unit test for ETWOTWO-1224 / WCM-948
       14589: ETHREEOH-1646 - User Sandboxes aren't visible for Content Publisher
    15604: Merged V3.1 to V3.2
        14734: Merged V2.2 to V3.1
            14718: ETWOTWO-1244 - unable to revert some snapshots ("Does not exist: xxx")
        14852: Merged V2.2 to V3.1
            14720: ETWOTWO-1183 - "Show All Sandboxes" checkbox should only be visible for "Content Publisher" or "Content Manager"
        15032: Fix ETHREEOH-2240 - delete WCM web project (does not clean-up workflow sandboxes and also appears in archive store)
        15037: Fix ETHREEOH-2240 - follow-on for Alfresco Explorer's Manage (Review) Task Dialog
        15056: Fix ETHREEOH-2297 - WCM layered folder - problem deleting file
        15072: Minor - fix remote AVM test
    15605: Merged V3.1 to V3.2
        15082: Merged V2.2 to V3.1
            15081: AVM - add tests only
        15083: Fix ETHREEOH-2296 - user conflict when updating an AVM layered file
        15118: Merged V2.2 to V3.1
            15115: Fix ETWOTWO-1265 - WCM locking not working as expected (+ add WCM services test)
        15137: Fix ETHREEOH-2309 and ETHREEOH-227 - including refactor (& clean-up) of WCM-related actions
        15156: Fix ETHREEOH-2078 & ETHREEOH-2040 - WCM - deploy to localhost causes "Must have at least one store" errors
        15175: Fix ETHREEOH-2309 and ETHREEOH-227 - further clean-up of WCM submit/undo actions (for consistency)
        15190: Minor: message updates for WCM submit/undo actions


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@16858 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2009-10-13 11:34:23 +00:00
parent aa61dae7b0
commit d67b53b7cc
7 changed files with 98 additions and 60 deletions

View File

@@ -1720,6 +1720,7 @@ by=by
assignee=Assignee
comment=Comment
invalid_task=The task being viewed is no longer valid, it has probably been completed by another user.
error_webprj_does_not_exist=Web project {0} does not exist (it may have been deleted)
# Workflow Definitions
wf_review_options=Review Options

View File

@@ -25,7 +25,6 @@
package org.alfresco.web.bean.wcm;
import java.io.FileNotFoundException;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
@@ -52,9 +51,7 @@ import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.avm.AVMNodeType;
import org.alfresco.repo.avm.actions.AVMUndoSandboxListAction;
import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMService;
@@ -75,11 +72,11 @@ import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.cmr.workflow.WorkflowService;
import org.alfresco.service.cmr.workflow.WorkflowTask;
import org.alfresco.util.NameMatcher;
import org.alfresco.util.Pair;
import org.alfresco.util.VirtServerUtils;
import org.alfresco.wcm.asset.AssetInfo;
import org.alfresco.wcm.asset.AssetInfoImpl;
import org.alfresco.wcm.sandbox.SandboxInfo;
import org.alfresco.wcm.sandbox.SandboxService;
import org.alfresco.wcm.util.WCMUtil;
import org.alfresco.wcm.webproject.WebProjectInfo;
import org.alfresco.wcm.webproject.WebProjectService;
import org.alfresco.web.app.Application;
@@ -91,6 +88,7 @@ import org.alfresco.web.bean.BrowseBean;
import org.alfresco.web.bean.NavigationBean;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.repository.User;
import org.alfresco.web.bean.search.SearchContext;
import org.alfresco.web.forms.FormInstanceData;
import org.alfresco.web.forms.FormNotFoundException;
@@ -1070,6 +1068,18 @@ public class AVMBrowseBean implements IContextListener
return false;
}
public boolean getIsManagerOrPublisherRole()
{
Node wpNode = getWebsite();
if (wpNode != null)
{
User user = Application.getCurrentUser(FacesContext.getCurrentInstance());
String userRole = getWebProjectService().getWebUserRole(wpNode.getNodeRef(), user.getUserName());
return (WCMUtil.ROLE_CONTENT_MANAGER.equals(userRole) || WCMUtil.ROLE_CONTENT_PUBLISHER.equals(userRole));
}
return false;
}
/**
* @return true to show all sandboxes visible to this user, false to only show the current user sandbox
*/
@@ -1086,6 +1096,7 @@ public class AVMBrowseBean implements IContextListener
this.showAllSandboxes = value;
}
/**
* @return true if the website has had a deployment attempt
*/
@@ -1645,8 +1656,9 @@ public class AVMBrowseBean implements IContextListener
*/
public void revertNode(ActionEvent event)
{
final String path = getPathFromEventArgs(event);
final List<String> namesForDisplayMsg = new LinkedList<String>();
String avmPath = getPathFromEventArgs(event);
String sbStoreId = WCMUtil.getSandboxStoreId(avmPath);
List<String> namesForDisplayMsg = new LinkedList<String>();
UserTransaction tx = null;
final FacesContext context = FacesContext.getCurrentInstance();
try
@@ -1654,50 +1666,41 @@ public class AVMBrowseBean implements IContextListener
tx = Repository.getUserTransaction(context, false);
tx.begin();
AVMNodeDescriptor node = getAvmService().lookup(-1, path, true);
AVMNodeDescriptor node = getAvmService().lookup(-1, avmPath, true);
if (node != null)
{
FormInstanceData fid = null;
if (getAvmService().hasAspect(-1, path, WCMAppModel.ASPECT_RENDITION))
if (getAvmService().hasAspect(-1, avmPath, WCMAppModel.ASPECT_RENDITION))
{
fid = this.getFormsService().getRendition(-1, path).getPrimaryFormInstanceData();
fid = this.getFormsService().getRendition(-1, avmPath).getPrimaryFormInstanceData();
}
else if (getAvmService().hasAspect(-1, path, WCMAppModel.ASPECT_FORM_INSTANCE_DATA))
else if (getAvmService().hasAspect(-1, avmPath, WCMAppModel.ASPECT_FORM_INSTANCE_DATA))
{
fid = this.getFormsService().getFormInstanceData(-1, path);
fid = this.getFormsService().getFormInstanceData(-1, avmPath);
}
List<Pair<Integer, String>> versionPaths = new ArrayList<Pair<Integer, String>>();
List<String> paths = new ArrayList<String>();
if (fid != null)
{
versionPaths.add(new Pair<Integer, String>(-1, fid.getPath()));
paths.add(WCMUtil.getStoreRelativePath(fid.getPath()));
namesForDisplayMsg.add(fid.getName());
for (Rendition r : fid.getRenditions())
{
versionPaths.add(new Pair<Integer, String>(-1, r.getPath()));
paths.add(WCMUtil.getStoreRelativePath(r.getPath()));
namesForDisplayMsg.add(r.getName());
}
}
else
{
versionPaths.add(new Pair<Integer, String>(-1, path));
paths.add(WCMUtil.getStoreRelativePath(avmPath));
namesForDisplayMsg.add(node.getName());
}
final Map<String, Serializable> args = new HashMap<String, Serializable>(1, 1.0f);
args.put(AVMUndoSandboxListAction.PARAM_NODE_LIST, (Serializable)versionPaths);
Action action = this.getActionService().createAction(AVMUndoSandboxListAction.NAME, args);
this.getActionService().executeAction(action, null); // dummy action ref
getSandboxService().revertList(sbStoreId, paths);
}
// commit the transaction
tx.commit();
// possibly update webapp after commit
if (VirtServerUtils.requiresUpdateNotification(path))
{
AVMUtil.updateVServerWebapp(path, true);
}
// if we get here, all was well - output friendly status message to the user
this.displayStatusMessage(context,
MessageFormat.format(Application.getMessage(context, MSG_REVERT_SUCCESS),
@@ -2162,46 +2165,47 @@ public class AVMBrowseBean implements IContextListener
final HtmlCommandButton button = (HtmlCommandButton) event.getComponent();
List<Object> params = button.getChildren();
String userStore = null;
String stagingStore = null;
String userStorePath = null;
//String stagingStorePath = null;
for (Object obj : params)
{
UIParameter uip = (UIParameter) obj;
if (uip.getName().equals("userStorePath"))
{
userStore = (String) uip.getValue();
userStorePath = (String) uip.getValue();
}
/*
if (uip.getName().equals("stagingStorePath"))
{
stagingStore = (String) uip.getValue();
}
*/
}
NameMatcher matcher = (NameMatcher) FacesContextUtils.getRequiredWebApplicationContext(FacesContext.getCurrentInstance()).getBean("globalPathExcluder");
String[] storePath = WCMUtil.splitPath(userStorePath);
// calcluate the list of differences between the user store and the staging area
List<AVMDifference> diffs = this.getAvmSyncService().compare(-1, userStore, -1, stagingStore, matcher);
List<Pair<Integer, String>> versionPaths = new ArrayList<Pair<Integer, String>>();
List<AssetInfo> assets = sbService.listChanged(storePath[0], storePath[1], true);
String sbStoreId = storePath[0];
List<String> paths = new ArrayList<String>();
List<WorkflowTask> tasks = null;
for (AVMDifference diff : diffs)
for (AssetInfo asset : assets)
{
if (diff.getDifferenceCode() == AVMDifference.CONFLICT)
if (asset.getDiffCode() == AVMDifference.CONFLICT)
{
AVMNodeDescriptor node = getAvmService().lookup(-1, diff.getSourcePath(), true);
// TODO refactor getAssociatedTasksForNode to use AssetInfo instead of AVMNodeDescriptor
AVMNodeDescriptor node = ((AssetInfoImpl)asset).getAVMNodeDescriptor();
if (tasks == null)
{
tasks = AVMWorkflowUtil.getAssociatedTasksForSandbox(AVMUtil.getStoreName(diff.getSourcePath()));
tasks = AVMWorkflowUtil.getAssociatedTasksForSandbox(sbStoreId);
}
if (AVMWorkflowUtil.getAssociatedTasksForNode(node, tasks).size() == 0)
{
String revertPath = diff.getSourcePath();
versionPaths.add(new Pair<Integer, String>(-1, revertPath));
paths.add(asset.getPath());
}
}
}
Map<String, Serializable> args = new HashMap<String, Serializable>(1, 1.0f);
args.put(AVMUndoSandboxListAction.PARAM_NODE_LIST, (Serializable) versionPaths);
Action action = this.getActionService().createAction(AVMUndoSandboxListAction.NAME, args);
this.getActionService().executeAction(action, null);
sbService.revertList(sbStoreId, paths);
}
}

View File

@@ -24,6 +24,7 @@
*/
package org.alfresco.web.bean.wcm;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -31,10 +32,14 @@ import java.util.Map;
import javax.faces.context.FacesContext;
import javax.transaction.UserTransaction;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.linkvalidation.LinkValidationReport;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.wcm.sandbox.SandboxConstants;
import org.alfresco.service.cmr.avm.AVMNotFoundException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.wcm.sandbox.SandboxConstants;
import org.alfresco.wcm.util.WCMUtil;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
@@ -53,10 +58,13 @@ public class ManageReviewTaskDialog extends ManageTaskDialog
{
private static final long serialVersionUID = 59524560340308134L;
private static final String MSG_WEB_PRJ_DOES_NOT_EXIST = "error_webprj_does_not_exist";
protected String store;
protected String webapp;
protected NodeRef webProjectRef;
protected AVMBrowseBean avmBrowseBean;
protected PermissionService permissionService;
private static final Log logger = LogFactory.getLog(ManageReviewTaskDialog.class);
@@ -85,8 +93,15 @@ public class ManageReviewTaskDialog extends ManageTaskDialog
this.store = this.workflowPackage.getStoreRef().getIdentifier();
// get the web project noderef for the workflow store
String wpStoreId = WCMUtil.getWebProjectStoreId(this.store);
this.webProjectRef = getWebProjectService().getWebProjectNodeFromStore(WCMUtil.getWebProjectStoreId(this.store));
if (this.webProjectRef == null)
{
String mesg = MessageFormat.format(Application.getMessage(context, MSG_WEB_PRJ_DOES_NOT_EXIST), wpStoreId);
throw new AlfrescoRuntimeException(mesg);
}
PropertyValue val = this.getAvmService().getStoreProperty(this.store,
SandboxConstants.PROP_LINK_VALIDATION_REPORT);
if (val != null)
@@ -184,6 +199,14 @@ public class ManageReviewTaskDialog extends ManageTaskDialog
this.avmBrowseBean = avmBrowseBean;
}
/**
* @param permissionService PermissionService instance
*/
public void setPermissionService(PermissionService permissionService)
{
this.permissionService = permissionService;
}
/**
* @return Determines if there are any test servers configured for the
* web project this task belongs to
@@ -203,7 +226,7 @@ public class ManageReviewTaskDialog extends ManageTaskDialog
{
result = Boolean.FALSE;
if (this.webProjectRef != null)
if (this.webProjectRef != null && permissionService.hasPermission(webProjectRef, PermissionService.READ_PROPERTIES).equals(AccessStatus.ALLOWED))
{
List<NodeRef> testServers = DeploymentUtil.findTestServers(this.webProjectRef, false);
if (testServers != null)
@@ -227,8 +250,16 @@ public class ManageReviewTaskDialog extends ManageTaskDialog
*/
public boolean getDeployAttempted()
{
PropertyValue propVal = getAvmService().getStoreProperty(this.store,
PropertyValue propVal = null;
try
{
propVal = getAvmService().getStoreProperty(this.store,
SandboxConstants.PROP_LAST_DEPLOYMENT_ID);
}
catch (AVMNotFoundException nfe)
{
// ignore - eg. web project deleted
}
return (propVal != null);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2008 Alfresco Software Limited.
* Copyright (C) 2005-2009 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
@@ -247,10 +247,8 @@ public class UISandboxSnapshots extends SelfRenderingComponent
determineDeploymentStatus(context, webProjectRef, sandbox, nodeService, avmService);
Map requestMap = context.getExternalContext().getRequestMap();
for (int i = versions.size() - 1; i >= 0; i--) // reverse order
for (SandboxVersion item : versions)
{
SandboxVersion item = versions.get(i);
// only display snapshots with a valid label/tag - others are system generated snapshots
if (! item.isSystemGenerated())
{

View File

@@ -336,7 +336,7 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa
if (showAllSandboxes)
{
Map<String, String> userRoles = null;
if (currentUserRole.equals(WCMUtil.ROLE_CONTENT_MANAGER))
if (currentUserRole.equals(WCMUtil.ROLE_CONTENT_MANAGER) || currentUserRole.equals(WCMUtil.ROLE_CONTENT_PUBLISHER))
{
Map<String, String> allUserRoles = wpService.listWebUsers(websiteRef);
@@ -408,8 +408,8 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa
if ((showAllSandboxes &&
(currentUserName.equals(username) ||
AVMUtil.ROLE_CONTENT_MANAGER.equals(currentUserRole) ||
AVMUtil.ROLE_CONTENT_PUBLISHER.equals(currentUserRole))) ||
WCMUtil.ROLE_CONTENT_MANAGER.equals(currentUserRole) ||
WCMUtil.ROLE_CONTENT_PUBLISHER.equals(currentUserRole))) ||
showAllSandboxes == false)
{
if (logger.isDebugEnabled())
@@ -558,7 +558,7 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa
menu.getChildren().add(refresh);
// Delete Sandbox action
if (AVMUtil.ROLE_CONTENT_MANAGER.equals(currentUserRole))
if (WCMUtil.ROLE_CONTENT_MANAGER.equals(currentUserRole))
{
UIActionLink delete = createAction(context, mainStore, username,
ACT_REMOVE_SANDBOX, "/images/icons/delete_sandbox.gif",

View File

@@ -2604,6 +2604,10 @@
<property-name>avmBrowseBean</property-name>
<value>#{AVMBrowseBean}</value>
</managed-property>
<managed-property>
<property-name>permissionService</property-name>
<value>#{PermissionService}</value>
</managed-property>
</managed-bean>
<managed-bean>

View File

@@ -1,5 +1,5 @@
<%--
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2009 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
@@ -233,7 +233,7 @@
<%-- used by the panel to add additional component facets --%>
<h:panelGroup id="sandboxes-panel-facets">
<f:facet name="title">
<h:panelGroup id="sandboxes-panel-facets-wrapper">
<h:panelGroup id="sandboxes-panel-facets-wrapper" rendered="#{AVMBrowseBean.isManagerOrPublisherRole}">
<h:selectBooleanCheckbox id="showAllSandboxes" value="#{AVMBrowseBean.showAllSandboxes}" onchange="document.forms['website'].submit(); return true;" immediate="false" />
<h:outputText id="txtShowSandboxes" value="#{msg.website_showallsandboxes}" style="vertical-align:15%" />
</h:panelGroup>