Merged V2.2 to HEAD

7462: Renamed ManageLinkValidationTaskDialog to ManageReviewTaskDialog as it is now more generic
         Enabled deployment and link validation in parallel review tasks
         Created separate JSP page for manage change request task dialog
         When a server is edited it is now scrolled to
         Some minor UI tidyup
   7467: Added ability to define excludes for a deployment via a regular expression
   7475: Incorporated new icons from Linton
   7492: Allows multiple callbacks for deployment. Adds new FAILED deployment event.
   7493: Added ability to view previous deployment attempts


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8380 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2008-02-26 14:19:37 +00:00
parent 6ce387a808
commit 4780da35d5
22 changed files with 6555 additions and 5687 deletions

View File

@@ -29,7 +29,10 @@ import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
import javax.faces.component.UIComponent;
import javax.faces.component.UIParameter;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.el.ValueBinding;
@@ -51,9 +54,12 @@ 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.DeploymentUtil;
import org.alfresco.web.ui.common.ComponentConstants;
import org.alfresco.web.ui.common.PanelGenerator;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.SelfRenderingComponent;
import org.alfresco.web.ui.common.component.UIActionLink;
import org.alfresco.web.ui.repo.component.UIActions;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.util.StringUtils;
@@ -65,7 +71,22 @@ import org.springframework.util.StringUtils;
*/
public class UIDeploymentReports extends SelfRenderingComponent
{
// date filters
public static final String FILTER_DATE_TODAY = "today";
public static final String FILTER_DATE_YESTERDAY = "yesterday";
public static final String FILTER_DATE_WEEK = "week";
public static final String FILTER_DATE_MONTH = "month";
public static final String FILTER_DATE_ALL = "all";
protected String store;
protected String dateFilter;
protected Boolean showPrevious;
protected NodeRef attempt;
private static final String MSG_ATTEMPT_DATE = "deploy_attempt_date";
private static final String MSG_SERVERS = "deployed_to_servers";
private static final String MSG_SNAPSHOT = "snapshot";
private static final String MSG_SELECT_ATTEMPT = "select_deploy_attempt";
private static Log logger = LogFactory.getLog(UIDeploymentReports.class);
@@ -86,14 +107,20 @@ public class UIDeploymentReports extends SelfRenderingComponent
// standard component attributes are restored by the super class
super.restoreState(context, values[0]);
this.store = (String)values[1];
this.dateFilter = (String)values[2];
this.showPrevious = (Boolean)values[3];
this.attempt = (NodeRef)values[4];
}
public Object saveState(FacesContext context)
{
Object values[] = new Object[2];
Object values[] = new Object[5];
// standard component attributes are saved by the super class
values[0] = super.saveState(context);
values[1] = this.store;
values[2] = this.dateFilter;
values[3] = this.showPrevious;
values[4] = this.attempt;
return values;
}
@@ -121,50 +148,14 @@ public class UIDeploymentReports extends SelfRenderingComponent
throw new IllegalArgumentException("The store must be specified.");
}
if (logger.isDebugEnabled())
logger.debug("Rendering deployment reports for store: " + storeName);
NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
ContentService contentService = Repository.getServiceRegistry(context).getContentService();
AVMService avmService = Repository.getServiceRegistry(context).getAVMService();
PropertyValue val = avmService.getStoreProperty(storeName, SandboxConstants.PROP_LAST_DEPLOYMENT_ID);
String attemptId = null;
if (val != null)
boolean showPrevious = getShowPrevious();
if (showPrevious)
{
attemptId = val.getStringValue();
renderPreviousReports(context, out, storeName);
}
if (attemptId == null || attemptId.length() == 0)
else
{
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 = DeploymentUtil.findDeploymentAttempt(attemptId);
if (attempt != null)
{
// render the supporting JavaScript
out.write("<script type='text/javascript' src='");
out.write(context.getExternalContext().getRequestContextPath());
out.write("/scripts/ajax/deployment.js'></script>\n");
// 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");
renderAttempt(context, out, storeName);
}
tx.commit();
@@ -201,10 +192,262 @@ public class UIDeploymentReports extends SelfRenderingComponent
this.store = value;
}
/**
* @return The current dateFilter if previous reports are being shown
*/
public String getDateFilter()
{
ValueBinding vb = getValueBinding("dateFilter");
if (vb != null)
{
this.dateFilter = (String)vb.getValue(getFacesContext());
}
return this.dateFilter;
}
/**
* @param value The dateFilter to use when previous reports are being shown
*/
public void setDateFilter(String value)
{
this.dateFilter = value;
}
/**
* @return true if the component should show previous reports
*/
public boolean getShowPrevious()
{
ValueBinding vb = getValueBinding("showPrevious");
if (vb != null)
{
this.showPrevious = (Boolean)vb.getValue(getFacesContext());
}
if (this.showPrevious == null)
{
this.showPrevious = Boolean.FALSE;
}
return this.showPrevious.booleanValue();
}
/**
* @param showPrevious Determines whether previous reports are shown
*/
public void setShowPrevious(boolean showPrevious)
{
this.showPrevious = new Boolean(showPrevious);
}
/**
* @return NodeRef of the deploymentattempt to show the details for
*/
public NodeRef getAttempt()
{
ValueBinding vb = getValueBinding("attempt");
if (vb != null)
{
this.attempt = (NodeRef)vb.getValue(getFacesContext());
}
return this.attempt;
}
/**
* @param value The NodeRef of the deploymentattempt to show the details for
*/
public void setAttempt(NodeRef value)
{
this.attempt = value;
}
// ------------------------------------------------------------------------------
// Helpers
private void renderReport(FacesContext context, ResponseWriter out, NodeRef deploymentReport,
@SuppressWarnings("unchecked")
protected void renderPreviousReports(FacesContext context, ResponseWriter out, String store)
throws IOException
{
NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
ResourceBundle bundle = Application.getBundle(context);
List<NodeRef> deployAttempts = null;
String dateFilter = getDateFilter();
if (logger.isDebugEnabled())
logger.debug("Rendering previous deployment reports for store '" + store +
"' using dateFilter: " + dateFilter);
if (dateFilter == null || dateFilter.equals(FILTER_DATE_ALL))
{
deployAttempts = DeploymentUtil.findDeploymentAttempts(store);
}
else
{
// get today's date
Date toDate = new Date();
// calculate the from date
Date fromDate;
if (FILTER_DATE_TODAY.equals(dateFilter))
{
fromDate = toDate;
}
else if (FILTER_DATE_YESTERDAY.equals(dateFilter))
{
fromDate = new Date(toDate.getTime() - (1000L*60L*60L*24L));
toDate = fromDate;
}
else if (FILTER_DATE_WEEK.equals(dateFilter))
{
fromDate = new Date(toDate.getTime() - (1000L*60L*60L*24L*7L));
}
else if (FILTER_DATE_MONTH.equals(dateFilter))
{
fromDate = new Date(toDate.getTime() - (1000L*60L*60L*24L*30L));
}
else
{
throw new IllegalArgumentException("Unknown date filter mode: " + dateFilter);
}
// get the filtered list of attempts
deployAttempts = DeploymentUtil.findDeploymentAttempts(store, fromDate, toDate);
}
if (deployAttempts.size() > 0)
{
out.write("<table class='deployMoreReportsList' cellspacing='3' cellpadding='3' width='100%'>");
out.write("<tr><th align='left'><nobr>");
out.write(bundle.getString(MSG_ATTEMPT_DATE));
out.write("</nobr></th><th align='left'><nobr>");
out.write(bundle.getString(MSG_SERVERS));
out.write("</nobr></th><th align='left'><nobr>");
out.write(bundle.getString(MSG_SNAPSHOT));
out.write("</th></tr>");
for (NodeRef attempt : deployAttempts)
{
Map<QName, Serializable> props = nodeService.getProperties(attempt);
String attemptId = (String)props.get(WCMAppModel.PROP_DEPLOYATTEMPTID);
Date attemptTime = (Date)props.get(WCMAppModel.PROP_DEPLOYATTEMPTTIME);
Integer version = (Integer)props.get(WCMAppModel.PROP_DEPLOYATTEMPTVERSION);
List<String> servers = (List<String>)props.get(WCMAppModel.PROP_DEPLOYATTEMPTSERVERS);
StringBuilder buffer = new StringBuilder();
if (servers != null)
{
for (String server : servers)
{
if (buffer.length() != 0)
{
buffer.append(", ");
}
buffer.append(server);
}
}
// format the date using the default pattern
String attemptDate = Utils.getDateTimeFormat(context).format(attemptTime);
out.write("<tr><td><nobr>");
Utils.encodeRecursive(context,
aquireViewAttemptAction(context, attemptId, attempt, attemptDate));
out.write("</nobr></td><td>");
out.write(buffer.toString());
out.write("</td><td>");
if (version != null)
{
out.write(version.toString());
}
out.write("</td></tr>");
}
out.write("</table>");
}
else
{
out.write("<div class='deployServersInfo'>");
out.write(Application.getMessage(context, "no_deploy_attempts"));
out.write("</div>\n");
}
}
protected void renderAttempt(FacesContext context, ResponseWriter out, String store)
throws IOException
{
// get services required
NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
ContentService contentService = Repository.getServiceRegistry(context).getContentService();
AVMService avmService = Repository.getServiceRegistry(context).getAVMService();
// get the attempt node to show (if any)
NodeRef attempt = getAttempt();
if (attempt == null)
{
if (logger.isDebugEnabled())
logger.debug("Rendering last deployment report for store: " + store);
// get the last deployment attempt id, then locate the deploymentattempt node
PropertyValue val = avmService.getStoreProperty(store, SandboxConstants.PROP_LAST_DEPLOYMENT_ID);
String attemptId = null;
if (val != null)
{
attemptId = val.getStringValue();
}
if (attemptId == null || attemptId.length() == 0)
{
throw new IllegalStateException("Failed to retrieve deployment attempt id");
}
if (logger.isDebugEnabled())
logger.debug("Retrieving deploymentattempt node with attempt id: " + attemptId);
// get the deploymentattempt object
attempt = DeploymentUtil.findDeploymentAttempt(attemptId);
}
// if we have an attempt node, render it
if (attempt != null)
{
if (logger.isDebugEnabled())
logger.debug("Rendering deployment reports for attempt: " + attempt);
// render the supporting JavaScript
out.write("<script type='text/javascript' src='");
out.write(context.getExternalContext().getRequestContextPath());
out.write("/scripts/ajax/deployment.js'></script>\n");
// iterate through each deployment report
List<ChildAssociationRef> deployReportRefs = nodeService.getChildAssocs(
attempt, WCMAppModel.ASSOC_DEPLOYMENTREPORTS, RegexQNamePattern.MATCH_ALL);
if (deployReportRefs.size() > 0)
{
for (ChildAssociationRef ref : deployReportRefs)
{
// render each report
renderReport(context, out, ref.getChildRef(), nodeService, contentService);
}
}
else
{
out.write("<div class='deployInProgress'><img src='");
out.write(context.getExternalContext().getRequestContextPath());
out.write("/images/icons/info_icon_large.gif' />&nbsp;");
out.write(Application.getMessage(context, "no_deploy_reports"));
out.write("</div>\n");
}
// add some padding after the panels
out.write("\n<div style='padding-top:12px;'></div>\n");
}
}
protected void renderReport(FacesContext context, ResponseWriter out, NodeRef deploymentReport,
NodeService nodeService, ContentService contentService)
throws IOException
{
@@ -260,6 +503,7 @@ public class UIDeploymentReports extends SelfRenderingComponent
String username = (String)serverProps.get(WCMAppModel.PROP_DEPLOYSERVERUSERNAMEUSED);
String source = (String)serverProps.get(WCMAppModel.PROP_DEPLOYSOURCEPATHUSED);
String target = (String)serverProps.get(WCMAppModel.PROP_DEPLOYSERVERTARGETUSED);
String excludes = (String)serverProps.get(WCMAppModel.PROP_DEPLOYEXCLUDESUSED);
String failReason = (String)serverProps.get(WCMAppModel.PROP_DEPLOYFAILEDREASON);
String content = "";
@@ -374,6 +618,15 @@ public class UIDeploymentReports extends SelfRenderingComponent
out.write("</div>");
}
if (excludes != null)
{
out.write("<div style='margin-top: 3px;'>");
out.write(Application.getMessage(context, "deploy_server_excludes"));
out.write(":&nbsp;");
out.write(excludes);
out.write("</div>");
}
if (target != null)
{
out.write("<div style='margin-top: 3px;'>");
@@ -416,4 +669,53 @@ public class UIDeploymentReports extends SelfRenderingComponent
PanelGenerator.generatePanelEnd(out,
context.getExternalContext().getRequestContextPath(), "lightstorm");
}
@SuppressWarnings("unchecked")
protected UIActionLink aquireViewAttemptAction(FacesContext context,
String attemptId, NodeRef attemptRef, String attemptDate)
{
UIActionLink action = null;
String actionId = "va_" + attemptId;
// try find the action as a child of this component
for (UIComponent component : (List<UIComponent>)getChildren())
{
if (actionId.equals(component.getId()))
{
action = (UIActionLink)component;
break;
}
}
if (action == null)
{
// create the action and add as a child component
javax.faces.application.Application facesApp = context.getApplication();
action = (UIActionLink)facesApp.createComponent(UIActions.COMPONENT_ACTIONLINK);
action.setId(actionId);
action.setValue(attemptDate);
action.setTooltip(Application.getMessage(context, MSG_SELECT_ATTEMPT));
action.setShowLink(true);
action.setActionListener(facesApp.createMethodBinding(
"#{DialogManager.bean.attemptSelected}", UIActions.ACTION_CLASS_ARGS));
// add attemptRef param
UIParameter param1 = (UIParameter)facesApp.createComponent(ComponentConstants.JAVAX_FACES_PARAMETER);
param1.setId(actionId + "_1");
param1.setName("attemptRef");
param1.setValue(attemptRef.toString());
action.getChildren().add(param1);
// add attemptDate param
UIParameter param2 = (UIParameter)facesApp.createComponent(ComponentConstants.JAVAX_FACES_PARAMETER);
param2.setId(actionId + "_2");
param2.setName("attemptDate");
param2.setValue(attemptDate);
action.getChildren().add(param2);
this.getChildren().add(action);
}
return action;
}
}

View File

@@ -75,6 +75,7 @@ public class UIDeploymentServers extends UIInput
private static final String MSG_ALLOCATED = "deploy_server_allocated";
private static final String MSG_SOURCE = "deploy_server_source_path";
private static final String MSG_TARGET = "deploy_server_target_name";
private static final String MSG_EXCLUDES = "deploy_server_excludes";
private static final String MSG_AUTO_DEPLOY = "deploy_automatically";
private static final String MSG_EDIT = "edit_deploy_server";
private static final String MSG_DELETE = "delete_deploy_server";
@@ -189,8 +190,14 @@ public class UIDeploymentServers extends UIInput
out.write("</div>");
out.write("\n<script type='text/javascript'>");
out.write("window.onload=Alfresco.checkDeployConfigPage();");
out.write("</script>");
out.write("window.onload=Alfresco.checkDeployConfigPage();\n");
if (currentServer != null)
{
out.write("Alfresco.scrollToEditServer('");
out.write(currentServer.getId());
out.write("');\n");
}
out.write("</script>\n");
tx.commit();
}
@@ -334,7 +341,7 @@ public class UIDeploymentServers extends UIInput
out.write("</div></td></tr>");
out.write("<tr><td colspan='3'>");
out.write("<table cellpadding='0' cellspacing='0'>");
out.write("<tr><td><table cellpadding='3' cellspacing='0' class='deployConfigServerDetailsLeftCol'>");
out.write("<tr><td width='100%'><table cellpadding='3' cellspacing='0' class='deployConfigServerDetailsLeftCol'>");
out.write("<tr><td align='right'>");
out.write(bundle.getString(MSG_HOST));
out.write(":</td><td>");
@@ -389,20 +396,29 @@ public class UIDeploymentServers extends UIInput
out.write("</td></tr></table></td>");
out.write("<td valign='top'><table cellpadding='3' cellspacing='0' class='deployConfigServerDetailsRightCol'>");
out.write("<tr><td align='right'>");
out.write("<tr><td align='right'><nobr>");
out.write(bundle.getString(MSG_SOURCE));
out.write(":</td><td>");
out.write(":</nobr></td><td>");
if (server.getProperties().get(DeploymentServerConfig.PROP_SOURCE_PATH) != null)
{
out.write((String)server.getProperties().get(DeploymentServerConfig.PROP_SOURCE_PATH));
}
out.write("</td></tr>");
out.write("<tr><td align='right'><nobr>");
out.write(bundle.getString(MSG_EXCLUDES));
out.write(":</nobr></td><td>");
if (server.getProperties().get(DeploymentServerConfig.PROP_EXCLUDES) != null)
{
out.write((String)server.getProperties().get(DeploymentServerConfig.PROP_EXCLUDES));
}
out.write("</td></tr>");
if (WCMAppModel.CONSTRAINT_FILEDEPLOY.equals(server.getDeployType()))
{
out.write("<tr><td align='right'>");
out.write("<tr><td align='right'><nobr>");
out.write(bundle.getString(MSG_TARGET));
out.write(":</td><td>");
out.write(":</nobr></td><td>");
if (server.getProperties().get(DeploymentServerConfig.PROP_TARGET_NAME) != null)
{
out.write((String)server.getProperties().get(DeploymentServerConfig.PROP_TARGET_NAME));
@@ -413,9 +429,9 @@ public class UIDeploymentServers extends UIInput
if (WCMAppModel.CONSTRAINT_LIVESERVER.equals(
server.getProperties().get(DeploymentServerConfig.PROP_TYPE)))
{
out.write("<tr><td align='right'>");
out.write("<tr><td align='right'><nobr>");
out.write(bundle.getString(MSG_AUTO_DEPLOY));
out.write(":</td><td>");
out.write(":</nobr></td><td>");
if (server.getProperties().get(DeploymentServerConfig.PROP_ON_APPROVAL) != null)
{
Object obj = server.getProperties().get(DeploymentServerConfig.PROP_ON_APPROVAL);
@@ -434,9 +450,9 @@ public class UIDeploymentServers extends UIInput
if (WCMAppModel.CONSTRAINT_TESTSERVER.equals(
server.getProperties().get(DeploymentServerConfig.PROP_TYPE)))
{
out.write("<tr><td align='right'>");
out.write("<tr><td align='right'><nobr>");
out.write(bundle.getString(MSG_ALLOCATED));
out.write(":</td><td>");
out.write(":</nobr></td><td>");
if (server.getProperties().get(DeploymentServerConfig.PROP_ALLOCATED_TO) != null)
{
String allocatedToTip = (String)server.getProperties().get(
@@ -466,7 +482,14 @@ public class UIDeploymentServers extends UIInput
String contextPath = context.getExternalContext().getRequestContextPath();
ResourceBundle bundle = Application.getBundle(context);
out.write("<div class='deployConfigServer'>");
out.write("<div class='deployConfigServer'");
if (edit)
{
out.write(" id='");
out.write(server.getId());
out.write("'");
}
out.write(">");
PanelGenerator.generatePanelStart(out, contextPath, "lightstorm", "#eaeff2");
out.write("<table width='100%'><tr><td><img class='deployConfigServerIcon' src='");
out.write(contextPath);
@@ -656,6 +679,22 @@ public class UIDeploymentServers extends UIInput
Utils.encodeRecursive(context, source);
out.write("</td></tr>");
// create the excludes field
out.write("<tr><td align='right'>");
out.write(bundle.getString(MSG_EXCLUDES));
out.write(":</td><td>");
UIComponent excludes = context.getApplication().createComponent(
UIInput.COMPONENT_TYPE);
FacesHelper.setupComponentId(context, excludes, null);
excludes.getAttributes().put("styleClass", "inputField");
ValueBinding vbExcludes = context.getApplication().createValueBinding(
"#{WizardManager.bean.editedDeployServerProperties." +
DeploymentServerConfig.PROP_EXCLUDES + "}");
excludes.setValueBinding("value", vbExcludes);
this.getChildren().add(excludes);
Utils.encodeRecursive(context, excludes);
out.write("</td></tr>");
if ((edit == false && WCMAppModel.CONSTRAINT_FILEDEPLOY.equals(getAddType())) ||
(edit && WCMAppModel.CONSTRAINT_FILEDEPLOY.equals(server.getDeployType())))
{

View File

@@ -490,7 +490,7 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa
if (hasAllocatedTestServer)
{
UIActionLink releaseServer = createAction(context, mainStore, username,
ACT_SANDBOX_RELEASE_SERVER, "/images/icons/deploy_server.gif",
ACT_SANDBOX_RELEASE_SERVER, "/images/icons/release_server.gif",
"#{AVMBrowseBean.releaseTestServer}", null, null, null, false);
menu.getChildren().add(releaseServer);
}
@@ -1298,7 +1298,7 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa
menu.getAttributes().put("itemSpacing", 4);
menu.getAttributes().put("image", "/images/icons/menu.gif");
menu.getAttributes().put("menuStyleClass", "moreActionsMenu");
menu.getAttributes().put("style", "white-space:nowrap; margin-left: 4px;");
menu.getAttributes().put("style", "white-space:nowrap; margin-left: 4px; margin-right: 6px;");
return menu;
}

View File

@@ -36,6 +36,9 @@ import org.alfresco.web.ui.common.tag.BaseComponentTag;
public class DeploymentReportsTag extends BaseComponentTag
{
private String value;
private String showPrevious;
private String dateFilter;
private String attempt;
/**
* @see javax.faces.webapp.UIComponentTag#getComponentType()
@@ -61,6 +64,9 @@ public class DeploymentReportsTag extends BaseComponentTag
super.setProperties(component);
setStringProperty(component, "value", this.value);
setStringProperty(component, "dateFilter", this.dateFilter);
setStringProperty(component, "attempt", this.attempt);
setBooleanProperty(component, "showPrevious", this.showPrevious);
}
/**
@@ -70,6 +76,9 @@ public class DeploymentReportsTag extends BaseComponentTag
{
super.release();
this.value = null;
this.showPrevious = null;
this.dateFilter = null;
this.attempt = null;
}
/**
@@ -81,4 +90,19 @@ public class DeploymentReportsTag extends BaseComponentTag
{
this.value = value;
}
public void setShowPrevious(String showPrevious)
{
this.showPrevious = showPrevious;
}
public void setDateFilter(String dateFilter)
{
this.dateFilter = dateFilter;
}
public void setAttempt(String attempt)
{
this.attempt = attempt;
}
}