Author: woonsan
Date: Wed Mar 31 14:48:29 2010
New Revision: 929556
URL: http://svn.apache.org/viewvc?rev=929556&view=rev
Log:
JS2-1102: When adding node (folder | page | link) in the page navigator, it is
now created under the current selected folder of the space.
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/webapp/WEB-INF/view/spaces/page-navigator.jsp
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=929556&r1=929555&r2=929556&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
Wed Mar 31 14:48:29 2010
@@ -40,6 +40,7 @@ import org.apache.jetspeed.PortalReserve
import org.apache.jetspeed.administration.PortalAdministration;
import org.apache.jetspeed.container.url.BasePortalURL;
import org.apache.jetspeed.om.folder.Folder;
+import org.apache.jetspeed.om.page.ContentPage;
import org.apache.jetspeed.om.page.Link;
import org.apache.jetspeed.om.page.Page;
import org.apache.jetspeed.page.PageManager;
@@ -216,17 +217,29 @@ public class PageNavigator extends Gener
}
}
- String spacePath = space.getPath();
-
try
{
RequestContext requestContext = (RequestContext)
actionRequest.getAttribute(RequestContext.REQUEST_PORTALENV);
+ ContentPage contentPage = requestContext.getPage();
+ String spacePath = space.getPath();
+ String contentPagePath = contentPage.getPath();
+ String contentFolderPath =
StringUtils.defaultIfEmpty(StringUtils.substringBeforeLast(contentPagePath,
"/"), "/");
String nodeName = name.replace(' ', '_');
+ String nodePath = null;
+
+ if (contentFolderPath.startsWith(spacePath))
+ {
+ nodePath = StringUtils.removeEnd(contentFolderPath, "/") + "/"
+ StringUtils.removeStart(nodeName, "/");
+ }
+ else
+ {
+ nodePath = StringUtils.removeEnd(spacePath, "/") + "/" +
StringUtils.removeStart(nodeName, "/");
+ }
if (Page.DOCUMENT_TYPE.equals(type))
{
- String path = StringUtils.removeEnd(spacePath, "/") + "/" +
StringUtils.removeStart(nodeName, "/") + Page.DOCUMENT_TYPE;
+ String path = nodePath + Page.DOCUMENT_TYPE;
Page source = pageManager.getPage(templatePage);
Page newPage = pageManager.copyPage(source, path, false);
newPage.setTitle(name);
@@ -239,7 +252,7 @@ public class PageNavigator extends Gener
}
else if (Folder.FOLDER_TYPE.equals(type))
{
- String path = StringUtils.removeEnd(spacePath, "/") + "/" +
StringUtils.removeStart(nodeName, "/");
+ String path = nodePath;
Folder folder = pageManager.newFolder(path);
folder.setTitle(name);
pageManager.updateFolder(folder);
@@ -253,7 +266,7 @@ public class PageNavigator extends Gener
}
else if (Link.DOCUMENT_TYPE.equals(type))
{
- String path = StringUtils.removeEnd(spacePath, "/") + "/" +
StringUtils.removeStart(nodeName, "/") + Link.DOCUMENT_TYPE;
+ String path = nodePath + Link.DOCUMENT_TYPE;
Link link = pageManager.newLink(path);
link.setTitle(name);
pageManager.updateLink(link);
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=929556&r1=929555&r2=929556&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
Wed Mar 31 14:48:29 2010
@@ -109,10 +109,6 @@ RequestContext rc = (RequestContext) req
PortalSiteRequestContext psrc = (PortalSiteRequestContext)
rc.getAttribute("org.apache.jetspeed.portalsite.PortalSiteRequestContext");
String contextPath = rc.getRequest().getContextPath();
String basePath = rc.getPortalURL().getBasePath();
-String portalPagePath = rc.getPortalURL().getPath();
-if (portalPagePath == null || "".equals(portalPagePath)) {
- portalPagePath = "/";
-}
SpaceBean space = (SpaceBean) renderRequest.getAttribute("space");
Locale locale = renderRequest.getLocale();
PageNavigator pageNavigator = (PageNavigator)
renderRequest.getAttribute("PageNavigator");
@@ -169,7 +165,7 @@ for (MenuElement element : linkElements)
<option value="${nodeType}"><fmt:message
key="spaces.pages.label.nodeType.${nodeType}"/></option>
</c:forEach>
</select>
- <input type="text" name="name" class="portlet-form-input-field"
size="8" value="" ><input type="submit" value="<fmt:message
key='spaces.pages.label.add'/>" />
+ <input type="text" name="name" class="portlet-form-input-field"
size="8" value=""/><input type="submit" value="<fmt:message
key='spaces.pages.label.add'/>" />
</td>
</tr>
<tr>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]