added request builder injection
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/client-context-library@134693 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
cf4456a0cd
commit
0689fc24b0
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.portal.clientcontext.client;
|
||||
|
||||
import com.google.gwt.core.client.EntryPoint;
|
||||
import com.google.gwt.http.client.RequestBuilder;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -9,6 +10,7 @@ import com.google.gwt.core.client.EntryPoint;
|
|||
*/
|
||||
public class GCubeClientContext implements EntryPoint {
|
||||
public static final String VRE_ID_ATTR_NAME = "gcube-vreid";
|
||||
public static final String USER_ID_ATTR_NAME = "gcube-userId";
|
||||
|
||||
public void onModuleLoad() {}
|
||||
|
||||
|
@ -21,4 +23,22 @@ public class GCubeClientContext implements EntryPoint {
|
|||
return groupId;
|
||||
}-*/;
|
||||
|
||||
public static native String getCurrentUserId() /*-{
|
||||
var userId;
|
||||
if ($wnd.Liferay != null) {
|
||||
userId = $wnd.Liferay.ThemeDisplay.getUserId();
|
||||
console.log("current userid is = " + userId);
|
||||
}
|
||||
return userId;
|
||||
}-*/;
|
||||
/**
|
||||
* to be used in standard servlets requests before the actual request
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public static RequestBuilder injectContext(RequestBuilder request) {
|
||||
request.setHeader(VRE_ID_ATTR_NAME, getCurrentContextId());
|
||||
request.setHeader(USER_ID_ATTR_NAME, getCurrentUserId());
|
||||
return request;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue