mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-310: A user is not able to edit metadata of the record he has permissions for
* fixed up add record web script as it was using a admin only web script * extended rm meta-data web script to support above * EditRecordMetaData capability missing for composite Update and UpdateProperty capabilities * EditNonRecordMetaData capability takes into consideration whether the user is the owner or not git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.0@36180 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -488,7 +488,8 @@
|
|||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="rmEditNonRecordMetadataCapability"
|
<bean id="rmEditNonRecordMetadataCapability"
|
||||||
parent="declarativeCapability">
|
parent="declarativeCapability"
|
||||||
|
class="org.alfresco.module.org_alfresco_module_rm.capability.impl.EditCapability">
|
||||||
<property name="name" value="EditNonRecordMetadata"/>
|
<property name="name" value="EditNonRecordMetadata"/>
|
||||||
<property name="permission" value="EditNonRecordMetadata"/>
|
<property name="permission" value="EditNonRecordMetadata"/>
|
||||||
<property name="conditions">
|
<property name="conditions">
|
||||||
@@ -500,7 +501,7 @@
|
|||||||
|
|
||||||
<bean id="rmEditRecordMetadataCapability"
|
<bean id="rmEditRecordMetadataCapability"
|
||||||
parent="rmBaseCapability"
|
parent="rmBaseCapability"
|
||||||
class="org.alfresco.module.org_alfresco_module_rm.capability.impl.EditRecordMetadataCapability">
|
class="org.alfresco.module.org_alfresco_module_rm.capability.impl.EditCapability">
|
||||||
<property name="name" value="EditRecordMetadata"/>
|
<property name="name" value="EditRecordMetadata"/>
|
||||||
<property name="permission" value="EditRecordMetadata"/>
|
<property name="permission" value="EditRecordMetadata"/>
|
||||||
<property name="kinds">
|
<property name="kinds">
|
||||||
@@ -641,8 +642,7 @@
|
|||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="rmPlanningReviewCyclesCapability"
|
<bean id="rmPlanningReviewCyclesCapability"
|
||||||
parent="rmBaseCapability"
|
parent="declarativeCapability" >
|
||||||
class="org.alfresco.module.org_alfresco_module_rm.capability.impl.EditRecordMetadataCapability">
|
|
||||||
<property name="name" value="PlanningReviewCycles"/>
|
<property name="name" value="PlanningReviewCycles"/>
|
||||||
<property name="permission" value="PlanningReviewCycles"/>
|
<property name="permission" value="PlanningReviewCycles"/>
|
||||||
<property name="conditions">
|
<property name="conditions">
|
||||||
@@ -825,6 +825,7 @@
|
|||||||
<ref bean="rmEditDeclaredRecordMetadataCapability"/>
|
<ref bean="rmEditDeclaredRecordMetadataCapability"/>
|
||||||
<ref bean="rmEditNonRecordMetadataCapability"/>
|
<ref bean="rmEditNonRecordMetadataCapability"/>
|
||||||
<ref bean="rmCreateModifyRecordsInCuttoffFoldersCapability"/>
|
<ref bean="rmCreateModifyRecordsInCuttoffFoldersCapability"/>
|
||||||
|
<ref bean="rmEditRecordMetadataCapability"/>
|
||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
@@ -841,6 +842,7 @@
|
|||||||
<ref bean="rmEditDeclaredRecordMetadataCapability"/>
|
<ref bean="rmEditDeclaredRecordMetadataCapability"/>
|
||||||
<ref bean="rmEditNonRecordMetadataCapability"/>
|
<ref bean="rmEditNonRecordMetadataCapability"/>
|
||||||
<ref bean="rmCreateModifyRecordsInCuttoffFoldersCapability"/>
|
<ref bean="rmCreateModifyRecordsInCuttoffFoldersCapability"/>
|
||||||
|
<ref bean="rmEditRecordMetadataCapability"/>
|
||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
@@ -347,6 +347,7 @@
|
|||||||
parent="webscript">
|
parent="webscript">
|
||||||
<property name="recordsManagementService" ref="RecordsManagementService"/>
|
<property name="recordsManagementService" ref="RecordsManagementService"/>
|
||||||
<property name="namespaceService" ref="namespaceService"/>
|
<property name="namespaceService" ref="namespaceService"/>
|
||||||
|
<property name="nodeService" ref="NodeService"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
@@ -1,7 +1,7 @@
|
|||||||
<webscript>
|
<webscript>
|
||||||
<shortname>RM node metadata retrieval service</shortname>
|
<shortname>RM node metadata retrieval service</shortname>
|
||||||
<description>Used by the extended RM forms service to retrieve RM node metadata.</description>
|
<description>Used by the extended RM forms service to retrieve RM node metadata.</description>
|
||||||
<url>/api/rmmetadata?noderef={noderef?}&type={type?}</url>
|
<url>/api/rmmetadata?noderef={noderef?}&type={type?}&extended={extended?}</url>
|
||||||
<format default="json" />
|
<format default="json" />
|
||||||
<authentication>user</authentication>
|
<authentication>user</authentication>
|
||||||
<transaction allow="readonly">required</transaction>
|
<transaction allow="readonly">required</transaction>
|
||||||
|
@@ -1,3 +1,16 @@
|
|||||||
{
|
{
|
||||||
"kind" : ${kind}
|
"kind" : "${kind}"
|
||||||
|
<#if extended>
|
||||||
|
,
|
||||||
|
"aspects":
|
||||||
|
[
|
||||||
|
<#list aspects as aspect>
|
||||||
|
{
|
||||||
|
"name": "${aspect.name}",
|
||||||
|
"prefixedName": "${aspect.prefixedName}"
|
||||||
|
}
|
||||||
|
<#if aspect_has_next>,</#if>
|
||||||
|
</#list>
|
||||||
|
]
|
||||||
|
</#if>
|
||||||
}
|
}
|
@@ -27,11 +27,12 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
|||||||
import org.alfresco.service.cmr.security.OwnableService;
|
import org.alfresco.service.cmr.security.OwnableService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edit record metadata capability implementation.
|
* Edit capability, checks the permission and whether the current user is the owner of the
|
||||||
|
* object.
|
||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
*/
|
*/
|
||||||
public class EditRecordMetadataCapability extends DeclarativeCapability
|
public class EditCapability extends DeclarativeCapability
|
||||||
{
|
{
|
||||||
private OwnableService ownableService;
|
private OwnableService ownableService;
|
||||||
|
|
@@ -18,14 +18,19 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.module.org_alfresco_module_rm.script.slingshot.forms;
|
package org.alfresco.module.org_alfresco_module_rm.script.slingshot.forms;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.FilePlanComponentKind;
|
import org.alfresco.module.org_alfresco_module_rm.FilePlanComponentKind;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
|
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.springframework.extensions.webscripts.Cache;
|
import org.springframework.extensions.webscripts.Cache;
|
||||||
@@ -43,6 +48,7 @@ public class RMMetaDataGet extends DeclarativeWebScript
|
|||||||
/** Query parameters */
|
/** Query parameters */
|
||||||
private static final String PARAM_NODEREF = "noderef";
|
private static final String PARAM_NODEREF = "noderef";
|
||||||
private static final String PARAM_TYPE = "type";
|
private static final String PARAM_TYPE = "type";
|
||||||
|
private static final String PARAM_EXTENDED = "extended";
|
||||||
|
|
||||||
/** NodeRef pattern */
|
/** NodeRef pattern */
|
||||||
private static final Pattern nodeRefPattern = Pattern.compile(".+://.+/.+");
|
private static final Pattern nodeRefPattern = Pattern.compile(".+://.+/.+");
|
||||||
@@ -53,6 +59,9 @@ public class RMMetaDataGet extends DeclarativeWebScript
|
|||||||
/** Namespace service */
|
/** Namespace service */
|
||||||
private NamespaceService namespaceService;
|
private NamespaceService namespaceService;
|
||||||
|
|
||||||
|
/** Node service */
|
||||||
|
private NodeService nodeService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param rmService records management service
|
* @param rmService records management service
|
||||||
*/
|
*/
|
||||||
@@ -69,6 +78,14 @@ public class RMMetaDataGet extends DeclarativeWebScript
|
|||||||
this.namespaceService = namespaceService;
|
this.namespaceService = namespaceService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param nodeService node service
|
||||||
|
*/
|
||||||
|
public void setNodeService(NodeService nodeService)
|
||||||
|
{
|
||||||
|
this.nodeService = nodeService;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)
|
* @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)
|
||||||
*/
|
*/
|
||||||
@@ -78,6 +95,7 @@ public class RMMetaDataGet extends DeclarativeWebScript
|
|||||||
// create model object with the lists model
|
// create model object with the lists model
|
||||||
Map<String, Object> model = new HashMap<String, Object>(1);
|
Map<String, Object> model = new HashMap<String, Object>(1);
|
||||||
|
|
||||||
|
boolean extended = false;
|
||||||
String result = "NONE";
|
String result = "NONE";
|
||||||
|
|
||||||
// Get the nodeRef and confirm it is valid
|
// Get the nodeRef and confirm it is valid
|
||||||
@@ -103,16 +121,89 @@ public class RMMetaDataGet extends DeclarativeWebScript
|
|||||||
Matcher m = nodeRefPattern.matcher(nodeRef);
|
Matcher m = nodeRefPattern.matcher(nodeRef);
|
||||||
if (m.matches())
|
if (m.matches())
|
||||||
{
|
{
|
||||||
FilePlanComponentKind kind = rmService.getFilePlanComponentKind(new NodeRef(nodeRef));
|
NodeRef nodeRefObj = new NodeRef(nodeRef);
|
||||||
|
|
||||||
|
FilePlanComponentKind kind = rmService.getFilePlanComponentKind(nodeRefObj);
|
||||||
if (kind != null)
|
if (kind != null)
|
||||||
{
|
{
|
||||||
result = kind.toString();
|
result = kind.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String extendedValue = req.getParameter(PARAM_EXTENDED);
|
||||||
|
if (extendedValue != null && extendedValue.length() != 0)
|
||||||
|
{
|
||||||
|
extended = Boolean.parseBoolean(extendedValue);
|
||||||
|
if (extended == true)
|
||||||
|
{
|
||||||
|
// get the aspects of the node
|
||||||
|
model.put("aspects", getAspects(nodeRefObj));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
model.put("kind", result);
|
model.put("kind", result);
|
||||||
|
model.put("extended", extended);
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current node aspects
|
||||||
|
*
|
||||||
|
* @return node aspects
|
||||||
|
*/
|
||||||
|
public List<Aspect> getAspects(NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
Set<QName> qnames = nodeService.getAspects(nodeRef);
|
||||||
|
List<Aspect> aspects = new ArrayList<Aspect>(qnames.size());
|
||||||
|
for (QName qname : qnames)
|
||||||
|
{
|
||||||
|
aspects.add(new Aspect(qname));
|
||||||
|
}
|
||||||
|
return aspects;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Qname wrapper class
|
||||||
|
*/
|
||||||
|
public class QNameBean implements Serializable
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 6982292337846270774L;
|
||||||
|
|
||||||
|
protected QName name;
|
||||||
|
|
||||||
|
public QNameBean(QName name)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return name.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrefixedName()
|
||||||
|
{
|
||||||
|
return name.toPrefixString(namespaceService);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aspect wrapper class
|
||||||
|
*/
|
||||||
|
public class Aspect extends QNameBean
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = -6448182941386934326L;
|
||||||
|
|
||||||
|
public Aspect(QName name)
|
||||||
|
{
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user