org.springframework.extensions.webscripts.Cache Java Examples
The following examples show how to use
org.springframework.extensions.webscripts.Cache.
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: LargeContentTestPut.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) { Map<String, Object> model = new HashMap<String, Object>(); try { req.getContent().getInputStream().close(); model.put("result", "success"); } catch (IOException e) { throw new WebScriptException(Status.STATUS_INTERNAL_SERVER_ERROR, "Fail to read request content."); } return model; }
Example #2
Source File: UserCalendarEntriesGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) { Map<String, String> templateVars = req.getServiceMatch().getTemplateVars(); // Site is optional SiteInfo site = null; String siteName = templateVars.get("site"); if (siteName != null) { site = siteService.getSite(siteName); // MNT-3053 fix, siteName was provided in request but it doesn't exists or user has no permissions to access it. if (site == null) { status.setCode(HttpServletResponse.SC_NOT_FOUND, "Site '" + siteName + "' does not exist or user has no permissions to access it."); return null; } } return executeImpl(site, null, req, null, status, cache); }
Example #3
Source File: RepoUsagePost.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) { Map<String, Object> model = new HashMap<String, Object>(7); boolean updated = repoAdminService.updateUsage(UsageType.USAGE_ALL); RepoUsage repoUsage = repoAdminService.getUsage(); putUsageInModel(model, repoUsage, updated); // Done if (logger.isDebugEnabled()) { logger.debug("Result: \n\tRequest: " + req + "\n\tModel: " + model); } return model; }
Example #4
Source File: WorkflowInstancesForNodeGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected Map<String, Object> buildModel(WorkflowModelBuilder modelBuilder, WebScriptRequest req, Status status, Cache cache) { Map<String, String> params = req.getServiceMatch().getTemplateVars(); // get nodeRef from request NodeRef nodeRef = new NodeRef(params.get(PARAM_STORE_TYPE), params.get(PARAM_STORE_ID), params.get(PARAM_NODE_ID)); // list all active workflows for nodeRef List<WorkflowInstance> workflows = workflowService.getWorkflowsForContent(nodeRef, true); List<Map<String, Object>> results = new ArrayList<Map<String, Object>>(workflows.size()); for (WorkflowInstance workflow : workflows) { results.add(modelBuilder.buildSimple(workflow)); } Map<String, Object> model = new HashMap<String, Object>(); // build the model for ftl model.put("workflowInstances", results); return model; }
Example #5
Source File: AbstractSiteWebScript.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) { // Grab the site String siteName = req.getServiceMatch().getTemplateVars().get("shortname"); SiteInfo site = siteService.getSite(siteName); if (site == null) { throw new WebScriptException( Status.STATUS_NOT_FOUND, "No Site found with that short name"); } // Process return executeImpl(site, req, status, cache); }
Example #6
Source File: WorkflowInstanceGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected Map<String, Object> buildModel(WorkflowModelBuilder modelBuilder, WebScriptRequest req, Status status, Cache cache) { Map<String, String> params = req.getServiceMatch().getTemplateVars(); // getting workflow instance id from request parameters String workflowInstanceId = params.get("workflow_instance_id"); boolean includeTasks = getIncludeTasks(req); WorkflowInstance workflowInstance = workflowService.getWorkflowById(workflowInstanceId); // task was not found -> return 404 if (workflowInstance == null) { throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find workflow instance with id: " + workflowInstanceId); } Map<String, Object> model = new HashMap<String, Object>(); // build the model for ftl model.put("workflowInstance", modelBuilder.buildDetailed(workflowInstance, includeTasks)); return model; }
Example #7
Source File: WorkflowDefinitionGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected Map<String, Object> buildModel(WorkflowModelBuilder modelBuilder, WebScriptRequest req, Status status, Cache cache) { Map<String, String> params = req.getServiceMatch().getTemplateVars(); // Get the definition id from the params String workflowDefinitionId = params.get(PARAM_WORKFLOW_DEFINITION_ID); WorkflowDefinition workflowDefinition = workflowService.getDefinitionById(workflowDefinitionId); // Workflow definition is not found, 404 if (workflowDefinition == null) { throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find workflow definition with id: " + workflowDefinitionId); } Map<String, Object> model = new HashMap<String, Object>(); model.put("workflowDefinition", modelBuilder.buildDetailed(workflowDefinition)); return model; }
Example #8
Source File: ReplicationDefinitionsGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected Map<String, Object> buildModel(ReplicationModelBuilder modelBuilder, WebScriptRequest req, Status status, Cache cache) { // Get all the defined replication definitions List<ReplicationDefinition> definitions = replicationService.loadReplicationDefinitions(); // How do we need to sort them? Comparator<Map<String,Object>> sorter = new ReplicationModelBuilder.SimpleSorterByName(); String sort = req.getParameter("sort"); if(sort == null) { // Default was set above } else if(sort.equalsIgnoreCase("status")) { sorter = new ReplicationModelBuilder.SimpleSorterByStatus(); } else if(sort.equalsIgnoreCase("lastRun") || sort.equalsIgnoreCase("lastRunTime")) { sorter = new ReplicationModelBuilder.SimpleSorterByLastRun(); } // Have them turned into simple models return modelBuilder.buildSimpleList(definitions, sorter); }
Example #9
Source File: BulkImportStopWebScript.java From alfresco-bulk-import with Apache License 2.0 | 6 votes |
/** * @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(final WebScriptRequest request, final Status status, final Cache cache) { Map<String, Object> result = new HashMap<>(); cache.setNeverCache(true); if (importer.getStatus().inProgress()) { result.put("result", "stop requested"); importer.stop(); status.setCode(Status.STATUS_ACCEPTED, "Stop requested."); status.setRedirect(true); // Make sure the custom 202 status template is used (why this is needed at all is beyond me...) } else { result.put("result", "no imports in progress"); status.setCode(Status.STATUS_BAD_REQUEST, "No bulk imports are in progress."); } return(result); }
Example #10
Source File: SolrFacetConfigAdminPost.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected Map<String, Object> unprotectedExecuteImpl(WebScriptRequest req, Status status, Cache cache) { try { SolrFacetProperties fp = parseRequestForFacetProperties(req); facetService.createFacetNode(fp); if (logger.isDebugEnabled()) { logger.debug("Created facet node: " + fp); } } catch (Throwable t) { throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not save the facet configuration.", t); } return new HashMap<>(); // Needs to be mutable. }
Example #11
Source File: SolrFacetConfigAdminDelete.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected Map<String, Object> unprotectedExecuteImpl(WebScriptRequest req, Status status, Cache cache) { // get the filterID parameter. Map<String, String> templateVars = req.getServiceMatch().getTemplateVars(); String filterID = templateVars.get("filterID"); if (filterID == null) { throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Filter id not provided"); } facetService.deleteFacet(filterID); Map<String, Object> model = new HashMap<String, Object>(1); model.put("success", true); if (logger.isDebugEnabled()) { logger.debug("Facet [" + filterID + "] has been deleted successfully"); } return model; }
Example #12
Source File: RunningActionGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected Map<String, Object> buildModel( RunningActionModelBuilder modelBuilder, WebScriptRequest req, Status status, Cache cache) { // Which action did they ask for? String actionTrackingId = req.getServiceMatch().getTemplateVars().get("action_tracking_id"); ExecutionSummary action = getSummaryFromKey(actionTrackingId); // Get the details, if we can Map<String,Object> model = modelBuilder.buildSimpleModel(action); if(model == null) { throw new WebScriptException( Status.STATUS_NOT_FOUND, "No Running Action found with that tracking id" ); } return model; }
Example #13
Source File: TaskInstanceGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected Map<String, Object> buildModel(WorkflowModelBuilder modelBuilder, WebScriptRequest req, Status status, Cache cache) { Map<String, String> params = req.getServiceMatch().getTemplateVars(); // getting task id from request parameters String taskId = params.get("task_instance_id"); // searching for task in repository WorkflowTask workflowTask = workflowService.getTaskById(taskId); // task was not found -> return 404 if (workflowTask == null) { throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find workflow task with id: " + taskId); } Map<String, Object> model = new HashMap<String, Object>(); // build the model for ftl model.put("workflowTask", modelBuilder.buildDetailed(workflowTask)); return model; }
Example #14
Source File: BulkFilesystemImportStatusWebScript.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
/** * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(WebScriptRequest, Status, Cache) */ @Override protected Map<String, Object> executeImpl(WebScriptRequest request, Status status, Cache cache) { Map<String, Object> result = new HashMap<String, Object>(); cache.setNeverCache(true); LicenseDescriptor licenseDescriptor = descriptorService.getLicenseDescriptor(); boolean isEnterprise = (licenseDescriptor == null ? false : (licenseDescriptor.getLicenseMode() == LicenseMode.ENTERPRISE)); result.put(IS_ENTERPRISE, Boolean.valueOf(isEnterprise)); result.put(RESULT_IMPORT_STATUS, bulkImporter.getStatus()); return(result); }
Example #15
Source File: ArchivedNodesGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) { Map<String, Object> model = new HashMap<String, Object>(); // We want to get all nodes in the archive which were originally // contained in the following StoreRef. StoreRef storeRef = parseRequestForStoreRef(req); // Create paging ScriptPagingDetails paging = new ScriptPagingDetails(getIntParameter(req, MAX_ITEMS, DEFAULT_MAX_ITEMS_PER_PAGE), getIntParameter(req, SKIP_COUNT, 0)); PagingResults<NodeRef> result = getArchivedNodesFrom(storeRef, paging, req.getParameter(NAME_FILTER)); List<NodeRef> nodeRefs = result.getPage(); List<ArchivedNodeState> deletedNodes = new ArrayList<ArchivedNodeState>(nodeRefs.size()); for (NodeRef archivedNode : nodeRefs) { ArchivedNodeState state = ArchivedNodeState.create(archivedNode, serviceRegistry); deletedNodes.add(state); } // Now do the paging // ALF-19111. Note: Archived nodes CQ, supports Paging, // so no need to use the ModelUtil.page method to build the page again. model.put(DELETED_NODES, deletedNodes); // Because we haven't used ModelUtil.page method, we need to set the total items manually. paging.setTotalItems(deletedNodes.size()); model.put("paging", ModelUtil.buildPaging(paging)); return model; }
Example #16
Source File: SolrFacetConfigAdminGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected Map<String, Object> unprotectedExecuteImpl(WebScriptRequest req, Status status, Cache cache) { // get the filterID parameter. Map<String, String> templateVars = req.getServiceMatch().getTemplateVars(); String filterID = templateVars.get("filterID"); Map<String, Object> model = new HashMap<String, Object>(1); if (filterID == null) { model.put("filters", facetService.getFacets()); } else { SolrFacetProperties fp = facetService.getFacet(filterID); if (fp == null) { throw new WebScriptException(Status.STATUS_NOT_FOUND, "Filter not found"); } model.put("filter", fp); } if (logger.isDebugEnabled()) { logger.debug("Retrieved all available facets: " + model.values()); } return model; }
Example #17
Source File: RatingDefinitionsGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) { Map<String, Object> model = new HashMap<String, Object>(); Map<String, RatingScheme> schemes = this.ratingService.getRatingSchemes(); model.put("schemeDefs", schemes); return model; }
Example #18
Source File: ActionConditionDefinitionsGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) { Map<String, Object> model = new HashMap<String, Object>(); // get all action condition definitions List<ActionConditionDefinition> actionconditiondefinitions = actionService.getActionConditionDefinitions(); model.put("actionconditiondefinitions", actionconditiondefinitions); return model; }
Example #19
Source File: InheritedRulesGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) { Map<String, Object> model = new HashMap<String, Object>(); // get request parameters NodeRef nodeRef = parseRequestForNodeRef(req); String ruleType = req.getParameter("ruleType"); RuleType type = ruleService.getRuleType(ruleType); if (type == null) { ruleType = null; } // get all rules (including inherited) filtered by rule type List<Rule> inheritedRules = ruleService.getRules(nodeRef, true, ruleType); // get owned rules (excluding inherited) filtered by rule type List<Rule> ownedRules = ruleService.getRules(nodeRef, false, ruleType); // remove owned rules inheritedRules.removeAll(ownedRules); List<RuleRef> inheritedRuleRefs = new ArrayList<RuleRef>(); for (Rule rule : inheritedRules) { inheritedRuleRefs.add(new RuleRef(rule, fileFolderService.getFileInfo(ruleService.getOwningNodeRef(rule)))); } model.put("inheritedRuleRefs", inheritedRuleRefs); return model; }
Example #20
Source File: BlogPostsPost.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected Map<String, Object> executeImpl(SiteInfo site, NodeRef nodeRef, BlogPostInfo blog, WebScriptRequest req, JSONObject json, Status status, Cache cache) { Map<String, Object> model = new HashMap<String, Object>(); // If they're doing Path Based rather than Site Based, ensure // that the Container is a Tag Scope if(site == null && nodeRef != null) { ensureTagScope(nodeRef); } // Have the Blog Post created JsonParams jsonPostParams = parsePostParams(json); BlogPostInfo post = createBlogPost(jsonPostParams, site, nodeRef); Map<String, Object> blogPostData = BlogPostLibJs.getBlogPostData(post.getNodeRef(), services); model.put(ITEM, blogPostData); model.put(EXTERNAL_BLOG_CONFIG, BlogPostLibJs.hasExternalBlogConfiguration(nodeRef, services)); boolean isDraft = blogPostData.get("isDraft") != null && ((Boolean)blogPostData.get("isDraft")).booleanValue(); if (jsonPostParams.getSite() != null && jsonPostParams.getContainer() != null && jsonPostParams.getPage() != null && !isDraft) { addActivityEntry("created", post, site, req, json, post.getNodeRef()); } return model; }
Example #21
Source File: ActionConstraintsGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) { Map<String, Object> model = new HashMap<String, Object>(); // get request parameters String[] names = req.getParameterValues("name"); List<ParameterConstraint> parameterConstraints = null; if (names != null && names.length > 0) { // filter is present in request parameterConstraints = new ArrayList<ParameterConstraint>(); // find specified parameter constraints for (String name : names) { ParameterConstraint parameterConstraint = actionService.getParameterConstraint(name); if (parameterConstraint != null) { parameterConstraints.add(parameterConstraint); } } } else { // no filter was provided, return all parameter constraints parameterConstraints = actionService.getParameterConstraints(); } model.put("actionConstraints", parameterConstraints); return model; }
Example #22
Source File: BulkImportPauseWebScript.java From alfresco-bulk-import with Apache License 2.0 | 5 votes |
/** * @see DeclarativeWebScript#executeImpl(WebScriptRequest, Status, Cache) */ @Override protected Map<String, Object> executeImpl(final WebScriptRequest request, final Status status, final Cache cache) { Map<String, Object> result = new HashMap<>(); cache.setNeverCache(true); if (importer.getStatus().inProgress()) { if (!importer.getStatus().isPaused()) { result.put("result", "pause requested"); importer.pause(); status.setCode(Status.STATUS_ACCEPTED, "Pause requested."); status.setRedirect(true); // Make sure the custom 202 status template is used (why this is needed at all is beyond me...) } else { result.put("result", "import is already paused"); status.setCode(Status.STATUS_BAD_REQUEST, "Bulk import is already paused."); } } else { result.put("result", "no imports in progress"); status.setCode(Status.STATUS_BAD_REQUEST, "No bulk imports are in progress."); } return(result); }
Example #23
Source File: ActionDefinitionsGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) { Map<String, Object> model = new HashMap<String, Object>(); // get all action definitions List<ActionDefinition> actiondefinitions = actionService.getActionDefinitions(); model.put("actiondefinitions", actiondefinitions); return model; }
Example #24
Source File: AuditControlPost.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) { Map<String, Object> model = new HashMap<String, Object>(7); String appName = getParamAppName(req); String path = getParamPath(req); boolean enable = getParamEnableDisable(req); if (appName == null) { // Global operation auditService.setAuditEnabled(enable); } else { // Apply to a specific application if (enable) { auditService.enableAudit(appName, path); } else { auditService.disableAudit(appName, path); } } model.put(JSON_KEY_ENABLED, enable); // Done if (logger.isDebugEnabled()) { logger.debug("Result: \n\tRequest: " + req + "\n\tModel: " + model); } return model; }
Example #25
Source File: RulesGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) { Map<String, Object> model = new HashMap<String, Object>(); // get request parameters NodeRef nodeRef = parseRequestForNodeRef(req); String ruleType = req.getParameter("ruleType"); RuleType type = ruleService.getRuleType(ruleType); if (type == null) { ruleType = null; } // get all rules (excluding inherited) filtered by rule type List<Rule> rules = ruleService.getRules(nodeRef, false, ruleType); List<RuleRef> ruleRefs = new ArrayList<RuleRef>(); for (Rule rule : rules) { ruleRefs.add(new RuleRef(rule, fileFolderService.getFileInfo(ruleService.getOwningNodeRef(rule)))); } model.put("ruleRefs", ruleRefs); return model; }
Example #26
Source File: WorkflowInstanceDelete.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected Map<String, Object> buildModel(WorkflowModelBuilder modelBuilder, WebScriptRequest req, Status status, Cache cache) { Map<String, String> params = req.getServiceMatch().getTemplateVars(); // getting workflow instance id from request parameters String workflowInstanceId = params.get("workflow_instance_id"); // determine if instance should be cancelled or deleted boolean forced = getForced(req); if (canUserEndWorkflow(workflowInstanceId)) { if (forced) { workflowService.deleteWorkflow(workflowInstanceId); } else { workflowService.cancelWorkflow(workflowInstanceId); } return null; } else { throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "Failed to " + (forced ? "delete" : "cancel") + " workflow instance with id: " + workflowInstanceId); } }
Example #27
Source File: AbstractCommentsWebScript.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
/** * Overrides DeclarativeWebScript with parse request for nodeRef */ @Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) { // get requested node NodeRef nodeRef = parseRequestForNodeRef(req); // Have the real work done return executeImpl(nodeRef, req, status, cache); }
Example #28
Source File: ReadGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected Map<String, Object> executeImpl(final WebScriptRequest req, Status status, Cache cache) { if (! isEnabled()) { throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "QuickShare is disabled system-wide"); } // create map of params (template vars) Map<String, String> params = req.getServiceMatch().getTemplateVars(); final String sharedId = params.get("shared_id"); if (sharedId == null) { throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "A valid sharedId must be specified !"); } try { boolean canRead = quickShareService.canRead(sharedId); Map<String, Object> result = new HashMap<String, Object>(); result.put("canRead", canRead); return result; } catch (InvalidSharedIdException ex) { logger.error("Unable to find: "+sharedId); throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find: "+sharedId); } catch (InvalidNodeRefException inre) { logger.error("Unable to find: "+sharedId+" ["+inre.getNodeRef()+"]"); throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find: "+sharedId); } }
Example #29
Source File: ContentInfo.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
protected void streamContentImpl(WebScriptRequest req, WebScriptResponse res, ContentReader reader, NodeRef nodeRef, QName propertyQName, boolean attach, Date modified, String eTag, String attachFileName) throws IOException { delegate.setAttachment(req, res, attach, attachFileName); // establish mimetype String mimetype = reader.getMimetype(); String extensionPath = req.getExtensionPath(); if (mimetype == null || mimetype.length() == 0) { mimetype = MimetypeMap.MIMETYPE_BINARY; int extIndex = extensionPath.lastIndexOf('.'); if (extIndex != -1) { String ext = extensionPath.substring(extIndex + 1); mimetype = mimetypeService.getMimetype(ext); } } // set mimetype for the content and the character encoding + length for the stream res.setContentType(mimetype); res.setContentEncoding(reader.getEncoding()); res.setHeader("Content-Length", Long.toString(reader.getSize())); // set caching Cache cache = new Cache(); cache.setNeverCache(false); cache.setMustRevalidate(true); cache.setMaxAge(0L); cache.setLastModified(modified); cache.setETag(eTag); res.setCache(cache); }
Example #30
Source File: AbstractExecuteActionWebscript.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
protected Map<String, Object> buildModel( RunningActionModelBuilder modelBuilder, WebScriptRequest req, Status status, Cache cache) { try { // Have the action to run be identified Action action = identifyAction(req, status, cache); if(action == null) { throw new WebScriptException( Status.STATUS_NOT_FOUND, "No Runnable Action found with the supplied details" ); } // Ask for it to be run in the background // It will be available to execute once the webscript finishes actionService.executeAction( action, null, false, true ); // Return the details if we can ExecutionSummary summary = getSummaryFromAction(action); if(summary == null) { throw new WebScriptException( Status.STATUS_EXPECTATION_FAILED, "Action failed to be added to the pending queue" ); } return modelBuilder.buildSimpleModel(summary); } catch(Exception e) { // Transaction broke throw new RuntimeException(e); } }