use of com.zimbra.cs.service.formatter.FormatterFactory.FormatType in project zm-mailbox by Zimbra.
the class UserServlet method doAuthGet.
private void doAuthGet(HttpServletRequest req, HttpServletResponse resp, UserServletContext context) throws ServletException, IOException, ServiceException, UserServletException {
if (log.isDebugEnabled()) {
StringBuffer reqURL = context.req.getRequestURL();
String queryParam = context.req.getQueryString();
if (queryParam != null)
reqURL.append('?').append(queryParam);
log.debug("UserServlet: " + reqURL.toString());
}
context.opContext = new OperationContext(context.getAuthAccount(), isAdminRequest(req));
Mailbox mbox = UserServletUtil.getTargetMailbox(context);
if (mbox != null) {
ZimbraLog.addMboxToContext(mbox.getId());
if (context.reqListIds != null) {
resolveItems(context);
} else {
MailItem item = resolveItem(context);
if (proxyIfMountpoint(req, resp, context, item)) {
// if the target is a mountpoint, the request was already proxied to the resolved target
return;
}
}
}
if (FormatType.FREE_BUSY.equals(context.format)) {
/* Always reference Calendar. This is the fallback for non-existent paths, thus, could harvest
* emails by asking for freebusy against, say the Drafts folder. Without this change, the returned
* HTML would reference Drafts for valid emails and Calendar for invalid ones.
*/
context.fakeTarget = new UserServletContext.FakeFolder(context.accountPath, "/Calendar", "Calendar");
}
resolveFormatter(context);
// authentication, call the formatter and let it deal with preventing harvest attacks.
if (mbox == null && context.formatter.requiresAuth())
throw ServiceException.PERM_DENIED(L10nUtil.getMessage(MsgKey.errPermissionDenied, req));
String cacheControlValue = LC.rest_response_cache_control_value.value();
if (!StringUtil.isNullOrEmpty(cacheControlValue)) {
resp.addHeader("Cache-Control", cacheControlValue);
}
FormatType formatType = context.formatter.getType();
if (formatType != null) {
context.resp.setContentType(formatType.getContentType());
}
context.formatter.format(context);
}
Aggregations