use of com.zimbra.cs.mailbox.MailItem 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);
}
use of com.zimbra.cs.mailbox.MailItem in project zm-mailbox by Zimbra.
the class ZimbraQueryResultsImpl method getZimbraHit.
/**
* We've got a {@link Mailbox}, a {@link DbSearch.Result} and (optionally) a Lucene Doc...
* that's everything we need to build a real ZimbraHit.
*
* @param doc - Optional, only set if this search had a Lucene part
*/
ZimbraHit getZimbraHit(Mailbox mbox, DbSearch.Result sr, Document doc, DbSearch.FetchMode fetch) {
MailItem item = null;
ImapMessage i4msg = null;
int modseq = -1, parentId = 0;
switch(fetch) {
case MAIL_ITEM:
item = sr.getItem();
break;
case IMAP_MSG:
i4msg = sr.getImapMessage();
break;
case MODSEQ:
modseq = sr.getModSeq();
break;
case PARENT:
parentId = sr.getParentId();
break;
}
ZimbraHit result = null;
switch(sr.getType()) {
case CHAT:
case MESSAGE:
if (doc != null) {
result = getMessagePartHit(mbox, sr.getId(), (Message) item, doc, sr.getSortValue());
} else {
result = getMessageHit(mbox, sr.getId(), (Message) item, null, sr.getSortValue());
}
break;
case CONTACT:
result = getContactHit(mbox, sr.getId(), (Contact) item, sr.getSortValue());
break;
case NOTE:
result = getNoteHit(mbox, sr.getId(), (Note) item, sr.getSortValue());
break;
case APPOINTMENT:
result = getAppointmentHit(mbox, sr.getId(), (CalendarItem) item, sr.getSortValue());
break;
case TASK:
result = getTaskHit(mbox, sr.getId(), (Task) item, sr.getSortValue());
break;
case DOCUMENT:
case WIKI:
result = getDocumentHit(mbox, sr.getId(), (com.zimbra.cs.mailbox.Document) item, doc, sr.getSortValue());
break;
default:
assert (false);
}
if (i4msg != null) {
result.cacheImapMessage(i4msg);
}
if (modseq > 0) {
result.cacheModifiedSequence(modseq);
}
if (parentId != 0) {
result.cacheParentId(parentId);
}
return result;
}
use of com.zimbra.cs.mailbox.MailItem in project zm-mailbox by Zimbra.
the class ZimbraHit method getModifiedSequence.
public int getModifiedSequence() throws ServiceException {
if (cachedModseq < 0) {
MailItem item = getMailItem();
cachedModseq = item != null ? item.getModifiedSequence() : 0;
}
return cachedModseq;
}
use of com.zimbra.cs.mailbox.MailItem in project zm-mailbox by Zimbra.
the class ZimbraHit method getImapMessage.
public ImapMessage getImapMessage() throws ServiceException {
if (cachedImapMessage == null) {
MailItem item = getMailItem();
if (item == null) {
return null;
}
cachedImapMessage = new ImapMessage(item);
}
return cachedImapMessage;
}
use of com.zimbra.cs.mailbox.MailItem in project zm-mailbox by Zimbra.
the class MailDocumentHandler method getProxyTarget.
protected static ItemId getProxyTarget(ZimbraSoapContext zsc, OperationContext octxt, ItemId iid, boolean checkMountpoint) throws ServiceException {
if (zsc == null || iid == null) {
return null;
}
Account acct = getRequestedAccount(zsc);
if (!iid.belongsTo(acct)) {
return iid;
}
if (!checkMountpoint || !Provisioning.onLocalServer(acct)) {
return null;
}
Mailbox mbox = getRequestedMailbox(zsc);
MailItem item = mbox.getItemById(octxt, iid.getId(), MailItem.Type.UNKNOWN);
if (!(item instanceof Mountpoint)) {
return null;
}
return ((Mountpoint) item).getTarget();
}
Aggregations