org.springframework.extensions.webscripts.WebScriptRequest - java examples

Here are the examples of the java api org.springframework.extensions.webscripts.WebScriptRequest taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

155 Examples 7

16 View Complete Implementation : TransactionIntervalGet.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
/* (non-Javadoc)
     * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.WebScriptResponse)
     */
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status) {
    Long fromNodeId = Long.parseLong(req.getParameter("fromNodeId"));
    Long toNodeId = Long.parseLong(req.getParameter("toNodeId"));
    Map<String, Object> model = new HashMap<>();
    model.put("minTransactionCommitTimeMs", nodeDAO.getMinTxInNodeIdRange(fromNodeId, toNodeId));
    model.put("maxTransactionCommitTimeMs", nodeDAO.getMaxTxInNodeIdRange(fromNodeId, toNodeId));
    return model;
}

16 View Complete Implementation : SubscriptionServiceFollowsPost.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@SuppressWarnings("unchecked")
public JSONArray executeImpl(String userId, WebScriptRequest req, WebScriptResponse res) throws IOException, ParseException {
    JSONArray jsonUsers = (JSONArray) JSONValue.parseWithException(req.getContent().getContent());
    JSONArray result = new JSONArray();
    for (Object o : jsonUsers) {
        String user = (o == null ? null : o.toString());
        if (user != null) {
            JSONObject item = new JSONObject();
            item.put(user, subscriptionService.follows(userId, user));
            result.add(item);
        }
    }
    return result;
}

16 View Complete Implementation : RunningReplicationActionsPost.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@Override
protected Action identifyAction(WebScriptRequest req, Status status, Cache cache) {
    // Which action did they ask for?
    String name = req.getParameter("name");
    if (name == null) {
        try {
            JSONObject json = new JSONObject(new JSONTokener(req.getContent().getContent()));
            if (!json.has("name")) {
                throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not find required 'name' parameter");
            }
            name = json.getString("name");
        } catch (IOException iox) {
            throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not read content from request.", iox);
        } catch (JSONException je) {
            throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not parse JSON from request.", je);
        }
    }
    // Load the specified replication definition
    ReplicationDefinition replicationDefinition = replicationService.loadReplicationDefinition(name);
    return replicationDefinition;
}

16 View Complete Implementation : CalendarEntryDelete.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@Override
protected Map<String, Object> executeImpl(SiteInfo site, String eventName, WebScriptRequest req, JSONObject json, Status status, Cache cache) {
    CalendarEntry entry = calendarService.getCalendarEntry(site.getShortName(), eventName);
    if (entry == null) {
        status.setCode(Status.STATUS_NOT_FOUND);
        return null;
    }
    // Special case for "deleting" an instance of a recurring event
    if (req.getParameter("date") != null && entry.getRecurrenceRule() != null) {
        // Have an ignored event generated
        createIgnoreEvent(req, entry);
        // Mark as ignored
        status.setCode(Status.STATUS_NO_CONTENT, "Recurring entry ignored");
        return null;
    }
    // Delete the calendar entry
    calendarService.deleteCalendarEntry(entry);
    // Record this in the activity feed
    addActivityEntry("deleted", entry, site, req, json);
    // All done
    status.setCode(Status.STATUS_NO_CONTENT, "Entry deleted");
    return null;
}

16 View Complete Implementation : AbstractAuditWebScript.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
/**
 * Get the entry id from the request.
 *
 * @return Returns the id or <tt>null</tt> if not present
 */
protected Long getId(WebScriptRequest req) {
    Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
    String id = templateVars.get("id");
    if (id == null || id.length() == 0) {
        return null;
    } else {
        try {
            return Long.parseLong(id);
        } catch (NumberFormatException e) {
            return null;
        }
    }
}

16 View Complete Implementation : InfoWebScriptGet.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@Override
public void execute(final Api api, WebScriptRequest req, WebScriptResponse res) throws IOException {
    ResourceDictionary resourceDic = lookupDictionary.getDictionary();
    final Map<String, ResourceWithMetadata> apiResources = resourceDic.getAllResources().get(api);
    if (apiResources == null) {
        throw new InvalidArgumentException(InvalidArgumentException.DEFAULT_INVALID_API);
    }
    replacedistant.getJsonHelper().withWriter(res.getOutputStream(), new Writer() {

        @Override
        public void writeContents(JsonGenerator generator, ObjectMapper objectMapper) throws JsonGenerationException, JsonMappingException, IOException {
            List<ExecutionResult> enreplacedies = new ArrayList<ExecutionResult>();
            for (ResourceWithMetadata resource : apiResources.values()) {
                enreplacedies.add(new ExecutionResult(resource.getMetaData(), null));
            }
            Collections.sort(enreplacedies, new Comparator<ExecutionResult>() {

                public int compare(ExecutionResult r1, ExecutionResult r2) {
                    return ((ResourceMetadata) r1.getRoot()).getUniqueId().compareTo(((ResourceMetadata) r2.getRoot()).getUniqueId());
                }
            });
            objectMapper.writeValue(generator, CollectionWithPagingInfo.asPaged(Paging.DEFAULT, enreplacedies));
        }
    });
}

16 View Complete Implementation : AclsReadersGet.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status) {
    try {
        Map<String, Object> model = buildModel(req);
        if (logger.isDebugEnabled()) {
            logger.debug("Result: \n\tRequest: " + req + "\n\tModel: " + model);
        }
        return model;
    } catch (IOException e) {
        throw new WebScriptException("IO exception parsing request", e);
    } catch (JSONException e) {
        throw new WebScriptException("Invalid JSON", e);
    }
}

16 View Complete Implementation : InviteResponse.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
/*
     * (non-Javadoc)
     * 
     * @see
     * org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco
     * .web.scripts.WebScriptRequest,
     * org.alfresco.web.scripts.WebScriptResponse)
     */
@Override
protected Map<String, Object> executeImpl(final WebScriptRequest req, final Status status) {
    String tenantDomain = TenantService.DEFAULT_DOMAIN;
    final String inviteeUserName = req.getParameter(PARAM_INVITEE_USER_NAME);
    if (tenantService.isEnabled()) {
        if (inviteeUserName != null) {
            tenantDomain = tenantService.getUserDomain(inviteeUserName);
        }
    }
    // run as system user
    return TenantUtil.runreplacedystemTenant(new TenantRunAsWork<Map<String, Object>>() {

        public Map<String, Object> doWork() throws Exception {
            String oldUser = null;
            try {
                if (inviteeUserName != null && !inviteeUserName.equals(oldUser)) {
                    oldUser = AuthenticationUtil.getFullyAuthenticatedUser();
                    AuthenticationUtil.setFullyAuthenticatedUser(inviteeUserName);
                }
                return execute(req, status);
            } finally {
                if (oldUser != null && !oldUser.equals(inviteeUserName)) {
                    AuthenticationUtil.setFullyAuthenticatedUser(oldUser);
                }
            }
        }
    }, tenantDomain);
}

16 View Complete Implementation : AuditClearPost.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@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);
    if (appName == null) {
        throw new WebScriptException(Status.STATUS_BAD_REQUEST, "audit.err.app.notProvided");
    }
    AuditApplication app = auditService.getAuditApplications().get(appName);
    if (app == null) {
        throw new WebScriptException(Status.STATUS_NOT_FOUND, "audit.err.app.notFound", appName);
    }
    // Get from/to times
    // might be null
    Long fromTime = getParamFromTime(req);
    // might be null
    Long toTime = getParamToTime(req);
    // Clear
    int cleared = auditService.clearAudit(appName, fromTime, toTime);
    model.put(JSON_KEY_CLEARED, cleared);
    // Done
    if (logger.isDebugEnabled()) {
        logger.debug("Result: \n\tRequest: " + req + "\n\tModel: " + model);
    }
    return model;
}

16 View Complete Implementation : AbstractArchivedNodeWebScript.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
protected NodeRef parseRequestForNodeRef(WebScriptRequest req) {
    // get the parameters that represent the NodeRef. They may not all be there
    // for all deletednodes webscripts.
    Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
    String storeType = templateVars.get("store_type");
    String storeId = templateVars.get("store_id");
    String id = templateVars.get("id");
    if (id == null || id.trim().length() == 0) {
        return null;
    } else {
        return new NodeRef(storeType, storeId, id);
    }
}

16 View Complete Implementation : RunningActionsPost.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@Override
protected Action identifyAction(WebScriptRequest req, Status status, Cache cache) {
    // Which action did they ask for?
    String nodeRef = req.getParameter("nodeRef");
    if (nodeRef == null) {
        try {
            JSONObject json = new JSONObject(new JSONTokener(req.getContent().getContent()));
            if (!json.has("nodeRef")) {
                throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not find required 'nodeRef' parameter");
            }
            nodeRef = json.getString("nodeRef");
        } catch (IOException iox) {
            throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not read content from request.", iox);
        } catch (JSONException je) {
            throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not parse JSON from request.", je);
        }
    }
    // Does it exist in the repo?
    NodeRef actionNodeRef = new NodeRef(nodeRef);
    if (!nodeService.exists(actionNodeRef)) {
        return null;
    }
    // Load the specified action
    Action action = runtimeActionService.createAction(actionNodeRef);
    return action;
}

16 View Complete Implementation : ExecutionTests.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
private WebScriptRequest mockRequest(Map<String, String> templateVars, final Map<String, List<String>> params) {
    final String[] paramNames = params.keySet().toArray(new String[] {});
    WebScriptRequest request = mock(WebScriptRequest.clreplaced);
    when(request.getServiceMatch()).thenReturn(new Match(null, templateVars, null));
    when(request.getParameterNames()).thenReturn(paramNames);
    when(request.getParameterValues(anyString())).thenAnswer(new Answer<String[]>() {

        @Override
        public String[] answer(InvocationOnMock invocation) throws Throwable {
            Object[] args = invocation.getArguments();
            return params.get((String) args[0]).toArray(new String[] {});
        }
    });
    return request;
}

16 View Complete Implementation : SubscriptionServiceFollowersGet.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@SuppressWarnings("unchecked")
public JSONObject executeImpl(String userId, WebScriptRequest req, WebScriptResponse res) throws IOException {
    PagingFollowingResults result = subscriptionService.getFollowers(userId, createPagingRequest(req));
    JSONObject obj = new JSONObject();
    obj.put("people", getUserArray(result.getPage()));
    obj.put("hasMoreItems", result.hasMoreItems());
    if (result.getTotalResultCount() != null) {
        obj.put("totalCount", result.getTotalResultCount().getFirst());
    }
    return obj;
}

16 View Complete Implementation : TransferWebScript.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
/* (non-Javadoc)
     * @see org.alfresco.web.scripts.WebScript#execute(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.WebScriptResponse)
     */
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException {
    if (enabled) {
        log.debug("Transfer webscript invoked by user: " + AuthenticationUtil.getFullyAuthenticatedUser() + " running as " + AuthenticationUtil.getRunAsAuthentication().getName());
        processCommand(req.getServiceMatch().getTemplateVars().get("command"), req, res);
    } else {
        res.setStatus(Status.STATUS_NOT_FOUND);
    }
}

16 View Complete Implementation : SubscriptionServiceFollowingGet.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@SuppressWarnings("unchecked")
public JSONObject executeImpl(String userId, WebScriptRequest req, WebScriptResponse res) throws IOException {
    PagingFollowingResults result = subscriptionService.getFollowing(userId, createPagingRequest(req));
    JSONObject obj = new JSONObject();
    obj.put("people", getUserArray(result.getPage()));
    obj.put("hasMoreItems", result.hasMoreItems());
    if (result.getTotalResultCount() != null) {
        obj.put("totalCount", result.getTotalResultCount().getFirst());
    }
    return obj;
}

16 View Complete Implementation : StreamContent.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
/**
 * Streams the content on a given node's content property to the response of the web script.
 *
 * @param req               Request
 * @param res               Response
 * @param nodeRef           The node reference
 * @param propertyQName     The content property name
 * @param attach            Indicates whether the content should be streamed as an attachment or not
 * @param attachFileName    Optional file name to use when attach is <code>true</code>
 * @throws IOException
 */
protected void streamContent(WebScriptRequest req, WebScriptResponse res, NodeRef nodeRef, QName propertyQName, boolean attach, String attachFileName, Map<String, Object> model) throws IOException {
    delegate.streamContent(req, res, nodeRef, propertyQName, attach, attachFileName, model);
}

16 View Complete Implementation : WorkflowDefinitionsGet.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@Override
protected Map<String, Object> buildModel(WorkflowModelBuilder modelBuilder, WebScriptRequest req, Status status, Cache cache) {
    ExcludeFilter excludeFilter = null;
    String excludeParam = req.getParameter(PARAM_EXCLUDE);
    if (excludeParam != null && excludeParam.length() > 0) {
        excludeFilter = new ExcludeFilter(excludeParam);
    }
    // list all workflow's definitions simple representation
    List<WorkflowDefinition> workflowDefinitions = workflowService.getDefinitions();
    ArrayList<Map<String, Object>> results = new ArrayList<Map<String, Object>>();
    for (WorkflowDefinition workflowDefinition : workflowDefinitions) {
        // if present, filter out excluded definitions
        if (excludeFilter == null || !excludeFilter.isMatch(workflowDefinition.getName())) {
            results.add(modelBuilder.buildSimple(workflowDefinition));
        }
    }
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("workflowDefinitions", results);
    return model;
}

16 View Complete Implementation : RunningActionsGet.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@Override
protected Map<String, Object> buildModel(RunningActionModelBuilder modelBuilder, WebScriptRequest req, Status status, Cache cache) {
    List<ExecutionSummary> actions = null;
    // Do they want all actions, or only certain ones?
    String type = req.getParameter("type");
    String nodeRef = req.getParameter("nodeRef");
    if (type != null) {
        actions = actionTrackingService.getExecutingActions(type);
    } else if (nodeRef != null) {
        NodeRef actionNodeRef = new NodeRef(nodeRef);
        Action action = runtimeActionService.createAction(actionNodeRef);
        actions = actionTrackingService.getExecutingActions(action);
    } else {
        actions = actionTrackingService.getAllExecutingActions();
    }
    // Build the model list
    return modelBuilder.buildSimpleList(actions);
}

15 View Complete Implementation : ArchivedNodePut.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
    Map<String, Object> model = new HashMap<String, Object>();
    // Current user
    String userID = AuthenticationUtil.getFullyAuthenticatedUser();
    if (userID == null) {
        throw new WebScriptException(HttpServletResponse.SC_UNAUTHORIZED, "Web Script [" + req.getServiceMatch().getWebScript().getDescription() + "] requires user authentication.");
    }
    NodeRef nodeRefToBeRestored = parseRequestForNodeRef(req);
    if (nodeRefToBeRestored == null) {
        throw new WebScriptException(Status.STATUS_BAD_REQUEST, "nodeRef not recognised. Could not restore.");
    }
    // check if the current user has the permission to restore the node
    validatePermission(nodeRefToBeRestored, userID);
    RestoreNodeReport report = nodeArchiveService.restoreArchivedNode(nodeRefToBeRestored);
    // Handling of some error scenarios
    if (report.getStatus().equals(RestoreNodeReport.RestoreStatus.FAILURE_INVALID_ARCHIVE_NODE)) {
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find archive node: " + nodeRefToBeRestored);
    } else if (report.getStatus().equals(RestoreNodeReport.RestoreStatus.FAILURE_PERMISSION)) {
        throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "Unable to restore archive node: " + nodeRefToBeRestored);
    } else if (report.getStatus().equals(RestoreNodeReport.RestoreStatus.FAILURE_DUPLICATE_CHILD_NODE_NAME)) {
        throw new WebScriptException(HttpServletResponse.SC_CONFLICT, "Unable to restore archive node: " + nodeRefToBeRestored + ". Duplicate child node name");
    } else if (report.getStatus().equals(RestoreNodeReport.RestoreStatus.FAILURE_INVALID_PARENT) || report.getStatus().equals(RestoreNodeReport.RestoreStatus.FAILURE_INTEGRITY) || report.getStatus().equals(RestoreNodeReport.RestoreStatus.FAILURE_OTHER)) {
        throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Unable to restore archive node: " + nodeRefToBeRestored);
    }
    model.put("restoreNodeReport", report);
    return model;
}

15 View Complete Implementation : RulesGet.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@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;
}

15 View Complete Implementation : UserCSVUploadGet.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@Override
protected List<Pair<QName, Boolean>> buildPropertiesForHeader(Object resource, String format, WebScriptRequest req) {
    List<Pair<QName, Boolean>> properties = new ArrayList<Pair<QName, Boolean>>(UserCSVUploadPost.COLUMNS.length);
    boolean required = true;
    for (QName qname : UserCSVUploadPost.COLUMNS) {
        Pair<QName, Boolean> p = null;
        if (qname != null) {
            p = new Pair<QName, Boolean>(qname, required);
        } else {
            required = false;
        }
        properties.add(p);
    }
    return properties;
}

15 View Complete Implementation : SearchEngines.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
/* (non-Javadoc)
     * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.WebScriptResponse)
     */
@SuppressWarnings("deprecation")
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status) {
    String urlType = req.getParameter("type");
    if (urlType == null || urlType.length() == 0) {
        urlType = URL_ARG_DESCRIPTION;
    } else if (!urlType.equals(URL_ARG_DESCRIPTION) && !urlType.equals(URL_ARG_TEMPLATE) && !urlType.equals(URL_ARG_ALL)) {
        urlType = URL_ARG_DESCRIPTION;
    }
    // 
    // retrieve open search engines configuration
    // 
    Set<UrlTemplate> urls = getUrls(urlType);
    Map<String, Object> model = new HashMap<String, Object>(7, 1.0f);
    model.put("urltype", urlType);
    model.put("engines", urls);
    return model;
}

15 View Complete Implementation : AbstractCommentsWebScript.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
/**
 * returns the nodeRef from  web script request
 * @param req
 * @return
 */
protected NodeRef parseRequestForNodeRef(WebScriptRequest req) {
    Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
    String storeType = templateVars.get("store_type");
    String storeId = templateVars.get("store_id");
    String nodeId = templateVars.get("id");
    // create the NodeRef and ensure it is valid
    StoreRef storeRef = new StoreRef(storeType, storeId);
    return new NodeRef(storeRef, nodeId);
}

15 View Complete Implementation : WorkflowInstanceGet.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@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;
}

15 View Complete Implementation : SolrFacetConfigAdminPost.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
private SolrFacetProperties parseRequestForFacetProperties(WebScriptRequest req) {
    JSONObject json = null;
    try {
        json = new JSONObject(new JSONTokener(req.getContent().getContent()));
        final String filterID = json.getString(PARAM_FILTER_ID);
        validateFilterID(filterID);
        final String facetQNameStr = json.getString(PARAM_FACET_QNAME);
        // Note: we're using this util clreplaced here because we need to be able to deal with
        // qnames without a URI e.g. "{}SITE" and *not* have them default to the cm: namespace
        // which happens with the 'normal' Alfresco QName code.
        final QName facetQName = FacetQNameUtils.createQName(facetQNameStr, namespaceService);
        final String displayName = json.getString(PARAM_DISPLAY_NAME);
        final String displayControl = json.getString(PARAM_DISPLAY_CONTROL);
        final int maxFilters = json.getInt(PARAM_MAX_FILTERS);
        final int hitThreshold = json.getInt(PARAM_HIT_THRESHOLD);
        final int minFilterValueLength = json.getInt(PARAM_MIN_FILTER_VALUE_LENGTH);
        final String sortBy = json.getString(PARAM_SORT_BY);
        // Optional params
        final String scope = getValue(String.clreplaced, json.opt(PARAM_SCOPE), "ALL");
        final boolean isEnabled = getValue(Boolean.clreplaced, json.opt(PARAM_IS_ENABLED), false);
        JSONArray scopedSitesJsonArray = getValue(JSONArray.clreplaced, json.opt(PARAM_SCOPED_SITES), null);
        final Set<String> scopedSites = getScopedSites(scopedSitesJsonArray);
        final JSONObject customPropJsonObj = getValue(JSONObject.clreplaced, json.opt(PARAM_CUSTOM_PROPERTIES), null);
        final Set<CustomProperties> customProps = getCustomProperties(customPropJsonObj);
        SolrFacetProperties fp = new SolrFacetProperties.Builder().filterID(filterID).facetQName(facetQName).displayName(displayName).displayControl(displayControl).maxFilters(maxFilters).hitThreshold(hitThreshold).minFilterValueLength(minFilterValueLength).sortBy(sortBy).scope(scope).isEnabled(isEnabled).scopedSites(scopedSites).customProperties(customProps).build();
        return fp;
    } catch (IOException e) {
        throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not read content from req.", e);
    } catch (JSONException e) {
        throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not parse JSON from req.", e);
    }
}

15 View Complete Implementation : AbstractCommentsWebScript.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
/**
 * 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);
}

15 View Complete Implementation : AuditControlGet.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@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 enabledGlobal = auditService.isAuditEnabled();
    Map<String, AuditApplication> appsByName = auditService.getAuditApplications();
    // Check that the application exists
    if (appName != null) {
        if (path == null) {
            throw new WebScriptException(Status.STATUS_BAD_REQUEST, "audit.err.path.notProvided");
        }
        AuditApplication app = appsByName.get(appName);
        if (app == null) {
            throw new WebScriptException(Status.STATUS_NOT_FOUND, "audit.err.app.notFound", appName);
        }
        // Discard all the other applications
        appsByName = Collections.singletonMap(appName, app);
    }
    model.put(JSON_KEY_ENABLED, enabledGlobal);
    model.put(JSON_KEY_APPLICATIONS, appsByName.values());
    // Done
    if (logger.isDebugEnabled()) {
        logger.debug("Result: \n\tRequest: " + req + "\n\tModel: " + model);
    }
    return model;
}

15 View Complete Implementation : AbstractCommentsWebScript.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
/**
 * parse JSON from request
 * @param req
 * @return
 */
protected JSONObject parseJSON(WebScriptRequest req) {
    JSONObject json = null;
    String contentType = req.getContentType();
    if (contentType != null && contentType.indexOf(';') != -1) {
        contentType = contentType.substring(0, contentType.indexOf(';'));
    }
    if (MimetypeMap.MIMETYPE_JSON.equals(contentType)) {
        JSONParser parser = new JSONParser();
        try {
            json = (JSONObject) parser.parse(req.getContent().getContent());
        } catch (IOException io) {
            throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Invalid JSON: " + io.getMessage());
        } catch (ParseException pe) {
            throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Invalid JSON: " + pe.getMessage());
        }
    }
    return json;
}

15 View Complete Implementation : StreamContent.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
/**
 * Stream content implementation
 *
 * @param req               The request
 * @param res               The response
 * @param reader            The reader
 * @param nodeRef           The content nodeRef if applicable
 * @param propertyQName     The content property if applicable
 * @param attach            Indicates whether the content should be streamed as an attachment or not
 * @param modified          Modified date of content
 * @param eTag              ETag to use
 * @param attachFileName    Optional file name to use when attach is <code>true</code>
 * @throws IOException
 */
protected void streamContentImpl(WebScriptRequest req, WebScriptResponse res, ContentReader reader, NodeRef nodeRef, QName propertyQName, boolean attach, Date modified, String eTag, String attachFileName, Map<String, Object> model) throws IOException {
    delegate.streamContentImpl(req, res, reader, nodeRef, propertyQName, attach, modified, eTag, attachFileName, model);
}

15 View Complete Implementation : ContentInfo.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@Override
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException {
    // create empty map of args
    Map<String, String> args = new HashMap<String, String>(0, 1.0f);
    // create map of template vars
    Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
    // create object reference from url
    ObjectReference reference = createObjectReferenceFromUrl(args, templateVars);
    NodeRef nodeRef = reference.getNodeRef();
    if (nodeRef == null) {
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find " + reference.toString());
    }
    // render content
    QName propertyQName = ContentModel.PROP_CONTENT;
    // Stream the content
    streamContent(req, res, nodeRef, propertyQName, false, null, null);
}

15 View Complete Implementation : LinkDelete.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@Override
protected Map<String, Object> executeImpl(SiteInfo site, String linkName, WebScriptRequest req, JSONObject json, Status status, Cache cache) {
    Map<String, Object> model = new HashMap<String, Object>();
    // Try to find the link
    LinkInfo link = linksService.getLink(site.getShortName(), linkName);
    if (link == null) {
        String message = "No link found with that name";
        throw new WebScriptException(Status.STATUS_NOT_FOUND, message);
    }
    // Delete it
    try {
        linksService.deleteLink(link);
    } catch (AccessDeniedException e) {
        String message = "You don't have permission to delete that link";
        throw new WebScriptException(Status.STATUS_FORBIDDEN, message);
    }
    // Mark it as gone
    status.setCode(Status.STATUS_NO_CONTENT);
    return model;
}

15 View Complete Implementation : AbstractGetBlogWebScript.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
private Date parseDateParam(WebScriptRequest req, String paramName) {
    Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
    String dateStr = templateVars.get(paramName);
    if (dateStr == null) {
        // Try on the parameters instead
        dateStr = req.getParameter(paramName);
    }
    // Parse if available
    Date result = null;
    if (dateStr != null) {
        result = new Date(Long.parseLong(dateStr));
    }
    return result;
}

15 View Complete Implementation : ResourceWebScriptPost.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
/**
 * If the request content-type is <i><b>multipart/form-data</b></i> then it
 * returns the {@link FormData}, otherwise it tries to extract the required
 * object from the JSON payload.
 */
private Object processRequest(ResourceMetadata resourceMeta, ResourceOperation operation, WebScriptRequest req) {
    if (WebScriptRequestImpl.MULTIPART_FORM_DATA.equals(req.getContentType())) {
        return (FormData) req.parseContent();
    }
    return extractObjFromJson(resourceMeta, operation, req);
}

15 View Complete Implementation : ActionConstraintsGet.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@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;
}

15 View Complete Implementation : TemplatesWebScript.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
/* (non-Javadoc)
     * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.WebScriptResponse)
     */
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status) {
    String path = "/";
    String templatePattern = "*.ftl";
    // process extension
    // optional
    String p = req.getExtensionPath();
    if ((p != null) && (p.length() > 0)) {
        int idx = p.lastIndexOf("/");
        if (idx != -1) {
            path = p.substring(0, idx);
            templatePattern = p.substring(idx + 1) + ".ftl";
        }
    }
    Set<String> templatePaths = new HashSet<String>();
    for (Store apiStore : searchPath.getStores()) {
        try {
            for (String templatePath : apiStore.getDoreplacedentPaths(path, false, templatePattern)) {
                templatePaths.add(templatePath);
            }
        } catch (IOException e) {
            throw new WebScriptException("Failed to search for templates from store " + apiStore, e);
        }
    }
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("paths", templatePaths);
    return model;
}

15 View Complete Implementation : AbstractArchivedNodeWebScript.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
protected StoreRef parseRequestForStoreRef(WebScriptRequest req) {
    // get the parameters that represent the StoreRef, we know they are present
    // otherwise this webscript would not have matched
    Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
    String storeType = templateVars.get("store_type");
    String storeId = templateVars.get("store_id");
    // create the StoreRef and ensure it is valid
    StoreRef storeRef = new StoreRef(storeType, storeId);
    return storeRef;
}

15 View Complete Implementation : WorkflowDefinitionGet.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@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;
}

15 View Complete Implementation : NodeLocatorGet.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
private Map<String, Serializable> mapParams(WebScriptRequest req) {
    Map<String, Serializable> params = new HashMap<String, Serializable>();
    for (String key : req.getParameterNames()) {
        String value = req.getParameter(key);
        if (value != null) {
            String decodedValue = URLDecoder.decode(value);
            // TODO Handle type conversions here.
            params.put(key, decodedValue);
        }
    }
    return params;
}

15 View Complete Implementation : TaskInstanceGet.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@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;
}

15 View Complete Implementation : RatingDelete.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
    Map<String, Object> model = new HashMap<String, Object>();
    NodeRef nodeRef = parseRequestForNodeRef(req);
    String ratingSchemeName = parseRequestForScheme(req);
    Rating deletedRating = ratingService.removeRatingByCurrentUser(nodeRef, ratingSchemeName);
    if (deletedRating == null) {
        // There was no rating in the specified scheme to delete.
        throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Unable to delete non-existent rating: " + ratingSchemeName + " from " + nodeRef.toString());
    }
    model.put(NODE_REF, nodeRef.toString());
    model.put(AVERAGE_RATING, ratingService.getAverageRating(nodeRef, ratingSchemeName));
    model.put(RATINGS_TOTAL, ratingService.getTotalRating(nodeRef, ratingSchemeName));
    model.put(RATINGS_COUNT, ratingService.getRatingsCount(nodeRef, ratingSchemeName));
    return model;
}

15 View Complete Implementation : ResourceWebScriptGet.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@Override
public Params extractParams(ResourceMetadata resourceMeta, WebScriptRequest req) {
    final String enreplacedyId = req.getServiceMatch().getTemplateVars().get(ResourceLocator.ENreplacedY_ID);
    final String relationshipId = req.getServiceMatch().getTemplateVars().get(ResourceLocator.RELATIONSHIP_ID);
    final RecognizedParams params = getRecognizedParams(req);
    switch(resourceMeta.getType()) {
        case ENreplacedY:
            if (StringUtils.isNotBlank(enreplacedyId)) {
                return Params.valueOf(params, enreplacedyId, null, req);
            } else {
                // collection resource
                return Params.valueOf(params, null, null, req);
            }
        case RELATIONSHIP:
            if (StringUtils.isNotBlank(relationshipId)) {
                return Params.valueOf(params, enreplacedyId, relationshipId, req);
            } else {
                // relationship collection resource
                return Params.valueOf(params, enreplacedyId, null, req);
            }
        case PROPERTY:
            final String resourceName = req.getServiceMatch().getTemplateVars().get(ResourceLocator.RELATIONSHIP_RESOURCE);
            final String propertyName = req.getServiceMatch().getTemplateVars().get(ResourceLocator.PROPERTY);
            if (StringUtils.isNotBlank(enreplacedyId) && StringUtils.isNotBlank(resourceName)) {
                if (StringUtils.isNotBlank(propertyName)) {
                    return Params.valueOf(enreplacedyId, relationshipId, null, null, propertyName, params, null, req);
                } else {
                    return Params.valueOf(enreplacedyId, null, null, null, resourceName, params, null, req);
                }
            }
        // Fall through to unsupported.
        default:
            throw new UnsupportedResourceOperationException("GET not supported for Actions");
    }
}

15 View Complete Implementation : AbstractCommentsWebScript.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
/**
 * returns SiteInfo needed for post activity
 * @param req
 * @return
 */
protected SiteInfo getSiteInfo(WebScriptRequest req, boolean searchForSiteInJSON) {
    String siteName = req.getParameter(JSON_KEY_SITE);
    if (siteName == null && searchForSiteInJSON) {
        JSONObject json = parseJSON(req);
        if (json != null) {
            if (json.containsKey(JSON_KEY_SITE)) {
                siteName = (String) json.get(JSON_KEY_SITE);
            } else if (json.containsKey(JSON_KEY_SITE_ID)) {
                siteName = (String) json.get(JSON_KEY_SITE_ID);
            }
        }
    }
    if (siteName != null) {
        SiteInfo site = siteService.getSite(siteName);
        return site;
    }
    return null;
}

15 View Complete Implementation : RulePost.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@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);
    Rule rule = null;
    JSONObject json = null;
    try {
        // read request json
        json = new JSONObject(new JSONTokener(req.getContent().getContent()));
        // parse request json
        rule = parseJsonRule(json);
        // check the rule
        checkRule(rule);
        // create rule
        ruleService.saveRule(nodeRef, rule);
        RuleRef ruleRef = new RuleRef(rule, fileFolderService.getFileInfo(ruleService.getOwningNodeRef(rule)));
        model.put("ruleRef", ruleRef);
    } catch (IOException iox) {
        throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not read content from req.", iox);
    } catch (JSONException je) {
        throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not parse JSON from req.", je);
    }
    return model;
}

15 View Complete Implementation : DiscoveryApiWebscript.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@Override
public void execute(WebScriptRequest webScriptRequest, WebScriptResponse webScriptResponse) throws IOException {
    try {
        checkEnabled();
        DiscoveryDetails discoveryDetails = new DiscoveryDetails(getRepositoryInfo());
        // Write response
        setResponse(webScriptResponse, DEFAULT_SUCCESS);
        renderJsonResponse(webScriptResponse, discoveryDetails, replacedistant.getJsonHelper());
    } catch (Exception exception) {
        renderException(exception, webScriptResponse, replacedistant);
    }
}

15 View Complete Implementation : QuickShareMetaDataGet.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@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 {
        return quickShareService.getMetaData(sharedId);
    } 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);
    }
}

14 View Complete Implementation : ResourceWebScriptPut.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
/**
 * Returns the input stream for the request
 * @param req WebScriptRequest
 * @return InputStream
 */
private InputStream getStream(WebScriptRequest req) {
    try {
        if (req instanceof WebScriptServletRequest) {
            WebScriptServletRequest servletRequest = (WebScriptServletRequest) req;
            return servletRequest.getHttpServletRequest().getInputStream();
        } else if (req instanceof WrappingWebScriptRequest) {
            // eg. BufferredRequest
            WrappingWebScriptRequest wrappedRequest = (WrappingWebScriptRequest) req;
            return wrappedRequest.getContent().getInputStream();
        }
    } catch (IOException error) {
        logger.warn("Failed to get the input stream.", error);
    }
    return null;
}

14 View Complete Implementation : DownloadStatusGet.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
    Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
    if (templateVars == null) {
        String error = "No parameters supplied";
        throw new WebScriptException(Status.STATUS_BAD_REQUEST, error);
    }
    if (!(templateVars.containsKey("store_type") && templateVars.containsKey("store_id") && templateVars.containsKey("node_id"))) {
        String error = "Missing template variables (store_type, store_id or node_id).";
        throw new WebScriptException(Status.STATUS_BAD_REQUEST, error);
    }
    StoreRef store = new StoreRef(templateVars.get("store_type"), templateVars.get("store_id"));
    NodeRef nodeRef = new NodeRef(store, templateVars.get("node_id"));
    if (!nodeService.exists(nodeRef)) {
        String error = "Could not find node: " + nodeRef;
        throw new WebScriptException(Status.STATUS_NOT_FOUND, error);
    }
    DownloadStatus downloadStatus = downloadService.getDownloadStatus(nodeRef);
    Map<String, Object> result = new HashMap<String, Object>();
    result.put("downloadStatus", downloadStatus);
    return result;
}

14 View Complete Implementation : ShareContentPost.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@Override
protected Map<String, Object> executeImpl(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 NodeRef nodeRef = WebScriptUtil.getNodeRef(params);
    if (nodeRef == null) {
        String msg = "A valid NodeRef must be specified!";
        throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, msg);
    }
    try {
        QuickShareDTO dto = quickShareService.shareContent(nodeRef);
        Map<String, Object> model = new HashMap<String, Object>(1);
        model.put("sharedDTO", dto);
        return model;
    } catch (InvalidNodeRefException inre) {
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find node: " + nodeRef);
    }
}

14 View Complete Implementation : DownloadDelete.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
    Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
    if (templateVars == null) {
        String error = "No parameters supplied";
        throw new WebScriptException(Status.STATUS_BAD_REQUEST, error);
    }
    if (!(templateVars.containsKey("store_type") && templateVars.containsKey("store_id") && templateVars.containsKey("node_id"))) {
        String error = "Missing template variables (store_type, store_id or node_id).";
        throw new WebScriptException(Status.STATUS_BAD_REQUEST, error);
    }
    StoreRef store = new StoreRef(templateVars.get("store_type"), templateVars.get("store_id"));
    NodeRef nodeRef = new NodeRef(store, templateVars.get("node_id"));
    if (!nodeService.exists(nodeRef)) {
        String error = "Could not find node: " + nodeRef;
        throw new WebScriptException(Status.STATUS_NOT_FOUND, error);
    }
    downloadService.cancelDownload(nodeRef);
    status.setCode(HttpServletResponse.SC_OK);
    return new HashMap<String, Object>();
}

14 View Complete Implementation : BlogGet.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
@Override
protected Map<String, Object> executeImpl(SiteInfo site, NodeRef containerNodeRef, BlogPostInfo blog, WebScriptRequest req, JSONObject json, Status status, Cache cache) {
    if (blog != null) {
    // They appear to have supplied a blog post itself...
    // Oh well, let's hope for the best!
    }
    if (containerNodeRef == null && site != null) {
        // They want to know about a blog container on a
        // site where nothing has lazy-created the container
        // Give them info on the site for now, should be close enough!
        containerNodeRef = site.getNodeRef();
    }
    if (containerNodeRef == null) {
        // Looks like they've asked for something that isn't there
        throw new WebScriptException(Status.STATUS_NOT_FOUND, "Blog Not Found");
    }
    // Build the response
    // (For now, we just supply the noderef, but when we have a
    // proper blog details object we'll use that)
    Map<String, Object> model = new HashMap<String, Object>();
    model.put(ITEM, containerNodeRef);
    return model;
}