use of org.alfresco.service.cmr.subscriptions.PrivateSubscriptionListException in project alfresco-remote-api by Alfresco.
the class AbstractSubscriptionServiceWebScript method execute.
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException {
if (!subscriptionService.isActive()) {
res.setStatus(404);
return;
}
try {
String userId = req.getServiceMatch().getTemplateVars().get("userid");
Object obj = executeImpl(userId, req, res);
if (obj instanceof JSONObject || obj instanceof JSONArray) {
res.setContentEncoding(Charset.defaultCharset().displayName());
res.setContentType(Format.JSON.mimetype() + ";charset=UTF-8");
Writer writer = res.getWriter();
if (obj instanceof JSONObject) {
((JSONObject) obj).writeJSONString(writer);
} else {
((JSONArray) obj).writeJSONString(writer);
}
writer.flush();
} else {
res.setStatus(204);
}
} catch (SubscriptionsDisabledException sde) {
throw new WebScriptException(404, "Subscription service is disabled!", sde);
} catch (NoSuchPersonException nspe) {
throw new WebScriptException(404, "Unknown user '" + nspe.getUserName() + "'!", nspe);
} catch (PrivateSubscriptionListException psle) {
throw new WebScriptException(403, "Subscription list is private!", psle);
} catch (ParseException pe) {
throw new WebScriptException(400, "Unable to parse JSON!", pe);
} catch (ClassCastException cce) {
throw new WebScriptException(400, "Unable to parse JSON!", cce);
} catch (IOException ioe) {
throw new WebScriptException(500, "Unable to serialize JSON!", ioe);
}
}
Aggregations