Search in sources :

Example 76 with UserRequest

use of org.olat.core.gui.UserRequest in project OpenOLAT by OpenOLAT.

the class CourseDbWebService method deleteValue.

/**
 * Delete a value for an authenticated user.
 * @response.representation.200.doc the key value pair is remove from the db
 * @response.representation.401.doc The roles of the authenticated user are not sufficient
 * @response.representation.404.doc The entry cannot be found
 * @param courseId The course resourceable's id
 * @param category The name of the database
 * @param name The name of the key value pair
 * @param request The HTTP request
 * @return
 */
@DELETE
@Path("values/{name}")
public Response deleteValue(@PathParam("courseId") Long courseId, @PathParam("category") String category, @PathParam("name") String name, @Context HttpServletRequest request) {
    Roles roles = RestSecurityHelper.getRoles(request);
    if (roles.isAuthor() || roles.isOLATAdmin()) {
        ICourse course = loadCourse(courseId);
        UserRequest ureq = RestSecurityHelper.getUserRequest(request);
        boolean ok = CoreSpringFactory.getImpl(CourseDBManager.class).deleteValue(course, ureq.getIdentity(), category, name);
        if (ok) {
            return Response.ok().build();
        }
        return Response.serverError().status(Status.NOT_FOUND).build();
    }
    return Response.serverError().status(Status.UNAUTHORIZED).build();
}
Also used : CourseDBManager(org.olat.course.db.CourseDBManager) Roles(org.olat.core.id.Roles) ICourse(org.olat.course.ICourse) UserRequest(org.olat.core.gui.UserRequest) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 77 with UserRequest

use of org.olat.core.gui.UserRequest in project OpenOLAT by OpenOLAT.

the class CourseDbWebService method internPutValue.

private Response internPutValue(Long courseId, String category, String name, Object value, HttpServletRequest request) {
    ICourse course = loadCourse(courseId);
    UserRequest ureq = RestSecurityHelper.getUserRequest(request);
    CourseDBEntry entry = CoreSpringFactory.getImpl(CourseDBManager.class).setValue(course, ureq.getIdentity(), category, name, value);
    if (entry == null) {
        return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build();
    }
    return Response.ok().build();
}
Also used : CourseDBManager(org.olat.course.db.CourseDBManager) ICourse(org.olat.course.ICourse) UserRequest(org.olat.core.gui.UserRequest) CourseDBEntry(org.olat.course.db.CourseDBEntry)

Example 78 with UserRequest

use of org.olat.core.gui.UserRequest in project OpenOLAT by OpenOLAT.

the class AbstractBusinessGroupListController method doEmails.

/**
 * @param ureq
 * @param items
 */
private void doEmails(UserRequest ureq, List<? extends BusinessGroupRef> selectedItems) {
    removeAsListenerAndDispose(emailWizard);
    if (selectedItems == null || selectedItems.isEmpty()) {
        showWarning("error.select.one");
        return;
    }
    List<BusinessGroup> groups = toBusinessGroups(ureq, selectedItems, true);
    if (groups.isEmpty()) {
        showWarning("msg.alleastone.editable.group");
        return;
    }
    if (selectedItems.size() != groups.size()) {
        showWarning("msg.only.editable.group");
        return;
    }
    Step start = new BGEmailSelectReceiversStep(ureq, groups);
    StepRunnerCallback finish = new StepRunnerCallback() {

        @Override
        public Step execute(UserRequest uureq, WindowControl wControl, StepsRunContext runContext) {
            // mails are send by the last controller of the wizard
            return StepsMainRunController.DONE_MODIFIED;
        }
    };
    emailWizard = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("email.group"), "o_sel_groups_email_wizard");
    listenTo(emailWizard);
    getWindowControl().pushAsModalDialog(emailWizard.getInitialComponent());
}
Also used : BGCopyBusinessGroup(org.olat.group.ui.wizard.BGCopyBusinessGroup) BGConfigBusinessGroup(org.olat.group.ui.wizard.BGConfigBusinessGroup) BusinessGroup(org.olat.group.BusinessGroup) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) Step(org.olat.core.gui.control.generic.wizard.Step) BGCopyPreparationStep(org.olat.group.ui.wizard.BGCopyPreparationStep) BGMergeStep(org.olat.group.ui.wizard.BGMergeStep) BGConfigToolsStep(org.olat.group.ui.wizard.BGConfigToolsStep) BGEmailSelectReceiversStep(org.olat.group.ui.wizard.BGEmailSelectReceiversStep) WindowControl(org.olat.core.gui.control.WindowControl) StepsRunContext(org.olat.core.gui.control.generic.wizard.StepsRunContext) BGEmailSelectReceiversStep(org.olat.group.ui.wizard.BGEmailSelectReceiversStep) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback) UserRequest(org.olat.core.gui.UserRequest)

Example 79 with UserRequest

use of org.olat.core.gui.UserRequest in project OpenOLAT by OpenOLAT.

the class AbstractBusinessGroupListController method doCopy.

/**
 * Make copies of a list of business groups
 * @param ureq
 * @param items
 */
private void doCopy(UserRequest ureq, List<? extends BusinessGroupRef> items) {
    removeAsListenerAndDispose(businessGroupWizard);
    if (items == null || items.isEmpty()) {
        showWarning("error.select.one");
        return;
    }
    List<BusinessGroup> groups = toBusinessGroups(ureq, items, true);
    if (groups.isEmpty()) {
        showWarning("msg.alleastone.editable.group");
        return;
    }
    if (items.size() != groups.size()) {
        showWarning("msg.only.editable.group");
        return;
    }
    boolean enableCoursesCopy = businessGroupService.hasResources(groups);
    boolean enableAreasCopy = areaManager.countBGAreasOfBusinessGroups(groups) > 0;
    boolean enableRightsCopy = rightManager.hasBGRight(groups);
    Step start = new BGCopyPreparationStep(ureq, groups, enableCoursesCopy, enableAreasCopy, enableRightsCopy);
    StepRunnerCallback finish = new StepRunnerCallback() {

        @Override
        public Step execute(UserRequest uureq, WindowControl wControl, StepsRunContext runContext) {
            @SuppressWarnings("unchecked") List<BGCopyBusinessGroup> copies = (List<BGCopyBusinessGroup>) runContext.get("groupsCopy");
            if (copies != null && !copies.isEmpty()) {
                boolean copyAreas = convertToBoolean(runContext, "areas");
                boolean copyCollabToolConfig = convertToBoolean(runContext, "tools");
                boolean copyRights = convertToBoolean(runContext, "rights");
                boolean copyOwners = convertToBoolean(runContext, "owners");
                boolean copyParticipants = convertToBoolean(runContext, "participants");
                boolean copyMemberVisibility = convertToBoolean(runContext, "membersvisibility");
                boolean copyWaitingList = convertToBoolean(runContext, "waitingList");
                boolean copyRelations = convertToBoolean(runContext, "resources");
                for (BGCopyBusinessGroup copy : copies) {
                    businessGroupService.copyBusinessGroup(getIdentity(), copy.getOriginal(), copy.getName(), copy.getDescription(), copy.getMinParticipants(), copy.getMaxParticipants(), copyAreas, copyCollabToolConfig, copyRights, copyOwners, copyParticipants, copyMemberVisibility, copyWaitingList, copyRelations);
                }
                return StepsMainRunController.DONE_MODIFIED;
            } else {
                return StepsMainRunController.DONE_UNCHANGED;
            }
        }
    };
    businessGroupWizard = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("copy.group"), "o_sel_group_copy_wizard");
    listenTo(businessGroupWizard);
    getWindowControl().pushAsModalDialog(businessGroupWizard.getInitialComponent());
}
Also used : BGCopyBusinessGroup(org.olat.group.ui.wizard.BGCopyBusinessGroup) BGCopyBusinessGroup(org.olat.group.ui.wizard.BGCopyBusinessGroup) BGConfigBusinessGroup(org.olat.group.ui.wizard.BGConfigBusinessGroup) BusinessGroup(org.olat.group.BusinessGroup) BGCopyPreparationStep(org.olat.group.ui.wizard.BGCopyPreparationStep) Step(org.olat.core.gui.control.generic.wizard.Step) BGCopyPreparationStep(org.olat.group.ui.wizard.BGCopyPreparationStep) BGMergeStep(org.olat.group.ui.wizard.BGMergeStep) BGConfigToolsStep(org.olat.group.ui.wizard.BGConfigToolsStep) BGEmailSelectReceiversStep(org.olat.group.ui.wizard.BGEmailSelectReceiversStep) WindowControl(org.olat.core.gui.control.WindowControl) StepsRunContext(org.olat.core.gui.control.generic.wizard.StepsRunContext) ContactList(org.olat.core.util.mail.ContactList) List(java.util.List) ArrayList(java.util.ArrayList) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback) UserRequest(org.olat.core.gui.UserRequest)

Example 80 with UserRequest

use of org.olat.core.gui.UserRequest in project OpenOLAT by OpenOLAT.

the class AbstractBusinessGroupListController method doMerge.

/**
 * @param ureq
 * @param items
 */
private void doMerge(UserRequest ureq, List<? extends BusinessGroupRef> selectedItems) {
    removeAsListenerAndDispose(businessGroupWizard);
    if (selectedItems == null || selectedItems.size() < 2) {
        showWarning("error.select.one");
        return;
    }
    final List<BusinessGroup> groups = toBusinessGroups(ureq, selectedItems, true);
    if (groups.size() < 2) {
        showWarning("msg.alleasttwo.editable.group");
        return;
    }
    if (selectedItems.size() != groups.size()) {
        showWarning("msg.only.editable.group");
        return;
    }
    StringBuilder managedNames = new StringBuilder();
    for (BusinessGroup group : groups) {
        String gname = group.getName() == null ? "???" : StringHelper.escapeHtml(group.getName());
        if (StringHelper.containsNonWhitespace(group.getManagedFlagsString())) {
            if (managedNames.length() > 0)
                managedNames.append(", ");
            managedNames.append(gname);
        }
    }
    if (managedNames.length() > 0) {
        showWarning("error.managed.group", managedNames.toString());
        return;
    }
    Step start = new BGMergeStep(ureq, groups);
    StepRunnerCallback finish = new StepRunnerCallback() {

        @Override
        public Step execute(UserRequest uureq, WindowControl wControl, StepsRunContext runContext) {
            BusinessGroup targetGroup = (BusinessGroup) runContext.get("targetGroup");
            groups.remove(targetGroup);
            businessGroupService.mergeBusinessGroups(getIdentity(), targetGroup, groups, null);
            return StepsMainRunController.DONE_MODIFIED;
        }
    };
    businessGroupWizard = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("merge.group"), "o_sel_groups_merge_wizard");
    listenTo(businessGroupWizard);
    getWindowControl().pushAsModalDialog(businessGroupWizard.getInitialComponent());
}
Also used : BGCopyBusinessGroup(org.olat.group.ui.wizard.BGCopyBusinessGroup) BGConfigBusinessGroup(org.olat.group.ui.wizard.BGConfigBusinessGroup) BusinessGroup(org.olat.group.BusinessGroup) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) Step(org.olat.core.gui.control.generic.wizard.Step) BGCopyPreparationStep(org.olat.group.ui.wizard.BGCopyPreparationStep) BGMergeStep(org.olat.group.ui.wizard.BGMergeStep) BGConfigToolsStep(org.olat.group.ui.wizard.BGConfigToolsStep) BGEmailSelectReceiversStep(org.olat.group.ui.wizard.BGEmailSelectReceiversStep) WindowControl(org.olat.core.gui.control.WindowControl) StepsRunContext(org.olat.core.gui.control.generic.wizard.StepsRunContext) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback) UserRequest(org.olat.core.gui.UserRequest) BGMergeStep(org.olat.group.ui.wizard.BGMergeStep)

Aggregations

UserRequest (org.olat.core.gui.UserRequest)314 WindowControl (org.olat.core.gui.control.WindowControl)154 Identity (org.olat.core.id.Identity)92 ControllerCreator (org.olat.core.gui.control.creator.ControllerCreator)74 RestSecurityHelper.getUserRequest (org.olat.restapi.security.RestSecurityHelper.getUserRequest)68 Path (javax.ws.rs.Path)64 StepsMainRunController (org.olat.core.gui.control.generic.wizard.StepsMainRunController)64 Controller (org.olat.core.gui.control.Controller)62 RepositoryEntry (org.olat.repository.RepositoryEntry)58 Step (org.olat.core.gui.control.generic.wizard.Step)56 StepRunnerCallback (org.olat.core.gui.control.generic.wizard.StepRunnerCallback)56 StepsRunContext (org.olat.core.gui.control.generic.wizard.StepsRunContext)56 ArrayList (java.util.ArrayList)46 ICourse (org.olat.course.ICourse)44 Produces (javax.ws.rs.Produces)40 List (java.util.List)36 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)36 PUT (javax.ws.rs.PUT)32 UserRequestImpl (org.olat.core.gui.UserRequestImpl)30 RestSecurityHelper.getIdentity (org.olat.restapi.security.RestSecurityHelper.getIdentity)30