Search in sources :

Example 1 with MailboxCultureType

use of com.microsoft.schemas.exchange.services._2006.types.MailboxCultureType in project zm-mailbox by Zimbra.

the class ExchangeEWSFreeBusyProvider method bindFolder.

BaseFolderType bindFolder(DistinguishedFolderIdNameType distinguishedFolderId, DefaultShapeNamesType shapeType) {
    final DistinguishedFolderIdType distinguishedFolderIdType = new DistinguishedFolderIdType();
    distinguishedFolderIdType.setId(distinguishedFolderId);
    final NonEmptyArrayOfBaseFolderIdsType nonEmptyArrayOfBaseFolderIdsType = new NonEmptyArrayOfBaseFolderIdsType();
    nonEmptyArrayOfBaseFolderIdsType.getFolderIdOrDistinguishedFolderId().add(distinguishedFolderIdType);
    GetFolderType getFolderRequest = new GetFolderType();
    getFolderRequest.setFolderIds(nonEmptyArrayOfBaseFolderIdsType);
    FolderResponseShapeType stResp = new FolderResponseShapeType();
    stResp.setBaseShape(shapeType);
    getFolderRequest.setFolderShape(stResp);
    RequestServerVersion serverVersion = new RequestServerVersion();
    serverVersion.setVersion(ExchangeVersionType.EXCHANGE_2010_SP_1);
    Holder<ServerVersionInfo> gfversionInfo = new Holder<ServerVersionInfo>();
    Holder<GetFolderResponseType> gfresponseHolder = new Holder<GetFolderResponseType>();
    MailboxCultureType mct = new MailboxCultureType();
    mct.setValue("EN");
    TimeZoneDefinitionType tzdt = new TimeZoneDefinitionType();
    tzdt.setId("Greenwich Standard Time");
    TimeZoneContextType tzct = new TimeZoneContextType();
    tzct.setTimeZoneDefinition(tzdt);
    service.getFolder(getFolderRequest, mct, serverVersion, tzct, gfresponseHolder, gfversionInfo);
    FolderInfoResponseMessageType firmtResp = (FolderInfoResponseMessageType) gfresponseHolder.value.getResponseMessages().getCreateItemResponseMessageOrDeleteItemResponseMessageOrGetItemResponseMessage().get(0).getValue();
    if (firmtResp.getFolders().getFolderOrCalendarFolderOrContactsFolder().size() > 0) {
        return firmtResp.getFolders().getFolderOrCalendarFolderOrContactsFolder().get(0);
    } else {
        ZimbraLog.fb.error("Could not find the folder in Exchange : " + distinguishedFolderId.toString());
    }
    return null;
}
Also used : NonEmptyArrayOfBaseFolderIdsType(com.microsoft.schemas.exchange.services._2006.types.NonEmptyArrayOfBaseFolderIdsType) Holder(javax.xml.ws.Holder) TimeZoneContextType(com.microsoft.schemas.exchange.services._2006.types.TimeZoneContextType) FolderInfoResponseMessageType(com.microsoft.schemas.exchange.services._2006.messages.FolderInfoResponseMessageType) FolderResponseShapeType(com.microsoft.schemas.exchange.services._2006.types.FolderResponseShapeType) DistinguishedFolderIdType(com.microsoft.schemas.exchange.services._2006.types.DistinguishedFolderIdType) GetFolderResponseType(com.microsoft.schemas.exchange.services._2006.messages.GetFolderResponseType) RequestServerVersion(com.microsoft.schemas.exchange.services._2006.types.RequestServerVersion) TimeZoneDefinitionType(com.microsoft.schemas.exchange.services._2006.types.TimeZoneDefinitionType) ServerVersionInfo(com.microsoft.schemas.exchange.services._2006.types.ServerVersionInfo) GetFolderType(com.microsoft.schemas.exchange.services._2006.messages.GetFolderType) MailboxCultureType(com.microsoft.schemas.exchange.services._2006.types.MailboxCultureType)

Example 2 with MailboxCultureType

use of com.microsoft.schemas.exchange.services._2006.types.MailboxCultureType 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;
}
Also used : ContainsExpressionType(com.microsoft.schemas.exchange.services._2006.types.ContainsExpressionType) ConstantValueType(com.microsoft.schemas.exchange.services._2006.types.ConstantValueType) NonEmptyArrayOfBaseFolderIdsType(com.microsoft.schemas.exchange.services._2006.types.NonEmptyArrayOfBaseFolderIdsType) FindFolderType(com.microsoft.schemas.exchange.services._2006.messages.FindFolderType) QName(javax.xml.namespace.QName) Holder(javax.xml.ws.Holder) TimeZoneContextType(com.microsoft.schemas.exchange.services._2006.types.TimeZoneContextType) FieldURIOrConstantType(com.microsoft.schemas.exchange.services._2006.types.FieldURIOrConstantType) FolderResponseShapeType(com.microsoft.schemas.exchange.services._2006.types.FolderResponseShapeType) SearchExpressionType(com.microsoft.schemas.exchange.services._2006.types.SearchExpressionType) RestrictionType(com.microsoft.schemas.exchange.services._2006.types.RestrictionType) RequestServerVersion(com.microsoft.schemas.exchange.services._2006.types.RequestServerVersion) TimeZoneDefinitionType(com.microsoft.schemas.exchange.services._2006.types.TimeZoneDefinitionType) PathToUnindexedFieldType(com.microsoft.schemas.exchange.services._2006.types.PathToUnindexedFieldType) ServerVersionInfo(com.microsoft.schemas.exchange.services._2006.types.ServerVersionInfo) FindFolderResponseType(com.microsoft.schemas.exchange.services._2006.messages.FindFolderResponseType) MailboxCultureType(com.microsoft.schemas.exchange.services._2006.types.MailboxCultureType) FindFolderResponseMessageType(com.microsoft.schemas.exchange.services._2006.messages.FindFolderResponseMessageType)

Example 3 with MailboxCultureType

use of com.microsoft.schemas.exchange.services._2006.types.MailboxCultureType in project zm-mailbox by Zimbra.

the class ExchangeEWSFreeBusyProvider method handleMailboxChange.

@Override
public boolean handleMailboxChange(String accountId) {
    ZimbraLog.fb.debug("Entering handleMailboxChange() for account : " + accountId);
    String email = getEmailAddress(accountId);
    ServerInfo serverInfo = getServerInfo(email);
    if (email == null || !serverInfo.enabled) {
        ZimbraLog.fb.debug("Exiting handleMailboxChange() for account : " + accountId);
        // no retry
        return true;
    }
    FreeBusy fb;
    try {
        fb = getFreeBusy(accountId, FreeBusyQuery.CALENDAR_FOLDER_ALL);
    } catch (ServiceException se) {
        ZimbraLog.fb.warn("can't get freebusy for account " + accountId, se);
        ZimbraLog.fb.debug("Exiting handleMailboxChange() for account : " + accountId);
        // retry the request if it's receivers fault.
        return !se.isReceiversFault();
    }
    if (email == null || fb == null) {
        ZimbraLog.fb.warn("account not found / incorrect / wrong host: " + accountId);
        ZimbraLog.fb.debug("Exiting handleMailboxChange() for account : " + accountId);
        // no retry
        return true;
    }
    if (serverInfo == null || serverInfo.org == null || serverInfo.cn == null) {
        ZimbraLog.fb.warn("no exchange server info for user " + email);
        ZimbraLog.fb.debug("Exiting handleMailboxChange() for account : " + accountId);
        // no retry
        return true;
    }
    if (null == service) {
        try {
            if (!initService(serverInfo)) {
                ZimbraLog.fb.error("failed to initialize exchange service object " + serverInfo.url);
                ZimbraLog.fb.debug("Exiting handleMailboxChange() for account : " + accountId);
                return true;
            }
        } catch (MalformedURLException e) {
            ZimbraLog.fb.error("exception while trying to initialize exchange service object " + serverInfo.url);
            ZimbraLog.fb.debug("Exiting handleMailboxChange() for account : " + accountId);
            return true;
        }
    }
    ExchangeEWSMessage msg = new ExchangeEWSMessage(serverInfo.org, serverInfo.cn, email);
    try {
        FolderType publicFolderRoot = (FolderType) bindFolder(DistinguishedFolderIdNameType.PUBLICFOLDERSROOT, DefaultShapeNamesType.ALL_PROPERTIES);
        if (publicFolderRoot == null) {
            ZimbraLog.fb.error("Could not find the public root folder on exchange");
            return true;
        }
        List<BaseFolderType> resultsNonIpm = findFolderByProp(publicFolderRoot.getParentFolderId(), UnindexedFieldURIType.FOLDER_DISPLAY_NAME, "NON_IPM_SUBTREE");
        if (resultsNonIpm != null && resultsNonIpm.size() > 0) {
            FolderType folderNonIPM = (FolderType) resultsNonIpm.get(0);
            List<BaseFolderType> resultSchedulePlus = findFolderByProp(folderNonIPM.getFolderId(), UnindexedFieldURIType.FOLDER_DISPLAY_NAME, "SCHEDULE+ FREE BUSY");
            if (resultSchedulePlus != null && resultSchedulePlus.size() > 0) {
                FolderType folderSchedulePlus = (FolderType) resultSchedulePlus.get(0);
                List<BaseFolderType> resultFBFolder = findFolderByPartialProp(folderSchedulePlus.getFolderId(), UnindexedFieldURIType.FOLDER_DISPLAY_NAME, // TODO: check here for partial name
                serverInfo.org);
                // search
                if (resultFBFolder != null && resultFBFolder.size() > 0) {
                    FolderType folderFB = (FolderType) resultFBFolder.get(0);
                    List<ItemType> resultMessage = findItemByProp(folderFB.getFolderId(), UnindexedFieldURIType.ITEM_SUBJECT, "USER-/CN=RECIPIENTS/CN=" + getForeignPrincipal(accountId), DefaultShapeNamesType.ALL_PROPERTIES);
                    if (resultMessage != null && resultMessage.size() > 0) {
                        // edit message
                        ItemType itemMessage = resultMessage.get(0);
                        Map<PathToExtendedFieldType, NonEmptyArrayOfPropertyValuesType> props = msg.GetFreeBusyProperties(fb);
                        final NonEmptyArrayOfItemChangeDescriptionsType cdExPropArr = new NonEmptyArrayOfItemChangeDescriptionsType();
                        for (PathToExtendedFieldType pathExProp : props.keySet()) {
                            ItemType itemEmptyMessage = new ItemType();
                            SetItemFieldType sifItem = new SetItemFieldType();
                            sifItem.setPath(new JAXBElement<PathToExtendedFieldType>(new QName("http://schemas.microsoft.com/exchange/services/2006/types", "Path"), PathToExtendedFieldType.class, pathExProp));
                            ExtendedPropertyType exProp = new ExtendedPropertyType();
                            exProp.setExtendedFieldURI(pathExProp);
                            if (pathExProp.getPropertyType() == MapiPropertyTypeType.APPLICATION_TIME_ARRAY || pathExProp.getPropertyType() == MapiPropertyTypeType.BINARY_ARRAY || pathExProp.getPropertyType() == MapiPropertyTypeType.CLSID_ARRAY || pathExProp.getPropertyType() == MapiPropertyTypeType.CURRENCY_ARRAY || pathExProp.getPropertyType() == MapiPropertyTypeType.DOUBLE_ARRAY || pathExProp.getPropertyType() == MapiPropertyTypeType.FLOAT_ARRAY || pathExProp.getPropertyType() == MapiPropertyTypeType.INTEGER_ARRAY || pathExProp.getPropertyType() == MapiPropertyTypeType.LONG_ARRAY || pathExProp.getPropertyType() == MapiPropertyTypeType.OBJECT_ARRAY || pathExProp.getPropertyType() == MapiPropertyTypeType.SHORT_ARRAY || pathExProp.getPropertyType() == MapiPropertyTypeType.STRING_ARRAY || pathExProp.getPropertyType() == MapiPropertyTypeType.SYSTEM_TIME_ARRAY) {
                                exProp.setValues(props.get(pathExProp));
                            } else {
                                if (props.get(pathExProp).getValue().size() > 0) {
                                    exProp.setValue(props.get(pathExProp).getValue().get(0));
                                }
                            }
                            itemEmptyMessage.getExtendedProperty().add(exProp);
                            sifItem.setItem(itemEmptyMessage);
                            cdExPropArr.getAppendToItemFieldOrSetItemFieldOrDeleteItemField().add(sifItem);
                        }
                        UpdateItemType updateItemRequest = new UpdateItemType();
                        updateItemRequest.setMessageDisposition(MessageDispositionType.SAVE_ONLY);
                        updateItemRequest.setConflictResolution(ConflictResolutionType.ALWAYS_OVERWRITE);
                        RequestServerVersion serverVersion = new RequestServerVersion();
                        serverVersion.setVersion(ExchangeVersionType.EXCHANGE_2010_SP_1);
                        ItemChangeType itemExpropChange = new ItemChangeType();
                        itemExpropChange.setItemId(itemMessage.getItemId());
                        itemExpropChange.setUpdates(cdExPropArr);
                        final NonEmptyArrayOfItemChangesType ctExPropArr = new NonEmptyArrayOfItemChangesType();
                        ctExPropArr.getItemChange().add(itemExpropChange);
                        updateItemRequest.setItemChanges(ctExPropArr);
                        Holder<UpdateItemResponseType> updateItemResponse = new Holder<UpdateItemResponseType>();
                        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.updateItem(updateItemRequest, mct, serverVersion, tzct, updateItemResponse, gfversionInfo);
                        ResponseMessageType updateItemResponseMessage = updateItemResponse.value.getResponseMessages().getCreateItemResponseMessageOrDeleteItemResponseMessageOrGetItemResponseMessage().get(0).getValue();
                    } else {
                        // create message
                        PostItemType itemMessage = new PostItemType();
                        itemMessage.setSubject("USER-/CN=RECIPIENTS/CN=" + getForeignPrincipal(accountId));
                        itemMessage.setItemClass("IPM.Post");
                        Map<PathToExtendedFieldType, NonEmptyArrayOfPropertyValuesType> props = msg.GetFreeBusyProperties(fb);
                        for (PathToExtendedFieldType pathExProp : props.keySet()) {
                            ExtendedPropertyType exProp = new ExtendedPropertyType();
                            exProp.setExtendedFieldURI(pathExProp);
                            if (pathExProp.getPropertyType() == MapiPropertyTypeType.APPLICATION_TIME_ARRAY || pathExProp.getPropertyType() == MapiPropertyTypeType.BINARY_ARRAY || pathExProp.getPropertyType() == MapiPropertyTypeType.CLSID_ARRAY || pathExProp.getPropertyType() == MapiPropertyTypeType.CURRENCY_ARRAY || pathExProp.getPropertyType() == MapiPropertyTypeType.DOUBLE_ARRAY || pathExProp.getPropertyType() == MapiPropertyTypeType.FLOAT_ARRAY || pathExProp.getPropertyType() == MapiPropertyTypeType.INTEGER_ARRAY || pathExProp.getPropertyType() == MapiPropertyTypeType.LONG_ARRAY || pathExProp.getPropertyType() == MapiPropertyTypeType.OBJECT_ARRAY || pathExProp.getPropertyType() == MapiPropertyTypeType.SHORT_ARRAY || pathExProp.getPropertyType() == MapiPropertyTypeType.STRING_ARRAY || pathExProp.getPropertyType() == MapiPropertyTypeType.SYSTEM_TIME_ARRAY) {
                                exProp.setValues(props.get(pathExProp));
                            } else {
                                if (props.get(pathExProp).getValue().size() > 0) {
                                    exProp.setValue(props.get(pathExProp).getValue().get(0));
                                }
                            }
                            itemMessage.getExtendedProperty().add(exProp);
                        }
                        CreateItemType createItemRequest = new CreateItemType();
                        RequestServerVersion serverVersion = new RequestServerVersion();
                        serverVersion.setVersion(ExchangeVersionType.EXCHANGE_2010_SP_1);
                        createItemRequest.setMessageDisposition(MessageDispositionType.SAVE_ONLY);
                        TargetFolderIdType idTargetFolder = new TargetFolderIdType();
                        idTargetFolder.setFolderId(folderFB.getFolderId());
                        createItemRequest.setSavedItemFolderId(idTargetFolder);
                        NonEmptyArrayOfAllItemsType createItems = new NonEmptyArrayOfAllItemsType();
                        createItems.getItemOrMessageOrCalendarItem().add(itemMessage);
                        createItemRequest.setItems(createItems);
                        Holder<CreateItemResponseType> createItemResponse = new Holder<CreateItemResponseType>();
                        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.createItem(createItemRequest, mct, serverVersion, tzct, createItemResponse, gfversionInfo);
                        ResponseMessageType createItemResponseMessage = createItemResponse.value.getResponseMessages().getCreateItemResponseMessageOrDeleteItemResponseMessageOrGetItemResponseMessage().get(0).getValue();
                    }
                } else {
                    ZimbraLog.fb.error("Could not find the Exchange folder containing '" + serverInfo.org + "'. Make sure zimbraFreebusyExchangeUserOrg is configured correctly and it exists on Exchange");
                }
            } else {
                ZimbraLog.fb.error("Could not find the Exchange folder 'SCHEDULE+ FREE BUSY'");
            }
        } else {
            ZimbraLog.fb.error("Could not find the Exchange folder 'NON_IPM_SUBTREE'");
        }
        return true;
    } catch (Exception e) {
        ZimbraLog.fb.error("error communicating with " + serverInfo.url, e);
    } finally {
        ZimbraLog.fb.debug("Exiting handleMailboxChange() for account : " + accountId);
    }
    // retry
    return false;
}
Also used : MalformedURLException(java.net.MalformedURLException) FolderInfoResponseMessageType(com.microsoft.schemas.exchange.services._2006.messages.FolderInfoResponseMessageType) ResponseMessageType(com.microsoft.schemas.exchange.services._2006.messages.ResponseMessageType) FindFolderResponseMessageType(com.microsoft.schemas.exchange.services._2006.messages.FindFolderResponseMessageType) FindItemResponseMessageType(com.microsoft.schemas.exchange.services._2006.messages.FindItemResponseMessageType) ServerInfo(com.zimbra.cs.fb.ExchangeFreeBusyProvider.ServerInfo) FindItemType(com.microsoft.schemas.exchange.services._2006.messages.FindItemType) UpdateItemType(com.microsoft.schemas.exchange.services._2006.messages.UpdateItemType) CreateItemType(com.microsoft.schemas.exchange.services._2006.messages.CreateItemType) ItemType(com.microsoft.schemas.exchange.services._2006.types.ItemType) PostItemType(com.microsoft.schemas.exchange.services._2006.types.PostItemType) TimeZoneContextType(com.microsoft.schemas.exchange.services._2006.types.TimeZoneContextType) BaseFolderType(com.microsoft.schemas.exchange.services._2006.types.BaseFolderType) UpdateItemResponseType(com.microsoft.schemas.exchange.services._2006.messages.UpdateItemResponseType) SetItemFieldType(com.microsoft.schemas.exchange.services._2006.types.SetItemFieldType) CreateItemResponseType(com.microsoft.schemas.exchange.services._2006.messages.CreateItemResponseType) ItemChangeType(com.microsoft.schemas.exchange.services._2006.types.ItemChangeType) RequestServerVersion(com.microsoft.schemas.exchange.services._2006.types.RequestServerVersion) TimeZoneDefinitionType(com.microsoft.schemas.exchange.services._2006.types.TimeZoneDefinitionType) ServerVersionInfo(com.microsoft.schemas.exchange.services._2006.types.ServerVersionInfo) ExtendedPropertyType(com.microsoft.schemas.exchange.services._2006.types.ExtendedPropertyType) CreateItemType(com.microsoft.schemas.exchange.services._2006.messages.CreateItemType) GetFolderType(com.microsoft.schemas.exchange.services._2006.messages.GetFolderType) FindFolderType(com.microsoft.schemas.exchange.services._2006.messages.FindFolderType) FolderType(com.microsoft.schemas.exchange.services._2006.types.FolderType) BaseFolderType(com.microsoft.schemas.exchange.services._2006.types.BaseFolderType) NonEmptyArrayOfAllItemsType(com.microsoft.schemas.exchange.services._2006.types.NonEmptyArrayOfAllItemsType) UpdateItemType(com.microsoft.schemas.exchange.services._2006.messages.UpdateItemType) QName(javax.xml.namespace.QName) Holder(javax.xml.ws.Holder) PathToExtendedFieldType(com.microsoft.schemas.exchange.services._2006.types.PathToExtendedFieldType) NonEmptyArrayOfPropertyValuesType(com.microsoft.schemas.exchange.services._2006.types.NonEmptyArrayOfPropertyValuesType) DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) ServiceException(com.zimbra.common.service.ServiceException) IOException(java.io.IOException) MalformedURLException(java.net.MalformedURLException) CertificateException(java.security.cert.CertificateException) NonEmptyArrayOfItemChangesType(com.microsoft.schemas.exchange.services._2006.types.NonEmptyArrayOfItemChangesType) ServiceException(com.zimbra.common.service.ServiceException) TargetFolderIdType(com.microsoft.schemas.exchange.services._2006.types.TargetFolderIdType) NonEmptyArrayOfItemChangeDescriptionsType(com.microsoft.schemas.exchange.services._2006.types.NonEmptyArrayOfItemChangeDescriptionsType) PostItemType(com.microsoft.schemas.exchange.services._2006.types.PostItemType) MailboxCultureType(com.microsoft.schemas.exchange.services._2006.types.MailboxCultureType)

Example 4 with MailboxCultureType

use of com.microsoft.schemas.exchange.services._2006.types.MailboxCultureType in project zm-mailbox by Zimbra.

the class ExchangeEWSFreeBusyProvider method findFolderByProp.

List<BaseFolderType> findFolderByProp(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();
    IsEqualToType ieq = new IsEqualToType();
    PathToUnindexedFieldType pix = new PathToUnindexedFieldType();
    pix.setFieldURI(prop);
    ieq.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);
    ieq.setFieldURIOrConstant(ct);
    rtRestriction.setSearchExpression(new JAXBElement<SearchExpressionType>(new QName("http://schemas.microsoft.com/exchange/services/2006/types", "IsEqualTo"), SearchExpressionType.class, ieq));
    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("findFolderByProp " + ffRespMessage.getResponseCode());
    return null;
}
Also used : ConstantValueType(com.microsoft.schemas.exchange.services._2006.types.ConstantValueType) NonEmptyArrayOfBaseFolderIdsType(com.microsoft.schemas.exchange.services._2006.types.NonEmptyArrayOfBaseFolderIdsType) FindFolderType(com.microsoft.schemas.exchange.services._2006.messages.FindFolderType) QName(javax.xml.namespace.QName) Holder(javax.xml.ws.Holder) TimeZoneContextType(com.microsoft.schemas.exchange.services._2006.types.TimeZoneContextType) FieldURIOrConstantType(com.microsoft.schemas.exchange.services._2006.types.FieldURIOrConstantType) FolderResponseShapeType(com.microsoft.schemas.exchange.services._2006.types.FolderResponseShapeType) SearchExpressionType(com.microsoft.schemas.exchange.services._2006.types.SearchExpressionType) RestrictionType(com.microsoft.schemas.exchange.services._2006.types.RestrictionType) RequestServerVersion(com.microsoft.schemas.exchange.services._2006.types.RequestServerVersion) IsEqualToType(com.microsoft.schemas.exchange.services._2006.types.IsEqualToType) TimeZoneDefinitionType(com.microsoft.schemas.exchange.services._2006.types.TimeZoneDefinitionType) PathToUnindexedFieldType(com.microsoft.schemas.exchange.services._2006.types.PathToUnindexedFieldType) ServerVersionInfo(com.microsoft.schemas.exchange.services._2006.types.ServerVersionInfo) FindFolderResponseType(com.microsoft.schemas.exchange.services._2006.messages.FindFolderResponseType) MailboxCultureType(com.microsoft.schemas.exchange.services._2006.types.MailboxCultureType) FindFolderResponseMessageType(com.microsoft.schemas.exchange.services._2006.messages.FindFolderResponseMessageType)

Example 5 with MailboxCultureType

use of com.microsoft.schemas.exchange.services._2006.types.MailboxCultureType in project zm-mailbox by Zimbra.

the class ExchangeEWSFreeBusyProvider method findItemByProp.

List<ItemType> findItemByProp(FolderIdType id, UnindexedFieldURIType prop, String val, DefaultShapeNamesType shapeType) {
    FindItemType findItemRequest = new FindItemType();
    RestrictionType rtRestriction = new RestrictionType();
    IsEqualToType ieq = new IsEqualToType();
    PathToUnindexedFieldType pix = new PathToUnindexedFieldType();
    pix.setFieldURI(prop);
    ieq.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);
    ieq.setFieldURIOrConstant(ct);
    rtRestriction.setSearchExpression(new JAXBElement<SearchExpressionType>(new QName("http://schemas.microsoft.com/exchange/services/2006/types", "IsEqualTo"), SearchExpressionType.class, ieq));
    findItemRequest.setRestriction(rtRestriction);
    ItemResponseShapeType stShape = new ItemResponseShapeType();
    stShape.setBaseShape(shapeType);
    findItemRequest.setItemShape(stShape);
    NonEmptyArrayOfBaseFolderIdsType ids = new NonEmptyArrayOfBaseFolderIdsType();
    ids.getFolderIdOrDistinguishedFolderId().add(id);
    findItemRequest.setParentFolderIds(ids);
    findItemRequest.setTraversal(ItemQueryTraversalType.SHALLOW);
    RequestServerVersion serverVersion = new RequestServerVersion();
    serverVersion.setVersion(ExchangeVersionType.EXCHANGE_2010_SP_1);
    Holder<FindItemResponseType> fiResponse = new Holder<FindItemResponseType>();
    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.findItem(findItemRequest, mct, serverVersion, tzct, fiResponse, gfversionInfo);
    FindItemResponseMessageType fiRespMessage = (FindItemResponseMessageType) fiResponse.value.getResponseMessages().getCreateItemResponseMessageOrDeleteItemResponseMessageOrGetItemResponseMessage().get(0).getValue();
    if (ResponseClassType.SUCCESS == fiRespMessage.getResponseClass()) {
        return fiRespMessage.getRootFolder().getItems().getItemOrMessageOrCalendarItem();
    }
    ZimbraLog.fb.warn("findItemByProp " + fiRespMessage.getResponseCode());
    return null;
}
Also used : ConstantValueType(com.microsoft.schemas.exchange.services._2006.types.ConstantValueType) NonEmptyArrayOfBaseFolderIdsType(com.microsoft.schemas.exchange.services._2006.types.NonEmptyArrayOfBaseFolderIdsType) QName(javax.xml.namespace.QName) Holder(javax.xml.ws.Holder) TimeZoneContextType(com.microsoft.schemas.exchange.services._2006.types.TimeZoneContextType) ItemResponseShapeType(com.microsoft.schemas.exchange.services._2006.types.ItemResponseShapeType) FindItemResponseType(com.microsoft.schemas.exchange.services._2006.messages.FindItemResponseType) FieldURIOrConstantType(com.microsoft.schemas.exchange.services._2006.types.FieldURIOrConstantType) SearchExpressionType(com.microsoft.schemas.exchange.services._2006.types.SearchExpressionType) RestrictionType(com.microsoft.schemas.exchange.services._2006.types.RestrictionType) RequestServerVersion(com.microsoft.schemas.exchange.services._2006.types.RequestServerVersion) IsEqualToType(com.microsoft.schemas.exchange.services._2006.types.IsEqualToType) FindItemType(com.microsoft.schemas.exchange.services._2006.messages.FindItemType) TimeZoneDefinitionType(com.microsoft.schemas.exchange.services._2006.types.TimeZoneDefinitionType) PathToUnindexedFieldType(com.microsoft.schemas.exchange.services._2006.types.PathToUnindexedFieldType) ServerVersionInfo(com.microsoft.schemas.exchange.services._2006.types.ServerVersionInfo) MailboxCultureType(com.microsoft.schemas.exchange.services._2006.types.MailboxCultureType) FindItemResponseMessageType(com.microsoft.schemas.exchange.services._2006.messages.FindItemResponseMessageType)

Aggregations

MailboxCultureType (com.microsoft.schemas.exchange.services._2006.types.MailboxCultureType)5 RequestServerVersion (com.microsoft.schemas.exchange.services._2006.types.RequestServerVersion)5 ServerVersionInfo (com.microsoft.schemas.exchange.services._2006.types.ServerVersionInfo)5 TimeZoneContextType (com.microsoft.schemas.exchange.services._2006.types.TimeZoneContextType)5 TimeZoneDefinitionType (com.microsoft.schemas.exchange.services._2006.types.TimeZoneDefinitionType)5 Holder (javax.xml.ws.Holder)5 NonEmptyArrayOfBaseFolderIdsType (com.microsoft.schemas.exchange.services._2006.types.NonEmptyArrayOfBaseFolderIdsType)4 QName (javax.xml.namespace.QName)4 FindFolderResponseMessageType (com.microsoft.schemas.exchange.services._2006.messages.FindFolderResponseMessageType)3 FindFolderType (com.microsoft.schemas.exchange.services._2006.messages.FindFolderType)3 ConstantValueType (com.microsoft.schemas.exchange.services._2006.types.ConstantValueType)3 FieldURIOrConstantType (com.microsoft.schemas.exchange.services._2006.types.FieldURIOrConstantType)3 FolderResponseShapeType (com.microsoft.schemas.exchange.services._2006.types.FolderResponseShapeType)3 PathToUnindexedFieldType (com.microsoft.schemas.exchange.services._2006.types.PathToUnindexedFieldType)3 RestrictionType (com.microsoft.schemas.exchange.services._2006.types.RestrictionType)3 SearchExpressionType (com.microsoft.schemas.exchange.services._2006.types.SearchExpressionType)3 FindFolderResponseType (com.microsoft.schemas.exchange.services._2006.messages.FindFolderResponseType)2 FindItemResponseMessageType (com.microsoft.schemas.exchange.services._2006.messages.FindItemResponseMessageType)2 FindItemType (com.microsoft.schemas.exchange.services._2006.messages.FindItemType)2 FolderInfoResponseMessageType (com.microsoft.schemas.exchange.services._2006.messages.FolderInfoResponseMessageType)2