Author: tyrell
Date: Wed Jun 4 11:52:59 2008
New Revision: 17938
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=17938
Log:
Initial code to store a users gadget URLs in the registry.
Added:
trunk/mashup/java/modules/dashboard/ajax_add_gadget.jsp
trunk/mashup/java/modules/dashboard/javascript/prototype.js
- copied unchanged from r17887,
/trunk/mashup/java/modules/www/js/prototype.js
Added: trunk/mashup/java/modules/dashboard/ajax_add_gadget.jsp
URL:
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/dashboard/ajax_add_gadget.jsp?pathrev=17938
==============================================================================
--- (empty file)
+++ trunk/mashup/java/modules/dashboard/ajax_add_gadget.jsp Wed Jun 4
11:52:59 2008
@@ -0,0 +1,84 @@
+<%--
+ * 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.
+--%>
+<%@ page import="org.wso2.registry.Resource" %>
+<%@ page import="org.wso2.registry.Comment" %>
+<%@ page import="org.wso2.registry.exceptions.RegistryException" %>
+<%@ page import="org.wso2.registry.ResourceImpl" %>
+<%@ page import="java.util.ArrayList" %>
+
+<%
+ String thisPage = request.getContextPath() + "/ajax_add_gadget.jsp";
+%>
+
+<!--Required to keep a user logged in if 'Remember Me' option is selected-->
+<%@ include file="login_validator.jsp" %>
+
+<%
+ String currentUser = RegistryUtils.getCurrentUser(userRegistry);
+
+ boolean success = true;
+ String reason = "";
+
+ String gadgetPath = MashupConstants.USERS_PATH + "/" + currentUser +
"/gadgets";
+ String gadgetUrl = request.getParameter("gadgetUrl");
+
+ Resource gadgetList = null;
+
+ try {
+ if (!RegistryUtils.isLoggedIn(userRegistry)) {
+ success = false;
+ reason = "Unauthorized attempt to add a gadget - please log in and
try again.";
+ } else if (request.getMethod().equals("POST")) {
+ String method = request.getParameter("_method");
+ if (method != null && method.equals("delete")) {
+ // todo Add deletion code
+ } else {
+ if (userRegistry.get(gadgetPath) == null) {
+ // Creating the resource
+ gadgetList = new ResourceImpl();
+ gadgetList.setDescription(
+ "A list of Google Gadget URLs to be displayed in
the Dashboard.");
+ ArrayList gadgetUrls = new ArrayList();
+ gadgetUrls.add(gadgetUrl);
+ gadgetList.setProperty("GADGET_LIST", gadgetUrls);
+ } else {
+ gadgetList = userRegistry.get(gadgetPath);
+ ArrayList gadgetUrls = (ArrayList)
gadgetList.getPropertyValues("GADGET_LIST");
+ gadgetUrls.add(gadgetUrl);
+ gadgetList.setProperty("GADGET_LIST", gadgetUrls);
+ }
+
+ try {
+ userRegistry.put(gadgetPath, gadgetList);
+ } catch (RegistryException e) {
+ success = false;
+ reason = e.getMessage();
+ }
+ }
+ }
+ } catch (RegistryException e) {
+ success = false;
+ reason = e.getMessage();
+ }
+
+ if (!success) { %>
+<div class="error">Error! <%=reason%>
+</div>
+<% } else {
+%>
+<div class="success">success</div>
+<%
+ }%>
\ No newline at end of file
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev