use of com.zimbra.soap.mail.message.CreateSearchFolderRequest in project zm-mailbox by Zimbra.
the class ZMailbox method createSearchFolder.
/**
* create a new sub folder of the specified parent folder.
*
* @param parentId parent folder id
* @param name name of new folder
* @param query search query (required)
* @param types comma-sep list of types to search for. Use null for default value.
* @param sortBy how to sort the result. Use null for default value.
* @see {@link ZSearchParams#TYPE_MESSAGE}
* @return newly created search folder
* @throws ServiceException on error
* @param color color of folder
*/
public ZSearchFolder createSearchFolder(String parentId, String name, String query, String types, SearchSortBy sortBy, ZFolder.Color color) throws ServiceException {
NewSearchFolderSpec spec = NewSearchFolderSpec.forNameQueryAndFolder(name, query, parentId);
if (color != null) {
if (StringUtil.equal(color.getName(), Color.RGBCOLOR)) {
spec.setRgb(color.getRgbColorValue());
} else {
spec.setColor((byte) color.getValue());
}
}
spec.setSearchTypes(types);
if (sortBy != null) {
spec.setSortBy(sortBy.name());
}
CreateSearchFolderResponse resp = this.invokeJaxb(new CreateSearchFolderRequest(spec));
ZSearchFolder newSearch = getSearchFolderById(resp.getSearchFolder().getId());
return newSearch != null ? newSearch : new ZSearchFolder(resp.getSearchFolder(), null, this);
}
use of com.zimbra.soap.mail.message.CreateSearchFolderRequest in project zm-mailbox by Zimbra.
the class CreateSearchFolder method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Mailbox mbox = getRequestedMailbox(zsc);
OperationContext octxt = getOperationContext(zsc, context);
ItemIdFormatter ifmt = new ItemIdFormatter(zsc);
CreateSearchFolderRequest req = zsc.elementToJaxb(request);
NewSearchFolderSpec spec = req.getSearchFolder();
Byte color = spec.getColor() != null ? spec.getColor() : MailItem.DEFAULT_COLOR;
Color itemColor = spec.getRgb() != null ? new Color(spec.getRgb()) : new Color(color);
ItemId iidParent = new ItemId(spec.getParentFolderId(), zsc);
SearchFolder search = mbox.createSearchFolder(octxt, iidParent.getId(), spec.getName(), spec.getQuery(), spec.getSearchTypes(), spec.getSortBy(), Flag.toBitmask(spec.getFlags()), itemColor);
Element response = zsc.createElement(MailConstants.CREATE_SEARCH_FOLDER_RESPONSE);
if (search != null)
ToXML.encodeSearchFolder(response, ifmt, search);
return response;
}
Aggregations