Search in sources :

Example 1 with KnownIssueException

use of org.olat.core.logging.KnownIssueException in project OpenOLAT by OpenOLAT.

the class BusinessGroupServiceImpl method deleteBusinessGroup.

@Override
public void deleteBusinessGroup(BusinessGroup group) {
    try {
        OLATResourceableJustBeforeDeletedEvent delEv = new OLATResourceableJustBeforeDeletedEvent(group);
        // notify all (currently running) BusinessGroupXXXcontrollers
        // about the deletion which will occur.
        CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(delEv, group);
        // refresh object to avoid stale object exceptions
        group = loadBusinessGroup(group);
        // 0) Loop over all deletableGroupData
        Map<String, DeletableGroupData> deleteListeners = CoreSpringFactory.getBeansOfType(DeletableGroupData.class);
        for (DeletableGroupData deleteListener : deleteListeners.values()) {
            if (log.isDebug()) {
                log.debug("deleteBusinessGroup: call deleteListener=" + deleteListener);
            }
            deleteListener.deleteGroupDataFor(group);
        }
        // 1) Delete all group properties
        CollaborationTools ct = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(group);
        // deletes everything concerning properties&collabTools
        ct.deleteTools(group);
        // 1.c)delete user in security groups
        // removeFromRepositoryEntrySecurityGroup(group);
        // 2) Delete the group areas
        areaManager.deleteBGtoAreaRelations(group);
        // 3) Delete the relations
        businessGroupRelationDAO.deleteRelationsToRepositoryEntry(group);
        assessmentModeDao.deleteAssessmentModesToGroup(group);
        // 4) delete properties
        propertyManager.deleteProperties(null, group, null, null, null);
        propertyManager.deleteProperties(null, null, group, null, null);
        // 5) delete the publisher attached to this group (e.g. the forum and folder
        // publisher)
        notificationsManager.deletePublishersOf(group);
        // 6) delete info messages and subscription context associated with this group
        infoMessageManager.removeInfoMessagesAndSubscriptionContext(group);
        // 7) the group
        businessGroupDAO.delete(group);
        // 8) delete the associated security groups
        // TODO group
        dbInstance.commit();
        log.audit("Deleted Business Group", group.toString());
    } catch (DBRuntimeException dbre) {
        Throwable th = dbre.getCause();
        if ((th instanceof ObjectNotFoundException) && th.getMessage().contains("org.olat.group.BusinessGroupImpl")) {
            // group already deleted
            return;
        }
        if ((th instanceof StaleObjectStateException) && (th.getMessage().startsWith("Row was updated or deleted by another transaction"))) {
            // known issue OLAT-3654
            log.info("Group was deleted by another user in the meantime. Known issue OLAT-3654");
            throw new KnownIssueException("Group was deleted by another user in the meantime", 3654);
        } else {
            throw dbre;
        }
    }
}
Also used : DeletableGroupData(org.olat.group.DeletableGroupData) DBRuntimeException(org.olat.core.logging.DBRuntimeException) KnownIssueException(org.olat.core.logging.KnownIssueException) ObjectNotFoundException(org.hibernate.ObjectNotFoundException) CollaborationTools(org.olat.collaboration.CollaborationTools) OLATResourceableJustBeforeDeletedEvent(org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent) StaleObjectStateException(org.hibernate.StaleObjectStateException)

Example 2 with KnownIssueException

use of org.olat.core.logging.KnownIssueException in project openolat by klemens.

the class BusinessGroupServiceImpl method deleteBusinessGroup.

@Override
public void deleteBusinessGroup(BusinessGroup group) {
    try {
        OLATResourceableJustBeforeDeletedEvent delEv = new OLATResourceableJustBeforeDeletedEvent(group);
        // notify all (currently running) BusinessGroupXXXcontrollers
        // about the deletion which will occur.
        CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(delEv, group);
        // refresh object to avoid stale object exceptions
        group = loadBusinessGroup(group);
        // 0) Loop over all deletableGroupData
        Map<String, DeletableGroupData> deleteListeners = CoreSpringFactory.getBeansOfType(DeletableGroupData.class);
        for (DeletableGroupData deleteListener : deleteListeners.values()) {
            if (log.isDebug()) {
                log.debug("deleteBusinessGroup: call deleteListener=" + deleteListener);
            }
            deleteListener.deleteGroupDataFor(group);
        }
        // 1) Delete all group properties
        CollaborationTools ct = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(group);
        // deletes everything concerning properties&collabTools
        ct.deleteTools(group);
        // 1.c)delete user in security groups
        // removeFromRepositoryEntrySecurityGroup(group);
        // 2) Delete the group areas
        areaManager.deleteBGtoAreaRelations(group);
        // 3) Delete the relations
        businessGroupRelationDAO.deleteRelationsToRepositoryEntry(group);
        assessmentModeDao.deleteAssessmentModesToGroup(group);
        // 4) delete properties
        propertyManager.deleteProperties(null, group, null, null, null);
        propertyManager.deleteProperties(null, null, group, null, null);
        // 5) delete the publisher attached to this group (e.g. the forum and folder
        // publisher)
        notificationsManager.deletePublishersOf(group);
        // 6) delete info messages and subscription context associated with this group
        infoMessageManager.removeInfoMessagesAndSubscriptionContext(group);
        // 7) the group
        businessGroupDAO.delete(group);
        // 8) delete the associated security groups
        // TODO group
        dbInstance.commit();
        log.audit("Deleted Business Group", group.toString());
    } catch (DBRuntimeException dbre) {
        Throwable th = dbre.getCause();
        if ((th instanceof ObjectNotFoundException) && th.getMessage().contains("org.olat.group.BusinessGroupImpl")) {
            // group already deleted
            return;
        }
        if ((th instanceof StaleObjectStateException) && (th.getMessage().startsWith("Row was updated or deleted by another transaction"))) {
            // known issue OLAT-3654
            log.info("Group was deleted by another user in the meantime. Known issue OLAT-3654");
            throw new KnownIssueException("Group was deleted by another user in the meantime", 3654);
        } else {
            throw dbre;
        }
    }
}
Also used : DeletableGroupData(org.olat.group.DeletableGroupData) DBRuntimeException(org.olat.core.logging.DBRuntimeException) KnownIssueException(org.olat.core.logging.KnownIssueException) ObjectNotFoundException(org.hibernate.ObjectNotFoundException) CollaborationTools(org.olat.collaboration.CollaborationTools) OLATResourceableJustBeforeDeletedEvent(org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent) StaleObjectStateException(org.hibernate.StaleObjectStateException)

Example 3 with KnownIssueException

use of org.olat.core.logging.KnownIssueException in project OpenOLAT by OpenOLAT.

the class IQTESTCourseNode method updateUserScoreEvaluation.

/**
 * @see org.olat.course.nodes.AssessableCourseNode#updateUserScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation,
 *      org.olat.course.run.userview.UserCourseEnvironment,
 *      org.olat.core.id.Identity)
 */
@Override
public void updateUserScoreEvaluation(ScoreEvaluation scoreEvaluation, UserCourseEnvironment userCourseEnvironment, Identity coachingIdentity, boolean incrementAttempts, Role by) {
    AssessmentManager am = userCourseEnvironment.getCourseEnvironment().getAssessmentManager();
    Identity mySelf = userCourseEnvironment.getIdentityEnvironment().getIdentity();
    try {
        am.saveScoreEvaluation(this, coachingIdentity, mySelf, scoreEvaluation, userCourseEnvironment, incrementAttempts, by);
    } catch (DBRuntimeException ex) {
        throw new KnownIssueException("DBRuntimeException - Row was updated or deleted...", 3570, ex);
    }
}
Also used : DBRuntimeException(org.olat.core.logging.DBRuntimeException) AssessmentManager(org.olat.course.assessment.AssessmentManager) KnownIssueException(org.olat.core.logging.KnownIssueException) Identity(org.olat.core.id.Identity)

Example 4 with KnownIssueException

use of org.olat.core.logging.KnownIssueException in project openolat by klemens.

the class IQTESTCourseNode method updateUserScoreEvaluation.

/**
 * @see org.olat.course.nodes.AssessableCourseNode#updateUserScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation,
 *      org.olat.course.run.userview.UserCourseEnvironment,
 *      org.olat.core.id.Identity)
 */
@Override
public void updateUserScoreEvaluation(ScoreEvaluation scoreEvaluation, UserCourseEnvironment userCourseEnvironment, Identity coachingIdentity, boolean incrementAttempts, Role by) {
    AssessmentManager am = userCourseEnvironment.getCourseEnvironment().getAssessmentManager();
    Identity mySelf = userCourseEnvironment.getIdentityEnvironment().getIdentity();
    try {
        am.saveScoreEvaluation(this, coachingIdentity, mySelf, scoreEvaluation, userCourseEnvironment, incrementAttempts, by);
    } catch (DBRuntimeException ex) {
        throw new KnownIssueException("DBRuntimeException - Row was updated or deleted...", 3570, ex);
    }
}
Also used : DBRuntimeException(org.olat.core.logging.DBRuntimeException) AssessmentManager(org.olat.course.assessment.AssessmentManager) KnownIssueException(org.olat.core.logging.KnownIssueException) Identity(org.olat.core.id.Identity)

Aggregations

DBRuntimeException (org.olat.core.logging.DBRuntimeException)4 KnownIssueException (org.olat.core.logging.KnownIssueException)4 ObjectNotFoundException (org.hibernate.ObjectNotFoundException)2 StaleObjectStateException (org.hibernate.StaleObjectStateException)2 CollaborationTools (org.olat.collaboration.CollaborationTools)2 Identity (org.olat.core.id.Identity)2 OLATResourceableJustBeforeDeletedEvent (org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent)2 AssessmentManager (org.olat.course.assessment.AssessmentManager)2 DeletableGroupData (org.olat.group.DeletableGroupData)2