use of de.janrufmonitor.fritzbox.firmware.exception.DeleteCallerException in project janrufmonitor by tbrandt77.
the class FritzBoxPhonebookManager method removeCaller.
public void removeCaller(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.deleteCaller(id, pe);
ICallerList cl = getRuntime().getCallerFactory().createCallerList(1);
cl.add(caller);
try {
getDatabaseHandler().deleteCallerList(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 (DeleteCallerException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
}
if (!this.isSyncing)
this.createCallerListFromFritzBoxPhonebook();
}
Aggregations