Search in sources :

Example 1 with DefaultOutlookMapping

use of de.janrufmonitor.repository.mapping.DefaultOutlookMapping in project janrufmonitor by tbrandt77.

the class OutlookContactProxy method getCallerListFromSingleContact.

private ICallerList getCallerListFromSingleContact(Dispatch contact) throws ComFailException {
    ICallerList callers = getRuntime().getCallerFactory().createCallerList();
    try {
        Properties config = this.getRuntime().getConfigManagerFactory().getConfigManager().getProperties(NAMESPACE);
        if (config.getProperty("split", "true").equalsIgnoreCase("true")) {
            ICaller privateCaller = createPrivateCaller(contact);
            ICaller businessCaller = createBusinessCaller(contact);
            if (privateCaller == null && businessCaller != null) {
                callers.add(businessCaller);
            }
            if (privateCaller != null && businessCaller == null) {
                callers.add(privateCaller);
            }
            if (privateCaller != null && businessCaller != null) {
                if (((IMultiPhoneCaller) businessCaller).getPhonenumbers().size() == 1) {
                    // only one entry available
                    IPhonenumber pn = (IPhonenumber) ((IMultiPhoneCaller) businessCaller).getPhonenumbers().get(0);
                    IAttribute numbertype = businessCaller.getAttribute(IOutlookNumberMapping.MAPPING_ATTTRIBUTE_ID + pn.getTelephoneNumber());
                    if (numbertype != null && numbertype.getValue().equalsIgnoreCase(OutlookContactConst.MobileTelephoneNumber)) {
                        this.m_logger.info("Bussiness caller will be dropped. Only mobile number available, but still in private contact: " + businessCaller);
                        businessCaller = null;
                    }
                }
                if (((IMultiPhoneCaller) privateCaller).getPhonenumbers().size() == 1 && businessCaller != null) {
                    // only one entry available
                    IPhonenumber pn = (IPhonenumber) ((IMultiPhoneCaller) privateCaller).getPhonenumbers().get(0);
                    IAttribute numbertype = privateCaller.getAttribute(IOutlookNumberMapping.MAPPING_ATTTRIBUTE_ID + pn.getTelephoneNumber());
                    if (numbertype != null && numbertype.getValue().equalsIgnoreCase(OutlookContactConst.MobileTelephoneNumber)) {
                        this.m_logger.info("Private caller will be dropped. Only mobile number available, but still in business contact: " + privateCaller);
                        privateCaller = null;
                    }
                }
                if (privateCaller != null) {
                    callers.add(privateCaller);
                }
                if (businessCaller != null) {
                    callers.add(businessCaller);
                }
            }
        } else {
            ICaller c = OutlookMappingManager.getInstance().mapToJamCaller(contact, new DefaultOutlookMapping());
            if (c != null)
                callers.add(c);
        }
        updateProxyDatabase(callers);
    } catch (ComFailException ex) {
        this.m_logger.warning("1 item (e.g. distribution list) was ignored on loading.");
        if (ex.toString().indexOf("Can't get object clsid from progid") > -1) {
            this.m_logger.log(Level.SEVERE, ex.toString(), ex);
            PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespace(), "olstarterror", ex));
        } else
            this.m_logger.warning(ex.toString() + ", " + ex.getMessage());
    } catch (Exception ex) {
        this.m_logger.warning(ex.getMessage() + ", " + ex.toString());
    } finally {
        // added 2006/02/05: clean outlook references
        if (contact != null)
            contact.safeRelease();
    }
    return callers;
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) DefaultOutlookMapping(de.janrufmonitor.repository.mapping.DefaultOutlookMapping) ICallerList(de.janrufmonitor.framework.ICallerList) Message(de.janrufmonitor.exception.Message) IAttribute(de.janrufmonitor.framework.IAttribute) IMultiPhoneCaller(de.janrufmonitor.framework.IMultiPhoneCaller) Properties(java.util.Properties) ComFailException(com.jacob.com.ComFailException) ZipArchiveException(de.janrufmonitor.repository.zip.ZipArchiveException) SQLException(java.sql.SQLException) ComFailException(com.jacob.com.ComFailException) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 2 with DefaultOutlookMapping

use of de.janrufmonitor.repository.mapping.DefaultOutlookMapping in project janrufmonitor by tbrandt77.

the class OutlookContactProxy method setContactData.

private void setContactData(Dispatch contact, ICaller c, boolean business) {
    IOutlookMapping om = null;
    if (business)
        om = new BussinessOutlookMapping();
    else
        om = new PrivateOutlookMapping();
    Properties config = this.getRuntime().getConfigManagerFactory().getConfigManager().getProperties(NAMESPACE);
    if (config.getProperty("split", "true").equalsIgnoreCase("false")) {
        om = new DefaultOutlookMapping();
        PropagationFactory.getInstance().fire(new Message(Message.WARNING, getNamespace(), "olstore", new Exception("No split option selected.")));
    }
    OutlookMappingManager.getInstance().mapToOutlookCaller(contact, c, om);
}
Also used : DefaultOutlookMapping(de.janrufmonitor.repository.mapping.DefaultOutlookMapping) Message(de.janrufmonitor.exception.Message) BussinessOutlookMapping(de.janrufmonitor.repository.mapping.BussinessOutlookMapping) Properties(java.util.Properties) PrivateOutlookMapping(de.janrufmonitor.repository.mapping.PrivateOutlookMapping) ZipArchiveException(de.janrufmonitor.repository.zip.ZipArchiveException) SQLException(java.sql.SQLException) ComFailException(com.jacob.com.ComFailException) IOutlookMapping(de.janrufmonitor.repository.mapping.IOutlookMapping)

Aggregations

ComFailException (com.jacob.com.ComFailException)2 Message (de.janrufmonitor.exception.Message)2 DefaultOutlookMapping (de.janrufmonitor.repository.mapping.DefaultOutlookMapping)2 ZipArchiveException (de.janrufmonitor.repository.zip.ZipArchiveException)2 SQLException (java.sql.SQLException)2 Properties (java.util.Properties)2 IAttribute (de.janrufmonitor.framework.IAttribute)1 ICaller (de.janrufmonitor.framework.ICaller)1 ICallerList (de.janrufmonitor.framework.ICallerList)1 IMultiPhoneCaller (de.janrufmonitor.framework.IMultiPhoneCaller)1 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)1 BussinessOutlookMapping (de.janrufmonitor.repository.mapping.BussinessOutlookMapping)1 IOutlookMapping (de.janrufmonitor.repository.mapping.IOutlookMapping)1 PrivateOutlookMapping (de.janrufmonitor.repository.mapping.PrivateOutlookMapping)1