mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
WCM Locking UI implementation and fixes.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6065 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -31,6 +31,7 @@ import javax.faces.context.FacesContext;
|
|||||||
|
|
||||||
import org.alfresco.model.WCMAppModel;
|
import org.alfresco.model.WCMAppModel;
|
||||||
import org.alfresco.service.cmr.avm.AVMService;
|
import org.alfresco.service.cmr.avm.AVMService;
|
||||||
|
import org.alfresco.service.cmr.avm.locking.AVMLockingService;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||||
@@ -52,8 +53,12 @@ public class DeleteSandboxDialog extends BaseDialogBean
|
|||||||
|
|
||||||
protected AVMService avmService;
|
protected AVMService avmService;
|
||||||
protected AVMBrowseBean avmBrowseBean;
|
protected AVMBrowseBean avmBrowseBean;
|
||||||
|
protected AVMLockingService avmLockingService;
|
||||||
|
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------
|
||||||
|
// Bean property getters and setters
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param avmBrowseBean The avmBrowseBean to set.
|
* @param avmBrowseBean The avmBrowseBean to set.
|
||||||
*/
|
*/
|
||||||
@@ -70,6 +75,14 @@ public class DeleteSandboxDialog extends BaseDialogBean
|
|||||||
this.avmService = avmService;
|
this.avmService = avmService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param avmLockingService The AVMLockingService to set
|
||||||
|
*/
|
||||||
|
public void setAvmLockingService(AVMLockingService avmLockingService)
|
||||||
|
{
|
||||||
|
this.avmLockingService = avmLockingService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// Dialog implementation
|
// Dialog implementation
|
||||||
@@ -125,10 +138,14 @@ public class DeleteSandboxDialog extends BaseDialogBean
|
|||||||
|
|
||||||
// purge the user main sandbox store from the system
|
// purge the user main sandbox store from the system
|
||||||
this.avmService.purgeStore(sandbox);
|
this.avmService.purgeStore(sandbox);
|
||||||
|
// remove any locks this user may have
|
||||||
|
this.avmLockingService.removeStoreLocks(sandbox);
|
||||||
|
|
||||||
// purge the user preview sandbox store from the system
|
// purge the user preview sandbox store from the system
|
||||||
sandbox = AVMUtil.buildUserPreviewStoreName(storeRoot, username);
|
sandbox = AVMUtil.buildUserPreviewStoreName(storeRoot, username);
|
||||||
this.avmService.purgeStore(sandbox);
|
this.avmService.purgeStore(sandbox);
|
||||||
|
// remove any locks this user may have
|
||||||
|
this.avmLockingService.removeStoreLocks(sandbox);
|
||||||
|
|
||||||
// remove the association to this web project user meta-data
|
// remove the association to this web project user meta-data
|
||||||
this.nodeService.removeChild(website.getNodeRef(), ref.getChildRef());
|
this.nodeService.removeChild(website.getNodeRef(), ref.getChildRef());
|
||||||
|
@@ -26,9 +26,7 @@ package org.alfresco.web.bean.wcm;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.faces.context.FacesContext;
|
import javax.faces.context.FacesContext;
|
||||||
@@ -36,9 +34,6 @@ import javax.faces.context.FacesContext;
|
|||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||||
import org.alfresco.service.cmr.avm.AVMService;
|
import org.alfresco.service.cmr.avm.AVMService;
|
||||||
import org.alfresco.service.cmr.avm.locking.AVMLock;
|
|
||||||
import org.alfresco.service.cmr.avm.locking.AVMLockingException;
|
|
||||||
import org.alfresco.service.cmr.avm.locking.AVMLockingService;
|
|
||||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||||
import org.alfresco.service.cmr.model.FileExistsException;
|
import org.alfresco.service.cmr.model.FileExistsException;
|
||||||
@@ -60,7 +55,7 @@ public class EditFilePropertiesDialog extends EditContentPropertiesDialog
|
|||||||
{
|
{
|
||||||
protected AVMBrowseBean avmBrowseBean;
|
protected AVMBrowseBean avmBrowseBean;
|
||||||
protected AVMService avmService;
|
protected AVMService avmService;
|
||||||
protected AVMLockingService avmLockingService;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// Bean property getters and setters
|
// Bean property getters and setters
|
||||||
@@ -81,14 +76,6 @@ public class EditFilePropertiesDialog extends EditContentPropertiesDialog
|
|||||||
this.avmService = avmService;
|
this.avmService = avmService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param avmLockingService The AVMLockingService to set
|
|
||||||
*/
|
|
||||||
public void setAvmLockingService(AVMLockingService avmLockingService)
|
|
||||||
{
|
|
||||||
this.avmLockingService = avmLockingService;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// Dialog implementation
|
// Dialog implementation
|
||||||
@@ -106,27 +93,6 @@ public class EditFilePropertiesDialog extends EditContentPropertiesDialog
|
|||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
NodeRef nodeRef = this.editableNode.getNodeRef();
|
NodeRef nodeRef = this.editableNode.getNodeRef();
|
||||||
String webProjectId = this.avmBrowseBean.getWebProject().getStoreId();
|
|
||||||
String avmPath = AVMNodeConverter.ToAVMVersionPath(nodeRef).getSecond();
|
|
||||||
String[] storePath = avmPath.split(":");
|
|
||||||
String username = Application.getCurrentUser(context).getUserName();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (this.avmLockingService.hasAccess(webProjectId, avmPath, username) == false)
|
|
||||||
{
|
|
||||||
throw new AVMLockingException("avmlockservice.locked", new Object[]{avmPath});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (this.avmLockingService.getLock(webProjectId, avmPath) == null)
|
|
||||||
{
|
|
||||||
List<String> owners = new ArrayList<String>(1);
|
|
||||||
owners.add(username);
|
|
||||||
AVMLock lock = new AVMLock(webProjectId, storePath[0], storePath[1], AVMLockingService.Type.DISCRETIONARY, owners);
|
|
||||||
this.avmLockingService.lockPath(lock);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Map<String, Object> editedProps = this.editableNode.getProperties();
|
Map<String, Object> editedProps = this.editableNode.getProperties();
|
||||||
|
|
||||||
// handle the name property separately, it is a special case for AVM nodes
|
// handle the name property separately, it is a special case for AVM nodes
|
||||||
@@ -157,7 +123,7 @@ public class EditFilePropertiesDialog extends EditContentPropertiesDialog
|
|||||||
// add the "titled" aspect if required, properties will get set below
|
// add the "titled" aspect if required, properties will get set below
|
||||||
if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TITLED) == false)
|
if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TITLED) == false)
|
||||||
{
|
{
|
||||||
this.nodeService.addAspect(nodeRef, ContentModel.ASPECT_TITLED, null);
|
nodeService.addAspect(nodeRef, ContentModel.ASPECT_TITLED, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the remaining properties
|
// add the remaining properties
|
||||||
@@ -199,14 +165,6 @@ public class EditFilePropertiesDialog extends EditContentPropertiesDialog
|
|||||||
this.fileFolderService.rename(nodeRef, name);
|
this.fileFolderService.rename(nodeRef, name);
|
||||||
editedProps.put(ContentModel.PROP_NAME.toString(), name);
|
editedProps.put(ContentModel.PROP_NAME.toString(), name);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (this.avmLockingService.getLock(webProjectId, avmPath) != null)
|
|
||||||
{
|
|
||||||
this.avmLockingService.removeLock(webProjectId, avmPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return outcome;
|
return outcome;
|
||||||
}
|
}
|
||||||
|
@@ -50,6 +50,7 @@ import org.alfresco.repo.domain.PropertyValue;
|
|||||||
import org.alfresco.repo.workflow.WorkflowModel;
|
import org.alfresco.repo.workflow.WorkflowModel;
|
||||||
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
||||||
import org.alfresco.service.cmr.avm.AVMService;
|
import org.alfresco.service.cmr.avm.AVMService;
|
||||||
|
import org.alfresco.service.cmr.avm.locking.AVMLockingService;
|
||||||
import org.alfresco.service.cmr.avmsync.AVMDifference;
|
import org.alfresco.service.cmr.avmsync.AVMDifference;
|
||||||
import org.alfresco.service.cmr.avmsync.AVMSyncService;
|
import org.alfresco.service.cmr.avmsync.AVMSyncService;
|
||||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||||
@@ -122,6 +123,7 @@ public class SubmitDialog extends BaseDialogBean
|
|||||||
protected AVMBrowseBean avmBrowseBean;
|
protected AVMBrowseBean avmBrowseBean;
|
||||||
protected WorkflowService workflowService;
|
protected WorkflowService workflowService;
|
||||||
protected AVMSyncService avmSyncService;
|
protected AVMSyncService avmSyncService;
|
||||||
|
protected AVMLockingService avmLockingService;
|
||||||
protected NameMatcher nameMatcher;
|
protected NameMatcher nameMatcher;
|
||||||
|
|
||||||
/** Current workflow for dialog context */
|
/** Current workflow for dialog context */
|
||||||
@@ -153,6 +155,14 @@ public class SubmitDialog extends BaseDialogBean
|
|||||||
this.avmSyncService = avmSyncService;
|
this.avmSyncService = avmSyncService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param avmLockingService The AVMLockingService to set
|
||||||
|
*/
|
||||||
|
public void setAvmLockingService(AVMLockingService avmLockingService)
|
||||||
|
{
|
||||||
|
this.avmLockingService = avmLockingService;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param avmBrowseBean The AVM BrowseBean to set
|
* @param avmBrowseBean The AVM BrowseBean to set
|
||||||
*/
|
*/
|
||||||
@@ -373,13 +383,14 @@ public class SubmitDialog extends BaseDialogBean
|
|||||||
AVMDifference diff = new AVMDifference(-1, srcPath, -1, destPath, AVMDifference.NEWER);
|
AVMDifference diff = new AVMDifference(-1, srcPath, -1, destPath, AVMDifference.NEWER);
|
||||||
diffs.add(diff);
|
diffs.add(diff);
|
||||||
|
|
||||||
|
// recursively remove locks from this item
|
||||||
|
recursivelyRemoveLocks(this.avmBrowseBean.getWebProject().getStoreId(), -1, srcPath);
|
||||||
|
|
||||||
// If nothing has required notifying the virtualization server
|
// If nothing has required notifying the virtualization server
|
||||||
// so far, check to see if destPath forces a notification
|
// so far, check to see if destPath forces a notification
|
||||||
// (e.g.: it might be a path to a jar file within WEB-INF/lib).
|
// (e.g.: it might be a path to a jar file within WEB-INF/lib).
|
||||||
|
|
||||||
if ( (this.virtUpdatePath == null) &&
|
if ( (this.virtUpdatePath == null) &&
|
||||||
VirtServerUtils.requiresUpdateNotification( destPath )
|
VirtServerUtils.requiresUpdateNotification( destPath ) )
|
||||||
)
|
|
||||||
{
|
{
|
||||||
this.virtUpdatePath = destPath;
|
this.virtUpdatePath = destPath;
|
||||||
}
|
}
|
||||||
@@ -397,6 +408,27 @@ public class SubmitDialog extends BaseDialogBean
|
|||||||
return outcome;
|
return outcome;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursively remove locks from a path. Walking child folders looking for files
|
||||||
|
* to remove locks from.
|
||||||
|
*/
|
||||||
|
private void recursivelyRemoveLocks(String webProject, int version, String path)
|
||||||
|
{
|
||||||
|
AVMNodeDescriptor desc = this.avmService.lookup(version, path, true);
|
||||||
|
if (desc.isFile() || desc.isDeletedFile())
|
||||||
|
{
|
||||||
|
this.avmLockingService.removeLock(webProject, path.substring(path.indexOf(":") + 1));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Map<String, AVMNodeDescriptor> list = avmService.getDirectoryListing(version, path, true);
|
||||||
|
for (AVMNodeDescriptor child : list.values())
|
||||||
|
{
|
||||||
|
recursivelyRemoveLocks(webProject, version, child.getPath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle notification to the virtualization server
|
* Handle notification to the virtualization server
|
||||||
* (this needs to occur after the sandbox is updated).
|
* (this needs to occur after the sandbox is updated).
|
||||||
|
@@ -48,6 +48,8 @@ import org.alfresco.web.ui.repo.component.UILockIcon;
|
|||||||
*/
|
*/
|
||||||
public class UIAVMLockIcon extends UILockIcon
|
public class UIAVMLockIcon extends UILockIcon
|
||||||
{
|
{
|
||||||
|
public static final String ALFRESCO_FACES_AVMLOCKICON = "org.alfresco.faces.AVMLockIcon";
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// Component implementation
|
// Component implementation
|
||||||
|
|
||||||
@@ -56,7 +58,7 @@ public class UIAVMLockIcon extends UILockIcon
|
|||||||
*/
|
*/
|
||||||
public String getFamily()
|
public String getFamily()
|
||||||
{
|
{
|
||||||
return "org.alfresco.faces.AVMLockIcon";
|
return ALFRESCO_FACES_AVMLOCKICON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -77,7 +79,7 @@ public class UIAVMLockIcon extends UILockIcon
|
|||||||
boolean locked = false;
|
boolean locked = false;
|
||||||
boolean lockedOwner = false;
|
boolean lockedOwner = false;
|
||||||
Object val = getValue();
|
Object val = getValue();
|
||||||
List<String> lockUser = null;
|
List<String> lockUsers = null;
|
||||||
final String avmPath = (val instanceof NodeRef
|
final String avmPath = (val instanceof NodeRef
|
||||||
? AVMNodeConverter.ToAVMVersionPath((NodeRef)val).getSecond()
|
? AVMNodeConverter.ToAVMVersionPath((NodeRef)val).getSecond()
|
||||||
: (val instanceof String
|
: (val instanceof String
|
||||||
@@ -93,15 +95,14 @@ public class UIAVMLockIcon extends UILockIcon
|
|||||||
{
|
{
|
||||||
locked = true;
|
locked = true;
|
||||||
final User currentUser = Application.getCurrentUser(context);
|
final User currentUser = Application.getCurrentUser(context);
|
||||||
lockUser = lock.getOwners();
|
lockUsers = lock.getOwners();
|
||||||
lockedOwner = (webProject.isManager(currentUser) ||
|
lockedOwner = (lockUsers.contains(currentUser.getUserName()));
|
||||||
lockUser.contains(currentUser.getUserName()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.encodeBegin(context,
|
this.encodeBegin(context,
|
||||||
locked,
|
locked,
|
||||||
lockedOwner,
|
lockedOwner,
|
||||||
lockUser == null ? new String[0] : (String[])lockUser.toArray(new String[lockUser.size()]));
|
lockUsers == null ? new String[0] : (String[])lockUsers.toArray(new String[lockUsers.size()]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -719,7 +719,8 @@ public class UIUserSandboxes extends SelfRenderingComponent
|
|||||||
out.write("</a></td><td>");
|
out.write("</a></td><td>");
|
||||||
out.write(linkPrefix);
|
out.write(linkPrefix);
|
||||||
out.write(name);
|
out.write(name);
|
||||||
UIAVMLockIcon lockIcon = (UIAVMLockIcon)fc.getApplication().createComponent("org.alfresco.faces.AVMLockIcon");
|
UIAVMLockIcon lockIcon = (UIAVMLockIcon)fc.getApplication().createComponent(
|
||||||
|
UIAVMLockIcon.ALFRESCO_FACES_AVMLOCKICON);
|
||||||
lockIcon.setId("lock_" + FacesHelper.makeLegalId(name));
|
lockIcon.setId("lock_" + FacesHelper.makeLegalId(name));
|
||||||
lockIcon.setValue(sourcePath);
|
lockIcon.setValue(sourcePath);
|
||||||
Utils.encodeRecursive(fc, lockIcon);
|
Utils.encodeRecursive(fc, lockIcon);
|
||||||
|
@@ -3054,6 +3054,10 @@
|
|||||||
<property-name>avmService</property-name>
|
<property-name>avmService</property-name>
|
||||||
<value>#{AVMService}</value>
|
<value>#{AVMService}</value>
|
||||||
</managed-property>
|
</managed-property>
|
||||||
|
<managed-property>
|
||||||
|
<property-name>avmLockingService</property-name>
|
||||||
|
<value>#{AVMLockingService}</value>
|
||||||
|
</managed-property>
|
||||||
<managed-property>
|
<managed-property>
|
||||||
<property-name>avmBrowseBean</property-name>
|
<property-name>avmBrowseBean</property-name>
|
||||||
<value>#{AVMBrowseBean}</value>
|
<value>#{AVMBrowseBean}</value>
|
||||||
@@ -3196,10 +3200,6 @@
|
|||||||
<property-name>avmService</property-name>
|
<property-name>avmService</property-name>
|
||||||
<value>#{AVMService}</value>
|
<value>#{AVMService}</value>
|
||||||
</managed-property>
|
</managed-property>
|
||||||
<managed-property>
|
|
||||||
<property-name>avmLockingService</property-name>
|
|
||||||
<value>#{AVMLockingService}</value>
|
|
||||||
</managed-property>
|
|
||||||
<managed-property>
|
<managed-property>
|
||||||
<property-name>fileFolderService</property-name>
|
<property-name>fileFolderService</property-name>
|
||||||
<value>#{FileFolderService}</value>
|
<value>#{FileFolderService}</value>
|
||||||
@@ -3397,6 +3397,10 @@
|
|||||||
<property-name>avmSyncService</property-name>
|
<property-name>avmSyncService</property-name>
|
||||||
<value>#{AVMSyncService}</value>
|
<value>#{AVMSyncService}</value>
|
||||||
</managed-property>
|
</managed-property>
|
||||||
|
<managed-property>
|
||||||
|
<property-name>avmLockingService</property-name>
|
||||||
|
<value>#{AVMLockingService}</value>
|
||||||
|
</managed-property>
|
||||||
<managed-property>
|
<managed-property>
|
||||||
<property-name>avmBrowseBean</property-name>
|
<property-name>avmBrowseBean</property-name>
|
||||||
<value>#{AVMBrowseBean}</value>
|
<value>#{AVMBrowseBean}</value>
|
||||||
|
Reference in New Issue
Block a user