@Override protected boolean boolVote(Object value) { return ServerConfiguration.getInstance().isAdmin(); }
@Override public int doStartTag() { if (ServerConfiguration.getInstance().isAdmin()) { return EVAL_BODY_INCLUDE; } return SKIP_BODY; }
public boolean isAuthorInstance(){ return ServerConfiguration.getInstance().isAdmin(); }
public boolean isAuthorInstance(){ return ServerConfiguration.getInstance().isAdmin(); }
/** * Returns the mime-type associated with this extension, or the server's default. */ public static String getMIMETypeOrDefault(String extension) { String mimeType = getMIMEType(extension); if (StringUtils.isNotEmpty(mimeType)) { return mimeType; } if (StringUtils.isNotEmpty(extension)) { log.info("Cannot find MIME type for extension \"{}\"", extension); } String defaultExtension = ServerConfiguration.getInstance().getDefaultExtension(); if (StringUtils.isBlank(defaultExtension)) { defaultExtension = DEFAULT_EXTENSION; } return getMIMEType(defaultExtension); }
/** * Output a full url given a content handle (usually a page). * @param handle page handle * @return url formed using context path + handle + default extension */ public static String link(String handle) { return MgnlContext.getContextPath() + handle + '.' + ServerConfiguration.getInstance().getDefaultExtension(); }
/** * Returns the locationto which we intend to redirect. * @param request The HTTP request. * @return A URI if a child page is available, or null. */ private String getRedirectLocation(HttpServletRequest request) { Content page = MgnlContext.getAggregationState().getMainContent(); Iterator it = page.getChildren().iterator(); if (it.hasNext()) { Content c = (Content) it.next(); return c.getHandle() + '.' + ServerConfiguration.getInstance().getDefaultExtension(); } return null; }
@Override protected boolean condition() { if (ServerConfiguration.getInstance().isAdmin() && (!MgnlContext.getAggregationState().isPreviewMode() || showInPreview)) { return true; } return false; }
@Override protected boolean condition() { if (!ServerConfiguration.getInstance().isAdmin() || (showInPreview && MgnlContext.getAggregationState().isPreviewMode())) { return true; } return false; }
@Override public int doStartTag() throws JspException { if (!adminOnly || ServerConfiguration.getInstance().isAdmin()) { HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest(); // check if links have already been added. if (request.getAttribute(Sources.REQUEST_LINKS_DRAWN) == null) { Sources src = new Sources(request.getContextPath()); JspWriter out = this.pageContext.getOut(); try { out.write(src.getHtmlCss()); out.write(src.getHtmlJs()); } catch (IOException e) { // should never happen throw new NestableRuntimeException(e); } request.setAttribute(Sources.REQUEST_LINKS_DRAWN, Boolean.TRUE); } } return EVAL_PAGE; }
/** * @see javax.servlet.jsp.tagext.Tag#doStartTag() */ public int doStartTag() throws JspException { HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); String location = getRedirectLocation(request); Content activePage = MgnlContext.getAggregationState().getMainContent(); // on public servers, during preview or when the user can't edit the page, just send the redirect if (!ServerConfiguration.getInstance().isAdmin() || MgnlContext.getAggregationState().isPreviewMode() || !activePage.isGranted(Permission.SET)) { if (location != null) { try { ((HttpServletResponse) pageContext.getResponse()).sendRedirect(request.getContextPath() + location); } catch (IOException e) { log.error("Could not redirect to first child HTML page: " + e.getMessage()); //$NON-NLS-1$ } return Tag.SKIP_PAGE; } } else if (StringUtils.isNotBlank(var)) { request.setAttribute(var, location); } return super.doStartTag(); }
@Override protected View handleTokenMissing() throws RepositoryException { // If this is an admin instance then the default behaviour of creating a new state is fine. This is needed in // order to let editors author the form without simultaneously filling it in. if (ServerConfiguration.getInstance().isAdmin()) return super.handleTokenMissing(); // But in a public instance we'll render a messages saying that the form starts elsewhere. return new GoToFirstPageView(NodeUtil.getNodeIdentifierIfPossible(startPage)); }
@Override public void handleTemplateException(TemplateException te, Environment env, Writer out) throws TemplateException { final boolean isAuthorInstance = ServerConfiguration.getInstance().isAdmin(); final boolean isPreviewMode = MgnlContext.getAggregationState().isPreviewMode(); if (isAuthorInstance && !isPreviewMode) { inEditMode(te, env, out); } else { inPublicMode(te, env, out); } }
data.put("defaultBaseUrl", ServerConfiguration.getInstance().getDefaultBaseUrl());
/** * Check if the current page is open in editing mode. Shortcut for checking if the server is admin, preview unset, * permissions to modify the page available for the current user. * @return true if the page is open in edit mode and user has permissions to edit */ public static boolean isEditMode() { final AggregationState aggregationState = MgnlContext.getAggregationState(); Content activePage = aggregationState.getMainContent(); return ServerConfiguration.getInstance().isAdmin() && !aggregationState.isPreviewMode() && activePage != null && NodeUtil.isGranted(activePage.getJCRNode(), Permission.SET); }
/** * Draws the main bar (incl. all magnolia specific js and css sources). */ public void drawHtml(Writer out) throws IOException { final AggregationState aggregationState = MgnlContext.getAggregationState(); final Node mainContent = aggregationState.getMainContent().getJCRNode(); boolean isGranted; try { isGranted = PermissionUtil.isGranted(mainContent.getSession(), mainContent.getPath(), Permission.SET); } catch (RepositoryException e) { // TODO dlipp - apply consistent ExceptionHandling throw new RuntimeException(e); } if (!aggregationState.isPreviewMode() && isGranted && ServerConfiguration.getInstance().isAdmin()) { this.setEvent("onmousedown", "mgnlMoveNodeEnd(this,'" + this.getPath() + "');"); this.setEvent("onmouseover", "mgnlMoveNodeHigh(this);"); this.setEvent("onmouseout", "mgnlMoveNodeReset(this);"); println(out, getHtml()); } }
@Override public int doEndTag() { Content activePage = MgnlContext.getAggregationState().getMainContent(); if (ServerConfiguration.getInstance().isAdmin() && activePage != null && NodeUtil.isGranted(activePage.getJCRNode(), Permission.SET)) { try { BarMain bar = new BarMain(); bar.setPath(this.getPath()); bar.setDialog(this.dialog); bar.setAdminButtonVisible(this.adminButtonVisible); bar.setDefaultButtons(); if (label != null) { bar.getButtonProperties().setLabel(label); } if (buttonRight != null) { bar.getButtonsRight().addAll(buttonRight); } if (buttonLeft != null) { bar.getButtonsLeft().addAll(buttonLeft); } bar.placeDefaultButtons(); bar.drawHtml(pageContext.getOut()); } catch (Exception e) { log.warn("Exception caught during display: " + e.getMessage(), e); //$NON-NLS-1$ } } this.buttonLeft = null; this.buttonRight = null; return EVAL_PAGE; }
@Override public int doEndTag() { if ((!adminOnly || ServerConfiguration.getInstance().isAdmin()) && NodeUtil.isGranted(MgnlContext.getAggregationState().getMainContent().getJCRNode(), Permission.SET)) { try { BarNew bar = new BarNew();
final HttpServletResponse response = MgnlContext.getWebContext().getResponse(); final boolean isAdmin = ServerConfiguration.getInstance().isAdmin(); final boolean isPreview = MgnlContext.getAggregationState().isPreviewMode(); try {
@Override public int doEndTag() { if ((!adminOnly || ServerConfiguration.getInstance().isAdmin()) && NodeUtil.isGranted(MgnlContext.getAggregationState().getMainContent().getJCRNode(), Permission.SET)) { try { if (this.getNodeCollectionName() != null && this.getNodeName() == null) { // cannot draw edit button with nodeCllection and without node return EVAL_PAGE; } JspWriter out = pageContext.getOut(); ButtonEdit button = new ButtonEdit(); button.setPath(this.getPath()); button.setDialog(this.getDialog()); button.setNodeCollectionName(this.getNodeCollectionName()); button.setNodeName(this.getNodeName()); button.setDefaultOnclick(); if (this.getLabel() != null) { button.setLabel(this.getLabel()); } if (this.small) { button.setSmall(true); } button.drawHtml((Writer) out); } catch (Exception e) { log.error(e.getMessage(), e); } } return EVAL_PAGE; }