mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
RM-1764 (Simplified Relationship View)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@90977 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -641,4 +641,11 @@
|
|||||||
parent="rmBaseWebscript">
|
parent="rmBaseWebscript">
|
||||||
<property name="relationshipService" ref="RelationshipService" />
|
<property name="relationshipService" ref="RelationshipService" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<!-- REST impl for DELETE Relationship -->
|
||||||
|
<bean id="webscript.org.alfresco.rma.relationship.delete"
|
||||||
|
class="org.alfresco.module.org_alfresco_module_rm.script.RelationshipDelete"
|
||||||
|
parent="rmBaseWebscript">
|
||||||
|
<property name="relationshipService" ref="RelationshipService" />
|
||||||
|
</bean>
|
||||||
</beans>
|
</beans>
|
@@ -0,0 +1,8 @@
|
|||||||
|
<webscript>
|
||||||
|
<shortname>Delete records management relationship</shortname>
|
||||||
|
<description>Deletes the specified relationship.</description>
|
||||||
|
<url>/api/node/{store_type}/{store_id}/{id}/targetnode/{target_store_type}/{target_store_id}/{target_id}/uniqueName/{uniqueName}</url>
|
||||||
|
<format default="json"/>
|
||||||
|
<authentication>user</authentication>
|
||||||
|
<transaction>required</transaction>
|
||||||
|
</webscript>
|
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"success": ${success?string}
|
||||||
|
}
|
@@ -5,5 +5,4 @@
|
|||||||
<format default="json"/>
|
<format default="json"/>
|
||||||
<authentication>user</authentication>
|
<authentication>user</authentication>
|
||||||
<transaction allow="readonly">required</transaction>
|
<transaction allow="readonly">required</transaction>
|
||||||
<lifecycle>internal</lifecycle>
|
|
||||||
</webscript>
|
</webscript>
|
@@ -5,5 +5,4 @@
|
|||||||
<format default="json"/>
|
<format default="json"/>
|
||||||
<authentication>user</authentication>
|
<authentication>user</authentication>
|
||||||
<transaction allow="readonly">required</transaction>
|
<transaction allow="readonly">required</transaction>
|
||||||
<lifecycle>internal</lifecycle>
|
|
||||||
</webscript>
|
</webscript>
|
@@ -0,0 +1,116 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco 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 Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.module.org_alfresco_module_rm.script;
|
||||||
|
|
||||||
|
import static org.alfresco.util.WebScriptUtils.getRequestParameterValue;
|
||||||
|
import static org.alfresco.util.WebScriptUtils.getTemplateVars;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.springframework.extensions.webscripts.Cache;
|
||||||
|
import org.springframework.extensions.webscripts.Status;
|
||||||
|
import org.springframework.extensions.webscripts.WebScriptException;
|
||||||
|
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation for Java backed webscript to delete a relationship from a node.
|
||||||
|
*
|
||||||
|
* @author Tuna Aksoy
|
||||||
|
* @since 2.3
|
||||||
|
*/
|
||||||
|
public class RelationshipDelete extends AbstractRmWebScript
|
||||||
|
{
|
||||||
|
/** Constants */
|
||||||
|
private static final String STORE_TYPE = "target_store_type";
|
||||||
|
private static final String STORE_ID = "target_store_id";
|
||||||
|
private static final String ID = "target_id";
|
||||||
|
private static final String UNIQUE_NAME = "uniqueName";
|
||||||
|
|
||||||
|
/** Relationship service */
|
||||||
|
private RelationshipService relationshipService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the relationship service
|
||||||
|
*
|
||||||
|
* @return The relationship service
|
||||||
|
*/
|
||||||
|
protected RelationshipService getRelationshipService()
|
||||||
|
{
|
||||||
|
return this.relationshipService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the relationship service
|
||||||
|
*
|
||||||
|
* @param relationshipService The relationship service
|
||||||
|
*/
|
||||||
|
public void setRelationshipService(RelationshipService relationshipService)
|
||||||
|
{
|
||||||
|
this.relationshipService = relationshipService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest,
|
||||||
|
* org.springframework.extensions.webscripts.Status,
|
||||||
|
* org.springframework.extensions.webscripts.Cache)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||||
|
{
|
||||||
|
String uniqueName = getRequestParameterValue(req, UNIQUE_NAME);
|
||||||
|
NodeRef source = parseRequestForNodeRef(req);
|
||||||
|
NodeRef target = parseRequestForTargetNodeRef(req);
|
||||||
|
|
||||||
|
getRelationshipService().removeRelationship(uniqueName, source, target);
|
||||||
|
getRelationshipService().removeRelationship(uniqueName, target, source);
|
||||||
|
|
||||||
|
Map<String, Object> model = new HashMap<String, Object>(1);
|
||||||
|
model.put(SUCCESS, true);
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the node reference of target
|
||||||
|
*
|
||||||
|
* @param req The webscript request
|
||||||
|
* @return The node reference of the target
|
||||||
|
*/
|
||||||
|
private NodeRef parseRequestForTargetNodeRef(WebScriptRequest req)
|
||||||
|
{
|
||||||
|
Map<String, String> templateVars = getTemplateVars(req);
|
||||||
|
String storeType = templateVars.get(STORE_TYPE);
|
||||||
|
String storeId = templateVars.get(STORE_ID);
|
||||||
|
String nodeId = templateVars.get(ID);
|
||||||
|
|
||||||
|
NodeRef nodeRef = new NodeRef(storeType, storeId, nodeId);
|
||||||
|
|
||||||
|
if (!getNodeService().exists(nodeRef))
|
||||||
|
{
|
||||||
|
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find node: '" +
|
||||||
|
nodeRef.toString() + "'.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return nodeRef;
|
||||||
|
}
|
||||||
|
}
|
@@ -47,6 +47,7 @@ public class RelationshipsGet extends AbstractRmWebScript
|
|||||||
/** Constants */
|
/** Constants */
|
||||||
private static final String RELATIONSHIPS = "relationships";
|
private static final String RELATIONSHIPS = "relationships";
|
||||||
private static final String RELATIONSHIP_LABEL = "relationshipLabel";
|
private static final String RELATIONSHIP_LABEL = "relationshipLabel";
|
||||||
|
private static final String RELATIONSHIP_UNIQUE_NAME = "relationshipUniqueName";
|
||||||
|
|
||||||
/** The relationship end point */
|
/** The relationship end point */
|
||||||
private enum RelationshipEndPoint
|
private enum RelationshipEndPoint
|
||||||
@@ -172,6 +173,7 @@ public class RelationshipsGet extends AbstractRmWebScript
|
|||||||
String nodeDetails = getJsonConversionComponent().toJSON(node, true);
|
String nodeDetails = getJsonConversionComponent().toJSON(node, true);
|
||||||
JSONObject jsonObject = WebScriptUtils.createJSONObject(nodeDetails);
|
JSONObject jsonObject = WebScriptUtils.createJSONObject(nodeDetails);
|
||||||
WebScriptUtils.putValuetoJSONObject(jsonObject, RELATIONSHIP_LABEL, label);
|
WebScriptUtils.putValuetoJSONObject(jsonObject, RELATIONSHIP_LABEL, label);
|
||||||
|
WebScriptUtils.putValuetoJSONObject(jsonObject, RELATIONSHIP_UNIQUE_NAME, relationshipDefinition.getUniqueName());
|
||||||
|
|
||||||
result.add(jsonObject.toString());
|
result.add(jsonObject.toString());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user