Search in sources :

Example 1 with WrappedSession

use of com.vaadin.server.WrappedSession in project cuba by cuba-platform.

the class AppUI method processExternalLink.

public void processExternalLink(VaadinRequest request) {
    WrappedSession wrappedSession = request.getWrappedSession();
    String action = (String) wrappedSession.getAttribute(LAST_REQUEST_ACTION_ATTR);
    if (webConfig.getLinkHandlerActions().contains(action)) {
        // noinspection unchecked
        Map<String, String> params = (Map<String, String>) wrappedSession.getAttribute(LAST_REQUEST_PARAMS_ATTR);
        params = params != null ? params : Collections.emptyMap();
        try {
            LinkHandler linkHandler = AppBeans.getPrototype(LinkHandler.NAME, app, action, params);
            if (app.connection.isConnected() && linkHandler.canHandleLink()) {
                linkHandler.handle();
            } else {
                app.linkHandler = linkHandler;
            }
        } catch (Exception e) {
            error(new com.vaadin.server.ErrorEvent(e));
        }
    }
}
Also used : WrappedSession(com.vaadin.server.WrappedSession) LinkHandler(com.haulmont.cuba.web.sys.LinkHandler) LoginException(com.haulmont.cuba.security.global.LoginException)

Example 2 with WrappedSession

use of com.vaadin.server.WrappedSession in project ANNIS by korpling.

the class Helper method getUser.

public static AnnisUser getUser() {
    VaadinSession vSession = VaadinSession.getCurrent();
    WrappedSession wrappedSession = null;
    if (vSession != null) {
        wrappedSession = vSession.getSession();
    }
    if (wrappedSession != null) {
        Object o = VaadinSession.getCurrent().getSession().getAttribute(AnnisBaseUI.USER_KEY);
        if (o != null && o instanceof AnnisUser) {
            return (AnnisUser) o;
        }
    }
    return null;
}
Also used : VaadinSession(com.vaadin.server.VaadinSession) WrappedSession(com.vaadin.server.WrappedSession)

Example 3 with WrappedSession

use of com.vaadin.server.WrappedSession in project cuba by cuba-platform.

the class LinkHandler method handle.

/**
 * Called to handle the link.
 */
public void handle() {
    try {
        ExternalLinkContext linkContext = new ExternalLinkContext(requestParams, action, app);
        for (LinkHandlerProcessor processor : processors) {
            if (processor.canHandle(linkContext)) {
                processor.handle(linkContext);
                break;
            }
        }
    } finally {
        VaadinRequest request = VaadinService.getCurrentRequest();
        WrappedSession wrappedSession = request.getWrappedSession();
        wrappedSession.removeAttribute(AppUI.LAST_REQUEST_PARAMS_ATTR);
        wrappedSession.removeAttribute(AppUI.LAST_REQUEST_ACTION_ATTR);
    }
}
Also used : LinkHandlerProcessor(com.haulmont.cuba.web.sys.linkhandling.LinkHandlerProcessor) WrappedSession(com.vaadin.server.WrappedSession) VaadinRequest(com.vaadin.server.VaadinRequest) ExternalLinkContext(com.haulmont.cuba.web.sys.linkhandling.ExternalLinkContext)

Example 4 with WrappedSession

use of com.vaadin.server.WrappedSession in project linkki by linkki-framework.

the class DynamicFieldUI method getCarStorage.

// some fake persistent storage
// store the cars in the session so it is available after a browser
// refresh as long as we are in the same session
private List<Car> getCarStorage() {
    List<Car> carStorage;
    WrappedSession session = CurrentInstance.get(VaadinSession.class).getSession();
    @SuppressWarnings("unchecked") List<Car> storage = (List<Car>) session.getAttribute(CAR_STORAGE_ATTRIBUTE);
    if (storage != null) {
        carStorage = storage;
    } else {
        carStorage = new ArrayList<>();
        addCars(carStorage);
        session.setAttribute(CAR_STORAGE_ATTRIBUTE, carStorage);
    }
    return carStorage;
}
Also used : VaadinSession(com.vaadin.server.VaadinSession) Car(org.linkki.samples.dynamicfield.model.Car) WrappedSession(com.vaadin.server.WrappedSession) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with WrappedSession

use of com.vaadin.server.WrappedSession in project VaadinUtils by rlsutton1.

the class JasperManager method exportAsync.

public void exportAsync(OutputFormat exportMethod, Collection<ReportParameter<?>> params, JasperProgressListener progressListener) {
    if (params == null) {
        params = new LinkedList<>();
    }
    this.params = params;
    images = new ConcurrentHashMap<>();
    if (UI.getCurrent() != null) {
        WrappedSession session = UI.getCurrent().getSession().getSession();
        session.setAttribute(VaadinJasperPrintServlet.IMAGES_MAP, images);
    } else {
        logger.warn("No vaadin UI present");
    }
    stop = false;
    writerReady = new CountDownLatch(1);
    completeBarrier = new CountDownLatch(1);
    readerReady = new CountDownLatch(1);
    this.progressListener = progressListener;
    if (progressListener == null) {
        this.progressListener = new JasperProgressListener() {

            @Override
            public void failed(String string) {
            // noop
            }

            @Override
            public void completed() {
            // noop
            }

            @Override
            public void outputStreamReady() {
            // noop
            }
        };
    }
    inputStream = null;
    outputStream = null;
    queueEntry = new QueueEntry(reportProperties.getReportTitle(), reportProperties.getUsername());
    inQueue = true;
    jobQueue.add(queueEntry);
    this.exportMethod = exportMethod;
    thread = new Thread(this, "JasperManager");
    thread.start();
}
Also used : WrappedSession(com.vaadin.server.WrappedSession) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

WrappedSession (com.vaadin.server.WrappedSession)5 VaadinSession (com.vaadin.server.VaadinSession)2 LoginException (com.haulmont.cuba.security.global.LoginException)1 LinkHandler (com.haulmont.cuba.web.sys.LinkHandler)1 ExternalLinkContext (com.haulmont.cuba.web.sys.linkhandling.ExternalLinkContext)1 LinkHandlerProcessor (com.haulmont.cuba.web.sys.linkhandling.LinkHandlerProcessor)1 VaadinRequest (com.vaadin.server.VaadinRequest)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Car (org.linkki.samples.dynamicfield.model.Car)1