org.apache.struts.util.MessageResources Java Examples
The following examples show how to use
org.apache.struts.util.MessageResources.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TargetForm.java From openemm with GNU Affero General Public License v3.0 | 6 votes |
/** * Reset all properties to their default values. * * @param mapping The mapping used to select this instance * @param request The servlet request we are processing */ @Override public void reset(ActionMapping mapping, HttpServletRequest request) { super.reset(mapping, request); this.targetID = 0; this.action = StrutsActionBase.ACTION_SAVE; Locale aLoc = AgnUtils.getLocale(request); MessageResources text=(MessageResources)this.getServlet().getServletContext().getAttribute(org.apache.struts.Globals.MESSAGES_KEY); //MessageResources text=this.getServlet().getResources(); this.shortname = text.getMessage(aLoc, "default.Name"); this.description = text.getMessage(aLoc, "default.description"); this.isShowStatistic = false; // Reset form fields for new rule clearNewRuleData(); }
Example #2
Source File: SalutationForm.java From openemm with GNU Affero General Public License v3.0 | 6 votes |
/** * Validate the properties that have been set from this HTTP request, * and return an <code>ActionErrors</code> object that encapsulates any * validation errors that have been found. If no errors are found, return * <code>null</code> or an <code>ActionErrors</code> object with no * recorded error messages. * * @param mapping The mapping used to select this instance * @param request The servlet request we are processing * @return errors */ @Override public ActionErrors formSpecificValidate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if (action == SalutationAction.ACTION_SAVE || action == SalutationAction.ACTION_NEW) { if (StringUtils.isEmpty(shortname) || shortname.length() < 3) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.name.too.short")); } } if (action == SalutationAction.ACTION_VIEW && salutationID == 0) { Locale aLoc = AgnUtils.getLocale(request); MessageResources text=(MessageResources)this.getServlet().getServletContext().getAttribute(org.apache.struts.Globals.MESSAGES_KEY); this.shortname=text.getMessage(aLoc, "default.salutation.shortname"); this.description=text.getMessage(aLoc, "default.salutation.description"); } return errors; }
Example #3
Source File: ForunsManagement.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 6 votes |
private LocalizedString getQuotationText(HttpServletRequest request) { String quotedMessageId = this.getQuotedMessageId(request); String quotationText = null; if (quotedMessageId != null) { MessageResources resources = this.getResources(request, "MESSAGING_RESOURCES"); ConversationMessage message = (ConversationMessage) FenixFramework.getDomainObject(quotedMessageId); String author = message.getCreator().getName() + " (" + message.getCreator().getUsername() + ")"; quotationText = resources.getMessage(this.getLocale(request), "messaging.viewThread.quotationText", author, message.getBody() .getContent()); } return new LocalizedString(I18N.getLocale(), quotationText); }
Example #4
Source File: EvaluationManagementBackingBean.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 6 votes |
public String publishMarks() { final MessageResources messages = MessageResources.getMessageResources(Bundle.APPLICATION); final String announcementTitle = (getPublishMarksMessage() != null && getPublishMarksMessage().length() > 0) ? messages .getMessage("message.publishment") : null; try { PublishMarks.runPublishMarks(this.getExecutionCourseID(), this.getEvaluationID(), this.getPublishMarksMessage(), this.getSendSMS(), announcementTitle); } catch (Exception e) { this.setErrorMessage(e.getMessage()); return ""; } return this.getEvaluation().getClass().getSimpleName(); }
Example #5
Source File: PaymentPhase.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 5 votes |
public String getDescriptionFromMessageResourses() { MessageResources messages = MessageResources.getMessageResources(Bundle.APPLICATION); String newDescription = null; newDescription = messages.getMessage(super.getDescription()); if (newDescription == null) { newDescription = super.getDescription(); } return newDescription; }
Example #6
Source File: SOPEvaluationManagementBackingBean.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 5 votes |
public List<SelectItem> getOrderByCriteriaItems() { MessageResources messageResources = MessageResources.getMessageResources(Bundle.RESOURCE_ALLOCATION); List<SelectItem> orderByCriteriaItems = new ArrayList<SelectItem>(3); orderByCriteriaItems.add(new SelectItem(0, messageResources.getMessage("label.capacity"))); orderByCriteriaItems.add(new SelectItem(1, messageResources.getMessage("property.room.building"))); orderByCriteriaItems.add(new SelectItem(2, messageResources.getMessage("label.room.type"))); return orderByCriteriaItems; }
Example #7
Source File: KualiPropertyMessageResourcesFactory.java From rice with Educational Community License v2.0 | 5 votes |
/** * Uses KualiPropertyMessageResources, which allows multiple property files to be loaded into the default message * set * * @see org.apache.struts.util.MessageResourcesFactory#createResources(java.lang.String) */ @Override public MessageResources createResources(String config) { if (StringUtils.isBlank(config)) { final String propertyConfig = (String) ConfigContext.getCurrentContextConfig().getProperties().get( KRADConstants.MESSAGE_RESOURCES); config = removeSpacesAround(propertyConfig); } return new KualiPropertyMessageResources(this, config, this.returnNull); }
Example #8
Source File: KFSMessageResourcesFactory.java From kfs with GNU Affero General Public License v3.0 | 5 votes |
/** * Uses KFSPropertyMessageResources, which allows multiple property files to be loaded into the defalt message set. * * @see org.apache.struts.util.MessageResourcesFactory#createResources(java.lang.String) */ @Override public MessageResources createResources(String config) { if (StringUtils.isBlank(config)) { config = PropertyLoadingFactoryBean.getBaseProperty("struts.message.resources"); } return new KFSPropertyMessageResources(this, config, this.returnNull); }
Example #9
Source File: BackTracker.java From unitime with Apache License 2.0 | 5 votes |
public static String getBackButton(HttpServletRequest request, int nrBackSteps, String name, String title, String accessKey, String style, String clazz, String backType, String backId) { MessageResources rsc = getResources(request); if (rsc!=null && rsc.getMessage(name)!=null) { name = rsc.getMessage(name); } synchronized (request.getSession()) { Vector backList = getBackList(request.getSession()); if (backList.size()<nrBackSteps) return ""; String[] backItem = (String[])backList.elementAt(backList.size()-nrBackSteps); if (backItem[1]!=null) title = title.replaceAll("%%", backItem[1]); String backUrl = backItem[0]; if (backId!=null && backType!=null) { if (backUrl.indexOf('?')>0) backUrl += "&backType="+backType+"&backId="+backId+"#back"; else backUrl += "?backType="+backType+"&backId="+backId+"#back"; } return "<input type='button'"+ " value='"+name+"' "+ (accessKey==null?"":" accesskey=\""+accessKey+"\"")+ (style==null?"":" style=\""+style+"\"")+ (clazz==null?"":" class=\""+clazz+"\"")+ " title=\""+title+"\""+ " onClick=\"document.location='back.do?uri="+encodeURL(backUrl)+"'"+ ";\""+ "/>"; } }
Example #10
Source File: SpringAwareLookupDispatchAction.java From unitime with Apache License 2.0 | 5 votes |
@Override protected MessageResources getResources(HttpServletRequest request, String key) { // Identify the current module, the right way ServletContext context = request.getSession().getServletContext(); ModuleConfig moduleConfig = ModuleUtils.getInstance().getModuleConfig(request, context); // Return the requested message resources instance return (MessageResources) context.getAttribute(key + moduleConfig.getPrefix()); }
Example #11
Source File: ExamDistributionPrefsForm.java From unitime with Apache License 2.0 | 5 votes |
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); // Get Message Resources MessageResources rsc = (MessageResources) super.getServlet() .getServletContext().getAttribute(Globals.MESSAGES_KEY); // Distribution Type must be selected if(distType==null || distType.equals(Preference.BLANK_PREF_VALUE)) { errors.add("distType", new ActionMessage( "errors.generic", "Select a distribution type. ") ); } // Distribution Pref Level must be selected if(prefLevel==null || prefLevel.equals(Preference.BLANK_PREF_VALUE)) { errors.add("prefLevel", new ActionMessage( "errors.generic", "Select a preference level. ") ); } // Save/Update clicked if(op.equals(rsc.getMessage("button.addNew")) || op.equals(rsc.getMessage("button.update")) ) { } return errors; }
Example #12
Source File: AddSpecialUseRoomAction.java From unitime with Apache License 2.0 | 4 votes |
/** * Method execute * @param mapping * @param form * @param request * @param response * @return ActionForward * @throws Exception */ public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { SpecialUseRoomForm specialUseRoomForm = (SpecialUseRoomForm) form; MessageResources rsc = getResources(request); ActionMessages errors = new ActionMessages(); sessionContext.checkPermission(Right.AddSpecialUseRoom); Set<Department> departments = Department.getUserDepartments(sessionContext.getUser()); List<Building> buildings = Building.findAll(sessionContext.getUser().getCurrentAcademicSessionId()); if (specialUseRoomForm.getDoit() != null) { String doit = specialUseRoomForm.getDoit(); if (doit.equals(rsc.getMessage("button.returnToRoomList"))) { return mapping.findForward("showRoomList"); } if (doit.equals(rsc.getMessage("button.addNew"))) { // Validate input prefs errors = specialUseRoomForm.validate(mapping, request); // No errors if (errors.isEmpty()) { String forward = update(request, specialUseRoomForm); if (forward != null) return mapping.findForward(forward); } else { saveErrors(request, errors); } } } setup(request, departments, buildings); //set default department specialUseRoomForm.setDeptSize(departments.size()); if (departments.size() == 1) { Department d = departments.iterator().next(); specialUseRoomForm.setDeptCode(d.getDeptCode()); } else if (sessionContext.getAttribute(SessionAttribute.DepartmentCodeRoom) != null) { specialUseRoomForm.setDeptCode((String)sessionContext.getAttribute(SessionAttribute.DepartmentCodeRoom)); } return mapping.findForward("showAdd"); }
Example #13
Source File: DBMessagesResourceFactory.java From openemm with GNU Affero General Public License v3.0 | 4 votes |
@Override public MessageResources createResources(String configuration) { DBMessagesResourceWrapperForStruts dbMessagesResource = new DBMessagesResourceWrapperForStruts(this, configuration); dbMessagesResource.init(); return dbMessagesResource; }
Example #14
Source File: InstructionalOfferingConfigEditForm.java From unitime with Apache License 2.0 | 4 votes |
/** * Method validate * @param mapping * @param request * @return ActionErrors */ public ActionErrors validate( ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); // Get Message Resources MessageResources rsc = (MessageResources) super.getServlet() .getServletContext().getAttribute(Globals.MESSAGES_KEY); // Check limit in all cases if(limit<0) { errors.add("limit", new ActionMessage("errors.integerGtEq", "Limit", "0")); } String lblMax = "Limit"; if (request.getParameter("varLimits")!=null) { lblMax = "Max limit"; } // Check Itype is specified if(op.equals(rsc.getMessage("button.add"))) { if(itype==null || itype.trim().length()==0 || itype.equals(Constants.BLANK_OPTION_VALUE)) { errors.add("itype", new ActionMessage("errors.required", "Instructional Type")); } } if( op.equals(MSG.actionSaveConfiguration()) || op.equals(MSG.actionUpdateConfiguration()) ) { HttpSession webSession = request.getSession(); Vector sp = (Vector) webSession.getAttribute(SimpleItypeConfig.CONFIGS_ATTR_NAME); // Check that config name doesn't already exist InstructionalOffering io = new InstructionalOfferingDAO().get( new Long(this.getInstrOfferingId()) ); if (io.existsConfig(this.getName(), this.getConfigId())) { errors.add("subparts", new ActionMessage("errors.generic", "A configuration with this name already exists in this offering. Use a unique name")); } // Read user defined config for(int i=0; i<sp.size(); i++) { SimpleItypeConfig sic = (SimpleItypeConfig) sp.elementAt(i); // Check top level subparts if (!this.getUnlimited().booleanValue() && ApplicationProperty.ConfigEditCheckLimits.isTrue()) { int numClasses = sic.getNumClasses(); int maxLimitPerClass = sic.getMaxLimitPerClass(); if (numClasses == 1 && maxLimitPerClass!=this.limit) { sic.setHasError(true); errors.add("subparts", new ActionMessage("errors.equal", lblMax + " per class for <u>" + sic.getItype().getDesc() + "</u>", "Configuration limit of " + this.limit ) ); } if (numClasses>1 && (maxLimitPerClass*numClasses)<this.limit) { sic.setHasError(true); errors.add("subparts", new ActionMessage("errors.integerGtEq", "Sum of class limits <u>" + sic.getItype().getDesc() + "</u>", "Configuration limit of " + this.limit ) ); } } // Check input text fields checkInputfields(request, errors, sic, lblMax, this.getUnlimited().booleanValue()); // Check child subparts short errCode = checkChildSubpart(request, errors, sic, lblMax, this.getUnlimited().booleanValue()); if(errCode!=NO_ERR) { String errM = "Subparts that are grouped under <u>" + sic.getItype().getDesc() + "</u> must <br>"; if (errCode==ERR_NC) errM += " have number of classes that is a multiple of " + sic.getNumClasses() + "."; if (errCode==ERR_CL) errM += " have a " + lblMax.toLowerCase() + " per class <= " + lblMax.toLowerCase() + " per class of " + sic.getMaxLimitPerClass() + "."; if (errCode==ERR_LS) errM += " not accomodate lesser number of students."; errors.add("subparts", new ActionMessage("errors.generic", errM ) ); } } } return errors; }
Example #15
Source File: TimetableManagerForm.java From unitime with Apache License 2.0 | 4 votes |
public ActionErrors validate( ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); // Get Message Resources MessageResources rsc = (MessageResources) super.getServlet() .getServletContext().getAttribute(Globals.MESSAGES_KEY); if (op.equalsIgnoreCase(rsc.getMessage("button.addRole"))) { if (role.equals(Constants.BLANK_OPTION_VALUE)) errors.add("role", new ActionMessage("errors.invalid", "Role")); } if (op.equalsIgnoreCase(rsc.getMessage("button.addDepartment"))) { if (dept.equals(Constants.BLANK_OPTION_VALUE)) errors.add("dept", new ActionMessage("errors.invalid", "Department")); } if (op.equalsIgnoreCase(rsc.getMessage("button.addSolverGroup"))) { if (solverGr.equals(Constants.BLANK_OPTION_VALUE)) errors.add("solverGr", new ActionMessage("errors.invalid", "Solver Group")); } if (op.equalsIgnoreCase(rsc.getMessage("button.insertTimetableManager")) || op.equalsIgnoreCase(rsc.getMessage("button.updateTimetableManager")) ) { if (externalId==null || externalId.trim().length()==0) errors.add("externalId", new ActionMessage("errors.required", "External ID")); /* if (User.canIdentify()) { User user = User.identify(externalId); if (user==null) errors.add("externalId", new ActionMessage("errors.generic", "Manager '" + externalId + "' cannot be identified")); } */ if (email==null || email.trim().length()==0) errors.add("email", new ActionMessage("errors.required", "Email Address")); if (primaryRole==null || primaryRole.trim().length()==0) errors.add("primaryRole", new ActionMessage("errors.required", "Primary Role")); /* if(depts.size()==0) { Roles deptRole = Roles.getRole(Roles.DEPT_SCHED_MGR_ROLE); if (deptRole!=null && roles.contains(deptRole.getRoleId().toString())) errors.add("depts", new ActionMessage("errors.generic", "At least one department must be assigned for role "+deptRole.getAbbv())); } */ if(roles.size()==0) errors.add("roles", new ActionMessage("errors.generic", "At least one role must be assigned")); if (externalId!=null && externalId.trim().length()>0) { TimetableManager mgr = TimetableManager.findByExternalId(externalId); if (mgr!=null && !mgr.getUniqueId().toString().equals(getUniqueId())) errors.add("roles", new ActionMessage("errors.generic", "Duplicate Record - This manager already exists")); } if (!lookupEnabled) { if (firstName == null || firstName.isEmpty()) { errors.add("firstName", new ActionMessage("errors.required", "First Name")); } if (lastName == null || lastName.isEmpty()) { errors.add("lastName", new ActionMessage("errors.required", "Last Name")); } } } return errors; }
Example #16
Source File: SubjectAreaEditAction.java From unitime with Apache License 2.0 | 4 votes |
/** * Method execute * @param mapping * @param form * @param request * @param response * @return ActionForward */ public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Check Access sessionContext.checkPermission(Right.SubjectAreas); SubjectAreaEditForm frm = (SubjectAreaEditForm) form; MessageResources rsc = getResources(request); ActionMessages errors=null; // Read operation to be performed String op = (frm.getOp()!=null ? frm.getOp() : request.getParameter("op")); // Add if(op.equals(rsc.getMessage("button.addSubjectArea"))) { sessionContext.checkPermission(Right.SubjectAreaAdd); LookupTables.setupNonExternalDepts(request, sessionContext.getUser().getCurrentAcademicSessionId()); return mapping.findForward("addSubjectArea"); } // Edit if(op.equals(rsc.getMessage("op.edit"))) { doLoad(request, frm); LookupTables.setupNonExternalDepts(request, sessionContext.getUser().getCurrentAcademicSessionId()); return mapping.findForward("editSubjectArea"); } // Update if (op.equals(rsc.getMessage("button.updateSubjectArea")) || op.equals(rsc.getMessage("button.saveSubjectArea")) ) { // Validate input errors = frm.validate(mapping, request); if(errors.size()==0) { doUpdate(request, frm); } } // Delete if(op.equals(rsc.getMessage("button.deleteSubjectArea"))) { errors = frm.validate(mapping, request); if(errors.size()==0) { doDelete(request, frm); } } if (frm.getUniqueId()!=null) request.setAttribute(Constants.JUMP_TO_ATTR_NAME, frm.getUniqueId().toString()); if (errors!=null && errors.size()>0) { saveErrors(request, errors); LookupTables.setupNonExternalDepts(request, sessionContext.getUser().getCurrentAcademicSessionId()); if (frm.getUniqueId()!=null) return mapping.findForward("editSubjectArea"); else return mapping.findForward("addSubjectArea"); } return mapping.findForward("back"); }
Example #17
Source File: ChameleonAction.java From unitime with Apache License 2.0 | 4 votes |
/** * Method execute * @param mapping * @param form * @param request * @param response * @return ActionForward */ public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { UserContext user = sessionContext.getUser(); if (user != null && user instanceof UserContext.Chameleon) user = ((UserContext.Chameleon)user).getOriginalUserContext(); else sessionContext.checkPermission(Right.Chameleon); MessageResources rsc = getResources(request); ChameleonForm frm = (ChameleonForm) form; frm.setCanLookup(sessionContext.hasPermission(Right.HasRole)); ActionMessages errors = new ActionMessages(); String op = (request.getParameter("op")==null) ? (frm.getOp()==null || frm.getOp().length()==0) ? (request.getAttribute("op")==null) ? null : request.getAttribute("op").toString() : frm.getOp() : request.getParameter("op"); if(op==null || op.trim().length()==0) op = rsc.getMessage("op.view"); frm.setOp(op); // Lookup String uid = request.getParameter("uid"); if (uid != null && !uid.isEmpty() && ApplicationProperty.ChameleonAllowLookup.isTrue()) { frm.setPuid(uid); frm.setName(request.getParameter("uname")); op = rsc.getMessage("button.changeUser"); } // First Access - display blank form if ( op.equals(rsc.getMessage("op.view")) ) { LookupTables.setupTimetableManagers(request); if (user != null) frm.setPuid(user.getExternalUserId()); } // Change User if ( op.equals(rsc.getMessage("button.changeUser")) ) { try { doSwitch(request, frm, user); return mapping.findForward("reload"); } catch(Exception e) { Debug.error(e); errors.add("exception", new ActionMessage("errors.generic", e.getMessage()) ); saveErrors(request, errors); LookupTables.setupTimetableManagers(request); return mapping.findForward("displayForm"); } } return mapping.findForward("displayForm"); }
Example #18
Source File: BackTracker.java From unitime with Apache License 2.0 | 4 votes |
protected static MessageResources getResources(HttpServletRequest request) { return ((MessageResources) request.getAttribute(Globals.MESSAGES_KEY)); }
Example #19
Source File: DepartmentEditAction.java From unitime with Apache License 2.0 | 4 votes |
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { try { DepartmentEditForm myForm = (DepartmentEditForm) form; MessageResources rsc = getResources(request); // Check Access sessionContext.checkPermission(Right.Departments); // Read operation to be performed String op = (myForm.getOp()!=null?myForm.getOp():request.getParameter("op")); request.setAttribute(Department.DEPT_ATTR_NAME, Department.findAllNonExternal(sessionContext.getUser().getCurrentAcademicSessionId())); // Edit if(rsc.getMessage("op.edit").equalsIgnoreCase(op)) { String id = request.getParameter("id"); Department department = (new DepartmentDAO()).get(Long.valueOf(id)); if (department!=null) { if (sessionContext.hasPermission(department, Right.DepartmentLimitedEdit)) { myForm.setFullyEditable(false); } else { myForm.setFullyEditable(true); sessionContext.checkPermission(department, Right.DepartmentEdit); } myForm.load(department); return mapping.findForward("edit"); } } // Add if(rsc.getMessage("button.addDepartment").equalsIgnoreCase(op)) { myForm.reset(mapping, request); myForm.setSessionId(sessionContext.getUser().getCurrentAcademicSessionId()); myForm.setInheritInstructorPreferences(true); myForm.setAllowStudentScheduling(true); myForm.setFullyEditable(true); sessionContext.checkPermission(Right.DepartmentAdd); return mapping.findForward("add"); } // Update/Save if (rsc.getMessage("button.updateDepartment").equalsIgnoreCase(op) || rsc.getMessage("button.saveDepartment").equalsIgnoreCase(op)) { // Validate input ActionMessages errors = myForm.validate(mapping, request); if(errors.size()>0) { saveErrors(request, errors); if (myForm.getId()!=null) return mapping.findForward("edit"); else return mapping.findForward("add"); } else { if (myForm.getId() == null || myForm.getId().equals(0l)) sessionContext.checkPermission(Right.DepartmentAdd); else if (!myForm.isFullyEditable()) sessionContext.checkPermission(myForm.getId(), "Department", Right.DepartmentLimitedEdit); else sessionContext.checkPermission(myForm.getId(), "Department", Right.DepartmentEdit); myForm.save(sessionContext); } } if ("Add Status".equals(op)) { myForm.addBlankDependentDepartment(); return mapping.findForward(myForm.getId() == null ? "add" : "edit"); } if ("Delete All".equals(op)) { myForm.deleteAllDependentDepartments(); return mapping.findForward(myForm.getId() == null ? "add" : "edit"); } if ("Delete".equals(op) && request.getParameter("deleteId") != null && !request.getParameter("deleteId").isEmpty()) { myForm.deleteDependentDepartment(Integer.parseInt(request.getParameter("deleteId"))); return mapping.findForward(myForm.getId() == null ? "add" : "edit"); } // Delete if(rsc.getMessage("button.deleteDepartment").equalsIgnoreCase(op)) { doDelete(myForm); } if (myForm.getId()!=null) request.setAttribute(Constants.JUMP_TO_ATTR_NAME, myForm.getId().toString()); return mapping.findForward("back"); } catch (Exception e) { Debug.error(e); throw e; } }
Example #20
Source File: AddNonUnivLocationAction.java From unitime with Apache License 2.0 | 4 votes |
/** * Method execute * @param mapping * @param form * @param request * @param response * @return ActionForward * @throws Exception */ public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { NonUnivLocationForm nonUnivLocationForm = (NonUnivLocationForm) form; MessageResources rsc = getResources(request); ActionMessages errors = new ActionMessages(); sessionContext.checkPermission(Right.AddNonUnivLocation); Set<Department> departments = Department.getUserDepartments(sessionContext.getUser()); if (nonUnivLocationForm.getDoit() != null) { String doit = nonUnivLocationForm.getDoit(); if (doit.equals(rsc.getMessage("button.returnToRoomList"))) { return mapping.findForward("showRoomList"); } if (doit.equals(rsc.getMessage("button.addNew"))) { // Validate input prefs errors = nonUnivLocationForm.validate(mapping, request); if (errors.isEmpty() && !sessionContext.hasPermission(nonUnivLocationForm.getDeptCode(), "Department", Right.AddNonUnivLocation)) { errors.add("nonUniversityLocation", new ActionMessage("errors.generic", "Acess denied.")); } // No errors if(errors.size()==0) { update(request, nonUnivLocationForm); return mapping.findForward("showRoomList"); } else { setDepts(request, departments); saveErrors(request, errors); return mapping.findForward("showAdd"); } } } setDepts(request, departments); nonUnivLocationForm.setDeptSize(departments.size()); if (departments.size() == 1) { Department d = departments.iterator().next(); nonUnivLocationForm.setDeptCode(d.getDeptCode()); } else if (sessionContext.getAttribute(SessionAttribute.DepartmentCodeRoom) != null) { nonUnivLocationForm.setDeptCode((String) sessionContext.getAttribute(SessionAttribute.DepartmentCodeRoom)); } return mapping.findForward("showAdd"); }
Example #21
Source File: RoomGroupAddAction.java From unitime with Apache License 2.0 | 4 votes |
/** * Method execute * @param mapping * @param form * @param request * @param response * @return ActionForward */ public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception{ RoomGroupEditForm roomGroupEditForm = (RoomGroupEditForm) form; MessageResources rsc = getResources(request); String doit = roomGroupEditForm.getDoit(); if (doit != null) { //add new if(doit.equals(rsc.getMessage("button.addNew"))) { ActionMessages errors = new ActionMessages(); errors = roomGroupEditForm.validate(mapping, request); if(errors.size()==0) { save(mapping, roomGroupEditForm, request, response); return mapping.findForward("showRoomGroupList"); } else { saveErrors(request, errors); } } //return to room list if(doit.equals(rsc.getMessage("button.returnToRoomGroupList"))) { return mapping.findForward("showRoomGroupList"); } } //get depts owned by user LookupTables.setupDepartments(request, sessionContext, false); //set default department TreeSet<Department> departments = Department.getUserDepartments(sessionContext.getUser()); if (departments.size() == 1) { roomGroupEditForm.setDeptCode(departments.first().getDeptCode()); } else { String deptCode = (String)sessionContext.getAttribute(SessionAttribute.DepartmentCodeRoom); if (deptCode != null && !deptCode.isEmpty() && !deptCode.equals("All") && !deptCode.matches("Exam[0-9]*")) roomGroupEditForm.setDeptCode(deptCode); } if (roomGroupEditForm.getDeptCode() == null || roomGroupEditForm.getDeptCode().isEmpty() || roomGroupEditForm.getDeptCode().matches("Exam[0-9]*") || !sessionContext.hasPermission(roomGroupEditForm.getDeptCode(), "Department", Right.DepartmentRoomGroupAdd)) { sessionContext.checkPermission(Right.GlobalRoomGroupAdd); roomGroupEditForm.setGlobal(true); } else { sessionContext.checkPermission(roomGroupEditForm.getDeptCode(), "Department", Right.DepartmentRoomGroupAdd); roomGroupEditForm.setGlobal(false); } roomGroupEditForm.setSessionId(sessionContext.getUser().getCurrentAcademicSessionId()); return mapping.findForward("showAdd"); }
Example #22
Source File: RollForwardSessionAction.java From unitime with Apache License 2.0 | 4 votes |
/** * Method execute * @param mapping * @param form * @param request * @param response * @return ActionForward * @throws Exception */ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { MessageResources rsc = getResources(request); RollForwardSessionForm rollForwardSessionForm = (RollForwardSessionForm) form; // Get operation String op = request.getParameter("op"); if (op != null && op.equals(rsc.getMessage("button.rollForward"))) { sessionContext.checkPermission(Right.SessionRollForward); ActionMessages errors = rollForwardSessionForm.validate(mapping, request); if (errors.isEmpty()) { solverServerService.getQueueProcessor().add(new RollForwardQueueItem( SessionDAO.getInstance().get(rollForwardSessionForm.getSessionToRollForwardTo()), sessionContext.getUser(), (RollForwardSessionForm)rollForwardSessionForm.clone())); } else { saveErrors(request, errors); } } if (request.getParameter("remove") != null) { solverServerService.getQueueProcessor().remove(request.getParameter("remove")); } WebTable table = getQueueTable(request, rollForwardSessionForm); if (table != null) { request.setAttribute("table", table.printTable(WebTable.getOrder(sessionContext,"rollForwardSession.ord"))); } setToFromSessionsInForm(rollForwardSessionForm); rollForwardSessionForm.setSubjectAreas(getSubjectAreas(rollForwardSessionForm.getSessionToRollForwardTo())); rollForwardSessionForm.setDepartments(getDepartments(rollForwardSessionForm.getSessionToRollForwardTo())); rollForwardSessionForm.setFromPointInTimeDataSnapshots(getPointInTimeDataSnapshots(rollForwardSessionForm.getSessionToRollForwardTo())); if (op == null) setExpirationDates(rollForwardSessionForm); if (rollForwardSessionForm.getSubpartLocationPrefsAction() == null){ rollForwardSessionForm.setSubpartLocationPrefsAction(SessionRollForward.ROLL_PREFS_ACTION); } if (rollForwardSessionForm.getSubpartTimePrefsAction() == null){ rollForwardSessionForm.setSubpartTimePrefsAction(SessionRollForward.ROLL_PREFS_ACTION); } if (rollForwardSessionForm.getClassPrefsAction() == null){ rollForwardSessionForm.setClassPrefsAction(SessionRollForward.DO_NOT_ROLL_ACTION); } if (rollForwardSessionForm.getRollForwardDistributions() == null) rollForwardSessionForm.setRollForwardDistributions(SessionRollForward.DistributionMode.MIXED.name()); if (rollForwardSessionForm.getCancelledClassAction() == null) { rollForwardSessionForm.setCancelledClassAction(SessionRollForward.CancelledClassAction.REOPEN.name()); } if (rollForwardSessionForm.getMidtermExamsPrefsAction() == null) rollForwardSessionForm.setMidtermExamsPrefsAction(SessionRollForward.EXAMS_ROOM_PREFS); if (rollForwardSessionForm.getFinalExamsPrefsAction() == null) rollForwardSessionForm.setFinalExamsPrefsAction(SessionRollForward.EXAMS_ROOM_PREFS); return mapping.findForward("displayRollForwardSessionForm"); }
Example #23
Source File: InstructorListUpdateAction.java From unitime with Apache License 2.0 | 4 votes |
/** * Method execute * @param mapping * @param form * @param request * @param response * @return ActionForward */ public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { //Check permissions sessionContext.checkPermission(Right.ManageInstructors); InstructorListUpdateForm frm = (InstructorListUpdateForm) form; MessageResources rsc = getResources(request); String op = frm.getOp(); // Cancel - Go back to Instructors Detail Screen if(op != null && op.equals(rsc.getMessage("button.backToInstructorList"))) { response.sendRedirect( response.encodeURL("instructorList.do")); return null; } // Update - Update the instructor and go back to Instructor List Screen if(op != null && op.equals(rsc.getMessage("button.update")) ) { update(frm, request); response.sendRedirect( response.encodeURL("instructorList.do")); return null; } // Refresh - set filters if(op != null && op.equals(rsc.getMessage("button.applyFilter")) ) { request.setAttribute("filterApplied", "1"); } Collection assigned = getAssigned(); if (assigned != null) { frm.setAssignedInstr(assigned); } Collection available = getAvailable(frm, request); if (available != null) { frm.setAvailableInstr(available); } // Get Position Types LookupTables.setupPositionTypes(request); setupFilters(frm, request); frm.setInstructors(); frm.setNameFormat(sessionContext.getUser().getProperty(UserProperty.NameFormat)); return mapping.findForward("showUpdateInstructorList"); }
Example #24
Source File: ManagerSettingsAction.java From unitime with Apache License 2.0 | 4 votes |
/** * Method execute * @param mapping * @param form * @param request * @param response * @return ActionForward */ public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Check Access sessionContext.checkPermission(Right.SettingsUser); MessageResources rsc = getResources(request); ManagerSettingsForm frm = (ManagerSettingsForm) form; String op = frm.getOp(); if(op==null) { op = request.getParameter("op"); if(op==null) { frm.setOp("List"); op = "List"; } } // Reset Form if(op.equals(rsc.getMessage("button.cancelUpdateSetting"))) { frm.reset(mapping, request); frm.setOp("List"); } // Edit - Load setting with allowed values for user to update if(op.equals("Edit")) { // Load Settings object Settings s = SettingsDAO.getInstance().get(Long.valueOf(request.getParameter("id"))); // Set Form values frm.setOp("Edit"); frm.setAllowedValues(s.getAllowedValues()); frm.setKey(s.getKey()); frm.setName(s.getDescription()); frm.setDefaultValue(s.getDefaultValue()); frm.setValue(sessionContext.getUser().getProperty(s.getKey(), s.getDefaultValue())); return mapping.findForward("editManagerSettings"); } // Save changes made by the user if(op.equals(rsc.getMessage("button.updateSetting"))) { ActionMessages errors = frm.validate(mapping, request); if(errors.size()>0) { saveErrors(request, errors); frm.setOp("Edit"); } else { sessionContext.getUser().setProperty(frm.getKey(), frm.getValue()); } } // Read all existing settings and store in request getSettingsList(request); return mapping.findForward("showManagerSettings"); }
Example #25
Source File: RoomFeatureAddAction.java From unitime with Apache License 2.0 | 4 votes |
/** * Method execute * @param mapping * @param form * @param request * @param response * @return ActionForward */ public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { RoomFeatureEditForm roomFeatureEditForm = (RoomFeatureEditForm) form; MessageResources rsc = getResources(request); String doit = roomFeatureEditForm.getDoit(); if (doit != null) { //add new if(doit.equals(rsc.getMessage("button.addNew"))) { ActionMessages errors = new ActionMessages(); errors = roomFeatureEditForm.validate(mapping, request); if(errors.size()==0) { save(mapping, roomFeatureEditForm, request, response); return mapping.findForward("showRoomFeatureList"); } else { saveErrors(request, errors); } } //return to room list if(doit.equals(rsc.getMessage("button.returnToRoomFeatureList"))) { return mapping.findForward("showRoomFeatureList"); } } //get depts owned by user LookupTables.setupDepartments(request, sessionContext, false); LookupTables.setupExamTypes(request, sessionContext.getUser(), DepartmentStatusType.Status.ExamView, DepartmentStatusType.Status.ExamTimetable); request.setAttribute("featureTypes", RoomFeatureTypeDAO.getInstance().findAll(Order.asc("label"))); //set default department TreeSet<Department> departments = Department.getUserDepartments(sessionContext.getUser()); if (departments.size() == 1) { roomFeatureEditForm.setDeptCode(departments.first().getDeptCode()); } else { String deptCode = (String)sessionContext.getAttribute(SessionAttribute.DepartmentCodeRoom); if (deptCode != null && !deptCode.isEmpty() && !deptCode.equals("All") && !deptCode.matches("Exam[0-9]*")) roomFeatureEditForm.setDeptCode(deptCode); } if (roomFeatureEditForm.getDeptCode() == null || roomFeatureEditForm.getDeptCode().isEmpty() || roomFeatureEditForm.getDeptCode().matches("Exam[0-9]*") || !sessionContext.hasPermission(roomFeatureEditForm.getDeptCode(), "Department", Right.DepartmentRoomFeatureAdd)) { sessionContext.checkPermission(Right.GlobalRoomFeatureAdd); roomFeatureEditForm.setGlobal(true); } else { sessionContext.checkPermission(roomFeatureEditForm.getDeptCode(), "Department", Right.DepartmentRoomFeatureAdd); roomFeatureEditForm.setGlobal(false); } roomFeatureEditForm.setSessionId(sessionContext.getUser().getCurrentAcademicSessionId()); return mapping.findForward("showAdd"); }
Example #26
Source File: InstructionalOfferingModifyForm.java From unitime with Apache License 2.0 | 4 votes |
/** * Method validate * @param mapping * @param request * @return ActionErrors */ public ActionErrors validate( ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); // Get Message Resources MessageResources rsc = (MessageResources) super.getServlet() .getServletContext().getAttribute(Globals.MESSAGES_KEY); if (op.equals(rsc.getMessage("button.add"))) { // Check Added Course if (this.addTemplateClassId==null || this.addTemplateClassId.longValue()<=0) { errors.add("getAddTemplateClassId", new ActionMessage("errors.generic", MSG.errorRequiredClass())); } } if (op.equals(rsc.getMessage("button.moveUp"))) { // Check Course to move up if (this.moveUpClassId==null || this.moveUpClassId.longValue()<=0) { errors.add("getMoveUpClassId", new ActionMessage("errors.generic", MSG.errorRequiredClass())); } } if (op.equals(rsc.getMessage("button.moveDown"))) { // Check Course to move down if (this.moveDownClassId==null || this.moveDownClassId.longValue()<=0) { errors.add("getMoveDownClassId", new ActionMessage("errors.generic", MSG.errorRequiredClass())); } } if (op.equals(MSG.actionUpdateMultipleClassSetup())) { // Check Instructional Offering Config if (this.instrOffrConfigId==null || this.instrOffrConfigId.intValue()<=0) { errors.add("instrOffrConfigId", new ActionMessage("errors.generic", MSG.errorRequiredIOConfiguration())); } // Validate class limits provide space that is >= limit for the instructional offering config validateChildClassExistence(errors); validateClassLimits(errors); validateAllSubpartsHaveAtLeastOneClass(errors); } return errors; }
Example #27
Source File: XmlMessageResourcesFactory.java From spacewalk with GNU General Public License v2.0 | 2 votes |
/** * Create and return a newly instansiated <code>MessageResources</code>. * This method must be implemented by concrete subclasses. * * @param config Configuration parameter(s) for the requested bundle * @return A new instance of a MessageResources class. */ public MessageResources createResources(String config) { return new XmlMessageResources(this, config, this.returnNull); }
Example #28
Source File: XmlMessageResourcesFactory.java From uyuni with GNU General Public License v2.0 | 2 votes |
/** * Create and return a newly instansiated <code>MessageResources</code>. * This method must be implemented by concrete subclasses. * * @param config Configuration parameter(s) for the requested bundle * @return A new instance of a MessageResources class. */ public MessageResources createResources(String config) { return new XmlMessageResources(this, config, this.returnNull); }