Author: chris.laprun(a)jboss.com
Date: 2007-05-30 18:22:20 -0400 (Wed, 30 May 2007)
New Revision: 7367
Modified:
trunk/core-cms/src/main/org/jboss/portal/core/cms/servlet/CMSPreviewServlet.java
Log:
- Removed redundant casts.
Modified:
trunk/core-cms/src/main/org/jboss/portal/core/cms/servlet/CMSPreviewServlet.java
===================================================================
---
trunk/core-cms/src/main/org/jboss/portal/core/cms/servlet/CMSPreviewServlet.java 2007-05-30
22:22:01 UTC (rev 7366)
+++
trunk/core-cms/src/main/org/jboss/portal/core/cms/servlet/CMSPreviewServlet.java 2007-05-30
22:22:20 UTC (rev 7367)
@@ -22,22 +22,21 @@
******************************************************************************/
package org.jboss.portal.core.cms.servlet;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
import org.jboss.mx.util.MBeanProxy;
import org.jboss.mx.util.MBeanServerLocator;
import org.jboss.portal.cms.CMS;
import org.jboss.portal.cms.Command;
+import org.jboss.portal.cms.impl.jcr.JCRCMS;
import org.jboss.portal.cms.model.Content;
import org.jboss.portal.cms.model.File;
+import org.jboss.portal.identity.IdentityContext;
+import org.jboss.portal.identity.IdentityServiceController;
import org.jboss.portal.identity.User;
import org.jboss.portal.identity.UserModule;
-import org.jboss.portal.identity.IdentityServiceController;
-import org.jboss.portal.identity.IdentityContext;
-import org.jboss.portal.cms.impl.jcr.JCRCMS;
-import org.hibernate.SessionFactory;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.naming.InitialContext;
@@ -56,23 +55,23 @@
private static final long serialVersionUID = 1676227756085242093L;
/**
- *
+ *
*/
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
IOException
{
- String path = (String)request.getParameter("p");
- String version = (String)request.getParameter("v");
- String language = (String)request.getParameter("l");
+ String path = request.getParameter("p");
+ String version = request.getParameter("v");
+ String language = request.getParameter("l");
try
{
MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
CMS CMSService = (CMS)MBeanProxy.get(CMS.class, new
ObjectName("portal:service=CMS"), mbeanServer);
IdentityServiceController identityService =
(IdentityServiceController)MBeanProxy.get(
- IdentityServiceController.class, new
ObjectName("portal:service=Module,type=IdentityServiceController"),
mbeanServer);
-
+ IdentityServiceController.class, new
ObjectName("portal:service=Module,type=IdentityServiceController"),
mbeanServer);
+
//Setup the Identity of the user accessing this servlet
- this.setupUser(request, identityService);
+ this.setupUser(request, identityService);
Command getCMD = CMSService.getCommandFactory().createFileGetCommand(path,
version, new Locale(language));
File file = (File)CMSService.execute(getCMD);
@@ -104,43 +103,39 @@
}
/**
- *
+ *
*/
public void doPost(HttpServletRequest request, HttpServletResponse response) throws
IOException
{
doGet(request, response);
}
-
- /**
- *
- * @param identityService
- */
- private void setupUser(HttpServletRequest request,IdentityServiceController
identityService) throws Exception
+
+ /** @param identityService */
+ private void setupUser(HttpServletRequest request, IdentityServiceController
identityService) throws Exception
{
String remoteUser =
(String)request.getSession().getAttribute("remoteUser");
- if(remoteUser != null && remoteUser.trim().length() > 0)
+ if (remoteUser != null && remoteUser.trim().length() > 0)
{
User user = (User)request.getSession().getAttribute("cmsIdentity");
-
- if( user == null ||
- !user.getUserName().equals(remoteUser) //This happens if another user is
now logged in to the same session...rare scenario
- )
+
+ if (user == null ||
+ !user.getUserName().equals(remoteUser) //This happens if another user is now
logged in to the same session...rare scenario
+ )
{
user = this.getUser(remoteUser, identityService);
request.getSession().setAttribute("cmsIdentity", user);
- }
-
+ }
+
JCRCMS.getUserInfo().set(user);
}
}
-
+
/**
- *
* @param identityService
* @return
* @throws Exception
*/
- private User getUser(String remoteUser,IdentityServiceController identityService)
throws Exception
+ private User getUser(String remoteUser, IdentityServiceController identityService)
throws Exception
{
User user = null;
SessionFactory identitySessionFactory = (SessionFactory)new
InitialContext().lookup("java:/portal/IdentitySessionFactory");
@@ -150,15 +145,15 @@
try
{
UserModule userModule = (UserModule)
-
identityService.getIdentityContext().getObject(IdentityContext.TYPE_USER_MODULE);
- user = userModule.findUserByUserName(remoteUser);
+
identityService.getIdentityContext().getObject(IdentityContext.TYPE_USER_MODULE);
+ user = userModule.findUserByUserName(remoteUser);
success = true;
}
finally
{
- if(transaction != null)
+ if (transaction != null)
{
- if(success)
+ if (success)
{
transaction.commit();
}
@@ -167,8 +162,8 @@
transaction.rollback();
}
}
-
- if(session != null)
+
+ if (session != null)
{
session.close();
}
Show replies by date