use of org.hibernate.ObjectDeletedException in project openolat by klemens.
the class OLATUpgrade_7_0_1 method migrateNotificationPublishers.
private void migrateNotificationPublishers(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
if (!uhd.getBooleanDataValue(TASK_CHECK_NOTIFICATIONS)) {
log.audit("+-----------------------------------------------------------------------------+");
log.audit("+... Check the businesspath for the publishers (notifications) ...+");
log.audit("+-----------------------------------------------------------------------------+");
int counter = 0;
NotificationsManager notificationMgr = NotificationsManager.getInstance();
List<Publisher> allPublishers = notificationMgr.getAllPublisher();
if (log.isDebug())
log.info("Found " + allPublishers.size() + " publishers to check.");
for (Publisher publisher : allPublishers) {
if (publisher != null && StringHelper.containsNonWhitespace(publisher.getBusinessPath()) && (publisher.getBusinessPath().startsWith("[Identity") || publisher.getBusinessPath().startsWith("ROOT[Identity"))) {
try {
String businessPath = publisher.getBusinessPath();
int startIndex = businessPath.indexOf("[Identity");
int stopIndex = businessPath.indexOf("]", startIndex);
int wide = stopIndex - startIndex;
if (wide > 30) {
// Identity:326394598 cannot be too wide
continue;
} else if (stopIndex + 1 >= businessPath.length()) {
// only identity
continue;
}
String correctPath = businessPath.substring(stopIndex + 1);
publisher.setBusinessPath(correctPath);
DBFactory.getInstance().updateObject(publisher);
} catch (ObjectDeletedException e) {
log.warn("Publisher was already deleted, no update possible! Publisher key: " + publisher.getKey());
} catch (Exception e) {
log.warn("Publisher was already deleted, no update possible! Publisher key: " + publisher.getKey());
}
counter++;
}
if (counter > 0 && counter % 100 == 0) {
log.audit("Another 100 publishers done");
DBFactory.getInstance().intermediateCommit();
}
}
DBFactory.getInstance().intermediateCommit();
log.audit("**** Checked " + counter + " publishers. ****");
uhd.setBooleanDataValue(TASK_CHECK_NOTIFICATIONS, true);
upgradeManager.setUpgradesHistory(uhd, VERSION);
}
}
use of org.hibernate.ObjectDeletedException in project openolat by klemens.
the class OLATUpgrade_7_1_0 method migrateNotificationPublishers.
private void migrateNotificationPublishers(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
if (!uhd.getBooleanDataValue(TASK_CHECK_NOTIFICATIONS)) {
log.audit("+-----------------------------------------------------------------------------+");
log.audit("+... Check the businesspath for the publishers (notifications) ...+");
log.audit("+-----------------------------------------------------------------------------+");
if (!portletRepositoryTeacherEnabled && !portletRepositoryStudentEnabled) {
log.audit("**** Repository portlets disabled: don't need to check publishers. ****");
uhd.setBooleanDataValue(TASK_CHECK_NOTIFICATIONS, true);
upgradeManager.setUpgradesHistory(uhd, VERSION);
return;
}
int counter = 0;
NotificationsManager notificationMgr = NotificationsManager.getInstance();
List<Publisher> allPublishers = notificationMgr.getAllPublisher();
if (log.isDebug())
log.info("Found " + allPublishers.size() + " publishers to check.");
for (Publisher publisher : allPublishers) {
if (publisher != null && StringHelper.containsNonWhitespace(publisher.getBusinessPath()) && (publisher.getBusinessPath().startsWith("[Identity") || publisher.getBusinessPath().startsWith("ROOT[Identity"))) {
try {
String businessPath = publisher.getBusinessPath();
int startIndex = businessPath.indexOf("[Identity");
int stopIndex = businessPath.indexOf("]", startIndex);
int wide = stopIndex - startIndex;
if (wide > 30) {
// Identity:326394598 cannot be too wide
continue;
} else if (stopIndex + 1 >= businessPath.length()) {
// only identity
continue;
}
String correctPath = businessPath.substring(stopIndex + 1);
publisher.setBusinessPath(correctPath);
DBFactory.getInstance().updateObject(publisher);
} catch (ObjectDeletedException e) {
log.warn("Publisher was already deleted, no update possible! Publisher key: " + publisher.getKey());
} catch (Exception e) {
log.warn("Publisher was already deleted, no update possible! Publisher key: " + publisher.getKey());
}
counter++;
}
if (counter > 0 && counter % 100 == 0) {
log.audit("Another 100 publishers done");
DBFactory.getInstance().intermediateCommit();
}
}
DBFactory.getInstance().intermediateCommit();
log.audit("**** Checked " + counter + " publishers. ****");
uhd.setBooleanDataValue(TASK_CHECK_NOTIFICATIONS, true);
upgradeManager.setUpgradesHistory(uhd, VERSION);
}
}
Aggregations