From portal-commits at lists.jboss.org Sat May 24 13:23:44 2008 Content-Type: multipart/mixed; boundary="===============1206304749977137041==" MIME-Version: 1.0 From: portal-commits at lists.jboss.org To: portal-commits at lists.jboss.org Subject: [portal-commits] JBoss Portal SVN: r10810 - in branches/JBoss_Portal_Branch_2_6/core-samples/src: resources/portal-users-samples-war/WEB-INF and 2 other directories. Date: Sat, 24 May 2008 13:23:43 -0400 Message-ID: --===============1206304749977137041== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: sviluppatorefico Date: 2008-05-24 13:23:43 -0400 (Sat, 24 May 2008) New Revision: 10810 Added: branches/JBoss_Portal_Branch_2_6/core-samples/src/resources/portal-users= -samples-war/WEB-INF/jsp/users/help.jsp Modified: branches/JBoss_Portal_Branch_2_6/core-samples/src/main/org/jboss/portal/= core/samples/users/CurrentUsersPortlet.java branches/JBoss_Portal_Branch_2_6/core-samples/src/resources/portal-users= -samples-war/WEB-INF/classes/Resource.properties branches/JBoss_Portal_Branch_2_6/core-samples/src/resources/portal-users= -samples-war/WEB-INF/classes/Resource_it.properties branches/JBoss_Portal_Branch_2_6/core-samples/src/resources/portal-users= -samples-war/WEB-INF/jsp/users/oneUser.jsp branches/JBoss_Portal_Branch_2_6/core-samples/src/resources/portal-users= -samples-war/WEB-INF/jsp/users/users.jsp branches/JBoss_Portal_Branch_2_6/core-samples/src/resources/portal-users= -samples-war/WEB-INF/portlet.xml Log: I add customization and help page for current users portlet. See http://jira.jboss.org/jira/browse/JBPORTAL-2026 Modified: branches/JBoss_Portal_Branch_2_6/core-samples/src/main/org/jboss/= portal/core/samples/users/CurrentUsersPortlet.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/JBoss_Portal_Branch_2_6/core-samples/src/main/org/jboss/portal= /core/samples/users/CurrentUsersPortlet.java 2008-05-24 01:39:58 UTC (rev 1= 0809) +++ branches/JBoss_Portal_Branch_2_6/core-samples/src/main/org/jboss/portal= /core/samples/users/CurrentUsersPortlet.java 2008-05-24 17:23:43 UTC (rev 1= 0810) @@ -22,6 +22,15 @@ = package org.jboss.portal.core.samples.users; = +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Set; + +import javax.portlet.PortletException; +import javax.portlet.PortletRequestDispatcher; +import javax.portlet.PortletSecurityException; +import javax.portlet.UnavailableException; + import org.apache.log4j.Logger; import org.jboss.portal.core.identity.UsersActivityStatsService; import org.jboss.portal.core.servlet.jsp.PortalJsp; @@ -30,67 +39,74 @@ import org.jboss.portlet.JBossRenderRequest; import org.jboss.portlet.JBossRenderResponse; = -import javax.portlet.PortletException; -import javax.portlet.PortletRequestDispatcher; -import javax.portlet.UnavailableException; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Set; - /** * Read the current users online and write them in output. - * + * = * @author Luca Stancapiano */ -public class CurrentUsersPortlet extends JBossPortlet -{ +public class CurrentUsersPortlet extends JBossPortlet { = - /** Logger */ - public static Logger log =3D Logger.getLogger(CurrentUsersPortlet.class= ); + /** Logger */ + public static Logger log =3D Logger.getLogger(CurrentUsersPortlet.class); = - protected void doView(JBossRenderRequest rRequest, JBossRenderResponse = rResponse) throws PortletException, - IOException, UnavailableException - { - UsersActivityStatsService uass =3D (UsersActivityStatsService) this.= getPortletContext().getAttribute( - "UsersActivityStats"); + /** Help page */ + private static final String JSP_HELP =3D "/WEB-INF/jsp/users/help.jsp"; = - rResponse.setContentType("text/html"); - PrintWriter writer =3D rResponse.getWriter(); + protected void doHelp(JBossRenderRequest request, + JBossRenderResponse response) throws PortletException, + PortletSecurityException, IOException { + response.setContentType("text/html"); + PortletRequestDispatcher dispatcher =3D getPortletContext() + .getRequestDispatcher(JSP_HELP); + dispatcher.include(request, response); + } = - long currentTime =3D System.currentTimeMillis(); + protected void doView(JBossRenderRequest rRequest, + JBossRenderResponse rResponse) throws PortletException, + IOException, UnavailableException { + = + String guestNumber =3D rRequest.getPreferences().getValue("guestNumbe= r",""); + = + UsersActivityStatsService uass =3D (UsersActivityStatsService) this + .getPortletContext().getAttribute("UsersActivityStats"); = - //TODO: this is wrong - should pass period instead of current time -= actually it works by a coincedence... - Set users =3D uass.getActiveUsersNames(currentTime); + rResponse.setContentType("text/html"); + PrintWriter writer =3D rResponse.getWriter(); = - int sessionCount =3D uass.getActiveSessionCount(currentTime); + long currentTime =3D System.currentTimeMillis(); = - int allLoggedSessions =3D uass.getUsersActivities(currentTime).size(= ); + // TODO: this is wrong - should pass period instead of current time - + // actually it works by a coincedence... + Set users =3D uass.getActiveUsersNames(currentTime); = - if (sessionCount =3D=3D 1) - { - DelegateContext ctx =3D new DelegateContext(); - ctx.put("USERS", users.toString()); - ctx.put("USERS_COUNT", Integer.toString(sessionCount)); - rRequest.setAttribute(PortalJsp.CTX_REQUEST, ctx); - PortletRequestDispatcher rd =3D getPortletContext().getRequestDis= patcher("/WEB-INF/jsp/users/oneUser.jsp"); - rd.include(rRequest, rResponse); - } - else if (sessionCount > 1) - { - DelegateContext ctx =3D new DelegateContext(); - ctx.put("USERS", users.toString()); - ctx.put("USERS_COUNT", Integer.toString(sessionCount)); - ctx.put("USERS_LOGGED_COUNT", Integer.toString(users.size())); - rRequest.setAttribute(PortalJsp.CTX_REQUEST, ctx); - PortletRequestDispatcher rd =3D getPortletContext().getRequestDis= patcher("/WEB-INF/jsp/users/users.jsp"); - rd.include(rRequest, rResponse); - } - else - { - PortletRequestDispatcher rd =3D getPortletContext().getRequestDis= patcher("/WEB-INF/jsp/users/noUser.jsp"); - rd.include(rRequest, rResponse); - } + int sessionCount =3D uass.getActiveSessionCount(currentTime); = - writer.close(); - } + int allLoggedSessions =3D uass.getUsersActivities(currentTime).size(); + + if (sessionCount =3D=3D 1 || (guestNumber.equals("false") && users.size(= ) =3D=3D 1)) { + DelegateContext ctx =3D new DelegateContext(); + ctx.put("USERS", users.toString()); + ctx.put("USERS_COUNT", Integer.toString(sessionCount)); + ctx.put("USERS_LOGGED_COUNT", Integer.toString(users.size())); + rRequest.setAttribute(PortalJsp.CTX_REQUEST, ctx); + PortletRequestDispatcher rd =3D getPortletContext() + .getRequestDispatcher("/WEB-INF/jsp/users/oneUser.jsp"); + rd.include(rRequest, rResponse); + } else if (sessionCount > 1) { + DelegateContext ctx =3D new DelegateContext(); + ctx.put("USERS", users.toString()); + ctx.put("USERS_COUNT", Integer.toString(sessionCount)); + ctx.put("USERS_LOGGED_COUNT", Integer.toString(users.size())); + rRequest.setAttribute(PortalJsp.CTX_REQUEST, ctx); + PortletRequestDispatcher rd =3D getPortletContext() + .getRequestDispatcher("/WEB-INF/jsp/users/users.jsp"); + rd.include(rRequest, rResponse); + } else { + PortletRequestDispatcher rd =3D getPortletContext() + .getRequestDispatcher("/WEB-INF/jsp/users/noUser.jsp"); + rd.include(rRequest, rResponse); + } + + writer.close(); + } } Modified: branches/JBoss_Portal_Branch_2_6/core-samples/src/resources/porta= l-users-samples-war/WEB-INF/classes/Resource.properties =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/JBoss_Portal_Branch_2_6/core-samples/src/resources/portal-user= s-samples-war/WEB-INF/classes/Resource.properties 2008-05-24 01:39:58 UTC (= rev 10809) +++ branches/JBoss_Portal_Branch_2_6/core-samples/src/resources/portal-user= s-samples-war/WEB-INF/classes/Resource.properties 2008-05-24 17:23:43 UTC (= rev 10810) @@ -21,13 +21,15 @@ # 02110-1301 USA, or see the FSF site: http://www.fsf.org. = # ##########################################################################= ###### = -NO_USERS_ONLINE=3DNo logged-in user +NO_USERS_ONLINE=3DNo online user ONE_USER_ONLINE_0=3DThere is ONE_USER_ONLINE_1=3D online user +ONE_USER_LOGGED_1=3D logged user ONE_USER_IS_0=3D ONE_USER_IS_1=3D USERS_ONLINE_0=3DThere are USERS_ONLINE_1=3D online users +USERS_LOGGED_1=3D logged users USERS_ARE_0=3D USERS_ARE_1=3D USERS_WHICH_0=3DWhose Modified: branches/JBoss_Portal_Branch_2_6/core-samples/src/resources/porta= l-users-samples-war/WEB-INF/classes/Resource_it.properties =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/JBoss_Portal_Branch_2_6/core-samples/src/resources/portal-user= s-samples-war/WEB-INF/classes/Resource_it.properties 2008-05-24 01:39:58 UT= C (rev 10809) +++ branches/JBoss_Portal_Branch_2_6/core-samples/src/resources/portal-user= s-samples-war/WEB-INF/classes/Resource_it.properties 2008-05-24 17:23:43 UT= C (rev 10810) @@ -24,10 +24,12 @@ NO_USERS_ONLINE=3DNessun utente \u00e8 online ONE_USER_ONLINE_0=3DAl momento c'\u00e8 ONE_USER_ONLINE_1=3D utente online +ONE_USER_LOGGED_1=3D utente loggato ONE_USER_IS_0=3D ONE_USER_IS_1=3D USERS_ONLINE_0=3DAl momento ci sono USERS_ONLINE_1=3D utenti online +USERS_LOGGED_1=3D utenti loggati USERS_ARE_0=3D USERS_ARE_1=3D USERS_WHICH_0=3DDi cui Added: branches/JBoss_Portal_Branch_2_6/core-samples/src/resources/portal-u= sers-samples-war/WEB-INF/jsp/users/help.jsp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/JBoss_Portal_Branch_2_6/core-samples/src/resources/portal-user= s-samples-war/WEB-INF/jsp/users/help.jsp (rev 0) +++ branches/JBoss_Portal_Branch_2_6/core-samples/src/resources/portal-user= s-samples-war/WEB-INF/jsp/users/help.jsp 2008-05-24 17:23:43 UTC (rev 10810) @@ -0,0 +1,41 @@ +<%--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~~ + ~ JBoss, a division of Red Hat = ~ + ~ Copyright 2006, Red Hat Middleware, LLC, and individual = ~ + ~ contributors as indicated by the @authors tag. See the = ~ + ~ copyright.txt in the distribution for a full listing of = ~ + ~ individual contributors. = ~ + ~ = ~ + ~ This is free software; you can redistribute it and/or modify it = ~ + ~ under the terms of the GNU Lesser General Public License as = ~ + ~ published by the Free Software Foundation; either version 2.1 of = ~ + ~ the License, or (at your option) any later version. = ~ + ~ = ~ + ~ This software is distributed in the hope that it will be useful, = ~ + ~ but WITHOUT ANY WARRANTY; without even the implied warranty of = ~ + ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU = ~ + ~ Lesser General Public License for more details. = ~ + ~ = ~ + ~ You should have received a copy of the GNU Lesser General Public = ~ + ~ License along with this software; if not, write to the Free = ~ + ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA = ~ + ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. = ~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~--%> + +<%@ taglib uri=3D"http://java.sun.com/portlet" prefix=3D"portlet"%> + + + +
Current +Users Portlet Help:
+ +
+
Description: The Current users Portlet +shows current users actually connected. You can to see both guest and +logged users number and to see which users are logged.
+
+
You can to manage what to show to users. +You can to choose paragraphes to show, clicking the checkboxes
+
+
+ \ No newline at end of file Property changes on: branches/JBoss_Portal_Branch_2_6/core-samples/src/reso= urces/portal-users-samples-war/WEB-INF/jsp/users/help.jsp ___________________________________________________________________ Name: svn:executable + * Modified: branches/JBoss_Portal_Branch_2_6/core-samples/src/resources/porta= l-users-samples-war/WEB-INF/jsp/users/oneUser.jsp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/JBoss_Portal_Branch_2_6/core-samples/src/resources/portal-user= s-samples-war/WEB-INF/jsp/users/oneUser.jsp 2008-05-24 01:39:58 UTC (rev 10= 809) +++ branches/JBoss_Portal_Branch_2_6/core-samples/src/resources/portal-user= s-samples-war/WEB-INF/jsp/users/oneUser.jsp 2008-05-24 17:23:43 UTC (rev 10= 810) @@ -32,14 +32,30 @@ + <% if (renderRequest.getPreferences().getValue("guestNumber",= "").equals("true")) { %> ${n:i18n("ONE_USER_ONLINE_0")} ${n:out("USERS_COUNT")} - ${n:i18n("ONE_USER_ONLINE_1")} = - <% java.util.LinkedList linkedStack =3D (java.util.LinkedList= )contextStack.get(); + ${n:i18n("ONE_USER_ONLINE_1")} = +

+ <% } + java.util.LinkedList linkedStack =3D (java.util.LinkedList= )contextStack.get(); org.jboss.portal.core.servlet.jsp.taglib.context.Context c= urrentContext =3D = - ((org.jboss.portal.core.servlet.jsp.taglib.context.NamedCo= ntext)linkedStack.getLast()).getContext(); - if (!currentContext.get("USERS").equals("[]")) { %> = = + ((org.jboss.portal.core.servlet.jsp.taglib.context.NamedCont= ext)linkedStack.getLast()).getContext(); + if (!currentContext.get("USERS_LOGGED_COUNT").equals("0") = && renderRequest.getPreferences().getValue("loggedNumber", "").equals("true= ")) { %> = + + <% if (renderRequest.getPreferences().getValue("guestNumbe= r", "").equals("true")) { %> + ${n:i18n("USERS_WHICH_0")} + ${n:out("USERS_LOGGED_COUNT")} + ${n:i18n("USERS_WHICH_2")} = + <% } else { %> + ${n:i18n("ONE_USER_ONLINE_0")} + ${n:out("USERS_LOGGED_COUNT")} + ${n:i18n("ONE_USER_LOGGED_1")} = + <% } %>

+ <% } + if (!currentContext.get("USERS").equals("[]") && renderReq= uest.getPreferences().getValue("loggedUsers", "").equals("true")) { %> = = + ${n:i18n("ONE_USER_IS_0")} ${n:out("USERS")} ${n:i18n("ONE_USER_IS_1")} = Modified: branches/JBoss_Portal_Branch_2_6/core-samples/src/resources/porta= l-users-samples-war/WEB-INF/jsp/users/users.jsp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/JBoss_Portal_Branch_2_6/core-samples/src/resources/portal-user= s-samples-war/WEB-INF/jsp/users/users.jsp 2008-05-24 01:39:58 UTC (rev 1080= 9) +++ branches/JBoss_Portal_Branch_2_6/core-samples/src/resources/portal-user= s-samples-war/WEB-INF/jsp/users/users.jsp 2008-05-24 17:23:43 UTC (rev 1081= 0) @@ -32,24 +32,34 @@ + <% if (renderRequest.getPreferences().getValue("guestNumber",= "").equals("true")) { %> ${n:i18n("USERS_ONLINE_0")} ${n:out("USERS_COUNT")} - ${n:i18n("USERS_ONLINE_1")} = - <% java.util.LinkedList linkedStack =3D (java.util.LinkedList= )contextStack.get(); + ${n:i18n("USERS_ONLINE_1")} = +

= + <% } + java.util.LinkedList linkedStack =3D (java.util.LinkedList= )contextStack.get(); org.jboss.portal.core.servlet.jsp.taglib.context.Context c= urrentContext =3D = ((org.jboss.portal.core.servlet.jsp.taglib.context.NamedCont= ext)linkedStack.getLast()).getContext(); - if (!currentContext.get("USERS_LOGGED_COUNT").equals("0"))= { %> = + if (!currentContext.get("USERS_LOGGED_COUNT").equals("0") = && renderRequest.getPreferences().getValue("loggedNumber", "").equals("true= ")) { %> = + + <% if (renderRequest.getPreferences().getValue("guestNumbe= r", "").equals("true")) { %> + ${n:i18n("USERS_WHICH_0")} + ${n:out("USERS_LOGGED_COUNT")} + <% if (!currentContext.get("USERS_LOGGED_COUNT").equals= ("1")) { %> = + ${n:i18n("USERS_WHICH_1")} + <% } else { %> = + ${n:i18n("USERS_WHICH_2")} = + <% } %> + <% } else { %> + ${n:i18n("USERS_ONLINE_0")} + ${n:out("USERS_LOGGED_COUNT")} + ${n:i18n("USERS_LOGGED_1")} = + <% } %>

- ${n:i18n("USERS_WHICH_0")} - ${n:out("USERS_LOGGED_COUNT")} - <% if (!currentContext.get("USERS_LOGGED_COUNT").equals("1= ")) { %> = - ${n:i18n("USERS_WHICH_1")} - <% } else { %> = - ${n:i18n("USERS_WHICH_2")} = - <% } %> <% } - if (!currentContext.get("USERS").equals("[]")) { %> = = -

+ if (!currentContext.get("USERS").equals("[]") && renderReq= uest.getPreferences().getValue("loggedUsers", "").equals("true")) { %> = = + ${n:i18n("USERS_ARE_0")} ${n:out("USERS")} ${n:i18n("USERS_ARE_1")} = Modified: branches/JBoss_Portal_Branch_2_6/core-samples/src/resources/porta= l-users-samples-war/WEB-INF/portlet.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/JBoss_Portal_Branch_2_6/core-samples/src/resources/portal-user= s-samples-war/WEB-INF/portlet.xml 2008-05-24 01:39:58 UTC (rev 10809) +++ branches/JBoss_Portal_Branch_2_6/core-samples/src/resources/portal-user= s-samples-war/WEB-INF/portlet.xml 2008-05-24 17:23:43 UTC (rev 10810) @@ -35,6 +35,7 @@ text/html VIEW + HELP en it @@ -44,5 +45,19 @@ Current users sample,test + + + guestNumber + true + + + loggedNumber + true + + + loggedUsers + true + + --===============1206304749977137041==--