@Override protected void render(MCRServletJob job, Exception ex) throws Exception { if (ex != null) { //do not handle error here throw ex; } getLayoutService().doLayout(job.getRequest(), job.getResponse(), new MCRJDOMContent((Document) job.getRequest().getAttribute(LAYOUT_ELEMENT_KEY))); }
@Override protected void render(MCRServletJob job, Exception ex) throws Exception { if (ex != null) { //do not handle error here throw ex; } getLayoutService().doLayout(job.getRequest(), job.getResponse(), new MCRJDOMContent((Document) job.getRequest().getAttribute(LAYOUT_ELEMENT_KEY))); }
root.addContent(u.clone()); getLayoutService().doLayout(req, res, new MCRJDOMContent(root)); } else { res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, errorMsg("missingParameter"));
getLayoutService().doLayout(req, res, new MCRJAXBContent<>(JAXBContext.newInstance(MCRLogin.class), loginForm));
private void presentLoginForm(HttpServletRequest req, HttpServletResponse res, ServletException ex) throws IOException, TransformerException, SAXException, JAXBException { String returnURL = MCRLoginServlet.getReturnURL(req); String formAction = req.getRequestURI(); MCRLogin loginForm = new MCRLogin(MCRSessionMgr.getCurrentSession().getUserInformation(), returnURL, formAction); MCRLoginServlet.addCurrentUserInfo(loginForm); String realm = getProperty(req, "realm"); if (realm != null) { req.setAttribute("XSL.Realm", realm); } MCRLoginServlet.addFormFields(loginForm, realm); if (ex != null) { //Login failed res.setStatus(HttpServletResponse.SC_BAD_REQUEST); loginForm.setLoginFailed(true); loginForm.setErrorMessage(ex.getMessage()); } getLayoutService().doLayout(req, res, new MCRJAXBContent<>(JAXBContext.newInstance(MCRLogin.class), loginForm)); }
/** * Handles MCRUserServlet?action=delete&id={userID}. * Deletes the user. * Outputs user data of the deleted user using user.xsl afterwards. */ private void deleteUser(HttpServletRequest req, HttpServletResponse res, MCRUser user) throws Exception { MCRUser currentUser = MCRUserManager.getCurrentUser(); boolean allowed = MCRAccessManager.checkPermission(MCRUser2Constants.USER_ADMIN_PERMISSION) || currentUser.equals(user.getOwner()); if (!allowed) { String msg = MCRTranslation.translate("component.user2.UserServlet.noAdminPermission"); res.sendError(HttpServletResponse.SC_FORBIDDEN, msg); return; } LOGGER.info("delete user {} {} {}", user.getUserID(), user.getUserName(), user.getRealmID()); MCRUserManager.deleteUser(user); getLayoutService().doLayout(req, res, getContent(user)); }
@Override public void handleSubmission(ServletContext context, MCRServletJob job, MCREditorSession session, String style) throws Exception { session.getSubmission().setSubmittedValues(job.getRequest().getParameterMap()); Document result = session.getEditedXML(); if (session.getValidator().isValid()) { result = MCRChangeTracker.removeChangeTracking(result); result = session.getXMLCleaner().clean(result); result = session.getPostProcessor().process(result); if ((style != null) && (!style.isEmpty())) { job.getRequest().setAttribute("XSL.Style", style); } MCRContent editedXML = new MCRJDOMContent(result); MCRLayoutService.instance().doLayout(job.getRequest(), job.getResponse(), editedXML); session.setBreakpoint("After handling target layout " + style); } else { session.setBreakpoint("After validation failed, target layout " + style); job.getResponse().sendRedirect(job.getResponse().encodeRedirectURL(session.getRedirectURL(null))); } } }
/** * Handles MCRUserServlet?action=show&id={userID}. * Outputs user data for the given id using user.xsl. */ private void showUser(HttpServletRequest req, HttpServletResponse res, MCRUser user, String uid) throws Exception { MCRUser currentUser = MCRUserManager.getCurrentUser(); if (!checkUserIsNotNull(res, currentUser, null) || !checkUserIsNotNull(res, user, uid)) { return; } boolean allowed = MCRAccessManager.checkPermission(MCRUser2Constants.USER_ADMIN_PERMISSION) || currentUser.equals(user) || currentUser.equals(user.getOwner()); if (!allowed) { String msg = MCRTranslation.translate("component.user2.UserServlet.noAdminPermission"); res.sendError(HttpServletResponse.SC_FORBIDDEN, msg); return; } LOGGER.info("show user {} {} {}", user.getUserID(), user.getUserName(), user.getRealmID()); getLayoutService().doLayout(req, res, getContent(user)); }
} else { LOGGER.info("Request file \"" + request + "\"..."); getLayoutService().doLayout(job.getRequest(), job.getResponse(), new MCRJDOMContent(MCRURIResolver.instance().resolve("resource:setup/" + request))); getLayoutService().doLayout(job.getRequest(), job.getResponse(), new MCRJDOMContent(resXML));
getLayoutService().doLayout(req, res, new MCRJDOMContent(users));
root.addContent(u.clone()); getLayoutService().doLayout(req, res, new MCRJDOMContent(root)); } else { LOGGER.error("User " + user.getUserID() + " already exists!");
private void listRealms(HttpServletRequest req, HttpServletResponse res) throws IOException, TransformerException, SAXException { String redirectURL = getReturnURL(req); Document realmsDoc = MCRRealmFactory.getRealmsDocument(); Element realms = realmsDoc.getRootElement(); addCurrentUserInfo(realms); List<Element> realmList = realms.getChildren(REALM_URL_PARAMETER); for (Element realm : realmList) { String realmID = realm.getAttributeValue("id"); Element login = realm.getChild("login"); if (login != null) login.setAttribute("url", MCRRealmFactory.getRealm(realmID).getLoginURL(redirectURL)); } getLayoutService().doLayout(req, res, new MCRJDOMContent(realmsDoc)); }