[Commits] (bcm) add isUserInRole jsp tag that does exactly what you'd think it does. use this

commits at osafoundation.org commits at osafoundation.org
Tue Mar 1 13:36:59 PST 2005


Commit by: bcm
Modified files:
server/core/src/chsrv-core.tld 1.1 1.2
server/core/src/org/osaf/chandler/server/jsp/tag/IsUserInRoleTag.java None 1.1
server/core/src/org/osaf/chandler/server/jsp/tag/HomedirTag.java 1.1 1.2
server/docs/TODO.txt 1.13 1.14
server/webapps/ROOT/web/index.jsp 1.4 1.5

Log message:
add isUserInRole jsp tag that does exactly what you'd think it does. use this
tag in the welcome page to determine whether to show the console link or the
homedir link.


ViewCVS links:
http://cvs.osafoundation.org/index.cgi/server/core/src/chsrv-core.tld.diff?r1=text&tr1=1.1&r2=text&tr2=1.2
http://cvs.osafoundation.org/index.cgi/server/core/src/org/osaf/chandler/server/jsp/tag/IsUserInRoleTag.java?rev=1.1&content-type=text/vnd.viewcvs-markup
http://cvs.osafoundation.org/index.cgi/server/core/src/org/osaf/chandler/server/jsp/tag/HomedirTag.java.diff?r1=text&tr1=1.1&r2=text&tr2=1.2
http://cvs.osafoundation.org/index.cgi/server/docs/TODO.txt.diff?r1=text&tr1=1.13&r2=text&tr2=1.14
http://cvs.osafoundation.org/index.cgi/server/webapps/ROOT/web/index.jsp.diff?r1=text&tr1=1.4&r2=text&tr2=1.5

Index: server/docs/TODO.txt
diff -u server/docs/TODO.txt:1.13 server/docs/TODO.txt:1.14
--- server/docs/TODO.txt:1.13	Tue Mar  1 12:42:57 2005
+++ server/docs/TODO.txt	Tue Mar  1 13:36:58 2005
@@ -9,7 +9,6 @@
 
 ROOT webapp:
 
- * change test in welcome page to check for users in root role
  * final look and feel
  * figure out why `cadaver http://localhost:8080/~user/ does not work
    ... is Slide generating a directory index even when accessed with

Index: server/core/src/chsrv-core.tld
diff -u server/core/src/chsrv-core.tld:1.1 server/core/src/chsrv-core.tld:1.2
--- server/core/src/chsrv-core.tld:1.1	Tue Mar  1 12:42:56 2005
+++ server/core/src/chsrv-core.tld	Tue Mar  1 13:36:57 2005
@@ -7,6 +7,7 @@
   <description>Chandler Server core tag library</description>
   <display-name>Chandler Server core</display-name>
   <tlib-version>0.1</tlib-version>
+  <jspversion>2.0</jspversion>
   <short-name>chc</short-name>
   <uri>http://osafoundation.org/server/jsp/core</uri>
   <tag>
@@ -55,4 +56,39 @@
       <rtexprvalue>false</rtexprvalue>
     </attribute>
   </tag>
+  <tag>
+    <description>
+      Determines whether or not the currently logged in user is in
+      the named role.
+    </description>
+    <name>isUserInRole</name>
+    <tag-class>org.osaf.chandler.server.jsp.tag.IsUserInRoleTag</tag-class>
+    <body-content>empty</body-content>
+    <attribute>
+      <description>
+        The name of the role to check.
+      </description>
+      <name>role</name>
+      <required>true</required>
+      <rtexprvalue>true</rtexprvalue>
+    </attribute>
+    <attribute>
+      <description>
+        Scope in which the scripting variable holding the result of
+        this tag is placed (defaults to page).
+      </description>
+      <name>scope</name>
+      <required>false</required>
+      <rtexprvalue>false</rtexprvalue>
+    </attribute>
+    <attribute>
+      <description>
+        Name of the exported scoped variable which holds the result
+        of this tag.
+      </description>
+      <name>var</name>
+      <required>true</required>
+      <rtexprvalue>false</rtexprvalue>
+    </attribute>
+  </tag>
 </taglib>

Index: server/core/src/org/osaf/chandler/server/jsp/tag/HomedirTag.java
diff -u server/core/src/org/osaf/chandler/server/jsp/tag/HomedirTag.java:1.1 server/core/src/org/osaf/chandler/server/jsp/tag/HomedirTag.java:1.2
--- server/core/src/org/osaf/chandler/server/jsp/tag/HomedirTag.java:1.1	Tue Mar  1 12:42:56 2005
+++ server/core/src/org/osaf/chandler/server/jsp/tag/HomedirTag.java	Tue Mar  1 13:36:57 2005
@@ -22,9 +22,6 @@
      */
     public void doTag()
         throws JspException, IOException {
-        if (username == null) {
-            throw new JspException("username is null");
-        }
 
         StringBuffer homedirPath = new StringBuffer();
         homedirPath.append(basepath);
@@ -32,8 +29,6 @@
         homedirPath.append(username);
         homedirPath.append("/");
 
-        log.debug("homedir for " + username + ": " + homedirPath);
-
         if (var != null) {
             getJspContext().setAttribute(var, homedirPath.toString(), scope);
         }

Index: server/webapps/ROOT/web/index.jsp
diff -u server/webapps/ROOT/web/index.jsp:1.4 server/webapps/ROOT/web/index.jsp:1.5
--- server/webapps/ROOT/web/index.jsp:1.4	Tue Mar  1 12:42:57 2005
+++ server/webapps/ROOT/web/index.jsp	Tue Mar  1 13:36:58 2005
@@ -3,7 +3,10 @@
 <%@ taglib uri="http://java.sun.com/jsp/jstl/functions"   prefix="fn"  %>
 <%@ taglib uri="http://osafoundation.org/server/jsp/core" prefix="chc" %>
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<chc:isUserInRole var="isRoot" role="root"/>
 
 <html>
   <head>
@@ -17,7 +20,7 @@
       as <strong>${pageContext.request.remoteUser}</strong>.
     </p>
     <c:choose>
-      <c:when test="${pageContext.request.remoteUser ne 'root'}">
+      <c:when test="${not isRoot}">
         <chc:homedir username="${pageContext.request.remoteUser}"
                      var="homedir"/>
         <p>



More information about the Commits mailing list