protected boolean isAdmin() { return server.isAdmin(); }
/** * Returns whether the request is from an author instance. */ public boolean isAuthorInstance() { return Components.getComponent(ServerConfiguration.class).isAdmin(); }
@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(); }
private void processException(RenderException renderException, PrintWriter printWriter, String msg) { if (serverConfiguration.isAdmin() && !aggregationStateProvider.get().isPreviewMode()) { inEditMode(msg, renderException, printWriter); } else { inPublicMode(msg, renderException, printWriter); } printWriter.flush(); }
private boolean canRenderAreaScript() { if (!this.isAreaDefinitionEnabled) { // area script can be rendered only when area is enabled return false; } if (this.areaNode != null) { return true; } if (this.optional && this.getServer().isAdmin() && !MgnlContext.getAggregationState().isPreviewMode()) { // render script for optional areas when being in edit mode on author instance return true; } return false; }
@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)); }
@Test public void testIsAvailableReturnsTrueOnNonAuthorWithActiveSubscribers() { // GIVEN when(serverConfiguration.isAdmin()).thenReturn(false); when(activationManager.hasAnyActiveSubscriber()).thenReturn(true); // WHEN boolean result = rule.isAvailable(); // THEN assertTrue(result); }
@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); } }
@Test public void testIsAvailableReturnsFalseOnNonAuthorAndNoSubscribers() { // GIVEN when(serverConfiguration.isAdmin()).thenReturn(false); when(activationManager.hasAnyActiveSubscriber()).thenReturn(false); // WHEN boolean result = rule.isAvailable(); // THEN assertFalse(result); } }
@Test public void testIsAvailableReturnsTrueIfOnAuthor() { // GIVEN when(serverConfiguration.isAdmin()).thenReturn(true); // WHEN boolean result = rule.isAvailable(); // THEN assertTrue(result); }
/** * 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()); } }
if (Components.getComponent(ServerConfiguration.class).isAdmin() || ActivationManagerFactory.getActivationManager().hasAnyActiveSubscriber())