svnno****@sourc*****
svnno****@sourc*****
2007年 4月 12日 (木) 12:04:40 JST
Revision: 37 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=pal&view=rev&rev=37 Author: shinsuke Date: 2007-04-12 12:04:40 +0900 (Thu, 12 Apr 2007) Log Message: ----------- implemented start/stop/undeploy/delete action to portlet. Modified Paths: -------------- pal-admin/trunk/src/main/java/jp/sf/pal/admin/PALAdminConstants.java pal-admin/trunk/src/main/java/jp/sf/pal/admin/logic/PortletManagementLogic.java pal-admin/trunk/src/main/java/jp/sf/pal/admin/service/PortletManagementService.java pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/portletmanager/PortletListPage.java pal-admin/trunk/src/main/resources/appMessages.properties pal-admin/trunk/src/main/resources/jp/sf/pal/admin/web/portletmanager/label.properties pal-admin/trunk/src/main/webapp/view/portletmanager/portletList.html Added Paths: ----------- pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/portletmanager/PortletActionConfirmPage.java pal-admin/trunk/src/main/webapp/view/portletmanager/portletActionConfirm.html -------------- next part -------------- Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/PALAdminConstants.java =================================================================== --- pal-admin/trunk/src/main/java/jp/sf/pal/admin/PALAdminConstants.java 2007-04-12 01:29:19 UTC (rev 36) +++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/PALAdminConstants.java 2007-04-12 03:04:40 UTC (rev 37) @@ -63,4 +63,12 @@ public static final int PORTLET_APPLICATION_STATUS_STOPPED = 0; + public static final String PORTLET_MANAGEMENT_ACTION_START = "start"; + + public static final String PORTLET_MANAGEMENT_ACTION_STOP = "stop"; + + public static final String PORTLET_MANAGEMENT_ACTION_UNDEPLOY = "undeploy"; + + public static final String PORTLET_MANAGEMENT_ACTION_DELETE = "delete"; + } Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/logic/PortletManagementLogic.java =================================================================== --- pal-admin/trunk/src/main/java/jp/sf/pal/admin/logic/PortletManagementLogic.java 2007-04-12 01:29:19 UTC (rev 36) +++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/logic/PortletManagementLogic.java 2007-04-12 03:04:40 UTC (rev 37) @@ -1,17 +1,21 @@ package jp.sf.pal.admin.logic; +import java.io.IOException; import java.util.ArrayList; import java.util.List; import jp.sf.pal.admin.PALAdminConstants; +import jp.sf.pal.admin.PALAdminException; import jp.sf.pal.admin.entity.PortletApplication; import jp.sf.pal.admin.pager.PortletApplicationPager; import jp.sf.pal.admin.util.PortalComponentUtil; import org.apache.jetspeed.components.portletregistry.PortletRegistry; +import org.apache.jetspeed.components.portletregistry.RegistryException; import org.apache.jetspeed.factory.PortletFactory; import org.apache.jetspeed.om.common.portlet.MutablePortletApplication; import org.apache.jetspeed.tools.pamanager.servletcontainer.ApplicationServerManager; +import org.apache.jetspeed.tools.pamanager.servletcontainer.ApplicationServerManagerResult; import org.seasar.framework.log.Logger; public class PortletManagementLogic @@ -113,7 +117,7 @@ for (int i = offset; i < offset + limit && i < size; i++) { MutablePortletApplication pa = portlets.get(i); - + PortletApplication portlet = new PortletApplication(); portlet.setName(pa.getName()); portlet.setVersion(pa.getVersion()); @@ -140,10 +144,99 @@ portlet .setStatus(PALAdminConstants.PORTLET_APPLICATION_STATUS_STOPPED); } - + portletApplicationList.add(portlet); } return portletApplicationList; } + + public boolean isServerManagerAvailable() + { + return getApplicationServerManager() != null + && getApplicationServerManager().isConnected(); + } + + public void startPortletApplication(String portletName) + throws PALAdminException + { + MutablePortletApplication pa = getPortletRegistry() + .getPortletApplication(portletName); + try + { + ApplicationServerManagerResult result = getApplicationServerManager() + .start(pa.getWebApplicationDefinition().getContextRoot()); + if (!result.isOk()) + { + throw new PALAdminException(result.getMessage()); + } + } + catch (IOException e) + { + logger.error("Could not start the portlet: " + portletName, e); + throw new PALAdminException("Could not start the portlet: " + + portletName, e); + } + } + + public void stopPortletApplication(String portletName) + throws PALAdminException + { + MutablePortletApplication pa = getPortletRegistry() + .getPortletApplication(portletName); + try + { + ApplicationServerManagerResult result = getApplicationServerManager() + .stop(pa.getWebApplicationDefinition().getContextRoot()); + if (!result.isOk()) + { + throw new PALAdminException(result.getMessage()); + } + } + catch (IOException e) + { + logger.error("Could not stop the portlet: " + portletName, e); + throw new PALAdminException("Could not stop the portlet: " + + portletName, e); + } + } + + public void undeployPortletApplication(String portletName) + throws PALAdminException + { + MutablePortletApplication pa = getPortletRegistry() + .getPortletApplication(portletName); + try + { + ApplicationServerManagerResult result = getApplicationServerManager() + .undeploy(pa.getWebApplicationDefinition().getContextRoot()); + if (!result.isOk()) + { + throw new PALAdminException(result.getMessage()); + } + } + catch (IOException e) + { + logger.error("Could not undeploy the portlet: " + portletName, e); + throw new PALAdminException("Could not undeploy the portlet: " + + portletName, e); + } + } + + public void deletePortletApplication(String portletName) + throws PALAdminException + { + MutablePortletApplication pa = getPortletRegistry() + .getPortletApplication(portletName); + try + { + getPortletRegistry().removeApplication(pa); + } + catch (RegistryException e) + { + logger.error("Could not delete the portlet: " + portletName, e); + throw new PALAdminException("Could not delete the portlet: " + + portletName, e); + } + } } Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/service/PortletManagementService.java =================================================================== --- pal-admin/trunk/src/main/java/jp/sf/pal/admin/service/PortletManagementService.java 2007-04-12 01:29:19 UTC (rev 36) +++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/service/PortletManagementService.java 2007-04-12 03:04:40 UTC (rev 37) @@ -5,10 +5,12 @@ import java.util.Map; import jp.sf.pal.admin.PALAdminConstants; +import jp.sf.pal.admin.PALAdminException; import jp.sf.pal.admin.dxo.PortletApplicationDxo; import jp.sf.pal.admin.logic.PortletManagementLogic; import jp.sf.pal.admin.pager.PortletApplicationPager; import jp.sf.pal.admin.util.PagerUtil; +import jp.sf.pal.admin.web.portletmanager.PortletActionConfirmPage; import jp.sf.pal.admin.web.portletmanager.PortletListPage; public class PortletManagementService @@ -86,6 +88,37 @@ PagerUtil.updatePagerPage(page, pager); page.setPortletApplicationItems(list); + // set server manager status + page.setServerManagerAvailable(getPortletManagementLogic() + .isServerManagerAvailable()); } + public void startPortletApplication(PortletActionConfirmPage page) + throws PALAdminException + { + String portletName = page.getName(); + getPortletManagementLogic().startPortletApplication(portletName); + } + + public void stopPortletApplication(PortletActionConfirmPage page) + throws PALAdminException + { + String portletName = page.getName(); + getPortletManagementLogic().stopPortletApplication(portletName); + } + + public void undeployPortletApplication(PortletActionConfirmPage page) + throws PALAdminException + { + String portletName = page.getName(); + getPortletManagementLogic().undeployPortletApplication(portletName); + } + + public void deletePortletApplication(PortletActionConfirmPage page) + throws PALAdminException + { + String portletName = page.getName(); + getPortletManagementLogic().deletePortletApplication(portletName); + } + } Added: pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/portletmanager/PortletActionConfirmPage.java =================================================================== --- pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/portletmanager/PortletActionConfirmPage.java 2007-04-12 01:29:19 UTC (rev 36) +++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/portletmanager/PortletActionConfirmPage.java 2007-04-12 03:04:40 UTC (rev 37) @@ -0,0 +1,158 @@ +package jp.sf.pal.admin.web.portletmanager; + +import javax.faces.internal.FacesMessageUtil; + +import jp.sf.pal.admin.PALAdminConstants; +import jp.sf.pal.admin.PALAdminException; +import jp.sf.pal.admin.service.PortletManagementService; +import jp.sf.pal.admin.web.AbstractCrudPage; + +public class PortletActionConfirmPage extends AbstractCrudPage +{ + + private String name; + + private String action; + + private PortletManagementService portletManagementService; + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + /** + * @return the action + */ + public String getAction() + { + return action; + } + + /** + * @param action the action to set + */ + public void setAction(String action) + { + this.action = action; + } + + /** + * @return the portletManagementService + */ + public PortletManagementService getPortletManagementService() + { + return portletManagementService; + } + + /** + * @param portletManagementService the portletManagementService to set + */ + public void setPortletManagementService( + PortletManagementService portletManagementService) + { + this.portletManagementService = portletManagementService; + } + + public String initialize() + { + return null; + } + + public String prerender() + { + return null; + } + + public Class doFinish() + { + if (isStartAction()) + { + try + { + portletManagementService.startPortletApplication(this); + FacesMessageUtil.addInfoMessage("started.portlet.application"); + } + catch (PALAdminException e) + { + FacesMessageUtil + .addErrorMessage("failed.to.start.portlet.application"); + } + } + else if (isStopAction()) + { + try + { + portletManagementService.stopPortletApplication(this); + FacesMessageUtil.addInfoMessage("stopped.portlet.application"); + } + catch (PALAdminException e) + { + FacesMessageUtil + .addErrorMessage("failed.to.stop.portlet.application"); + } + } + else if (isUndeployAction()) + { + try + { + portletManagementService.undeployPortletApplication(this); + FacesMessageUtil + .addInfoMessage("undeployed.portlet.application"); + } + catch (PALAdminException e) + { + FacesMessageUtil + .addErrorMessage("failed.to.undeploy.portlet.application"); + } + } + else if (isDeleteAction()) + { + try + { + portletManagementService.deletePortletApplication(this); + FacesMessageUtil.addInfoMessage("deleted.portlet.application"); + } + catch (PALAdminException e) + { + FacesMessageUtil + .addErrorMessage("failed.to.delete.portlet.application"); + } + } + else + { + FacesMessageUtil + .addWarnMessage("invalid.action.for.portlet.application"); + } + return PortletListPage.class; + } + + public boolean isStartAction() + { + return PALAdminConstants.PORTLET_MANAGEMENT_ACTION_START + .equals(getAction()); + } + + public boolean isStopAction() + { + return PALAdminConstants.PORTLET_MANAGEMENT_ACTION_STOP + .equals(getAction()); + } + + public boolean isUndeployAction() + { + return PALAdminConstants.PORTLET_MANAGEMENT_ACTION_UNDEPLOY + .equals(getAction()); + } + + public boolean isDeleteAction() + { + return PALAdminConstants.PORTLET_MANAGEMENT_ACTION_DELETE + .equals(getAction()); + } +} Property changes on: pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/portletmanager/PortletActionConfirmPage.java ___________________________________________________________________ Name: svn:eol-style + native Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/portletmanager/PortletListPage.java =================================================================== --- pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/portletmanager/PortletListPage.java 2007-04-12 01:29:19 UTC (rev 36) +++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/portletmanager/PortletListPage.java 2007-04-12 03:04:40 UTC (rev 37) @@ -3,6 +3,7 @@ import java.util.List; import java.util.Map; +import jp.sf.pal.admin.PALAdminConstants; import jp.sf.pal.admin.service.PortletManagementService; import jp.sf.pal.admin.web.AbstractPagerPage; @@ -19,8 +20,12 @@ private Integer status; + private Integer applicationType; + private String version; + private boolean serverManagerAvailable; + private PortletManagementService portletManagementService; public String getName() @@ -74,6 +79,22 @@ this.status = status; } + /** + * @return the applicationType + */ + public Integer getApplicationType() + { + return applicationType; + } + + /** + * @param applicationType the applicationType to set + */ + public void setApplicationType(Integer applicationType) + { + this.applicationType = applicationType; + } + public String getVersion() { return version; @@ -85,6 +106,22 @@ } /** + * @return the serverManagerAvailable + */ + public boolean isServerManagerAvailable() + { + return serverManagerAvailable; + } + + /** + * @param serverManagerAvailable the serverManagerAvailable to set + */ + public void setServerManagerAvailable(boolean serverManagerAvailable) + { + this.serverManagerAvailable = serverManagerAvailable; + } + + /** * @return the portletManagementService */ public PortletManagementService getPortletManagementService() @@ -114,4 +151,39 @@ return null; } + public boolean isStartAction() + { + return isServerManagerAvailable() + && getStatus() == PALAdminConstants.PORTLET_APPLICATION_STATUS_STOPPED + && getApplicationType() == PALAdminConstants.PORTLET_APPLICATION_TYPE_WEBAPP; + } + + public boolean isStopAction() + { + return isServerManagerAvailable() + && getStatus() == PALAdminConstants.PORTLET_APPLICATION_STATUS_RUNNING + && getApplicationType() == PALAdminConstants.PORTLET_APPLICATION_TYPE_WEBAPP; + } + + public boolean isUndeployAction() + { + return isServerManagerAvailable() + && getApplicationType() == PALAdminConstants.PORTLET_APPLICATION_TYPE_WEBAPP; + } + + public boolean isDeleteAction() + { + return getStatus() == PALAdminConstants.PORTLET_APPLICATION_STATUS_STOPPED; + } + + public boolean isRunning() + { + return getStatus() == PALAdminConstants.PORTLET_APPLICATION_STATUS_RUNNING; + } + + public boolean isStopped() + { + return getStatus() == PALAdminConstants.PORTLET_APPLICATION_STATUS_STOPPED; + } + } Modified: pal-admin/trunk/src/main/resources/appMessages.properties =================================================================== --- pal-admin/trunk/src/main/resources/appMessages.properties 2007-04-12 01:29:19 UTC (rev 36) +++ pal-admin/trunk/src/main/resources/appMessages.properties 2007-04-12 03:04:40 UTC (rev 37) @@ -37,3 +37,15 @@ failed.to.remove.principalRules.from.user=Failed to remove profiling rules({1}) from the user({0}). invalid.principalRule.or.user.name=Invalid profiling rule or user name. principalRule.exists.in.user=The profiling rule({1}/{2}) exists in the user({0}). + +invalid.action.for.portlet.application=Invalid action for the portlet application. +started.portlet.application=Started the portlet application. +failed.to.start.portlet.application=Failed to start the portlet application. +stopped.portlet.application=Stopped the portlet application. +failed.to.stop.portlet.application=Failed to stop the portlet application. +undeployed.portlet.application=Undeployed the portlet application. +failed.to.undeploy.portlet.application=Failed to undeploy the portlet application. +deleted.portlet.application=Deleted the portlet application. +failed.to.delete.portlet.application=Failed to delete the portlet application. + + Modified: pal-admin/trunk/src/main/resources/jp/sf/pal/admin/web/portletmanager/label.properties =================================================================== --- pal-admin/trunk/src/main/resources/jp/sf/pal/admin/web/portletmanager/label.properties 2007-04-12 01:29:19 UTC (rev 36) +++ pal-admin/trunk/src/main/resources/jp/sf/pal/admin/web/portletmanager/label.properties 2007-04-12 03:04:40 UTC (rev 37) @@ -4,3 +4,11 @@ path=Path status=Status delete=Delete +start=Start +stop=Stop +undeploy=Undeploy + +startPortlet= Start Portlet +stopPortlet= Stop Portlet +undeployPortlet= Undeploy Portlet +deletePortlet= Delete Portlet Added: pal-admin/trunk/src/main/webapp/view/portletmanager/portletActionConfirm.html =================================================================== --- pal-admin/trunk/src/main/webapp/view/portletmanager/portletActionConfirm.html 2007-04-12 01:29:19 UTC (rev 36) +++ pal-admin/trunk/src/main/webapp/view/portletmanager/portletActionConfirm.html 2007-04-12 03:04:40 UTC (rev 37) @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="stylesheet" type="text/css" href="../../css/global.css"/> +</head> +<body> +<form id="PortletConfirmForm"> +<input type="hidden" id="crudType" /> +<input type="hidden" id="action" /> +<!-- tab: BEGIN --> +<div style="padding: 0px 0px 3px 10px; margin:5px 0px;border-bottom:1px solid #000000;"> + <label id="portletsTabLabel" style="border-top:1px solid #000000;border-right:1px solid #000000;border-bottom:1px solid #ffffff;border-left:1px solid #000000;padding: 3px 5px 3px 5px; margin: 0px 0px;">Portlets</label> + <a id="jumpGroupList" href="../deployer/deployerList.html" style="text-decoration: none;"> + <span id="deployerTabLabel" style="font-weight: bold;color:#ffffff;background-color:#999999;border:1px solid #000000; padding: 3px 5px 3px 5px; margin: 0px 0px;">Deployer</span> + </a> +</div> +<!-- tab: END --> + +<div> + <span id="allMessages" fatalClass="portlet-msg-error" errorClass="portlet-msg-error" warnClass="portlet-msg-alert" infoClass="portlet-msg-info"></span> +</div> + +<!-- content: BEGIN --> +<div style="padding:5px 0px;"> + <div class="portlet-section-header" id="isStartAction"> + <label id="startPortletLabel">Start Portlet</label> + </div> + <div class="portlet-section-header" id="isStopAction"> + <label id="stopPortletLabel">Stop Portlet</label> + </div> + <div class="portlet-section-header" id="isUndeployAction"> + <label id="undeployPortletLabel">Undeploy Portlet</label> + </div> + <div class="portlet-section-header" id="isDeleteAction"> + <label id="deletePortletLabel">Delete Portlet</label> + </div> + + <table class="tablebg"> + <tr> + <td class="portlet-section-subheader"><label id="portletNameLabel">Portlet Name</label></td> + <td class="portlet-section-body"><span id="name">PORTLET</span><input type="hidden" id="name-hidden" /></td> + <td><span id="nameMessage"></span></td> + </tr> + </table> + + <div> + <input type="button" id="jumpPortletList" value="Back" + onclick="location.href='portletList.html'" class="portlet-form-button"/> + <div id="isNotRead" style="display:inline;"> + <input type="button" id="doFinish" value="Finish" onclick="location.href='portletList.html'" class="portlet-form-button"/> + </div> + </div> +</div> +<!-- content: END --> +</form> +</body></html> Property changes on: pal-admin/trunk/src/main/webapp/view/portletmanager/portletActionConfirm.html ___________________________________________________________________ Name: svn:eol-style + native Modified: pal-admin/trunk/src/main/webapp/view/portletmanager/portletList.html =================================================================== --- pal-admin/trunk/src/main/webapp/view/portletmanager/portletList.html 2007-04-12 01:29:19 UTC (rev 36) +++ pal-admin/trunk/src/main/webapp/view/portletmanager/portletList.html 2007-04-12 03:04:40 UTC (rev 37) @@ -60,7 +60,30 @@ <td class="portlet-section-body"><span id="path">PATH</span></td> <td class="portlet-section-body"><span id="status">STATUS</span></td> <td class="portlet-section-alternate"> - <a id="goPortletDeleteConfirm" href="portletDeleteConfirm.html?fixed_crudType=3&name=name"><span id="deleteLabel">Delete</span></a> + <div id="isStartAction" style="display:inline;"> + <a id="goPortletActionConfirm" href="portletActionConfirm.html?fixed_crudType=2&fixed_action=start&name=name"><span id="startLabel">Start</span></a> + </div> + <div id="isNotStartAction" style="display:inline;"> + <label id="startLabel">Start</label> + </div> + <div id="isStopAction" style="display:inline;"> + <a id="goPortletActionConfirm" href="portletActionConfirm.html?fixed_crudType=2&fixed_action=stop&name=name"><span id="stopLabel">Stop</span></a> + </div> + <div id="isNotStopAction" style="display:inline;"> + <label id="stopLabel">Stop</label> + </div> + <div id="isUndeployAction" style="display:inline;"> + <a id="goPortletActionConfirm" href="portletActionConfirm.html?fixed_crudType=2&fixed_action=undeploy&name=name"><span id="undeployLabel">Undeploy</span></a> + </div> + <div id="isNotUndeployAction" style="display:inline;"> + <label id="undeployLabel">Undeploy</label> + </div> + <div id="isDeleteAction" style="display:inline;"> + <a id="goPortletActionConfirm" href="portletActionConfirm.html?fixed_crudType=3&fixed_action=delete&name=name"><span id="deleteLabel">Delete</span></a> + </div> + <div id="isNotDeleteAction" style="display:inline;"> + <label id="deleteLabel">Delete</label> + </div> </td> </tr> </div>