Example usage for com.vaadin.server VaadinPortletService getCurrentPortletRequest

List of usage examples for com.vaadin.server VaadinPortletService getCurrentPortletRequest

Introduction

In this page you can find the example usage for com.vaadin.server VaadinPortletService getCurrentPortletRequest.

Prototype

public static PortletRequest getCurrentPortletRequest() 

Source Link

Document

Gets the currently processed portlet request.

Usage

From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.presenters.configuration.PreferencesPresenter.java

License:Apache License

@Override
public void storePreferencesAndFireConfigChange() {
    try {/*from  w  w w.  j a v a 2 s  .c  om*/
        getView().commit();

        VaadinPortletService.getCurrentPortletRequest().getPreferences().store();
        eventBus.fireEvent(new ConfigurationUpdatedEvent(true));

        getView().showNotification(Context.getMessage("portlet.crud.page.edit.storedSettings"));

    } catch (Exception e) {
        LOGGER.error("Error storing preferences", e);
        getView().showError(Context.getMessage("portlet.crud.error.storingPreferences"));
    }
}

From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.ui.PreferenceProperty.java

License:Apache License

private PortletPreferences preferences() {
    return VaadinPortletService.getCurrentPortletRequest().getPreferences();
}

From source file:de.unioninvestment.eai.portal.support.vaadin.context.UIContextProvider.java

License:Apache License

@Override
public ApplicationContext getSpringContext() {
    PortletRequest currentRequest = VaadinPortletService.getCurrentPortletRequest();
    if (currentRequest != null) {
        PortletContext pc = currentRequest.getPortletSession().getPortletContext();
        org.springframework.context.ApplicationContext springContext = PortletApplicationContextUtils
                .getRequiredWebApplicationContext(pc);
        return springContext;

    } else {// w ww .  java  2s.co  m
        throw new IllegalStateException(
                "Found no current portlet request. Did you subclass PortletApplication in your Vaadin Application?");
    }
}

From source file:de.unioninvestment.eai.portal.support.vaadin.liferay.PermissionsUtil.java

License:Apache License

/**
 * Erzeugt einen Link zum ndern der Berechtigungen.
 * //w  ww  .  jav  a2s  .  c  o m
 * @param modelResource
 *            modelResource
 * @param resourcePrimKey
 *            resourcePrimKey
 * @param modelResourceDescription
 *            modelResourceDescription
 * @return URL
 */
public static String buildURL(String modelResource, String resourcePrimKey, String modelResourceDescription) {

    PortletRequest portletRequest = VaadinPortletService.getCurrentPortletRequest();
    HttpServletRequest request = PortalUtil.getHttpServletRequest(portletRequest);

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute("THEME_DISPLAY");
    Layout layout = themeDisplay.getLayout();

    PortletURL portletURL = PortletURLFactoryUtil.create(request, "86", layout.getPlid(), "RENDER_PHASE");

    try {
        if (themeDisplay.isStatePopUp()) {

            portletURL.setWindowState(LiferayWindowState.POP_UP);

        } else {
            portletURL.setWindowState(WindowState.MAXIMIZED);
        }
    } catch (WindowStateException e) {
        LOG.error(e.getMessage(), e);
    }
    portletURL.setParameter("struts_action", "/portlet_configuration/edit_permissions");
    portletURL.setParameter("portletResource", themeDisplay.getPortletDisplay().getId());
    portletURL.setParameter("modelResource", modelResource);
    portletURL.setParameter("modelResourceDescription", modelResourceDescription);
    portletURL.setParameter("resourcePrimKey", resourcePrimKey);

    String portletURLToString = portletURL.toString();

    return portletURLToString;
}

From source file:de.unioninvestment.eai.portal.support.vaadin.LiferayUI.java

License:Apache License

private void readContextInformationFromCurrentRequest() {
    PortletRequest currentRequest = VaadinPortletService.getCurrentPortletRequest();
    if (currentRequest != null) {
        portletId = (String) currentRequest.getAttribute(WebKeys.PORTLET_ID);

        ThemeDisplay themeDisplay = (ThemeDisplay) currentRequest.getAttribute(WebKeys.THEME_DISPLAY);
        communityId = themeDisplay.getScopeGroupId();
    }//from  www .j  ava  2s .c  om
}

From source file:de.unioninvestment.eai.portal.support.vaadin.ParameterRetrievalRequestHandler.java

License:Apache License

@Override
public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response)
        throws IOException {
    PortletRequest portletRequest = VaadinPortletService.getCurrentPortletRequest();
    if (portletRequest instanceof RenderRequest) {
        Map<String, String[]> allParameters = getOriginalServletRequestParameters(portletRequest);
        Map<String, String[]> parameters = copyParametersIgnoreLiferayPrefix(allParameters);
        session.setAttribute("parameters", parameters);
    }/*from   w w  w  .j a  va2 s. c  o  m*/
    return false;
}

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());
    }/*  www .  ja  v  a2s.  c o m*/
    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("&region=");
        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&region=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;
}