[parancoe] 2 new revisions pushed by lucio.be...@gmail.com on 2012-01-25 16:57 GMT

0 views
Skip to first unread message

para...@googlecode.com

unread,
Jan 25, 2012, 11:58:12 AM1/25/12
to parancoe...@googlegroups.com
2 new revisions:

Revision: 84dedfc47642
Author: lucio.benfante <lucio.b...@gmail.com>
Date: Wed Jan 25 08:53:20 2012
Log: A little generalization for the FlashHelper.
http://code.google.com/p/parancoe/source/detail?r=84dedfc47642

Revision: 30b1ff48d8c2
Author: lucio.benfante <lucio.b...@gmail.com>
Date: Wed Jan 25 08:56:41 2012
Log: Merged
http://code.google.com/p/parancoe/source/detail?r=30b1ff48d8c2

==============================================================================
Revision: 84dedfc47642
Author: lucio.benfante <lucio.b...@gmail.com>
Date: Wed Jan 25 08:53:20 2012
Log: A little generalization for the FlashHelper.
http://code.google.com/p/parancoe/source/detail?r=84dedfc47642

Modified:
/parancoe-web/src/main/java/org/parancoe/web/util/FlashHelper.java

=======================================
--- /parancoe-web/src/main/java/org/parancoe/web/util/FlashHelper.java Sat
Sep 4 02:41:52 2010
+++ /parancoe-web/src/main/java/org/parancoe/web/util/FlashHelper.java Wed
Jan 25 08:53:20 2012
@@ -24,35 +24,41 @@
/**
*
* @author Jacopo Murador <jacopo.murador at seesaw.it>
+ * @author Lucio Benfante <lu...@benfante.com>
*/
public class FlashHelper {
+ public static String DEFAULT_NOTICE_TYPE = "notice";
+ public static String DEFAULT_ERROR_TYPE = "error";
+ public static String DEFAULT_FLASH_ATTRIBUTE = "flash";

public static void setError(HttpServletRequest req, String code) {
- Map<String, String> flash = (Map<String,
String>)req.getAttribute("flash");
- if (flash == null) flash = new HashMap<String, String>();
- flash.put("error", code);
- req.setAttribute("flash", flash);
+ doSet(req, code, DEFAULT_ERROR_TYPE, DEFAULT_FLASH_ATTRIBUTE);
}

public static void setNotice(HttpServletRequest req, String code) {
- Map<String, String> flash = (Map<String,
String>)req.getAttribute("flash");
- if (flash == null) flash = new HashMap<String, String>();
- flash.put("notice", code);
- req.setAttribute("flash", flash);
+ doSet(req, code, DEFAULT_NOTICE_TYPE, DEFAULT_FLASH_ATTRIBUTE);
}

- public static void setRedirectError(HttpServletRequest req, String
code) {
- Map<String, String> flash = (Map<String,
String>)req.getSession().getAttribute("flash");
+ public static void doSet(HttpServletRequest req, String code, String
type, String attribute) {
+ Map<String, String> flash = (Map<String,
String>)req.getAttribute(attribute);
if (flash == null) flash = new HashMap<String, String>();
- flash.put("error", code);
- req.getSession().setAttribute("flash", flash);
+ flash.put(DEFAULT_ERROR_TYPE, code);
+ req.setAttribute(attribute, flash);
+ }
+
+ public static void setRedirectError(HttpServletRequest req, String
code) {
+ doSetRedirect(req, code, DEFAULT_ERROR_TYPE,
DEFAULT_FLASH_ATTRIBUTE);
}

public static void setRedirectNotice(HttpServletRequest req, String
code) {
- Map<String, String> flash = (Map<String,
String>)req.getSession().getAttribute("flash");
+ doSetRedirect(req, code, DEFAULT_NOTICE_TYPE,
DEFAULT_FLASH_ATTRIBUTE);
+ }
+
+ public static void doSetRedirect(HttpServletRequest req, String code,
String type, String attribute) {
+ Map<String, String> flash = (Map<String,
String>)req.getSession().getAttribute(attribute);
if (flash == null) flash = new HashMap<String, String>();
- flash.put("notice", code);
- req.getSession().setAttribute("flash", flash);
+ flash.put(type, code);
+ req.getSession().setAttribute(attribute, flash);
}

}

==============================================================================
Revision: 30b1ff48d8c2
Author: lucio.benfante <lucio.b...@gmail.com>
Date: Wed Jan 25 08:56:41 2012
Log: Merged
http://code.google.com/p/parancoe/source/detail?r=30b1ff48d8c2

Deleted:
/examples/basicWebAppEvolution/src/main/resources/initialData/Authority.yml
/examples/basicWebAppEvolution/src/main/resources/initialData/User.yml

=======================================
---
/examples/basicWebAppEvolution/src/main/resources/initialData/Authority.yml
Sat Oct 11 23:29:39 2008
+++ /dev/null
@@ -1,4 +0,0 @@
-- &Authority-parancoe
- role: ROLE_PARANCOE
-- &Authority-admin
- role: ROLE_ADMIN
=======================================
--- /examples/basicWebAppEvolution/src/main/resources/initialData/User.yml
Sun Oct 19 01:30:03 2008
+++ /dev/null
@@ -1,12 +0,0 @@
-- &User-parancoe
- username: parancoe
- password: d928b1a8468c96804da6fcc70bff826f
- enabled: true
- authorities:
- - *Authority-parancoe
-- &User-admin
- username: admin
- password: ceb4f32325eda6142bd65215f4c0f371
- enabled: true
- authorities:
- - *Authority-admin

Reply all
Reply to author
Forward
0 new messages