List of usage examples for org.apache.wicket.protocol.http WebApplication get
public static WebApplication get()
From source file:abid.password.wicket.pages.LogoutPage.java
License:Apache License
public LogoutPage() { getSession().invalidateNow(); setResponsePage(WebApplication.get().getHomePage()); }
From source file:biz.turnonline.ecosystem.origin.frontend.FrontendApplication.java
License:Apache License
public static FrontendApplication get() { return (FrontendApplication) WebApplication.get(); }
From source file:bugs.HttpSessionStoreModified.java
License:Apache License
/** * Gets the prefix for storing variables in the actual session (typically * {@link HttpSession}) for this application instance. * /* w w w. j av a 2 s . co m*/ * @param request * the request * @return the prefix for storing variables in the actual session */ private String getSessionAttributePrefix(final Request request) { String sessionAttributePrefix = MarkupParser.WICKET; if (request instanceof WebRequest) { sessionAttributePrefix = WebApplication.get().getSessionAttributePrefix((WebRequest) request, null); } return sessionAttributePrefix; }
From source file:com.axway.ats.testexplorer.model.db.TestExplorerPGDbWriteAccess.java
License:Apache License
private void deleteAttachedFilesToRun(String runId) { ServletContext context = WebApplication.get().getServletContext(); if (context.getAttribute(ContextListener.getAttachedFilesDir()) == null) { LOG.error("No property \"" + ContextListener.getAttachedFilesDir() + "\" was found. Attached files in the current run directory won't be deleted!"); } else {//from ww w .j a v a 2 s. c o m String attachedfilesDir = context.getAttribute("ats-attached-files").toString(); LocalFileSystemOperations operations = new LocalFileSystemOperations(); String runDirPath = attachedfilesDir + "\\" + dbConnectionFactory.getDb() + "\\" + runId; if (operations.doesFileExist(runDirPath)) { operations.deleteDirectory(runDirPath, true); } } }
From source file:com.axway.ats.testexplorer.model.db.TestExplorerPGDbWriteAccess.java
License:Apache License
private void deleteAttachedFilesToSuite(String suiteId) { ServletContext context = WebApplication.get().getServletContext(); String atsAttachedFilesProp = "ats-attached-files"; if (context.getAttribute(atsAttachedFilesProp) == null) { LOG.error("No property \"" + atsAttachedFilesProp + "\" was found. Attached files in the current run directory won't be deleted!"); } else {//from w ww . j av a 2s . c o m String attachedfilesDir = context.getAttribute("ats-attached-files").toString(); LocalFileSystemOperations operations = new LocalFileSystemOperations(); String runDirPath = attachedfilesDir + "\\" + dbConnectionFactory.getDb() + "\\"; String runId = ""; try { runId = ((TestExplorerSession) Session.get()).getDbReadConnection() .getNavigationForScenario(suiteId).getRunId(); if (StringUtils.isNullOrEmpty(runId)) { LOG.warn("RunId was not get! Files attached to the current suite won't be deleted!"); } operations.deleteDirectory(runDirPath + "\\" + runId + "\\" + suiteId, true); } catch (DatabaseAccessException dae) { LOG.warn("Files attached to the current suite won't be deleted due to error!", dae); } } }
From source file:com.blogspot.chicchiricco.c3wicketdemo.CocoonSAXPipeline.java
License:Apache License
@Override protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) { this.pipeline.addComponent(createXMLSerializer()); HttpServletRequest request = ((WebRequest) RequestCycle.get().getRequest()).getHttpServletRequest(); HttpServletResponse response = ((WebResponse) RequestCycle.get().getResponse()).getHttpServletResponse(); ServletContext servletContext = WebApplication.get().getServletContext(); Map<String, Object> parameters = RequestProcessor.prepareParameters(request, response, this.settings, servletContext);/* ww w. j av a 2s . co m*/ ByteArrayOutputStream baos = new ByteArrayOutputStream(); this.pipeline.setup(baos, parameters); try { this.pipeline.execute(); } catch (Exception e) { throw new ProcessingException("Error while execution a Cocoon pipeline.", e); } this.replaceComponentTagBody(markupStream, openTag, new String(baos.toByteArray())); }
From source file:com.evolveum.midpoint.web.page.self.component.LinksPanel.java
License:Apache License
@Override protected void initLayout() { final List<RichHyperlinkType> linksList = getModel().getObject(); RepeatingView rowView = new RepeatingView(ID_LINKS_ROW); int linksListSize = linksList == null ? 0 : linksList.size(); if (linksListSize > 0) { int currentColumn = 0; RepeatingView columnView = null; WebMarkupContainer row = null;//from w w w .j ava 2s . co m boolean isRowAdded = false; for (int i = 0; i < linksListSize; i++) { final RichHyperlinkType link = linksList.get(i); if (WebComponentUtil.isAuthorized(link.getAuthorization())) { if (currentColumn == 0) { row = new WebMarkupContainer(rowView.newChildId()); isRowAdded = false; columnView = new RepeatingView(ID_LINKS_COLUMN); } WebMarkupContainer column = new WebMarkupContainer(columnView.newChildId()); Link linkItem = new Link(ID_LINK) { @Override public void onClick() { } @Override protected void onComponentTag(final ComponentTag tag) { super.onComponentTag(tag); String rootContext = ""; //TODO: what is this for??? if (link.getTargetUrl() != null && !link.getTargetUrl().startsWith("http://") && !link.getTargetUrl().startsWith("https://") && !link.getTargetUrl().startsWith("www://") && !link.getTargetUrl().startsWith("//")) { WebApplication webApplication = WebApplication.get(); if (webApplication != null) { ServletContext servletContext = webApplication.getServletContext(); if (servletContext != null) { rootContext = servletContext.getContextPath(); } } } tag.put("href", rootContext + (link.getTargetUrl() == null ? "#" : link.getTargetUrl())); } }; linkItem.add(new Label(ID_IMAGE) { @Override protected void onComponentTag(final ComponentTag tag) { super.onComponentTag(tag); String cssClass = ICON_DEFAULT_CSS_CLASS; if (link.getIcon() != null) { cssClass = link.getIcon().getCssClass(); } tag.put("class", "info-box-icon " + (link.getColor() != null ? (link.getColor().startsWith("bg-") ? link.getColor() : "bg-" + link.getColor()) : "") + " " + cssClass); } }); linkItem.add(new Label(ID_LABEL, new Model<String>() { public String getObject() { return link.getLabel(); } })); Label description = new Label(ID_DESCRIPTION, new Model<String>() { public String getObject() { return link.getDescription(); } }); description.setEnabled(false); linkItem.add(description); column.add(linkItem); columnView.add(column); if (currentColumn == 1 || (linksList.indexOf(link) == linksListSize - 1)) { row.add(columnView); rowView.add(row); currentColumn = 0; isRowAdded = true; } else { currentColumn++; } } else { LOGGER.trace("Link {} not authorized, skipping", link); } } if (row != null && columnView != null && !isRowAdded) { row.add(columnView); rowView.add(row); } } add(rowView); }
From source file:com.gitblit.wicket.GitBlitWebApp.java
License:Apache License
public static GitBlitWebApp get() { return (GitBlitWebApp) WebApplication.get(); }
From source file:com.googlecode.wicketelements.security.UnauthorizedComponentInstantiationListener.java
License:Apache License
public void onUnauthorizedInstantiation(final Component componentParam) { PARAM_REQ.Object.requireNotNull(componentParam, "The component parameter must not be null."); if (!SecureSession.get().isAuthenticated()) { LOGGER.debug("Unauthorized and user not authenticated."); if (securityCheck.isApplicationWithSignInPageSpecified()) { LOGGER.debug("Application has a sign in page specified. Setting sign in page as response."); throw new RestartResponseAtInterceptPageException(securityCheck.signInPage()); }/*from ww w . ja va2s.c o m*/ } LOGGER.debug("Setting access denied page as response."); throw new RestartResponseException(WebApplication.get().getApplicationSettings().getAccessDeniedPage()); }
From source file:com.googlesource.gerrit.plugins.gitblit.app.StaticRewritingHeaderResponse.java
License:Apache License
private String rewriteUrl(final String url) { if (Strings.isNullOrEmpty(url) || EXTERNAL_URL.matcher(url).matches()) { return url; }//w ww .j a v a2 s . c o m ServletContext servletContext = WebApplication.get().getServletContext(); String contextPath = servletContext.getContextPath(); String rewrittenUrl = url; if (url.startsWith(contextPath)) { if (!url.startsWith(contextPath + "/static/")) { rewrittenUrl = contextPath + "/static" + url.substring(contextPath.length()); } } else if (url.charAt(0) == '/') { rewrittenUrl = contextPath + "/static" + url; } else { rewrittenUrl = contextPath + "/static/" + url; } return rewrittenUrl; }