Author: chris.laprun(a)jboss.com
Date: 2007-03-20 00:21:33 -0400 (Tue, 20 Mar 2007)
New Revision: 6766
Added:
trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/UserAccess.java
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
Log:
- JBPORTAL-1254: Added UserAccess class to encapsulate user information retrieval from
request.
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-03-20
02:05:40 UTC (rev 6765)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-03-20
04:21:33 UTC (rev 6766)
@@ -45,6 +45,7 @@
import org.jboss.portal.wsrp.core.RegistrationContext;
import org.jboss.portal.wsrp.core.ServiceDescription;
import org.jboss.portal.wsrp.core.WSRP_v1_PortletManagement_PortType;
+import org.jboss.portal.wsrp.servlet.UserAccess;
import java.util.Collections;
import java.util.HashMap;
@@ -428,7 +429,8 @@
log.debug("Retrieving portlet '" + portletHandle + "' via
getPortletDescription");
GetPortletDescription gpd =
WSRPTypeFactory.createGetPortletDescription(getRegistrationContext(), portletContext);
- gpd.setUserContext(null); // todo: deal with user context!!
+ gpd.setUserContext(UserAccess.getUserContext());
+
try
{
PortletDescriptionResponse response =
persistentEndpointInfo.getPortletManagementService().getPortletDescription(gpd);
@@ -589,7 +591,7 @@
GetPortletPropertyDescription request =
WSRPTypeFactory.createSimpleGetPortletPropertyDescription(portletHandle);
request.setRegistrationContext(getRegistrationContext());
- request.setUserContext(null); // todo: fix me!
+ request.setUserContext(UserAccess.getUserContext());
return service.getPortletPropertyDescription(request);
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-03-20
02:05:40 UTC (rev 6765)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-03-20
04:21:33 UTC (rev 6766)
@@ -68,6 +68,7 @@
import org.jboss.portal.wsrp.core.WSRP_v1_Registration_PortType;
import org.jboss.portal.wsrp.core.WSRP_v1_ServiceDescription_PortType;
import org.jboss.portal.wsrp.services.ServiceFactory;
+import org.jboss.portal.wsrp.servlet.UserAccess;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@@ -204,9 +205,8 @@
throw new PortletInvokerException("No portlet '" +
portletContext.getId() + "' to clone!");
}
- // todo: deal with user context
ClonePortlet clonePortlet =
WSRPTypeFactory.createClonePortlet(getRegistrationContext(),
- WSRPUtils.convertToWSRPPortletContext(portletContext), null);
+ WSRPUtils.convertToWSRPPortletContext(portletContext),
UserAccess.getUserContext());
try
{
PortletContext newPortletContext =
WSRPUtils.convertToPortalPortletContext(getPortletManagementService().clonePortlet(clonePortlet));
Added: trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/UserAccess.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/UserAccess.java
(rev 0)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/UserAccess.java 2007-03-20 04:21:33
UTC (rev 6766)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.jboss.portal.wsrp.servlet;
+
+import org.jboss.portal.wsrp.WSRPTypeFactory;
+import org.jboss.portal.wsrp.core.UserContext;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class UserAccess
+{
+ public static String getUser()
+ {
+ HttpServletRequest req = ServletAccess.getRequest();
+ return req.getRemoteUser();
+ }
+
+ public static UserContext getUserContext()
+ {
+ String userId = getUser();
+ return userId != null ? WSRPTypeFactory.createUserContext(userId) : null;
+ }
+}
Property changes on: trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/UserAccess.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native