Example usage for com.vaadin.server VaadinSession getCurrent

List of usage examples for com.vaadin.server VaadinSession getCurrent

Introduction

In this page you can find the example usage for com.vaadin.server VaadinSession getCurrent.

Prototype

public static VaadinSession getCurrent() 

Source Link

Document

Gets the currently used session.

Usage

From source file:org.bubblecloud.ilves.site.SecurityProviderSessionImpl.java

License:Apache License

/**
 * Sets roles to session.//from ww w. j a  va 2s  .c om
 * @param roles the roles
 */
private void setRolesToSession(final List<String> roles) {
    VaadinSession.getCurrent().setAttribute("roles", roles);
    VaadinSession.getCurrent().getSession().setAttribute("roles", roles);
}

From source file:org.hip.vif.admin.admin.print.FileDownloaderExtension.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override/*from  w ww  .  j  a  v  a 2  s. c  o m*/
public boolean handleConnectorRequest(final VaadinRequest inRequest, final VaadinResponse inResponse,
        final String inPath) throws IOException {
    if (!inPath.matches("dl(/.*)?")) {
        // Ignore if it isn't for us
        return false;
    }

    final VaadinSession lSession = getSession();
    lSession.lock();

    DownloadStream lDownloadStream = null;
    try {
        final Collection<GroupWrapper> lSelected = (Collection<GroupWrapper>) groupSelect.getValue();
        Collection<GroupExtent> lGroups = new ArrayList<GroupExtent>();
        for (final GroupWrapper lGroup : lSelected) {
            final Long lGroupID = lGroup.getGroupID();
            if (lGroupID.equals(0l)) {
                lGroups = printTask.getAllGroups();
                break;
            } else {
                lGroups.add(new GroupExtent(lGroup.getGroupID()));
            }
        }

        final DownloadFile lDownloadFile = new DownloadFile(lGroups, VaadinSession.getCurrent().getLocale());
        lDownloadStream = lDownloadFile.getStream();
    } catch (final Exception exc) {
        LOG.error("Error encountered while printing the discussion groups!", exc); //$NON-NLS-1$
    } finally {
        lSession.unlock();
    }
    if (lDownloadStream != null) {
        lDownloadStream.writeResponse(inRequest, inResponse);
    }
    groupSelect.clear();
    return true;
}

From source file:org.hip.vif.app.admin.AdminApplication.java

License:Open Source License

@Override
protected void beforeInitializeLayout() { // NOPMD
    VIFAppHelper.initializeContext();//from  ww w  .  java2 s  . co  m
    Page.getCurrent().setTitle(APP_NAME);

    eventDispatcher = new VIFEventDispatcher();
    eventDispatcher.setApplication(this);
    try {
        VaadinSession.getCurrent().getLockInstance().lock();
        VaadinSession.getCurrent().setAttribute(IVIFEventDispatcher.class, eventDispatcher);
    } finally {
        VaadinSession.getCurrent().getLockInstance().unlock();
    }
    final DBConnectionProber lDBProber = new DBConnectionProber();
    if (lDBProber.isReady()) {
        initializePermissions();
    }
    super.beforeInitializeLayout();
}

From source file:org.hip.vif.app.admin.scr.ToolbarItemLogout.java

License:Open Source License

@SuppressWarnings("serial")
@Override/* w w  w  .  j  a  v  a 2  s  . c  o  m*/
public Component getComponent() {
    final HorizontalLayout out = new HorizontalLayout();
    out.setSizeUndefined();
    final Button lLogout = new Button(Activator.getMessages().getMessage("toolbar.logout.label"));
    lLogout.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent inEvent) {
            if (inEvent.getButton() != lLogout) {
                return;
            }

            if (listener != null) {
                listener.processAction(new IToolbarAction() {
                    @Override
                    public void run() {
                        VaadinSession.getCurrent().getAttribute(IRiplaEventDispatcher.class)
                                .dispatch(IRiplaEventDispatcher.Event.LOGOUT, new HashMap<String, Object>());
                    }
                });
            }
        }
    });
    lLogout.setStyleName(BaseTheme.BUTTON_LINK);
    out.addComponent(lLogout);
    return out;
}

From source file:org.hip.vif.app.forum.ForumApplication.java

License:Open Source License

@Override
protected void beforeInitializeLayout() { // NOPMD
    VIFAppHelper.initializeContext();//from w  w w . j  av a  2s .com
    Page.getCurrent().setTitle(APP_NAME);

    eventDispatcher = new VIFEventDispatcher();
    try {
        VaadinSession.getCurrent().getLockInstance().lock();
        VaadinSession.getCurrent().setAttribute(IVIFEventDispatcher.class, eventDispatcher);
    } finally {
        VaadinSession.getCurrent().getLockInstance().unlock();
    }
    initializePermissions();
    super.beforeInitializeLayout();
}

From source file:org.hip.vif.web.internal.controller.ActorManager.java

License:Open Source License

@Override
public void setActorToContext(final Long inMemberID, final String inUserID) throws VException {
    final IActor lActor = new Actor(inMemberID, inUserID);
    try {/*from   ww  w  .  j  av  a2 s  . c  o  m*/
        VaadinSession.getCurrent().getLockInstance().lock();
        VaadinSession.getCurrent().setAttribute(IActor.class, lActor);
    } finally {
        VaadinSession.getCurrent().getLockInstance().unlock();
    }
    try {
        RoleHelper.mapUserToRole(lActor, userAdmin);
    } catch (final SQLException exc) {
        LOG.error("An error encountered while creating the OSGi user object!", exc);
    }
}

From source file:org.hip.vif.web.tasks.AbstractWebController.java

License:Open Source License

/** @return {@link IActor} the actor, i.e. the actual user. */
protected IActor getActor() {
    try {//from  w ww .j  a va  2 s .  co  m
        VaadinSession.getCurrent().getLockInstance().lock();
        return VaadinSession.getCurrent().getAttribute(IActor.class);
    } finally {
        VaadinSession.getCurrent().getLockInstance().unlock();
    }
}

From source file:org.hip.vif.web.tasks.AbstractWebController.java

License:Open Source License

private IRiplaEventDispatcher getRiplaDispatcher() {
    try {/*from ww w  .j  a  v  a  2s . c  o  m*/
        VaadinSession.getCurrent().getLockInstance().lock();
        return VaadinSession.getCurrent().getAttribute(IRiplaEventDispatcher.class);
    } finally {
        VaadinSession.getCurrent().getLockInstance().unlock();
    }
}

From source file:org.hip.vif.web.tasks.AbstractWebController.java

License:Open Source License

private IVIFEventDispatcher getDispatcher() {
    try {//from w w  w .j  a v a 2  s .  co  m
        VaadinSession.getCurrent().getLockInstance().lock();
        return VaadinSession.getCurrent().getAttribute(IVIFEventDispatcher.class);
    } finally {
        VaadinSession.getCurrent().getLockInstance().unlock();
    }
}

From source file:org.hip.vif.web.tasks.AbstractWebController.java

License:Open Source License

protected Locale getLocaleChecked() { // NOPMD
    try {//from   ww  w.  ja v a2 s . c om
        VaadinSession.getCurrent().getLockInstance().lock();
        return VaadinSession.getCurrent().getLocale();
    } finally {
        VaadinSession.getCurrent().getLockInstance().unlock();
    }
}