use of com.microsoft.schemas.exchange.services._2006.types.ContainsExpressionType in project zm-mailbox by Zimbra.
the class ExchangeEWSFreeBusyProvider method findFolderByPartialProp.
List<BaseFolderType> findFolderByPartialProp(FolderIdType id, UnindexedFieldURIType prop, String val) {
FindFolderType findFolderRequest = new FindFolderType();
findFolderRequest.setTraversal(FolderQueryTraversalType.SHALLOW);
final NonEmptyArrayOfBaseFolderIdsType ffEmptyArrayOfBaseFolderIdsType = new NonEmptyArrayOfBaseFolderIdsType();
ffEmptyArrayOfBaseFolderIdsType.getFolderIdOrDistinguishedFolderId().add(id);
FolderResponseShapeType stResp = new FolderResponseShapeType();
stResp.setBaseShape(DefaultShapeNamesType.ID_ONLY);
findFolderRequest.setParentFolderIds(ffEmptyArrayOfBaseFolderIdsType);
findFolderRequest.setFolderShape(stResp);
RestrictionType rtRestriction = new RestrictionType();
ContainsExpressionType contains = new ContainsExpressionType();
PathToUnindexedFieldType pix = new PathToUnindexedFieldType();
pix.setFieldURI(prop);
contains.setPath(new JAXBElement<PathToUnindexedFieldType>(new QName("http://schemas.microsoft.com/exchange/services/2006/types", "FieldURI"), PathToUnindexedFieldType.class, pix));
FieldURIOrConstantType ct = new FieldURIOrConstantType();
ConstantValueType cv = new ConstantValueType();
cv.setValue(val);
ct.setConstant(cv);
contains.setConstant(cv);
contains.setContainmentMode(ContainmentModeType.SUBSTRING);
rtRestriction.setSearchExpression(new JAXBElement<SearchExpressionType>(new QName("http://schemas.microsoft.com/exchange/services/2006/types", "Contains"), SearchExpressionType.class, contains));
findFolderRequest.setRestriction(rtRestriction);
Holder<FindFolderResponseType> findFolderResponse = new Holder<FindFolderResponseType>();
RequestServerVersion serverVersion = new RequestServerVersion();
serverVersion.setVersion(ExchangeVersionType.EXCHANGE_2010_SP_1);
Holder<ServerVersionInfo> gfversionInfo = new Holder<ServerVersionInfo>();
MailboxCultureType mct = new MailboxCultureType();
mct.setValue("EN");
TimeZoneDefinitionType tzdt = new TimeZoneDefinitionType();
tzdt.setId("Greenwich Standard Time");
TimeZoneContextType tzct = new TimeZoneContextType();
tzct.setTimeZoneDefinition(tzdt);
service.findFolder(findFolderRequest, mct, serverVersion, tzct, findFolderResponse, gfversionInfo);
FindFolderResponseMessageType ffRespMessage = (FindFolderResponseMessageType) findFolderResponse.value.getResponseMessages().getCreateItemResponseMessageOrDeleteItemResponseMessageOrGetItemResponseMessage().get(0).getValue();
if (ResponseClassType.SUCCESS == ffRespMessage.getResponseClass()) {
return ffRespMessage.getRootFolder().getFolders().getFolderOrCalendarFolderOrContactsFolder();
}
ZimbraLog.fb.warn("findFolderByPartialProp " + ffRespMessage.getResponseCode());
return null;
}
Aggregations