From bd0a362d5d872f39c1606ae3c8762cd70d4e37e6 Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Mon, 11 Feb 2008 13:19:19 +0000 Subject: [PATCH] Merged V2.2 to HEAD 7307: Re-enabled ability to perform deployments against new model 7278: Added friendly server name property to model and refactored view deployment report dialog 7272: Patch for new deployment features git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8245 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/messages/webclient.properties | 1 - config/alfresco/web-client-config-dialogs.xml | 1 + .../alfresco/web-client-config-properties.xml | 1 - config/alfresco/web-client-config-wcm.xml | 11 - .../alfresco/web/bean/wcm/AVMBrowseBean.java | 14 +- .../org/alfresco/web/bean/wcm/AVMUtil.java | 207 ++++-------------- .../web/bean/wcm/CreateWebsiteWizard.java | 38 +--- .../web/bean/wcm/DeploySnapshotDialog.java | 164 +++++++------- .../web/bean/wcm/DeploymentMonitor.java | 39 +++- .../web/bean/wcm/EditWebsiteWizard.java | 2 - .../web/ui/wcm/component/UIDeployWebsite.java | 47 ++-- .../ui/wcm/component/UIDeploymentReports.java | 51 ++++- .../ui/wcm/component/UISandboxSnapshots.java | 150 +++++++------ source/web/WEB-INF/faces-config-beans.xml | 4 + .../jsp/wcm/create-website-wizard/details.jsp | 23 -- 15 files changed, 314 insertions(+), 439 deletions(-) diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties index d2c86cea97..a983c31853 100644 --- a/config/alfresco/messages/webclient.properties +++ b/config/alfresco/messages/webclient.properties @@ -1213,7 +1213,6 @@ deploy_status_failed=FAILED deploy_status_partial=PARTIAL FAILURE reason=Reason snapshot=Snapshot -deploy_to_help=A comma separated list of servers to deploy the website to. Each entry either represents the location of a Deployment Receiver or an Alfresco Repository.

A file server entry must be prefixed with '\\\\'. Each server can be represented by a host name or an IP address and may also contain an RMI port number. If an RMI port number is not specified for a Deployment Receiver the default of {0} will be used. If an RMI port number is not specified for an Alfresco Repository the default of {1} will be used.

Example: \\\\liveserver1, \\\\liveserver2:44200, liverserver3, liverserver4:50900 content_launch=Content Launch launch_date=Launch Date expiration_date_header=Content Expiration diff --git a/config/alfresco/web-client-config-dialogs.xml b/config/alfresco/web-client-config-dialogs.xml index 6f4e4e3e66..6720d6ad58 100644 --- a/config/alfresco/web-client-config-dialogs.xml +++ b/config/alfresco/web-client-config-dialogs.xml @@ -276,6 +276,7 @@ diff --git a/config/alfresco/web-client-config-properties.xml b/config/alfresco/web-client-config-properties.xml index 50bbecb0af..7608f09bcd 100644 --- a/config/alfresco/web-client-config-properties.xml +++ b/config/alfresco/web-client-config-properties.xml @@ -637,7 +637,6 @@ - diff --git a/config/alfresco/web-client-config-wcm.xml b/config/alfresco/web-client-config-wcm.xml index 5c912a5f69..393e6c1f97 100644 --- a/config/alfresco/web-client-config-wcm.xml +++ b/config/alfresco/web-client-config-wcm.xml @@ -17,20 +17,9 @@ 25 - - - admin - - admin - - 50500 - - 44100 2 - - 30 diff --git a/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java b/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java index 71fe3e226c..6d9a8c7dc2 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java @@ -843,27 +843,27 @@ public class AVMBrowseBean implements IContextListener // expression in a 'rendered' attribute, we therefore cache the result // on a per request basis - List deployReportRefs = null; + List deployAttempts = null; FacesContext context = FacesContext.getCurrentInstance(); Map request = context.getExternalContext().getRequestMap(); if (request.get(REQUEST_BEEN_DEPLOYED_KEY) == null) { - // see if there are any deployment reports for the site + // see if there are any deployment attempts for the site NodeRef webProjectRef = this.getWebsite().getNodeRef(); - deployReportRefs = this.nodeService.getChildAssocs(webProjectRef, - WCMAppModel.ASSOC_DEPLOYMENTREPORT, RegexQNamePattern.MATCH_ALL); + deployAttempts = this.nodeService.getChildAssocs(webProjectRef, + WCMAppModel.ASSOC_DEPLOYMENTATTEMPT, RegexQNamePattern.MATCH_ALL); // add a placeholder object in the request so we don't evaluate this again for this request request.put(REQUEST_BEEN_DEPLOYED_KEY, Boolean.TRUE); - request.put(REQUEST_BEEN_DEPLOYED_RESULT, deployReportRefs); + request.put(REQUEST_BEEN_DEPLOYED_RESULT, deployAttempts); } else { - deployReportRefs = (List)request.get(REQUEST_BEEN_DEPLOYED_RESULT); + deployAttempts = (List)request.get(REQUEST_BEEN_DEPLOYED_RESULT); } - return (deployReportRefs != null && deployReportRefs.size() > 0); + return (deployAttempts != null && deployAttempts.size() > 0); } /** diff --git a/source/java/org/alfresco/web/bean/wcm/AVMUtil.java b/source/java/org/alfresco/web/bean/wcm/AVMUtil.java index 9bc5134003..8ed5ca6417 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMUtil.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMUtil.java @@ -289,58 +289,6 @@ public final class AVMUtil return (otherStore + ':' + AVMUtil.getStoreRelativePath(avmPath)); } - /** - * Returns the username to connect as on the remote machine being deployed to - *

- * This value is read from the <wcm> config section in - * web-client-config-wcm.xml - *

- * - * @return Username for remote machine - */ - public static String getRemoteDeploymentUsername() - { - String username = "admin"; - - ConfigElement deploymentConfig = getDeploymentConfig(); - if (deploymentConfig != null) - { - ConfigElement elem = deploymentConfig.getChild("remote-username"); - if (elem != null) - { - username = elem.getValue(); - } - } - - return username; - } - - /** - * Returns the password to use on the remote machine being deployed to - *

- * This value is read from the <wcm> config section in - * web-client-config-wcm.xml - *

- * - * @return Password for remote machine - */ - public static String getRemoteDeploymentPassword() - { - String password = "admin"; - - ConfigElement deploymentConfig = getDeploymentConfig(); - if (deploymentConfig != null) - { - ConfigElement elem = deploymentConfig.getChild("remote-password"); - if (elem != null) - { - password = elem.getValue(); - } - } - - return password; - } - /** * Returns the number of seconds between each call back to the server to * obtain the latest status of an in progress deployment. @@ -380,123 +328,6 @@ public final class AVMUtil return pollFreq; } - /** - * Returns the default RMI registry port to use when one is not supplied - * for target Alfresco deployment servers. - *

- * This value is read from the <wcm> config section in - * web-client-config-wcm.xml - *

- * - * @return The remote RMI registry port to use for deployments. - * The default is 50500. - */ - public static int getRemoteRMIRegistryPort() - { - int rmiPort = 50500; - - ConfigElement deploymentConfig = getDeploymentConfig(); - if (deploymentConfig != null) - { - ConfigElement elem = deploymentConfig.getChild("remote-rmi-port"); - if (elem != null) - { - try - { - int value = Integer.parseInt(elem.getValue()); - if (value > 0) - { - rmiPort = value; - } - } - catch (NumberFormatException nfe) - { - // do nothing, just use the default - } - } - } - - return rmiPort; - } - - /** - * Returns the default RMI port to use when one is not supplied - * for target deployment receivers. - *

- * This value is read from the <wcm> config section in - * web-client-config-wcm.xml - *

- * - * @return The deployment receiver RMI port to use for deployments. - * The default is 44100. - */ - public static int getRemoteReceiverRMIPort() - { - int rmiPort = 44100; - - ConfigElement deploymentConfig = getDeploymentConfig(); - if (deploymentConfig != null) - { - ConfigElement elem = deploymentConfig.getChild("receiver-rmi-port"); - if (elem != null) - { - try - { - int value = Integer.parseInt(elem.getValue()); - if (value > 0) - { - rmiPort = value; - } - } - catch (NumberFormatException nfe) - { - // do nothing, just use the default - } - } - } - - return rmiPort; - } - - /** - * Returns the delay (in seconds) to apply to the start of a deployment - * operation (mainly for demo and testing purposes). - *

- * This value is read from the <wcm> config section in - * web-client-config-wcm.xml - *

- * - * @return The delay to use at the start of a deployment. - * The default is 30. - */ - public static int getRemoteDeploymentDelay() - { - int delay = 30; - - ConfigElement deploymentConfig = getDeploymentConfig(); - if (deploymentConfig != null) - { - ConfigElement elem = deploymentConfig.getChild("delay"); - if (elem != null) - { - try - { - int value = Integer.parseInt(elem.getValue()); - if (value > 0) - { - delay = value; - } - } - catch (NumberFormatException nfe) - { - // do nothing, just use the default - } - } - } - - return delay; - } - /** * Returns the number of seconds between each call back to the server to * obtain the latest status of a link validation check. @@ -978,6 +809,44 @@ public final class AVMUtil return webProjectNode; } + + /** + * Retrieves the NodeRef of the deploymentattempt node with the given id + * + * @param attemptId The deployattemptid of the node to be found + * @return The NodeRef of the deploymentattempt node or null if not found + */ + public static NodeRef findDeploymentAttempt(String attemptId) + { + FacesContext fc = FacesContext.getCurrentInstance(); + SearchService searchService = Repository.getServiceRegistry(fc).getSearchService(); + + // construct the query + String query = "@wca\\:deployattemptid:\"" + attemptId + "\""; + + NodeRef attempt = null; + ResultSet results = null; + try + { + // execute the query + results = searchService.query(Repository.getStoreRef(), + SearchService.LANGUAGE_LUCENE, query); + + if (results.length() == 1) + { + attempt = results.getNodeRef(0); + } + } + finally + { + if (results != null) + { + results.close(); + } + } + + return attempt; + } /** * Creates all directories for a path if they do not already exist. diff --git a/source/java/org/alfresco/web/bean/wcm/CreateWebsiteWizard.java b/source/java/org/alfresco/web/bean/wcm/CreateWebsiteWizard.java index af62b79667..0973837019 100644 --- a/source/java/org/alfresco/web/bean/wcm/CreateWebsiteWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/CreateWebsiteWizard.java @@ -25,7 +25,6 @@ package org.alfresco.web.bean.wcm; import java.io.Serializable; -import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -85,7 +84,6 @@ import org.apache.commons.logging.LogFactory; */ public class CreateWebsiteWizard extends BaseWizardBean { - private static final String MSG_DEPLOY_TO_HELP = "deploy_to_help"; private static final String MSG_USERROLES = "create_website_summary_users"; private static final String COMPONENT_FORMLIST = "form-list"; @@ -112,7 +110,6 @@ public class CreateWebsiteWizard extends BaseWizardBean protected String name; protected String description; protected String webapp = WEBAPP_DEFAULT; - protected List deployTo; protected String createFrom = null; protected String[] sourceWebProject = null; protected ExpiringValueCache> webProjectsList; @@ -171,7 +168,6 @@ public class CreateWebsiteWizard extends BaseWizardBean this.dnsName = null; this.title = null; this.description = null; - this.deployTo = null; this.isSource = false; clearFormsWorkflowsAndUsers(); this.createFrom = CREATE_EMPTY; @@ -232,9 +228,6 @@ public class CreateWebsiteWizard extends BaseWizardBean String webapp = (this.webapp != null && this.webapp.length() != 0) ? this.webapp : WEBAPP_DEFAULT; this.nodeService.setProperty(nodeRef, WCMAppModel.PROP_DEFAULTWEBAPP, webapp); - // set the list of servers to deploy to - this.nodeService.setProperty(nodeRef, WCMAppModel.PROP_DEPLOYTO, (Serializable)this.deployTo); - // call a delegate wizard bean to provide invite user functionality InviteWebsiteUsersWizard wiz = getInviteUsersWizard(); wiz.reset(); @@ -425,6 +418,7 @@ public class CreateWebsiteWizard extends BaseWizardBean * @param loadProperties Load the basic properties such as name, title, DNS. * @param loadUsers Load the user details. */ + @SuppressWarnings("unchecked") protected void loadWebProjectModel(NodeRef nodeRef, boolean loadProperties, boolean loadUsers) { // simple properties are optionally loaded @@ -436,7 +430,6 @@ public class CreateWebsiteWizard extends BaseWizardBean this.description = (String)props.get(ContentModel.PROP_DESCRIPTION); this.dnsName = (String)props.get(WCMAppModel.PROP_AVMSTORE); this.webapp = (String)props.get(WCMAppModel.PROP_DEFAULTWEBAPP); - this.deployTo = (List)props.get(WCMAppModel.PROP_DEPLOYTO); Boolean isSource = (Boolean)props.get(WCMAppModel.PROP_ISSOURCE); if (isSource != null) { @@ -692,22 +685,6 @@ public class CreateWebsiteWizard extends BaseWizardBean this.webapp = webapp; } - /** - * @return The comma separated list of servers to deploy to - */ - public List getDeployTo() - { - return this.deployTo; - } - - /** - * @param deployTo The comma separated list of servers to deploy to - */ - public void setDeployTo(List deployTo) - { - this.deployTo = deployTo; - } - /** * @return the create from selection value */ @@ -862,19 +839,6 @@ public class CreateWebsiteWizard extends BaseWizardBean { return this.showAllSourceProjects; } - - /** - * @return the deploy to help text that gets displayed if the user - * clicks the Help icon - */ - public String getDeployToHelp() - { - String pattern = Application.getMessage(FacesContext.getCurrentInstance(), - MSG_DEPLOY_TO_HELP); - String defaultAlfPort = Integer.toString(AVMUtil.getRemoteRMIRegistryPort()); - String defaultReceiverPort = Integer.toString(AVMUtil.getRemoteReceiverRMIPort()); - return MessageFormat.format(pattern, new Object[] {defaultReceiverPort, defaultAlfPort}); - } /** * @see org.alfresco.web.bean.wizard.BaseWizardBean#next() diff --git a/source/java/org/alfresco/web/bean/wcm/DeploySnapshotDialog.java b/source/java/org/alfresco/web/bean/wcm/DeploySnapshotDialog.java index 837ce191ac..8818f2df98 100644 --- a/source/java/org/alfresco/web/bean/wcm/DeploySnapshotDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/DeploySnapshotDialog.java @@ -26,6 +26,7 @@ package org.alfresco.web.bean.wcm; import java.io.Serializable; import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -35,11 +36,15 @@ import javax.faces.context.FacesContext; import org.alfresco.model.WCMAppModel; import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.repo.avm.actions.AVMDeploySnapshotAction; +import org.alfresco.repo.domain.PropertyValue; +import org.alfresco.sandbox.SandboxConstants; import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.action.ActionService; -import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.avm.AVMService; +import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.RegexQNamePattern; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.GUID; import org.alfresco.web.bean.dialog.BaseDialogBean; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -53,10 +58,12 @@ public class DeploySnapshotDialog extends BaseDialogBean { protected int versionToDeploy; protected String[] deployTo; + protected String stagingStore; protected NodeRef websiteRef; protected NodeRef webProjectRef; protected AVMBrowseBean avmBrowseBean; + protected AVMService avmService; protected ActionService actionService; private static final Log logger = LogFactory.getLog(DeploySnapshotDialog.class); @@ -74,8 +81,9 @@ public class DeploySnapshotDialog extends BaseDialogBean this.versionToDeploy = Integer.parseInt(parameters.get("version")); this.avmBrowseBean.getDeploymentMonitorIds().clear(); this.webProjectRef = this.avmBrowseBean.getWebsite().getNodeRef(); - String stagingStore = AVMUtil.buildSandboxRootPath(this.avmBrowseBean.getStagingStore()); - this.websiteRef = AVMNodeConverter.ToNodeRef(this.versionToDeploy, stagingStore); + this.stagingStore = this.avmBrowseBean.getStagingStore(); + String storeRoot = AVMUtil.buildSandboxRootPath(this.stagingStore); + this.websiteRef = AVMNodeConverter.ToNodeRef(this.versionToDeploy, storeRoot); if (logger.isDebugEnabled()) logger.debug("Initialising dialog to deploy version " + this.versionToDeploy + @@ -86,94 +94,82 @@ public class DeploySnapshotDialog extends BaseDialogBean @Override protected String finishImpl(FacesContext context, String outcome) throws Exception { - // put all the selected servers to deploy to into a list - List selectedDeployTo = new ArrayList(); - if (this.deployTo != null) - { - for (int x = 0; x < this.deployTo.length; x++) - { - selectedDeployTo.add(this.deployTo[x].trim()); - } - } - if (logger.isDebugEnabled()) - logger.debug("Executing deployment of " + this.websiteRef.toString() + - " to servers: " + selectedDeployTo); + logger.debug("Requesting deployment of: " + this.websiteRef.toString()); - if (selectedDeployTo.size() > 0) + if (this.deployTo != null && this.deployTo.length > 0) { - // TODO: move any existing deployment reports to a node representing the - // snapshot, we can then keep a history of deployment attempts on a - // per snapshot basis. - NodeRef webProjectRef = this.avmBrowseBean.getWebsite().getNodeRef(); - List allDeployToServers = (List)nodeService.getProperty(webProjectRef, - WCMAppModel.PROP_DEPLOYTO); - List deployReportRefs = nodeService.getChildAssocs( - webProjectRef, WCMAppModel.ASSOC_DEPLOYMENTREPORT, RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef ref : deployReportRefs) - { - NodeRef report = ref.getChildRef(); - - String server = (String)this.nodeService.getProperty(report, WCMAppModel.PROP_DEPLOYSERVER); - - int version = -1; - Serializable snapshotObj = nodeService.getProperty(report, WCMAppModel.PROP_DEPLOYVERSION); - if (snapshotObj != null && snapshotObj instanceof Integer) - { - version = (Integer)snapshotObj; - } - - if ((version == this.versionToDeploy && selectedDeployTo.contains(server)) || - (version != this.versionToDeploy) || (allDeployToServers.contains(server) == false)) - { - // cascade delete will take care of child-child relationships - this.nodeService.removeChild(webProjectRef, report); - - if (logger.isDebugEnabled()) - logger.debug("Removed exisiting deployment report for server: " + server); - } - } + List selectedDeployToNames = new ArrayList(); - // update the selecteddeployto property with list of servers selected - this.nodeService.setProperty(webProjectRef, WCMAppModel.PROP_SELECTEDDEPLOYTO, - (Serializable)selectedDeployTo); - // update the selecteddeployversion property with the selected snapshot version - this.nodeService.setProperty(webProjectRef, WCMAppModel.PROP_SELECTEDDEPLOYVERSION, - this.versionToDeploy); + // create a deploymentattempt node to represent this deployment + String attemptId = GUID.generate(); + Map props = new HashMap(8, 1.0f); + props.put(WCMAppModel.PROP_DEPLOYATTEMPTID, attemptId); + props.put(WCMAppModel.PROP_DEPLOYATTEMPTTYPE, WCMAppModel.CONSTRAINT_LIVESERVER); + props.put(WCMAppModel.PROP_DEPLOYATTEMPTSTORE, this.stagingStore); + props.put(WCMAppModel.PROP_DEPLOYATTEMPTVERSION, this.versionToDeploy); + props.put(WCMAppModel.PROP_DEPLOYATTEMPTTIME, new Date()); + NodeRef attempt = this.nodeService.createNode(webProjectRef, + WCMAppModel.ASSOC_DEPLOYMENTATTEMPT, WCMAppModel.ASSOC_DEPLOYMENTATTEMPT, + WCMAppModel.TYPE_DEPLOYMENTATTEMPT, props).getChildRef(); // execute a deploy action for each of the selected remote servers asynchronously - for (String targetServer : selectedDeployTo) + for (String targetServer : this.deployTo) { if (targetServer.length() > 0) { - // create a deployment monitor object, store in the session, - // add to avm browse bean and pass to action - DeploymentMonitor monitor = new DeploymentMonitor( - this.websiteRef, targetServer, versionToDeploy); - context.getExternalContext().getSessionMap().put(monitor.getId(), monitor); - this.avmBrowseBean.getDeploymentMonitorIds().add(monitor.getId()); - - // create the action - Map args = new HashMap(1, 1.0f); - args.put(AVMDeploySnapshotAction.PARAM_WEBSITE, webProjectRef); - args.put(AVMDeploySnapshotAction.PARAM_TARGET_SERVER, targetServer); - args.put(AVMDeploySnapshotAction.PARAM_DEFAULT_RMI_PORT, - AVMUtil.getRemoteRMIRegistryPort()); - args.put(AVMDeploySnapshotAction.PARAM_DEFAULT_RECEIVER_RMI_PORT, - AVMUtil.getRemoteReceiverRMIPort()); - args.put(AVMDeploySnapshotAction.PARAM_REMOTE_USERNAME, - AVMUtil.getRemoteDeploymentUsername()); - args.put(AVMDeploySnapshotAction.PARAM_REMOTE_PASSWORD, - AVMUtil.getRemoteDeploymentPassword()); - args.put(AVMDeploySnapshotAction.PARAM_CALLBACK, monitor); - args.put(AVMDeploySnapshotAction.PARAM_DELAY, - AVMUtil.getRemoteDeploymentDelay()); - Action action = this.actionService.createAction(AVMDeploySnapshotAction.NAME, args); - this.actionService.executeAction(action, this.websiteRef, false, true); + NodeRef serverRef = new NodeRef(targetServer); + if (nodeService.exists(serverRef)) + { + // get all properties of the target server + Map serverProps = nodeService.getProperties(serverRef); + + String serverUri = AVMDeploySnapshotAction.calculateServerUri(serverProps); + String serverName = (String)serverProps.get(WCMAppModel.PROP_DEPLOYSERVERNAME); + if (serverName == null || serverName.length() == 0) + { + serverName = serverUri; + } + + if (logger.isDebugEnabled()) + logger.debug("Issuing deployment request for: " + serverName); + + // remember the servers deployed to + selectedDeployToNames.add(serverName); + + // create a deployment monitor object, store in the session, + // add to avm browse bean and pass to action + DeploymentMonitor monitor = new DeploymentMonitor( + this.websiteRef, serverRef, versionToDeploy, serverName, attemptId); + context.getExternalContext().getSessionMap().put(monitor.getId(), monitor); + this.avmBrowseBean.getDeploymentMonitorIds().add(monitor.getId()); + + // create and execute the action asynchronously + Map args = new HashMap(1, 1.0f); + args.put(AVMDeploySnapshotAction.PARAM_WEBSITE, webProjectRef); + args.put(AVMDeploySnapshotAction.PARAM_SERVER, serverRef); + args.put(AVMDeploySnapshotAction.PARAM_ATTEMPT, attempt); + args.put(AVMDeploySnapshotAction.PARAM_CALLBACK, monitor); + Action action = this.actionService.createAction(AVMDeploySnapshotAction.NAME, args); + this.actionService.executeAction(action, this.websiteRef, false, true); + } + else if (logger.isWarnEnabled()) + { + logger.warn("target server '" + targetServer + "' was ignored as it no longer exists!"); + } } } + // now we know the list of selected servers set the property on the attempt node + this.nodeService.setProperty(attempt, WCMAppModel.PROP_DEPLOYATTEMPTSERVERS, + (Serializable)selectedDeployToNames); + + // set the deploymentattempid property on the store this deployment was for + this.avmService.deleteStoreProperty(this.stagingStore, SandboxConstants.PROP_LAST_DEPLOYMENT_ID); + this.avmService.setStoreProperty(this.stagingStore, SandboxConstants.PROP_LAST_DEPLOYMENT_ID, + new PropertyValue(DataTypeDefinition.TEXT, attemptId)); + // close this dialog and immediately open the monitorDeployment dialog return "dialog:monitorDeployment"; } @@ -199,13 +195,21 @@ public class DeploySnapshotDialog extends BaseDialogBean // Bean getters and setters /** - * @param avmBrowseBean The AVM BrowseBean to set + * @param avmBrowseBean The AVM BrowseBean to set */ public void setAvmBrowseBean(AVMBrowseBean avmBrowseBean) { this.avmBrowseBean = avmBrowseBean; } + /** + * @param avmService The AVMService to set. + */ + public void setAvmService(AVMService avmService) + { + this.avmService = avmService; + } + /** * @param actionService The actionService to set. */ diff --git a/source/java/org/alfresco/web/bean/wcm/DeploymentMonitor.java b/source/java/org/alfresco/web/bean/wcm/DeploymentMonitor.java index 727a8650e6..1e0cf9006b 100644 --- a/source/java/org/alfresco/web/bean/wcm/DeploymentMonitor.java +++ b/source/java/org/alfresco/web/bean/wcm/DeploymentMonitor.java @@ -46,7 +46,9 @@ public class DeploymentMonitor implements DeploymentCallback, Serializable { private String id; private NodeRef website; - private String targetServer; + private NodeRef targetServer; + private String targetServerName; + private String deployAttemptId; private int snapshotVersion; private boolean started = false; private boolean finished = false; @@ -58,12 +60,15 @@ public class DeploymentMonitor implements DeploymentCallback, Serializable /** * Default constructor */ - public DeploymentMonitor(NodeRef website, String targetServer, int snapshotVersion) + public DeploymentMonitor(NodeRef website, NodeRef server, int snapshotVersion, + String serverName, String deployAttemptId) { this.id = ID_PREFIX + Long.toString(System.currentTimeMillis()) + this.hashCode(); this.website = website; - this.targetServer = targetServer; + this.targetServer = server; this.snapshotVersion = snapshotVersion; + this.targetServerName = serverName; + this.deployAttemptId = deployAttemptId; } // ------------------------------------------------------------------------------ @@ -86,7 +91,7 @@ public class DeploymentMonitor implements DeploymentCallback, Serializable } if (logger.isDebugEnabled()) - logger.debug(this.targetServer + ": " + event.getType() + + logger.debug(this.targetServerName + ": " + event.getType() + " " + event.getDestination()); } @@ -98,7 +103,7 @@ public class DeploymentMonitor implements DeploymentCallback, Serializable public void errorOccurred(Throwable err) { if (logger.isDebugEnabled()) - logger.debug(this.targetServer + ": ERROR: " + err.getMessage()); + logger.debug(this.targetServerName + ": ERROR: " + err.getMessage()); this.successful = false; this.finished = true; @@ -111,7 +116,9 @@ public class DeploymentMonitor implements DeploymentCallback, Serializable buffer.append(" (id=").append(this.id); buffer.append(" website=").append(this.website); buffer.append(" targetServer=").append(this.targetServer); + buffer.append(" targetServerName=").append(this.targetServerName); buffer.append(" snapshotVersion=").append(this.snapshotVersion); + buffer.append(" deployAttemptId=").append(this.deployAttemptId); buffer.append(" started=").append(this.started); buffer.append(" finished=").append(this.finished); buffer.append(" successful=").append(this.successful).append(")"); @@ -123,7 +130,11 @@ public class DeploymentMonitor implements DeploymentCallback, Serializable StringBuilder buffer = new StringBuilder("\n"); @@ -172,13 +175,14 @@ public class UIDeployWebsite extends UIInput if (logger.isDebugEnabled()) logger.debug("Found deployment monitor: " + monitor); - renderServer(context, out, monitor.getTargetServer(), false, true, id); + renderServer(context, out, nodeService, monitor.getTargetServer(), false, true, id); } } } else { // get a list of the servers that have been successfully deployed to + /* NodeService nodeService = Repository.getServiceRegistry(context).getNodeService(); int deployingVersion = this.getSnapshotVersion(); List serversAlreadyDeployed = new ArrayList(); @@ -207,21 +211,18 @@ public class UIDeployWebsite extends UIInput } } } + */ - // get the list of servers for the user to select from - List servers = (List)nodeService.getProperty(webProject, - WCMAppModel.PROP_DEPLOYTO); - - if (logger.isDebugEnabled()) - logger.debug("Servers available: " + servers + ", servers already deployed: " + - serversAlreadyDeployed); - - // render the list of servers, only pre-select those that have not been - // deployed successfully - for (String server : servers) + // get the servers available to deploy to + List deployServerRefs = nodeService.getChildAssocs( + webProjectRef, WCMAppModel.ASSOC_DEPLOYMENTSERVER, RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef ref : deployServerRefs) { - boolean preSelected = !serversAlreadyDeployed.contains(server); - renderServer(context, out, server, preSelected, false, null); + NodeRef server = ref.getChildRef(); + + // TODO: determine if the server has already been successfully deployed to + + renderServer(context, out, nodeService, server, true, false, null); } } @@ -428,11 +429,19 @@ public class UIDeployWebsite extends UIInput out.write("\n"); } - private void renderServer(FacesContext context, ResponseWriter out, String server, - boolean selected, boolean monitoring, String monitorId) throws IOException + private void renderServer(FacesContext context, ResponseWriter out, NodeService nodeService, + NodeRef server, boolean selected, boolean monitoring, String monitorId) + throws IOException { String contextPath = context.getExternalContext().getRequestContextPath(); + Map props = nodeService.getProperties(server); + String serverName = (String)props.get(WCMAppModel.PROP_DEPLOYSERVERNAME); + if (serverName == null || serverName.length() == 0) + { + serverName = AVMDeploySnapshotAction.calculateServerUri(props); + } + out.write(""); out.write(" - - - - -
"); out.write("
"); - out.write(server); + out.write(serverName); out.write("
"); if (monitoring) { diff --git a/source/java/org/alfresco/web/ui/wcm/component/UIDeploymentReports.java b/source/java/org/alfresco/web/ui/wcm/component/UIDeploymentReports.java index ed9e3448e4..161afa71a1 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/UIDeploymentReports.java +++ b/source/java/org/alfresco/web/ui/wcm/component/UIDeploymentReports.java @@ -36,6 +36,9 @@ import javax.transaction.UserTransaction; import org.alfresco.model.ContentModel; import org.alfresco.model.WCMAppModel; +import org.alfresco.repo.domain.PropertyValue; +import org.alfresco.sandbox.SandboxConstants; +import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentService; @@ -44,6 +47,7 @@ import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.web.app.Application; import org.alfresco.web.bean.repository.Repository; +import org.alfresco.web.bean.wcm.AVMUtil; import org.alfresco.web.ui.common.PanelGenerator; import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.component.SelfRenderingComponent; @@ -117,22 +121,47 @@ public class UIDeploymentReports extends SelfRenderingComponent if (logger.isDebugEnabled()) logger.debug("Rendering deployment reports for: " + webProject.toString()); - // render the supporting JavaScript - renderScript(context, out); - - // iterate through each deployment report NodeService nodeService = Repository.getServiceRegistry(context).getNodeService(); ContentService contentService = Repository.getServiceRegistry(context).getContentService(); - List deployReportRefs = nodeService.getChildAssocs( - this.webProjectRef, WCMAppModel.ASSOC_DEPLOYMENTREPORT, RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef ref : deployReportRefs) + AVMService avmService = Repository.getServiceRegistry(context).getAVMService(); + + String store = (String)nodeService.getProperty(webProject, WCMAppModel.PROP_AVMSTORE); + PropertyValue val = avmService.getStoreProperty(store, SandboxConstants.PROP_LAST_DEPLOYMENT_ID); + String attemptId = null; + + if (val != null) { - // render each report - renderReport(context, out, ref.getChildRef(), nodeService, contentService); + attemptId = val.getStringValue(); } - // add some padding after the panels - out.write("\n
\n"); + if (attemptId == null || attemptId.length() == 0) + { + throw new IllegalStateException("Failed to retrieve deployment attempt id"); + } + + if (logger.isDebugEnabled()) + logger.debug("Retrieving deployment reports for attempt id: " + attemptId); + + // get the deploymentattempt object + NodeRef attempt = AVMUtil.findDeploymentAttempt(attemptId); + + if (attempt != null) + { + // render the supporting JavaScript + renderScript(context, out); + + // iterate through each deployment report + List deployReportRefs = nodeService.getChildAssocs( + attempt, WCMAppModel.ASSOC_DEPLOYMENTREPORTS, RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef ref : deployReportRefs) + { + // render each report + renderReport(context, out, ref.getChildRef(), nodeService, contentService); + } + + // add some padding after the panels + out.write("\n
\n"); + } tx.commit(); } diff --git a/source/java/org/alfresco/web/ui/wcm/component/UISandboxSnapshots.java b/source/java/org/alfresco/web/ui/wcm/component/UISandboxSnapshots.java index db064ef8f0..a7d58adbed 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/UISandboxSnapshots.java +++ b/source/java/org/alfresco/web/ui/wcm/component/UISandboxSnapshots.java @@ -42,6 +42,8 @@ import javax.faces.el.ValueBinding; import javax.transaction.UserTransaction; import org.alfresco.model.WCMAppModel; +import org.alfresco.repo.domain.PropertyValue; +import org.alfresco.sandbox.SandboxConstants; import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.avm.VersionDescriptor; import org.alfresco.service.cmr.repository.ChildAssociationRef; @@ -205,7 +207,7 @@ public class UISandboxSnapshots extends SelfRenderingComponent { final Calendar c = Calendar.getInstance(); c.setTime(toDate); - c.set(Calendar.HOUR, 0); + c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); fromDate = c.getTime(); @@ -229,15 +231,15 @@ public class UISandboxSnapshots extends SelfRenderingComponent boolean showDeployAction = false; NodeRef webProjectRef = AVMUtil.getWebProjectNodeFromStore(sandbox); NodeService nodeService = Repository.getServiceRegistry(context).getNodeService(); - List deployToServers = (List)nodeService.getProperty(webProjectRef, - WCMAppModel.PROP_DEPLOYTO); + List deployToServers = nodeService.getChildAssocs( + webProjectRef, WCMAppModel.ASSOC_DEPLOYMENTSERVER, RegexQNamePattern.MATCH_ALL); if (deployToServers != null && deployToServers.size() > 0) { showDeployAction = true; } // determine the deployment status for the website - determineDeploymentStatus(context, webProjectRef, sandbox, nodeService); + determineDeploymentStatus(context, webProjectRef, sandbox, nodeService, avmService); Map requestMap = context.getExternalContext().getRequestMap(); for (int i=versions.size() - 1; i >= 0; i--) // reverse order @@ -378,6 +380,7 @@ public class UISandboxSnapshots extends SelfRenderingComponent * * @return UIActionLink component if found, else null if not created yet */ + @SuppressWarnings("unchecked") private UIActionLink findAction(String name, String sandbox) { UIActionLink action = null; @@ -411,6 +414,7 @@ public class UISandboxSnapshots extends SelfRenderingComponent * * @return UIActionLink child component */ + @SuppressWarnings("unchecked") private UIActionLink createAction(FacesContext fc, String sandbox, String name, String icon, String actionListener, String outcome, String url, Map params) { @@ -478,87 +482,89 @@ public class UISandboxSnapshots extends SelfRenderingComponent return control; } + @SuppressWarnings("unchecked") private void determineDeploymentStatus(FacesContext context, NodeRef webProjectRef, - String sandbox, NodeService nodeService) + String sandbox, NodeService nodeService, AVMService avmService) { - // work out what status to show against which snapshot - List selectedServers = (List)nodeService.getProperty(webProjectRef, - WCMAppModel.PROP_SELECTEDDEPLOYTO); - Integer ver = (Integer)nodeService.getProperty(webProjectRef, - WCMAppModel.PROP_SELECTEDDEPLOYVERSION); - if (ver != null) + // if the store property holding the last deployment id is non null a + // deployment has been attempted + PropertyValue val = avmService.getStoreProperty(sandbox, SandboxConstants.PROP_LAST_DEPLOYMENT_ID); + String attemptId = null; + + if (val != null) { - this.deployAttemptVersion = ver.intValue(); - } - - if (selectedServers != null && selectedServers.size() > 0) - { - // if the 'selecteddeployto' property is set a deployment has been attempted - List deployReportRefs = nodeService.getChildAssocs( - webProjectRef, WCMAppModel.ASSOC_DEPLOYMENTREPORT, RegexQNamePattern.MATCH_ALL); + attemptId = val.getStringValue(); - List deployedServers = new ArrayList(); - - boolean oneOrMoreFailed = false; - boolean allFailed = true; - for (ChildAssociationRef ref : deployReportRefs) + // get the latest deployment attempt + NodeRef attempt = AVMUtil.findDeploymentAttempt(attemptId); + if (attempt != null) { - NodeRef report = ref.getChildRef(); - - // get the name of the server and the deploy outcome - String serverName = (String)nodeService.getProperty(report, - WCMAppModel.PROP_DEPLOYSERVER); - Boolean successful = (Boolean)nodeService.getProperty(report, - WCMAppModel.PROP_DEPLOYSUCCESSFUL); - - deployedServers.add(serverName); - if (successful != null) + // retrieve the snapshot deployed + Integer ver = (Integer)nodeService.getProperty(attempt, + WCMAppModel.PROP_DEPLOYATTEMPTVERSION); + if (ver != null) { - if (successful.booleanValue()) + this.deployAttemptVersion = ver.intValue(); + } + + // determine if all required reports are present + List selectedServers = (List)nodeService.getProperty( + attempt, WCMAppModel.PROP_DEPLOYATTEMPTSERVERS); + int numServersSelected = 0; + if (selectedServers != null) + { + numServersSelected = selectedServers.size(); + + List deployReportRefs = nodeService.getChildAssocs( + attempt, WCMAppModel.ASSOC_DEPLOYMENTREPORTS, RegexQNamePattern.MATCH_ALL); + + if (deployReportRefs.size() >= numServersSelected) { - allFailed = false; + // the number of expected reports are present, determine the status + boolean oneOrMoreFailed = false; + boolean allFailed = true; + for (ChildAssociationRef ref : deployReportRefs) + { + NodeRef report = ref.getChildRef(); + + // get the deploy outcome + Boolean successful = (Boolean)nodeService.getProperty(report, + WCMAppModel.PROP_DEPLOYSUCCESSFUL); + + if (successful != null) + { + if (successful.booleanValue()) + { + allFailed = false; + } + else + { + oneOrMoreFailed = true; + } + } + } + + // get the right status string + if (allFailed) + { + this.deployStatus = Application.getMessage(context, "deploy_status_failed"); + } + else if (oneOrMoreFailed) + { + this.deployStatus = Application.getMessage(context, "deploy_status_partial"); + } + else + { + this.deployStatus = Application.getMessage(context, "deploy_status_live"); + } } else { - oneOrMoreFailed = true; + // not all expected reports are present yet, still in progress + this.deployStatus = Application.getMessage(context, "deploy_status_in_progress"); } } } - - // now we have a list of servers that were deployed see if all - // the selected servers have a report, if not it means a deployment - // is in progress. If all servers reports are present then - // determine the status by the outcomes of from all the reports. - boolean allPresent = true; - for (String selectedServer : selectedServers) - { - if (deployedServers.contains(selectedServer) == false) - { - allPresent = false; - break; - } - } - - if (allPresent) - { - // get the right status string - if (allFailed) - { - this.deployStatus = Application.getMessage(context, "deploy_status_failed"); - } - else if (oneOrMoreFailed) - { - this.deployStatus = Application.getMessage(context, "deploy_status_partial"); - } - else - { - this.deployStatus = Application.getMessage(context, "deploy_status_live"); - } - } - else - { - this.deployStatus = Application.getMessage(context, "deploy_status_in_progress"); - } } } diff --git a/source/web/WEB-INF/faces-config-beans.xml b/source/web/WEB-INF/faces-config-beans.xml index 164559fff4..4586df0072 100644 --- a/source/web/WEB-INF/faces-config-beans.xml +++ b/source/web/WEB-INF/faces-config-beans.xml @@ -4043,6 +4043,10 @@ avmBrowseBean #{AVMBrowseBean} + + + avmService + #{AVMLockingAwareService} actionService diff --git a/source/web/jsp/wcm/create-website-wizard/details.jsp b/source/web/jsp/wcm/create-website-wizard/details.jsp index 9daaabe0ec..3cfddd3495 100644 --- a/source/web/jsp/wcm/create-website-wizard/details.jsp +++ b/source/web/jsp/wcm/create-website-wizard/details.jsp @@ -144,29 +144,6 @@
- - - - - - - - - - - -