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 2006/12/03 17:24:01 UTC
svn commit: r481790 - in /portals/pluto/trunk:
pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/
pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/
pluto-portal-driver/src/main/java/org/apache/pluto/drive...
Author: cdoremus
Date: Sun Dec 3 08:24:00 2006
New Revision: 481790
URL: http://svn.apache.org/viewvc?view=rev&rev=481790
Log:
New additions to support PLUTO-215. There needs to be some resolution of the conflicts produced by David's recent additions.
Added:
portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/AdminDeploymentPortlet.java
portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/DeployWarAdminService.java
portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/WarUploadAdminService.java
portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/impl/ReassembleWarAdminServiceImpl.java
portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/impl/Tomcat5DeployWarAdminServiceImpl.java
portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/impl/WarUploadAdminServiceImpl.java
portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/deploy/edit.jsp
portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/deploy/help.jsp
portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/deploy/view.jsp
portals/pluto/trunk/pluto-portal/src/main/webapp/portlet-spec-1.0.css
portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/deploy/HttpDeploymentConfig.java
portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/deploy/Undeployer.java
portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/deploy/http/HttpTomcatDeployer.java
portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/ui/PortletUiMessage.java
portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/ui/PortletUiMessageType.java
Added: portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/AdminDeploymentPortlet.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/AdminDeploymentPortlet.java?view=auto&rev=481790
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/AdminDeploymentPortlet.java (added)
+++ portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/AdminDeploymentPortlet.java Sun Dec 3 08:24:00 2006
@@ -0,0 +1,277 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.pluto.driver.portlets;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletContext;
+import javax.portlet.PortletException;
+import javax.portlet.PortletSession;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pluto.driver.config.AdminConfiguration;
+import org.apache.pluto.driver.config.DriverConfiguration;
+import org.apache.pluto.driver.services.portal.admin.DeployWarAdminService;
+import org.apache.pluto.driver.services.portal.admin.PortletRegistryAdminService;
+import org.apache.pluto.driver.services.portal.admin.ReassembleWarAdminService;
+import org.apache.pluto.driver.services.portal.admin.RenderConfigAdminService;
+import org.apache.pluto.driver.services.portal.admin.WarUploadAdminService;
+import org.apache.pluto.driver.AttributeKeys;
+import org.apache.pluto.util.UtilityException;
+import org.apache.pluto.util.deploy.DeploymentException;
+import org.apache.pluto.util.fileupload.FileUploaderException;
+import org.apache.pluto.util.ui.PortletUiMessage;
+import org.apache.pluto.util.ui.PortletUiMessageType;
+
+/**
+ * Administrative portlet used to deploy wars into the Pluto portal driver.
+ *
+ * @author <a href="mailto:cdoremus@apache.org">Craig Doremus</a>
+ */
+public class AdminDeploymentPortlet extends GenericPortlet {
+
+ public static final Log LOG = LogFactory.getLog(AdminDeploymentPortlet.class);
+
+ /**
+ * JSP file used for the view mode
+ */
+ public static final String VIEW_JSP = "/WEB-INF/fragments/admin/deploy/view.jsp";
+ /**
+ * JSP file used for the edit mode
+ */
+ public static final String EDIT_JSP = "/WEB-INF/fragments/admin/deploy/edit.jsp";
+ /**
+ * JSP file used for the help mode
+ */
+ public static final String HELP_JSP = "/WEB-INF/fragments/admin/deploy/help.jsp";
+
+ public static final String ISCONFIGURED_PARAM = "isconfigured";
+ public static final String BUNDLE_ATTR = "bundle";
+ public static final String MAXUPLOAD_SIZE_ATTR = "maxupload_size";
+ public static final String FILEUPLOAD_CMD = "uploadfile";
+ public static final String UPLOAD_PATH_PARAM = "fileupload";
+ /**
+ * Resources held in a properties file.
+ */
+ private ResourceBundle _bundle = null;
+
+ private PortletContext _context = null;
+
+ /**
+ * Service to upload the war file
+ */
+ private WarUploadAdminService _wuService = null;
+ /**
+ * Service to modify the web.xml, reassemble the war with it
+ * and move it into place
+ */
+ private ReassembleWarAdminService _awService = null;
+ /**
+ * Service to create a deployment descriptor and move it into place
+ */
+ private DeployWarAdminService _dwService = null;
+ /**
+ * Holds admin configuration info from Spring config file
+ */
+ private AdminConfiguration _adminConfig = null;
+ /**
+ * Service to get information on the portal driver servlet from Spring
+ * config file
+ */
+ private DriverConfiguration _driverConfig = null;
+
+ private PortletRegistryAdminService _portletRegistry;
+ private RenderConfigAdminService _renderConfig;
+
+ /**
+ *
+ */
+ public void init(PortletConfig config) throws PortletException {
+ super.init(config);
+ //create a PortletContext reference
+ _context = getPortletContext();
+ //create a ResourceBundle reference
+ _bundle = config.getResourceBundle(Locale.getDefault());
+
+
+ //Get admin service implementations
+ //First get the Admin config from the context that contains Spring config info
+ //loaded by the PortalStartupListener
+ //NOTE: This makes use of the shared nature of the Servlet and Portlet context
+ _adminConfig = (AdminConfiguration)_context.getAttribute(AttributeKeys.DRIVER_ADMIN_CONFIG);
+ _wuService = _adminConfig.getWarUploadAdminService();
+ _awService = _adminConfig.getReassembleWarAdminService();
+ _dwService = _adminConfig.getDeployWarAdminService();
+// TODO: Configure registry and render service
+// _renderConfig = _adminConfig.getRenderConfigAdminService();
+
+
+ //TODO:
+// Get handle to DriverConfiguration for hot deployment
+// _driverConfig = (DriverConfiguration)_context.getAttribute(AttributeKeys.DRIVER_CONFIG);
+ //TODO: ??Hot deploy by adding new Portlet to DriverConfiguration
+ //portlet application Collection and new config info in XML file to
+ //PortletApplicationConfiguration object(reread the file?)
+// }
+ }
+
+ public void doView(RenderRequest req, RenderResponse res)
+ throws IOException, PortletException {
+ //add bundle to session for use on JSP pages
+ PortletSession session = req.getPortletSession();
+ try {
+// if (session.getAttribute(BUNDLE_ATTR) == null) {
+// session.setAttribute(BUNDLE_ATTR, _bundle);
+// }
+ res.setContentType("text/html;charset=UTF-8");
+ //get any messages passed from processAction()
+// PortletUiMessage msg = (PortletUiMessage) req.getPortletSession().getAttribute(MSG_PARAM);
+// req.getPortletSession().removeAttribute(MSG_PARAM);
+// LOG.debug("Message in doView(): " + msg);
+// if (msg == null) {
+// //set default blank message
+// msg = new PortletUiMessage("",PortletUiMessageType.INFO);
+// }
+// req.setAttribute(MSG_PARAM, msg);
+ //TODO: pass MAX_FILE_UPLOAD_SIZE_PARAM and UPLOAD_PATH_PARAM to view
+// req.setAttribute(MAX_FILE_UPLOAD_SIZE_PARAM, Long.toString(MAX_FILE_UPLOAD_SIZE));
+// req.setAttribute(UPLOAD_PATH_PARAM, UPLOAD_PATH);
+ } catch (Throwable e) {
+ LOG.error(e);
+ session.setAttribute(AttributeKeys.PORTLET_MSG, new PortletUiMessage(e));
+ }
+ getPortletContext().getRequestDispatcher(VIEW_JSP).include(req, res);
+ }
+
+ public void doEdit(RenderRequest req, RenderResponse res)
+ throws IOException, PortletException {
+ res.setContentType("text/html;charset=UTF-8");
+ PortletSession session = req.getPortletSession();
+ try {
+// validateParams(req);
+ //get any messages passed from processAction()
+ PortletUiMessage msg = (PortletUiMessage) session.getAttribute(AttributeKeys.PORTLET_MSG);
+ session.removeAttribute(AttributeKeys.PORTLET_MSG);
+ if (msg == null) {
+ //set default blank message
+ msg = new PortletUiMessage("",PortletUiMessageType.INFO);
+ }
+ session.setAttribute(AttributeKeys.PORTLET_MSG, msg);
+ } catch (Throwable e) {
+ LOG.error(e);
+ session.setAttribute(AttributeKeys.PORTLET_MSG, new PortletUiMessage(e));
+ }
+ getPortletContext().getRequestDispatcher(EDIT_JSP).include(req, res);
+ }
+
+
+ public void doHelp(RenderRequest req, RenderResponse res)
+ throws IOException, PortletException {
+ res.setContentType("text/html;charset=UTF-8");
+ getPortletContext().getRequestDispatcher(HELP_JSP).include(req, res);
+ }
+
+ public void processAction(ActionRequest req, ActionResponse res)
+ throws IOException, PortletException {
+ PortletSession session = req.getPortletSession();
+ String command = req.getParameter("command");
+ if (command.equalsIgnoreCase("uploadfile")) {
+ //tmpWarPath is path to temp directory where war is uploaded to
+ File tmpWarPath = null;
+ File newWar = null;
+ try {
+ //set max file upload size if present
+ Integer oMaxuploadsize = (Integer)session.getAttribute(MAXUPLOAD_SIZE_ATTR);
+ if (oMaxuploadsize != null) {
+ _wuService.setMaxUploadSize(oMaxuploadsize.intValue());
+ }
+ tmpWarPath = _wuService.uploadWar(req);
+ //Check a flag to see if assembly was NOT requested
+ String isAssemblyNotRequested = req.getParameter("no-assembly");
+ if (isAssemblyNotRequested == null ||
+ (isAssemblyNotRequested != null &&
+ (isAssemblyNotRequested.equalsIgnoreCase("no") ||
+ isAssemblyNotRequested.equalsIgnoreCase("false")))) {
+ newWar = _awService.reassembleWar(tmpWarPath);
+ }
+ /* Deploy: Move reassembled war into place and create deployment descriptor and move it into place */
+ //check parameter to skip configuration if already done
+ boolean isConfigured = false;
+ String strIsConfigured = req.getParameter(ISCONFIGURED_PARAM);
+ if (strIsConfigured != null && (strIsConfigured.equalsIgnoreCase("true") || strIsConfigured.equalsIgnoreCase("yes"))) {
+ isConfigured = true;
+ }
+ _dwService.deployWar(newWar != null ? newWar : tmpWarPath, isConfigured);
+
+
+// String strWarFile = tmpWarPath.getAbsolutePath();
+// String warFile = strWarFile.substring(strWarFile.indexOf(File.separator) + 1);
+// String context = warFile.substring(0, warFile.indexOf('.'));
+
+ //TODO: ???Add parameter to skip publishing in pluto-portal-driver-config.xml
+ //TODO: call registry service to register the war in
+ // pluto-portal-driver-config.xml file by adding a portlet-app element
+ // try {
+ // _portletRegistry.addPortletApplication(context);
+ // } catch (DriverAdministrationException e) {
+ // LOG.error("Problem registering portlet app.", e);
+ // req.setAttribute(MSG_PARAM,
+ // new PortletUiMessage(e.getMessage(), PortletUiMessageType.ERROR));
+ // }
+ //TODO: call render service to add the war in
+ // pluto-portal-driver-config.xml file to render-config section
+ // PageConfig pconfig = new PageConfig();
+ // pconfig.setName(context);
+ // pconfig.setPortletIds(portlets);
+ // pconfig.setUri("/" + context);
+ // _renderConfig.addPage(pconfig);
+
+ session.setAttribute(AttributeKeys.PORTLET_MSG,
+ new PortletUiMessage("Portlet successfully deployed!", PortletUiMessageType.INFO));
+ } catch (FileUploaderException e) {
+ LOG.error("File upload problem", e);
+ //TODO: Check to see if message is in the resource bundle
+ session.setAttribute(AttributeKeys.PORTLET_MSG, new PortletUiMessage(e));
+ } catch (UtilityException e) {
+ LOG.error("Reassembly problem", e);
+ session.setAttribute(AttributeKeys.PORTLET_MSG, new PortletUiMessage(e));
+ } catch (DeploymentException e) {
+ LOG.error("Deployment problem", e);
+ session.setAttribute(AttributeKeys.PORTLET_MSG, new PortletUiMessage(e));
+ } catch (Exception e) {
+ LOG.error("Deployment problem", e);
+ session.setAttribute(AttributeKeys.PORTLET_MSG, new PortletUiMessage(e));
+ }
+
+ } else if (command.equalsIgnoreCase("config")) {
+ //TODO: Actions for edit mode???
+ // 1. Put the max file upload size in the PortletSession
+// _service.doEditAction(req, res);
+ }
+
+ }
+
+}
Added: portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/DeployWarAdminService.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/DeployWarAdminService.java?view=auto&rev=481790
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/DeployWarAdminService.java (added)
+++ portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/DeployWarAdminService.java Sun Dec 3 08:24:00 2006
@@ -0,0 +1,11 @@
+package org.apache.pluto.driver.services.portal.admin;
+
+import java.io.File;
+
+import org.apache.pluto.util.deploy.DeploymentException;
+
+public interface DeployWarAdminService {
+
+ public void deployWar(File war, boolean configure) throws DeploymentException;
+
+}
Added: portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/WarUploadAdminService.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/WarUploadAdminService.java?view=auto&rev=481790
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/WarUploadAdminService.java (added)
+++ portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/WarUploadAdminService.java Sun Dec 3 08:24:00 2006
@@ -0,0 +1,30 @@
+package org.apache.pluto.driver.services.portal.admin;
+
+import java.io.File;
+
+import javax.portlet.ActionRequest;
+
+import org.apache.pluto.util.fileupload.FileUploaderException;
+
+public interface WarUploadAdminService {
+
+ /**
+ * Processes an uploaded file and puts it on the file system in a temporary
+ * directory (<code>AdminPortletConfig.getInstance().getTempUploadDir()</code>.
+ *
+ * @param req ActionRequest
+ * @return The uploaded file name.
+ * @throws AdminPortletException If there is no upload file. This is a RuntimeException that
+ * wraps a FileUploaderException, IOException and any other Exception thrown during the processing
+ * of the uploaded file.
+ */
+ public File uploadWar(ActionRequest req) throws FileUploaderException;
+
+ /**
+ * Change the max upload size via a session variable set in the edit mode or configured using Spring.
+ *
+ * @param maxUploadSize
+ */
+ public void setMaxUploadSize(int maxUploadSize);
+
+}
Added: portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/impl/ReassembleWarAdminServiceImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/impl/ReassembleWarAdminServiceImpl.java?view=auto&rev=481790
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/impl/ReassembleWarAdminServiceImpl.java (added)
+++ portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/impl/ReassembleWarAdminServiceImpl.java Sun Dec 3 08:24:00 2006
@@ -0,0 +1,74 @@
+package org.apache.pluto.driver.services.portal.admin.impl;
+
+import java.io.File;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pluto.driver.services.portal.admin.ReassembleWarAdminService;
+import org.apache.pluto.util.UtilityException;
+import org.apache.pluto.util.assemble.ReassemblerConfig;
+import org.apache.pluto.util.assemble.WarReassembler;
+
+public class ReassembleWarAdminServiceImpl implements ReassembleWarAdminService {
+
+ private static final Log LOG = LogFactory.getLog(ReassembleWarAdminService.class);
+ private WarReassembler reassembler = null;//reassembly utility
+ /**
+ * Base directory to do the unzipping for reassembly
+ */
+ private String unzipBaseDir = System.getProperty("user.home") + "/pluto";
+ /**
+ * Destination directory of the reassembled war
+ */
+ private String destination = System.getProperty("user.home") + "/pluto/war";
+
+ public ReassembleWarAdminServiceImpl() {
+ super();
+ }
+
+ public File reassembleWar(File warFilePath) throws UtilityException {
+ ReassemblerConfig config = new ReassemblerConfig();
+ config.setRootUnassemblyDir(new File(unzipBaseDir));
+ config.setWarFilePath(warFilePath);
+ File dest = new File(destination);
+ if (!dest.exists()) {
+ dest.mkdirs();
+ }
+ config.setWarDestination(dest);
+ return reassembler.reassemble(config);
+ }
+
+ private String getWarBaseName(File warFilePath) {
+ String baseName = null;
+ String name = warFilePath.getName();
+ baseName = name.substring(0, name.lastIndexOf('.'));
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Base file name: " + baseName);
+ }
+ return baseName;
+ }
+ public WarReassembler getReassembler() {
+ return reassembler;
+ }
+
+ public void setReassembler(WarReassembler reassembler) {
+ this.reassembler = reassembler;
+ }
+
+ public String getUnzipBaseDir() {
+ return unzipBaseDir;
+ }
+
+ public void setUnzipBaseDir(String unzipBaseDir) {
+ this.unzipBaseDir = unzipBaseDir;
+ }
+
+ public String getDestination() {
+ return destination;
+ }
+
+ public void setDestination(String destination) {
+ this.destination = destination;
+ }
+
+}
Added: portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/impl/Tomcat5DeployWarAdminServiceImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/impl/Tomcat5DeployWarAdminServiceImpl.java?view=auto&rev=481790
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/impl/Tomcat5DeployWarAdminServiceImpl.java (added)
+++ portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/impl/Tomcat5DeployWarAdminServiceImpl.java Sun Dec 3 08:24:00 2006
@@ -0,0 +1,118 @@
+package org.apache.pluto.driver.services.portal.admin.impl;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pluto.driver.services.portal.admin.DeployWarAdminService;
+import org.apache.pluto.util.deploy.Deployer;
+import org.apache.pluto.util.deploy.DeploymentException;
+import org.apache.pluto.util.deploy.Undeployer;
+import org.apache.pluto.util.deploy.file.Tomcat5FileSystemDeployer;
+import org.apache.pluto.util.deploy.file.TomcatDeploymentConfig;
+import org.apache.pluto.util.deploy.http.HttpTomcatDeployer;
+import org.apache.pluto.util.install.file.TomcatCrossContextGenerator;
+
+public class Tomcat5DeployWarAdminServiceImpl implements DeployWarAdminService {
+
+ private static final Log LOG = LogFactory.getLog(TomcatDeploymentConfig.class);
+
+ private Deployer deployer = null;//configure with Spring
+ private Undeployer undeployer = null;//configure with Spring
+ private String tomcatService = "Catalina";//configure with Spring
+ private String host = "localhost";//configure with Spring
+ private String port = "8080";//configure with Spring
+ private String protocol = "http";//configure with Spring
+ private String tomcatHome = System.getProperty("catalina.home");//configure with Spring
+
+
+ public Tomcat5DeployWarAdminServiceImpl() {
+ super();
+ }
+ /* (non-Javadoc)
+ * @see org.apache.pluto.driver.services.portal.admin.DeployWarAdminService#deployWar(java.io.File)
+ */
+ public void deployWar(File war, boolean configure) throws DeploymentException{
+ String strWar = war.getAbsolutePath();
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("New War to deploy:" + strWar);
+ }
+ String warName = strWar.substring(strWar.lastIndexOf(File.separator) +1);
+ String deploymentName = warName.substring(0, warName.lastIndexOf('.'));
+ //
+ TomcatDeploymentConfig config = new TomcatDeploymentConfig(deploymentName);
+ //is the war configured already or is it a redeployment?
+ config.setConfigured(configure);
+ config.setDeploymentName(deploymentName);
+ //Add other info for deployment
+ config.addDeploymentProperty("tomcat.home", tomcatHome);
+ config.addDeploymentProperty("tomcat.service", tomcatService);
+ config.addDeploymentProperty("tomcat.host", host);
+ config.addDeploymentProperty("tomcat.port", port);
+ config.addDeploymentProperty("tomcat.protocol", protocol);
+
+ undeployer = new HttpTomcatDeployer();
+ deployer = new Tomcat5FileSystemDeployer();
+
+
+ try {
+ undeployer.undeploy(config, war);
+ deployer.deploy(config, war);
+ } catch (FileNotFoundException e) {
+ DeploymentException de = new DeploymentException("War file cannot be found");
+ de.initCause(e);
+ throw de;
+ } catch (IOException e) {
+ DeploymentException de = new DeploymentException("Generic I/O issue with war file");
+ de.initCause(e);
+ throw de;
+ }
+ }
+
+ public String getHost() {
+ return host;
+ }
+ public void setHost(String host) {
+ this.host = host;
+ }
+ public String getTomcatHome() {
+ return tomcatHome;
+ }
+ public void setTomcatHome(String tomcatHome) {
+ this.tomcatHome = tomcatHome;
+ }
+ public String getTomcatService() {
+ return tomcatService;
+ }
+ public void setTomcatService(String tomcatService) {
+ this.tomcatService = tomcatService;
+ }
+ public Deployer getDeployer() {
+ return deployer;
+ }
+ public void setDeployer(Deployer deployer) {
+ this.deployer = deployer;
+ }
+ public String getPort() {
+ return port;
+ }
+ public void setPort(String port) {
+ this.port = port;
+ }
+ public String getProtocol() {
+ return protocol;
+ }
+ public void setProtocol(String protocol) {
+ this.protocol = protocol;
+ }
+ public Undeployer getUndeployer() {
+ return undeployer;
+ }
+ public void setUndeployer(Undeployer undeployer) {
+ this.undeployer = undeployer;
+ }
+
+
+}
Added: portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/impl/WarUploadAdminServiceImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/impl/WarUploadAdminServiceImpl.java?view=auto&rev=481790
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/impl/WarUploadAdminServiceImpl.java (added)
+++ portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/impl/WarUploadAdminServiceImpl.java Sun Dec 3 08:24:00 2006
@@ -0,0 +1,110 @@
+package org.apache.pluto.driver.services.portal.admin.impl;
+
+import java.io.File;
+
+import javax.portlet.ActionRequest;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pluto.driver.services.portal.admin.WarUploadAdminService;
+import org.apache.pluto.util.fileupload.FileUploaderConfig;
+import org.apache.pluto.util.fileupload.FileUploader;
+import org.apache.pluto.util.fileupload.FileUploaderException;
+
+/**
+ * Uploads the war using a <code>FileUploader</code> utility.
+ *
+ * @author <a href="cdoremus@apache.org">Craig Doremus</a>
+ * @see FileUploader
+ */
+public class WarUploadAdminServiceImpl implements WarUploadAdminService {
+
+ public static final Log LOG = LogFactory.getLog(WarUploadAdminServiceImpl.class);
+ /**
+ * Implementation of FileUploader utility used to upload
+ * file, which can be configured using Spring.
+ */
+ FileUploader fileUploader = null;//configure with Spring
+ /**
+ * Directory to upload the war to, which should be configured
+ * by Spring. By default, it is a .pluto directory underneath
+ * the user's home directory.
+ */
+ String uploadDir = System.getProperty("user.home") + "/pluto";
+ /**
+ * Maximum size of file upload in megabytes, which should be configured
+ * by String. By default it is 10 megabytes.
+ */
+ int maxUploadSize = 10;//configure with Spring
+
+ public WarUploadAdminServiceImpl() {
+ super();
+ }
+
+ /**
+ * Uploads the war using a FileUploader implementation.
+ *
+ * @param request The portlet request
+ * @return Pointer to the uploaded file
+ */
+ public File uploadWar(ActionRequest request) throws FileUploaderException {
+ File uploadedFile = null;
+ if (fileUploader == null) {
+ throw new FileUploaderException("FileUploader is null. Please check Spring configuration.");
+ }
+ FileUploaderConfig config = new FileUploaderConfig();
+ config.setMaxUploadSize(maxUploadSize * 1000000);
+ File fUploadDir = new File(uploadDir);
+ if (!fUploadDir.exists()) {
+ fUploadDir.mkdir();
+ }
+ config.setUploadPath(fUploadDir);
+ uploadedFile = fileUploader.upload(request,config);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Uploaded file: " + uploadedFile.getAbsolutePath());
+ }
+ return uploadedFile;
+ }
+
+ /**
+ * @return the maxUploadSize
+ */
+ public int getMaxUploadSize() {
+ return maxUploadSize;
+ }
+
+ /**
+ * @param maxUploadSize the maxUploadSize to set
+ */
+ public void setMaxUploadSize(int maxUploadSize) {
+ this.maxUploadSize = maxUploadSize;
+ }
+
+ /**
+ * @return the uploadDir
+ */
+ public String getUploadDir() {
+ return uploadDir;
+ }
+
+ /**
+ * @param uploadDir the uploadDir to set
+ */
+ public void setUploadDir(String uploadDir) {
+ this.uploadDir = uploadDir;
+ }
+
+ /**
+ * @return the fileUploader
+ */
+ public FileUploader getFileUploader() {
+ return fileUploader;
+ }
+
+ /**
+ * @param fileUploader the fileUploader to set
+ */
+ public void setFileUploader(FileUploader fileUploader) {
+ this.fileUploader = fileUploader;
+ }
+}
Added: portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/deploy/edit.jsp
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/deploy/edit.jsp?view=auto&rev=481790
==============================================================================
--- portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/deploy/edit.jsp (added)
+++ portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/deploy/edit.jsp Sun Dec 3 08:24:00 2006
@@ -0,0 +1,45 @@
+<%--
+Copyright 2004 The Apache Software Foundation
+Licensed 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.
+--%>
+<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
+<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
+<%@ taglib uri='http://java.sun.com/portlet' prefix='portlet'%>
+<%@page import="org.apache.pluto.driver.services.portal.admin.PlutoAdminPortlet"%>
+<%@page import="java.util.ResourceBundle"%>
+
+<portlet:defineObjects/>
+
+<fmt:bundle basename="FileUploadPortlet">
+ <fmt:message key="fileupload.edit.title" var="title"/>
+ <fmt:message key="fileupload.edit.subtitle" var="subtitle"/>
+</fmt:bundle>
+
+<h2><c:out value="${title}"/></h2>
+<h4><c:out value="${subtitle}"/></h4>
+
+<c:set value="${portlet_msg.cssClass}" var="css"/>
+<div class="<c:out value='${css}'/>">
+ <c:out value="${portlet_msg}"/>
+</div>
+
+<portlet:actionURL var="configaction">
+ <portlet:param name="command" value="config"/>
+</portlet:actionURL>
+<form action="<c:out value='${configaction}'/>" enctype="application/x-www-form-urlencoded" method="post">
+ <div><label>Max File Size:</label> <input type="text" name="<%= FileUploadPortlet.MAX_FILE_UPLOAD_SIZE_PARAM %>" value="<c:out value='${maxfileuploadsize}'/>" /></div>
+ <div><label>Upload directory:</label><input type="text" name="<%= FileUploadPortlet.UPLOAD_PATH_PARAM %>" value="<c:out value='${uploadpath}'/>" /></div>
+ <div><label></label><input type="submit" value="Submit"/></div>
+</form>
Added: portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/deploy/help.jsp
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/deploy/help.jsp?view=auto&rev=481790
==============================================================================
--- portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/deploy/help.jsp (added)
+++ portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/deploy/help.jsp Sun Dec 3 08:24:00 2006
@@ -0,0 +1,21 @@
+<%--
+Copyright 2004 The Apache Software Foundation
+Licensed 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.
+--%>
+<%@ taglib uri='http://java.sun.com/portlet' prefix='portlet'%>
+
+<portlet:defineObjects/>
+
+<h2>Deploy War Portlet Help Mode</h2>
Added: portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/deploy/view.jsp
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/deploy/view.jsp?view=auto&rev=481790
==============================================================================
--- portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/deploy/view.jsp (added)
+++ portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/fragments/admin/deploy/view.jsp Sun Dec 3 08:24:00 2006
@@ -0,0 +1,42 @@
+<%--
+Copyright 2004 The Apache Software Foundation
+Licensed 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.
+--%>
+<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
+<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
+<%@ taglib uri='http://java.sun.com/portlet' prefix='portlet'%>
+<%@ taglib uri='http://portals.apache.org/pluto' prefix='pluto'%>
+<%@page import="org.apache.pluto.driver.portlets.AdminDeploymentPortlet"%>
+
+<portlet:defineObjects/>
+
+<fmt:bundle basename="AdminDeploymentPortlet">
+ <fmt:message key="admin-deploy.view.title" var="title"/>
+ <fmt:message key="admin-deploy.view.subtitle" var="subtitle"/>
+</fmt:bundle>
+
+<div class="portlet-section-header"><c:out value="${title}"/></div>
+<div class="portlet-section-subheader"><c:out value="${subtitle}"/></div>
+
+<portlet:actionURL var="uploadaction">
+ <portlet:param name="command" value="uploadfile"/>
+</portlet:actionURL>
+<form action="<c:out value='${uploadaction}'/>" enctype="multipart/form-data" method="post">
+ <div><input type="file" name="<%= AdminDeploymentPortlet.UPLOAD_PATH_PARAM %>"/></div>
+ <div><input type="submit" value="Submit"/></div>
+</form>
+
+<pluto:message/>
+
Added: portals/pluto/trunk/pluto-portal/src/main/webapp/portlet-spec-1.0.css
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-portal/src/main/webapp/portlet-spec-1.0.css?view=auto&rev=481790
==============================================================================
--- portals/pluto/trunk/pluto-portal/src/main/webapp/portlet-spec-1.0.css (added)
+++ portals/pluto/trunk/pluto-portal/src/main/webapp/portlet-spec-1.0.css Sun Dec 3 08:24:00 2006
@@ -0,0 +1,275 @@
+/*
+Copyright 2004,2005,2006 The Apache Software Foundation
+Licensed 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.
+*/
+/*
+NOTE:
+This stylesheet is a formatted copy of Appendix PLT. C in the Portlet API specification, which defines
+CSS styles to be used in portlets conforming to the spec.
+*/
+
+/*****************************************************************************************
+Java(TM) Portlet Specification, version 1.0 (10/07/2003) pp. 115-118
+
+PLT.C
+CSS Style Definitions
+To achieve a common look and feel throughout the portal page, all portlets in the portal
+page should use a common CSS style sheet when generating content.
+This appendix defines styles for a variety of logical units in the markup. It follows the
+style being considered by the OASIS Web Services for Remote Portlets Technical Committee.
+******************************************************************************************/
+
+/*****************************************************************************************
+PLT.C.1 Links (Anchor)
+A custom CSS class is not defined for the <a> tag. The entity should use the default
+classes when embedding anchor tags.
+******************************************************************************************/
+
+/*****************************************************************************************
+PLT.C.2 Fonts
+The font style definitions affect the font attributes only (font face, size, color, style, etc).
+******************************************************************************************/
+
+/* Font attributes for the "normal" fragment font. Used for the display of non-accentuated information.
+Example: Normal Text */
+.portlet-font {
+ font-family: Arial,Helvetica,sans-serif;
+ font-style: normal;
+ font-weight: normal;
+ font-size: 10pt;
+ color:black;
+}
+
+/* Font attributes similar to the portlet-font but the color is lighter. Example: Dim Text */
+.portlet-font-dim {
+ font-family: Arial,Helvetica,sans-serif;
+ font-style: normal;
+ font-weight: normal;
+ font-size: 10pt;
+ color:lightgrey;
+}
+
+/*****************************************************************************************
+PLT.C.3 Messages
+Message style definitions affect the rendering of a paragraph (alignment, borders,
+background color, etc) as well as text attributes.
+******************************************************************************************/
+/* Status of the current operation. Example: Progress: 80% */
+.portlet-msg-status {
+ font-family: Arial,Helvetica,sans-serif;
+ font-style: normal;
+ font-weight: bold;
+ font-size:10pt;
+ color:black;
+}
+
+/* Help messages, general additional information, etc. Example: Info about */
+.portlet-msg-info {
+ font-family: Arial,Helvetica,sans-serif;
+ font-style: normal;
+ font-weight: bold;
+ font-size:10pt;
+ color:blue;
+}
+
+/* Error messages.
+Example: Portlet not available*/
+.portlet-msg-error {
+ font-family: Arial,Helvetica,sans-serif;
+ font-style: normal;
+ font-weight: bold;
+ font-size:8pt;
+ color:red;
+}
+
+/* Warning messages.
+Example: Timeout occurred, try again later */
+.portlet-msg-alert {
+ font-family: Arial,Helvetica,sans-serif;
+ font-style: normal;
+ font-weight: bold;
+ font-size:10pt;
+ color:yellow;
+}
+
+/* Verification of the successful completion of a task. Example: Operation completed successfully */
+.portlet-msg-success {
+ font-family: Arial,Helvetica,sans-serif;
+ font-style: normal;
+ font-weight: bold;
+ font-size:10pt;
+ color:green;
+}
+
+/*****************************************************************************************
+PLT.C.4 Sections
+Section style definitions affect the rendering of markup sections such as table, div and
+span (alignment, borders, background color, etc) as well as their text attributes.
+******************************************************************************************/
+/* Table or section header */
+.portlet-section-header {
+ font-family: Arial,Helvetica,sans-serif;
+ font-style: normal;
+ font-weight: bold;
+ font-size: 16pt;
+ margin-top: 0;
+ margin-bottom: 1em;
+}
+
+/* Normal text in a table cell */
+.portlet-section-body {
+ font-family: Arial,Helvetica,sans-serif;
+ font-style: normal;
+ font-weight: normal;
+ font-size: 12pt;
+
+}
+
+/* Text in every other row in the cell */
+.portlet-section-alternate {
+
+}
+
+/* Text in a selected cell range */
+.portlet-section-selected {
+
+}
+
+/* Text of a subheading */
+.portlet-section-subheader {
+ font-family: Arial,Helvetica,sans-serif;
+ font-style: normal;
+ font-weight: bold;
+ font-size: 12pt;
+}
+
+/* Table or section footnote */
+.portlet-section-footer {
+
+}
+
+/* Text that belongs to the table but does not fall in one of
+the other categories (e.g. explanatory or help text that is
+associated with the section). */
+.portlet-section-text {
+
+}
+
+/*****************************************************************************************
+PLT.C.5 Forms
+Form styles define the look-and-feel of the elements in an HTML form.
+******************************************************************************************/
+/* Text used for the descriptive label of the whole form (not the labels for fields). */
+.portlet-form-label {
+ font-family: Arial,Helvetica,sans-serif;
+ font-style: normal;
+ font-weight: bold;
+ font-size: 12pt;
+ color: black;
+}
+
+/* Text of the user-input in an input field. */
+.portlet-form-input-field {
+ font-family: Arial,Helvetica,sans-serif;
+ font-style: normal;
+ font-weight: normal;
+ font-size: 10pt;
+ color: black;
+}
+
+/* Text on a button */
+.portlet-form-button {
+ font-family: Arial,Helvetica,sans-serif;
+ font-style: normal;
+ font-weight: normal;
+ font-size: 12pt;
+ color: black;
+}
+
+/* Text that appears beside a context dependent action icon. */
+.portlet-icon-label {
+
+}
+
+/* Text that appears beside a "standard" icon (e.g. Ok, or Cancel) */
+.portlet-dlg-icon-label {
+
+}
+
+/* Text for a separator of fields (e.g. checkboxes, etc.) */
+.portlet-form-field-label {
+ font-family: Arial,Helvetica,sans-serif;
+ font-style: normal;
+ font-weight: bold;
+ font-size: 10pt;
+ color: black;
+}
+
+/* Text for a field (not input field, e.g. checkboxes, etc) */
+.portlet-form-field {
+
+}
+
+/*****************************************************************************************
+PLT.C.6 Menus
+Menu styles define the look-and-feel of the text and background of a menu structure. This
+structure may be embedded in the aggregated page or may appear as a context sensitive
+popup menu.
+******************************************************************************************/
+/* General menu settings such as background color, margins, etc */
+.portlet-menu {
+
+}
+
+/* Normal, unselected menu item. */
+.portlet-menu-item {
+
+}
+
+/* Selected menu item. */
+.portlet-menu-item-selected {
+
+}
+
+/* Normal, unselected menu item when the mouse hovers over it. */
+.portlet-menu-item-hover {
+
+}
+
+/* Selected menu item when the mouse hovers over it. */
+.portlet-menu-item-hover-selected {
+
+}
+
+/* Normal, unselected menu item that has submenus. */
+.portlet-menu-cascade-item {
+
+}
+
+/* Selected sub-menu item that has sub-menus. */
+.portlet-menu-cascade-item-selected {
+
+}
+
+/* Descriptive text for the menu (e.g. in a help context below the menu) */
+.portlet-menu-description {
+
+}
+
+/* Menu caption */
+.portlet-menu-caption {
+
+}
+
Added: portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/deploy/HttpDeploymentConfig.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/deploy/HttpDeploymentConfig.java?view=auto&rev=481790
==============================================================================
--- portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/deploy/HttpDeploymentConfig.java (added)
+++ portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/deploy/HttpDeploymentConfig.java Sun Dec 3 08:24:00 2006
@@ -0,0 +1,47 @@
+package org.apache.pluto.util.deploy;
+
+import java.util.Properties;
+
+/**
+ * Holds configuration data for http deployments.
+ *
+ * @author <a href="cdoremus@apache.org">Craig Doremus</a>
+ *
+ */
+public class HttpDeploymentConfig {
+
+ private String protocol = "http";
+
+ private String host = "localhost";
+
+ private int port = 8080;
+
+ public HttpDeploymentConfig() {
+ super();
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public void setProtocol(String protocol) {
+ this.protocol = protocol;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public String getProtocol() {
+ return protocol;
+ }
+
+}
Added: portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/deploy/Undeployer.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/deploy/Undeployer.java?view=auto&rev=481790
==============================================================================
--- portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/deploy/Undeployer.java (added)
+++ portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/deploy/Undeployer.java Sun Dec 3 08:24:00 2006
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed 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.pluto.util.deploy;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Interface defining the methods necessary to deploy a portlet application to
+ * a servlet container.
+ *
+ * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
+ * @version 1.0
+ * @since Oct 15, 2004
+ */
+public interface Undeployer {
+
+ /**
+ * Undeploy the specified portlet application to pluto.
+ * @param config the deployment configuration of the portlet app.
+ * @param webappInputStream the input stream to the WAR file.
+ * @throws IOException if an IO error occurs.
+ * @throws DeploymentException if a deployment error occurs.
+ */
+ public void undeploy(DeploymentConfig config, File webappFile)
+ throws IOException, DeploymentException;
+
+}
+
Added: portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/deploy/http/HttpTomcatDeployer.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/deploy/http/HttpTomcatDeployer.java?view=auto&rev=481790
==============================================================================
--- portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/deploy/http/HttpTomcatDeployer.java (added)
+++ portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/deploy/http/HttpTomcatDeployer.java Sun Dec 3 08:24:00 2006
@@ -0,0 +1,106 @@
+package org.apache.pluto.util.deploy.http;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URLEncoder;
+
+import org.apache.commons.httpclient.HostConfiguration;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.cookie.CookiePolicy;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pluto.util.deploy.Deployer;
+import org.apache.pluto.util.deploy.DeploymentConfig;
+import org.apache.pluto.util.deploy.DeploymentException;
+import org.apache.pluto.util.deploy.HttpDeploymentConfig;
+import org.apache.pluto.util.deploy.Undeployer;
+
+/**
+ * Handles deployment of war files using the Tomcat manger
+ * application URL interface via commons-httpclient.
+ *
+ * @author <a href="cdoremus@apache.org">Craig Doremus</a>
+ *
+ */
+public class HttpTomcatDeployer implements Deployer, Undeployer {
+ private static final Log LOG = LogFactory.getLog(HttpDeploymentConfig.class);
+
+ public void deploy(DeploymentConfig config, File webappFile)
+ throws IOException, DeploymentException {
+
+ GetMethod get = doDeployment(config, webappFile, "deploy");
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("Deployment Response Status: "+get.getStatusLine().toString());
+ }
+ String response = get.getResponseBodyAsString();
+
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("Deployment Details: \n"+response);
+ }
+ }
+
+
+ public void undeploy(DeploymentConfig config, File webappFile) throws IOException, DeploymentException {
+ GetMethod get = doDeployment(config, webappFile, "undeploy");
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("Undeployment Response Status: "+get.getStatusLine().toString());
+ }
+ String response = get.getResponseBodyAsString();
+
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("Undeployment Details: \n"+response);
+ }
+ }
+
+ public GetMethod doDeployment(DeploymentConfig config, File webappFile, String deploymentType) throws DeploymentException {
+ HttpClient hclient = new HttpClient();
+ hclient.setHostConfiguration(getHostConfiguration(config));
+ hclient.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
+
+ StringBuffer sb = new StringBuffer();
+ sb.append("/manager/")
+ .append(deploymentType)
+ .append("?path=")
+ .append(URLEncoder.encode(webappFile.getAbsolutePath()));
+
+
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("Request url: "+sb.toString());
+ }
+
+ GetMethod get = new GetMethod(sb.toString());
+
+ try {
+ hclient.executeMethod(get);
+
+ }
+ catch(HttpException e) {
+ DeploymentException de = new DeploymentException("Unable to undeploy");
+ de.initCause(e);
+ throw de;
+ }
+ catch(IOException e) {
+ DeploymentException de = new DeploymentException("Unable to undeploy");
+ de.initCause(e);
+ throw de;
+ }
+
+ return get;
+ }
+
+ private HostConfiguration getHostConfiguration(DeploymentConfig config) {
+ HostConfiguration host = new HostConfiguration();
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("Host configuration: ");
+ LOG.debug("Host: " + config.getDeploymentProperty("tomcat.host"));
+ LOG.debug("Port: " + config.getDeploymentProperty("tomcat.port"));
+ LOG.debug("Protocol: " + config.getDeploymentProperty("tomcat.protocol"));
+ }
+ host.setHost(config.getDeploymentProperty("tomcat.host"),
+ Integer.parseInt(config.getDeploymentProperty("tomcat.port")),
+ config.getDeploymentProperty("tomcat.protocol"));
+ return host;
+ }
+}
Added: portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/ui/PortletUiMessage.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/ui/PortletUiMessage.java?view=auto&rev=481790
==============================================================================
--- portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/ui/PortletUiMessage.java (added)
+++ portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/ui/PortletUiMessage.java Sun Dec 3 08:24:00 2006
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.pluto.util.ui;
+
+/**
+ * Immutable value object carrying a message and a message type to the user interface.
+ *
+ * @author <a href="cdoremus@apache.org">Craig Doremus</a>
+ * @see PortletUiMessageType
+ */
+public class PortletUiMessage {
+
+ private String message = "";
+ private Throwable exception = null;
+ private PortletUiMessageType messageType = PortletUiMessageType.INFO;
+
+ private PortletUiMessage() {
+ //don't use
+ }
+
+ public PortletUiMessage(String message, PortletUiMessageType messageType) {
+ this.message = message;
+ this.messageType = messageType;
+ }
+
+ public PortletUiMessage(Throwable e, PortletUiMessageType messageType) {
+ this.message = e.getMessage();
+ this.messageType = messageType;
+ this.exception = e;
+ }
+
+ public PortletUiMessage(Throwable e) {
+ this.message = e.getMessage();
+ this.messageType = PortletUiMessageType.ERROR;
+ this.exception = e;
+ }
+
+ public PortletUiMessage(String message, Throwable e) {
+ this.message = message;
+ this.messageType = PortletUiMessageType.ERROR;
+ this.exception = e;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public PortletUiMessageType getMessageType() {
+ return messageType;
+ }
+
+ public String getCssClass(){
+ return messageType.cssClass;
+ }
+
+ public String toString() {
+ return message;
+ }
+
+ public Throwable getException() {
+ return exception;
+ }
+
+}
Added: portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/ui/PortletUiMessageType.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/ui/PortletUiMessageType.java?view=auto&rev=481790
==============================================================================
--- portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/ui/PortletUiMessageType.java (added)
+++ portals/pluto/trunk/pluto-util/src/main/java/org/apache/pluto/util/ui/PortletUiMessageType.java Sun Dec 3 08:24:00 2006
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.pluto.util.ui;
+
+/**
+ * Typesafe enum (pre-JDK-1.4) representing different message
+ * types and the Cascading Style Sheet class that should be
+ * used to render the message (see PLT.C.3 in JSR-168 spec).
+ *
+ * TODO: Convert to JDK 1.5+ enum
+ *
+ * @author <a href="cdoremus@apache.org">Craig Doremus</a>
+ * @see PortletUiMessage
+ */
+public final class PortletUiMessageType {
+//TODO: Add methods to allow implemention of Serializable
+
+ public static final PortletUiMessageType INFO = new PortletUiMessageType("info", "portlet-msg-info");
+ public static final PortletUiMessageType ERROR = new PortletUiMessageType("error", "portlet-msg-error");
+ public static final PortletUiMessageType STATUS = new PortletUiMessageType("status", "portlet-msg-status");
+ public static final PortletUiMessageType ALERT = new PortletUiMessageType("alert", "portlet-msg-alert");
+ public static final PortletUiMessageType SUCCESS = new PortletUiMessageType("success", "portlet-msg-success");
+
+ public final String name;
+ public final String cssClass;
+
+ private PortletUiMessageType(String name, String cssClass){
+ this.name = name;
+ this.cssClass = cssClass;
+ }
+
+ public static final PortletUiMessageType[] values() {
+ PortletUiMessageType[] vals = {INFO, ERROR, STATUS, ALERT, SUCCESS};
+ return vals;
+ }
+
+ public String toString(){
+ return name;
+ }
+
+ public boolean equals(Object obj) {
+ return name.equals(obj);
+ }
+
+ public int hashCode() {
+ return name.hashCode();
+ }
+
+
+
+
+}