Search in sources :

Example 1 with SetCallerException

use of de.janrufmonitor.fritzbox.firmware.exception.SetCallerException in project janrufmonitor by tbrandt77.

the class FritzBoxPhonebookManager method setCaller.

public void setCaller(ICaller caller) {
    FirmwareManager fwm = FirmwareManager.getInstance();
    fwm.startup();
    try {
        if (!fwm.isLoggedIn())
            fwm.login();
        // check if phonebook is configured
        String abId = getConfiguration().getProperty(CFG_ADDRESSBOOK, "0");
        if (this.m_logger.isLoggable(Level.INFO))
            this.m_logger.info("Getting FritzBox phonebook ID: #" + abId);
        int id = Integer.parseInt(abId);
        IPhonebookEntry pe = FritzBoxMappingManager.getInstance().mapJamCallerToFritzBox(caller);
        fwm.setCaller(id, pe);
        ICallerList cl = getRuntime().getCallerFactory().createCallerList(1);
        cl.add(caller);
        try {
            getDatabaseHandler().insertOrUpdateCallerList(cl);
            getDatabaseHandler().commit();
        } catch (SQLException e) {
            this.m_logger.log(Level.SEVERE, e.getMessage(), e);
            try {
                getDatabaseHandler().rollback();
            } catch (SQLException e1) {
                this.m_logger.log(Level.SEVERE, e1.getMessage(), e1);
            }
        }
    } catch (FritzBoxLoginException e) {
        this.m_logger.log(Level.SEVERE, e.getMessage(), e);
    } catch (IOException e) {
        this.m_logger.log(Level.SEVERE, e.getMessage(), e);
    } catch (SetCallerException e) {
        this.m_logger.log(Level.SEVERE, e.getMessage(), e);
    }
    if (!this.isSyncing)
        this.createCallerListFromFritzBoxPhonebook();
}
Also used : FritzBoxLoginException(de.janrufmonitor.fritzbox.firmware.exception.FritzBoxLoginException) ICallerList(de.janrufmonitor.framework.ICallerList) FirmwareManager(de.janrufmonitor.fritzbox.firmware.FirmwareManager) SQLException(java.sql.SQLException) SetCallerException(de.janrufmonitor.fritzbox.firmware.exception.SetCallerException) IPhonebookEntry(de.janrufmonitor.fritzbox.IPhonebookEntry) IOException(java.io.IOException)

Aggregations

ICallerList (de.janrufmonitor.framework.ICallerList)1 IPhonebookEntry (de.janrufmonitor.fritzbox.IPhonebookEntry)1 FirmwareManager (de.janrufmonitor.fritzbox.firmware.FirmwareManager)1 FritzBoxLoginException (de.janrufmonitor.fritzbox.firmware.exception.FritzBoxLoginException)1 SetCallerException (de.janrufmonitor.fritzbox.firmware.exception.SetCallerException)1 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1