Refactored links management UI following link validation service API changes

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6024 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2007-06-19 21:30:52 +00:00
parent 01fcd8f734
commit fcacf048c0
9 changed files with 141 additions and 56 deletions

View File

@@ -31,6 +31,7 @@ import javax.faces.context.FacesContext;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.util.ParameterCheck;
import org.alfresco.web.app.AlfrescoNavigationHandler;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.dialog.BaseDialogBean;
@@ -49,7 +50,11 @@ public class LinkValidationReportDialog extends BaseDialogBean
protected ActionService actionService;
private String store;
private String webapp;
private String webappPath;
private String cancelOutcome;
private String fromTaskDialog;
private String compareToStaging;
private static final Log logger = LogFactory.getLog(LinkValidationReportDialog.class);
@@ -61,16 +66,26 @@ public class LinkValidationReportDialog extends BaseDialogBean
{
super.init(parameters);
// check required params are present
this.store = parameters.get("store");
this.webapp = parameters.get("webapp");
ParameterCheck.mandatoryString("store", this.store);
ParameterCheck.mandatoryString("webapp", this.webapp);
// setup context for dialog
store = parameters.get("store");
this.webappPath = AVMUtil.buildStoreWebappPath(this.store, this.webapp);
this.compareToStaging = parameters.get("compareToStaging");
if (logger.isDebugEnabled())
logger.debug("Showing link validation report for store '" + store + "'");
String directView = parameters.get("directView");
if (directView != null && directView.equals("true"))
logger.debug("Showing link validation report for webapp '" + webappPath + "'");
// use a different cancel outcome if we were launched from the task dialog
this.fromTaskDialog = parameters.get("fromTaskDialog");
if (this.fromTaskDialog != null && this.fromTaskDialog.equals("true"))
{
this.cancelOutcome = super.getDefaultCancelOutcome();
this.cancelOutcome = AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME +
AlfrescoNavigationHandler.OUTCOME_SEPARATOR +
"myalfresco";
}
else
{
@@ -85,10 +100,13 @@ public class LinkValidationReportDialog extends BaseDialogBean
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
if (logger.isDebugEnabled())
logger.debug("Re-running link validation report for store '" + store + "'");
logger.debug("Re-running link validation report for webapp '" + this.webappPath + "'");
Map<String, String> params = new HashMap<String, String>(1);
params.put("store", this.store);
params.put("webapp", this.webapp);
params.put("fromTaskDialog", this.fromTaskDialog);
params.put("compareToStaging", this.compareToStaging);
Application.getDialogManager().setupParameters(params);
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME +
@@ -126,11 +144,14 @@ public class LinkValidationReportDialog extends BaseDialogBean
public String updateStatus()
{
if (logger.isDebugEnabled())
logger.debug("Updating status for link validation report for store '" + store + "'");
logger.debug("Updating status for link validation report for webapp '" + this.webappPath + "'");
Map<String, String> params = new HashMap<String, String>(1);
params.put("store", this.store);
params.put("rerun", "true");
params.put("webapp", this.webapp);
params.put("fromTaskDialog", this.fromTaskDialog);
params.put("compareToStaging", this.compareToStaging);
params.put("update", "true");
Application.getDialogManager().setupParameters(params);
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME +

View File

@@ -41,6 +41,7 @@ import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.util.ParameterCheck;
import org.alfresco.web.app.AlfrescoNavigationHandler;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.dialog.BaseDialogBean;
@@ -61,8 +62,12 @@ public class LinkValidationRunDialog extends BaseDialogBean
protected ActionService actionService;
private String store;
private NodeRef storePathRef;
private boolean rerun = false;
private String webapp;
private String webappPath;
private String fromTaskDialog;
private NodeRef webappPathRef;
private boolean update = false;
private boolean compareToStaging = false;
private static final Log logger = LogFactory.getLog(LinkValidationRunDialog.class);
@@ -74,39 +79,49 @@ public class LinkValidationRunDialog extends BaseDialogBean
{
super.init(parameters);
// TODO: determine whether the virtualisation server is running, if it's not
// we need to throw an exception to reflect that
// check required params are present
this.store = parameters.get("store");
this.webapp = parameters.get("webapp");
ParameterCheck.mandatoryString("store", this.store);
ParameterCheck.mandatoryString("webapp", this.webapp);
// setup context for dialog
store = parameters.get("store");
this.fromTaskDialog = parameters.get("fromTaskDialog");
this.webappPath = AVMUtil.buildStoreWebappPath(this.store, this.webapp);
this.webappPathRef = AVMNodeConverter.ToNodeRef(-1, this.webappPath);
String storePath = this.store + ":/";
this.storePathRef = AVMNodeConverter.ToNodeRef(-1, storePath);
this.rerun = false;
String rerunParam = parameters.get("rerun");
if (rerunParam != null && rerunParam.equals("true"))
this.update = false;
String updateParam = parameters.get("update");
if (updateParam != null && updateParam.equals("true"))
{
this.rerun = true;
this.update = true;
}
this.compareToStaging = false;
String compareToStagingParam = parameters.get("compareToStaging");
if (compareToStagingParam != null && compareToStagingParam.equals("true"))
{
this.compareToStaging = true;
}
if (logger.isDebugEnabled())
{
if (this.rerun)
logger.debug("Starting re-run link validation check for store '" + store + "'");
if (this.update)
logger.debug("Starting update link validation check for webapp '" + this.webappPath + "'");
else
logger.debug("Starting initial link validation check for store '" + store + "'");
logger.debug("Starting initial link validation check for webapp '" + this.webappPath + "'");
}
// create context required to run and monitor the link check
HrefValidationProgress monitor = new HrefValidationProgress();
Map<String, Serializable> args = new HashMap<String, Serializable>(1, 1.0f);
args.put(LinkValidationAction.PARAM_MONITOR, monitor);
args.put(LinkValidationAction.PARAM_COMPARE_TO_STAGING, new Boolean(this.compareToStaging));
this.avmBrowseBean.setLinkValidationMonitor(monitor);
// create and execute the action in the background
Action action = this.actionService.createAction(LinkValidationAction.NAME, args);
this.actionService.executeAction(action, this.storePathRef, false, true);
this.actionService.executeAction(action, this.webappPathRef, false, true);
}
@SuppressWarnings("unchecked")
@@ -145,18 +160,21 @@ public class LinkValidationRunDialog extends BaseDialogBean
if (report.wasSuccessful())
{
// setup the context required by the reporting components to display the results
if (this.rerun)
if (this.update)
{
this.avmBrowseBean.getLinkValidationState().updateState(report);
}
else
{
LinkValidationState state = new LinkValidationState(this.store, report);
LinkValidationState state = new LinkValidationState(report);
this.avmBrowseBean.setLinkValidationState(state);
}
Map<String, String> params = new HashMap<String, String>(1);
params.put("store", this.store);
params.put("webapp", this.webapp);
params.put("fromTaskDialog", this.fromTaskDialog);
params.put("compareToStaging", Boolean.toString(this.compareToStaging));
Application.getDialogManager().setupParameters(params);
outcome = AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME +

View File

@@ -58,8 +58,9 @@ import org.apache.commons.logging.LogFactory;
public class LinkValidationState
{
private String store;
private Date initialCheckedCompletedAt;
private String webapp;
private boolean checkBeenReRun = false;
private Date initialCheckCompletedAt;
private int noFilesCheckedStart = -1;
private int noFilesCheckedLast = -1;
@@ -95,10 +96,10 @@ public class LinkValidationState
/**
* Default constructor
*/
public LinkValidationState(String store, LinkValidationReport initialReport)
public LinkValidationState(LinkValidationReport initialReport)
{
this.store = store;
this.initialCheckedCompletedAt = new Date();
this.store = initialReport.getStore();
this.webapp = initialReport.getWebapp();
processReport(initialReport, false);
}
@@ -114,12 +115,20 @@ public class LinkValidationState
return this.store;
}
/**
* @return The webapp within a store this validaton state represents
*/
public String getWebapp()
{
return this.webapp;
}
/**
* @return The date the initial check was completed
*/
public Date getInitialCheckCompletedAt()
{
return this.initialCheckedCompletedAt;
return this.initialCheckCompletedAt;
}
/**
@@ -293,6 +302,14 @@ public class LinkValidationState
*/
public void updateState(LinkValidationReport newReport)
{
// make sure the updated report has the same store and webapp
// as the initial report
if ((newReport.getStore().equals(this.store) == false) ||
(newReport.getWebapp().equals(this.webapp) == false))
{
throw new IllegalStateException("Can not update a report from a different store or webapp!");
}
// process the new report
processReport(newReport, true);
}
@@ -302,6 +319,7 @@ public class LinkValidationState
{
StringBuilder buffer = new StringBuilder(super.toString());
buffer.append(" (store=").append(this.store);
buffer.append(" webapp=").append(this.webapp);
buffer.append(" error=").append(this.cause).append(")");
return buffer.toString();
}
@@ -309,14 +327,20 @@ public class LinkValidationState
// ------------------------------------------------------------------------------
// Private Helpers
public void processReport(LinkValidationReport report, boolean rerunReport)
public void processReport(LinkValidationReport report, boolean updatedReport)
{
this.checkBeenReRun = rerunReport;
this.checkBeenReRun = updatedReport;
this.cause = report.getError();
// make sure there is an initial check completed date
if (this.initialCheckCompletedAt == null)
{
this.initialCheckCompletedAt = report.getCheckCompletedAt();
}
if (this.cause == null)
{
if (rerunReport == false)
if (updatedReport == false)
{
// setup initial counts
this.noBrokenFilesStart = report.getNumberBrokenFiles();
@@ -336,7 +360,7 @@ public class LinkValidationState
// process the broken files and determine which ones are static files
// and which ones are generated
processFiles(report.getFilesWithBrokenLinks(), rerunReport, report);
processFiles(report.getFilesWithBrokenLinks(), updatedReport, report);
}
else
{
@@ -360,7 +384,7 @@ public class LinkValidationState
// process the broken files and determine which ones are static files
// and which ones are generated
processFiles(report.getFilesWithBrokenLinks(), rerunReport, report);
processFiles(report.getFilesWithBrokenLinks(), updatedReport, report);
// go through the list of files & forms still broken and find which ones
// were fixed in the last re-run of the report
@@ -384,7 +408,7 @@ public class LinkValidationState
}
}
protected void processFiles(List<String> files, boolean rerunReport, LinkValidationReport report)
protected void processFiles(List<String> files, boolean updatedReport, LinkValidationReport report)
{
AVMService avmService = Repository.getServiceRegistry(
FacesContext.getCurrentInstance()).getAVMService();
@@ -393,7 +417,7 @@ public class LinkValidationState
if (logger.isDebugEnabled())
{
if (rerunReport)
if (updatedReport)
logger.debug("Processing files from updated report: " + report);
else
logger.debug("Processing files from initial report: " + report);
@@ -442,6 +466,11 @@ public class LinkValidationState
genFiles.add(file);
this.brokenFilesByForm.put(xmlPath, genFiles);
}
else
{
if (logger.isDebugEnabled())
logger.debug("Ignoring generated XML file: " + file);
}
}
else
{
@@ -456,7 +485,7 @@ public class LinkValidationState
}
// if this is the first run of the report setup the initial lists
if (rerunReport == false)
if (updatedReport == false)
{
this.brokenStaticFilesStart = new ArrayList<String>(this.brokenStaticFilesLast.size());
this.brokenStaticFilesStart.addAll(this.brokenStaticFilesLast);

View File

@@ -48,6 +48,8 @@ import org.apache.commons.logging.LogFactory;
*/
public class ManageVerifyBrokenLinksTaskDialog extends ManageTaskDialog
{
protected String store;
protected String webapp;
protected AVMBrowseBean avmBrowseBean;
private static final Log logger = LogFactory.getLog(ManageVerifyBrokenLinksTaskDialog.class);
@@ -77,7 +79,7 @@ public class ManageVerifyBrokenLinksTaskDialog extends ManageTaskDialog
String storeName = this.workflowPackage.getStoreRef().getIdentifier();
if (logger.isDebugEnabled())
logger.debug("Retrieving link validation report for store '" + storeName + "'");
logger.debug("Retrieving link validation report from store '" + storeName + "'");
PropertyValue val = this.avmService.getStoreProperty(storeName,
SandboxConstants.PROP_LINK_VALIDATION_REPORT);
@@ -86,7 +88,14 @@ public class ManageVerifyBrokenLinksTaskDialog extends ManageTaskDialog
LinkValidationReport report = (LinkValidationReport)val.getSerializableValue();
if (report != null)
{
LinkValidationState state = new LinkValidationState(storeName, report);
this.store = report.getStore();
this.webapp = report.getWebapp();
if (logger.isDebugEnabled())
logger.debug("Found link validation report for webapp '" +
AVMUtil.buildStoreWebappPath(this.store, this.webapp) + "'");
LinkValidationState state = new LinkValidationState(report);
this.avmBrowseBean.setLinkValidationState(state);
if (logger.isDebugEnabled())
@@ -110,14 +119,14 @@ public class ManageVerifyBrokenLinksTaskDialog extends ManageTaskDialog
public String viewLinkReport()
{
String storeName = this.workflowPackage.getStoreRef().getIdentifier();
if (logger.isDebugEnabled())
logger.debug("Viewing link validation report for store '" + storeName + "'");
logger.debug("Viewing link validation report for webapp '" +
AVMUtil.buildStoreWebappPath(this.store, this.webapp) + "'");
Map<String, String> params = new HashMap<String, String>(1);
params.put("store", storeName);
params.put("directView", "true");
params.put("store", this.store);
params.put("webapp", this.webapp);
params.put("fromTaskDialog", "true");
Application.getDialogManager().setupParameters(params);
return "dialog:linkValidationReport";

View File

@@ -64,6 +64,7 @@ import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.util.ISO8601DateFormat;
import org.alfresco.util.NameMatcher;
import org.alfresco.util.VirtServerUtils;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.DownloadContentServlet;
import org.alfresco.web.bean.BrowseBean;
@@ -75,8 +76,6 @@ import org.alfresco.web.forms.FormInstanceDataImpl;
import org.alfresco.web.forms.Rendition;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.UIListItem;
import org.alfresco.web.ui.wcm.WebResources;
import org.alfresco.util.VirtServerUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -97,7 +96,7 @@ public class SubmitDialog extends BaseDialogBean
private String[] workflowSelectedValue;
private boolean enteringExpireDate = false;
private boolean startedFromWorkflow = false;
private boolean validateLinks = false;
private boolean validateLinks = true;
private Date defaultExpireDate;
private Date launchDate;
@@ -196,7 +195,7 @@ public class SubmitDialog extends BaseDialogBean
this.defaultExpireDate = new Date();
this.workflowSelectedValue = null;
this.launchDate = null;
this.validateLinks = false;
this.validateLinks = true;
// determine if the dialog has been started from a workflow
Boolean bool = new Boolean(this.parameters.get(PARAM_STARTED_FROM_WORKFLOW));
@@ -332,7 +331,10 @@ public class SubmitDialog extends BaseDialogBean
params.put(WCMWorkflowModel.PROP_FROM_PATH,
AVMUtil.buildStoreRootPath(this.avmBrowseBean.getSandbox()));
params.put(WCMWorkflowModel.PROP_LAUNCH_DATE, this.launchDate);
params.put(WCMWorkflowModel.PROP_VALIDATE_LINKS, new Boolean(this.validateLinks));
params.put(WCMWorkflowModel.PROP_VALIDATE_LINKS,
new Boolean(this.validateLinks));
params.put(WCMWorkflowModel.PROP_WEBAPP,
this.avmBrowseBean.getWebapp());
params.put(WCMWorkflowModel.ASSOC_WEBPROJECT,
this.avmBrowseBean.getWebsite().getNodeRef());

View File

@@ -93,7 +93,7 @@ public class UILinkValidationSummary extends AbstractLinkValidationReportCompone
{
String pattern = bundle.getString("files_links_still_broken");
String stillBroken = MessageFormat.format(pattern,
new Object[] {linkState.getNumberBrokenFiles(), linkState.getNumberBrokenLinks()});
new Object[] {linkState.getNumberBrokenLinks(), linkState.getNumberBrokenFiles()});
pattern = bundle.getString("broken_links_fixed");
String linksFixed = MessageFormat.format(pattern,
new Object[] {linkState.getNumberFixedLinks()});
@@ -161,7 +161,7 @@ public class UILinkValidationSummary extends AbstractLinkValidationReportCompone
linkState.getInitialNumberLinksChecked()});
pattern = bundle.getString("files_links_broken");
String initialBrokenSummary = MessageFormat.format(pattern,
new Object[] {linkState.getInitialNumberBrokenFiles(), linkState.getInitialNumberBrokenLinks()});
new Object[] {linkState.getInitialNumberBrokenLinks(), linkState.getInitialNumberBrokenFiles()});
out.write("<div style='margin-bottom: 6px;'>");
out.write(initialCheckSummary);

View File

@@ -375,9 +375,14 @@ public class UIUserSandboxes extends SelfRenderingComponent
out.write(")</td><td><nobr>");
// Direct actions for a sandbox...
Map<String, String> params = new HashMap<String, String>(3);
params.put("store", mainStore);
params.put("username", username);
params.put("webapp", this.getWebapp());
params.put("compareToStaging", "true");
Utils.encodeRecursive(context, aquireAction(
context, mainStore, username, ACT_SANDBOX_CHECK_LINKS, "/images/icons/run_link_validation.gif",
"#{DialogManager.setupParameters}", "dialog:runLinkValidation"));
"#{DialogManager.setupParameters}", "dialog:runLinkValidation", null, params));
out.write("&nbsp;&nbsp;");
// Browse Sandbox