mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-1641 (Create Relationship Service)
* Refactored existing customReference classes git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@85575 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -43,6 +43,7 @@ public abstract class AbstractRmWebScript extends DeclarativeWebScript
|
|||||||
{
|
{
|
||||||
/** Constants */
|
/** Constants */
|
||||||
protected static final String PATH_SEPARATOR = "/";
|
protected static final String PATH_SEPARATOR = "/";
|
||||||
|
protected static final String SUCCESS = "success";
|
||||||
|
|
||||||
/** Disposition service */
|
/** Disposition service */
|
||||||
protected DispositionService dispositionService;
|
protected DispositionService dispositionService;
|
||||||
|
@@ -18,14 +18,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.module.org_alfresco_module_rm.script;
|
package org.alfresco.module.org_alfresco_module_rm.script;
|
||||||
|
|
||||||
|
import static org.alfresco.util.WebScriptUtils.getRequestParameterValue;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService;
|
import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
|
||||||
import org.alfresco.service.cmr.rule.RuleService;
|
import org.alfresco.service.cmr.rule.RuleService;
|
||||||
import org.alfresco.service.cmr.rule.RuleType;
|
import org.alfresco.service.cmr.rule.RuleType;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
@@ -33,28 +32,31 @@ import org.springframework.extensions.webscripts.Cache;
|
|||||||
import org.springframework.extensions.webscripts.Status;
|
import org.springframework.extensions.webscripts.Status;
|
||||||
import org.springframework.extensions.webscripts.WebScriptException;
|
import org.springframework.extensions.webscripts.WebScriptException;
|
||||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation for Java backed webscript to remove RM custom reference instances
|
* Implementation for Java backed webscript to remove RM custom reference instances from a node.
|
||||||
* from a node.
|
|
||||||
*
|
*
|
||||||
* @author Neil McErlean
|
* @author Neil McErlean
|
||||||
|
* @author Tuna Aksoy
|
||||||
*/
|
*/
|
||||||
public class CustomRefDelete extends AbstractRmWebScript
|
public class CustomRefDelete extends AbstractRmWebScript
|
||||||
{
|
{
|
||||||
/** Logger */
|
/** Constants */
|
||||||
private static Log logger = LogFactory.getLog(CustomRefDelete.class);
|
private static final String REF_ID = "refId";
|
||||||
|
private static final String ST = "st";
|
||||||
|
private static final String SI = "si";
|
||||||
|
private static final String ID = "id";
|
||||||
|
|
||||||
/** RM Admin Service */
|
/** RM admin service */
|
||||||
private RecordsManagementAdminService rmAdminService;
|
private RecordsManagementAdminService rmAdminService;
|
||||||
|
|
||||||
/** Rule Service */
|
/** Rule service */
|
||||||
private RuleService ruleService;
|
private RuleService ruleService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param rmAdminService RM Admin Service
|
* Sets the RM admin service
|
||||||
|
*
|
||||||
|
* @param rmAdminService RM admin service
|
||||||
*/
|
*/
|
||||||
public void setRecordsManagementAdminService(RecordsManagementAdminService rmAdminService)
|
public void setRecordsManagementAdminService(RecordsManagementAdminService rmAdminService)
|
||||||
{
|
{
|
||||||
@@ -62,80 +64,93 @@ public class CustomRefDelete extends AbstractRmWebScript
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ruleService Rule Service
|
* Sets the rule service
|
||||||
|
*
|
||||||
|
* @param ruleService Rule service
|
||||||
*/
|
*/
|
||||||
public void setRuleService(RuleService ruleService)
|
public void setRuleService(RuleService ruleService)
|
||||||
{
|
{
|
||||||
this.ruleService = ruleService;
|
this.ruleService = ruleService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* @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)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||||
{
|
{
|
||||||
Map<String, Object> ftlModel;
|
Map<String, Object> model = new HashMap<String, Object>(1);
|
||||||
ruleService.disableRuleType(RuleType.OUTBOUND);
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ftlModel = removeCustomReferenceInstance(req);
|
ruleService.disableRuleType(RuleType.OUTBOUND);
|
||||||
|
removeCustomReferenceInstance(req);
|
||||||
|
model.put(SUCCESS, true);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
ruleService.enableRuleType(RuleType.OUTBOUND);
|
ruleService.enableRuleType(RuleType.OUTBOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ftlModel;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes custom reference.
|
* Removes custom reference instance
|
||||||
|
*
|
||||||
|
* @param req The webscript request
|
||||||
*/
|
*/
|
||||||
protected Map<String, Object> removeCustomReferenceInstance(WebScriptRequest req)
|
private void removeCustomReferenceInstance(WebScriptRequest req)
|
||||||
{
|
{
|
||||||
NodeRef fromNodeRef = parseRequestForNodeRef(req);
|
NodeRef fromNode = parseRequestForNodeRef(req);
|
||||||
|
NodeRef toNodeRef = getToNode(req);
|
||||||
|
QName associationQName = getAssociationQName(req);
|
||||||
|
|
||||||
|
rmAdminService.removeCustomReference(fromNode, toNodeRef, associationQName);
|
||||||
|
rmAdminService.removeCustomReference(toNodeRef, fromNode, associationQName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the node from which the reference will be removed
|
||||||
|
*
|
||||||
|
* @param req The webscript request
|
||||||
|
* @return The node from which the reference will be removed
|
||||||
|
*/
|
||||||
|
private NodeRef getToNode(WebScriptRequest req)
|
||||||
|
{
|
||||||
// Get the toNode from the URL query string.
|
// Get the toNode from the URL query string.
|
||||||
String storeType = req.getParameter("st");
|
String storeType = req.getParameter(ST);
|
||||||
String storeId = req.getParameter("si");
|
String storeId = req.getParameter(SI);
|
||||||
String nodeId = req.getParameter("id");
|
String nodeId = req.getParameter(ID);
|
||||||
|
|
||||||
// create the NodeRef and ensure it is valid
|
// Create the NodeRef and ensure it is valid
|
||||||
StoreRef storeRef = new StoreRef(storeType, storeId);
|
NodeRef toNode = new NodeRef(storeType, storeId, nodeId);
|
||||||
NodeRef toNodeRef = new NodeRef(storeRef, nodeId);
|
if (!nodeService.exists(toNode))
|
||||||
|
|
||||||
if (!this.nodeService.exists(toNodeRef))
|
|
||||||
{
|
{
|
||||||
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find to-node: " +
|
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Unable to find toNode: '" +
|
||||||
toNodeRef.toString());
|
toNode.toString() + "'.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Object> result = new HashMap<String, Object>();
|
return toNode;
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
|
/**
|
||||||
String clientsRefId = templateVars.get("refId");
|
* Gets the QName of the association
|
||||||
QName qn = rmAdminService.getQNameForClientId(clientsRefId);
|
*
|
||||||
if (qn == null)
|
* @param req The webscript request
|
||||||
|
* @return QName of the association
|
||||||
|
*/
|
||||||
|
private QName getAssociationQName(WebScriptRequest req)
|
||||||
{
|
{
|
||||||
throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
|
String clientsRefId = getRequestParameterValue(req, REF_ID);
|
||||||
"Unable to find reference type: " + clientsRefId);
|
QName qName = rmAdminService.getQNameForClientId(clientsRefId);
|
||||||
}
|
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (qName == null)
|
||||||
{
|
{
|
||||||
StringBuilder msg = new StringBuilder();
|
throw new WebScriptException(Status.STATUS_NOT_FOUND,
|
||||||
msg.append("Removing reference ").append(qn).append(" from ")
|
"Unable to find reference type: '" + clientsRefId + "'.");
|
||||||
.append(fromNodeRef).append(" to ").append(toNodeRef);
|
|
||||||
logger.debug(msg.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rmAdminService.removeCustomReference(fromNodeRef, toNodeRef, qn);
|
return qName;
|
||||||
rmAdminService.removeCustomReference(toNodeRef, fromNodeRef, qn);
|
|
||||||
|
|
||||||
result.put("success", true);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -18,44 +18,45 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.module.org_alfresco_module_rm.script;
|
package org.alfresco.module.org_alfresco_module_rm.script;
|
||||||
|
|
||||||
import java.io.IOException;
|
import static org.alfresco.util.WebScriptUtils.getRequestContentAsJsonObject;
|
||||||
|
import static org.alfresco.util.WebScriptUtils.getStringValueFromJSONObject;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService;
|
import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.rule.RuleService;
|
import org.alfresco.service.cmr.rule.RuleService;
|
||||||
import org.alfresco.service.cmr.rule.RuleType;
|
import org.alfresco.service.cmr.rule.RuleType;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.json.JSONException;
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.json.JSONTokener;
|
|
||||||
import org.springframework.extensions.webscripts.Cache;
|
import org.springframework.extensions.webscripts.Cache;
|
||||||
import org.springframework.extensions.webscripts.Status;
|
import org.springframework.extensions.webscripts.Status;
|
||||||
import org.springframework.extensions.webscripts.WebScriptException;
|
import org.springframework.extensions.webscripts.WebScriptException;
|
||||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation for Java backed webscript to add RM custom reference instances
|
* Implementation for Java backed webscript to add RM custom reference instances to a node.
|
||||||
* to a node.
|
|
||||||
*
|
*
|
||||||
* @author Neil McErlean
|
* @author Neil McErlean
|
||||||
|
* @author Tuna Aksoy
|
||||||
*/
|
*/
|
||||||
public class CustomRefPost extends AbstractRmWebScript
|
public class CustomRefPost extends AbstractRmWebScript
|
||||||
{
|
{
|
||||||
|
/** Constants */
|
||||||
private static final String TO_NODE = "toNode";
|
private static final String TO_NODE = "toNode";
|
||||||
private static final String REF_ID = "refId";
|
private static final String REF_ID = "refId";
|
||||||
|
|
||||||
/** RM Admin Service */
|
/** RM admin service */
|
||||||
private RecordsManagementAdminService rmAdminService;
|
private RecordsManagementAdminService rmAdminService;
|
||||||
|
|
||||||
/** Rule Service */
|
/** Rule service */
|
||||||
private RuleService ruleService;
|
private RuleService ruleService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param rmAdminService RM Admin Service
|
* Sets the RM admin service
|
||||||
|
*
|
||||||
|
* @param rmAdminService RM admin service
|
||||||
*/
|
*/
|
||||||
public void setRecordsManagementAdminService(RecordsManagementAdminService rmAdminService)
|
public void setRecordsManagementAdminService(RecordsManagementAdminService rmAdminService)
|
||||||
{
|
{
|
||||||
@@ -63,71 +64,89 @@ public class CustomRefPost extends AbstractRmWebScript
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ruleService Rule Service
|
* Sets the rule service
|
||||||
|
*
|
||||||
|
* @param ruleService Rule service
|
||||||
*/
|
*/
|
||||||
public void setRuleService(RuleService ruleService)
|
public void setRuleService(RuleService ruleService)
|
||||||
{
|
{
|
||||||
this.ruleService = ruleService;
|
this.ruleService = ruleService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* @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)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||||
{
|
{
|
||||||
JSONObject json = null;
|
Map<String, Object> model = new HashMap<String, Object>(1);
|
||||||
Map<String, Object> ftlModel = null;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ruleService.disableRuleType(RuleType.INBOUND);
|
ruleService.disableRuleType(RuleType.INBOUND);
|
||||||
|
addCustomReferenceInstance(req);
|
||||||
json = new JSONObject(new JSONTokener(req.getContent().getContent()));
|
model.put(SUCCESS, true);
|
||||||
|
|
||||||
ftlModel = addCustomReferenceInstance(req, json);
|
|
||||||
}
|
|
||||||
catch (IOException iox)
|
|
||||||
{
|
|
||||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST,
|
|
||||||
"Could not read content from req.", iox);
|
|
||||||
}
|
|
||||||
catch (JSONException je)
|
|
||||||
{
|
|
||||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST,
|
|
||||||
"Could not parse JSON from req.", je);
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
ruleService.enableRuleType(RuleType.INBOUND);
|
ruleService.enableRuleType(RuleType.INBOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ftlModel;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies custom reference.
|
* Adds a custom reference instance
|
||||||
|
*
|
||||||
|
* @param req The webscript request
|
||||||
*/
|
*/
|
||||||
protected Map<String, Object> addCustomReferenceInstance(WebScriptRequest req, JSONObject json) throws JSONException
|
protected void addCustomReferenceInstance(WebScriptRequest req)
|
||||||
{
|
{
|
||||||
NodeRef fromNode = parseRequestForNodeRef(req);
|
NodeRef fromNode = parseRequestForNodeRef(req);
|
||||||
|
JSONObject json = getRequestContentAsJsonObject(req);
|
||||||
|
NodeRef toNode = getToNode(json);
|
||||||
|
QName associationQName = getAssociationQName(json);
|
||||||
|
|
||||||
Map<String, Object> result = new HashMap<String, Object>();
|
rmAdminService.addCustomReference(fromNode, toNode, associationQName);
|
||||||
|
}
|
||||||
|
|
||||||
String toNodeStg = json.getString(TO_NODE);
|
/**
|
||||||
NodeRef toNode = new NodeRef(toNodeStg);
|
* Gets the node to which the reference will be added
|
||||||
|
*
|
||||||
String clientsRefId = json.getString(REF_ID);
|
* @param json Request content as json object
|
||||||
QName qn = rmAdminService.getQNameForClientId(clientsRefId);
|
* @return The node to which the reference will be added
|
||||||
if (qn == null)
|
*/
|
||||||
|
private NodeRef getToNode(JSONObject json)
|
||||||
{
|
{
|
||||||
throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
|
String toNodeString = getStringValueFromJSONObject(json, TO_NODE);
|
||||||
"Unable to find reference type: " + clientsRefId);
|
NodeRef toNode = new NodeRef(toNodeString);
|
||||||
|
|
||||||
|
if (!nodeService.exists(toNode))
|
||||||
|
{
|
||||||
|
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Unable to find toNode: '" +
|
||||||
|
toNode.toString() + "'.");
|
||||||
}
|
}
|
||||||
|
|
||||||
rmAdminService.addCustomReference(fromNode, toNode, qn);
|
return toNode;
|
||||||
|
}
|
||||||
|
|
||||||
result.put("success", true);
|
/**
|
||||||
|
* Gets the QName of the association
|
||||||
|
*
|
||||||
|
* @param json Request content as json object
|
||||||
|
* @return QName of the association
|
||||||
|
*/
|
||||||
|
private QName getAssociationQName(JSONObject json)
|
||||||
|
{
|
||||||
|
String clientsRefId = getStringValueFromJSONObject(json, REF_ID);
|
||||||
|
QName qName = rmAdminService.getQNameForClientId(clientsRefId);
|
||||||
|
|
||||||
return result;
|
if (qName == null)
|
||||||
|
{
|
||||||
|
throw new WebScriptException(Status.STATUS_NOT_FOUND,
|
||||||
|
"Unable to find reference type: '" + clientsRefId + "'.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return qName;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -35,19 +35,19 @@ 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.cmr.security.AccessStatus;
|
import org.alfresco.service.cmr.security.AccessStatus;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.springframework.extensions.webscripts.Cache;
|
import org.springframework.extensions.webscripts.Cache;
|
||||||
import org.springframework.extensions.webscripts.Status;
|
import org.springframework.extensions.webscripts.Status;
|
||||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides the implementation for the customrefs.get webscript.
|
* Implementation for Java backed webscript to get RM custom references for a node.
|
||||||
*
|
*
|
||||||
* @author Neil McErlean
|
* @author Neil McErlean
|
||||||
|
* @author Tuna Aksoy
|
||||||
*/
|
*/
|
||||||
public class CustomRefsGet extends AbstractRmWebScript
|
public class CustomRefsGet extends AbstractRmWebScript
|
||||||
{
|
{
|
||||||
|
/** Constants */
|
||||||
private static final String REFERENCE_TYPE = "referenceType";
|
private static final String REFERENCE_TYPE = "referenceType";
|
||||||
private static final String REF_ID = "refId";
|
private static final String REF_ID = "refId";
|
||||||
private static final String LABEL = "label";
|
private static final String LABEL = "label";
|
||||||
@@ -62,20 +62,18 @@ public class CustomRefsGet extends AbstractRmWebScript
|
|||||||
private static final String NODE_NAME = "nodeName";
|
private static final String NODE_NAME = "nodeName";
|
||||||
private static final String NODE_TITLE = "nodeTitle";
|
private static final String NODE_TITLE = "nodeTitle";
|
||||||
|
|
||||||
/** logger */
|
/** RM admin service */
|
||||||
private static Log logger = LogFactory.getLog(CustomRefsGet.class);
|
|
||||||
|
|
||||||
/** records management admin service */
|
|
||||||
private RecordsManagementAdminService rmAdminService;
|
private RecordsManagementAdminService rmAdminService;
|
||||||
|
|
||||||
/** dictionary service */
|
/** Dictionary service */
|
||||||
private DictionaryService dictionaryService;
|
private DictionaryService dictionaryService;
|
||||||
|
|
||||||
/** capability service */
|
/** Capability service */
|
||||||
private CapabilityService capabilityService;
|
private CapabilityService capabilityService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param rmAdminService records management admin service
|
* Sets the RM admin service
|
||||||
|
* @param rmAdminService RM admin service
|
||||||
*/
|
*/
|
||||||
public void setRecordsManagementAdminService(RecordsManagementAdminService rmAdminService)
|
public void setRecordsManagementAdminService(RecordsManagementAdminService rmAdminService)
|
||||||
{
|
{
|
||||||
@@ -83,7 +81,9 @@ public class CustomRefsGet extends AbstractRmWebScript
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dictionaryService dictionary service
|
* Sets the dictionary service
|
||||||
|
*
|
||||||
|
* @param dictionaryService Dictionary service
|
||||||
*/
|
*/
|
||||||
public void setDictionaryService(DictionaryService dictionaryService)
|
public void setDictionaryService(DictionaryService dictionaryService)
|
||||||
{
|
{
|
||||||
@@ -91,7 +91,9 @@ public class CustomRefsGet extends AbstractRmWebScript
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param capabilityService capability service
|
* Sets the capability service
|
||||||
|
*
|
||||||
|
* @param capabilityService Capability service
|
||||||
*/
|
*/
|
||||||
public void setCapabilityService(CapabilityService capabilityService)
|
public void setCapabilityService(CapabilityService capabilityService)
|
||||||
{
|
{
|
||||||
@@ -102,46 +104,53 @@ public class CustomRefsGet extends AbstractRmWebScript
|
|||||||
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
|
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||||
{
|
{
|
||||||
Map<String, Object> ftlModel = new HashMap<String, Object>();
|
Map<String, Object> model = new HashMap<String, Object>(4);
|
||||||
|
NodeRef nodeRef = parseRequestForNodeRef(req);
|
||||||
NodeRef node = parseRequestForNodeRef(req);
|
model.put(NODE_NAME, nodeService.getProperty(nodeRef, ContentModel.PROP_NAME));
|
||||||
|
model.put(NODE_TITLE, nodeService.getProperty(nodeRef, ContentModel.PROP_TITLE));
|
||||||
if (logger.isDebugEnabled())
|
model.put(CUSTOM_REFS_FROM, getOutwardReferences(nodeRef));
|
||||||
{
|
model.put(CUSTOM_REFS_TO, getInwardReferenceData(nodeRef));
|
||||||
logger.debug("Getting custom reference instances for " + node);
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
// All the references that come 'out' from this node.
|
/**
|
||||||
List<Map<String, String>> listOfOutwardReferenceData = new ArrayList<Map<String, String>>();
|
* Gets all the references that come 'out' from this node
|
||||||
|
*
|
||||||
List<AssociationRef> assocsFromThisNode = this.rmAdminService.getCustomReferencesFrom(node);
|
* @param nodeRef Node reference
|
||||||
addBidirectionalReferenceData(listOfOutwardReferenceData, assocsFromThisNode);
|
* @return All the references that come 'out' from this node
|
||||||
|
*/
|
||||||
List<ChildAssociationRef> childAssocs = this.rmAdminService.getCustomChildReferences(node);
|
private List<Map<String, String>> getOutwardReferences(NodeRef nodeRef)
|
||||||
addParentChildReferenceData(listOfOutwardReferenceData, childAssocs);
|
|
||||||
|
|
||||||
// All the references that come 'in' to this node.
|
|
||||||
List<Map<String, String>> listOfInwardReferenceData = new ArrayList<Map<String, String>>();
|
|
||||||
|
|
||||||
List<AssociationRef> toAssocs = this.rmAdminService.getCustomReferencesTo(node);
|
|
||||||
addBidirectionalReferenceData(listOfInwardReferenceData, toAssocs);
|
|
||||||
|
|
||||||
List<ChildAssociationRef> parentAssocs = this.rmAdminService.getCustomParentReferences(node);
|
|
||||||
addParentChildReferenceData(listOfInwardReferenceData, parentAssocs);
|
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
|
||||||
{
|
{
|
||||||
logger.debug("Retrieved custom reference instances: " + assocsFromThisNode);
|
List<Map<String, String>> outwardReferenceData = new ArrayList<Map<String, String>>();
|
||||||
|
|
||||||
|
List<AssociationRef> assocsFromThisNode = rmAdminService.getCustomReferencesFrom(nodeRef);
|
||||||
|
addBidirectionalReferenceData(outwardReferenceData, assocsFromThisNode);
|
||||||
|
|
||||||
|
List<ChildAssociationRef> childAssocs = rmAdminService.getCustomChildReferences(nodeRef);
|
||||||
|
addParentChildReferenceData(outwardReferenceData, childAssocs);
|
||||||
|
|
||||||
|
return outwardReferenceData;
|
||||||
}
|
}
|
||||||
|
|
||||||
ftlModel.put(NODE_NAME, nodeService.getProperty(node, ContentModel.PROP_NAME));
|
/**
|
||||||
ftlModel.put(NODE_TITLE, nodeService.getProperty(node, ContentModel.PROP_TITLE));
|
* Gets all the references that come 'in' to this node
|
||||||
ftlModel.put(CUSTOM_REFS_FROM, listOfOutwardReferenceData);
|
*
|
||||||
ftlModel.put(CUSTOM_REFS_TO, listOfInwardReferenceData);
|
* @param nodeRef Node reference
|
||||||
|
* @return All the references that come 'in' to this node
|
||||||
|
*/
|
||||||
|
private List<Map<String, String>> getInwardReferenceData(NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
List<Map<String, String>> inwardReferenceData = new ArrayList<Map<String, String>>();
|
||||||
|
|
||||||
return ftlModel;
|
List<AssociationRef> toAssocs = rmAdminService.getCustomReferencesTo(nodeRef);
|
||||||
|
addBidirectionalReferenceData(inwardReferenceData, toAssocs);
|
||||||
|
|
||||||
|
List<ChildAssociationRef> parentAssocs = rmAdminService.getCustomParentReferences(nodeRef);
|
||||||
|
addParentChildReferenceData(inwardReferenceData, parentAssocs);
|
||||||
|
|
||||||
|
return inwardReferenceData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -149,10 +158,10 @@ public class CustomRefsGet extends AbstractRmWebScript
|
|||||||
* for each assRef. FTL-relevant data are added to that map. The associationRefs must all be
|
* for each assRef. FTL-relevant data are added to that map. The associationRefs must all be
|
||||||
* parent/child references.
|
* parent/child references.
|
||||||
*
|
*
|
||||||
* @param listOfReferenceData
|
* @param referenceData Reference data
|
||||||
* @param assocs
|
* @param childAssocs Association references
|
||||||
*/
|
*/
|
||||||
private void addParentChildReferenceData(List<Map<String, String>> listOfReferenceData,List<ChildAssociationRef> childAssocs)
|
private void addParentChildReferenceData(List<Map<String, String>> referenceData, List<ChildAssociationRef> childAssocs)
|
||||||
{
|
{
|
||||||
for (ChildAssociationRef childAssRef : childAssocs)
|
for (ChildAssociationRef childAssRef : childAssocs)
|
||||||
{
|
{
|
||||||
@@ -178,7 +187,7 @@ public class CustomRefsGet extends AbstractRmWebScript
|
|||||||
data.put(TARGET, sourceAndTarget[1]);
|
data.put(TARGET, sourceAndTarget[1]);
|
||||||
data.put(REFERENCE_TYPE, CustomReferenceType.PARENT_CHILD.toString());
|
data.put(REFERENCE_TYPE, CustomReferenceType.PARENT_CHILD.toString());
|
||||||
|
|
||||||
listOfReferenceData.add(data);
|
referenceData.add(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -188,10 +197,10 @@ public class CustomRefsGet extends AbstractRmWebScript
|
|||||||
* for each assRef. FTL-relevant data are added to that map. The associationRefs must all be
|
* for each assRef. FTL-relevant data are added to that map. The associationRefs must all be
|
||||||
* bidirectional references.
|
* bidirectional references.
|
||||||
*
|
*
|
||||||
* @param listOfReferenceData
|
* @param referenceData Reference data
|
||||||
* @param assocs
|
* @param assocs Association references
|
||||||
*/
|
*/
|
||||||
private void addBidirectionalReferenceData(List<Map<String, String>> listOfReferenceData, List<AssociationRef> assocs)
|
private void addBidirectionalReferenceData(List<Map<String, String>> referenceData, List<AssociationRef> assocs)
|
||||||
{
|
{
|
||||||
for (AssociationRef assRef : assocs)
|
for (AssociationRef assRef : assocs)
|
||||||
{
|
{
|
||||||
@@ -210,16 +219,16 @@ public class CustomRefsGet extends AbstractRmWebScript
|
|||||||
data.put(SOURCE_REF, assRef.getSourceRef().toString());
|
data.put(SOURCE_REF, assRef.getSourceRef().toString());
|
||||||
data.put(TARGET_REF, assRef.getTargetRef().toString());
|
data.put(TARGET_REF, assRef.getTargetRef().toString());
|
||||||
|
|
||||||
listOfReferenceData.add(data);
|
referenceData.add(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether the current user has view capabilities on the given node.
|
* Determines whether the current user has view capabilities on the given node.
|
||||||
*
|
*
|
||||||
* @param nodeRef node reference
|
* @param nodeRef Node reference
|
||||||
* @return boolean true if current user has view capability, false otherwise
|
* @return boolean <code>true</code> if current user has view capability, <code>false</code> otherwise
|
||||||
*/
|
*/
|
||||||
private boolean hasView(NodeRef nodeRef)
|
private boolean hasView(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
@@ -230,6 +239,7 @@ public class CustomRefsGet extends AbstractRmWebScript
|
|||||||
{
|
{
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -94,7 +94,7 @@ public final class WebScriptUtils
|
|||||||
*
|
*
|
||||||
* @param req The webscript request
|
* @param req The webscript request
|
||||||
* @param parameter The request parameter
|
* @param parameter The request parameter
|
||||||
* @param checkValue FIXME!!!
|
* @param checkValue Determines if the value of the parameter should be checked or not
|
||||||
* @return The value of the request parameter
|
* @return The value of the request parameter
|
||||||
*/
|
*/
|
||||||
public static String getRequestParameterValue(WebScriptRequest req, String parameter, boolean checkValue)
|
public static String getRequestParameterValue(WebScriptRequest req, String parameter, boolean checkValue)
|
||||||
|
Reference in New Issue
Block a user