List of usage examples for com.vaadin.server VaadinRequest getContextPath
public String getContextPath();
From source file:annis.gui.CommonUI.java
License:Apache License
private boolean checkUrlShortenerRedirect(VaadinRequest request, VaadinResponse response) { String id = request.getParameter("id"); if (id == null) { return false; }/*from w ww . j a v a 2s . c om*/ // get the actual URL WebResource res = Helper.getAnnisWebResource(); res = res.path("shortener").path(id); String longURL = res.get(String.class); // redirects only work in http servlets if (response instanceof VaadinServletResponse) { ServletResponse servletResponse = ((VaadinServletResponse) response).getResponse(); if (servletResponse instanceof HttpServletResponse) { HttpServletResponse httpResponse = (HttpServletResponse) servletResponse; httpResponse.setHeader("Location", request.getContextPath() + longURL); httpResponse.setStatus(307); // temporary redirect return true; } } return false; }
From source file:annis.gui.requesthandler.ShortenerRequestHandler.java
License:Apache License
@Override public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { String id = request.getParameter("id"); if (id == null) { return false; }/*from w w w . j a va2s .c om*/ // get the actual URL WebResource res = Helper.getAnnisWebResource(); res = res.path("shortener").path(id); String longURL = res.get(String.class); // redirects only work in http servlets if (response instanceof VaadinServletResponse) { ServletResponse servletResponse = ((VaadinServletResponse) response).getResponse(); if (servletResponse instanceof HttpServletResponse) { HttpServletResponse httpResponse = (HttpServletResponse) servletResponse; httpResponse.setHeader("Location", request.getContextPath() + longURL); httpResponse.setStatus(307); // temporary redirect return true; } } return false; }
From source file:annis.libgui.AnnisBaseUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { initLogging();//from w w w .j a v a 2 s . c o m // store the webservice URL property explicitly in the session in order to // access it from the "external" servlets getSession().getSession().setAttribute(WEBSERVICEURL_KEY, getSession().getAttribute(Helper.KEY_WEB_SERVICE_URL)); getSession().setAttribute(CONTEXT_PATH, request.getContextPath()); alreadyAddedCSS.clear(); initPlugins(); checkIfRemoteLoggedIn(request); getSession().addRequestHandler(new RemoteUserRequestHandler()); }
From source file:com.arcusys.liferay.vaadinplugin.ControlPanelPortlet.java
License:Apache License
@Override protected VaadinPortletService createPortletService(DeploymentConfiguration deploymentConfiguration) throws ServiceException { VaadinPortletService service = new VaadinPortletService(this, deploymentConfiguration) { private static final long serialVersionUID = 1L; @Override/*from w w w. ja v a 2s.c o m*/ public final String getStaticFileLocation(VaadinRequest request) { // Use static resources (widgetsets and themes) in the portlet war: return request.getContextPath(); } }; service.init(); return service; }
From source file:com.lst.deploymentautomation.vaadin.core.LoginUI.java
License:Open Source License
@Override public void init(VaadinRequest request) { //The application itself is not covered by container security - that would break bookmarkability //(the view info is kept in the URL fragment, which is not sent to server, thus it's lost //when the container redirects the browser to the login page). //Therefore only one JSP page is currently covered by container security (ui.jsp). If no user //is logged in, we show ui.jsp in a full-sized iframe; since no user is logged in, login page //is shown instead - once user logs in, content of ui.jsp is returned, which refreshes the top //window - and thus the correct view is shown, since the URL fragment was kept. //using a label for this is not very nice, but it's simplest String src = request.getContextPath() + "/ui.jsp"; Label iframe = new Label("<iframe src='" + src + "' style='width: 100%; height: 100%; border: 0' />", ContentMode.HTML);//ww w . j a v a 2 s . c om iframe.setSizeFull(); setContent(iframe); //set page title getPage().setTitle(Utils.getLocalizedString(getLocale(), "application.title")); }
From source file:de.akquinet.engineering.vaadinator.example.contractapplication.ContractApplicationExampleUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { NavigationManager m = new NavigationManager(); m.setMaintainBreadcrumb(true);/* w w w .jav a 2 s . c om*/ FirstPagePresenter fpres; fpres = obtainPresenterFactory(request.getContextPath()).createFirstPagePresenter(); FirstPageView fview = (FirstPageView) fpres.getView(); m.setCurrentComponent((Component) fview.getComponent()); setContent(m); // and go fpres.startPresenting(); }
From source file:de.akquinet.engineering.vaadinator.timesheet.TimesheetUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { // TODO: remove test-entry into contet context.put(CONTEXT_LOGIN_USER, "sebastian"); // create//from w w w . j a va 2 s.co m NavigationManager m = new NavigationManager(); m.setMaintainBreadcrumb(true); TimesheetChangePresenter pres = obtainPresenterFactory(request.getContextPath()) .createTimesheetChangePresenter(null); // Load the july timesheet into the presenter CouchDbTimesheetService tsService = new CouchDbTimesheetService(); List<Timesheet> tsList = tsService.listAllTimesheet(new HashMap<String, Object>(context)); for (Timesheet ts : tsList) { if (ts.getMonth() == 7 && ts.getYear() == 2014) { pres.setTimesheet(ts); break; } } // TODO: have list presenter before (instead of one) m.setCurrentComponent((Component) pres.getView().getComponent()); setContent(m); // and go pres.startPresenting(); }
From source file:de.catma.ui.CatmaApplication.java
License:Open Source License
@Override protected void init(VaadinRequest request) { backgroundService = new UIBackgroundService(true); storeParameters(request.getParameterMap()); Page.getCurrent().setTitle("CATMA 5.0 " + MINORVERSION); mainLayout = new VerticalLayout(); mainLayout.setSizeFull();// www.j a v a 2 s . c om menuPanel = new Panel(); menuPanel.addStyleName("menuPanel"); mainLayout.addComponent(menuPanel); contentPanel = new Panel(); contentPanel.setHeight("100%"); contentPanel.addStyleName("contentPanel"); defaultContentPanelLabel = new Label("Please log in to get started"); defaultContentPanelLabel.addStyleName("defaultContentPanelLabel"); contentPanel.setContent(defaultContentPanelLabel); mainLayout.addComponent(contentPanel); mainLayout.setExpandRatio(contentPanel, 1.0f); menuLayout = new HorizontalLayout(); menuLayout.setMargin(true); menuLayout.setSpacing(true); logoResource = new ThemeResource("catma-logo.png"); Link logoImage = new Link(null, new ExternalResource("http://www.catma.de")); logoImage.setIcon(logoResource); logoImage.setTargetName("_blank"); menuLayout.addComponent(logoImage); MenuFactory menuFactory = new MenuFactory(); try { initTempDirectory(); tagManager = new TagManager(); repositoryManagerView = new RepositoryManagerView( new RepositoryManager(this, tagManager, RepositoryProperties.INSTANCE.getProperties())); tagManagerView = new TagManagerView(tagManager); taggerManagerView = new TaggerManagerView(); analyzerManagerView = new AnalyzerManagerView(); visualizationManagerView = new VisualizationManagerView(); menu = menuFactory.createMenu(menuLayout, contentPanel, new MenuFactory.MenuEntryDefinition("Repository Manager", repositoryManagerView), new MenuFactory.MenuEntryDefinition("Tag Type Manager", tagManagerView), new MenuFactory.MenuEntryDefinition("Tagger", taggerManagerView), new MenuFactory.MenuEntryDefinition("Analyzer", analyzerManagerView), new MenuFactory.MenuEntryDefinition("Visualizer", visualizationManagerView)); addPropertyChangeListener(CatmaApplicationEvent.userChange, menu.userChangeListener); Link latestFeaturesLink = new Link("Latest Features", new ExternalResource("http://www.catma.de/latestfeatures")); latestFeaturesLink.setTargetName("_blank"); menuLayout.addComponent(latestFeaturesLink); menuLayout.setComponentAlignment(latestFeaturesLink, Alignment.TOP_RIGHT); menuLayout.setExpandRatio(latestFeaturesLink, 1.0f); Link aboutLink = new Link("About", new ExternalResource("http://www.catma.de")); aboutLink.setTargetName("_blank"); menuLayout.addComponent(aboutLink); menuLayout.setComponentAlignment(aboutLink, Alignment.TOP_RIGHT); Link termsOfUseLink = new Link("Terms of Use", new ExternalResource("http://www.catma.de/termsofuse")); termsOfUseLink.setTargetName("_blank"); menuLayout.addComponent(termsOfUseLink); menuLayout.setComponentAlignment(termsOfUseLink, Alignment.TOP_RIGHT); Link manualLink = new Link("Manual", new ExternalResource(request.getContextPath() + "/manual/")); manualLink.setTargetName("_blank"); menuLayout.addComponent(manualLink); menuLayout.setComponentAlignment(manualLink, Alignment.TOP_RIGHT); Link helpLink = new Link("Helpdesk", new ExternalResource("http://www.catma.de/helpdesk/")); helpLink.setTargetName("_blank"); menuLayout.addComponent(helpLink); menuLayout.setComponentAlignment(helpLink, Alignment.TOP_RIGHT); helpLink.setVisible(false); btHelp = new Button(FontAwesome.QUESTION_CIRCLE); btHelp.addStyleName("help-button"); btHelp.addStyleName("application-help-button"); menuLayout.addComponent(btHelp); btHelp.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { if (uiHelpWindow.getParent() == null) { UI.getCurrent().addWindow(uiHelpWindow); } else { UI.getCurrent().removeWindow(uiHelpWindow); } } }); LoginLogoutCommand loginLogoutCommand = new LoginLogoutCommand(menu, repositoryManagerView); Button btloginLogout = new Button("Sign in", event -> loginLogoutCommand.menuSelected(null)); btloginLogout.setStyleName(BaseTheme.BUTTON_LINK); btloginLogout.addStyleName("application-loginlink"); loginLogoutCommand.setLoginLogoutButton(btloginLogout); menuLayout.addComponent(btloginLogout); menuLayout.setComponentAlignment(btloginLogout, Alignment.TOP_RIGHT); menuLayout.setWidth("100%"); menuPanel.setContent(menuLayout); setContent(mainLayout); if (getParameter(Parameter.USER_IDENTIFIER) != null) { btloginLogout.click(); } setPollInterval(10000); if ((getParameter(Parameter.AUTOLOGIN) != null) && (getUser() == null)) { getPage().setLocation(repositoryManagerView.createAuthenticationDialog().createLogInClick(this, RepositoryPropertyKey.CATMA_oauthAuthorizationCodeRequestURL.getValue(), RepositoryPropertyKey.CATMA_oauthAccessTokenRequestURL.getValue(), RepositoryPropertyKey.CATMA_oauthClientId.getValue(), RepositoryPropertyKey.CATMA_oauthClientSecret.getValue(), URLEncoder.encode("/", "UTF-8"))); } } catch (Exception e) { showAndLogError("The system could not be initialized!", e); } }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.ProxyForGenomeViewerRestApi.java
License:Open Source License
@Override public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { if (UI.getCurrent() != null && UI.getCurrent().getPage() != null && UI.getCurrent().getPage().getUriFragment() != null) { System.out.println(UI.getCurrent().getPage().getUriFragment()); }//from ww w. jav a 2 s . c om System.out.println("is handling request"); System.out.println(request.getPathInfo()); System.out.println(request.getContextPath()); PortletRequest portletRequest = VaadinPortletService.getCurrentPortletRequest(); Map<String, String[]> para = request.getParameterMap(); Set<Entry<String, String[]>> s = para.entrySet(); Iterator<Entry<String, String[]>> it = s.iterator(); while (it.hasNext()) { Entry<String, String[]> en = it.next(); System.out.println("Key: " + en.getKey()); System.out.println("Value:"); for (int i = 0; i < en.getValue().length; i++) { System.out.println(en.getValue()[i]); } System.out.println("Next"); } Enumeration<String> enu = portletRequest.getParameterNames(); while (enu.hasMoreElements()) { String su = enu.nextElement(); System.out.println(su + " " + portletRequest.getParameter(su)); } enu = portletRequest.getPropertyNames(); while (enu.hasMoreElements()) { String su = enu.nextElement(); System.out.println(su + " " + portletRequest.getProperty(su)); } HttpServletRequest httpRequest = PortalUtil.getHttpServletRequest(portletRequest); System.out.println(httpRequest.getPathInfo()); enu = httpRequest.getParameterNames(); while (enu.hasMoreElements()) { String su = enu.nextElement(); System.out.println(su + " " + httpRequest.getParameter(su)); } System.out.println(httpRequest.getQueryString()); enu = PortalUtil.getOriginalServletRequest(httpRequest).getParameterNames(); System.out.println(PortalUtil.getOriginalServletRequest(httpRequest).getPathInfo()); while (enu.hasMoreElements()) { String su = enu.nextElement(); System.out.println(su + " " + PortalUtil.getOriginalServletRequest(httpRequest).getParameter(su)); } if (!String.valueOf(session).equals(request.getPathInfo())) { return false; } String fileId = request.getParameter("fileId"); String filepaths = request.getParameter("filepath"); String removeZeroGenotypes = request.getParameter("removeZeroGenotypes"); String region = request.getParameter("region"); String interval = request.getParameter("interval"); String histogram = request.getParameter("histogram"); URL u; try { StringBuilder sb = new StringBuilder(); sb.append(ConfigurationManagerFactory.getInstance().getGenomeViewerRestApiUrl()); sb.append(fileId); sb.append("/fetch?filepaths="); sb.append(filepaths); sb.append("®ion="); sb.append(region); if (interval != null) { sb.append("&interval="); sb.append(interval); } if (histogram != null) { sb.append("&histogram="); sb.append(histogram); } if (removeZeroGenotypes != null) { sb.append(""); } u = new URL(sb.toString()); // u = new // URL("http://localhost:7777/vizrest/rest/data/QBAMS001AB.bam/fetch?filepaths=/store/1/0EEF79A2-8140-4FC7-BA67-E51908FE4619/f0/91/36/20141116104428925-3161/original/QBAMS001AB.bam&removeZeroGenotypes=false®ion=9:117163200-117164799,9:117164800-117166399,9:117166400-117167999,9:117168000-117169599&interval=1600&h"); URLConnection urlConnection = u.openConnection(); urlConnection.setUseCaches(false); urlConnection.setDoOutput(false); urlConnection.connect(); InputStream is = urlConnection.getInputStream(); response.setContentType("application/json"); response.setHeader("Content-Type", "application/json"); OutputStream out = response.getOutputStream(); byte[] buffer = new byte[com.vaadin.server.Constants.DEFAULT_BUFFER_SIZE]; while (true) { int readCount = is.read(buffer); if (readCount < 0) { break; } out.write(buffer, 0, readCount); } } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return true; }
From source file:org.rapidpm.ddi.DDIVaadinServletService.java
License:Apache License
@Override public void handleRequest(VaadinRequest request, VaadinResponse response) throws ServiceException { super.handleRequest(request, response); System.out.println("handleRequest-request = " + request.getContextPath()); }