mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-487 (REST API to retrieve details of available RM data sets)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@41314 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -376,4 +376,9 @@
|
|||||||
<property name="nodeService" ref="NodeService"/>
|
<property name="nodeService" ref="NodeService"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<!-- REST impl for GET Data Sets -->
|
||||||
|
<bean id="webscript.org.alfresco.rma.datasets.get" class="org.alfresco.module.org_alfresco_module_rm.script.DataSetsGet" parent="webscript">
|
||||||
|
<property name="dataSetService" ref="DataSetService" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
@@ -0,0 +1,9 @@
|
|||||||
|
<webscript>
|
||||||
|
<shortname>Get data sets</shortname>
|
||||||
|
<description>WebScript to get the list of available RM test data</description>
|
||||||
|
<url>/api/rma/datasets</url>
|
||||||
|
<format default="json">argument</format>
|
||||||
|
<authentication>admin</authentication>
|
||||||
|
<transaction>required</transaction>
|
||||||
|
<lifecycle>internal</lifecycle>
|
||||||
|
</webscript>
|
@@ -0,0 +1,5 @@
|
|||||||
|
<#escape x as jsonUtils.encodeJSONString(x)>
|
||||||
|
{
|
||||||
|
"data": ${data}
|
||||||
|
}
|
||||||
|
</#escape>
|
@@ -0,0 +1,70 @@
|
|||||||
|
package org.alfresco.module.org_alfresco_module_rm.script;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.dataset.DataSet;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService;
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import org.springframework.extensions.webscripts.Cache;
|
||||||
|
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||||
|
import org.springframework.extensions.webscripts.Status;
|
||||||
|
import org.springframework.extensions.webscripts.WebScriptException;
|
||||||
|
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||||
|
|
||||||
|
public class DataSetsGet extends DeclarativeWebScript
|
||||||
|
{
|
||||||
|
|
||||||
|
/** Data set service */
|
||||||
|
private DataSetService dataSetService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set data set service
|
||||||
|
*
|
||||||
|
* @param dataSetService the data set service
|
||||||
|
*/
|
||||||
|
public void setDataSetService(DataSetService dataSetService)
|
||||||
|
{
|
||||||
|
this.dataSetService = dataSetService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
JSONObject data = new JSONObject();
|
||||||
|
JSONArray dataSets = new JSONArray();
|
||||||
|
|
||||||
|
for (Map.Entry<String, DataSet> entry : dataSetService.getDataSets().entrySet())
|
||||||
|
{
|
||||||
|
DataSet value = entry.getValue();
|
||||||
|
JSONObject dataSet = new JSONObject();
|
||||||
|
|
||||||
|
dataSet.put("label", value.getLabel());
|
||||||
|
dataSet.put("id", value.getId());
|
||||||
|
|
||||||
|
dataSets.put(dataSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
data.put("datasets", dataSets);
|
||||||
|
|
||||||
|
Map<String, Object> model = new HashMap<String, Object>(1, 1.0f);
|
||||||
|
model.put("data", data.toString());
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
catch (JSONException error)
|
||||||
|
{
|
||||||
|
throw new WebScriptException(Status.STATUS_BAD_REQUEST,
|
||||||
|
"Cannot convert data set details into JSON.", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user