@RequestMapping(method = RequestMethod.POST) public ModelAndView executeThenShowPage(HttpServletRequest req, HttpServletResponse res) throws Exception { log.info("Page <FEATURES> on action <POST>"); // Environment de travail EnvironmenBean envBean = (EnvironmenBean) req.getSession().getAttribute(ATTR_ENVBEAN); // Access features through HTTP store (all parsing done) FeatureStore storeHTTP = new FeatureStoreHttp(envBean.getEnvUrl() + "/" + FF4jWebConstants.RESOURCE_FF4J); // Data in the target screen FeaturesBean featBean = new FeaturesBean(); try { // Import Features if (ServletFileUpload.isMultipartContent(req)) { List<FileItem> items = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(req); for (FileItem item : items) { if (item.isFormField()) { if (OPERATION.equalsIgnoreCase(item.getFieldName())) { log.info("Processing action : " + item.getString()); } } else if (FLIPFILE.equalsIgnoreCase(item.getFieldName())) { String filename = FilenameUtils.getName(item.getName()); if (filename.toLowerCase().endsWith("xml")) { opImportFile(storeHTTP, item.getInputStream()); featBean.setMessage( "The file <b>" + filename + "</b> has been successfully imported"); } else { featBean.setMessage("Invalid FILE, must be XML files"); featBean.setMessageType(MSG_ERROR); } } } } else { // Edit Operations String operation = req.getParameter(OPERATION); if (operation != null && !operation.isEmpty()) { if (OP_EDIT_FEATURE.equalsIgnoreCase(operation)) { opUpdateFeatureDescription(storeHTTP, req); featBean.setMessage(buildMessage(req.getParameter(FEATID), "UPDATED")); } else if (OP_CREATE_FEATURE.equalsIgnoreCase(operation)) { opCreateFeature(storeHTTP, req); featBean.setMessage(buildMessage(req.getParameter(FEATID), "ADDED")); } else if (OP_TOGGLE_GROUP.equalsIgnoreCase(operation)) { String groupName = req.getParameter(GROUPNAME); if (groupName != null && !groupName.isEmpty()) { String operationGroup = req.getParameter(SUBOPERATION); if (OP_ENABLE.equalsIgnoreCase(operationGroup)) { storeHTTP.enableGroup(groupName); featBean.setMessage(buildMessageGroup(groupName, "ENABLED")); log.info("Group '" + groupName + "' has been ENABLED."); } else if (OP_DISABLE.equalsIgnoreCase(operationGroup)) { storeHTTP.disableGroup(groupName); featBean.setMessage(buildMessageGroup(groupName, "DISABLED")); log.info("Group '" + groupName + "' has been DISABLED."); } } } else { log.error("Invalid POST OPERATION" + operation); featBean.setMessageType(MSG_ERROR); featBean.setMessage("Invalid REQUEST"); } } } } catch (Exception e) { featBean.setMessageType(MSG_ERROR); featBean.setMessage(e.getMessage()); e.printStackTrace(); } // Updating bean featBean.setListOfFeatures(new ArrayList<Feature>(storeHTTP.readAll().values())); featBean.setHtmlPermissions(populatePermissionList(envBean)); featBean.setGroupList(storeHTTP.readAllGroups()); // Create view ModelAndView mav = new ModelAndView(VIEW_FEATURES); mav.addObject(ATTR_ENVBEAN, envBean); mav.addObject(ATTR_FEATUREBEAN, featBean); return mav; }