portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r906919 - in /portals/jetspeed-2/applications/j2-admin/trunk/src/main: java/org/apache/jetspeed/portlets/spaces/ resources/org/apache/jetspeed/portlets/spaces/resources/ webapp/WEB-INF/ webapp/WEB-INF/view/spaces/
Date Fri, 05 Feb 2010 12:34:27 GMT
Author: woonsan
Date: Fri Feb  5 12:34:25 2010
New Revision: 906919

URL: http://svn.apache.org/viewvc?rev=906919&view=rev
Log:
JS2-1057: Adding template selection when adding a page.

Added:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/NodeBean.java
  (with props)
Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/PageNavigator.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/SpaceBean.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/spaces/resources/SpacesResources.properties
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/spaces/page-navigator.jsp

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/NodeBean.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/NodeBean.java?rev=906919&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/NodeBean.java
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/NodeBean.java
Fri Feb  5 12:34:25 2010
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.portlets.spaces;
+
+import java.io.Serializable;
+
+import org.apache.jetspeed.page.document.Node;
+
+public class NodeBean implements Serializable 
+{
+	private static final long serialVersionUID = 1L;
+
+	private String name;
+	private String path;
+	private String title;
+	
+	public NodeBean()
+	{
+	}
+
+	public NodeBean(Node node)
+	{
+		setName(node.getName());
+    	setPath(node.getPath());
+    	setTitle(node.getTitle());
+	}
+	
+	public String getName() 
+	{
+		return name;
+	}
+	
+	public void setName(String name) 
+	{
+		this.name = name;
+	}
+	
+	public String getPath() 
+	{
+		return path;
+	}
+	
+	public void setPath(String path) 
+	{
+		this.path = path;
+	}
+	
+	public String getTitle() 
+	{
+		return title;
+	}
+	
+	public void setTitle(String title) 
+	{
+		this.title = title;
+	}
+	
+}

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/NodeBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/NodeBean.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/NodeBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/PageNavigator.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/PageNavigator.java?rev=906919&r1=906918&r2=906919&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/PageNavigator.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/PageNavigator.java
Fri Feb  5 12:34:25 2010
@@ -66,7 +66,7 @@
     public static final String DEFAULT_LINKS_MENU = "links";
     public static final String DEFAULT_SPACE_NAVS_MENU = "space-navigations";
     public static final String DEFAULT_SPACE_LINKS_MENU = "space-links";
-    public static final String DEFAULT_NEW_TEMPLATE_PAGE_PATH = "/_template/new-user/min.psml";
+    public static final String DEFAULT_TEMPLATE_PAGE = "/_template/new-user/min.psml";
     
     private static Logger log = LoggerFactory.getLogger(PageNavigator.class);
     
@@ -76,7 +76,6 @@
     private BasePortalURL baseUrlAccess = null;
     private String defaultMenu = DEFAULT_SPACE_NAVS_MENU;
     private String defaultLinksMenu = DEFAULT_SPACE_LINKS_MENU;
-    private String newTemplatePagePath = DEFAULT_NEW_TEMPLATE_PAGE_PATH;
     
     protected String yuiScriptPath = "/javascript/yui/build/yui/yui-min.js";
 
@@ -108,19 +107,15 @@
         
         String param = config.getInitParameter("yuiScriptPath");
         
-        if (param != null) {
+        if (param != null) 
+        {
             yuiScriptPath = param;
         }
-        
-        param = config.getInitParameter("newTemplatePagePath");
-        
-        if (param != null) {
-            newTemplatePagePath = param;
-        }
     }
     
     @Override
-    protected void doHeaders(RenderRequest request, RenderResponse response) {
+    protected void doHeaders(RenderRequest request, RenderResponse response) 
+    {
         super.doHeaders(request, response);
         RequestContext rc = (RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV);
         Element headElem = response.createElement("script");
@@ -149,14 +144,25 @@
         request.setAttribute(SpaceNavigator.ATTRIBUTE_SPACES, scc.getSpaces());        
         request.setAttribute(SpacesManager.MSG_TOPIC_PAGE_NAV, this);        
         request.setAttribute("spaceMenuElements", getSpaceMenuElements(scc.getSpace(), request));
-        request.setAttribute("spaceLinkElements", getSpaceLinkMenuElements(scc.getSpace(),
request));        
+        request.setAttribute("spaceLinkElements", getSpaceLinkMenuElements(scc.getSpace(),
request));
+        request.setAttribute("templatePages", getTemplatePageNodes(request));
         super.doView(request, response);
     }
     
-    public void processAction(ActionRequest actionRequest, ActionResponse actionResponse)
throws PortletException,
-    IOException
+    public void processAction(ActionRequest actionRequest, ActionResponse actionResponse)
throws PortletException, IOException
     {
         String addPage = actionRequest.getParameter("addPage");
+        String templatePage = StringUtils.defaultString(actionRequest.getParameter("templatePage"),
null);
+        
+        if (StringUtils.isBlank(templatePage))
+        {
+            templatePage = actionRequest.getPreferences().getValue("defaultTemplatePage",
null);
+            
+            if (StringUtils.isBlank(templatePage))
+            {
+                throw new PortletException("Invalid template page: " + templatePage);
+            }
+        }
         
         if (addPage != null)
         {
@@ -167,16 +173,16 @@
                 String spacePath = space.getPath();
                 try
                 {
-                    String pageName = addPage.replace(' ', '_');                
-                    String path = spacePath + "/" + pageName + ".psml";                 
  
-                    Page source = pageManager.getPage(newTemplatePagePath);             
  
+                    String pageName = addPage.replace(' ', '_');
+                    String path = spacePath + "/" + pageName + ".psml";
+                    Page source = pageManager.getPage(templatePage);
                     Page newPage = pageManager.copyPage(source, path);
                     newPage.setTitle(addPage);
-                    pageManager.updatePage(newPage);                    
+                    pageManager.updatePage(newPage);
                     actionRequest.getPortletSession().removeAttribute("pages");
                     actionRequest.getPortletSession().removeAttribute("links");
                     String redirect = admin.getPortalURL(actionRequest, actionResponse, path);
-                    actionResponse.sendRedirect(redirect);                              
         
+                    actionResponse.sendRedirect(redirect);
                 }
                 catch (Exception e)
                 {
@@ -354,4 +360,35 @@
         
         return spaceLinkMenuElements;
     }
+    
+    private List<NodeBean> getTemplatePageNodes(PortletRequest request)
+    {
+        List<NodeBean> pageNodes = new ArrayList<NodeBean>();
+        
+        String templatePages = request.getPreferences().getValue("templatePages", null);
+        
+        if (!StringUtils.isBlank(templatePages))
+        {
+            String [] templatePagePaths = StringUtils.split(templatePages, ", \t\r\n");
+            
+            for (String templatePagePath : templatePagePaths)
+            {
+                try
+                {
+                    Page templatePage = pageManager.getPage(templatePagePath);
+                    pageNodes.add(new NodeBean(templatePage));
+                }
+                catch (SecurityException e)
+                {
+                    // ignore security exception when retrieving template pages.
+                }
+                catch (Exception e)
+                {
+                    log.warn("Invalid template page path: " + templatePagePath + ". {}",
e.toString());
+                }
+            }
+        }
+        
+        return pageNodes;
+    }
 }
\ No newline at end of file

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/SpaceBean.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/SpaceBean.java?rev=906919&r1=906918&r2=906919&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/SpaceBean.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/SpaceBean.java
Fri Feb  5 12:34:25 2010
@@ -16,32 +16,34 @@
  */
 package org.apache.jetspeed.portlets.spaces;
 
-import java.io.Serializable;
-
 import org.apache.jetspeed.spaces.Space;
 
-public class SpaceBean implements Serializable 
+public class SpaceBean extends NodeBean
 {
+    
 	private static final long serialVersionUID = 1L;
 
-	private String name;
-	private String path;
 	private String owner;
-	private String title;
 	private String description;
 	private String theme;
 	private String constraint;
 	private boolean persisted = false;
 	
+    public SpaceBean()
+    {
+        super();
+    }
+    
 	public SpaceBean(String name, String owner)
 	{
-		this.name = name;
+	    super();
+	    setName(name);
 		this.owner = owner;
-		this.path = "";
 	}
-
+	
 	public SpaceBean(Space s)
 	{
+        super();
 		setName(s.getName());
     	setPath(s.getPath());
     	setOwner(s.getOwner());
@@ -57,46 +59,44 @@
 		return persisted;
 	}
 	
-	public String getName() {
-		return name;
-	}
-	public void setName(String name) {
-		this.name = name;
-	}
-	public String getPath() {
-		return path;
-	}
-	public void setPath(String path) {
-		this.path = path;
-	}
-	public String getOwner() {
+	public String getOwner() 
+	{
 		return owner;
 	}
-	public void setOwner(String owner) {
+	
+	public void setOwner(String owner) 
+	{
 		this.owner = owner;
 	}
-	public String getTitle() {
-		return title;
-	}
-	public void setTitle(String title) {
-		this.title = title;
-	}
-	public String getDescription() {
+	
+	public String getDescription() 
+	{
 		return description;
 	}
-	public void setDescription(String description) {
+	
+	public void setDescription(String description) 
+	{
 		this.description = description;
 	}
-	public String getTheme() {
+	
+	public String getTheme() 
+	{
 		return theme;
 	}
-	public void setTheme(String theme) {
+	
+	public void setTheme(String theme) 
+	{
 		this.theme = theme;
 	}
-	public String getSecurityConstraint() {
+	
+	public String getSecurityConstraint() 
+	{
 		return constraint;
 	}
-	public void setSecurityConstraint(String constraint) {
+	
+	public void setSecurityConstraint(String constraint) 
+	{
 		this.constraint = constraint;
-	}	
+	}
+	
 }

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/spaces/resources/SpacesResources.properties
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/spaces/resources/SpacesResources.properties?rev=906919&r1=906918&r2=906919&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/spaces/resources/SpacesResources.properties
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/spaces/resources/SpacesResources.properties
Fri Feb  5 12:34:25 2010
@@ -31,3 +31,5 @@
 spaces.label.update = Update Space
 
 spaces.pages.label.add = Add Page
+spaces.pages.label.space.title = {0} Space
+spaces.pages.label.template = Template

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml?rev=906919&r1=906918&r2=906919&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml (original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml Fri
Feb  5 12:34:25 2010
@@ -2279,6 +2279,21 @@
       <short-title>PageNavigator</short-title>
       <keywords>admin,spaces,space,navigator,pages,nav</keywords>           
            
     </portlet-info>
+    <portlet-preferences>
+      <preference>
+        <name>defaultTemplatePage</name>
+        <value>
+          /_template/new-user/min.psml
+        </value>
+      </preference>
+      <preference>
+        <name>templatePages</name>
+        <value>
+          /_template/new-user/min.psml
+          /_template/new-user/default-page.psml
+        </value>
+      </preference>
+    </portlet-preferences>
   </portlet>
 
    <portlet id="SpacesList">

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/spaces/page-navigator.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/spaces/page-navigator.jsp?rev=906919&r1=906918&r2=906919&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/spaces/page-navigator.jsp
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/spaces/page-navigator.jsp
Fri Feb  5 12:34:25 2010
@@ -115,9 +115,10 @@
 List<MenuElement> linkElements = (List<MenuElement>) renderRequest.getAttribute("spaceLinkElements");
 %>
 
+<form id='jsPages' method="POST" action='<portlet:actionURL/>'>
 <table>
     <tr>
-        <td class="portlet-section-body"><b><%=space.getTitle() %> Space</b></td>
+        <td class="portlet-section-body"><b><fmt:message key="spaces.pages.label.space.title"><fmt:param
value="${space.title}"/></fmt:message></b></td>
     </tr>
     <tr>
         <td class="portlet-section-body">
@@ -163,15 +164,24 @@
 %>
     <tr>
       <td class="portlet-section-subheader">
-        <form id='jsPages' method="POST" action='<portlet:actionURL/>'>
           <input type="text" name="addPage" size="15" value="" ><input type="submit"
value="<fmt:message key='spaces.pages.label.add'/>" />
-        </form>
+      </td>
+    </tr>
+    <tr>
+      <td class="portlet-section-subheader">
+          <fmt:message key="spaces.pages.label.template"/>:
+          <select name="templatePage">
+            <c:forEach items="${templatePages}" var="templatePage">
+              <option value="${templatePage.path}">${templatePage.title}</option>
+            </c:forEach>
+          </select>
       </td>
     </tr>
 <%
 }
 %>
 </table>
+</form>
 
 <script language="javascript">
 YUI().use('jetui-portal', 'io', 'json', 'node', 'cookie', 'overlay', 'anim', 'plugin', function(Y)
{



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message