Update of 
/var/cvs/contributions/CMSContainer_Portlets/portlets-newsletter/src/java/com/finalist/newsletter/services
In directory 
james.mmbase.org:/tmp/cvs-serv4327/portlets-newsletter/src/java/com/finalist/newsletter/services

Modified Files:
        CommunityModuleAdapter.java 
Log Message:
function is moved to com.finalist.cmsc.newsletter.services.CommunityModuleAdapte


See also: 
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer_Portlets/portlets-newsletter/src/java/com/finalist/newsletter/services


Index: CommunityModuleAdapter.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Portlets/portlets-newsletter/src/java/com/finalist/newsletter/services/CommunityModuleAdapter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- CommunityModuleAdapter.java 22 Apr 2008 10:45:31 -0000      1.1
+++ CommunityModuleAdapter.java 22 Apr 2008 16:27:16 -0000      1.2
@@ -1,37 +1,46 @@
 package com.finalist.newsletter.services;
 //
-//import com.finalist.cmsc.services.community.person.Person;
-//import com.finalist.cmsc.services.community.person.PersonService;
-//import org.acegisecurity.context.SecurityContextHolder;
-//import org.acegisecurity.userdetails.UserDetails;
-//import org.springframework.web.context.WebApplicationContext;
-//import org.springframework.web.context.support.WebApplicationContextUtils;
+
+import com.finalist.cmsc.services.community.person.Person;
+import com.finalist.cmsc.services.community.person.PersonService;
+import org.acegisecurity.context.SecurityContextHolder;
+import org.acegisecurity.context.SecurityContext;
+import org.acegisecurity.userdetails.UserDetails;
+import org.acegisecurity.Authentication;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
 
 import javax.servlet.ServletContext;
 
 public class CommunityModuleAdapter {
    /**
-    * @param servletContext use 
RequestContextUtils.getWebApplicationContext(ServletRequest request) to get a 
WebApplicationContext
+    * @param servletContext get servletContext:
+    *In portlet : ((PortletContextImpl) 
this.getPortletContext()).getServletContext()
     * @return get current Person.
     */
-//   public static Person getCurrentUserId(ServletContext servletContext) {
-//
-//      WebApplicationContext ctx = 
WebApplicationContextUtils.getWebApplicationContext(servletContext);
-//
-//      Object obj = 
SecurityContextHolder.getContext().getAuthentication().getPrincipal();
-//
-//      Person person = null;
-//
-//      if (obj instanceof UserDetails) {
-//         String username = ((UserDetails) obj).getUsername();
-//         PersonService personService = (PersonService) 
ctx.getBean("personService");
-//         person = personService.getPersonByUserId(username);
-//
-//         System.out.println("000000000000" + username);
-//      }
-//
-//      return person;
-//
-//   }
+   public static Person getCurrentUser(ServletContext servletContext) {
+
+      WebApplicationContext ctx = 
WebApplicationContextUtils.getWebApplicationContext(servletContext);
+
+      SecurityContext securityContext = SecurityContextHolder.getContext();
+      Authentication authentication = securityContext.getAuthentication();
+
+      Person person = null;
+
+      if (null == authentication) {
+         Object obj = authentication.getPrincipal();
+         if (obj instanceof UserDetails) {
+            String username = ((UserDetails) obj).getUsername();
+            PersonService personService = (PersonService) 
ctx.getBean("personService");
+            person = personService.getPersonByUserId(username);
+
+            System.out.println("000000000000" + username);
+         }
+      }
+
+
+      return person;
+
+   }
 
 }
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to