Update of 
/var/cvs/contributions/CMSContainer_Portlets/portlets-login/src/java/com/finalist/cmsc/portlets
In directory 
james.mmbase.org:/tmp/cvs-serv6811/portlets-login/src/java/com/finalist/cmsc/portlets

Modified Files:
      Tag: b1_5
        AbstractLoginPortlet.java 
Log Message:
CMSC-1320 - LoginPortlet improvements.


See also: 
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer_Portlets/portlets-login/src/java/com/finalist/cmsc/portlets
See also: http://www.mmbase.org/jira/browse/CMSC-1320


Index: AbstractLoginPortlet.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Portlets/portlets-login/src/java/com/finalist/cmsc/portlets/AbstractLoginPortlet.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -b -r1.1.2.3 -r1.1.2.4
--- AbstractLoginPortlet.java   5 Mar 2009 11:17:36 -0000       1.1.2.3
+++ AbstractLoginPortlet.java   6 Mar 2009 09:28:39 -0000       1.1.2.4
@@ -33,13 +33,14 @@
 import com.finalist.cmsc.util.HttpUtil;
 
 public abstract class AbstractLoginPortlet extends CmscPortlet{
+   
    protected String DEFAULT_EMAIL_CONFIRM_TEMPLATE_DIR = 
"../templates/view/login/confirmation.txt";
    protected static final String EMAIL_SUBJECT = "emailSubject";
    protected static final String EMAIL_TEXT = "emailText";
    protected static final String EMAIL_FROMEMAIL = "emailFromEmail";
    protected static final String EMAIL_FROMNAME = "emailFromName";
    
-   protected static final String DEFAULT_EMAILREGEX = 
"^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$";
+   public static final String DEFAULT_EMAILREGEX = 
"^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$";
 
    
    private static final Log log = 
LogFactory.getLog(AbstractLoginPortlet.class);
@@ -68,11 +69,15 @@
 
       super.processEditDefaults(request, response);
    }
+   
    protected String getEmailBody(String emailText,ActionRequest request,
          Authentication authentication, Person person) {
+
       Cloud cloud = getCloudForAnonymousUpdate(false);
       String pageId = request.getParameter("page");
-      String url = getConfirmationLink(cloud,pageId);
+
+      if (cloud.hasNode(pageId)) {
+         String url = getConfirmationLink(cloud, Integer.parseInt(pageId));
       String confirmUrl = HttpUtil.getWebappUri((HttpServletRequest) request)
             + "login/confirm.do?s=" + authentication.getId() + url;
       
@@ -80,6 +85,8 @@
             .getUserId(), authentication.getPassword(), person.getFirstName(),
             person.getInfix(), person.getLastName(), confirmUrl);
    }
+      return null;
+   }
    
    protected Cloud getCloudForAnonymousUpdate(boolean isRemote) {
       Cloud cloud = CloudProviderFactory.getCloudProvider().getCloud();
@@ -89,7 +96,7 @@
       return cloud;
    }
 
-   protected String getConfirmationLink(Cloud cloud,String pageId) {
+   protected String getConfirmationLink(Cloud cloud, int pageNode) {
       String link = null;
       NodeList portletDefinations = SearchUtil.findNodeList(cloud,
             "portletdefinition", "definition", this.getPortletName());
@@ -102,7 +109,12 @@
             "definitionrel", SearchUtil.SOURCE);
       Node portlet = null;
       Relation relation = null;
-      Node page = cloud.getNode(Integer.parseInt(pageId));
+      Node page = cloud.getNode(pageNode);
+      
+      if (page == null) {
+         return null;
+      }
+      
       NodeList nodeList = page.getRelatedNodes("portlet", "portletrel", 
SearchUtil.DESTINATION);
       for (int i =0 ; i < nodeList.size() ; i++) {
          for (int j = 0 ; j < portlets.size() ; j++) {
@@ -111,8 +123,8 @@
             }
          }
       }
-      relation = 
RelationUtil.getRelation(cloud.getRelationManager("portletrel"), 
page.getNumber(), portlet.getNumber());
 
+      relation = 
RelationUtil.getRelation(cloud.getRelationManager("portletrel"), 
page.getNumber(), portlet.getNumber());
       link = "&pn=" + page.getNumber();  
       if (relation != null) {
          String name = relation.getStringValue("name");
@@ -127,19 +139,23 @@
    protected String getConfirmationTemplate() {
       InputStream is = Thread.currentThread().getContextClassLoader()
             .getResourceAsStream(DEFAULT_EMAIL_CONFIRM_TEMPLATE_DIR);
+
       if (is == null) {
          throw new NullPointerException(
                "The confirmation template file confirmation.txt in directory 
'templates/view/login' does't exist.");
       }
+      
       BufferedReader reader = new BufferedReader(new InputStreamReader(is));
       StringBuilder sb = new StringBuilder();
-      String strLine;
+      
       try {
+         String strLine;
          while ((strLine = reader.readLine()) != null) {
             sb.append(strLine + "\n");
          }
+         is.close();
       } catch (IOException e) {
-         log.error("error happen when reading email template", e);
+         log.error("error happened when reading email template", e);
       }
       
       return sb.toString();
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to