Search in sources :

Example 31 with AssertException

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;
}
Also used : AssertException(org.olat.core.logging.AssertException) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem)

Example 32 with AssertException

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);
    }
}
Also used : AssertException(org.olat.core.logging.AssertException) OLATResourceable(org.olat.core.id.OLATResourceable) Test(org.junit.Test)

Example 33 with AssertException

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");
            }
        }
    }
}
Also used : TreeModel(org.olat.core.gui.components.tree.TreeModel) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) BusinessGroupMembership(org.olat.group.BusinessGroupMembership) RepositoryTableModel(org.olat.repository.ui.RepositoryTableModel) AssertException(org.olat.core.logging.AssertException) TableEvent(org.olat.core.gui.components.table.TableEvent) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) Component(org.olat.core.gui.components.Component)

Example 34 with AssertException

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;
        }
    }
}
Also used : TreeModel(org.olat.core.gui.components.tree.TreeModel) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) AssertException(org.olat.core.logging.AssertException) AssessmentEvent(org.olat.course.nodes.iq.AssessmentEvent) OLATResourceableJustBeforeDeletedEvent(org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent) BusinessGroupModifiedEvent(org.olat.group.ui.edit.BusinessGroupModifiedEvent)

Example 35 with AssertException

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;
}
Also used : AssertException(org.olat.core.logging.AssertException) Authentication(org.olat.basesecurity.Authentication) LDAPError(org.olat.ldap.LDAPError) AssertException(org.olat.core.logging.AssertException)

Aggregations

AssertException (org.olat.core.logging.AssertException)364 IOException (java.io.IOException)38 File (java.io.File)28 Identity (org.olat.core.id.Identity)28 ArrayList (java.util.ArrayList)26 HashMap (java.util.HashMap)24 Controller (org.olat.core.gui.control.Controller)22 OLATResourceable (org.olat.core.id.OLATResourceable)22 RepositoryEntry (org.olat.repository.RepositoryEntry)22 WindowControl (org.olat.core.gui.control.WindowControl)20 UnsupportedEncodingException (java.io.UnsupportedEncodingException)18 JSONException (org.json.JSONException)18 BusinessGroup (org.olat.group.BusinessGroup)18 JSONObject (org.json.JSONObject)16 UserRequest (org.olat.core.gui.UserRequest)16 VFSContainer (org.olat.core.util.vfs.VFSContainer)16 VFSItem (org.olat.core.util.vfs.VFSItem)16 Date (java.util.Date)14 Properties (java.util.Properties)14 Property (org.olat.properties.Property)14