use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.
the class EPArtefactManager method getArtefactContainer.
protected VFSContainer getArtefactContainer(AbstractArtefact artefact) {
Long key = artefact.getKey();
if (key == null)
throw new AssertException("artefact not yet persisted -> no key available!");
VFSContainer container = null;
VFSItem item = getArtefactsRoot().resolve(key.toString());
if (item == null) {
container = getArtefactsRoot().createChildContainer(key.toString());
} else if (item instanceof VFSContainer) {
container = (VFSContainer) item;
} else {
logError("Cannot create a container for artefact: " + artefact, null);
}
return container;
}
use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.
the class CoordinatorTest method testSyncerAssertAlreadyDoInSyncFor.
@Test
public void testSyncerAssertAlreadyDoInSyncFor() {
final OLATResourceable ores = OresHelper.createOLATResourceableInstance("testSyncerAssertAlreadyDoInSyncFor", new Long("123"));
// 1. check assertAlreadyDoInSyncFor WITHOUT sync-block => AssertException must be thrown
try {
CoordinatorManager.getInstance().getCoordinator().getSyncer().assertAlreadyDoInSyncFor(ores);
fail("Did not throw AssertException");
} catch (AssertException ex) {
log.info("testSyncerAssertAlreadyDoInSyncFor: This exception is ok, exception=" + ex.getMessage());
}
// 2.check assertAlreadyDoInSyncFor WITH sync-block => No AssertException should occour
try {
log.info("testSyncerAssertAlreadyDoInSyncFor: before doInSync");
CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(ores, new SyncerCallback<Boolean>() {
public Boolean execute() {
log.info("testSyncerAssertAlreadyDoInSyncFor: execute before assertAlreadyDoInSyncFor");
CoordinatorManager.getInstance().getCoordinator().getSyncer().assertAlreadyDoInSyncFor(ores);
log.info("testSyncerAssertAlreadyDoInSyncFor: execute done");
return Boolean.TRUE;
}
});
// end syncerCallback
} catch (AssertException aex) {
fail("testSyncerAssertAlreadyDoInSyncFor: got a AssertException=" + aex);
}
}
use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.
the class BusinessGroupMainRunController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
*/
@Override
public void event(UserRequest ureq, Controller source, Event event) {
if (source == bgEditCntrllr) {
// changes from the admin controller
if (event == Event.CHANGED_EVENT) {
businessGroup = bgEditCntrllr.getBusinessGroup();
chatAvailable = isChatAvailable();
TreeModel trMdl = buildTreeModel();
bgTree.setTreeModel(trMdl);
bgTree.setSelectedNode(nodeAdmin);
} else if (event == Event.CANCELLED_EVENT) {
// could not get lock on business group, back to inital screen
bgTree.setSelectedNodeId(bgTree.getTreeModel().getRootNode().getIdent());
mainPanel.setContent(main);
}
} else if (source == resourcesCtr) {
if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
TableEvent te = (TableEvent) event;
String actionid = te.getActionId();
int rowid = te.getRowId();
RepositoryTableModel repoTableModel = (RepositoryTableModel) resourcesCtr.getTableDataModel();
if (RepositoryTableModel.TABLE_ACTION_SELECT_LINK.equals(actionid)) {
RepositoryEntry currentRepoEntry = repoTableModel.getObject(rowid);
OLATResource ores = currentRepoEntry.getOlatResource();
if (ores == null)
throw new AssertException("repoEntry had no olatresource, repoKey = " + currentRepoEntry.getKey());
addLoggingResourceable(LoggingResourceable.wrap(ores, OlatResourceableType.genRepoEntry));
String businessPath = "[RepositoryEntry:" + currentRepoEntry.getKey() + "]";
NewControllerFactory.getInstance().launch(businessPath, ureq, getWindowControl());
}
}
} else if (source == sendToChooserForm) {
if (event == Event.DONE_EVENT) {
removeAsListenerAndDispose(collabToolCtr);
collabToolCtr = createContactFormController(ureq);
listenTo(collabToolCtr);
mainPanel.setContent(collabToolCtr.getInitialComponent());
} else if (event == Event.CANCELLED_EVENT) {
// back to group overview
bgTree.setSelectedNodeId(bgTree.getTreeModel().getRootNode().getIdent());
mainPanel.setContent(main);
}
} else if (source == collabToolCtr) {
if (event == Event.CANCELLED_EVENT || event == Event.DONE_EVENT || event == Event.BACK_EVENT || event == Event.FAILED_EVENT) {
// In all cases (success or failure) we
// go back to the group overview page.
bgTree.setSelectedNodeId(bgTree.getTreeModel().getRootNode().getIdent());
mainPanel.setContent(main);
}
} else if (source == accessController) {
if (event.equals(AccessEvent.ACCESS_OK_EVENT)) {
removeAsListenerAndDispose(accessController);
accessController = null;
// check if on waiting list
List<BusinessGroupMembership> memberships = businessGroupService.getBusinessGroupMembership(Collections.singletonList(businessGroup.getKey()), getIdentity());
if (isOnWaitinglist(memberships)) {
Component cmp = getOnWaitingListMessage(ureq, businessGroup);
mainPanel.setContent(cmp);
} else {
mainPanel.setContent(main);
bgTree.setTreeModel(buildTreeModel());
needActivation = false;
}
} else if (event.equals(AccessEvent.ACCESS_FAILED_EVENT)) {
String msg = ((AccessEvent) event).getMessage();
if (StringHelper.containsNonWhitespace(msg)) {
getWindowControl().setError(msg);
} else {
showError("error.accesscontrol");
}
}
}
}
use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.
the class BusinessGroupMainRunController method event.
/**
* @see org.olat.core.util.event.GenericEventListener#event(org.olat.core.gui.control.Event)
*/
@Override
public void event(Event event) {
if (event instanceof OLATResourceableJustBeforeDeletedEvent) {
OLATResourceableJustBeforeDeletedEvent delEvent = (OLATResourceableJustBeforeDeletedEvent) event;
if (!delEvent.targetEquals(businessGroup)) {
throw new AssertException("receiving a delete event for a olatres we never registered for!!!:" + delEvent.getDerivedOres());
}
dispose();
} else if (event instanceof BusinessGroupModifiedEvent) {
BusinessGroupModifiedEvent bgmfe = (BusinessGroupModifiedEvent) event;
if (event.getCommand().equals(BusinessGroupModifiedEvent.CONFIGURATION_MODIFIED_EVENT)) {
// reset business group property manager
// update reference to update business group object
businessGroup = businessGroupService.loadBusinessGroup(businessGroup);
chatAvailable = isChatAvailable();
main.contextPut("BuddyGroup", businessGroup);
TreeModel trMdl = buildTreeModel();
bgTree.setTreeModel(trMdl);
if (bgEditCntrllr == null) {
// change didn't origin by our own edit controller
showInfo("grouprun.configurationchanged");
bgTree.setSelectedNodeId(trMdl.getRootNode().getIdent());
mainPanel.setContent(main);
} else {
// Activate edit menu item
bgTree.setSelectedNodeId(ACTIVITY_MENUSELECT_ADMINISTRATION);
}
} else if (bgmfe.wasMyselfRemoved(getIdentity()) && !wildcard && !isGroupsAdmin) {
// nothing more here!! The message will be created and displayed upon disposing
// disposed message controller will be set
dispose();
}
} else if (event instanceof AssessmentEvent) {
if (((AssessmentEvent) event).getEventType().equals(AssessmentEvent.TYPE.STARTED)) {
groupRunDisabled = true;
} else if (((AssessmentEvent) event).getEventType().equals(AssessmentEvent.TYPE.STOPPED)) {
groupRunDisabled = false;
}
}
}
use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.
the class OLATAuthManager method changePassword.
/**
* Change the password of an identity. if the given identity is a LDAP-User,
* the pw-change is propagated to LDAP (according to config) NOTE: caller of
* this method should check if identity is allowed to change it's own pw [
* UserModule.isPwdchangeallowed(Identity ident) ], applies only if doer
* equals identity
*
* @param doer
* Identity who is changing the password
* @param identity
* Identity who's password is beeing changed.
* @param newPwd
* New password.
* @return True upon success.
*/
public boolean changePassword(Identity doer, Identity identity, String newPwd) {
if (doer == null)
throw new AssertException("password changing identity cannot be undefined!");
if (identity.getKey() == null)
throw new AssertException("cannot change password on a nonpersisted identity");
// o_clusterREVIEW
identity = securityManager.loadIdentityByKey(identity.getKey());
boolean allOk = false;
Authentication ldapAuth = securityManager.findAuthentication(identity, LDAPAuthenticationController.PROVIDER_LDAP);
if (ldapAuth != null) {
if (ldapLoginModule.isPropagatePasswordChangedOnLdapServer()) {
LDAPError ldapError = new LDAPError();
ldapLoginManager.changePassword(identity, newPwd, ldapError);
log.audit(doer.getName() + " change the password on the LDAP server for identity: " + identity.getName());
allOk = ldapError.isEmpty();
if (allOk && ldapLoginModule.isCacheLDAPPwdAsOLATPwdOnLogin()) {
allOk &= changeOlatPassword(doer, identity, identity.getName(), newPwd);
}
}
} else {
allOk = changeOlatPassword(doer, identity, identity.getName(), newPwd);
}
if (allOk) {
sendConfirmationEmail(doer, identity);
// remove
try {
loginModule.clearFailedLoginAttempts(identity.getName());
loginModule.clearFailedLoginAttempts(identity.getUser().getEmail());
} catch (Exception e) {
log.error("", e);
}
}
return allOk;
}
Aggregations