Java Code Examples for org.springframework.extensions.webscripts.WebScriptRequest#getContent()
The following examples show how to use
org.springframework.extensions.webscripts.WebScriptRequest#getContent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AlfrescoModelsDiff.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
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; }
Example 2
Source File: WebScriptUtil.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 4 votes |
public static String getContent(WebScriptRequest request) throws IOException { Content content = request.getContent(); return content.getContent(); }
Example 3
Source File: AclsGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 4 votes |
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; }
Example 4
Source File: AclsReadersGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 4 votes |
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; }