Search in sources :

Example 21 with ICaller

use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.

the class GetCaller method handleWithException.

public void handleWithException(IHttpRequest req, IMutableHttpResponse resp) throws HandlerException {
    ICallerManager mgr = null;
    String manager = null;
    try {
        manager = req.getParameter(GetCaller.PARAMETER_CALLERMANAGER);
    } catch (Exception e) {
        throw new HandlerException(e.getMessage(), 500);
    }
    if (manager == null)
        mgr = this.getRuntime().getCallerManagerFactory().getDefaultCallerManager();
    if (manager != null && manager.length() > 0)
        mgr = this.getRuntime().getCallerManagerFactory().getCallerManager(manager);
    if (mgr == null || !mgr.isActive() || !mgr.isSupported(IIdentifyCallerRepository.class)) {
        throw new HandlerException("Requested Callermanager does not exist or is not active.", 404);
    }
    String number = null;
    try {
        number = req.getParameter(GetCaller.PARAMETER_NUMBER);
    } catch (Exception e) {
        throw new HandlerException(e.getMessage(), 500);
    }
    if (number == null || number.length() == 0) {
        this.m_logger.severe("Parameter &number= was empty or not set.");
        throw new HandlerException("Parameter &number= was empty or not set.", 404);
    }
    IPhonenumber pn = null;
    StringTokenizer st = new StringTokenizer(number, ";");
    if (st.countTokens() == 3) {
        pn = this.getRuntime().getCallerFactory().createPhonenumber(st.nextToken().trim(), st.nextToken().trim(), st.nextToken().trim());
    }
    if (st.countTokens() == 2) {
        pn = this.getRuntime().getCallerFactory().createPhonenumber(st.nextToken().trim(), "", st.nextToken().trim());
    }
    if (st.countTokens() == 1) {
        pn = this.getRuntime().getCallerFactory().createPhonenumber(st.nextToken().trim());
    }
    try {
        ICaller caller = ((IIdentifyCallerRepository) mgr).getCaller(pn);
        String xml = XMLSerializer.toXML(caller, false);
        resp.setParameter("Content-Type", "text/xml");
        resp.setParameter("Content-Length", Long.toString(xml.length()));
        OutputStream ps = resp.getContentStreamForWrite();
        ps.write(xml.getBytes());
        ps.flush();
        ps.close();
    } catch (CallerNotFoundException e) {
        throw new HandlerException(e.getMessage(), 404);
    } catch (Exception e) {
        throw new HandlerException(e.getMessage(), 500);
    }
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) HandlerException(de.janrufmonitor.service.commons.http.handler.HandlerException) StringTokenizer(java.util.StringTokenizer) OutputStream(java.io.OutputStream) CallerNotFoundException(de.janrufmonitor.repository.CallerNotFoundException) IIdentifyCallerRepository(de.janrufmonitor.repository.types.IIdentifyCallerRepository) ICallerManager(de.janrufmonitor.repository.ICallerManager) CallerNotFoundException(de.janrufmonitor.repository.CallerNotFoundException) HandlerException(de.janrufmonitor.service.commons.http.handler.HandlerException) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 22 with ICaller

use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.

the class Image method handleWithException.

public void handleWithException(IHttpRequest req, IMutableHttpResponse resp) throws HandlerException {
    ICallerManager mgr = null;
    String manager = null;
    try {
        manager = req.getParameter(Image.PARAMETER_CALLERMANAGER);
    } catch (Exception e) {
        throw new HandlerException(e.getMessage(), 500);
    }
    if (manager == null)
        mgr = this.getRuntime().getCallerManagerFactory().getDefaultCallerManager();
    if (manager != null && manager.length() > 0)
        mgr = this.getRuntime().getCallerManagerFactory().getCallerManager(manager);
    if (mgr == null || !mgr.isActive() || !mgr.isSupported(IIdentifyCallerRepository.class)) {
        throw new HandlerException("Requested Callermanager does not exist or is not active.", 404);
    }
    String number = null;
    try {
        number = req.getParameter(Image.PARAMETER_NUMBER);
    } catch (Exception e) {
        throw new HandlerException(e.getMessage(), 500);
    }
    if (number == null || number.length() == 0) {
        this.m_logger.severe("Parameter &number= was empty or not set.");
        throw new HandlerException("Parameter &number= was empty or not set.", 404);
    }
    IPhonenumber pn = null;
    StringTokenizer st = new StringTokenizer(number, ";");
    if (st.countTokens() == 3) {
        pn = this.getRuntime().getCallerFactory().createPhonenumber(st.nextToken().trim(), st.nextToken().trim(), st.nextToken().trim());
    }
    if (st.countTokens() == 2) {
        pn = this.getRuntime().getCallerFactory().createPhonenumber(st.nextToken().trim(), "", st.nextToken().trim());
    }
    if (st.countTokens() == 1) {
        pn = this.getRuntime().getCallerFactory().createPhonenumber(st.nextToken().trim());
    }
    try {
        ICaller caller = ((IIdentifyCallerRepository) mgr).getCaller(pn);
        IAttribute imageAtt = caller.getAttribute(IJAMConst.ATTRIBUTE_NAME_IMAGEPATH);
        if (ImageHandler.getInstance().hasImage(caller)) {
            InputStream in = ImageHandler.getInstance().getImageStream(caller);
            if (in != null) {
                resp.setParameter("Content-Type", this.getMimetype("jpg"));
                OutputStream ps = resp.getContentStreamForWrite();
                byte[] buffer = new byte[8092];
                int bytesRead;
                while ((bytesRead = in.read(buffer)) != -1) {
                    ps.write(buffer, 0, bytesRead);
                }
                in.close();
                ps.flush();
                ps.close();
            }
        } else if (imageAtt != null) {
            String pathToImage = PathResolver.getInstance(getRuntime()).resolve(imageAtt.getValue());
            File image = new File(pathToImage);
            if (image.exists()) {
                resp.setParameter("Content-Type", this.getMimetype(pathToImage));
                resp.setParameter("Content-Length", Long.toString(image.length()));
                OutputStream ps = resp.getContentStreamForWrite();
                FileInputStream in = new FileInputStream(image);
                byte[] buffer = new byte[8092];
                int bytesRead;
                while ((bytesRead = in.read(buffer)) != -1) {
                    ps.write(buffer, 0, bytesRead);
                }
                in.close();
                ps.flush();
                ps.close();
            } else {
                throw new CallerNotFoundException("Image " + pathToImage + " not found");
            }
        } else {
            throw new CallerNotFoundException("No image assigned for caller " + caller);
        }
    } catch (CallerNotFoundException e) {
        throw new HandlerException(e.getMessage(), 404);
    } catch (Exception e) {
        throw new HandlerException(e.getMessage(), 500);
    }
}
Also used : HandlerException(de.janrufmonitor.service.commons.http.handler.HandlerException) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) IIdentifyCallerRepository(de.janrufmonitor.repository.types.IIdentifyCallerRepository) ICallerManager(de.janrufmonitor.repository.ICallerManager) CallerNotFoundException(de.janrufmonitor.repository.CallerNotFoundException) HandlerException(de.janrufmonitor.service.commons.http.handler.HandlerException) FileInputStream(java.io.FileInputStream) ICaller(de.janrufmonitor.framework.ICaller) StringTokenizer(java.util.StringTokenizer) IAttribute(de.janrufmonitor.framework.IAttribute) CallerNotFoundException(de.janrufmonitor.repository.CallerNotFoundException) File(java.io.File) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 23 with ICaller

use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.

the class LdapContactsProxy method identify.

public synchronized ICaller identify(IPhonenumber pn) throws LdapContactsException {
    ICaller c = Identifier.identifyDefault(getRuntime(), pn);
    if (c == null && PhonenumberAnalyzer.getInstance(getRuntime()).isInternal(pn)) {
        IPhonenumber p = getRuntime().getCallerFactory().createInternalPhonenumber(pn.getTelephoneNumber());
        c = getRuntime().getCallerFactory().createCaller(p);
    }
    if (c != null) {
        pn = c.getPhoneNumber();
        try {
            List uuids = this.m_dbh.select(pn.getIntAreaCode(), pn.getAreaCode(), pn.getCallNumber());
            if (this.m_logger.isLoggable(Level.INFO)) {
                this.m_logger.info("List of found UUIDs: " + uuids);
            }
            if (uuids.size() > 0) {
                String uuid = null;
                ICaller contact = null;
                for (int k = 0; k < uuids.size(); k++) {
                    uuid = (String) uuids.get(k);
                    try {
                        contact = this.identifyByUUID(uuid);
                        if (contact != null) {
                            if (this.m_logger.isLoggable(Level.INFO)) {
                                this.m_logger.info("LDAP contact found for UUID: " + uuid);
                            }
                            contact.setUUID(new UUID().toString());
                            if (contact instanceof IMultiPhoneCaller) {
                                ((IMultiPhoneCaller) contact).getPhonenumbers().clear();
                            }
                            contact.setPhoneNumber(pn);
                            contact.setAttribute(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CENTRAL_NUMBER_OF_EXTENSION, pn.getTelephoneNumber()));
                            return contact;
                        }
                    } catch (LdapContactsException e) {
                        this.m_logger.log(Level.SEVERE, e.getMessage(), e);
                    }
                }
            } else {
                Properties config = this.getRuntime().getConfigManagerFactory().getConfigManager().getProperties(LdapRepository.NAMESPACE);
                if (config.getProperty(CFG_LDAP_KEEPEXT, "false").equalsIgnoreCase("true")) {
                    // iterate down
                    String callnumber = pn.getCallNumber();
                    if (callnumber.length() > 1) {
                        pn.setCallNumber(callnumber.substring(0, callnumber.length() - 1));
                        ICaller ca = this.identify(pn);
                        if (ca != null) {
                            pn.setCallNumber(callnumber);
                            if (ca instanceof IMultiPhoneCaller) {
                                ((IMultiPhoneCaller) ca).getPhonenumbers().clear();
                            }
                            ca.setPhoneNumber(pn);
                            // set extension
                            if (ca.getAttributes().contains(IJAMConst.ATTRIBUTE_NAME_CENTRAL_NUMBER_OF_EXTENSION)) {
                                String centralnumber = ca.getAttribute(IJAMConst.ATTRIBUTE_NAME_CENTRAL_NUMBER_OF_EXTENSION).getValue();
                                if (pn.getTelephoneNumber().length() > centralnumber.length()) {
                                    IAttribute att = getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_EXTENSION, pn.getTelephoneNumber().substring(centralnumber.length()));
                                    ca.setAttribute(att);
                                }
                            }
                            if (this.m_logger.isLoggable(Level.INFO)) {
                                this.m_logger.info("Caller match by central number: " + ca.toString());
                            }
                            return ca;
                        }
                    }
                }
            }
        } catch (SQLException e) {
            this.m_logger.log(Level.SEVERE, e.toString(), e);
        }
    }
    if (this.m_logger.isLoggable(Level.INFO))
        this.m_logger.info("Caller not identified: " + pn.getTelephoneNumber());
    return null;
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) SQLException(java.sql.SQLException) IAttribute(de.janrufmonitor.framework.IAttribute) ICallerList(de.janrufmonitor.framework.ICallerList) List(java.util.List) IMultiPhoneCaller(de.janrufmonitor.framework.IMultiPhoneCaller) UUID(de.janrufmonitor.util.uuid.UUID) Properties(java.util.Properties) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 24 with ICaller

use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.

the class LdapContactsProxy method getContacts.

public synchronized ICallerList getContacts(String category) throws LdapContactsException {
    ICallerList cl = getRuntime().getCallerFactory().createCallerList(getMaxResults());
    String query = "(objectclass=*)";
    if (category != null) {
        String ldapAttrib = LdapMappingManager.getInstance().getLdapAttribute(IJAMConst.ATTRIBUTE_NAME_CATEGORY);
        if (ldapAttrib != null && ldapAttrib.trim().length() > 0) {
            query = "(" + ldapAttrib + "=" + category + ")";
        }
    }
    LDAPConnection lc = new LDAPConnection();
    try {
        lc.connect(getServer(), getPort());
        lc.bind(LDAPConnection.LDAP_V3, getLoginUser(), getLoginPassword().getBytes("UTF-8"));
        LDAPSearchConstraints cons = lc.getSearchConstraints();
        cons.setMaxResults(getMaxResults());
        String baseDN = this.getBaseDN();
        String[] bases = null;
        if (baseDN.indexOf("|") > 0) {
            bases = baseDN.split("\\|");
        } else {
            bases = new String[] { baseDN };
        }
        for (int i = 0; i < bases.length; i++) {
            LDAPSearchResults searchResults = lc.search(bases[i], getScope(), query, // return all attributes
            null, // return attrs and values
            false, cons);
            ICaller c = null;
            while (searchResults.hasMore()) {
                LDAPEntry nextEntry = null;
                try {
                    nextEntry = searchResults.next();
                } catch (LDAPException e) {
                    if (e.getResultCode() == LDAPException.LDAP_TIMEOUT || e.getResultCode() == LDAPException.CONNECT_ERROR)
                        break;
                    else
                        continue;
                }
                c = LdapMappingManager.getInstance().mapToJamCaller(nextEntry);
                if (c != null) {
                    cl.add(c);
                }
            }
        }
        // disconnect from the server
        lc.disconnect();
        LdapMappingManager.invalidate();
    } catch (LDAPException e) {
        this.m_logger.log(Level.SEVERE, e.toString(), e);
        throw new LdapContactsException(e.toString(), e);
    } catch (UnsupportedEncodingException e) {
        this.m_logger.log(Level.SEVERE, e.toString(), e);
    }
    if (this.m_dbh != null) {
        try {
            this.m_dbh.deleteAll();
            ICaller c = null;
            for (int i = 0, j = cl.size(); i < j; i++) {
                c = cl.get(i);
                if (c instanceof IMultiPhoneCaller) {
                    List phones = ((IMultiPhoneCaller) c).getPhonenumbers();
                    IPhonenumber pn = null;
                    for (int k = 0; k < phones.size(); k++) {
                        pn = (IPhonenumber) phones.get(k);
                        this.m_dbh.insert(c.getUUID(), pn.getIntAreaCode(), pn.getAreaCode(), pn.getCallNumber());
                    }
                } else {
                    IPhonenumber pn = c.getPhoneNumber();
                    this.m_dbh.insert(c.getUUID(), pn.getIntAreaCode(), pn.getAreaCode(), pn.getCallNumber());
                }
            }
        } catch (SQLException e) {
            throw new LdapContactsException(e.getMessage(), e);
        }
    } else {
        this.m_logger.warning("GoogleContacts proxy datahandler not initialized. Could not insert google contacts...");
    }
    return cl;
}
Also used : SQLException(java.sql.SQLException) LDAPSearchConstraints(com.novell.ldap.LDAPSearchConstraints) UnsupportedEncodingException(java.io.UnsupportedEncodingException) LDAPConnection(com.novell.ldap.LDAPConnection) ICaller(de.janrufmonitor.framework.ICaller) LDAPEntry(com.novell.ldap.LDAPEntry) ICallerList(de.janrufmonitor.framework.ICallerList) LDAPSearchResults(com.novell.ldap.LDAPSearchResults) LDAPException(com.novell.ldap.LDAPException) IMultiPhoneCaller(de.janrufmonitor.framework.IMultiPhoneCaller) ICallerList(de.janrufmonitor.framework.ICallerList) List(java.util.List) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 25 with ICaller

use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.

the class MacAddressBookMappingManager method mapToJamCaller.

@SuppressWarnings("unchecked")
public synchronized ICaller mapToJamCaller(Map<?, ?> oCaller, IMacAddressBookMapping om) {
    if (!oCaller.containsKey(IMacAddressBookConst.PHONE)) {
        if (this.m_logger.isLoggable(Level.INFO)) {
            this.m_logger.info("Mac Address Book entry has no phone numbers: " + oCaller);
        }
        return null;
    }
    if (((List) oCaller.get(IMacAddressBookConst.PHONE)).size() == 0) {
        if (this.m_logger.isLoggable(Level.INFO)) {
            this.m_logger.info("Mac Address Book entry phone numbers are empty: " + oCaller);
        }
        return null;
    }
    if (this.m_logger.isLoggable(Level.INFO)) {
        this.m_logger.info("Appliing mapping: " + om.toString());
    }
    IAttributeMap m = getRuntime().getCallerFactory().createAttributeMap();
    // processing the numbers
    List macNumberMappings = om.getSupportedNumbers();
    // added 2015/05/03: added generic etiketts
    if (macNumberMappings.contains("*")) {
        macNumberMappings.addAll(this.getGenericMappings(((List) oCaller.get(IMacAddressBookConst.PHONE))));
    }
    List phones = new ArrayList(macNumberMappings.size());
    String numbertype = null;
    String number = null;
    IPhonenumber phone = null;
    for (int i = 0, j = macNumberMappings.size(); i < j; i++) {
        numbertype = (String) macNumberMappings.get(i);
        while ((number = getRawNumber(((List) oCaller.get(IMacAddressBookConst.PHONE)), numbertype)) != null) {
            if (number != null && !PhonenumberAnalyzer.getInstance(getRuntime()).isInternal(number) && !PhonenumberAnalyzer.getInstance(getRuntime()).isClired(number)) {
                if (this.m_logger.isLoggable(Level.INFO)) {
                    this.m_logger.info("MacAddressbook raw number: " + number);
                }
                phone = PhonenumberAnalyzer.getInstance(getRuntime()).toIdentifiedPhonenumber(number);
                if (this.m_logger.isLoggable(Level.INFO)) {
                    this.m_logger.info("MacAddressbook identified number: " + phone);
                }
                if (phone != null && phone.getTelephoneNumber().trim().length() > 0 && !phone.isClired()) {
                    m.add(getNumberTypeAttribute(numbertype, phone, om));
                    m.add(om.createMacAddressBookNumberTypeAttribute(phone, numbertype));
                    phones.add(phone);
                    if (this.m_logger.isLoggable(Level.INFO)) {
                        this.m_logger.info("Added phone " + phone.toString());
                    }
                }
            } else if (number != null && PhonenumberAnalyzer.getInstance(getRuntime()).isInternal(number)) {
                // found internal number
                phone = getRuntime().getCallerFactory().createInternalPhonenumber(number);
                if (phone != null && phone.getTelephoneNumber().trim().length() > 0 && !phone.isClired()) {
                    m.add(getNumberTypeAttribute(numbertype, phone, om));
                    m.add(om.createMacAddressBookNumberTypeAttribute(phone, numbertype));
                    phones.add(phone);
                    if (this.m_logger.isLoggable(Level.INFO)) {
                        this.m_logger.info("Added internal phone " + phone.toString());
                    }
                }
            }
        }
    }
    if (phones.size() > 0) {
        if (phones.size() > 1)
            Collections.sort(phones, new PhonenumberTypeComparator(m, om));
        // process address data
        List macContacFieldMappings = om.getSupportedContactFields();
        String field = null;
        String jamField = null;
        IAttribute a = null;
        if (oCaller.containsKey(IMacAddressBookAddressMapping.ADDRESS)) {
            for (int i = 0, j = macContacFieldMappings.size(); i < j; i++) {
                field = (String) macContacFieldMappings.get(i);
                jamField = om.mapToJamField(field);
                if (jamField != null) {
                    a = createAttribute(jamField, this.getRawAddress((List) oCaller.get(IMacAddressBookAddressMapping.ADDRESS), om.getSupportedAddressType(), field));
                    if (a != null) {
                        m.add(a);
                        if (this.m_logger.isLoggable(Level.INFO)) {
                            this.m_logger.info("Added attribute " + a.toString());
                        }
                    }
                }
            }
        }
        if (oCaller.containsKey(IMacAddressBookAddressMapping.EMAIL)) {
            jamField = om.mapToJamField(IMacAddressBookAddressMapping.EMAIL);
            a = createAttribute(jamField, this.getRawEmail((List) oCaller.get(IMacAddressBookAddressMapping.EMAIL), om.getSupportedEmailType()));
            if (a != null) {
                m.add(a);
                if (this.m_logger.isLoggable(Level.INFO)) {
                    this.m_logger.info("Added attribute " + a.toString());
                }
            }
        }
        for (int i = 0, j = macContacFieldMappings.size(); i < j; i++) {
            field = (String) macContacFieldMappings.get(i);
            jamField = om.mapToJamField(field);
            if (jamField != null) {
                a = createAttribute(jamField, (String) oCaller.get(field));
                if (a != null) {
                    m.add(a);
                    if (this.m_logger.isLoggable(Level.INFO)) {
                        this.m_logger.info("Added attribute " + a.toString());
                    }
                }
            }
        }
        // date format 2010-07-22 15:34:45 +0200
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
        if (oCaller.containsKey(IMacAddressBookConst.CREATION)) {
            try {
                a = createAttribute(IJAMConst.ATTRIBUTE_NAME_CREATION, Long.toString(sdf.parse((String) oCaller.get(IMacAddressBookConst.CREATION)).getTime()));
            } catch (ParseException e) {
                this.m_logger.warning("Could not parse creation date: " + oCaller.get(IMacAddressBookConst.CREATION));
            }
            if (a != null)
                m.add(a);
        }
        if (oCaller.containsKey(IMacAddressBookConst.MODIFICATION)) {
            try {
                a = createAttribute(IJAMConst.ATTRIBUTE_NAME_MODIFIED, Long.toString(sdf.parse((String) oCaller.get(IMacAddressBookConst.MODIFICATION)).getTime()));
            } catch (ParseException e) {
                this.m_logger.warning("Could not parse modification date: " + oCaller.get(IMacAddressBookConst.MODIFICATION));
            }
            if (a != null)
                m.add(a);
        }
        if (oCaller.containsKey(IMacAddressBookConst.PARENT_GROUPS)) {
            List categories = (List) oCaller.get(IMacAddressBookConst.PARENT_GROUPS);
            if (categories.size() > 0) {
                for (int i = 0; i < categories.size(); i++) {
                    a = createAttribute(IJAMConst.ATTRIBUTE_NAME_CATEGORY, MacAddressBookProxy.getInstance().getCategory((String) categories.get(i)));
                    if (a != null) {
                        m.add(a);
                        break;
                    }
                }
            }
        }
        // TODO: 2008/08/13 - Hack - split up street and street no
        IAttribute street = m.get(IJAMConst.ATTRIBUTE_NAME_STREET);
        if (street != null && street.getValue().trim().length() > 0) {
            String[] streetSplit = street.getValue().trim().split(" ");
            if (streetSplit.length > 1) {
                street.setValue("");
                for (int i = 0; i < streetSplit.length - 1; i++) {
                    street.setValue(street.getValue() + " " + streetSplit[i]);
                }
                street.setValue(street.getValue().trim());
                m.add(street);
                IAttribute streetno = getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_STREET_NO, streetSplit[streetSplit.length - 1]);
                m.add(streetno);
            }
        }
        String uuid = (String) oCaller.get(IMacAddressBookConst.UID);
        if (uuid == null || uuid.trim().length() == 0)
            uuid = new UUID().toString();
        try {
            MacAddressBookProxy.getInstance().getDataHandler().deleteAttributes(uuid);
        } catch (SQLException e) {
            this.m_logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
        }
        ICaller macCaller = getRuntime().getCallerFactory().createCaller(uuid, null, phones, m);
        this.setPictureAttribute(macCaller, oCaller);
        this.setGeoData(macCaller);
        IAttribute cm = getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLERMANAGER, ID);
        macCaller.setAttribute(cm);
        if (this.m_logger.isLoggable(Level.INFO)) {
            this.m_logger.info("Created Mac address book contact: " + macCaller.toString());
        }
        try {
            if (macCaller.getAttributes().contains(IJAMConst.ATTRIBUTE_NAME_LASTNAME))
                MacAddressBookProxy.getInstance().getDataHandler().insertAttribute(macCaller.getUUID(), IJAMConst.ATTRIBUTE_NAME_LASTNAME, macCaller.getAttribute(IJAMConst.ATTRIBUTE_NAME_LASTNAME).getValue());
            if (macCaller.getAttributes().contains(IJAMConst.ATTRIBUTE_NAME_CITY))
                MacAddressBookProxy.getInstance().getDataHandler().insertAttribute(macCaller.getUUID(), IJAMConst.ATTRIBUTE_NAME_CITY, macCaller.getAttribute(IJAMConst.ATTRIBUTE_NAME_CITY).getValue());
            if (macCaller.getAttributes().contains(IJAMConst.ATTRIBUTE_NAME_COUNTRY))
                MacAddressBookProxy.getInstance().getDataHandler().insertAttribute(macCaller.getUUID(), IJAMConst.ATTRIBUTE_NAME_COUNTRY, macCaller.getAttribute(IJAMConst.ATTRIBUTE_NAME_COUNTRY).getValue());
            if (macCaller.getAttributes().contains(IJAMConst.ATTRIBUTE_NAME_POSTAL_CODE))
                MacAddressBookProxy.getInstance().getDataHandler().insertAttribute(macCaller.getUUID(), IJAMConst.ATTRIBUTE_NAME_POSTAL_CODE, macCaller.getAttribute(IJAMConst.ATTRIBUTE_NAME_POSTAL_CODE).getValue());
        } catch (SQLException e) {
            this.m_logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
        }
        return macCaller;
    }
    return null;
}
Also used : SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) ICaller(de.janrufmonitor.framework.ICaller) IAttribute(de.janrufmonitor.framework.IAttribute) IAttributeMap(de.janrufmonitor.framework.IAttributeMap) ArrayList(java.util.ArrayList) List(java.util.List) ParseException(java.text.ParseException) UUID(de.janrufmonitor.util.uuid.UUID) SimpleDateFormat(java.text.SimpleDateFormat) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Aggregations

ICaller (de.janrufmonitor.framework.ICaller)144 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)62 ICallerList (de.janrufmonitor.framework.ICallerList)49 List (java.util.List)46 IAttribute (de.janrufmonitor.framework.IAttribute)42 ICall (de.janrufmonitor.framework.ICall)41 ArrayList (java.util.ArrayList)40 IAttributeMap (de.janrufmonitor.framework.IAttributeMap)32 SQLException (java.sql.SQLException)26 IMultiPhoneCaller (de.janrufmonitor.framework.IMultiPhoneCaller)25 IOException (java.io.IOException)25 Viewer (org.eclipse.jface.viewers.Viewer)24 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)22 File (java.io.File)20 Date (java.util.Date)17 Iterator (java.util.Iterator)17 Shell (org.eclipse.swt.widgets.Shell)17 IMsn (de.janrufmonitor.framework.IMsn)16 Properties (java.util.Properties)15 ICip (de.janrufmonitor.framework.ICip)14