mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
RM-1319 (Implement REST API for getting the holds)
* Added more information about the hold git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@63879 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
<#escape x as jsonUtils.encodeJSONString(x)>
|
||||||
{
|
{
|
||||||
"data":
|
"data":
|
||||||
{
|
{
|
||||||
@@ -5,9 +6,11 @@
|
|||||||
[
|
[
|
||||||
<#list holds as hold>
|
<#list holds as hold>
|
||||||
{
|
{
|
||||||
"name": "${hold}"
|
"name": "${hold.name}",
|
||||||
|
"nodeRef": "${hold.nodeRef}"
|
||||||
}<#if hold_has_next>,</#if>
|
}<#if hold_has_next>,</#if>
|
||||||
</#list>
|
</#list>
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
</#escape>
|
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* 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.hold;
|
||||||
|
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hold POJO
|
||||||
|
*
|
||||||
|
* @author Tuna Aksoy
|
||||||
|
* @since 2.2
|
||||||
|
*/
|
||||||
|
public class Hold
|
||||||
|
{
|
||||||
|
/** Hold name */
|
||||||
|
private String Name;
|
||||||
|
|
||||||
|
/** Hold node reference */
|
||||||
|
private NodeRef nodeRef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param name The name of the hold
|
||||||
|
* @param nodeRef The {@link NodeRef} of the hold
|
||||||
|
*/
|
||||||
|
public Hold(String name, NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
this.Name = name;
|
||||||
|
this.nodeRef = nodeRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the hold name
|
||||||
|
*
|
||||||
|
* @return The name of the hold
|
||||||
|
*/
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return this.Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the hold node reference
|
||||||
|
*
|
||||||
|
* @return The {@link NodeRef} of the hold
|
||||||
|
*/
|
||||||
|
public NodeRef getNodeRef()
|
||||||
|
{
|
||||||
|
return this.nodeRef;
|
||||||
|
}
|
||||||
|
}
|
@@ -104,16 +104,16 @@ public class HoldsGet extends DeclarativeWebScript
|
|||||||
holds.addAll(holdService.getHoldsForItem(itemNodeRef));
|
holds.addAll(holdService.getHoldsForItem(itemNodeRef));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> holdNames = new ArrayList<String>(holds.size());
|
List<Hold> holdObjects = new ArrayList<Hold>(holds.size());
|
||||||
for (NodeRef hold : holds)
|
for (NodeRef nodeRef : holds)
|
||||||
{
|
{
|
||||||
String holdName = (String) nodeService.getProperty(hold, ContentModel.PROP_NAME);
|
String name = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||||
holdNames.add(holdName);
|
holdObjects.add(new Hold(name, nodeRef));
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Object> model = new HashMap<String, Object>(1);
|
Map<String, Object> model = new HashMap<String, Object>(1);
|
||||||
sortByName(holdNames);
|
sortHoldByName(holdObjects);
|
||||||
model.put("holds", holdNames);
|
model.put("holds", holdObjects);
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
@@ -169,16 +169,16 @@ public class HoldsGet extends DeclarativeWebScript
|
|||||||
/**
|
/**
|
||||||
* Helper method to sort the holds by their names
|
* Helper method to sort the holds by their names
|
||||||
*
|
*
|
||||||
* @param holdNames List of hold names to sort
|
* @param holds List of holds to sort
|
||||||
*/
|
*/
|
||||||
private void sortByName(List<String> holdNames)
|
private void sortHoldByName(List<Hold> holds)
|
||||||
{
|
{
|
||||||
Collections.sort(holdNames, new Comparator<String>()
|
Collections.sort(holds, new Comparator<Hold>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public int compare(String o1, String o2)
|
public int compare(Hold h1, Hold h2)
|
||||||
{
|
{
|
||||||
return o1.toLowerCase().compareTo(o2.toLowerCase());
|
return h1.getName().toLowerCase().compareTo(h2.getName().toLowerCase());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user