[Yanel-dev] Re: [Yanel-commits] rev
26033 - public/yanel/trunk/src/resources/xml/src/java/org/wyona/yanel/impl/resources
Michael Wechner
michael.wechner at wyona.com
Tue Jul 17 16:40:47 CEST 2007
Josias Thöny wrote:
> michi at wyona.com wrote:
>
>> Author: michi
>> Date: 2007-07-17 10:59:41 +0200 (Tue, 17 Jul 2007)
>> New Revision: 26033
>>
>> Modified:
>>
>> public/yanel/trunk/src/resources/xml/src/java/org/wyona/yanel/impl/resources/XMLResource.java
>>
>> Log:
>> get username added
>
>
> FYI, you can also get the user name in a resource as follows:
>
> getEnvironment().getIdentity().getUsername();
good to know, whereas I guess we still need to check if getIdentity is
null, right?
Cheers
Michi
>
> josias
>
>
>
>>
>> Modified:
>> public/yanel/trunk/src/resources/xml/src/java/org/wyona/yanel/impl/resources/XMLResource.java
>>
>> ===================================================================
>> ---
>> public/yanel/trunk/src/resources/xml/src/java/org/wyona/yanel/impl/resources/XMLResource.java
>> 2007-07-17 08:59:20 UTC (rev 26032)
>> +++
>> public/yanel/trunk/src/resources/xml/src/java/org/wyona/yanel/impl/resources/XMLResource.java
>> 2007-07-17 08:59:41 UTC (rev 26033)
>> @@ -54,6 +54,10 @@
>> import org.wyona.yarep.core.RepositoryFactory;
>> import org.wyona.yarep.core.Revision;
>> import org.wyona.yarep.util.RepoPath;
>> +
>> +import org.wyona.security.core.api.Identity;
>> +import org.wyona.security.core.api.IdentityMap;
>> +
>> import org.xml.sax.InputSource;
>> import org.xml.sax.XMLReader;
>> import org.xml.sax.helpers.XMLReaderFactory;
>> @@ -96,6 +100,8 @@
>> public class XMLResource extends Resource implements ViewableV2,
>> ModifiableV2, VersionableV2, CreatableV2, IntrospectableV1,
>> TranslatableV1, WorkflowableV1 {
>>
>> private static Category log =
>> Category.getInstance(XMLResource.class);
>> +
>> + private static String IDENTITY_MAP_KEY = "identity-map";
>> /**
>> *
>> @@ -169,7 +175,7 @@
>>
>> xsltHandlers[i].getTransformer().setParameter("content-language",
>> getContentLanguage());
>>
>> // Username
>> -
>> xsltHandlers[i].getTransformer().setParameter("username", "HUGO");
>> +
>> xsltHandlers[i].getTransformer().setParameter("username",
>> getUsername());
>> }
>> // create i18n transformer:
>> @@ -692,4 +698,14 @@
>> return WorkflowHelper.getWorkflowIntrospection(this);
>> }
>>
>> + /**
>> + * Get username from session
>> + */
>> + private String getUsername() {
>> + IdentityMap im = (IdentityMap)
>> getRequest().getSession(true).getAttribute(IDENTITY_MAP_KEY);
>> + if (im != null) {
>> + return
>> ((Identity)im.get(getRealm().getID())).getUsername();
>> + }
>> + return null;
>> + }
>> }
>>
>> _______________________________________________
>> Yanel-commits mailing list
>> Yanel-commits at wyona.com
>> http://wyona.com/cgi-bin/mailman/listinfo/yanel-commits
>
>
> _______________________________________________
> Yanel-development mailing list
> Yanel-development at wyona.com
> http://wyona.com/cgi-bin/mailman/listinfo/yanel-development
--
Michael Wechner
Wyona - Open Source Content Management - Yanel, Yulup
http://www.wyona.com
michael.wechner at wyona.com, michi at apache.org
+41 44 272 91 61
More information about the Yanel-development
mailing list