Package javax.portlet

Examples of javax.portlet.PortletSession


     * @see javax.portlet.Portlet#processAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse)
     */
    public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException
    {

        PortletSession session = request.getPortletSession();
        String language = request.getParameter(PREFERED_LOCALE_SESSION_KEY);

        if (language != null)
        {
            String[] localeArray = language.split("[-|_]");
            String country = "";
            String variant = "";
            for (int i = 0; i < localeArray.length; i++)
            {
                if (i == 0)
                {
                    language = localeArray[i];
                }
                else if (i == 1)
                {
                    country = localeArray[i];
                }
                else if (i == 2)
                {
                    variant = localeArray[i];
                }
            }

            Locale preferedLocale = new Locale(language, country, variant);

            if (request.getRemoteUser() != null)
            {
                // Set the prefered locale to user's perferences(persistent storage) if not anon user
                try
                {
                    User user = userManager.getUser(request.getRemoteUser());
                    // TODO if preferred lang or locale is defined in PLT.D, it's better to use it
                    SecurityAttributes secAttrs = user.getSecurityAttributes();
                    secAttrs.getAttribute(PortalReservedParameters.PREFERED_LOCALE_ATTRIBUTE, true).setStringValue(JetspeedLocale.convertLocaleToString(preferedLocale));
                    userManager.updateUser(user);
                }
                catch (SecurityException e)
                {
                    logger.error("Failed to update security attributes with preferred locale.", e);
                }
            }

            session.setAttribute(PortalReservedParameters.PREFERED_LOCALE_ATTRIBUTE, preferedLocale,
                    PortletSession.APPLICATION_SCOPE);
            RequestContext requestContext = (RequestContext) request
                    .getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
            requestContext.setLocale(preferedLocale);
            requestContext.setSessionAttribute(PortalReservedParameters.PREFERED_LOCALE_ATTRIBUTE, preferedLocale);
View Full Code Here


    public void doView(RenderRequest request, RenderResponse response)
            throws PortletException, IOException
    {
        Context velocityContext = getContext(request);
        PortletSession session = request.getPortletSession();

        StatisticsQueryCriteria sqc = (StatisticsQueryCriteria) session
                .getAttribute(SESSION_CRITERIA);
        AggregateStatistics stats = (AggregateStatistics) session
                .getAttribute(SESSION_RESULTS);
        if (stats == null)
        {
            if (sqc == null)
            {
                // if we get here, we're on the first startup.
                sqc = statistics.createStatisticsQueryCriteria();
                sqc.setQueryType(PortalStatistics.QUERY_TYPE_PORTLET);
                sqc.setTimePeriod("1");
                sqc.setListsize("5");
                sqc.setSorttype("count");
                sqc.setSortorder("desc");
                session.setAttribute(SESSION_CRITERIA, sqc);

                try
                {
                    statistics.forceFlush();
                    stats = statistics.queryStatistics(sqc);
                } catch (InvalidCriteriaException e)
                {
                    logger.warn("unable to complete a statistics query ", e);
                }
                session.setAttribute(SESSION_RESULTS, stats);

            }
        }
        velocityContext.put(SESSION_TOTALSESSIONS, ""
                + statistics.getNumberOfLoggedInUsers());
View Full Code Here

    }

    public void processAction(ActionRequest request,
            ActionResponse actionResponse) throws PortletException, IOException
    {
        PortletSession session = request.getPortletSession();
        StatisticsQueryCriteria criteria = statistics.createStatisticsQueryCriteria();
       
        String user = request.getParameter("user");
        criteria.setUser(user);
        String timeperiod = request.getParameter("timeperiod");
        if (timeperiod == null)
        {
            timeperiod = "all";
        }
       
        String listsizeStr = request.getParameter("listsize");
        if(listsizeStr == null)
        {
            listsizeStr = "5";
        } else
        {
           try
            {
                Integer.parseInt(listsizeStr);
            } catch (NumberFormatException e)
            {
                // if we can't parse it.. just make it 5
                listsizeStr = "5";
            }
        }
        criteria.setListsize(listsizeStr);
        criteria.setSorttype("count");
        criteria.setSortorder("desc");

        criteria.setTimePeriod(timeperiod);
        String queryType = request.getParameter("queryType");

        criteria.setQueryType(queryType);
        AggregateStatistics stats = statistics.getDefaultEmptyAggregateStatistics();
        try
        {
            statistics.forceFlush();
            stats = statistics.queryStatistics(criteria);
        } catch (InvalidCriteriaException e)
        {
            logger.warn("unable to complete a statistics query ", e);
        }
        // save this to session for later display/edit
        session.setAttribute(SESSION_CRITERIA, criteria);
        session.setAttribute(SESSION_RESULTS, stats);

    }
View Full Code Here

        model.put("constraintsEnabled", new Boolean(constraintsEnabled));
        PageSecurity constraints = pageManager.getPageSecurity();       
        model.put("defs", constraints.getSecurityConstraintsDefs());
        model.put("globals", constraints.getGlobalSecurityConstraintsRefs());

        PortletSession session = request.getPortletSession();
        List<Role> roles = (List<Role>) session.getAttribute(ROLES_CACHE_SESSION_ATTRIBUTE_NAME, PortletSession.PORTLET_SCOPE);
        if ( roles == null )
        {
            try
            {
                roles = rm.getRoles("");
                session.setAttribute(ROLES_CACHE_SESSION_ATTRIBUTE_NAME, roles, PortletSession.PORTLET_SCOPE);
            }
            catch(Exception e)
            {
                logger.error( "Could not get list of roles from RoleManager.", e);
            }
        }
        model.put("roles", roles);

        List<Group> groups = (List<Group>) session.getAttribute(GROUPS_CACHE_SESSION_ATTRIBUTE_NAME, PortletSession.PORTLET_SCOPE);
        if ( groups == null )
        {
            try
            {
                groups = gm.getGroups("");
                session.setAttribute(GROUPS_CACHE_SESSION_ATTRIBUTE_NAME, groups, PortletSession.PORTLET_SCOPE);
            }
            catch(Exception e)
            {
                logger.error( "Could not get list of groups from GroupManager.", e);
            }
View Full Code Here

            String value = request.getParameter(params[i]);
            if(value != null) request.setAttribute(params[i], value);
        }
        KeystoreManager manager = PortletManager.getCurrentServer(request).getKeystoreManager();
        KeystoreInstance[] keystores = manager.getKeystores();
        PortletSession session = request.getPortletSession(true);
        KeystoreData[] datas = new KeystoreData[keystores.length];
        Map keys = new HashMap();
        for (int i = 0; i < datas.length; i++) {
            AbstractName aName = PortletManager.getNameFor(request, keystores[i]);
            String name = (String) aName.getName().get(NameFactory.J2EE_NAME);
            KeystoreData data = (KeystoreData) session.getAttribute(KEYSTORE_DATA_PREFIX+name);
            if(data == null) {
                data = new KeystoreData();
                data.setInstance(keystores[i]);
                session.setAttribute(KEYSTORE_DATA_PREFIX+name, data);
            }
            datas[i] = data;
            if(!data.getInstance().isKeystoreLocked()) {
                try {
                    String[] all = data.getInstance().getUnlockedKeys(null);
View Full Code Here

    private void renderTestLoginForm(RenderRequest request, RenderResponse response) throws IOException, PortletException {
        testLoginView.include(request, response);
    }

    private void renderTestResults(RenderRequest request, RenderResponse response) throws IOException, PortletException {
        PortletSession session = request.getPortletSession();
        String status = (String) session.getAttribute("TestLoginError");
        if (status == null) {
            Set principals = (Set) session.getAttribute("TestLoginPrincipals");
            status = "Login succeeded with " + (principals == null ? 0 : principals.size()) + " principals";
            request.setAttribute("principals", principals);
        }
        request.setAttribute("LoginResults", status);
        testResultsView.include(request, response);
View Full Code Here

        usageView = null;
        super.destroy();
    }

    public DriverDownloader.DriverInfo[] getDriverInfo(PortletRequest request) {
        PortletSession session = request.getPortletSession(true);
        DriverDownloader.DriverInfo[] results = (DriverDownloader.DriverInfo[]) session.getAttribute(DRIVER_SESSION_KEY, PortletSession.APPLICATION_SCOPE);
        if(results == null) {
            DriverDownloader downloader = new DriverDownloader();
            try {
                results = downloader.loadDriverInfo(new URL(DRIVER_INFO_URL));
                session.setAttribute(DRIVER_SESSION_KEY, results, PortletSession.APPLICATION_SCOPE);
            } catch (MalformedURLException e) {
                log.error("Unable to download driver data", e);
                results = new DriverDownloader.DriverInfo[0];
            }
        }
View Full Code Here

     * @param rarPath            If we're creating a new RA, the path to identify it
     * @param displayName        If we're editing an existing RA, its name
     * @param adapterAbstractName  If we're editing an existing RA, its AbstractName
     */
    public ResourceAdapterParams getRARConfiguration(PortletRequest request, String rarPath, String displayName, String adapterAbstractName) {
        PortletSession session = request.getPortletSession(true);
        if(rarPath != null && !rarPath.equals("")) {
            ResourceAdapterParams results = (ResourceAdapterParams) session.getAttribute(CONFIG_SESSION_KEY+"-"+rarPath, PortletSession.APPLICATION_SCOPE);
            if(results == null) {
                results = loadConfigPropertiesByPath(request, rarPath);
                session.setAttribute(CONFIG_SESSION_KEY+"-"+rarPath, results, PortletSession.APPLICATION_SCOPE);
                session.setAttribute(CONFIG_SESSION_KEY+"-"+results.displayName, results, PortletSession.APPLICATION_SCOPE);
            }
            return results;
        } else if(displayName != null && !displayName.equals("") && adapterAbstractName != null && !adapterAbstractName.equals("")) {
            ResourceAdapterParams results = (ResourceAdapterParams) session.getAttribute(CONFIG_SESSION_KEY+"-"+displayName, PortletSession.APPLICATION_SCOPE);
            if(results == null) {
                results = loadConfigPropertiesByAbstractName(request, adapterAbstractName);
                session.setAttribute(CONFIG_SESSION_KEY+"-"+displayName, results, PortletSession.APPLICATION_SCOPE);
            }
            return results;
        } else {
            throw new IllegalArgumentException();
        }
View Full Code Here

                }
            }
            if(found != null) {
                data.jars = new String[] {found.getRepositoryURI()};
                WriteableRepository repo = PortletManager.getCurrentServer(actionRequest).getWritableRepositories()[0];
                final PortletSession session = actionRequest.getPortletSession();
                ProgressInfo progressInfo = new ProgressInfo();
                progressInfo.setMainMessage("Downloading " + found.getName());
                session.setAttribute(ProgressInfo.PROGRESS_INFO_KEY, progressInfo, PortletSession.APPLICATION_SCOPE);
                // Start the download monitoring
                new Thread(new Downloader(found, progressInfo, repo)).start();
                actionResponse.setRenderParameter(MODE_KEY, DOWNLOAD_STATUS_MODE);
            } else {
                actionResponse.setRenderParameter(MODE_KEY, DOWNLOAD_MODE);
View Full Code Here

     * @param displayName         If we're editing an existing RA, its name
     * @param adapterAbstractName If we're editing an existing RA, its AbstractName
     * @return resource adapter parameter data object
     */
    public ResourceAdapterParams getRARConfiguration(PortletRequest request, String rarPath, String displayName, String adapterAbstractName) {
        PortletSession session = request.getPortletSession(true);
        if (rarPath != null && !rarPath.equals("")) {
            ResourceAdapterParams results = (ResourceAdapterParams) session.getAttribute(
                    CONFIG_SESSION_KEY + "-" + rarPath, PortletSession.APPLICATION_SCOPE);
            if (results == null) {
                results = loadConfigPropertiesByPath(request, rarPath);
                session.setAttribute(CONFIG_SESSION_KEY + "-" + rarPath, results, PortletSession.APPLICATION_SCOPE);
                session.setAttribute(CONFIG_SESSION_KEY + "-" + results.displayName, results,
                        PortletSession.APPLICATION_SCOPE);
            }
            return results;
        } else if (displayName != null && !displayName.equals(
                "") && adapterAbstractName != null && !adapterAbstractName.equals("")) {
            ResourceAdapterParams results = (ResourceAdapterParams) session.getAttribute(
                    CONFIG_SESSION_KEY + "-" + displayName, PortletSession.APPLICATION_SCOPE);
            if (results == null) {
                results = loadConfigPropertiesByAbstractName(request, adapterAbstractName);
                session.setAttribute(CONFIG_SESSION_KEY + "-" + displayName, results, PortletSession.APPLICATION_SCOPE);
            }
            return results;
        } else {
            throw new IllegalArgumentException();
        }
View Full Code Here

TOP

Related Classes of javax.portlet.PortletSession

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.