Author: channa
Date: Thu Dec  6 03:24:24 2007
New Revision: 10632

Log:

Changed infocard registration process to not display intermediate pages and to 
display registered cards; added multiple card handling ability.

Modified:
   trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
   
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/identity/InfoCardHandler.java
   trunk/mashup/java/modules/www/org/infocardaccept.jsp
   trunk/mashup/java/modules/www/org/signin.jsp
   trunk/mashup/java/modules/www/org/user.jsp

Modified: 
trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
==============================================================================
--- trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java     
(original)
+++ trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java     
Thu Dec  6 03:24:24 2007
@@ -63,6 +63,9 @@
     public static final String FIRST_NAME = "firstname";
     public static final String LAST_NAME = "lastname";
 
+    public static final String INFOCARD_PPID = "ppid";
+    public static final String INFOCARD_COUNT = "cardcount";
+
     public static final int SHOW_RESULTS_COUNT = 5;    // How many results to 
show before showing "more".
     public static final int MAX_RESULTS_COUNT = 1000;  // Maximum results to 
return.
 

Modified: 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/identity/InfoCardHandler.java
==============================================================================
--- 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/identity/InfoCardHandler.java
     (original)
+++ 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/identity/InfoCardHandler.java
     Thu Dec  6 03:24:24 2007
@@ -40,7 +40,6 @@
  */
 public class InfoCardHandler {
     private static final Log log = LogFactory.getLog(InfoCardHandler.class);
-    private static final String PPID_PROPERTY_KEY = "ppid";
 
     /**
      * Retrieves the infocard parameters and uses the ppid to validate the 
user.
@@ -73,10 +72,10 @@
                 Realm realm = (Realm) 
context.getAttribute(RegistryConstants.REGISTRY_REALM);
                 try {
                     UserStoreReader storeReader = realm.getUserStoreReader();
-                    String[] userNames = 
storeReader.getUserNamesWithPropertyValue(
-                            PPID_PROPERTY_KEY, ppid);
+                    // Null for key gets all users with the PPID - there can 
be only one.
+                    String[] userNames = 
storeReader.getUserNamesWithPropertyValue(null, ppid);
 
-                    // Only one person with PPID in the infocard, so get 
secure registry for user.
+                    // If a name is returned, instantiate a secure registry 
for user.
                     if (userNames.length == 1) {
                         SecureRegistry secureRegistry = new 
SecureRegistry(userNames[0],
                                                                            
jdbcRegistry, realm);
@@ -121,10 +120,18 @@
             if (TokenVerifierConstants.STATE_SUCCESS.equals(auth)) {
                 String ppid = (String) 
request.getAttribute(IdentityConstants.CLAIM_PPID);
 
-                // todo: Figure out how best to handle a user with multiple 
ppid's.
-                // Add if ppid has not been associated with a user and user 
has no associaed ppid.
-                if (!userProps.containsValue(ppid) && 
!userProps.containsKey(PPID_PROPERTY_KEY)) {
-                    userProps.put(PPID_PROPERTY_KEY, ppid);
+                // Add only if this ppid has not been associated with a user.
+                if (!userProps.containsValue(ppid)) {
+                    int regCardCount = 0;
+
+                    // There will be a count if keys have been registered, so 
append.
+                    if (userProps.containsKey(MashupConstants.INFOCARD_COUNT)) 
{
+                        regCardCount = Integer.parseInt((String) userProps.get(
+                                MashupConstants.INFOCARD_COUNT));
+                    }
+                    userProps.put(MashupConstants.INFOCARD_PPID + 
regCardCount, ppid);
+                    userProps.put(MashupConstants.INFOCARD_COUNT, 
Integer.toString(regCardCount
+                            + 1));
                     userStoreAdmin.setUserProperties(currentUser, userProps);
                     cardAdded = true;
                 }
@@ -136,4 +143,27 @@
         }
         return cardAdded;
     }
+
+    /**
+     * Get the list of infocards associated with this user.
+     *
+     * @param userProperties User property map containing card PPID's
+     * @return String array with list of card ID's.
+     */
+    public static String[] getUsersCards(Map userProperties) {
+        String[] cardIds = null;
+        // Make sure there are associated cards.
+        if (userProperties.containsKey(MashupConstants.INFOCARD_COUNT)) {
+            int cardCount = Integer.parseInt((String) 
userProperties.get(MashupConstants.
+                    INFOCARD_COUNT));
+            cardIds = new String[cardCount];
+            for (int cards = 0; cards < cardCount; cards++) {
+                String ppid = userProperties.get(MashupConstants.INFOCARD_PPID 
+ cards).toString();
+
+                // todo - get the freindly identifier here using 
IdentityproviderUtil
+                cardIds[cards] = ppid;
+            }
+        }
+        return cardIds;
+    }
 }

Modified: trunk/mashup/java/modules/www/org/infocardaccept.jsp
==============================================================================
--- trunk/mashup/java/modules/www/org/infocardaccept.jsp        (original)
+++ trunk/mashup/java/modules/www/org/infocardaccept.jsp        Thu Dec  6 
03:24:24 2007
@@ -36,7 +36,7 @@
     String thisPage = "infocardaccept.jsp";
     String bounceback = request.getParameter("bounceback");
     String title;
-    String message;
+    String message = null;
     if (bounceback == null) {
         bounceback = "index.jsp";
     } else {
@@ -47,7 +47,8 @@
     if (isLoggedIn) {
         title = "Associate InfoCard with user profile";
        if (InfoCardHandler.associateCardWithUser(registry, request)) {
-           message = "InfoCard successfully added to user profile.";
+           // Send the user back to the caling page on success - it'll show 
the added card ppid.
+            response.sendRedirect(bounceback);
        } else {
             message = "Could not add InfoCard to user profile.";
        }
@@ -73,9 +74,11 @@
             <tr>
                 <td align="center" height="175">
                     <div class="login-error"><%= message %></div>
+                    Return to <a href="<%= bounceback %>">calling page</a> to 
try again. 
                 </td>
             </tr>
         </table>
+
     </div>
     <%@ include file="footer.jsp" %>
 </div>

Modified: trunk/mashup/java/modules/www/org/signin.jsp
==============================================================================
--- trunk/mashup/java/modules/www/org/signin.jsp        (original)
+++ trunk/mashup/java/modules/www/org/signin.jsp        Thu Dec  6 03:24:24 2007
@@ -133,7 +133,7 @@
                                                                                
        value="Sign In"/></div>
                                 </td>
                                 <td align="center" height="175">
-                                    <a href="infocard.jsp"><img 
src="images/infocard_92x64.png" border="0"></a>
+                                    <a href="infocard.jsp?bounceback=<%= 
bounceback %>"><img src="images/infocard_92x64.png" border="0"></a>
                                     <br/>
                                     Signup using your personal or managed 
infocard.
                                 </td>

Modified: trunk/mashup/java/modules/www/org/user.jsp
==============================================================================
--- trunk/mashup/java/modules/www/org/user.jsp  (original)
+++ trunk/mashup/java/modules/www/org/user.jsp  Thu Dec  6 03:24:24 2007
@@ -14,9 +14,11 @@
  * limitations under the License.
 --%>
 <%@ page import="com.sun.syndication.feed.synd.SyndContent"
-%><%@ page import="com.sun.syndication.feed.synd.SyndContentImpl"
-%><%@ page import="com.sun.syndication.feed.synd.SyndEntry"
-%>
+        %>
+<%@ page import="com.sun.syndication.feed.synd.SyndContentImpl"
+        %>
+<%@ page import="com.sun.syndication.feed.synd.SyndEntry"
+        %>
 <%@ page import="com.sun.syndication.feed.synd.SyndEntryImpl" %>
 <%@ page import="com.sun.syndication.feed.synd.SyndFeed" %>
 <%@ page import="com.sun.syndication.feed.synd.SyndFeedImpl" %>
@@ -71,12 +73,17 @@
     String email = userProfile.getEmailAddress();
     String memberBio = userProfile.getBio();
     String memberFriendlyName = memberName;
+    String[] userCards = null;
 
     // If user properties are available, get the names.
-    if (userProperties != null && 
userProperties.containsKey(MashupConstants.FORMAL_NAME)) {
-        memberFriendlyName = 
userProperties.get(MashupConstants.FORMAL_NAME).toString();
+    if (userProperties != null) {
+        if (userProperties.containsKey(MashupConstants.FORMAL_NAME)) {
+            memberFriendlyName = 
userProperties.get(MashupConstants.FORMAL_NAME).toString();
+        }
+        userCards = InfoCardHandler.getUsersCards(userProperties);
     }
-    String customizedAuthor = 
(memberName.equals(RegistryUtils.getCurrentUser(registry)) ? "My" : 
memberFriendlyName + "'s");
+    String customizedAuthor = 
(memberName.equals(RegistryUtils.getCurrentUser(registry)) ? "My" :
+            memberFriendlyName + "'s");
 
 %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
@@ -140,10 +147,10 @@
 
 <table width="100%" height="400" border="0" cellspacing="0" cellpadding="5">
 <tr>
-    <td valign="top">
+<td valign="top">
 
-        <div class="profile">
-            <div class="profile_title">
+<div class="profile">
+    <div class="profile_title">
                 <span id="editFormalName">
                     <span 
id="editFormalName_value"><%=memberFriendlyName%></span>
 <% if (RegistryUtils.getCurrentUser(registry).equals(memberName)) { %>
@@ -151,59 +158,63 @@
 <% } %>
                 </span>
                 <span id="editFormalName_input" style="display:none">
-                    <textarea 
id="editFormalName_input_text"><%=memberFriendlyName%></textarea>
+                    <textarea 
id="editFormalName_input_text"><%=memberFriendlyName%>
+                    </textarea>
                     <span class="edit-link">[<a href="#" 
onclick="cancelEditable('editFormalName')">cancel</a>]</span>
                     <span class="edit-link">[<a href="#"
                                                 
onclick="saveEditable('editFormalName', 'formalName', 
'<%=RegistryUtils.getCurrentUser(registry)%>')">save</a>]</span>
                 </span>
-            </div>
-            <table>
-                <tr>
-                    <td class="profile_label">
-                        <nobr>user name:</nobr>
-                    </td>
-                    <td>
-                        <div class="profile_username"><%=memberName%>
-                        </div>
-                    </td>
-                </tr>
-                <% if 
(RegistryUtils.getCurrentUser(registry).equals(memberName)) { %>
-                <tr>
-                    <td class="profile_label">
-                        <nobr>email:</nobr>
-                    </td>
-                    <td>
-                        <div class="profile_email">
+    </div>
+    <table>
+        <tr>
+            <td class="profile_label">
+                <nobr>user name:</nobr>
+            </td>
+            <td>
+                <div class="profile_username"><%=memberName%>
+                </div>
+            </td>
+        </tr>
+        <% if (RegistryUtils.getCurrentUser(registry).equals(memberName)) { %>
+        <tr>
+            <td class="profile_label">
+                <nobr>email:</nobr>
+            </td>
+            <td>
+                <div class="profile_email">
                             <span id="editEmail">
                                 <span id="editEmail_value"><%=email%></span>
                                 <span class="edit-link">[<a href="#"
                                                             
onclick="makeEditable('editEmail')">edit</a>]</span>
                             </span>
                             <span id="editEmail_input" style="display:none">
-                                <textarea 
id="editEmail_input_text"><%=email%></textarea>
+                                <textarea id="editEmail_input_text"><%=email%>
+                                </textarea>
                                 <span class="edit-link">[<a href="#"
                                                             
onclick="cancelEditable('editEmail')">cancel</a>]</span>
                                 <span class="edit-link">[<a href="#"
                                                             
onclick="saveEditable('editEmail', 'email', 
'<%=RegistryUtils.getCurrentUser(registry)%>')">save</a>]</span>
                             </span>
-                        </div>
-                    </td>
-                </tr>
-                <% } %>
-                <tr>
-                    <td class="profile_label">
-                        <nobr>bio:</nobr>
-                    </td>
-                    <td>
-                        <div class="profile_bio">
+                </div>
+            </td>
+        </tr>
+        <% } %>
+        <tr>
+            <td class="profile_label">
+                <nobr>bio:</nobr>
+            </td>
+            <td>
+                <div class="profile_bio">
                             <span id="editBio">
                                 <span id="editBio_value"><%=memberBio%></span>
 <% if (RegistryUtils.getCurrentUser(registry).equals(memberName)) { %>
-                                <span class="edit-link">[<a href="#" 
onclick="makeEditable('editBio')">edit</a>]</span>
+                                <span class="edit-link">[<a href="#"
+                                                            
onclick="makeEditable('editBio')">edit</a>]</span>
 <% } %>
                             </span>
                             <span id="editBio_input" style="display:none">
-                                <textarea 
id="editBio_input_text"><%=memberBio%></textarea>
+                                <textarea 
id="editBio_input_text"><%=memberBio%>
+                                </textarea>
                                 <span class="edit-link">[<a href="#"
                                                             
onclick="cancelEditable('editBio')">cancel</a>]</span>
                                 <span class="edit-link">[<a href="#"
@@ -211,126 +222,154 @@
                                 <br/>
                                 <span class="profile_label">(accepts some html 
markup)</span>
                             </span>
+                </div>
+            </td>
+        </tr>
+        <% if (userCards != null) { %>
+        <tr>
+            <td class="profile_label">
+                <nobr>Registered Cards:</nobr>
+            </td>
+            <td>
+                <div class="profile_username">
+                    <span id="listInfocards">
+                        <div class="profile_username">
+                            <% for (String cardId : userCards) { %>
+                                <%=cardId%><br>                                
+                            <% } %>
                         </div>
-                    </td>
-                </tr>
-             </table>
-        </div>
-    </td>
-    <td width="250" valign="top" rowspan="2">
-        <table width="100%" border="0" class="box" cellspacing="0" 
cellpadding="3">
-            <tr>
-                <th>Tasks</th>
-            </tr>
-            <tr>
-                <td>
-                    <ul>
-                        <li>
-                             <a href="infocard.jsp">Register your 
infocard***</a>
-                        </li>
-                        <li>
-                            <a href="#">Add virtual directory**</a>
-                        </li>
-                        <li>
-                            <a href="#">Add user**</a>
-                        </li>
-                        <li>
-                            <a href="#">Allow internet guests**</a>
-                        </li>
-                        <li>
-                            <a href="#">Delete user** ***</a>
-                        </li>
-                        <li>
-                            <a href="#">Create a new service*</a>
-                        </li>
-                     </ul>
-                    <div>* only when logged in.</div>
-                    <div>** only when logged in as an admin.</div>
-                    <div>*** only viewing your own page.</div>
-                </td>
-            </tr>
-        </table>
-        <%@ include file="taskbar.jsp" %>
-    </td>
+                    </span>
+                </div>
+            </td>
+        </tr>
+        <% } %>
+    </table>
+</div>
+</td>
+<td width="250" valign="top" rowspan="2">
+    <table width="100%" border="0" class="box" cellspacing="0" cellpadding="3">
+        <tr>
+            <th>Tasks</th>
+        </tr>
+        <tr>
+            <td>
+                <ul>
+                    <% if 
(RegistryUtils.getCurrentUser(registry).equals(memberName)) { %>
+                    <li>
+                        Register your <a href="infocard.jsp">infocard</a>
+                    </li>
+                    <% } %>
+                    <li>
+                        <a href="#">Add virtual directory**</a>
+                    </li>
+                    <li>
+                        <a href="#">Add user**</a>
+                    </li>
+                    <li>
+                        <a href="#">Allow internet guests**</a>
+                    </li>
+                    <li>
+                        <a href="#">Delete user** ***</a>
+                    </li>
+                    <li>
+                        <a href="#">Create a new service*</a>
+                    </li>
+                </ul>
+                <div>* only when logged in.</div>
+                <div>** only when logged in as an admin.</div>
+                <div>*** only viewing your own page.</div>
+            </td>
+        </tr>
+    </table>
+    <%@ include file="taskbar.jsp" %>
+</td>
 </tr>
 <tr>
     <td>
-<%
+        <%
+
+
+
+            String queryTitle = customizedAuthor + " Mashups";
+            String queryPath = MashupConstants.MY_MASHUPS_QUERY_PATH;
+            String [] queryParams = new String[] {memberName};
+            QueryResults results = RegistryUtils.doQuery(registry, queryTitle, 
queryPath, queryParams, MashupConstants.SHOW_RESULTS_COUNT);
 
-    String queryTitle = customizedAuthor + " Mashups";
-    String queryPath = MashupConstants.MY_MASHUPS_QUERY_PATH;
-    String [] queryParams = new String[] {memberName};
-    QueryResults results = RegistryUtils.doQuery(registry, queryTitle, 
queryPath, queryParams, MashupConstants.SHOW_RESULTS_COUNT);
 
-%>
-    <div class="heading"><%= queryTitle%>
+
+        %>
+        <div class="heading"><%= queryTitle%>
         <span class="edit-link" title="RSS feed">[<a
-              href="search.jsp?<%=QueryParamUtils.paramsFromQuery(queryPath, 
queryParams)%>&format=rss" target="_blank">RSS</a>]</span>
+                href="search.jsp?<%=QueryParamUtils.paramsFromQuery(queryPath, 
queryParams)%>&format=rss"
+                target="_blank">RSS</a>]</span>
         <span class="edit-link" title="Atom feed">[<a
-              href="search.jsp?<%=QueryParamUtils.paramsFromQuery(queryPath, 
queryParams)%>&format=atom" target="_blank">Atom</a>]</span>
-    </div>
-    <table width="100%" border="0" cellpadding="3" cellspacing="0" 
class="data">
-        <tbody>
-            <tr>
-                <td width="12%" class="headers">Name</td>
-                <td width="12%" class="headers">Author</td>
-                <td class="headers">Description</td>
+                href="search.jsp?<%=QueryParamUtils.paramsFromQuery(queryPath, 
queryParams)%>&format=atom"
+                target="_blank">Atom</a>]</span>
+        </div>
+        <table width="100%" border="0" cellpadding="3" cellspacing="0" 
class="data">
+            <tbody>
+                <tr>
+                    <td width="12%" class="headers">Name</td>
+                    <td width="12%" class="headers">Author</td>
+                    <td class="headers">Description</td>
 
-                <td width="95" class="headers">Rating</td>
-            </tr>
-<%
-    Iterator iter = results.getResults().iterator();
-    int nextId = 0;
-    while (iter.hasNext()) {
-        QueryResult result = (QueryResult) iter.next();
-        String id = "id" + nextId;
-        String path = result.getPath();
-%>
-            <tr class="results">
-                <td width="1" nowrap>
-                    <a 
href="mashup.jsp?path=<%=result.getPath()%>"><%=result.getName()%>
-                    </a>
-                </td>
-                <td nowrap>
-                    <a class="updatableName" 
href="user.jsp?name=<%=result.getAuthor()%>"><%=RegistryUtils.getFullName(request,
 result.getAuthor())%>
-                    </a>
-                </td>
-                <td><%=result.getDescription() %>
-                </td>
-                <td nowrap>
-                    <div id="<%=id%>"
-                         class="rating_<%=path.replace('/', '_')%>"
-                         initialState="00 00 00 00 00"
-                         title="loading ratings...">
-                        <img src="images/r00.gif"
-                             onmouseover="previewRating('<%=id%>', 1)"
-                             onmouseout="clearPreview('<%=id%>')"
-                             onclick="setRating('<%=id%>', 
'<%=result.getPath()%>', 1)"
+                    <td width="95" class="headers">Rating</td>
+                </tr>
+                <%
+                    Iterator iter = results.getResults().iterator();
+                    int nextId = 0;
+                    while (iter.hasNext()) {
+                        QueryResult result = (QueryResult) iter.next();
+                        String id = "id" + nextId;
+                        String path = result.getPath();
+                %>
+                <tr class="results">
+                    <td width="1" nowrap>
+                        <a 
href="mashup.jsp?path=<%=result.getPath()%>"><%=result.getName()%>
+                        </a>
+                    </td>
+                    <td nowrap>
+                        <a class="updatableName"
+                           
href="user.jsp?name=<%=result.getAuthor()%>"><%=RegistryUtils
+                                .getFullName(request, result.getAuthor())%>
+                        </a>
+                    </td>
+                    <td><%=result.getDescription() %>
+                    </td>
+                    <td nowrap>
+                        <div id="<%=id%>"
+                             class="rating_<%=path.replace('/', '_')%>"
+                             initialState="00 00 00 00 00"
+                             title="loading ratings...">
+                            <img src="images/r00.gif"
+                                 onmouseover="previewRating('<%=id%>', 1)"
+                                 onmouseout="clearPreview('<%=id%>')"
+                                 onclick="setRating('<%=id%>', 
'<%=result.getPath()%>', 1)"
+                                    /><img src="images/r00.gif"
+                                           
onmouseover="previewRating('<%=id%>', 2)"
+                                           onmouseout="clearPreview('<%=id%>')"
+                                           onclick="setRating('<%=id%>', 
'<%=result.getPath()%>', 2)"
                                 /><img src="images/r00.gif"
-                                       onmouseover="previewRating('<%=id%>', 
2)"
+                                       onmouseover="previewRating('<%=id%>', 
3)"
                                        onmouseout="clearPreview('<%=id%>')"
-                                       onclick="setRating('<%=id%>', 
'<%=result.getPath()%>', 2)"
-                            /><img src="images/r00.gif"
-                                   onmouseover="previewRating('<%=id%>', 3)"
-                                   onmouseout="clearPreview('<%=id%>')"
-                                   onclick="setRating('<%=id%>', 
'<%=result.getPath()%>', 3)"
-                            /><img src="images/r00.gif"
-                                   onmouseover="previewRating('<%=id%>', 4)"
-                                   onmouseout="clearPreview('<%=id%>')"
-                                   onclick="setRating('<%=id%>', 
'<%=result.getPath()%>', 4)"
-                            /><img src="images/r00.gif"
-                                   onmouseover="previewRating('<%=id%>', 5)"
-                                   onmouseout="clearPreview('<%=id%>')"
-                                   onclick="setRating('<%=id%>', 
'<%=result.getPath()%>', 5)"/>
-                        <script type="text/javascript">
-                            getInitialRating('<%=id%>', 
'<%=result.getPath()%>');
-                        </script>
-                    </div>
-                </td>
-            </tr>
-<%      nextId++;
-    }
-    if (results.getResultCount() > MashupConstants.SHOW_RESULTS_COUNT) { %>
+                                       onclick="setRating('<%=id%>', 
'<%=result.getPath()%>', 3)"
+                                /><img src="images/r00.gif"
+                                       onmouseover="previewRating('<%=id%>', 
4)"
+                                       onmouseout="clearPreview('<%=id%>')"
+                                       onclick="setRating('<%=id%>', 
'<%=result.getPath()%>', 4)"
+                                /><img src="images/r00.gif"
+                                       onmouseover="previewRating('<%=id%>', 
5)"
+                                       onmouseout="clearPreview('<%=id%>')"
+                                       onclick="setRating('<%=id%>', 
'<%=result.getPath()%>', 5)"/>
+                            <script type="text/javascript">
+                                getInitialRating('<%=id%>', 
'<%=result.getPath()%>');
+                            </script>
+                        </div>
+                    </td>
+                </tr>
+                <% nextId++;
+                }
+                    if (results.getResultCount() > 
MashupConstants.SHOW_RESULTS_COUNT) { %>
                 <tr>
                     <td colspan="3"></td>
 
@@ -338,14 +377,14 @@
                         <div class="more"><a 
href="search.jsp">more...</a></div>
                     </td>
                 </tr>
-<%  } %>
-        </tbody>
-    </table>
-    </tr>
+                <% } %>
+            </tbody>
+        </table>
+</tr>
 </table>
 
 </div>
-    <%@ include file="footer.jsp" %>
+<%@ include file="footer.jsp" %>
 </div>
 
 </body>

_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to