roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r263866 - in /incubator/roller/branches/roller_2.0/src/org/roller/presentation: tags/menu/MenuItemImpl.java xmlrpc/MetaWeblogAPIHandler.java
Date Sun, 28 Aug 2005 12:11:02 GMT
Author: snoopdave
Date: Sun Aug 28 05:10:59 2005
New Revision: 263866

URL: http://svn.apache.org/viewcvs?rev=263866&view=rev
Log:
Use forward and mapping to determine if menu item is selected

Modified:
    incubator/roller/branches/roller_2.0/src/org/roller/presentation/tags/menu/MenuItemImpl.java
    incubator/roller/branches/roller_2.0/src/org/roller/presentation/xmlrpc/MetaWeblogAPIHandler.java

Modified: incubator/roller/branches/roller_2.0/src/org/roller/presentation/tags/menu/MenuItemImpl.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/presentation/tags/menu/MenuItemImpl.java?rev=263866&r1=263865&r2=263866&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/presentation/tags/menu/MenuItemImpl.java
(original)
+++ incubator/roller/branches/roller_2.0/src/org/roller/presentation/tags/menu/MenuItemImpl.java
Sun Aug 28 05:10:59 2005
@@ -7,6 +7,8 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
 import javax.servlet.jsp.PageContext;
+import org.apache.struts.Globals;
+import org.apache.struts.action.ActionMapping;
 
 import org.apache.struts.config.ForwardConfig;
 import org.apache.struts.config.ModuleConfig;
@@ -87,6 +89,7 @@
 		boolean selected = false;
         HttpSession ses = req.getSession(false);
         
+        // first look for menu state in request params, then attributes
         String itemKey = req.getParameter(RollerMenuModel.MENU_ITEM_KEY );
         if (null == itemKey) 
         {
@@ -97,29 +100,28 @@
         {
             selected = true;
         }
-		else
+		else if (mForward != null) 
 		{
-			// Is this item's forward the one being requested?
+			// next, can we use Struts forward name to find menu state
             ServletContext ctx = RollerContext.getServletContext();     
-			ModuleConfig mConfig = RequestUtils.getModuleConfig(req,ctx);
-			ForwardConfig fConfig = mConfig.findForwardConfig(mForward);						
-			if (fConfig != null)
+			ModuleConfig mConfig = RequestUtils.getModuleConfig(req, ctx);
+			ForwardConfig fconfig = mConfig.findForwardConfig(mForward);
+            ActionMapping amapping = 
+                    (ActionMapping)req.getAttribute(Globals.MAPPING_KEY);            
+			if (fconfig != null && amapping != null)
 			{
-				// Is the forward path in the request's URL?
-				String url = req.getRequestURL().toString();
-                String path = fConfig.getPath();
-                if (path != null)
+                String reqPath = amapping.getPath();
+                String fwdPath = fconfig.getPath();
+                int end = fwdPath.indexOf(".do");
+                fwdPath = (end == -1) ? fwdPath : fwdPath.substring(0, end);
+                if  (fwdPath.equals(reqPath))
                 {
-                    int end = path.indexOf("?");
-                    path = (end == -1) ? path : path.substring(0, end);
-                }				
-				if ( url.indexOf(path) != -1 )
-				{
-					//  Yes it is, so return true - this item is selected
-					selected = true;
-				}				
+                    selected = true;
+                }
 			}
 		}
+        
+        // still not found, look for menu state in session attributes
 		if (ses != null && selected)
 		{
 			ses.setAttribute(mMenuId+"_"+RollerMenuModel.MENU_ITEM_KEY, mName);

Modified: incubator/roller/branches/roller_2.0/src/org/roller/presentation/xmlrpc/MetaWeblogAPIHandler.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/presentation/xmlrpc/MetaWeblogAPIHandler.java?rev=263866&r1=263865&r2=263866&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/presentation/xmlrpc/MetaWeblogAPIHandler.java
(original)
+++ incubator/roller/branches/roller_2.0/src/org/roller/presentation/xmlrpc/MetaWeblogAPIHandler.java
Sun Aug 28 05:10:59 2005
@@ -22,6 +22,7 @@
 import org.roller.model.Roller;
 import org.roller.model.RollerFactory;
 import org.roller.model.WeblogManager;
+import org.roller.pojos.UserData;
 import org.roller.pojos.WeblogCategoryData;
 import org.roller.pojos.WeblogEntryData;
 import org.roller.pojos.WebsiteData;
@@ -208,7 +209,7 @@
         mLogger.info("     UserId: " + userid);
         mLogger.info("    Publish: " + publish);
 
-        WebsiteData website = validate(blogid, userid,password);
+        WebsiteData website = validate(blogid, userid, password);
 
         Hashtable postcontent = struct;
         String description = (String)postcontent.get("description");
@@ -236,7 +237,7 @@
         {
             Roller roller = RollerFactory.getRoller(); 
             WeblogManager weblogMgr = roller.getWeblogManager();
-
+            UserData user = roller.getUserManager().getUser(userid);
             Timestamp current =
                 new Timestamp(System.currentTimeMillis());
 
@@ -246,6 +247,7 @@
             entry.setPubTime(new Timestamp(dateCreated.getTime()));
             entry.setUpdateTime(current);
             entry.setWebsite(website);
+            entry.setCreator(user);
             if (Boolean.valueOf(publish).booleanValue())
             {
                 entry.setStatus(WeblogEntryData.PUBLISHED);



Mime
View raw message