Author: tyrell
Date: Wed Jun  4 08:44:35 2008
New Revision: 17932
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=17932

Log:
Initial code to browse mashups in the local server and add their gadgets to the 
dashboard.

Added:
   trunk/mashup/java/modules/dashboard/directory.jsp
   trunk/mashup/java/modules/dashboard/login_validator.jsp
Modified:
   trunk/mashup/java/modules/dashboard/css/gadgets.css
   trunk/mashup/java/modules/dashboard/index.jsp

Modified: trunk/mashup/java/modules/dashboard/css/gadgets.css
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/dashboard/css/gadgets.css?rev=17932&r1=17931&r2=17932&view=diff
==============================================================================
--- trunk/mashup/java/modules/dashboard/css/gadgets.css (original)
+++ trunk/mashup/java/modules/dashboard/css/gadgets.css Wed Jun  4 08:44:35 2008
@@ -1,3 +1,4 @@
+/*Gadget Styles*/
 .gadgets-gadget-chrome {
     float: left;
     margin: 4px;
@@ -42,6 +43,7 @@
 .gadgets-log-entry {
 }
 
+/*Container Styles*/
 #widgets {
     margin: 10px auto;
 }
@@ -59,4 +61,31 @@
 #widget_col_2 {
     float: left;
     width: 33%;
-} 
\ No newline at end of file
+}
+
+/*Gadget Directory Styles*/
+.directory-entry {
+    border-bottom: 1px solid #D9E2F4;
+    float: left;
+    margin-bottom: 12px;
+    padding: 0pt 0pt 10px;
+    width: 100%;
+}
+
+.gadget {
+    float: left;
+    text-align: center;
+    width: 140px;
+}
+
+.author {
+    color: #666666;
+    float: right;
+    font-size: 85%;
+    width: 100px;
+}
+
+.info {
+    margin-left: 150px;
+    margin-right: 110px;
+}

Added: trunk/mashup/java/modules/dashboard/directory.jsp
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/dashboard/directory.jsp?pathrev=17932
==============================================================================
--- (empty file)
+++ trunk/mashup/java/modules/dashboard/directory.jsp   Wed Jun  4 08:44:35 2008
@@ -0,0 +1,73 @@
+<%@ page import="org.wso2.registry.Resource" %>
+<%@ page import="org.wso2.mashup.utils.QueryResults" %>
+<%@ page import="java.util.Iterator" %>
+<%@ page import="org.wso2.mashup.utils.QueryResult" %>
+<%--
+ * Copyright 2006,2007 WSO2, Inc. http://www.wso2.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+--%>
+
+<%
+    String thisPage = request.getContextPath() + "/directory.jsp";
+%>
+
+<!--Required to keep a user logged in if 'Remember Me' option is selected-->
+<%@ include file="login_validator.jsp" %>
+
+<!DOCTYPE html>
+<html>
+<head>
+    <title><%= bundle.getString("main.title")%> - Dashboard :: Add 
Gadgets</title>
+    <link rel="stylesheet" href="css/gadgets.css">
+
+    <script type="text/javascript" language="JavaScript">
+        function addGadget() {
+            alert("in toggle add");
+        }
+    </script>
+</head>
+<body>
+
+<div id="local-gadgets">
+
+    <%
+        // Executing a query to get all mashups from the registry
+        QueryResults mashupsCollection =
+                RegistryUtils.doQuery(userRegistry, "Everyone's mashups",
+                                      MashupConstants.ALL_MASHUPS_QUERY_PATH, 
null,
+                                      MashupConstants.MAX_RESULTS_COUNT);
+        Iterator iter = mashupsCollection.getResults().iterator();
+
+        while (iter.hasNext()) {
+            QueryResult result = (QueryResult) iter.next();
+    %>
+    <div class="directory-entry">
+        <div class="gadget">
+            <%=result.getName()%>
+            <div><input type="button" onclick="addGadget();" value="Add it 
now"/></div>
+        </div>
+        <div class="author">
+            <p>By <%=RegistryUtils.getFullName(request, 
result.getAuthor())%></p>            
+        </div>
+        <div class="info">
+            <%=result.getDescription()%>
+        </div>
+    </div>
+    <%
+        }
+    %>
+</div>
+
+</body>
+</html>
\ No newline at end of file

Modified: trunk/mashup/java/modules/dashboard/index.jsp
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/dashboard/index.jsp?rev=17932&r1=17931&r2=17932&view=diff
==============================================================================
--- trunk/mashup/java/modules/dashboard/index.jsp       (original)
+++ trunk/mashup/java/modules/dashboard/index.jsp       Wed Jun  4 08:44:35 2008
@@ -14,7 +14,6 @@
  * limitations under the License.
 --%>
 
-<%@ page import="java.util.ResourceBundle" %>
 <%@ page import="org.wso2.registry.session.UserRegistry" %>
 <%@ page import="org.wso2.mashup.webapp.utils.RegistryUtils" %>
 <%@ page import="org.wso2.registry.jdbc.EmbeddedRegistry" %>
@@ -24,81 +23,14 @@
 <%@ page import="org.wso2.mashup.utils.MashupUtils" %>
 <%@ page import="org.wso2.mashup.MashupConstants" %>
 
-
 <%
-    String thisPage = request.getContextPath() + "index.jsp";
-
-    ResourceBundle bundle = ResourceBundle.getBundle("UI");
-
-    ServerManager serverManager = ServerManager.getInstance();
-    ConfigurationContext configContext = serverManager.configContext;
-    EmbeddedRegistry embeddedRegistry =
-            (EmbeddedRegistry) 
configContext.getAxisConfiguration().getParameterValue(
-                    RegistryConstants.REGISTRY);
-    ServletContext context = request.getSession().getServletContext();
-    context.setAttribute(RegistryConstants.REGISTRY, embeddedRegistry);
-
-    UserRegistry userRegistry = RegistryUtils.getRegistry(request);
-
-    //Checking whether the user is logged in
-    if (!RegistryUtils.isLoggedIn(userRegistry)) {
-
-        //Check whether the remember me option is set
-        Cookie[] cookies = request.getCookies();
-
-        if (cookies != null) {
-            boolean rememberMe = false;
-            String userNameStored = null;
-            String passwordStored = null;
-
-            Cookie curCookie = null;
-            for (int x = 0; x < cookies.length; x++) {
-                curCookie = cookies[x];
-                if (curCookie.getName().equalsIgnoreCase("rememberMe")) {
-                    rememberMe = true;
-                } else if (curCookie.getName().equalsIgnoreCase("username")) {
-                    userNameStored = curCookie.getValue();
-                } else if (curCookie.getName().equalsIgnoreCase("password")) {
-                    passwordStored =
-                            new String(
-                                    new 
sun.misc.BASE64Decoder().decodeBuffer(curCookie.getValue()),
-                                    "UTF-8");
-                }
-            }
-
-            if (rememberMe && (userNameStored != null) && (passwordStored != 
null)) {        
-
-                try {
-                    MashupUtils.login(userNameStored, passwordStored, 
session.getId(),
-                                      "/");
-
-                } catch (Exception e) {
-                    //Deleting the cookie in case of an exception.
-                    for (int x = 0; x < cookies.length; x++) {
-                        curCookie = cookies[x];
-                        if 
(curCookie.getName().equalsIgnoreCase("rememberMe")) {
-                            curCookie.setMaxAge(0);
-                            response.addCookie(curCookie);
-                        } else if 
(curCookie.getName().equalsIgnoreCase("username")) {
-                            curCookie.setMaxAge(0);
-                            response.addCookie(curCookie);
-                        } else if 
(curCookie.getName().equalsIgnoreCase("password")) {
-                            curCookie.setMaxAge(0);
-                            response.addCookie(curCookie);
-                        }
-                    }
-                    //Re-directing to the sign in page
-                    response.sendRedirect("../signin.jsp?bounceback=" + 
thisPage);
-                }
+    String thisPage = request.getContextPath() + "/index.jsp";
+%>
 
-                userRegistry =
-                        RegistryUtils.createUserRegistry(userNameStored, 
embeddedRegistry);
-
-                
request.getSession().setAttribute(MashupConstants.USER_REGISTRY, userRegistry);
-            }
-        }
-    }
+<!--Required to keep a user logged in if 'Remember Me' option is selected-->
+<%@ include file="login_validator.jsp" %>
 
+<%
     String currentUser = userRegistry.getUserName();
 %>
 

Added: trunk/mashup/java/modules/dashboard/login_validator.jsp
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/dashboard/login_validator.jsp?pathrev=17932
==============================================================================
--- (empty file)
+++ trunk/mashup/java/modules/dashboard/login_validator.jsp     Wed Jun  4 
08:44:35 2008
@@ -0,0 +1,83 @@
+<%@ page import="org.wso2.mashup.MashupConstants" %>
+<%@ page import="org.wso2.mashup.utils.MashupUtils" %>
+<%@ page import="org.wso2.mashup.webapp.utils.RegistryUtils" %>
+<%@ page import="org.apache.axis2.context.ConfigurationContext" %>
+<%@ page import="org.wso2.registry.RegistryConstants" %>
+<%@ page import="org.wso2.registry.jdbc.EmbeddedRegistry" %>
+<%@ page import="org.wso2.registry.session.UserRegistry" %>
+<%@ page import="org.wso2.wsas.ServerManager" %>
+<%@ page import="java.util.ResourceBundle" %>
+
+<%
+    ResourceBundle bundle = ResourceBundle.getBundle("UI");
+
+    ServerManager serverManager = ServerManager.getInstance();
+    ConfigurationContext configContext = serverManager.configContext;
+    EmbeddedRegistry embeddedRegistry =
+            (EmbeddedRegistry) 
configContext.getAxisConfiguration().getParameterValue(
+                    RegistryConstants.REGISTRY);
+    ServletContext context = request.getSession().getServletContext();
+    context.setAttribute(RegistryConstants.REGISTRY, embeddedRegistry);
+
+    UserRegistry userRegistry = RegistryUtils.getRegistry(request);
+
+    //Checking whether the user is logged in
+    if (!RegistryUtils.isLoggedIn(userRegistry)) {
+
+        //Check whether the remember me option is set
+        Cookie[] cookies = request.getCookies();
+
+        if (cookies != null) {
+            boolean rememberMe = false;
+            String userNameStored = null;
+            String passwordStored = null;
+
+            Cookie curCookie = null;
+            for (int x = 0; x < cookies.length; x++) {
+                curCookie = cookies[x];
+                if (curCookie.getName().equalsIgnoreCase("rememberMe")) {
+                    rememberMe = true;
+                } else if (curCookie.getName().equalsIgnoreCase("username")) {
+                    userNameStored = curCookie.getValue();
+                } else if (curCookie.getName().equalsIgnoreCase("password")) {
+                    passwordStored =
+                            new String(
+                                    new 
sun.misc.BASE64Decoder().decodeBuffer(curCookie.getValue()),
+                                    "UTF-8");
+                }
+            }
+
+            if (rememberMe && (userNameStored != null) && (passwordStored != 
null)) {
+
+                try {
+                    MashupUtils.login(userNameStored, passwordStored, 
session.getId(),
+                                      "/");
+
+                } catch (Exception e) {
+                    //Deleting the cookie in case of an exception.
+                    for (int x = 0; x < cookies.length; x++) {
+                        curCookie = cookies[x];
+                        if 
(curCookie.getName().equalsIgnoreCase("rememberMe")) {
+                            curCookie.setMaxAge(0);
+                            response.addCookie(curCookie);
+                        } else if 
(curCookie.getName().equalsIgnoreCase("username")) {
+                            curCookie.setMaxAge(0);
+                            response.addCookie(curCookie);
+                        } else if 
(curCookie.getName().equalsIgnoreCase("password")) {
+                            curCookie.setMaxAge(0);
+                            response.addCookie(curCookie);
+                        }
+                    }
+                    //Re-directing to the sign in page
+                    response.sendRedirect("../signin.jsp?bounceback=" + 
thisPage);
+                }
+
+                userRegistry =
+                        RegistryUtils.createUserRegistry(userNameStored, 
embeddedRegistry);
+
+                
request.getSession().setAttribute(MashupConstants.USER_REGISTRY, userRegistry);
+            }
+        }
+    }
+
+%>
\ No newline at end of file

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

Reply via email to