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();
}
Aggregations