Exemplo n.º 1
0
 /**
  * receives all sign on / sign off events so it can release locks of users which have or are
  * logged off
  */
 @Override
 public void event(final Event event) {
   final SignOnOffEvent se = (SignOnOffEvent) event;
   if (!se.isSignOn() && se.isEventOnThisNode()) {
     // it is a "logout" event - we are only interested in logout events
     // and it is from our VM => only release all locks from within one
     // VM
     final String identName = se.getIdentityName();
     // release all locks held by the identity that has just logged out.
     // (assuming one user has only one session (logged in with one
     // browser only): otherwise (as in singlevm, too)
     // since the lock is reentrant, a lock could be freed while a
     // session still is in a locked workflow (2x lock and then once
     // freed)
     try {
       clusterLockManager.releaseAllLocksFor(identName);
     } catch (final DBRuntimeException dbEx) {
       log.warn(
           "releaseAllLocksFor failed, close session and try it again for identName=" + identName);
       // TODO: 2010-04-23 Transactions [eglis]: OLAT-4318: this
       // rollback has possibly unwanted
       // side effects, as it rolls back any changes with this
       // transaction during this
       // event handling. Nicer would be to be done in the
       // outmost-possible place, e.g. dofire()
       DBFactory.getInstance().rollbackAndCloseSession();
       // try again with new db-session
       log.info("try again to release all locks for identName=" + identName);
       clusterLockManager.releaseAllLocksFor(identName);
       log.info("Done, released all locks for identName=" + identName);
     }
   }
 }
 @SuppressWarnings("deprecation")
 public void createAllCampusCoursesFromTemplate() {
   List<Long> courseIds = daoManager.getAllNotCreatedSapCourcesIds();
   for (Long courseId : courseIds) {
     CampusCourseImportTO campusCourseImportData = daoManager.getSapCampusCourse(courseId);
     if (campusCourseImportData.isOlatResourceableIdUndefined()) {
       if (!campusCourseImportData.getLecturers().isEmpty()) {
         try {
           Identity creator = campusCourseImportData.getLecturers().get(0);
           if (creator != null) {
             campusCourseCoreService.createCampusCourse(
                 null, courseId, creator, campusCourseImportData);
           }
         } catch (Exception ex) {
           LOG.error(ex.getMessage());
         } finally {
           DBFactory.getInstance(false).intermediateCommit();
         }
       }
     }
   }
 }
Exemplo n.º 3
0
 private void commitDBImplTransaction() {
   DBFactory.getInstance(false).intermediateCommit();
 }