From: <die...@us...> - 2010-02-15 15:49:11
|
Revision: 1949 http://openutils.svn.sourceforge.net/openutils/?rev=1949&view=rev Author: diego_schivo Date: 2010-02-15 15:49:04 +0000 (Mon, 15 Feb 2010) Log Message: ----------- Module store: json postdata Modified Paths: -------------- trunk/magnolia-test-webapp/src/main/java/info/magnolia/module/admininterface/pages/AllModulesListPage.java trunk/magnolia-test-webapp/src/main/resources/info/magnolia/module/admininterface/pages/AllModulesListPage.html trunk/module-store-server-webapp/src/main/webapp/templates/pages/module-list.jsp Added Paths: ----------- trunk/module-store-server-webapp/src/main/java/info/magnolia/module/ trunk/module-store-server-webapp/src/main/java/info/magnolia/module/modulestore/ trunk/module-store-server-webapp/src/main/java/info/magnolia/module/modulestore/el/ trunk/module-store-server-webapp/src/main/java/info/magnolia/module/modulestore/el/ModuleStoreElFunctions.java trunk/module-store-server-webapp/src/main/resources/META-INF/ trunk/module-store-server-webapp/src/main/resources/META-INF/modulestore-taglib.tld Modified: trunk/magnolia-test-webapp/src/main/java/info/magnolia/module/admininterface/pages/AllModulesListPage.java =================================================================== --- trunk/magnolia-test-webapp/src/main/java/info/magnolia/module/admininterface/pages/AllModulesListPage.java 2010-02-15 14:05:42 UTC (rev 1948) +++ trunk/magnolia-test-webapp/src/main/java/info/magnolia/module/admininterface/pages/AllModulesListPage.java 2010-02-15 15:49:04 UTC (rev 1949) @@ -6,13 +6,15 @@ import java.util.ArrayList; import java.util.Collections; -import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +import org.apache.taglibs.standard.functions.Functions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -29,7 +31,7 @@ */ private static Logger log = LoggerFactory.getLogger(AllModulesListPage.class); - private Map<String, String> installedModules = new LinkedHashMap<String, String>(); + private String postdata; /** * @@ -41,12 +43,12 @@ } /** - * Returns the installedModules. - * @return the installedModules + * Returns the postdata. + * @return the postdata */ - public Map<String, String> getInstalledModules() + public String getPostdata() { - return installedModules; + return postdata; } /** @@ -55,6 +57,7 @@ @Override public String show() { + JSONArray installedModules = new JSONArray(); ModuleRegistry registry = ModuleRegistry.Factory.getInstance(); List<String> moduleNames = new ArrayList<String>(registry.getModuleNames()); Collections.sort(moduleNames); @@ -63,9 +66,15 @@ ModuleDefinition def = registry.getDefinition(name); if (def != null) { - installedModules.put(def.getName(), def.getVersion().toString()); + JSONObject module = new JSONObject(); + module.set("name", def.getName()); + module.set("version", def.getVersion().toString()); + installedModules.put(module); } } + JSONObject json = new JSONObject(); + json.set("installedModules", installedModules); + postdata = Functions.escapeXml(json.toString()); return super.show(); } } Modified: trunk/magnolia-test-webapp/src/main/resources/info/magnolia/module/admininterface/pages/AllModulesListPage.html =================================================================== --- trunk/magnolia-test-webapp/src/main/resources/info/magnolia/module/admininterface/pages/AllModulesListPage.html 2010-02-15 14:05:42 UTC (rev 1948) +++ trunk/magnolia-test-webapp/src/main/resources/info/magnolia/module/admininterface/pages/AllModulesListPage.html 2010-02-15 15:49:04 UTC (rev 1949) @@ -19,9 +19,7 @@ <body id="mgnl" onload="setTimeout(loadModules, 1000);"> <form id="loadModulesForm" action="/module-store-server/module-list.html" method="post"> <div> - [#list this.installedModules?keys as key] - <input type="hidden" name="${key}" value="${this.installedModules[key]}" /> - [/#list] + <input type="hidden" name="postdata" value="${this.postdata}" /> </div> </form> <div style="display: block; width: 400px; background-color: #999; margin: 50px auto; text-align: center;"> Added: trunk/module-store-server-webapp/src/main/java/info/magnolia/module/modulestore/el/ModuleStoreElFunctions.java =================================================================== --- trunk/module-store-server-webapp/src/main/java/info/magnolia/module/modulestore/el/ModuleStoreElFunctions.java (rev 0) +++ trunk/module-store-server-webapp/src/main/java/info/magnolia/module/modulestore/el/ModuleStoreElFunctions.java 2010-02-15 15:49:04 UTC (rev 1949) @@ -0,0 +1,38 @@ +package info.magnolia.module.modulestore.el; + +import java.util.HashMap; +import java.util.Map; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + + +/** + * @author dschivo + * @version $Id$ + */ +public final class ModuleStoreElFunctions +{ + + /** + * + */ + private ModuleStoreElFunctions() + { + } + + public static Map<String, String> installedModuleVersionsFromJson(String jsonString) + { + JSONObject jsonObj = new JSONObject(jsonString); + JSONArray installedModules = jsonObj.getJSONArray("installedModules"); + int length = installedModules.length(); + Map<String, String> map = new HashMap<String, String>(length); + for (int index = 0; index < length; index++) + { + JSONObject module = installedModules.getJSONObject(index); + map.put(module.getString("name"), module.getString("version")); + } + return map; + } + +} Property changes on: trunk/module-store-server-webapp/src/main/java/info/magnolia/module/modulestore/el/ModuleStoreElFunctions.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/module-store-server-webapp/src/main/resources/META-INF/modulestore-taglib.tld =================================================================== --- trunk/module-store-server-webapp/src/main/resources/META-INF/modulestore-taglib.tld (rev 0) +++ trunk/module-store-server-webapp/src/main/resources/META-INF/modulestore-taglib.tld 2010-02-15 15:49:04 UTC (rev 1949) @@ -0,0 +1,15 @@ +<taglib xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" + version="2.0"> + <description>Module store functions</description> + <display-name>module store functions</display-name> + <tlib-version>1.0</tlib-version> + <short-name>modulestorefn</short-name> + <uri>http://www.magnolia.info/tlds/modulestore-taglib.tld</uri> + <function> + <description></description> + <name>installedModuleVersionsFromJson</name> + <function-class>info.magnolia.module.modulestore.el.ModuleStoreElFunctions</function-class> + <function-signature>java.util.Map installedModuleVersionsFromJson(java.lang.String)</function-signature> + </function> +</taglib> Property changes on: trunk/module-store-server-webapp/src/main/resources/META-INF/modulestore-taglib.tld ___________________________________________________________________ Added: svn:mime-type + text/xml Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/module-store-server-webapp/src/main/webapp/templates/pages/module-list.jsp =================================================================== --- trunk/module-store-server-webapp/src/main/webapp/templates/pages/module-list.jsp 2010-02-15 14:05:42 UTC (rev 1948) +++ trunk/module-store-server-webapp/src/main/webapp/templates/pages/module-list.jsp 2010-02-15 15:49:04 UTC (rev 1949) @@ -1,6 +1,7 @@ <jsp:root version="2.0" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:fmt="http://java.sun.com/jsp/jstl/fmt" xmlns:fn="http://java.sun.com/jsp/jstl/functions" xmlns:cms="urn:jsptld:cms-taglib" - xmlns:cmsu="urn:jsptld:cms-util-taglib" xmlns:cmsfn="http://www.magnolia.info/tlds/cmsfn-taglib.tld"> + xmlns:cmsu="urn:jsptld:cms-util-taglib" xmlns:cmsfn="http://www.magnolia.info/tlds/cmsfn-taglib.tld" + xmlns:modulestorefn="http://www.magnolia.info/tlds/modulestore-taglib.tld"> <jsp:directive.page contentType="text/html; charset=UTF-8" session="false" /> <jsp:text> <![CDATA[<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> ]]> @@ -72,6 +73,7 @@ <td>Status</td> </tr> </thead> + <c:set var="installedModuleVersions" value="${modulestorefn:installedModuleVersionsFromJson(param.postdata)}" /> <cms:contentNodeIterator items="${detailPages}" varStatus="loop"> <cms:setNode var="detailPage" /> <tr class="${loop.index % 2 == 0 ? 'odd' : 'even'}"> @@ -92,7 +94,7 @@ </c:if> </td> <td>${detailPage.version}</td> - <c:set var="version" value="${param[detailPage.name]}" /> + <c:set var="version" value="${installedModuleVersions[detailPage.name]}" /> <td> <c:choose> <c:when test="${empty version}">Not installed</c:when> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |