mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -26,7 +26,6 @@ package org.alfresco.web.ui.wcm.component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -37,9 +36,11 @@ import javax.faces.el.ValueBinding;
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
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.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
import org.alfresco.web.app.Application;
|
||||
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.");
|
||||
}
|
||||
|
||||
NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
|
||||
|
||||
// add some before the panels
|
||||
out.write("\n<div style='padding-top:4px;'></div>\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<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
|
||||
List<String> servers = (List<String>)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<ChildAssociationRef> 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("</script>\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<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("<tr><td width='10'><img src='");
|
||||
out.write(contextPath);
|
||||
@@ -455,7 +464,7 @@ public class UIDeployWebsite extends UIInput
|
||||
out.write("<input type='checkbox' name='");
|
||||
out.write(this.getClientId(context));
|
||||
out.write("' value='");
|
||||
out.write(server);
|
||||
out.write(server.toString());
|
||||
out.write("'");
|
||||
if (selected)
|
||||
{
|
||||
@@ -477,7 +486,7 @@ public class UIDeployWebsite extends UIInput
|
||||
out.write(contextPath);
|
||||
out.write("/images/parts/deploy_panel_bg.gif); background-repeat: repeat-x; width: 100%;'>");
|
||||
out.write("<div class='deployPanelServerName'>");
|
||||
out.write(server);
|
||||
out.write(serverName);
|
||||
out.write("</div>");
|
||||
if (monitoring)
|
||||
{
|
||||
|
@@ -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<ChildAssociationRef> 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<div style='padding-top:8px;'></div>\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<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();
|
||||
}
|
||||
|
@@ -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<String> deployToServers = (List<String>)nodeService.getProperty(webProjectRef,
|
||||
WCMAppModel.PROP_DEPLOYTO);
|
||||
List<ChildAssociationRef> 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<String, String> 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<String> selectedServers = (List<String>)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<ChildAssociationRef> deployReportRefs = nodeService.getChildAssocs(
|
||||
webProjectRef, WCMAppModel.ASSOC_DEPLOYMENTREPORT, RegexQNamePattern.MATCH_ALL);
|
||||
attemptId = val.getStringValue();
|
||||
|
||||
List<String> deployedServers = new ArrayList<String>();
|
||||
|
||||
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<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
|
||||
{
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user