mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
AVM locking UI evaluators. Actions such as Edit, Update are hidden if the item is locked.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6021 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* 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.repo.avm.AVMNodeConverter;
|
||||||
|
import org.alfresco.service.cmr.avm.locking.AVMLockingService;
|
||||||
|
import org.alfresco.web.action.ActionEvaluator;
|
||||||
|
import org.alfresco.web.app.Application;
|
||||||
|
import org.alfresco.web.app.servlet.FacesHelper;
|
||||||
|
import org.alfresco.web.bean.repository.Node;
|
||||||
|
import org.alfresco.web.bean.repository.Repository;
|
||||||
|
import org.alfresco.web.bean.wcm.AVMBrowseBean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Evaluator to return if a item is accessable due to a WCM user level lock.
|
||||||
|
*
|
||||||
|
* @author Kevin Roast
|
||||||
|
*/
|
||||||
|
public class WCMLockEvaluator implements ActionEvaluator
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return true if the item is not locked by another user
|
||||||
|
*/
|
||||||
|
public boolean evaluate(Node node)
|
||||||
|
{
|
||||||
|
FacesContext fc = FacesContext.getCurrentInstance();
|
||||||
|
AVMLockingService avmLockService = Repository.getServiceRegistry(fc).getAVMLockingService();
|
||||||
|
AVMBrowseBean avmBrowseBean = (AVMBrowseBean)FacesHelper.getManagedBean(fc, AVMBrowseBean.BEAN_NAME);
|
||||||
|
|
||||||
|
String path = AVMNodeConverter.ToAVMVersionPath(node.getNodeRef()).getSecond();
|
||||||
|
String username = Application.getCurrentUser(fc).getUserName();
|
||||||
|
|
||||||
|
return avmLockService.hasAccess(avmBrowseBean.getWebProject().getNodeRef(), path, username);
|
||||||
|
}
|
||||||
|
}
|
@@ -30,7 +30,6 @@ import org.alfresco.repo.avm.AVMNodeConverter;
|
|||||||
import org.alfresco.repo.avm.wf.AVMSubmittedAspect;
|
import org.alfresco.repo.avm.wf.AVMSubmittedAspect;
|
||||||
import org.alfresco.service.cmr.avm.AVMService;
|
import org.alfresco.service.cmr.avm.AVMService;
|
||||||
import org.alfresco.util.Pair;
|
import org.alfresco.util.Pair;
|
||||||
import org.alfresco.web.action.ActionEvaluator;
|
|
||||||
import org.alfresco.web.bean.repository.Node;
|
import org.alfresco.web.bean.repository.Node;
|
||||||
import org.alfresco.web.bean.repository.Repository;
|
import org.alfresco.web.bean.repository.Repository;
|
||||||
import org.alfresco.web.bean.wcm.AVMUtil;
|
import org.alfresco.web.bean.wcm.AVMUtil;
|
||||||
@@ -41,22 +40,27 @@ import org.alfresco.web.bean.wcm.AVMUtil;
|
|||||||
*
|
*
|
||||||
* @author Kevin Roast
|
* @author Kevin Roast
|
||||||
*/
|
*/
|
||||||
public class WCMWorkflowDeletedEvaluator implements ActionEvaluator
|
public class WCMWorkflowDeletedEvaluator extends WCMLockEvaluator
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
|
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
|
||||||
*/
|
*/
|
||||||
public boolean evaluate(final Node node)
|
public boolean evaluate(final Node node)
|
||||||
{
|
{
|
||||||
final FacesContext facesContext = FacesContext.getCurrentInstance();
|
boolean proceed = false;
|
||||||
final AVMService avmService = Repository.getServiceRegistry(facesContext).getAVMService();
|
if (super.evaluate(node))
|
||||||
final Pair<Integer, String> p = AVMNodeConverter.ToAVMVersionPath(node.getNodeRef());
|
{
|
||||||
final int version = p.getFirst();
|
final FacesContext facesContext = FacesContext.getCurrentInstance();
|
||||||
final String path = p.getSecond();
|
final AVMService avmService = Repository.getServiceRegistry(facesContext).getAVMService();
|
||||||
|
final Pair<Integer, String> p = AVMNodeConverter.ToAVMVersionPath(node.getNodeRef());
|
||||||
// evaluate to true if we are within a workflow store (i.e. list of resources in the task
|
final int version = p.getFirst();
|
||||||
// dialog) or not part of an already in-progress workflow
|
final String path = p.getSecond();
|
||||||
return (AVMUtil.isWorkflowStore(AVMUtil.getStoreName(path)) ||
|
|
||||||
avmService.hasAspect(version, path, AVMSubmittedAspect.ASPECT) == false);
|
// evaluate to true if we are within a workflow store (i.e. list of resources in the task
|
||||||
|
// dialog) or not part of an already in-progress workflow
|
||||||
|
proceed = (AVMUtil.isWorkflowStore(AVMUtil.getStoreName(path)) ||
|
||||||
|
avmService.hasAspect(version, path, AVMSubmittedAspect.ASPECT) == false);
|
||||||
|
}
|
||||||
|
return proceed;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -30,7 +30,6 @@ import org.alfresco.repo.avm.AVMNodeConverter;
|
|||||||
import org.alfresco.repo.avm.wf.AVMSubmittedAspect;
|
import org.alfresco.repo.avm.wf.AVMSubmittedAspect;
|
||||||
import org.alfresco.service.cmr.avm.AVMService;
|
import org.alfresco.service.cmr.avm.AVMService;
|
||||||
import org.alfresco.util.Pair;
|
import org.alfresco.util.Pair;
|
||||||
import org.alfresco.web.action.ActionEvaluator;
|
|
||||||
import org.alfresco.web.bean.repository.Node;
|
import org.alfresco.web.bean.repository.Node;
|
||||||
import org.alfresco.web.bean.repository.Repository;
|
import org.alfresco.web.bean.repository.Repository;
|
||||||
import org.alfresco.web.bean.wcm.AVMUtil;
|
import org.alfresco.web.bean.wcm.AVMUtil;
|
||||||
@@ -40,23 +39,28 @@ import org.alfresco.web.bean.wcm.AVMUtil;
|
|||||||
*
|
*
|
||||||
* @author Kevin Roast
|
* @author Kevin Roast
|
||||||
*/
|
*/
|
||||||
public class WCMWorkflowEvaluator implements ActionEvaluator
|
public class WCMWorkflowEvaluator extends WCMLockEvaluator
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
|
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
|
||||||
*/
|
*/
|
||||||
public boolean evaluate(final Node node)
|
public boolean evaluate(final Node node)
|
||||||
{
|
{
|
||||||
final FacesContext facesContext = FacesContext.getCurrentInstance();
|
boolean proceed = false;
|
||||||
final AVMService avmService = Repository.getServiceRegistry(facesContext).getAVMService();
|
if (super.evaluate(node))
|
||||||
final Pair<Integer, String> p = AVMNodeConverter.ToAVMVersionPath(node.getNodeRef());
|
{
|
||||||
final int version = p.getFirst();
|
final FacesContext facesContext = FacesContext.getCurrentInstance();
|
||||||
final String path = p.getSecond();
|
final AVMService avmService = Repository.getServiceRegistry(facesContext).getAVMService();
|
||||||
|
final Pair<Integer, String> p = AVMNodeConverter.ToAVMVersionPath(node.getNodeRef());
|
||||||
// evaluate to true if we are not deleted and within a workflow store (i.e. list of resources
|
final int version = p.getFirst();
|
||||||
// in the task dialog) or not part of an already in-progress workflow
|
final String path = p.getSecond();
|
||||||
return ((AVMUtil.isWorkflowStore(AVMUtil.getStoreName(path)) ||
|
|
||||||
avmService.hasAspect(version, path, AVMSubmittedAspect.ASPECT) == false) &&
|
// evaluate to true if we are not deleted and within a workflow store (i.e. list of resources
|
||||||
avmService.lookup(version, path) != null);
|
// in the task dialog) or not part of an already in-progress workflow
|
||||||
|
proceed = ((AVMUtil.isWorkflowStore(AVMUtil.getStoreName(path)) ||
|
||||||
|
avmService.hasAspect(version, path, AVMSubmittedAspect.ASPECT) == false) &&
|
||||||
|
avmService.lookup(version, path) != null);
|
||||||
|
}
|
||||||
|
return proceed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -43,6 +43,7 @@ import org.alfresco.model.ContentModel;
|
|||||||
import org.alfresco.model.WCMAppModel;
|
import org.alfresco.model.WCMAppModel;
|
||||||
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.AVMLockingService;
|
||||||
import org.alfresco.service.cmr.model.FileInfo;
|
import org.alfresco.service.cmr.model.FileInfo;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.security.AuthorityType;
|
import org.alfresco.service.cmr.security.AuthorityType;
|
||||||
@@ -88,8 +89,8 @@ public class CreateWebsiteWizard extends BaseWizardBean
|
|||||||
private static Log logger = LogFactory.getLog(CreateWebsiteWizard.class);
|
private static Log logger = LogFactory.getLog(CreateWebsiteWizard.class);
|
||||||
|
|
||||||
protected boolean editMode = false;
|
protected boolean editMode = false;
|
||||||
|
|
||||||
protected String dnsName;
|
protected String dnsName;
|
||||||
|
|
||||||
protected String title;
|
protected String title;
|
||||||
protected String name;
|
protected String name;
|
||||||
protected String description;
|
protected String description;
|
||||||
@@ -99,6 +100,7 @@ public class CreateWebsiteWizard extends BaseWizardBean
|
|||||||
protected AVMService avmService;
|
protected AVMService avmService;
|
||||||
protected WorkflowService workflowService;
|
protected WorkflowService workflowService;
|
||||||
protected PersonService personService;
|
protected PersonService personService;
|
||||||
|
protected AVMLockingService avmLockingService;
|
||||||
|
|
||||||
/** datamodel for table of selected forms */
|
/** datamodel for table of selected forms */
|
||||||
protected DataModel formsDataModel = null;
|
protected DataModel formsDataModel = null;
|
||||||
@@ -217,6 +219,9 @@ public class CreateWebsiteWizard extends BaseWizardBean
|
|||||||
// navigate to the Websites folder so we can see the newly created folder
|
// navigate to the Websites folder so we can see the newly created folder
|
||||||
this.navigator.setCurrentNodeId(websiteParent.getId());
|
this.navigator.setCurrentNodeId(websiteParent.getId());
|
||||||
|
|
||||||
|
// inform the locking service about this new instance
|
||||||
|
this.avmLockingService.addWebProject(avmStore);
|
||||||
|
|
||||||
outcome = AlfrescoNavigationHandler.CLOSE_WIZARD_OUTCOME;
|
outcome = AlfrescoNavigationHandler.CLOSE_WIZARD_OUTCOME;
|
||||||
}
|
}
|
||||||
return outcome;
|
return outcome;
|
||||||
@@ -370,6 +375,14 @@ public class CreateWebsiteWizard extends BaseWizardBean
|
|||||||
{
|
{
|
||||||
this.personService = personService;
|
this.personService = personService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param avmLockingService The AVMLockingService to set
|
||||||
|
*/
|
||||||
|
public void setAvmLockingService(AVMLockingService avmLockingService)
|
||||||
|
{
|
||||||
|
this.avmLockingService = avmLockingService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
|
@@ -26,7 +26,9 @@ 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;
|
||||||
@@ -34,6 +36,9 @@ 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;
|
||||||
@@ -55,7 +60,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
|
||||||
@@ -76,6 +81,14 @@ 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
|
||||||
@@ -93,77 +106,106 @@ public class EditFilePropertiesDialog extends EditContentPropertiesDialog
|
|||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
NodeRef nodeRef = this.editableNode.getNodeRef();
|
NodeRef nodeRef = this.editableNode.getNodeRef();
|
||||||
Map<String, Object> editedProps = this.editableNode.getProperties();
|
String webProjectId = this.avmBrowseBean.getWebProject().getStoreId();
|
||||||
|
String avmPath = AVMNodeConverter.ToAVMVersionPath(nodeRef).getSecond();
|
||||||
|
String[] storePath = avmPath.split(":");
|
||||||
|
String username = Application.getCurrentUser(context).getUserName();
|
||||||
|
|
||||||
// handle the name property separately, it is a special case for AVM nodes
|
try
|
||||||
String name = (String)editedProps.get(ContentModel.PROP_NAME);
|
|
||||||
if (name != null)
|
|
||||||
{
|
{
|
||||||
editedProps.remove(ContentModel.PROP_NAME);
|
if (this.avmLockingService.hasAccess(webProjectId, avmPath, username) == false)
|
||||||
}
|
{
|
||||||
|
throw new AVMLockingException("avmlockservice.locked", new Object[]{avmPath});
|
||||||
// we need to put all the properties from the editable bag back into
|
|
||||||
// the format expected by the repository
|
|
||||||
Map<QName, Serializable> repoProps = this.nodeService.getProperties(nodeRef);
|
|
||||||
|
|
||||||
// but first extract and deal with the special mimetype property for ContentData
|
|
||||||
String mimetype = (String)editedProps.get(TEMP_PROP_MIMETYPE);
|
|
||||||
if (mimetype != null)
|
|
||||||
{
|
|
||||||
// remove temporary prop from list so it isn't saved with the others
|
|
||||||
editedProps.remove(TEMP_PROP_MIMETYPE);
|
|
||||||
ContentData contentData = (ContentData)editedProps.get(ContentModel.PROP_CONTENT);
|
|
||||||
if (contentData != null)
|
|
||||||
{
|
|
||||||
contentData = ContentData.setMimetype(contentData, mimetype);
|
|
||||||
editedProps.put(ContentModel.PROP_CONTENT.toString(), contentData);
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
|
||||||
// add the "titled" aspect if required, properties will get set below
|
|
||||||
if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TITLED) == false)
|
|
||||||
{
|
|
||||||
nodeService.addAspect(nodeRef, ContentModel.ASPECT_TITLED, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
// add the remaining properties
|
|
||||||
Iterator<String> iterProps = editedProps.keySet().iterator();
|
|
||||||
while (iterProps.hasNext())
|
|
||||||
{
|
|
||||||
String propName = iterProps.next();
|
|
||||||
QName qname = QName.createQName(propName);
|
|
||||||
|
|
||||||
// make sure the property is represented correctly
|
|
||||||
Serializable propValue = (Serializable)editedProps.get(propName);
|
|
||||||
|
|
||||||
// check for empty strings when using number types, set to null in this case
|
|
||||||
if ((propValue != null) && (propValue instanceof String) &&
|
|
||||||
(propValue.toString().length() == 0))
|
|
||||||
{
|
{
|
||||||
PropertyDefinition propDef = this.dictionaryService.getProperty(qname);
|
if (this.avmLockingService.getLock(webProjectId, avmPath) == null)
|
||||||
if (propDef != null)
|
|
||||||
{
|
{
|
||||||
if (propDef.getDataType().getName().equals(DataTypeDefinition.DOUBLE) ||
|
List<String> owners = new ArrayList<String>(1);
|
||||||
propDef.getDataType().getName().equals(DataTypeDefinition.FLOAT) ||
|
owners.add(username);
|
||||||
propDef.getDataType().getName().equals(DataTypeDefinition.INT) ||
|
AVMLock lock = new AVMLock(webProjectId, storePath[0], storePath[1], AVMLockingService.Type.DISCRETIONARY, owners);
|
||||||
propDef.getDataType().getName().equals(DataTypeDefinition.LONG))
|
this.avmLockingService.lockPath(lock);
|
||||||
{
|
}
|
||||||
propValue = null;
|
}
|
||||||
}
|
Map<String, Object> editedProps = this.editableNode.getProperties();
|
||||||
|
|
||||||
|
// handle the name property separately, it is a special case for AVM nodes
|
||||||
|
String name = (String)editedProps.get(ContentModel.PROP_NAME);
|
||||||
|
if (name != null)
|
||||||
|
{
|
||||||
|
editedProps.remove(ContentModel.PROP_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
// we need to put all the properties from the editable bag back into
|
||||||
|
// the format expected by the repository
|
||||||
|
Map<QName, Serializable> repoProps = this.nodeService.getProperties(nodeRef);
|
||||||
|
|
||||||
|
// but first extract and deal with the special mimetype property for ContentData
|
||||||
|
String mimetype = (String)editedProps.get(TEMP_PROP_MIMETYPE);
|
||||||
|
if (mimetype != null)
|
||||||
|
{
|
||||||
|
// remove temporary prop from list so it isn't saved with the others
|
||||||
|
editedProps.remove(TEMP_PROP_MIMETYPE);
|
||||||
|
ContentData contentData = (ContentData)editedProps.get(ContentModel.PROP_CONTENT);
|
||||||
|
if (contentData != null)
|
||||||
|
{
|
||||||
|
contentData = ContentData.setMimetype(contentData, mimetype);
|
||||||
|
editedProps.put(ContentModel.PROP_CONTENT.toString(), contentData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
repoProps.put(qname, propValue);
|
// add the "titled" aspect if required, properties will get set below
|
||||||
|
if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TITLED) == false)
|
||||||
|
{
|
||||||
|
this.nodeService.addAspect(nodeRef, ContentModel.ASPECT_TITLED, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the remaining properties
|
||||||
|
Iterator<String> iterProps = editedProps.keySet().iterator();
|
||||||
|
while (iterProps.hasNext())
|
||||||
|
{
|
||||||
|
String propName = iterProps.next();
|
||||||
|
QName qname = QName.createQName(propName);
|
||||||
|
|
||||||
|
// make sure the property is represented correctly
|
||||||
|
Serializable propValue = (Serializable)editedProps.get(propName);
|
||||||
|
|
||||||
|
// check for empty strings when using number types, set to null in this case
|
||||||
|
if ((propValue != null) && (propValue instanceof String) &&
|
||||||
|
(propValue.toString().length() == 0))
|
||||||
|
{
|
||||||
|
PropertyDefinition propDef = this.dictionaryService.getProperty(qname);
|
||||||
|
if (propDef != null)
|
||||||
|
{
|
||||||
|
if (propDef.getDataType().getName().equals(DataTypeDefinition.DOUBLE) ||
|
||||||
|
propDef.getDataType().getName().equals(DataTypeDefinition.FLOAT) ||
|
||||||
|
propDef.getDataType().getName().equals(DataTypeDefinition.INT) ||
|
||||||
|
propDef.getDataType().getName().equals(DataTypeDefinition.LONG))
|
||||||
|
{
|
||||||
|
propValue = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repoProps.put(qname, propValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
// send the properties back to the repository
|
||||||
|
this.nodeService.setProperties(nodeRef, repoProps);
|
||||||
|
|
||||||
|
// perform the rename last as for an AVM it changes the NodeRef
|
||||||
|
if (name != null)
|
||||||
|
{
|
||||||
|
this.fileFolderService.rename(nodeRef, name);
|
||||||
|
editedProps.put(ContentModel.PROP_NAME.toString(), name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
// send the properties back to the repository
|
|
||||||
this.nodeService.setProperties(nodeRef, repoProps);
|
|
||||||
|
|
||||||
// perform the rename last as for an AVM it changes the NodeRef
|
|
||||||
if (name != null)
|
|
||||||
{
|
{
|
||||||
this.fileFolderService.rename(nodeRef, name);
|
if (this.avmLockingService.getLock(webProjectId, avmPath) != null)
|
||||||
editedProps.put(ContentModel.PROP_NAME.toString(), name);
|
{
|
||||||
|
this.avmLockingService.removeLock(webProjectId, avmPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return outcome;
|
return outcome;
|
||||||
|
@@ -25,7 +25,10 @@
|
|||||||
package org.alfresco.web.ui.repo.component.evaluator;
|
package org.alfresco.web.ui.repo.component.evaluator;
|
||||||
|
|
||||||
import javax.faces.context.FacesContext;
|
import javax.faces.context.FacesContext;
|
||||||
|
import javax.faces.el.ValueBinding;
|
||||||
|
|
||||||
|
import org.alfresco.config.ConfigException;
|
||||||
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.web.action.ActionEvaluator;
|
import org.alfresco.web.action.ActionEvaluator;
|
||||||
import org.alfresco.web.bean.repository.Node;
|
import org.alfresco.web.bean.repository.Node;
|
||||||
import org.alfresco.web.ui.common.component.evaluator.BaseEvaluator;
|
import org.alfresco.web.ui.common.component.evaluator.BaseEvaluator;
|
||||||
@@ -72,6 +75,7 @@ public class ActionInstanceEvaluator extends BaseEvaluator
|
|||||||
// standard component attributes are restored by the super class
|
// standard component attributes are restored by the super class
|
||||||
super.restoreState(context, values[0]);
|
super.restoreState(context, values[0]);
|
||||||
this.evaluator = (ActionEvaluator)values[1];
|
this.evaluator = (ActionEvaluator)values[1];
|
||||||
|
this.evaluatorClassName = (String)values[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,10 +83,11 @@ public class ActionInstanceEvaluator extends BaseEvaluator
|
|||||||
*/
|
*/
|
||||||
public Object saveState(FacesContext context)
|
public Object saveState(FacesContext context)
|
||||||
{
|
{
|
||||||
Object values[] = new Object[2];
|
Object values[] = new Object[] {
|
||||||
// standard component attributes are saved by the super class
|
// standard component attributes are saved by the super class
|
||||||
values[0] = super.saveState(context);
|
super.saveState(context),
|
||||||
values[1] = this.evaluator;
|
this.evaluator,
|
||||||
|
this.evaluatorClassName };
|
||||||
return (values);
|
return (values);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,6 +96,24 @@ public class ActionInstanceEvaluator extends BaseEvaluator
|
|||||||
*/
|
*/
|
||||||
public ActionEvaluator getEvaluator()
|
public ActionEvaluator getEvaluator()
|
||||||
{
|
{
|
||||||
|
if (this.evaluator == null)
|
||||||
|
{
|
||||||
|
Object objEvaluator;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Class clazz = Class.forName(getEvaluatorClassName());
|
||||||
|
objEvaluator = clazz.newInstance();
|
||||||
|
}
|
||||||
|
catch (Throwable err)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Unable to construct action evaluator: " + getEvaluatorClassName());
|
||||||
|
}
|
||||||
|
if (objEvaluator instanceof ActionEvaluator == false)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Must implement ActionEvaluator interface: " + getEvaluatorClassName());
|
||||||
|
}
|
||||||
|
this.evaluator = (ActionEvaluator)objEvaluator;
|
||||||
|
}
|
||||||
return this.evaluator;
|
return this.evaluator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,6 +125,27 @@ public class ActionInstanceEvaluator extends BaseEvaluator
|
|||||||
this.evaluator = evaluator;
|
this.evaluator = evaluator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the evaluatorClassName
|
||||||
|
*/
|
||||||
|
public String getEvaluatorClassName()
|
||||||
|
{
|
||||||
|
ValueBinding vb = getValueBinding("evaluatorClassName");
|
||||||
|
if (vb != null)
|
||||||
|
{
|
||||||
|
this.evaluatorClassName = (String)vb.getValue(getFacesContext());
|
||||||
|
}
|
||||||
|
return this.evaluatorClassName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param evaluatorClassName the evaluatorClassName to set
|
||||||
|
*/
|
||||||
|
public void setEvaluatorClassName(String evaluatorClassName)
|
||||||
|
{
|
||||||
|
this.evaluatorClassName = evaluatorClassName;
|
||||||
|
}
|
||||||
|
|
||||||
private ActionEvaluator evaluator;
|
private ActionEvaluator evaluator;
|
||||||
|
private String evaluatorClassName;
|
||||||
}
|
}
|
||||||
|
@@ -40,4 +40,36 @@ public class ActionInstanceEvaluatorTag extends GenericEvaluatorTag
|
|||||||
{
|
{
|
||||||
return "org.alfresco.faces.ActionInstanceEvaluator";
|
return "org.alfresco.faces.ActionInstanceEvaluator";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see javax.faces.webapp.UIComponentTag#setProperties(javax.faces.component.UIComponent)
|
||||||
|
*/
|
||||||
|
protected void setProperties(UIComponent component)
|
||||||
|
{
|
||||||
|
super.setProperties(component);
|
||||||
|
setStringProperty(component, "evaluatorClassName", this.evaluatorClassName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see javax.servlet.jsp.tagext.Tag#release()
|
||||||
|
*/
|
||||||
|
public void release()
|
||||||
|
{
|
||||||
|
super.release();
|
||||||
|
this.evaluatorClassName = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the evaluatorClassName
|
||||||
|
*
|
||||||
|
* @param evaluatorClassName the evaluatorClassName
|
||||||
|
*/
|
||||||
|
public void setEvaluatorClassName(String evaluatorClassName)
|
||||||
|
{
|
||||||
|
this.evaluatorClassName = evaluatorClassName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** the evaluatorClassName */
|
||||||
|
private String evaluatorClassName;
|
||||||
}
|
}
|
||||||
|
@@ -2746,6 +2746,10 @@
|
|||||||
<property-name>personService</property-name>
|
<property-name>personService</property-name>
|
||||||
<value>#{PersonService}</value>
|
<value>#{PersonService}</value>
|
||||||
</managed-property>
|
</managed-property>
|
||||||
|
<managed-property>
|
||||||
|
<property-name>avmLockingService</property-name>
|
||||||
|
<value>#{AVMLockingService}</value>
|
||||||
|
</managed-property>
|
||||||
</managed-bean>
|
</managed-bean>
|
||||||
|
|
||||||
<managed-bean>
|
<managed-bean>
|
||||||
@@ -3196,6 +3200,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>fileFolderService</property-name>
|
<property-name>fileFolderService</property-name>
|
||||||
<value>#{FileFolderService}</value>
|
<value>#{FileFolderService}</value>
|
||||||
|
@@ -1466,6 +1466,36 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
</tag>
|
</tag>
|
||||||
|
|
||||||
|
<tag>
|
||||||
|
<name>actionInstanceEvaluator</name>
|
||||||
|
<tag-class>org.alfresco.web.ui.repo.tag.evaluator.ActionInstanceEvaluatorTag</tag-class>
|
||||||
|
<body-content>JSP</body-content>
|
||||||
|
|
||||||
|
<attribute>
|
||||||
|
<name>id</name>
|
||||||
|
<required>false</required>
|
||||||
|
<rtexprvalue>true</rtexprvalue>
|
||||||
|
</attribute>
|
||||||
|
|
||||||
|
<attribute>
|
||||||
|
<name>value</name>
|
||||||
|
<required>true</required>
|
||||||
|
<rtexprvalue>true</rtexprvalue>
|
||||||
|
</attribute>
|
||||||
|
|
||||||
|
<attribute>
|
||||||
|
<name>evaluatorClassName</name>
|
||||||
|
<required>true</required>
|
||||||
|
<rtexprvalue>true</rtexprvalue>
|
||||||
|
</attribute>
|
||||||
|
|
||||||
|
<attribute>
|
||||||
|
<name>binding</name>
|
||||||
|
<required>false</required>
|
||||||
|
<rtexprvalue>true</rtexprvalue>
|
||||||
|
</attribute>
|
||||||
|
</tag>
|
||||||
|
|
||||||
<tag>
|
<tag>
|
||||||
<name>multiValueSelector</name>
|
<name>multiValueSelector</name>
|
||||||
<tag-class>org.alfresco.web.ui.repo.tag.MultiValueSelectorTag</tag-class>
|
<tag-class>org.alfresco.web.ui.repo.tag.MultiValueSelectorTag</tag-class>
|
||||||
|
@@ -151,7 +151,9 @@
|
|||||||
<h:panelGroup id="props-panel-facets">
|
<h:panelGroup id="props-panel-facets">
|
||||||
<f:facet name="title">
|
<f:facet name="title">
|
||||||
<r:permissionEvaluator value="#{FileDetailsBean.document}" allow="Write">
|
<r:permissionEvaluator value="#{FileDetailsBean.document}" allow="Write">
|
||||||
<a:actionLink id="titleLink1" value="#{msg.modify}" showLink="false" image="/images/icons/Change_details.gif" action="dialog:editAvmFileProperties" />
|
<r:actionInstanceEvaluator value="#{FileDetailsBean.document}" evaluatorClassName="org.alfresco.web.action.evaluator.WCMWorkflowEvaluator">
|
||||||
|
<a:actionLink id="titleLink1" value="#{msg.modify}" showLink="false" image="/images/icons/Change_details.gif" action="dialog:editAvmFileProperties" />
|
||||||
|
</r:actionInstanceEvaluator>
|
||||||
</r:permissionEvaluator>
|
</r:permissionEvaluator>
|
||||||
</f:facet>
|
</f:facet>
|
||||||
</h:panelGroup>
|
</h:panelGroup>
|
||||||
|
Reference in New Issue
Block a user