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
This commit is contained in:
Derek Hulley
2008-02-11 13:19:19 +00:00
parent a6d2fd9481
commit bd0a362d5d
15 changed files with 314 additions and 439 deletions

View File

@@ -1213,7 +1213,6 @@ deploy_status_failed=FAILED
deploy_status_partial=PARTIAL FAILURE deploy_status_partial=PARTIAL FAILURE
reason=Reason reason=Reason
snapshot=Snapshot 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.<br><br>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.<br><br>Example: \\\\liveserver1, \\\\liveserver2:44200, liverserver3, liverserver4:50900
content_launch=Content Launch content_launch=Content Launch
launch_date=Launch Date launch_date=Launch Date
expiration_date_header=Content Expiration expiration_date_header=Content Expiration

View File

@@ -276,6 +276,7 @@
<dialog name="viewDeploymentReport" page="/jsp/wcm/deployment-report.jsp" <dialog name="viewDeploymentReport" page="/jsp/wcm/deployment-report.jsp"
managed-bean="ViewDeploymentReportDialog" managed-bean="ViewDeploymentReportDialog"
title-id="deployment_report_title"
icon="/images/icons/deployment_report_large.gif" icon="/images/icons/deployment_report_large.gif"
description-id="deployment_report_desc" show-ok-button="false" /> description-id="deployment_report_desc" show-ok-button="false" />

View File

@@ -637,7 +637,6 @@
<property-sheet> <property-sheet>
<show-property name="wca:avmstore" read-only="true" /> <show-property name="wca:avmstore" read-only="true" />
<show-property name="wca:defaultwebapp" read-only="true" /> <show-property name="wca:defaultwebapp" read-only="true" />
<show-property name="wca:deployto" converter="org.alfresco.faces.MultiValueConverter" read-only="true" />
<show-property name="app:icon" show-in-view-mode="false" show-in-edit-mode="false" /> <show-property name="app:icon" show-in-view-mode="false" show-in-edit-mode="false" />
</property-sheet> </property-sheet>
</config> </config>

View File

@@ -17,20 +17,9 @@
<browse-page-size>25</browse-page-size> <browse-page-size>25</browse-page-size>
</views> </views>
<!-- default values for website deployment -->
<deployment> <deployment>
<!-- username to login as on the remote machine -->
<remote-username>admin</remote-username>
<!-- password to use on remote machine -->
<remote-password>admin</remote-password>
<!-- default RMI port to connect to Alfresco server on remote machine -->
<remote-rmi-port>50500</remote-rmi-port>
<!-- default RMI port to connect to Deployment Receiver on remote machine -->
<receiver-rmi-port>44100</receiver-rmi-port>
<!-- frequency (in seconds) of polling checks to get latest status of a deployment --> <!-- frequency (in seconds) of polling checks to get latest status of a deployment -->
<progress-polling-frequency>2</progress-polling-frequency> <progress-polling-frequency>2</progress-polling-frequency>
<!-- the delay (in seconds) to apply to a deployment (for testing and demo purposes) -->
<delay>30</delay>
</deployment> </deployment>
<links-management> <links-management>

View File

@@ -843,27 +843,27 @@ public class AVMBrowseBean implements IContextListener
// expression in a 'rendered' attribute, we therefore cache the result // expression in a 'rendered' attribute, we therefore cache the result
// on a per request basis // on a per request basis
List<ChildAssociationRef> deployReportRefs = null; List<ChildAssociationRef> deployAttempts = null;
FacesContext context = FacesContext.getCurrentInstance(); FacesContext context = FacesContext.getCurrentInstance();
Map request = context.getExternalContext().getRequestMap(); Map request = context.getExternalContext().getRequestMap();
if (request.get(REQUEST_BEEN_DEPLOYED_KEY) == null) 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(); NodeRef webProjectRef = this.getWebsite().getNodeRef();
deployReportRefs = this.nodeService.getChildAssocs(webProjectRef, deployAttempts = this.nodeService.getChildAssocs(webProjectRef,
WCMAppModel.ASSOC_DEPLOYMENTREPORT, RegexQNamePattern.MATCH_ALL); WCMAppModel.ASSOC_DEPLOYMENTATTEMPT, RegexQNamePattern.MATCH_ALL);
// add a placeholder object in the request so we don't evaluate this again for this request // 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_KEY, Boolean.TRUE);
request.put(REQUEST_BEEN_DEPLOYED_RESULT, deployReportRefs); request.put(REQUEST_BEEN_DEPLOYED_RESULT, deployAttempts);
} }
else else
{ {
deployReportRefs = (List<ChildAssociationRef>)request.get(REQUEST_BEEN_DEPLOYED_RESULT); deployAttempts = (List<ChildAssociationRef>)request.get(REQUEST_BEEN_DEPLOYED_RESULT);
} }
return (deployReportRefs != null && deployReportRefs.size() > 0); return (deployAttempts != null && deployAttempts.size() > 0);
} }
/** /**

View File

@@ -289,58 +289,6 @@ public final class AVMUtil
return (otherStore + ':' + AVMUtil.getStoreRelativePath(avmPath)); return (otherStore + ':' + AVMUtil.getStoreRelativePath(avmPath));
} }
/**
* Returns the username to connect as on the remote machine being deployed to
* <p>
* This value is read from the &lt;wcm&gt; config section in
* web-client-config-wcm.xml
* </p>
*
* @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
* <p>
* This value is read from the &lt;wcm&gt; config section in
* web-client-config-wcm.xml
* </p>
*
* @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 * Returns the number of seconds between each call back to the server to
* obtain the latest status of an in progress deployment. * obtain the latest status of an in progress deployment.
@@ -380,123 +328,6 @@ public final class AVMUtil
return pollFreq; return pollFreq;
} }
/**
* Returns the default RMI registry port to use when one is not supplied
* for target Alfresco deployment servers.
* <p>
* This value is read from the &lt;wcm&gt; config section in
* web-client-config-wcm.xml
* </p>
*
* @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.
* <p>
* This value is read from the &lt;wcm&gt; config section in
* web-client-config-wcm.xml
* </p>
*
* @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).
* <p>
* This value is read from the &lt;wcm&gt; config section in
* web-client-config-wcm.xml
* </p>
*
* @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 * Returns the number of seconds between each call back to the server to
* obtain the latest status of a link validation check. * obtain the latest status of a link validation check.
@@ -979,6 +810,44 @@ public final class AVMUtil
return webProjectNode; 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. * Creates all directories for a path if they do not already exist.
*/ */

View File

@@ -25,7 +25,6 @@
package org.alfresco.web.bean.wcm; package org.alfresco.web.bean.wcm;
import java.io.Serializable; import java.io.Serializable;
import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
@@ -85,7 +84,6 @@ import org.apache.commons.logging.LogFactory;
*/ */
public class CreateWebsiteWizard extends BaseWizardBean 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 MSG_USERROLES = "create_website_summary_users";
private static final String COMPONENT_FORMLIST = "form-list"; private static final String COMPONENT_FORMLIST = "form-list";
@@ -112,7 +110,6 @@ public class CreateWebsiteWizard extends BaseWizardBean
protected String name; protected String name;
protected String description; protected String description;
protected String webapp = WEBAPP_DEFAULT; protected String webapp = WEBAPP_DEFAULT;
protected List<String> deployTo;
protected String createFrom = null; protected String createFrom = null;
protected String[] sourceWebProject = null; protected String[] sourceWebProject = null;
protected ExpiringValueCache<List<UIListItem>> webProjectsList; protected ExpiringValueCache<List<UIListItem>> webProjectsList;
@@ -171,7 +168,6 @@ public class CreateWebsiteWizard extends BaseWizardBean
this.dnsName = null; this.dnsName = null;
this.title = null; this.title = null;
this.description = null; this.description = null;
this.deployTo = null;
this.isSource = false; this.isSource = false;
clearFormsWorkflowsAndUsers(); clearFormsWorkflowsAndUsers();
this.createFrom = CREATE_EMPTY; 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; String webapp = (this.webapp != null && this.webapp.length() != 0) ? this.webapp : WEBAPP_DEFAULT;
this.nodeService.setProperty(nodeRef, WCMAppModel.PROP_DEFAULTWEBAPP, webapp); 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 // call a delegate wizard bean to provide invite user functionality
InviteWebsiteUsersWizard wiz = getInviteUsersWizard(); InviteWebsiteUsersWizard wiz = getInviteUsersWizard();
wiz.reset(); wiz.reset();
@@ -425,6 +418,7 @@ public class CreateWebsiteWizard extends BaseWizardBean
* @param loadProperties Load the basic properties such as name, title, DNS. * @param loadProperties Load the basic properties such as name, title, DNS.
* @param loadUsers Load the user details. * @param loadUsers Load the user details.
*/ */
@SuppressWarnings("unchecked")
protected void loadWebProjectModel(NodeRef nodeRef, boolean loadProperties, boolean loadUsers) protected void loadWebProjectModel(NodeRef nodeRef, boolean loadProperties, boolean loadUsers)
{ {
// simple properties are optionally loaded // simple properties are optionally loaded
@@ -436,7 +430,6 @@ public class CreateWebsiteWizard extends BaseWizardBean
this.description = (String)props.get(ContentModel.PROP_DESCRIPTION); this.description = (String)props.get(ContentModel.PROP_DESCRIPTION);
this.dnsName = (String)props.get(WCMAppModel.PROP_AVMSTORE); this.dnsName = (String)props.get(WCMAppModel.PROP_AVMSTORE);
this.webapp = (String)props.get(WCMAppModel.PROP_DEFAULTWEBAPP); this.webapp = (String)props.get(WCMAppModel.PROP_DEFAULTWEBAPP);
this.deployTo = (List<String>)props.get(WCMAppModel.PROP_DEPLOYTO);
Boolean isSource = (Boolean)props.get(WCMAppModel.PROP_ISSOURCE); Boolean isSource = (Boolean)props.get(WCMAppModel.PROP_ISSOURCE);
if (isSource != null) if (isSource != null)
{ {
@@ -692,22 +685,6 @@ public class CreateWebsiteWizard extends BaseWizardBean
this.webapp = webapp; this.webapp = webapp;
} }
/**
* @return The comma separated list of servers to deploy to
*/
public List<String> getDeployTo()
{
return this.deployTo;
}
/**
* @param deployTo The comma separated list of servers to deploy to
*/
public void setDeployTo(List<String> deployTo)
{
this.deployTo = deployTo;
}
/** /**
* @return the create from selection value * @return the create from selection value
*/ */
@@ -863,19 +840,6 @@ public class CreateWebsiteWizard extends BaseWizardBean
return this.showAllSourceProjects; 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() * @see org.alfresco.web.bean.wizard.BaseWizardBean#next()
*/ */

View File

@@ -26,6 +26,7 @@ package org.alfresco.web.bean.wcm;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -35,11 +36,15 @@ import javax.faces.context.FacesContext;
import org.alfresco.model.WCMAppModel; import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.avm.actions.AVMDeploySnapshotAction; 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.Action;
import org.alfresco.service.cmr.action.ActionService; 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.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.alfresco.web.bean.dialog.BaseDialogBean;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@@ -53,10 +58,12 @@ public class DeploySnapshotDialog extends BaseDialogBean
{ {
protected int versionToDeploy; protected int versionToDeploy;
protected String[] deployTo; protected String[] deployTo;
protected String stagingStore;
protected NodeRef websiteRef; protected NodeRef websiteRef;
protected NodeRef webProjectRef; protected NodeRef webProjectRef;
protected AVMBrowseBean avmBrowseBean; protected AVMBrowseBean avmBrowseBean;
protected AVMService avmService;
protected ActionService actionService; protected ActionService actionService;
private static final Log logger = LogFactory.getLog(DeploySnapshotDialog.class); 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.versionToDeploy = Integer.parseInt(parameters.get("version"));
this.avmBrowseBean.getDeploymentMonitorIds().clear(); this.avmBrowseBean.getDeploymentMonitorIds().clear();
this.webProjectRef = this.avmBrowseBean.getWebsite().getNodeRef(); this.webProjectRef = this.avmBrowseBean.getWebsite().getNodeRef();
String stagingStore = AVMUtil.buildSandboxRootPath(this.avmBrowseBean.getStagingStore()); this.stagingStore = this.avmBrowseBean.getStagingStore();
this.websiteRef = AVMNodeConverter.ToNodeRef(this.versionToDeploy, stagingStore); String storeRoot = AVMUtil.buildSandboxRootPath(this.stagingStore);
this.websiteRef = AVMNodeConverter.ToNodeRef(this.versionToDeploy, storeRoot);
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("Initialising dialog to deploy version " + this.versionToDeploy + logger.debug("Initialising dialog to deploy version " + this.versionToDeploy +
@@ -86,94 +94,82 @@ public class DeploySnapshotDialog extends BaseDialogBean
@Override @Override
protected String finishImpl(FacesContext context, String outcome) throws Exception protected String finishImpl(FacesContext context, String outcome) throws Exception
{ {
// put all the selected servers to deploy to into a list
List<String> selectedDeployTo = new ArrayList<String>();
if (this.deployTo != null)
{
for (int x = 0; x < this.deployTo.length; x++)
{
selectedDeployTo.add(this.deployTo[x].trim());
}
}
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("Executing deployment of " + this.websiteRef.toString() + logger.debug("Requesting deployment of: " + this.websiteRef.toString());
" to servers: " + selectedDeployTo);
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(); NodeRef webProjectRef = this.avmBrowseBean.getWebsite().getNodeRef();
List<String> allDeployToServers = (List<String>)nodeService.getProperty(webProjectRef, List<String> selectedDeployToNames = new ArrayList<String>();
WCMAppModel.PROP_DEPLOYTO);
List<ChildAssociationRef> 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); // create a deploymentattempt node to represent this deployment
String attemptId = GUID.generate();
int version = -1; Map<QName, Serializable> props = new HashMap<QName, Serializable>(8, 1.0f);
Serializable snapshotObj = nodeService.getProperty(report, WCMAppModel.PROP_DEPLOYVERSION); props.put(WCMAppModel.PROP_DEPLOYATTEMPTID, attemptId);
if (snapshotObj != null && snapshotObj instanceof Integer) props.put(WCMAppModel.PROP_DEPLOYATTEMPTTYPE, WCMAppModel.CONSTRAINT_LIVESERVER);
{ props.put(WCMAppModel.PROP_DEPLOYATTEMPTSTORE, this.stagingStore);
version = (Integer)snapshotObj; props.put(WCMAppModel.PROP_DEPLOYATTEMPTVERSION, this.versionToDeploy);
} props.put(WCMAppModel.PROP_DEPLOYATTEMPTTIME, new Date());
NodeRef attempt = this.nodeService.createNode(webProjectRef,
if ((version == this.versionToDeploy && selectedDeployTo.contains(server)) || WCMAppModel.ASSOC_DEPLOYMENTATTEMPT, WCMAppModel.ASSOC_DEPLOYMENTATTEMPT,
(version != this.versionToDeploy) || (allDeployToServers.contains(server) == false)) WCMAppModel.TYPE_DEPLOYMENTATTEMPT, props).getChildRef();
{
// 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);
}
}
// 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);
// execute a deploy action for each of the selected remote servers asynchronously // 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) if (targetServer.length() > 0)
{ {
// create a deployment monitor object, store in the session, NodeRef serverRef = new NodeRef(targetServer);
// add to avm browse bean and pass to action if (nodeService.exists(serverRef))
DeploymentMonitor monitor = new DeploymentMonitor( {
this.websiteRef, targetServer, versionToDeploy); // get all properties of the target server
context.getExternalContext().getSessionMap().put(monitor.getId(), monitor); Map<QName, Serializable> serverProps = nodeService.getProperties(serverRef);
this.avmBrowseBean.getDeploymentMonitorIds().add(monitor.getId());
// create the action String serverUri = AVMDeploySnapshotAction.calculateServerUri(serverProps);
Map<String, Serializable> args = new HashMap<String, Serializable>(1, 1.0f); String serverName = (String)serverProps.get(WCMAppModel.PROP_DEPLOYSERVERNAME);
args.put(AVMDeploySnapshotAction.PARAM_WEBSITE, webProjectRef); if (serverName == null || serverName.length() == 0)
args.put(AVMDeploySnapshotAction.PARAM_TARGET_SERVER, targetServer); {
args.put(AVMDeploySnapshotAction.PARAM_DEFAULT_RMI_PORT, serverName = serverUri;
AVMUtil.getRemoteRMIRegistryPort()); }
args.put(AVMDeploySnapshotAction.PARAM_DEFAULT_RECEIVER_RMI_PORT,
AVMUtil.getRemoteReceiverRMIPort()); if (logger.isDebugEnabled())
args.put(AVMDeploySnapshotAction.PARAM_REMOTE_USERNAME, logger.debug("Issuing deployment request for: " + serverName);
AVMUtil.getRemoteDeploymentUsername());
args.put(AVMDeploySnapshotAction.PARAM_REMOTE_PASSWORD, // remember the servers deployed to
AVMUtil.getRemoteDeploymentPassword()); selectedDeployToNames.add(serverName);
args.put(AVMDeploySnapshotAction.PARAM_CALLBACK, monitor);
args.put(AVMDeploySnapshotAction.PARAM_DELAY, // create a deployment monitor object, store in the session,
AVMUtil.getRemoteDeploymentDelay()); // add to avm browse bean and pass to action
Action action = this.actionService.createAction(AVMDeploySnapshotAction.NAME, args); DeploymentMonitor monitor = new DeploymentMonitor(
this.actionService.executeAction(action, this.websiteRef, false, true); 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<String, Serializable> args = new HashMap<String, Serializable>(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 // close this dialog and immediately open the monitorDeployment dialog
return "dialog:monitorDeployment"; return "dialog:monitorDeployment";
} }
@@ -199,13 +195,21 @@ public class DeploySnapshotDialog extends BaseDialogBean
// Bean getters and setters // Bean getters and setters
/** /**
* @param avmBrowseBean The AVM BrowseBean to set * @param avmBrowseBean The AVM BrowseBean to set
*/ */
public void setAvmBrowseBean(AVMBrowseBean avmBrowseBean) public void setAvmBrowseBean(AVMBrowseBean avmBrowseBean)
{ {
this.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. * @param actionService The actionService to set.
*/ */

View File

@@ -46,7 +46,9 @@ public class DeploymentMonitor implements DeploymentCallback, Serializable
{ {
private String id; private String id;
private NodeRef website; private NodeRef website;
private String targetServer; private NodeRef targetServer;
private String targetServerName;
private String deployAttemptId;
private int snapshotVersion; private int snapshotVersion;
private boolean started = false; private boolean started = false;
private boolean finished = false; private boolean finished = false;
@@ -58,12 +60,15 @@ public class DeploymentMonitor implements DeploymentCallback, Serializable
/** /**
* Default constructor * 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.id = ID_PREFIX + Long.toString(System.currentTimeMillis()) + this.hashCode();
this.website = website; this.website = website;
this.targetServer = targetServer; this.targetServer = server;
this.snapshotVersion = snapshotVersion; this.snapshotVersion = snapshotVersion;
this.targetServerName = serverName;
this.deployAttemptId = deployAttemptId;
} }
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
@@ -86,7 +91,7 @@ public class DeploymentMonitor implements DeploymentCallback, Serializable
} }
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug(this.targetServer + ": " + event.getType() + logger.debug(this.targetServerName + ": " + event.getType() +
" " + event.getDestination()); " " + event.getDestination());
} }
@@ -98,7 +103,7 @@ public class DeploymentMonitor implements DeploymentCallback, Serializable
public void errorOccurred(Throwable err) public void errorOccurred(Throwable err)
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug(this.targetServer + ": ERROR: " + err.getMessage()); logger.debug(this.targetServerName + ": ERROR: " + err.getMessage());
this.successful = false; this.successful = false;
this.finished = true; this.finished = true;
@@ -111,7 +116,9 @@ public class DeploymentMonitor implements DeploymentCallback, Serializable
buffer.append(" (id=").append(this.id); buffer.append(" (id=").append(this.id);
buffer.append(" website=").append(this.website); buffer.append(" website=").append(this.website);
buffer.append(" targetServer=").append(this.targetServer); buffer.append(" targetServer=").append(this.targetServer);
buffer.append(" targetServerName=").append(this.targetServerName);
buffer.append(" snapshotVersion=").append(this.snapshotVersion); buffer.append(" snapshotVersion=").append(this.snapshotVersion);
buffer.append(" deployAttemptId=").append(this.deployAttemptId);
buffer.append(" started=").append(this.started); buffer.append(" started=").append(this.started);
buffer.append(" finished=").append(this.finished); buffer.append(" finished=").append(this.finished);
buffer.append(" successful=").append(this.successful).append(")"); buffer.append(" successful=").append(this.successful).append(")");
@@ -123,7 +130,11 @@ public class DeploymentMonitor implements DeploymentCallback, Serializable
StringBuilder buffer = new StringBuilder("<target-server id=\""); StringBuilder buffer = new StringBuilder("<target-server id=\"");
buffer.append(this.getId()); buffer.append(this.getId());
buffer.append("\" name=\""); buffer.append("\" name=\"");
buffer.append(this.targetServerName);
buffer.append("\" server=\"");
buffer.append(this.targetServer); buffer.append(this.targetServer);
buffer.append("\" attempt=\"");
buffer.append(this.deployAttemptId);
buffer.append("\" finished=\""); buffer.append("\" finished=\"");
buffer.append(this.finished); buffer.append(this.finished);
buffer.append("\""); buffer.append("\"");
@@ -159,11 +170,19 @@ public class DeploymentMonitor implements DeploymentCallback, Serializable
/** /**
* @return The target server for this deployment * @return The target server for this deployment
*/ */
public String getTargetServer() public NodeRef getTargetServer()
{ {
return this.targetServer; return this.targetServer;
} }
/**
* @return The target server display name for this deployment
*/
public String getTargetServerName()
{
return this.targetServerName;
}
/** /**
* @return The snapshot version being deployed * @return The snapshot version being deployed
*/ */
@@ -172,6 +191,14 @@ public class DeploymentMonitor implements DeploymentCallback, Serializable
return this.snapshotVersion; return this.snapshotVersion;
} }
/**
* @return The deploy attempt id for this deployment
*/
public String getDeployAttemptId()
{
return this.deployAttemptId;
}
/** /**
* @return true if the deployment has started * @return true if the deployment has started
*/ */

View File

@@ -24,7 +24,6 @@
*/ */
package org.alfresco.web.bean.wcm; package org.alfresco.web.bean.wcm;
import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -85,7 +84,6 @@ public class EditWebsiteWizard extends CreateWebsiteWizard
this.nodeService.setProperty(nodeRef, ContentModel.PROP_NAME, this.name); this.nodeService.setProperty(nodeRef, ContentModel.PROP_NAME, this.name);
this.nodeService.setProperty(nodeRef, ContentModel.PROP_TITLE, this.title); this.nodeService.setProperty(nodeRef, ContentModel.PROP_TITLE, this.title);
this.nodeService.setProperty(nodeRef, ContentModel.PROP_DESCRIPTION, this.description); this.nodeService.setProperty(nodeRef, ContentModel.PROP_DESCRIPTION, this.description);
this.nodeService.setProperty(nodeRef, WCMAppModel.PROP_DEPLOYTO, (Serializable)this.deployTo);
this.nodeService.setProperty(nodeRef, WCMAppModel.PROP_ISSOURCE, this.isSource); this.nodeService.setProperty(nodeRef, WCMAppModel.PROP_ISSOURCE, this.isSource);
// clear the existing settings for forms, template and workflows - then the existing methods // clear the existing settings for forms, template and workflows - then the existing methods

View File

@@ -26,7 +26,6 @@ package org.alfresco.web.ui.wcm.component;
import java.io.IOException; import java.io.IOException;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -37,9 +36,11 @@ import javax.faces.el.ValueBinding;
import javax.transaction.UserTransaction; import javax.transaction.UserTransaction;
import org.alfresco.model.WCMAppModel; import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.avm.actions.AVMDeploySnapshotAction;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.Repository;
@@ -140,6 +141,8 @@ public class UIDeployWebsite extends UIInput
throw new IllegalArgumentException("The web project must be specified."); throw new IllegalArgumentException("The web project must be specified.");
} }
NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
// add some before the panels // add some before the panels
out.write("\n<div style='padding-top:4px;'></div>\n"); out.write("\n<div style='padding-top:4px;'></div>\n");
@@ -172,13 +175,14 @@ public class UIDeployWebsite extends UIInput
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("Found deployment monitor: " + monitor); logger.debug("Found deployment monitor: " + monitor);
renderServer(context, out, monitor.getTargetServer(), false, true, id); renderServer(context, out, nodeService, monitor.getTargetServer(), false, true, id);
} }
} }
} }
else else
{ {
// get a list of the servers that have been successfully deployed to // get a list of the servers that have been successfully deployed to
/*
NodeService nodeService = Repository.getServiceRegistry(context).getNodeService(); NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
int deployingVersion = this.getSnapshotVersion(); int deployingVersion = this.getSnapshotVersion();
List<String> serversAlreadyDeployed = new ArrayList<String>(); List<String> serversAlreadyDeployed = new ArrayList<String>();
@@ -207,21 +211,18 @@ public class UIDeployWebsite extends UIInput
} }
} }
} }
*/
// get the list of servers for the user to select from // get the servers available to deploy to
List<String> servers = (List<String>)nodeService.getProperty(webProject, List<ChildAssociationRef> deployServerRefs = nodeService.getChildAssocs(
WCMAppModel.PROP_DEPLOYTO); webProjectRef, WCMAppModel.ASSOC_DEPLOYMENTSERVER, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef ref : deployServerRefs)
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)
{ {
boolean preSelected = !serversAlreadyDeployed.contains(server); NodeRef server = ref.getChildRef();
renderServer(context, out, server, preSelected, false, null);
// 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("</script>\n"); out.write("</script>\n");
} }
private void renderServer(FacesContext context, ResponseWriter out, String server, private void renderServer(FacesContext context, ResponseWriter out, NodeService nodeService,
boolean selected, boolean monitoring, String monitorId) throws IOException NodeRef server, boolean selected, boolean monitoring, String monitorId)
throws IOException
{ {
String contextPath = context.getExternalContext().getRequestContextPath(); String contextPath = context.getExternalContext().getRequestContextPath();
Map<QName, Serializable> props = nodeService.getProperties(server);
String serverName = (String)props.get(WCMAppModel.PROP_DEPLOYSERVERNAME);
if (serverName == null || serverName.length() == 0)
{
serverName = AVMDeploySnapshotAction.calculateServerUri(props);
}
out.write("<table cellspacing='0' cellpadding='0' border='0' width='100%'>"); out.write("<table cellspacing='0' cellpadding='0' border='0' width='100%'>");
out.write("<tr><td width='10'><img src='"); out.write("<tr><td width='10'><img src='");
out.write(contextPath); out.write(contextPath);
@@ -455,7 +464,7 @@ public class UIDeployWebsite extends UIInput
out.write("<input type='checkbox' name='"); out.write("<input type='checkbox' name='");
out.write(this.getClientId(context)); out.write(this.getClientId(context));
out.write("' value='"); out.write("' value='");
out.write(server); out.write(server.toString());
out.write("'"); out.write("'");
if (selected) if (selected)
{ {
@@ -477,7 +486,7 @@ public class UIDeployWebsite extends UIInput
out.write(contextPath); out.write(contextPath);
out.write("/images/parts/deploy_panel_bg.gif); background-repeat: repeat-x; width: 100%;'>"); out.write("/images/parts/deploy_panel_bg.gif); background-repeat: repeat-x; width: 100%;'>");
out.write("<div class='deployPanelServerName'>"); out.write("<div class='deployPanelServerName'>");
out.write(server); out.write(serverName);
out.write("</div>"); out.write("</div>");
if (monitoring) if (monitoring)
{ {

View File

@@ -36,6 +36,9 @@ import javax.transaction.UserTransaction;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMAppModel; 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.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService; 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.service.namespace.RegexQNamePattern;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository; 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.PanelGenerator;
import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.SelfRenderingComponent; import org.alfresco.web.ui.common.component.SelfRenderingComponent;
@@ -117,22 +121,47 @@ public class UIDeploymentReports extends SelfRenderingComponent
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("Rendering deployment reports for: " + webProject.toString()); 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(); NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
ContentService contentService = Repository.getServiceRegistry(context).getContentService(); ContentService contentService = Repository.getServiceRegistry(context).getContentService();
List<ChildAssociationRef> deployReportRefs = nodeService.getChildAssocs( AVMService avmService = Repository.getServiceRegistry(context).getAVMService();
this.webProjectRef, WCMAppModel.ASSOC_DEPLOYMENTREPORT, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef ref : deployReportRefs) 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 attemptId = val.getStringValue();
renderReport(context, out, ref.getChildRef(), nodeService, contentService);
} }
// add some padding after the panels if (attemptId == null || attemptId.length() == 0)
out.write("\n<div style='padding-top:8px;'></div>\n"); {
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<ChildAssociationRef> 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<div style='padding-top:8px;'></div>\n");
}
tx.commit(); tx.commit();
} }

View File

@@ -42,6 +42,8 @@ import javax.faces.el.ValueBinding;
import javax.transaction.UserTransaction; import javax.transaction.UserTransaction;
import org.alfresco.model.WCMAppModel; 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.AVMService;
import org.alfresco.service.cmr.avm.VersionDescriptor; import org.alfresco.service.cmr.avm.VersionDescriptor;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
@@ -205,7 +207,7 @@ public class UISandboxSnapshots extends SelfRenderingComponent
{ {
final Calendar c = Calendar.getInstance(); final Calendar c = Calendar.getInstance();
c.setTime(toDate); c.setTime(toDate);
c.set(Calendar.HOUR, 0); c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0); c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0); c.set(Calendar.SECOND, 0);
fromDate = c.getTime(); fromDate = c.getTime();
@@ -229,15 +231,15 @@ public class UISandboxSnapshots extends SelfRenderingComponent
boolean showDeployAction = false; boolean showDeployAction = false;
NodeRef webProjectRef = AVMUtil.getWebProjectNodeFromStore(sandbox); NodeRef webProjectRef = AVMUtil.getWebProjectNodeFromStore(sandbox);
NodeService nodeService = Repository.getServiceRegistry(context).getNodeService(); NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
List<String> deployToServers = (List<String>)nodeService.getProperty(webProjectRef, List<ChildAssociationRef> deployToServers = nodeService.getChildAssocs(
WCMAppModel.PROP_DEPLOYTO); webProjectRef, WCMAppModel.ASSOC_DEPLOYMENTSERVER, RegexQNamePattern.MATCH_ALL);
if (deployToServers != null && deployToServers.size() > 0) if (deployToServers != null && deployToServers.size() > 0)
{ {
showDeployAction = true; showDeployAction = true;
} }
// determine the deployment status for the website // determine the deployment status for the website
determineDeploymentStatus(context, webProjectRef, sandbox, nodeService); determineDeploymentStatus(context, webProjectRef, sandbox, nodeService, avmService);
Map requestMap = context.getExternalContext().getRequestMap(); Map requestMap = context.getExternalContext().getRequestMap();
for (int i=versions.size() - 1; i >= 0; i--) // reverse order 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 * @return UIActionLink component if found, else null if not created yet
*/ */
@SuppressWarnings("unchecked")
private UIActionLink findAction(String name, String sandbox) private UIActionLink findAction(String name, String sandbox)
{ {
UIActionLink action = null; UIActionLink action = null;
@@ -411,6 +414,7 @@ public class UISandboxSnapshots extends SelfRenderingComponent
* *
* @return UIActionLink child component * @return UIActionLink child component
*/ */
@SuppressWarnings("unchecked")
private UIActionLink createAction(FacesContext fc, String sandbox, String name, String icon, private UIActionLink createAction(FacesContext fc, String sandbox, String name, String icon,
String actionListener, String outcome, String url, Map<String, String> params) String actionListener, String outcome, String url, Map<String, String> params)
{ {
@@ -478,87 +482,89 @@ public class UISandboxSnapshots extends SelfRenderingComponent
return control; return control;
} }
@SuppressWarnings("unchecked")
private void determineDeploymentStatus(FacesContext context, NodeRef webProjectRef, 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 // if the store property holding the last deployment id is non null a
List<String> selectedServers = (List<String>)nodeService.getProperty(webProjectRef, // deployment has been attempted
WCMAppModel.PROP_SELECTEDDEPLOYTO); PropertyValue val = avmService.getStoreProperty(sandbox, SandboxConstants.PROP_LAST_DEPLOYMENT_ID);
Integer ver = (Integer)nodeService.getProperty(webProjectRef, String attemptId = null;
WCMAppModel.PROP_SELECTEDDEPLOYVERSION);
if (ver != null) if (val != null)
{ {
this.deployAttemptVersion = ver.intValue(); attemptId = val.getStringValue();
}
if (selectedServers != null && selectedServers.size() > 0) // get the latest deployment attempt
{ NodeRef attempt = AVMUtil.findDeploymentAttempt(attemptId);
// if the 'selecteddeployto' property is set a deployment has been attempted if (attempt != null)
List<ChildAssociationRef> deployReportRefs = nodeService.getChildAssocs(
webProjectRef, WCMAppModel.ASSOC_DEPLOYMENTREPORT, RegexQNamePattern.MATCH_ALL);
List<String> deployedServers = new ArrayList<String>();
boolean oneOrMoreFailed = false;
boolean allFailed = true;
for (ChildAssociationRef ref : deployReportRefs)
{ {
NodeRef report = ref.getChildRef(); // retrieve the snapshot deployed
Integer ver = (Integer)nodeService.getProperty(attempt,
// get the name of the server and the deploy outcome WCMAppModel.PROP_DEPLOYATTEMPTVERSION);
String serverName = (String)nodeService.getProperty(report, if (ver != null)
WCMAppModel.PROP_DEPLOYSERVER);
Boolean successful = (Boolean)nodeService.getProperty(report,
WCMAppModel.PROP_DEPLOYSUCCESSFUL);
deployedServers.add(serverName);
if (successful != null)
{ {
if (successful.booleanValue()) this.deployAttemptVersion = ver.intValue();
}
// determine if all required reports are present
List<String> selectedServers = (List<String>)nodeService.getProperty(
attempt, WCMAppModel.PROP_DEPLOYATTEMPTSERVERS);
int numServersSelected = 0;
if (selectedServers != null)
{
numServersSelected = selectedServers.size();
List<ChildAssociationRef> 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 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");
}
} }
} }

View File

@@ -4044,6 +4044,10 @@
<property-name>avmBrowseBean</property-name> <property-name>avmBrowseBean</property-name>
<value>#{AVMBrowseBean}</value> <value>#{AVMBrowseBean}</value>
</managed-property> </managed-property>
<managed-property>
<property-name>avmService</property-name>
<value>#{AVMLockingAwareService}</value>
</managed-property>
<managed-property> <managed-property>
<property-name>actionService</property-name> <property-name>actionService</property-name>
<value>#{ActionService}</value> <value>#{ActionService}</value>

View File

@@ -144,29 +144,6 @@
<f:verbatim> <f:verbatim>
</td> </td>
</tr> </tr>
<tr>
<td></td>
<td valign="top">
</f:verbatim>
<h:outputText value="#{msg.website_deployto}:"/>
<f:verbatim>
</td>
<td>
</f:verbatim>
<h:inputText id="server" value="#{WizardManager.bean.deployTo}" size="45" maxlength="256">
<a:convertMultiValue />
</h:inputText>
<h:graphicImage id="deploy-to-help-img"
value="/images/icons/Help_icon.gif" style="cursor:help; padding-left: 4px; vertical-align: -4px;"
onclick="javascript:toggleDeployToHelp()" />
<f:verbatim>
<div id="deploy-to-help" class="summary infoText statusInfoText" style="display:none; padding:5px;">
</f:verbatim>
<h:outputText id="deploy-top-help-text" value="#{WizardManager.bean.deployToHelp}" escape="false" />
<f:verbatim>
</div>
</td>
</tr>
<tr> <tr>
<td></td> <td></td>
<td> <td>