Search in sources :

Example 26 with IdentitiesAddEvent

use of org.olat.admin.securitygroup.gui.IdentitiesAddEvent in project openolat by klemens.

the class CatalogNodeManagerController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (addEntryCtrl == source) {
        if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            loadNodesChildren();
        }
        cmc.deactivate();
        cleanUp();
        fireEvent(ureq, Event.CHANGED_EVENT);
    } else if (editEntryCtrl == source) {
        if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            catalogEntry = editEntryCtrl.getEditedCatalogEntry();
            loadEntryInfos();
        }
        cmc.deactivate();
        cleanUp();
        fireEvent(ureq, Event.CHANGED_EVENT);
    } else if (categoryMoveCtrl == source) {
        cmc.deactivate();
        CatalogEntry moveMe = null;
        if (event.equals(Event.DONE_EVENT)) {
            showInfo("tools.move.catalog.entry.success", catalogEntry.getName());
            moveMe = categoryMoveCtrl.getMoveMe();
        } else if (event.equals(Event.FAILED_EVENT)) {
            showError("tools.move.catalog.entry.failed");
            loadNodesChildren();
        }
        cleanUp();
        // in any case, remove the lock
        if (catModificationLock != null && catModificationLock.isSuccess()) {
            CoordinatorManager.getInstance().getCoordinator().getLocker().releaseLock(catModificationLock);
            catModificationLock = null;
        }
        // only after jump to the moved entry
        if (moveMe != null) {
            launchCatalogEntry(ureq, moveMe);
        }
    } else if (dialogDeleteSubtree == source) {
        // from remove subtree dialog -> yes or no
        if (DialogBoxUIFactory.isYesEvent(event)) {
            catalogManager.deleteCatalogEntry(catalogEntry);
            fireEvent(ureq, Event.BACK_EVENT);
        }
        // in any case, remove the lock
        if (catModificationLock != null && catModificationLock.isSuccess()) {
            CoordinatorManager.getInstance().getCoordinator().getLocker().releaseLock(catModificationLock);
            catModificationLock = null;
        }
    } else if (childNodeCtrl == source) {
        if (event == Event.BACK_EVENT) {
            toolbarPanel.popUpToController(this);
            removeAsListenerAndDispose(childNodeCtrl);
            childNodeCtrl = null;
            loadNodesChildren();
        }
    } else if (entrySearchCtrl == source) {
        if (event.getCommand().equals(RepositoryTableModel.TABLE_ACTION_SELECT_LINK)) {
            // successfully selected a repository entry which will be a link within
            // the current Category
            RepositoryEntry selectedEntry = entrySearchCtrl.getSelectedEntry();
            doAddResource(ureq, selectedEntry);
            fireEvent(ureq, Event.CHANGED_EVENT);
        }
        cmc.deactivate();
        cleanUp();
    } else if (groupCtrl == source) {
        if (event instanceof IdentitiesAddEvent || event instanceof IdentitiesRemoveEvent) {
            doAddRemoveOwners(event);
        }
    } else if (contactCtrl == source) {
        cmc.deactivate();
        cleanUp();
    } else if (dialogDeleteLink == source) {
        if (DialogBoxUIFactory.isYesEvent(event)) {
            CatalogEntryRow row = (CatalogEntryRow) dialogDeleteLink.getUserObject();
            catalogManager.deleteCatalogEntry(row, catalogEntry);
            loadResources(ureq);
        }
    } else if (entryResourceMoveCtrl == source) {
        if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            CatalogEntry moveMe = entryResourceMoveCtrl.getMoveMe();
            showInfo("tools.move.catalog.entry.success", moveMe.getName());
            loadResources(ureq);
        }
        cmc.deactivate();
        cleanUp();
    } else if (cmc == source) {
        cleanUp();
    }
    super.event(ureq, source, event);
}
Also used : IdentitiesRemoveEvent(org.olat.admin.securitygroup.gui.IdentitiesRemoveEvent) CatalogEntry(org.olat.repository.CatalogEntry) IdentitiesAddEvent(org.olat.admin.securitygroup.gui.IdentitiesAddEvent) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 27 with IdentitiesAddEvent

use of org.olat.admin.securitygroup.gui.IdentitiesAddEvent in project openolat by klemens.

the class RepositoryEntryResource method addCoach.

/**
 * Adds a coach to the repository entry.
 * @response.representation.200.doc The user is added as coach of the repository entry
 * @response.representation.401.doc The roles of the authenticated user are not sufficient
 * @response.representation.404.doc The repository entry or the user cannot be found
 * @param repoEntryKey The key of the repository entry
 * @param identityKey The user's id
 * @param request The HTTP request
 * @return
 */
@PUT
@Path("coaches/{identityKey}")
public Response addCoach(@PathParam("repoEntryKey") String repoEntryKey, @PathParam("identityKey") Long identityKey, @Context HttpServletRequest request) {
    try {
        RepositoryEntry repoEntry = lookupRepositoryEntry(repoEntryKey);
        if (repoEntry == null) {
            return Response.serverError().status(Status.NOT_FOUND).build();
        } else if (!isAuthorEditor(repoEntry, request)) {
            return Response.serverError().status(Status.UNAUTHORIZED).build();
        }
        Identity identityToAdd = securityManager.loadIdentityByKey(identityKey);
        if (identityToAdd == null) {
            return Response.serverError().status(Status.NOT_FOUND).build();
        }
        UserRequest ureq = RestSecurityHelper.getUserRequest(request);
        IdentitiesAddEvent iae = new IdentitiesAddEvent(identityToAdd);
        repositoryManager.addTutors(ureq.getIdentity(), ureq.getUserSession().getRoles(), iae, repoEntry, null);
        return Response.ok().build();
    } catch (Exception e) {
        log.error("Trying to add a coach to a repository entry", e);
        return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : IdentitiesAddEvent(org.olat.admin.securitygroup.gui.IdentitiesAddEvent) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) RestSecurityHelper.getIdentity(org.olat.restapi.security.RestSecurityHelper.getIdentity) RestSecurityHelper.getUserRequest(org.olat.restapi.security.RestSecurityHelper.getUserRequest) UserRequest(org.olat.core.gui.UserRequest) Path(javax.ws.rs.Path) PUT(javax.ws.rs.PUT)

Example 28 with IdentitiesAddEvent

use of org.olat.admin.securitygroup.gui.IdentitiesAddEvent in project openolat by klemens.

the class RepositoryEntryResource method addOwners.

@PUT
@Path("owners")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response addOwners(UserVO[] owners, @PathParam("repoEntryKey") String repoEntryKey, @Context HttpServletRequest request) {
    try {
        RepositoryEntry repoEntry = lookupRepositoryEntry(repoEntryKey);
        if (repoEntry == null) {
            return Response.serverError().status(Status.NOT_FOUND).build();
        } else if (!isAuthorEditor(repoEntry, request)) {
            return Response.serverError().status(Status.UNAUTHORIZED).build();
        }
        List<Identity> identityToAdd = loadIdentities(owners);
        UserRequest ureq = RestSecurityHelper.getUserRequest(request);
        IdentitiesAddEvent iae = new IdentitiesAddEvent(identityToAdd);
        repositoryManager.addOwners(ureq.getIdentity(), iae, repoEntry, new MailPackage(false));
        return Response.ok().build();
    } catch (Exception e) {
        log.error("Trying to add an owner to a repository entry", e);
        return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : MailPackage(org.olat.core.util.mail.MailPackage) IdentitiesAddEvent(org.olat.admin.securitygroup.gui.IdentitiesAddEvent) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) RestSecurityHelper.getIdentity(org.olat.restapi.security.RestSecurityHelper.getIdentity) RestSecurityHelper.getUserRequest(org.olat.restapi.security.RestSecurityHelper.getUserRequest) UserRequest(org.olat.core.gui.UserRequest) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) PUT(javax.ws.rs.PUT)

Example 29 with IdentitiesAddEvent

use of org.olat.admin.securitygroup.gui.IdentitiesAddEvent in project openolat by klemens.

the class RepositoryEntryResource method addCoach.

@PUT
@Path("coaches")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response addCoach(UserVO[] coaches, @PathParam("repoEntryKey") String repoEntryKey, @Context HttpServletRequest request) {
    try {
        RepositoryEntry repoEntry = lookupRepositoryEntry(repoEntryKey);
        if (repoEntry == null) {
            return Response.serverError().status(Status.NOT_FOUND).build();
        } else if (!isAuthorEditor(repoEntry, request)) {
            return Response.serverError().status(Status.UNAUTHORIZED).build();
        }
        List<Identity> identityToAdd = loadIdentities(coaches);
        UserRequest ureq = RestSecurityHelper.getUserRequest(request);
        IdentitiesAddEvent iae = new IdentitiesAddEvent(identityToAdd);
        repositoryManager.addTutors(ureq.getIdentity(), ureq.getUserSession().getRoles(), iae, repoEntry, null);
        return Response.ok().build();
    } catch (Exception e) {
        log.error("Trying to add a coach to a repository entry", e);
        return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : IdentitiesAddEvent(org.olat.admin.securitygroup.gui.IdentitiesAddEvent) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) RestSecurityHelper.getIdentity(org.olat.restapi.security.RestSecurityHelper.getIdentity) RestSecurityHelper.getUserRequest(org.olat.restapi.security.RestSecurityHelper.getUserRequest) UserRequest(org.olat.core.gui.UserRequest) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) PUT(javax.ws.rs.PUT)

Example 30 with IdentitiesAddEvent

use of org.olat.admin.securitygroup.gui.IdentitiesAddEvent in project openolat by klemens.

the class CourseWebService method addParticipants.

/**
 * Add an participant to the course
 * @response.representation.200.doc The user is a participant of the course
 * @response.representation.401.doc The roles of the authenticated user are not sufficient
 * @response.representation.404.doc The course or the user not found
 * @param identityKey The user identifier
 * @param httpRequest The HTTP request
 * @return It returns 200  if the user is added as owner and author of the course
 */
@PUT
@Path("participants")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response addParticipants(UserVO[] participants, @Context HttpServletRequest httpRequest) {
    if (!isAuthorEditor(course, httpRequest) && !isInstitutionalResourceManager(httpRequest)) {
        return Response.serverError().status(Status.UNAUTHORIZED).build();
    }
    List<Identity> participantList = loadIdentities(participants);
    Identity identity = getIdentity(httpRequest);
    UserRequest ureq = getUserRequest(httpRequest);
    // add the participants to the course
    RepositoryManager rm = RepositoryManager.getInstance();
    RepositoryEntry repositoryEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
    IdentitiesAddEvent iae = new IdentitiesAddEvent(participantList);
    rm.addParticipants(identity, ureq.getUserSession().getRoles(), iae, repositoryEntry, new MailPackage(false));
    return Response.ok().build();
}
Also used : MailPackage(org.olat.core.util.mail.MailPackage) IdentitiesAddEvent(org.olat.admin.securitygroup.gui.IdentitiesAddEvent) RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) RestSecurityHelper.getIdentity(org.olat.restapi.security.RestSecurityHelper.getIdentity) RestSecurityHelper.getUserRequest(org.olat.restapi.security.RestSecurityHelper.getUserRequest) UserRequest(org.olat.core.gui.UserRequest) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) PUT(javax.ws.rs.PUT)

Aggregations

IdentitiesAddEvent (org.olat.admin.securitygroup.gui.IdentitiesAddEvent)64 Identity (org.olat.core.id.Identity)50 RepositoryEntry (org.olat.repository.RepositoryEntry)44 PUT (javax.ws.rs.PUT)24 Path (javax.ws.rs.Path)24 RestSecurityHelper.getIdentity (org.olat.restapi.security.RestSecurityHelper.getIdentity)24 MailPackage (org.olat.core.util.mail.MailPackage)22 UserRequest (org.olat.core.gui.UserRequest)20 RestSecurityHelper.getUserRequest (org.olat.restapi.security.RestSecurityHelper.getUserRequest)20 URI (java.net.URI)16 HttpResponse (org.apache.http.HttpResponse)16 Test (org.junit.Test)16 IdentitiesRemoveEvent (org.olat.admin.securitygroup.gui.IdentitiesRemoveEvent)16 Consumes (javax.ws.rs.Consumes)12 RepositoryManager (org.olat.repository.RepositoryManager)12 ArrayList (java.util.ArrayList)8 HttpDelete (org.apache.http.client.methods.HttpDelete)8 HttpGet (org.apache.http.client.methods.HttpGet)8 BaseSecurity (org.olat.basesecurity.BaseSecurity)8 SecurityGroup (org.olat.basesecurity.SecurityGroup)8