本文整理汇总了Java中org.springframework.extensions.webscripts.WebScriptRequest.getContent方法的典型用法代码示例。如果您正苦于以下问题:Java WebScriptRequest.getContent方法的具体用法?Java WebScriptRequest.getContent怎么用?Java WebScriptRequest.getContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.extensions.webscripts.WebScriptRequest
的用法示例。
在下文中一共展示了WebScriptRequest.getContent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildModel
import org.springframework.extensions.webscripts.WebScriptRequest; //导入方法依赖的package包/类
private Map<String, Object> buildModel(WebScriptRequest req) throws JSONException, IOException
{
Map<String, Object> model = new HashMap<String, Object>(1, 1.0f);
Content content = req.getContent();
if(content == null)
{
throw new WebScriptException("Failed to convert request to String");
}
JSONObject o = new JSONObject(content.getContent());
JSONArray jsonModels = o.getJSONArray("models");
Map<QName, Long> models = new HashMap<QName, Long>(jsonModels.length());
for(int i = 0; i < jsonModels.length(); i++)
{
JSONObject jsonModel = jsonModels.getJSONObject(i);
models.put(QName.createQName(jsonModel.getString("name")), jsonModel.getLong("checksum"));
}
List<AlfrescoModelDiff> diffs = solrTrackingComponent.getModelDiffs(models);
model.put("diffs", diffs);
if (logger.isDebugEnabled())
{
logger.debug("Result: \n\tRequest: " + req + "\n\tModel: " + model);
}
return model;
}
示例2: getContent
import org.springframework.extensions.webscripts.WebScriptRequest; //导入方法依赖的package包/类
public static String getContent(WebScriptRequest request) throws IOException
{
Content content = request.getContent();
return content.getContent();
}
示例3: buildModel
import org.springframework.extensions.webscripts.WebScriptRequest; //导入方法依赖的package包/类
private Map<String, Object> buildModel(WebScriptRequest req) throws JSONException, IOException
{
List<Long> aclChangeSetIds = null;
Content content = req.getContent();
if (content == null)
{
throw new WebScriptException("Request content is empty");
}
JSONObject o = new JSONObject(content.getContent());
JSONArray aclChangeSetIdsJSON = o.has("aclChangeSetIds") ? o.getJSONArray("aclChangeSetIds") : null;
if (aclChangeSetIdsJSON == null)
{
throw new WebScriptException(
Status.STATUS_BAD_REQUEST,
"Parameter 'aclChangeSetIds' not provided in request content.");
}
else if (aclChangeSetIdsJSON.length() == 0)
{
throw new WebScriptException(
Status.STATUS_BAD_REQUEST,
"Parameter 'aclChangeSetIds' must hold from 1 or more IDs.");
}
aclChangeSetIds = new ArrayList<Long>(aclChangeSetIdsJSON.length());
for (int i = 0; i < aclChangeSetIdsJSON.length(); i++)
{
aclChangeSetIds.add(aclChangeSetIdsJSON.getLong(i));
}
String fromIdParam = req.getParameter("fromId");
String maxResultsParam = req.getParameter("maxResults");
Long fromId = (fromIdParam == null ? null : Long.valueOf(fromIdParam));
int maxResults = (maxResultsParam == null ? 1024 : Integer.valueOf(maxResultsParam));
// Request according to the paging query style required
List<Acl> acls = solrTrackingComponent.getAcls(aclChangeSetIds, fromId, maxResults);
Map<String, Object> model = new HashMap<String, Object>(1, 1.0f);
model.put("acls", acls);
if (logger.isDebugEnabled())
{
logger.debug("Result: \n\tRequest: " + req + "\n\tModel: " + model);
}
return model;
}
示例4: buildModel
import org.springframework.extensions.webscripts.WebScriptRequest; //导入方法依赖的package包/类
private Map<String, Object> buildModel(WebScriptRequest req) throws JSONException, IOException
{
List<Long> aclIds = null;
Content content = req.getContent();
if (content == null)
{
throw new WebScriptException("Request content is empty");
}
JSONObject o = new JSONObject(content.getContent());
JSONArray aclIdsJSON = o.has("aclIds") ? o.getJSONArray("aclIds") : null;
if (aclIdsJSON == null)
{
throw new WebScriptException(
Status.STATUS_BAD_REQUEST,
"Parameter 'aclIds' not provided in request content.");
}
else if (aclIdsJSON.length() == 0)
{
throw new WebScriptException(
Status.STATUS_BAD_REQUEST,
"Parameter 'aclIds' must hold from 1 or more IDs.");
}
aclIds = new ArrayList<Long>(aclIdsJSON.length());
for (int i = 0; i < aclIdsJSON.length(); i++)
{
aclIds.add(aclIdsJSON.getLong(i));
}
// Request according to the paging query style required
List<AclReaders> aclsReaders = solrTrackingComponent.getAclsReaders(aclIds);
Map<String, Object> model = new HashMap<String, Object>(1, 1.0f);
model.put("aclsReaders", aclsReaders);
if (logger.isDebugEnabled())
{
logger.debug("Result: \n\tRequest: " + req + "\n\tModel: " + model);
}
return model;
}