[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 17:22:04 CEST 2007
Josias Thöny wrote:
> Michael Wechner wrote:
>
>> 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?
>
>
> Well, currently it should not return null. If the identity in the
> session is null, YanelServlet adds a new empty Identity() to the
> environment.
> But since the getIdentity() method does not specify anything about the
> return value, we cannot rely on that. So either we declare that the
> getIdentity() method should not return null,
I guess we should add this to Javadoc, right?
Cheers
Michi
> or we have to check if the returned value is null.
> WDYT?
>
> josias
>
>
>>
>> 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
>>
>>
>>
>>
>
> _______________________________________________
> Yanel-development mailing list
> Yanel-development at lists.wy
> http://lists.wy/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