You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by cd...@apache.org on 2007/07/03 20:15:26 UTC
svn commit: r552939 - in /portals/pluto/branches/pluto-1.1.x:
pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/config/impl/
pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/impl/resource/
pluto-portal-driver/ pluto-...
Author: cdoremus
Date: Tue Jul 3 11:15:24 2007
New Revision: 552939
URL: http://svn.apache.org/viewvc?view=rev&rev=552939
Log:
Changes to incorporate Add/Remove Page functionality to Page Administrator Portlet to fix PLUTO-387.
Modified:
portals/pluto/branches/pluto-1.1.x/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/config/impl/DriverConfigurationImpl.java
portals/pluto/branches/pluto-1.1.x/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/impl/resource/RenderConfigServiceImpl.java
portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/pom.xml
portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java
portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfiguration.java
portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/PageAdminPortlet.java
portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/RenderConfig.java
portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/RenderConfigService.java
portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/RenderConfigAdminService.java
portals/pluto/branches/pluto-1.1.x/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/page/help.jsp
portals/pluto/branches/pluto-1.1.x/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/page/view.jsp
Modified: portals/pluto/branches/pluto-1.1.x/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/config/impl/DriverConfigurationImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/config/impl/DriverConfigurationImpl.java?view=diff&rev=552939&r1=552938&r2=552939
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/config/impl/DriverConfigurationImpl.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/config/impl/DriverConfigurationImpl.java Tue Jul 3 11:15:24 2007
@@ -1,9 +1,9 @@
/*
- * 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
+ * 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
@@ -193,6 +193,10 @@
public boolean isWindowStateSupportedByPortlet(String portletId, String windowState)
{
return supportedWindowStateService.isWindowStateSupportedByPortlet(portletId, windowState);
+ }
+
+ public RenderConfigService getRenderConfigService(){
+ return renderService;
}
}
Modified: portals/pluto/branches/pluto-1.1.x/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/impl/resource/RenderConfigServiceImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/impl/resource/RenderConfigServiceImpl.java?view=diff&rev=552939&r1=552938&r2=552939
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/impl/resource/RenderConfigServiceImpl.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/impl/resource/RenderConfigServiceImpl.java Tue Jul 3 11:15:24 2007
@@ -1,9 +1,9 @@
/*
- * 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
+ * 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
@@ -99,5 +99,9 @@
public void addPage(PageConfig pageConfig) {
config.getRenderConfig().addPage(pageConfig);
+ }
+
+ public void removePage(PageConfig pageConfig){
+ config.getRenderConfig().removePage(pageConfig);
}
}
Modified: portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/pom.xml
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/pom.xml?view=diff&rev=552939&r1=552938&r2=552939
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/pom.xml (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/pom.xml Tue Jul 3 11:15:24 2007
@@ -102,6 +102,11 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>${commons-io.version}</version>
+ </dependency>
</dependencies>
<build>
Modified: portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java?view=diff&rev=552939&r1=552938&r2=552939
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java Tue Jul 3 11:15:24 2007
@@ -1,9 +1,9 @@
/*
- * 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
+ * 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
@@ -52,7 +52,7 @@
/** The Portal Driver sServlet Context */
private ServletContext servletContext;
- protected static final String DEFAULT_PAGE_URI =
+ public static final String DEFAULT_PAGE_URI =
"/WEB-INF/themes/pluto-default-theme.jsp";
/** The portlet container to which we will forward all portlet requests. */
Modified: portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfiguration.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfiguration.java?view=diff&rev=552939&r1=552938&r2=552939
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfiguration.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfiguration.java Tue Jul 3 11:15:24 2007
@@ -1,9 +1,9 @@
/*
- * 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
+ * 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
@@ -21,6 +21,7 @@
import javax.servlet.ServletContext;
import org.apache.pluto.driver.services.portal.PageConfig;
+import org.apache.pluto.driver.services.portal.RenderConfigService;
import org.apache.pluto.driver.url.PortalURLParser;
import org.apache.pluto.spi.PortalCallbackService;
import org.apache.pluto.spi.optional.PortletPreferencesService;
@@ -111,4 +112,6 @@
PortletPreferencesService getPortletPreferencesService();
PortalURLParser getPortalUrlParser();
+
+ public RenderConfigService getRenderConfigService();
}
Modified: portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/PageAdminPortlet.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/PageAdminPortlet.java?view=diff&rev=552939&r1=552938&r2=552939
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/PageAdminPortlet.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/PageAdminPortlet.java Tue Jul 3 11:15:24 2007
@@ -16,18 +16,23 @@
*/
package org.apache.pluto.driver.portlets;
+import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.pluto.driver.AttributeKeys;
+import org.apache.pluto.driver.PortalDriverServlet;
import org.apache.pluto.driver.config.DriverConfiguration;
import org.apache.pluto.driver.services.portal.PageConfig;
import org.apache.pluto.driver.services.portal.PortletWindowConfig;
+import org.apache.pluto.driver.services.portal.RenderConfigService;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
+
+import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
@@ -42,15 +47,29 @@
private static final String EDIT_PAGE = JSP_DIR + "edit.jsp";
private static final String HELP_PAGE = JSP_DIR + "help.jsp";
+ private static final String CONFIG_FILE_PATH = "/WEB-INF/pluto-portal-driver-config.xml";
+ /** Token used to search for default page value in config file */
+ private static final String RENDER_CONFIG_SEARCH_TOKEN = "<render-config default=\"";
public void processAction(ActionRequest request, ActionResponse response) {
String command = request.getParameter("command");
- if("Add Portlet".equalsIgnoreCase(command)) {
- doAddPortlet(request);
- }
- else if ("Remove Portlet".equalsIgnoreCase(command)) {
- doRemovePortlet(request);
- }
+ try {
+ if("Add Portlet".equalsIgnoreCase(command)) {
+ doAddPortlet(request);
+ } else if ("Remove Portlet".equalsIgnoreCase(command)) {
+ doRemovePortlet(request);
+ } else if ("Add Page".equalsIgnoreCase(command)) {
+ doAddPage(request);
+ } else if ("Remove Page".equalsIgnoreCase(command)) {
+ doRemovePage(request);
+ }
+ persistPages();
+ } catch (IOException e) {
+ String msg = "Problem persisting configuration changes. Changes will not be persisted.";
+ LOG.error(msg, e);
+ //TODO: send message back to UI
+ }
+ //TODO: send 'success' message back to UI
}
public void doAddPortlet(ActionRequest request) {
@@ -65,7 +84,68 @@
}
+ /**
+ * Adds a page to the portal via the <code>RenderConfigService</code>.
+ *
+ * This does not add portlets to the new page. Do that when the page is created
+ * using the Add Portlet button.
+ *
+ * @param request The action request.
+ */
+ public void doAddPage(ActionRequest request) {
+ String page = request.getParameter("newPage");//newPage text input element
+ //Check if page is null or empty
+ if (page == null || page.equals("")) {
+ LOG.warn("Page parameter is null or empty. Page addition will be ignored.");
+ //TODO: send message back to UI
+ return;
+ }
+ //TODO: add page URI input to form
+ String uri = request.getParameter("pageURI");
+ if (uri == null) {
+ uri = PortalDriverServlet.DEFAULT_PAGE_URI;
+ }
+ DriverConfiguration driverConfig = (DriverConfiguration) getPortletContext()
+ .getAttribute(AttributeKeys.DRIVER_CONFIG);
+ PageConfig pageConfig = new PageConfig();
+ pageConfig.setName(page);
+ pageConfig.setUri(uri);
+
+ RenderConfigService renderConfig = driverConfig.getRenderConfigService();
+ renderConfig.addPage(pageConfig);
+ }
+ /**
+ * Removes a page from the portal ignoring any requests to remove the default page
+ * or the Pluto Admin page.
+ *
+ * The page's portlets are still available, but no longer associated with the deleted page.
+ *
+ * @param request The action request.
+ * @throws IOException If a problem occurs accessing the config file.
+ */
+ public void doRemovePage(ActionRequest request) throws IOException {
+ String page = request.getParameter("page");
+ DriverConfiguration driverConfig = (DriverConfiguration) getPortletContext()
+ .getAttribute(AttributeKeys.DRIVER_CONFIG);
+ //make sure we are not deleting the default page
+ String defaultPage = getDefaultPage();
+ if (page.equalsIgnoreCase(defaultPage)) {
+ LOG.warn("Trying to delete the default page. Page deletion will be ignored.");
+ //TODO: send message back to UI
+ return;
+ }
+ //make sure we are not deleting the Pluto Admin page
+ if (page.equalsIgnoreCase("Pluto Admin")) {
+ LOG.warn("Trying to delete the Pluto Admin page. Page deletion will be ignored.");
+ return;
+ }
+
+ PageConfig pageConfig = getPageConfig(page);
+ RenderConfigService renderConfig = driverConfig.getRenderConfigService();
+ renderConfig.removePage(pageConfig);
+ }
+
public void doRemovePortlet(ActionRequest request) {
String page = request.getParameter("page");
String portletId = request.getParameter("placedPortlets");
@@ -127,6 +207,120 @@
return list;
}
+ /**
+ * Persist page configuration changes to render-config section of pluto-portal-driver-config.xml.
+ *
+ * TODO: Use JAXB for config file parsing and persistence.
+ *
+ * @throws IOException
+ */
+ private void persistPages() throws IOException {
+ //TODO: Null checks??? Substitute empty string or throw an Exception
+ final String NL = System.getProperty("line.separator");
+ DriverConfiguration driverConfig = (DriverConfiguration) getPortletContext()
+ .getAttribute(AttributeKeys.DRIVER_CONFIG);
+ StringBuffer renderConfig = new StringBuffer();
+ //start with render-config element
+ renderConfig.append(" ");//indent
+ renderConfig.append(RENDER_CONFIG_SEARCH_TOKEN);
+ renderConfig.append(getDefaultPage());
+ renderConfig.append("\">");
+ renderConfig.append(NL);
+ Collection pages = getAvailablePages();
+ //iterate through pages
+ for (Iterator iter = pages.iterator(); iter.hasNext();) {
+ Page page = (Page) iter.next();
+ PageConfig config = driverConfig.getPageConfig(page.getName());
+ renderConfig.append(" <page name=\"");
+ String pageName = config.getName();
+ renderConfig.append(pageName);
+ renderConfig.append("\" uri=\"");
+ String uri = config.getUri();
+ renderConfig.append(uri);
+ renderConfig.append("\">");
+ renderConfig.append(NL);
+
+ //iterate through portlets in current page
+ Collection portletIds = config.getPortletIds();
+ for (Iterator iterator = portletIds.iterator(); iterator.hasNext();) {
+ renderConfig.append(" <portlet context=\"");
+ String pid = (String) iterator.next();
+ String pletContext = PortletWindowConfig.parseContextPath(pid);
+ renderConfig.append(pletContext);
+ renderConfig.append("\" name=\"");
+ String pletName = PortletWindowConfig.parsePortletName(pid);
+ renderConfig.append(pletName);
+ renderConfig.append("\"/>");
+ renderConfig.append(NL);
+ }
+ renderConfig.append(" </page>");
+ renderConfig.append(NL);
+ }
+ renderConfig.append(" </render-config>");
+ renderConfig.append(NL);
+ renderConfig.append(NL);
+ renderConfig.append("</pluto-portal-driver>");
+ renderConfig.append(NL);
+ //create new config file content
+ StringBuffer newFileContents = new StringBuffer();
+ newFileContents.append(getContentBeforeRenderConfig(getConfigFileContents()));
+ newFileContents.append(renderConfig);
+ //persist content to new config file
+ FileUtils.writeStringToFile(getConfigFile(), newFileContents.toString());
+ }
+
+ private String getConfigFileContents() throws IOException {
+ return FileUtils.readFileToString(getConfigFile());
+ }
+
+ private File getConfigFile() {
+ String path = getPortletContext().getRealPath(CONFIG_FILE_PATH);
+ return new File(path);
+ }
+
+ /**
+ * Get the page name of the default page from pluto-portal-driver-config.xml.
+ *
+ * @return
+ * @throws IOException
+ */
+ private String getDefaultPage() throws IOException {
+ String configFileContents = getConfigFileContents();
+ return parseDefaultPage(configFileContents);
+ }
+
+ /**
+ * Gets the content of the config page before the render-config element
+ * (also including the default attribute of render-config - see RENDER_CONFIG_SEARCH_TOKEN above).
+ *
+ * @param contents pluto-portal-driver-config.xml file contents.
+ * @return
+ */
+ protected static String getContentBeforeRenderConfig(String contents) {
+ return contents.substring(0, contents.indexOf(RENDER_CONFIG_SEARCH_TOKEN));
+ }
+
+ /**
+ * Parse out default attribute value of render-config element in pluto-portal-driver-config.xml.
+ * This method is protected to allow unit testing (see <code>PageAdminPortletTest.testParseDefaultPage()</code>.)
+ *
+ * @param configFileContents Contents of pluto-portal-driver-config.xml file.
+ * @return The value of the default attribute in the render-config element.
+ */
+ protected static String parseDefaultPage(String configFileContents) {
+ String defPage = null;
+ //length of token used to find default page
+ final int DEF_TOK_LEN = RENDER_CONFIG_SEARCH_TOKEN.length();
+ //index of start of default attribute value
+ int startInd = configFileContents.indexOf(RENDER_CONFIG_SEARCH_TOKEN) + DEF_TOK_LEN;
+ //rest of file after DEFAULT_TOK
+ String restOfConfigFile = configFileContents.substring(startInd);
+ //index of first quote in substring, which indicates end of default attribute value
+ int endInd = restOfConfigFile.indexOf('"');
+ defPage = configFileContents.substring(startInd, startInd + endInd);
+ return defPage;
+ }
+
public class Page {
private String id;
private String name;
Modified: portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/RenderConfig.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/RenderConfig.java?view=diff&rev=552939&r1=552938&r2=552939
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/RenderConfig.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/RenderConfig.java Tue Jul 3 11:15:24 2007
@@ -1,9 +1,9 @@
/*
- * 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
+ * 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
@@ -121,6 +121,10 @@
public void addPage(PageConfig config) {
config.setOrderNumber(orderNumberCounter++);
pages.put(config.getName(), config);
+ }
+
+ public void removePage(PageConfig config){
+ pages.remove(config.getName());
}
}
Modified: portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/RenderConfigService.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/RenderConfigService.java?view=diff&rev=552939&r1=552938&r2=552939
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/RenderConfigService.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/RenderConfigService.java Tue Jul 3 11:15:24 2007
@@ -1,9 +1,9 @@
/*
- * 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
+ * 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
@@ -48,4 +48,8 @@
*/
PageConfig getPage(String id);
+ //added for page admin portlet
+ public void addPage(PageConfig pageConfig);
+ public void removePage(PageConfig pageConfig);
+
}
Modified: portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/RenderConfigAdminService.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/RenderConfigAdminService.java?view=diff&rev=552939&r1=552938&r2=552939
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/RenderConfigAdminService.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/RenderConfigAdminService.java Tue Jul 3 11:15:24 2007
@@ -1,9 +1,9 @@
/*
- * 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
+ * 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
@@ -27,7 +27,10 @@
*/
public interface RenderConfigAdminService {
- void addPage(PageConfig config)
- throws DriverConfigurationException;
+ public void addPage(PageConfig config)
+ throws DriverConfigurationException;
+
+ public void removePage(PageConfig config)
+ throws DriverConfigurationException;
}
Modified: portals/pluto/branches/pluto-1.1.x/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/page/help.jsp
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/page/help.jsp?view=diff&rev=552939&r1=552938&r2=552939
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/page/help.jsp (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/page/help.jsp Tue Jul 3 11:15:24 2007
@@ -23,71 +23,106 @@
<div class="portlet-section-header">Page Adminstrator Portlet Help</div>
<p class="portlet-font">
-The Page Administrator Portlet works with portal pages and portlet applications defined in pluto-portal-driver-config.xml.
-Portlets must be deployed to the app server (Tomcat in the binary distribution). Deployment can be done via Maven, Ant
-or the app server's deployment console (use the 'Upload and deploy portlet war' link on the bottom of the page).
+The Page Administrator Portlet is used to add and remove pages and portlets from portal pages. The portlet
+also persist these changes to pluto-portal-driver-config.xml in pluto's WEB-INF directory.
</p>
-<div class="portlet-section-subheader">Configuring a Portlet Application</div>
+<div class="portlet-section-subheader"><a name="ConfiguringPortletApp">Configuring a Portlet Application</a></div>
<p class="portlet-font">
-The portlet application needs to be registered in pluto-portal-driver-config.xml with a
-proper portlet-app record like this:
+The portlet application needs to be bundled in a war file as per the Java Portlet Specification.
+The war also needs to include proper PortletServlet servlet and servlet-mapping records in WEB-INF/web.xml.
+An assembly process has been developed to add these records to web.xml using Maven 2 (the
+pluto:assemble goal in maven-pluto-plugin) or Ant (AssembleTask).
+See the testsuite web.xml file for an example how the servlet and servlet-mapping
+records should look like after assembly (other items the developer adds to web.xml should be
+carried forward into the updated file).
+</p>
+
+<p class="portlet-font">
+A custom portlet war deployed into the bundled distribution of Pluto also needs a Tomcat context descriptor
+with the same name as the portlet app war name (a.k.a. context name). This context file needs to be
+in the META-INF directory of the war file. Here's an example of one for a portlet bundled for a
+HelloWorldPortlet context (file name is HelloWorldPortlet.xml):
<pre>
-<portlet-app>
- <context-path>/HelloWorldPortlet</context-path>
- <portlets>
- <portlet name="HelloWorldPortlet"/>
- </portlets>
-</portlet-app>
+<Context path="/HelloWorldPortlet"
+ docBase="HelloWorldPortlet" crossContext="true"/>
</pre>
+The crossContext attribute allows Pluto, which is deployed in its own Tomcat context, to work with this custom portlet.
</p>
-<div class="portlet-section-subheader">Configuring a Portal Page</div>
+<div class="portlet-section-subheader">Deploying a Portlet Application</div>
<p class="portlet-font">
-The portal needs to be defined in pluto-portal-driver-config.xml as a page child element of render-config:
-<pre>
-<page name="Hello World Page" uri="/WEB-INF/themes/pluto-default-theme.jsp">
-</page>
-</pre>
+ The way to deploy a portlet application depends on the app server Pluto is running in. In the bundled distribution
+ Pluto is deployed in Tomcat. In this case, you can use the Tomcat manager app to deploy the portlet
+ war. There is a 'Upload and deploy portlet war' link at the bottom of the Page Administrator portlet that points to
+ the manager app in the bundled distribution (this link can be changed for other app servers -- see the
+ adjacent Help link). Use of the manager application requires you to be logged into Pluto in a manager role (pluto or
+ tomcat user).
+</p>
+
+<p class="portlet-font">
+ In the bundled distribution of Pluto, you can also deploy a properly configured portlet application by simply dropping
+ the war file into the webapp directory (see <a href="#ConfiguringPortletApp">Configuring a Portlet Application</a> above).
+ You will need to restart Pluto in order for the Page Administrator Portlet to see the newly deployed portlet so it
+ can be added to a portal page.
+</p>
+
+<div class="portlet-section-subheader">Adding Portal Pages</div>
+<p class="portlet-font">
+Adding a new portal page using the Pluto Page Administrator portlet involves inputing the page name into the text box adjacent
+to the Add Page button and clicking on the button. The new page is created with the default 'theme', which lays out the
+portlets in two columns (see /WEB-INF/themes/pluto-default-theme.jsp in the pluto webapp for details). Once a page
+has been added, portlets will need to be added to the page (see <a href="#AddingPortlets">Adding Portlets to a Portal Page</a>).
</p>
-<div class="portlet-section-subheader">Adding Portlets to a Portal Pages</div>
<p class="portlet-font">
-Adding portlets to a portal page involves first selecting a portal page using the Portal Pages drop-down and then
-selecting a portlet application using the Portlet Applications drop-down. When this is done, click the Add Portlet
-button.
+Please note that adding a new Page with the name of an existing page will replace the existing page with the
+new page. This is equivalent to removing the page and adding it again with the same name.
</p>
<div class="portlet-section-subheader">Removing Portal Pages</div>
<p class="portlet-font">
-Removing portlets from a portal page involves selecting a portal page using the Portal Pages drop-down and then
-clicking on the Remove Page button.
+Removing a portal page using the Pluto Page Administrator portlet involves selecting a page in the drop down above
+the Remove Page button and clicking on the button. You are not allowed to remove the default page
+(default attribute of the render-config element in pluto-portal-driver-config.xml) and the Pluto Admin page.
</p>
+<div class="portlet-section-subheader"><a name="AddingPortlets">Adding Portlets to a Portal Page</a></div>
+<p class="portlet-font">
+Adding portlets to a portal page using the Pluto Page Administrator portlet involves first selecting a portal
+page in the Portal Pages drop-down (above the Remove Page button) and then selecting a portlet application
+using the Portlet Applications drop-down and finally a portlet in the adjacent drop down. When this is done,
+click the Add Portlet button.
+</p>
-<div class="portlet-section-subheader">Manually Updating the Configuration File</div>
+<div class="portlet-section-subheader">Removing Portlets from a Portal Page</div>
<p class="portlet-font">
-The Page Administrator Portlet does not persist any portlet additions or portal page removals to
-the pluto-portal-driver-config.xml file. This must be done manually in the config file. Removal of portlets
-from pages must also be done manually in pluto-portal-driver-config.xml.
+Removing portlets from a portal page involves selecting a portal page on the Portal Pages drop-down
+(above the Remove Page button), selecting the portlet in the adjacent list and then clicking on the
+Remove Portlet button.
</p>
+
+<div class="portlet-section-subheader">Manually Updating the Configuration File</div>
<p class="portlet-font">
-To manually add a portlet to a page in pluto-portal-driver-config.xml, a portlet child element must be added to the
-page element. This element should look like this:
-<pre>
-<portlet context="/HelloWorldPortlet" name="HelloWorldPortlet"/>
-</pre>
+The pluto-portal-driver-config.xml file holds changes made by the Page Administrator Portlet. You can manually
+update this file to add pages or portlets. If this is done, please be careful of the structure of the
+render-config child elements.
</p>
+
<p class="portlet-font">
- The value of the context-path element within the portlet-app record must correspond to the value of the context
- attribute in the portlet element. In addition, the value of the name attribute in the portlet child element of
- portlet-app must correspond to the value of the name attribute of the portlet child element of page.
+You can also change the theme of portlets and the default page -- the portal's
+home page after login -- in this config file. The theme will require a proper URI to a file containing
+the new theme. Use the default theme (/WEB-INF/themes/pluto-default-theme.jsp in the pluto webapp) for
+an example theme elements.
+
+Again, be careful to not modify the XML structure of the
+config file if you choose to change the theme or default
</p>
+
<%-- Properties for link to app server deployer and help mode file --%>
<fmt:bundle basename="AdminPortlet">
- <fmt:message key="appserver.deployer.help.page" var="deployerHelp"/>
<fmt:message key="appserver.deployer.help.page" var="deployerHelp"/>
</fmt:bundle>
<portlet:renderURL portletMode="help" var="deployerhelpURL">
Modified: portals/pluto/branches/pluto-1.1.x/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/page/view.jsp
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/page/view.jsp?view=diff&rev=552939&r1=552938&r2=552939
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/page/view.jsp (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/page/view.jsp Tue Jul 3 11:15:24 2007
@@ -21,6 +21,8 @@
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<%@ taglib uri="http://portals.apache.org/pluto/portlet-el" prefix="portlet-el" %>
+<portlet:defineObjects/>
+
<portlet:actionURL var="formActionUrl"/>
<form name="adminForm" action="<c:out value="${formActionUrl}"/>" method="POST">
<script type="text/javascript">
@@ -32,41 +34,45 @@
<h2>Portal Pages</h2>
<p>
<script type="text/javascript">
- var placedPortlets = new Array();
+ var <portlet:namespace/>placedPortlets = new Array();
<c:forEach items="${availablePages}" var="page">
- placedPortlets['<c:out value="${page.id}"/>'] = new Array();
+ <portlet:namespace/>placedPortlets['<c:out value="${page.id}"/>'] = new Array();
<c:forEach items="${page.portlets}" var="portlet" varStatus="loopStatus">
- placedPortlets['<c:out value="${page.id}"/>'][<c:out value="${loopStatus.index}"/>] = new Array();
- placedPortlets['<c:out value="${page.id}"/>'][<c:out value="${loopStatus.index}"/>][0] = '<c:out value="${portlet.id}"/>';
- placedPortlets['<c:out value="${page.id}"/>'][<c:out value="${loopStatus.index}"/>][1] = '<c:out value="${portlet.portletName}"/>';
+ <portlet:namespace/>placedPortlets['<c:out value="${page.id}"/>'][<c:out value="${loopStatus.index}"/>] = new Array();
+ <portlet:namespace/>placedPortlets['<c:out value="${page.id}"/>'][<c:out value="${loopStatus.index}"/>][0] = '<c:out value="${portlet.id}"/>';
+ <portlet:namespace/>placedPortlets['<c:out value="${page.id}"/>'][<c:out value="${loopStatus.index}"/>][1] = '<c:out value="${portlet.portletName}"/>';
</c:forEach>
</c:forEach>
- function doSwitchPage(select) {
+ function <portlet:namespace/>doSwitchPage(select) {
var placePortletsSelect = document.forms['adminForm'].elements['placedPortlets'];
- for(var i=0;i<placePortletsSelect.options.length;i++) {
+ for(var i=0; i < placePortletsSelect.options.length;i++) {
placePortletsSelect.options[i] = null;
}
var disabled = select.value == 'Select. . .'
- document.forms['adminForm'].elements['command'][0].disabled = disabled;
+ //disable 'Remove Page' button
+ document.forms['adminForm'].elements['command'][1].disabled = disabled;
+ //disable 'Remove Portlet' button
+ document.forms['adminForm'].elements['command'][2].disabled = disabled;
if(disabled) {
return;
}
- for(var i=0;i<placedPortlets[select.value].length;i++) {
- placePortletsSelect[i] = new Option(placedPortlets[select.value][i][1], placedPortlets[select.value][i][0]);
+ for(var i=0; i < <portlet:namespace/>placedPortlets[select.value].length;i++) {
+ placePortletsSelect[i] = new Option(<portlet:namespace/>placedPortlets[select.value][i][1], <portlet:namespace/>placedPortlets[select.value][i][0]);
}
}
</script>
+ <p>
+ <input type="text" name="newPage"></input>
+ <input id="addPageButton" type="submit" name="command" value="Add Page"></input>
+ </p>
-
-
-
- <select name="page" onChange="doSwitchPage(this)">
+ <select name="page" onChange="<portlet:namespace/>doSwitchPage(this)">
<option value="Select. . .">Select. . .</option>
<c:forEach items="${driverConfig.pages}" var="page">
<option value="<c:out value="${page.name}"/>"><c:out value="${page.name}"/></option>
@@ -77,6 +83,7 @@
</select>
<p>
+ <input id="removePageButton" type="submit" name="command" disabled="true" value="Remove Page"></input>
<input id="removeButton" type="submit" name="command" disabled="true" value="Remove Portlet"></input>
</p>
</p>
@@ -85,48 +92,48 @@
<div>
<h2>Portlet Applications</h2>
<p>
- <!-- TODO: Should be namespaced! -->
<script type="text/javascript">
- var portlets = new Array();
+ var <portlet:namespace/>portlets = new Array();
<c:forEach items="${portletContainer.optionalContainerServices.portletRegistryService.registeredPortletApplications}" var="app">
- portlets['<c:out value="${app.applicationId}"/>'] = new Array();
- portlets['<c:out value="${app.applicationId}"/>'][0] = 'Select. . .';
+ <portlet:namespace/>portlets['<c:out value="${app.applicationId}"/>'] = new Array();
+ <portlet:namespace/>portlets['<c:out value="${app.applicationId}"/>'][0] = 'Select. . .';
<c:forEach items="${app.portletApplicationDefinition.portlets}" var="portlet" varStatus="loopStatus">
- portlets['<c:out value="${app.applicationId}"/>'][<c:out value="${loopStatus.index + 1}"/>] = '<c:out value="${portlet.portletName}"/>';
+ <portlet:namespace/>portlets['<c:out value="${app.applicationId}"/>'][<c:out value="${loopStatus.index + 1}"/>] = '<c:out value="${portlet.portletName}"/>';
</c:forEach>
</c:forEach>
- function doSwitch(select) {
+ function <portlet:namespace/>doSwitch(select) {
var portletsSelectBox = document.forms['adminForm'].elements['availablePortlets'];
- for(i = 0; i< portletsSelectBox.options.length;i++) {
+ for(var i = 0; i < portletsSelectBox.options.length;i++) {
portletsSelectBox.options[i] = null;
}
if (select.value == '-') {
document.forms['adminForm'].elements['availablePortlets'].disabled = true;
} else {
portletsSelectBox.disabled = false;
- var pList = portlets[select.value];
+ var pList = <portlet:namespace/>portlets[select.value];
for (i = 0; i < pList.length; i++) {
portletsSelectBox.options[i] = new Option(pList[i], pList[i]);
}
}
- doSwitchButton(portletsSelectBox);
+ <portlet:namespace/>doSwitchButton(portletsSelectBox);
}
- function doSwitchButton(select) {
- document.forms['adminForm'].elements['command'][1].disabled = (select.value == 'Select. . .' || select.disabled);
+ function <portlet:namespace/>doSwitchButton(select) {
+ //disable 'Add Portlet' button
+ document.forms['adminForm'].elements['command'][3].disabled = (select.value == 'Select. . .' || select.disabled);
}
</script>
- <select name="applications" onChange="doSwitch(this)">
+ <select name="applications" onChange="<portlet:namespace/>doSwitch(this)">
<option value='-'>Select. . .</option>
<c:forEach items="${portletContainer.optionalContainerServices.portletRegistryService.registeredPortletApplications}" var="app">
<option value="<c:out value="${app.applicationId}"/>"><c:out value="${app.applicationName}"/></option>
</c:forEach>
</select>
- <select name="availablePortlets" disabled="true" onChange='doSwitchButton(this)'>
+ <select name="availablePortlets" disabled="true" onChange='<portlet:namespace/>doSwitchButton(this)'>
</select>