Page 1 of 1

Getting user details when overriding methods

Posted: 13 Nov 2011, 22:41
by gwills
I'm sure there is an easy way to do this, basically I am trying to override the loadInventoryData and update the inventory results based on the current user.

I know when I extend the API by using addRequestHandler the sender is sent as a a parameter in handleClientRequest but I am wondering how I can get this user info inside the following:

@Override
public String loadInventoryData(String inventoryId)
{
}

Sorry if this is documented somewhere but I have looked and haven't found how to do this.

Posted: 14 Nov 2011, 09:28
by Bax
You can't change the number of parameters passed to an overridden method. Maybe you can save the data you need in a global variable and then access it from within the overridden method.

Posted: 24 Nov 2011, 10:03
by gwills
But is the Current User not accessible as a global variable already somewhere?

I already have some information stored in the session for the user from a previous request and I am just trying to get access to this session info in the loadInventoryData method. I am sure all I am missing is the correct syntax here.

@Override
public String loadInventoryData(String inventoryId)
{
//Get Current User\Session

//Use the user info to return subset of inventory items
}

Posted: 25 Nov 2011, 13:17
by Bax
In that method there's no reference to the user who sent the request, I'm sorry.

Posted: 28 Nov 2011, 09:35
by gwills
Does anyone have any recommendations on how to achieve this. If it is not possible to filter inventory on the server side I could do it i guess on the client side, but i am trying to avoid downloading the entire inventory as a user may only have access to a small subset.

Posted: 28 Nov 2011, 20:30
by Bax
Why don't you override getInventoryItemsList method of the OpenSpace Extension? This allows you to filter the inventory items based on the requester and other custom parameters BEFORE sending them to the client. Check the API for details.