[Yanel-commits] rev 44368 - in
public/yanel/contributions/resources/timetracker: htdocs
src/java/org/wyona/yanel/impl/resources/timetracker
michi at wyona.com
michi at wyona.com
Mon Aug 24 23:28:23 CEST 2009
Author: michi
Date: 2009-08-24 23:28:22 +0200 (Mon, 24 Aug 2009)
New Revision: 44368
Modified:
public/yanel/contributions/resources/timetracker/htdocs/create-entry.xsl
public/yanel/contributions/resources/timetracker/src/java/org/wyona/yanel/impl/resources/timetracker/TimeTrackerResource.java
Log:
identity handling implemented
Modified: public/yanel/contributions/resources/timetracker/htdocs/create-entry.xsl
===================================================================
--- public/yanel/contributions/resources/timetracker/htdocs/create-entry.xsl 2009-08-24 21:18:12 UTC (rev 44367)
+++ public/yanel/contributions/resources/timetracker/htdocs/create-entry.xsl 2009-08-24 21:28:22 UTC (rev 44368)
@@ -15,15 +15,16 @@
<title>Create time entry</title>
</head>
<body>
+ <a href="?yanel.resource.viewid=xml">Debug XML</a>
<h1>Create Time Entry</h1>
<form>
<table>
<tr>
- <td>Your name:</td><td><xsl:value-of select="/tt:time-tracking/tt:user"/></td>
+ <td>Your name:</td><td><xsl:value-of select="/tt:time-tracking/tt:user"/><xsl:apply-templates select="/tt:time-tracking/tt:no-identity-yet"/></td>
</tr>
<tr><td>*Date:</td><td><input type="text" name="date" value="TODO"/></td></tr>
<tr><td>*Client/Project:</td><td><select name="client-project"><option value="todo1">TODO 1</option><option value="todo2">TODO 2</option></select></td></tr>
- <tr><td>*Task/Description:</td><td><input type="text" name="task-description" value="TODO"/></td></tr>
+ <tr><td>*Task/Description:</td><td><input type="text" name="task-description" value=""/></td></tr>
<tr><td>*Effort/Duration (h):</td><td><input type="text" name="effort" value="0.25"/></td></tr>
<tr><td>Comment:</td><td><input type="text" name="comment" value=""/></td></tr>
<tr><td colspan="2"><input type="submit" name="submit" value="Save"/> <input type="submit" name="cancel" value="Cancel"/></td></tr>
@@ -36,4 +37,8 @@
</html>
</xsl:template>
+<xsl:template match="tt:no-identity-yet">
+WARNING: No identity yet! (HINT: This resource should be protected)
+</xsl:template>
+
</xsl:stylesheet>
Modified: public/yanel/contributions/resources/timetracker/src/java/org/wyona/yanel/impl/resources/timetracker/TimeTrackerResource.java
===================================================================
--- public/yanel/contributions/resources/timetracker/src/java/org/wyona/yanel/impl/resources/timetracker/TimeTrackerResource.java 2009-08-24 21:18:12 UTC (rev 44367)
+++ public/yanel/contributions/resources/timetracker/src/java/org/wyona/yanel/impl/resources/timetracker/TimeTrackerResource.java 2009-08-24 21:28:22 UTC (rev 44368)
@@ -21,14 +21,20 @@
/*
* @see org.wyona.yanel.impl.resources.BasicXMLResource#getContentXML(String)
*/
- protected InputStream getContentXML(String viewId) {
+ protected InputStream getContentXML(String viewId) throws Exception {
if (log.isDebugEnabled()) {
log.debug("requested viewId: " + viewId);
}
StringBuilder sb = new StringBuilder("<?xml version=\"1.0\"?>");
sb.append("<time-tracking xmlns=\"http://www.wyona.org/resource/time-tracking/1.0\">");
- sb.append(" <user id=\"" + "michi" + "\">" + "Michael Wechner" + "</user>");
+ org.wyona.security.core.api.Identity identity = getEnvironment().getIdentity();
+ if (identity != null && identity.getUsername() != null) {
+ org.wyona.security.core.api.User user = getRealm().getIdentityManager().getUserManager().getUser(identity.getUsername());
+ sb.append(" <user id=\"" + identity.getUsername() + "\">" + user.getDescription() + "</user>");
+ } else {
+ sb.append("<no-identity-yet/>");
+ }
sb.append("</time-tracking>");
return new ByteArrayInputStream(sb.toString().getBytes());
More information about the Yanel-commits
mailing list