mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Added links management to the submit process
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5989 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -49,6 +49,7 @@ public class LinkValidationReportDialog extends BaseDialogBean
|
||||
protected ActionService actionService;
|
||||
|
||||
private String store;
|
||||
private String cancelOutcome;
|
||||
|
||||
private static final Log logger = LogFactory.getLog(LinkValidationReportDialog.class);
|
||||
|
||||
@@ -65,6 +66,18 @@ public class LinkValidationReportDialog extends BaseDialogBean
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Showing link validation report for store '" + store + "'");
|
||||
|
||||
String directView = parameters.get("directView");
|
||||
if (directView != null && directView.equals("true"))
|
||||
{
|
||||
this.cancelOutcome = super.getDefaultCancelOutcome();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.cancelOutcome = AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME +
|
||||
AlfrescoNavigationHandler.OUTCOME_SEPARATOR +
|
||||
"browseWebsite";
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -83,6 +96,12 @@ public class LinkValidationReportDialog extends BaseDialogBean
|
||||
"dialog:runLinkValidation";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFinishButtonLabel()
|
||||
{
|
||||
@@ -98,9 +117,7 @@ public class LinkValidationReportDialog extends BaseDialogBean
|
||||
@Override
|
||||
protected String getDefaultCancelOutcome()
|
||||
{
|
||||
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME +
|
||||
AlfrescoNavigationHandler.OUTCOME_SEPARATOR +
|
||||
"browseWebsite";
|
||||
return this.cancelOutcome;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
|
@@ -29,6 +29,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import org.alfresco.linkvalidation.HrefValidationProgress;
|
||||
import org.alfresco.linkvalidation.LinkValidationAction;
|
||||
@@ -43,6 +44,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -59,7 +61,7 @@ public class LinkValidationRunDialog extends BaseDialogBean
|
||||
protected ActionService actionService;
|
||||
|
||||
private String store;
|
||||
private NodeRef storeRef;
|
||||
private NodeRef storePathRef;
|
||||
private boolean rerun = false;
|
||||
|
||||
private static final Log logger = LogFactory.getLog(LinkValidationRunDialog.class);
|
||||
@@ -79,7 +81,7 @@ public class LinkValidationRunDialog extends BaseDialogBean
|
||||
store = parameters.get("store");
|
||||
|
||||
String storePath = this.store + ":/";
|
||||
this.storeRef = AVMNodeConverter.ToNodeRef(-1, storePath);
|
||||
this.storePathRef = AVMNodeConverter.ToNodeRef(-1, storePath);
|
||||
|
||||
this.rerun = false;
|
||||
String rerunParam = parameters.get("rerun");
|
||||
@@ -104,7 +106,7 @@ public class LinkValidationRunDialog extends BaseDialogBean
|
||||
|
||||
// create and execute the action in the background
|
||||
Action action = this.actionService.createAction(LinkValidationAction.NAME, args);
|
||||
this.actionService.executeAction(action, this.storeRef, false, true);
|
||||
this.actionService.executeAction(action, this.storePathRef, false, true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -125,48 +127,65 @@ public class LinkValidationRunDialog extends BaseDialogBean
|
||||
// on the store the link check was run on, retrieve it and see if
|
||||
// the link check was successful.
|
||||
|
||||
PropertyValue val = this.avmService.getStoreProperty(this.store,
|
||||
SandboxConstants.PROP_LINK_VALIDATION_REPORT);
|
||||
if (val != null)
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
UserTransaction tx = null;
|
||||
|
||||
try
|
||||
{
|
||||
LinkValidationReport report = (LinkValidationReport)val.getSerializableValue();
|
||||
if (report != null)
|
||||
tx = Repository.getUserTransaction(context, true);
|
||||
tx.begin();
|
||||
|
||||
PropertyValue val = this.avmService.getStoreProperty(this.store,
|
||||
SandboxConstants.PROP_LINK_VALIDATION_REPORT);
|
||||
if (val != null)
|
||||
{
|
||||
if (report.wasSuccessful())
|
||||
LinkValidationReport report = (LinkValidationReport)val.getSerializableValue();
|
||||
if (report != null)
|
||||
{
|
||||
// setup the context required by the reporting components to display the results
|
||||
if (this.rerun)
|
||||
if (report.wasSuccessful())
|
||||
{
|
||||
this.avmBrowseBean.getLinkValidationState().updateState(report);
|
||||
// setup the context required by the reporting components to display the results
|
||||
if (this.rerun)
|
||||
{
|
||||
this.avmBrowseBean.getLinkValidationState().updateState(report);
|
||||
}
|
||||
else
|
||||
{
|
||||
LinkValidationState state = new LinkValidationState(this.store, report);
|
||||
this.avmBrowseBean.setLinkValidationState(state);
|
||||
}
|
||||
|
||||
Map<String, String> params = new HashMap<String, String>(1);
|
||||
params.put("store", this.store);
|
||||
Application.getDialogManager().setupParameters(params);
|
||||
|
||||
outcome = AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME +
|
||||
AlfrescoNavigationHandler.OUTCOME_SEPARATOR +
|
||||
"dialog:linkValidationReport";
|
||||
}
|
||||
else
|
||||
{
|
||||
LinkValidationState state = new LinkValidationState(this.store, report);
|
||||
this.avmBrowseBean.setLinkValidationState(state);
|
||||
String errorMsg = Application.getMessage(context, "link_validation_unknown_error");
|
||||
Throwable cause = report.getError();
|
||||
if (cause != null)
|
||||
{
|
||||
errorMsg = Application.getMessage(context, "link_validation_error") + ": " +
|
||||
cause.getMessage();
|
||||
}
|
||||
|
||||
Utils.addErrorMessage(errorMsg);
|
||||
}
|
||||
|
||||
Map<String, String> params = new HashMap<String, String>(1);
|
||||
params.put("store", this.store);
|
||||
Application.getDialogManager().setupParameters(params);
|
||||
|
||||
outcome = AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME +
|
||||
AlfrescoNavigationHandler.OUTCOME_SEPARATOR +
|
||||
"dialog:linkValidationReport";
|
||||
}
|
||||
else
|
||||
{
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
String errorMsg = Application.getMessage(context, "link_validation_unknown_error");
|
||||
Throwable cause = report.getError();
|
||||
if (cause != null)
|
||||
{
|
||||
errorMsg = Application.getMessage(context, "link_validation_error") + ": " +
|
||||
cause.getMessage();
|
||||
}
|
||||
|
||||
Utils.addErrorMessage(errorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
// commit the changes
|
||||
tx.commit();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
// rollback the transaction
|
||||
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
|
||||
Utils.addErrorMessage(formatErrorMessage(e), e);
|
||||
}
|
||||
|
||||
return outcome;
|
||||
|
@@ -61,20 +61,20 @@ public class LinkValidationState
|
||||
private Date initialCheckedCompletedAt;
|
||||
private boolean checkBeenReRun = false;
|
||||
|
||||
private int noFilesCheckedStart = 0;
|
||||
private int noFilesCheckedLast = 0;
|
||||
private int noFilesCheckedStart = -1;
|
||||
private int noFilesCheckedLast = -1;
|
||||
|
||||
private int noLinksCheckedStart = 0;
|
||||
private int noLinksCheckedLast = 0;
|
||||
private int noLinksCheckedStart = -1;
|
||||
private int noLinksCheckedLast = -1;
|
||||
|
||||
private int noBrokenFilesStart = 0;
|
||||
private int noBrokenFilesLast = 0;
|
||||
private int noBrokenFilesStart = -1;
|
||||
private int noBrokenFilesLast = -1;
|
||||
|
||||
private int noBrokenLinksStart = 0;
|
||||
private int noBrokenLinksLast = 0;
|
||||
private int noBrokenLinksStart = -1;
|
||||
private int noBrokenLinksLast = -1;
|
||||
|
||||
private int noFixedFiles = 0;
|
||||
private int noFixedLinks = 0;
|
||||
private int noFixedFiles = -1;
|
||||
private int noFixedLinks = -1;
|
||||
|
||||
private List<String> brokenStaticFilesStart;
|
||||
private List<String> brokenFormsStart;
|
||||
@@ -88,6 +88,8 @@ public class LinkValidationState
|
||||
private Map<String, List<String>> brokenLinksByFile;
|
||||
private Map<String, List<String>> brokenFilesByForm;
|
||||
|
||||
private Throwable cause;
|
||||
|
||||
private static Log logger = LogFactory.getLog(LinkValidationState.class);
|
||||
|
||||
/**
|
||||
@@ -120,6 +122,14 @@ public class LinkValidationState
|
||||
return this.initialCheckedCompletedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The error that caused the last report to fail
|
||||
*/
|
||||
public Throwable getError()
|
||||
{
|
||||
return this.cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The number of files checked by the initial link check
|
||||
*/
|
||||
@@ -291,7 +301,8 @@ public class LinkValidationState
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder buffer = new StringBuilder(super.toString());
|
||||
buffer.append(" (store=").append(this.store).append(")");
|
||||
buffer.append(" (store=").append(this.store);
|
||||
buffer.append(" error=").append(this.cause).append(")");
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
@@ -301,67 +312,73 @@ public class LinkValidationState
|
||||
public void processReport(LinkValidationReport report, boolean rerunReport)
|
||||
{
|
||||
this.checkBeenReRun = rerunReport;
|
||||
this.cause = report.getError();
|
||||
|
||||
if (rerunReport == false)
|
||||
if (this.cause == null)
|
||||
{
|
||||
// setup initial counts
|
||||
this.noBrokenFilesStart = report.getNumberBrokenFiles();
|
||||
this.noBrokenLinksStart = report.getNumberBrokenLinks();
|
||||
this.noFilesCheckedStart = report.getNumberFilesChecked();
|
||||
this.noLinksCheckedStart = report.getNumberLinksChecked();
|
||||
this.noBrokenFilesLast = report.getNumberBrokenFiles();
|
||||
this.noBrokenLinksLast = report.getNumberBrokenLinks();
|
||||
this.noFilesCheckedLast = report.getNumberFilesChecked();
|
||||
this.noLinksCheckedLast = report.getNumberLinksChecked();
|
||||
|
||||
// setup fixed lists
|
||||
this.fixedFiles = new ArrayList<String>(this.noBrokenFilesStart);
|
||||
this.fixedForms = new ArrayList<String>(this.noBrokenFilesStart);
|
||||
|
||||
// process the broken files and determine which ones are static files
|
||||
// and which ones are generated
|
||||
processFiles(report.getFilesWithBrokenLinks(), rerunReport, report);
|
||||
}
|
||||
else
|
||||
{
|
||||
// update the relevant counts
|
||||
this.noBrokenFilesLast = report.getNumberBrokenFiles();
|
||||
this.noBrokenLinksLast = report.getNumberBrokenLinks();
|
||||
this.noFilesCheckedLast = report.getNumberFilesChecked();
|
||||
this.noLinksCheckedLast = report.getNumberLinksChecked();
|
||||
|
||||
this.noFixedFiles = this.noBrokenFilesStart - this.noBrokenFilesLast;
|
||||
this.noFixedLinks = this.noBrokenLinksStart - this.noBrokenLinksLast;
|
||||
|
||||
if (this.noFixedFiles < 0)
|
||||
if (rerunReport == false)
|
||||
{
|
||||
// setup initial counts
|
||||
this.noBrokenFilesStart = report.getNumberBrokenFiles();
|
||||
this.noBrokenLinksStart = report.getNumberBrokenLinks();
|
||||
this.noFilesCheckedStart = report.getNumberFilesChecked();
|
||||
this.noLinksCheckedStart = report.getNumberLinksChecked();
|
||||
this.noBrokenFilesLast = report.getNumberBrokenFiles();
|
||||
this.noBrokenLinksLast = report.getNumberBrokenLinks();
|
||||
this.noFilesCheckedLast = report.getNumberFilesChecked();
|
||||
this.noLinksCheckedLast = report.getNumberLinksChecked();
|
||||
this.noFixedFiles = 0;
|
||||
}
|
||||
if (this.noFixedLinks < 0)
|
||||
{
|
||||
this.noFixedLinks = 0;
|
||||
|
||||
// setup fixed lists
|
||||
this.fixedFiles = new ArrayList<String>(this.noBrokenFilesStart);
|
||||
this.fixedForms = new ArrayList<String>(this.noBrokenFilesStart);
|
||||
|
||||
// process the broken files and determine which ones are static files
|
||||
// and which ones are generated
|
||||
processFiles(report.getFilesWithBrokenLinks(), rerunReport, report);
|
||||
}
|
||||
|
||||
// process the broken files and determine which ones are static files
|
||||
// and which ones are generated
|
||||
processFiles(report.getFilesWithBrokenLinks(), rerunReport, report);
|
||||
|
||||
// go through the list of files & forms still broken and find which ones
|
||||
// were fixed in the last re-run of the report
|
||||
for (String file : this.brokenStaticFilesStart)
|
||||
else
|
||||
{
|
||||
if (this.brokenStaticFilesLast.contains(file) == false &&
|
||||
this.fixedFiles.contains(file) == false)
|
||||
// update the relevant counts
|
||||
this.noBrokenFilesLast = report.getNumberBrokenFiles();
|
||||
this.noBrokenLinksLast = report.getNumberBrokenLinks();
|
||||
this.noFilesCheckedLast = report.getNumberFilesChecked();
|
||||
this.noLinksCheckedLast = report.getNumberLinksChecked();
|
||||
|
||||
this.noFixedFiles = this.noBrokenFilesStart - this.noBrokenFilesLast;
|
||||
this.noFixedLinks = this.noBrokenLinksStart - this.noBrokenLinksLast;
|
||||
|
||||
if (this.noFixedFiles < 0)
|
||||
{
|
||||
this.fixedFiles.add(file);
|
||||
this.noFixedFiles = 0;
|
||||
}
|
||||
}
|
||||
for (String file : this.brokenFormsStart)
|
||||
{
|
||||
if (this.brokenFormsLast.contains(file) == false &&
|
||||
this.fixedForms.contains(file) == false)
|
||||
if (this.noFixedLinks < 0)
|
||||
{
|
||||
this.fixedForms.add(file);
|
||||
this.noFixedLinks = 0;
|
||||
}
|
||||
|
||||
// process the broken files and determine which ones are static files
|
||||
// and which ones are generated
|
||||
processFiles(report.getFilesWithBrokenLinks(), rerunReport, report);
|
||||
|
||||
// go through the list of files & forms still broken and find which ones
|
||||
// were fixed in the last re-run of the report
|
||||
for (String file : this.brokenStaticFilesStart)
|
||||
{
|
||||
if (this.brokenStaticFilesLast.contains(file) == false &&
|
||||
this.fixedFiles.contains(file) == false)
|
||||
{
|
||||
this.fixedFiles.add(file);
|
||||
}
|
||||
}
|
||||
for (String file : this.brokenFormsStart)
|
||||
{
|
||||
if (this.brokenFormsLast.contains(file) == false &&
|
||||
this.fixedForms.contains(file) == false)
|
||||
{
|
||||
this.fixedForms.add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean.wcm;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import org.alfresco.linkvalidation.LinkValidationReport;
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.sandbox.SandboxConstants;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.bean.workflow.ManageTaskDialog;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Bean implementation for the "Manage Task" dialog when dealing
|
||||
* with the "WCM Review" task specifically.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class ManageVerifyBrokenLinksTaskDialog extends ManageTaskDialog
|
||||
{
|
||||
protected AVMBrowseBean avmBrowseBean;
|
||||
|
||||
private static final Log logger = LogFactory.getLog(ManageVerifyBrokenLinksTaskDialog.class);
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
@Override
|
||||
public void init(Map<String, String> parameters)
|
||||
{
|
||||
super.init(parameters);
|
||||
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
UserTransaction tx = null;
|
||||
|
||||
try
|
||||
{
|
||||
tx = Repository.getUserTransaction(context, true);
|
||||
tx.begin();
|
||||
|
||||
// reset any previous link validation state
|
||||
this.avmBrowseBean.setLinkValidationState(null);
|
||||
this.avmBrowseBean.setLinkValidationMonitor(null);
|
||||
|
||||
// try and retrieve the deployment report from the workflow
|
||||
// store, if present setup the validation state on AVMBrowseBean
|
||||
String storeName = this.workflowPackage.getStoreRef().getIdentifier();
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Retrieving link validation report for store '" + storeName + "'");
|
||||
|
||||
PropertyValue val = this.avmService.getStoreProperty(storeName,
|
||||
SandboxConstants.PROP_LINK_VALIDATION_REPORT);
|
||||
if (val != null)
|
||||
{
|
||||
LinkValidationReport report = (LinkValidationReport)val.getSerializableValue();
|
||||
if (report != null)
|
||||
{
|
||||
LinkValidationState state = new LinkValidationState(storeName, report);
|
||||
this.avmBrowseBean.setLinkValidationState(state);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Stored link validation state: " + state);
|
||||
}
|
||||
}
|
||||
|
||||
// commit the changes
|
||||
tx.commit();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
// rollback the transaction
|
||||
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
|
||||
Utils.addErrorMessage(formatErrorMessage(e), e);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Event handlers
|
||||
|
||||
public String viewLinkReport()
|
||||
{
|
||||
String storeName = this.workflowPackage.getStoreRef().getIdentifier();
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Viewing link validation report for store '" + storeName + "'");
|
||||
|
||||
Map<String, String> params = new HashMap<String, String>(1);
|
||||
params.put("store", storeName);
|
||||
params.put("directView", "true");
|
||||
Application.getDialogManager().setupParameters(params);
|
||||
|
||||
return "dialog:linkValidationReport";
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Getters and Setters
|
||||
|
||||
/**
|
||||
* @param avmBrowseBean AVMBrowseBean instance
|
||||
*/
|
||||
public void setAvmBrowseBean(AVMBrowseBean avmBrowseBean)
|
||||
{
|
||||
this.avmBrowseBean = avmBrowseBean;
|
||||
}
|
||||
}
|
@@ -97,6 +97,7 @@ public class SubmitDialog extends BaseDialogBean
|
||||
private String[] workflowSelectedValue;
|
||||
private boolean enteringExpireDate = false;
|
||||
private boolean startedFromWorkflow = false;
|
||||
private boolean validateLinks = false;
|
||||
private Date defaultExpireDate;
|
||||
private Date launchDate;
|
||||
|
||||
@@ -195,6 +196,7 @@ public class SubmitDialog extends BaseDialogBean
|
||||
this.defaultExpireDate = new Date();
|
||||
this.workflowSelectedValue = null;
|
||||
this.launchDate = null;
|
||||
this.validateLinks = false;
|
||||
|
||||
// determine if the dialog has been started from a workflow
|
||||
Boolean bool = new Boolean(this.parameters.get(PARAM_STARTED_FROM_WORKFLOW));
|
||||
@@ -330,6 +332,7 @@ 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.ASSOC_WEBPROJECT,
|
||||
this.avmBrowseBean.getWebsite().getNodeRef());
|
||||
|
||||
@@ -517,6 +520,22 @@ public class SubmitDialog extends BaseDialogBean
|
||||
this.launchDate = launchDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Flag to indicate whether links should be validated
|
||||
*/
|
||||
public boolean isValidateLinks()
|
||||
{
|
||||
return this.validateLinks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param validateLinks Flag to indicate whether links should be validated
|
||||
*/
|
||||
public void setValidateLinks(boolean validateLinks)
|
||||
{
|
||||
this.validateLinks = validateLinks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return List of UIListItem object representing the available workflows for the website
|
||||
*/
|
||||
|
@@ -72,14 +72,87 @@ public class UILinkValidationSummary extends AbstractLinkValidationReportCompone
|
||||
}
|
||||
|
||||
// get the link validation state object to get the data from
|
||||
ResourceBundle bundle = Application.getBundle(context);
|
||||
ResponseWriter out = context.getResponseWriter();
|
||||
LinkValidationState linkState = getValue();
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Rendering summary from state object: " + linkState);
|
||||
|
||||
// resolve all the strings holding data
|
||||
ResourceBundle bundle = Application.getBundle(context);
|
||||
if (linkState.getError() == null)
|
||||
{
|
||||
Object initialCheckOnly = this.getAttributes().get("initialCheckOnly");
|
||||
if (initialCheckOnly instanceof Boolean &&
|
||||
((Boolean)initialCheckOnly).booleanValue())
|
||||
{
|
||||
out.write("<div style='padding: 4px 4px 2px 13px;'>");
|
||||
renderInitialCheckSummary(context, out, linkState, bundle);
|
||||
out.write("</div>");
|
||||
}
|
||||
else
|
||||
{
|
||||
String pattern = bundle.getString("files_links_still_broken");
|
||||
String stillBroken = MessageFormat.format(pattern,
|
||||
new Object[] {linkState.getNumberBrokenFiles(), linkState.getNumberBrokenLinks()});
|
||||
pattern = bundle.getString("broken_links_fixed");
|
||||
String linksFixed = MessageFormat.format(pattern,
|
||||
new Object[] {linkState.getNumberFixedLinks()});
|
||||
|
||||
// get the action to update the current status
|
||||
UICommand updateStatusAction = aquireAction(context, "update_status_" + linkState.getStore());
|
||||
|
||||
// render the summary area
|
||||
out.write("<div class='linkValidationSummaryPanel'><div class='linkValidationReportTitle'>");
|
||||
out.write(bundle.getString("summary"));
|
||||
out.write("</div><table cellpadding='0' cellspacing='0'><tr>");
|
||||
out.write("<td valign='top' class='linkValidationReportSubTitle'>");
|
||||
out.write(bundle.getString("initial_check"));
|
||||
out.write(":</td><td>");
|
||||
renderInitialCheckSummary(context, out, linkState, bundle);
|
||||
out.write("</td></tr><tr><td class='linkValidationReportSubTitle'>");
|
||||
out.write(bundle.getString("current_status"));
|
||||
out.write(":</td><td><div><img src='");
|
||||
out.write(context.getExternalContext().getRequestContextPath());
|
||||
out.write("/images/icons/broken_link.gif' style='vertical-align: -4px; padding-right: 4px;' >");
|
||||
out.write(stillBroken);
|
||||
out.write("<img src='");
|
||||
out.write(context.getExternalContext().getRequestContextPath());
|
||||
out.write("/images/icons/fixed_link.gif' style='vertical-align: -4px; padding-left: 6px; padding-right: 4px;' >");
|
||||
out.write(linksFixed);
|
||||
out.write(" ");
|
||||
Utils.encodeRecursive(context, updateStatusAction);
|
||||
out.write("</div></td></tr>");
|
||||
out.write("</table></div>");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
String pattern = bundle.getString("files_links_checked_error");
|
||||
Date initialCheck = linkState.getInitialCheckCompletedAt();
|
||||
String initialCheckTime = Utils.getDateTimeFormat(context).format(initialCheck);
|
||||
String initialCheckSummary = MessageFormat.format(pattern,
|
||||
new Object[] {initialCheckTime});
|
||||
|
||||
out.write("<div class='linkValidationSummaryPanel'>");
|
||||
out.write(initialCheckSummary);
|
||||
out.write(" <span class='errorMessage'>");
|
||||
String err = linkState.getError().getMessage();
|
||||
if (err == null)
|
||||
{
|
||||
out.write(linkState.getError().toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
out.write(err);
|
||||
}
|
||||
out.write("</span></div>");
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderInitialCheckSummary(FacesContext context,
|
||||
ResponseWriter out, LinkValidationState linkState,
|
||||
ResourceBundle bundle) throws IOException
|
||||
{
|
||||
String pattern = bundle.getString("files_links_checked");
|
||||
Date initialCheck = linkState.getInitialCheckCompletedAt();
|
||||
String initialCheckTime = Utils.getDateTimeFormat(context).format(initialCheck);
|
||||
@@ -89,45 +162,16 @@ public class UILinkValidationSummary extends AbstractLinkValidationReportCompone
|
||||
pattern = bundle.getString("files_links_broken");
|
||||
String initialBrokenSummary = MessageFormat.format(pattern,
|
||||
new Object[] {linkState.getInitialNumberBrokenFiles(), linkState.getInitialNumberBrokenLinks()});
|
||||
pattern = bundle.getString("files_links_still_broken");
|
||||
String stillBroken = MessageFormat.format(pattern,
|
||||
new Object[] {linkState.getNumberBrokenFiles(), linkState.getNumberBrokenLinks()});
|
||||
pattern = bundle.getString("broken_links_fixed");
|
||||
String linksFixed = MessageFormat.format(pattern,
|
||||
new Object[] {linkState.getNumberFixedLinks()});
|
||||
|
||||
// get the action to update the current status
|
||||
UICommand updateStatusAction = aquireAction(context, "update_status_" + linkState.getStore());
|
||||
|
||||
// render the summary area
|
||||
out.write("<div class='linkValidationSummaryPanel'><div class='linkValidationReportTitle'>");
|
||||
out.write(bundle.getString("summary"));
|
||||
out.write("</div><table cellpadding='0' cellspacing='0'><tr>");
|
||||
out.write("<td valign='top' class='linkValidationReportSubTitle'>");
|
||||
out.write(bundle.getString("initial_check"));
|
||||
out.write(":</td><td><div style='margin-bottom: 6px;'>");
|
||||
out.write("<div style='margin-bottom: 6px;'>");
|
||||
out.write(initialCheckSummary);
|
||||
out.write("</div><div style='margin-bottom: 14px;'><img src='");
|
||||
out.write(context.getExternalContext().getRequestContextPath());
|
||||
out.write("/images/icons/broken_link.gif'' style='vertical-align: -4px; padding-right: 4px;'/>");
|
||||
out.write(initialBrokenSummary);
|
||||
out.write("</div></td></tr>");
|
||||
out.write("<tr><td class='linkValidationReportSubTitle'>");
|
||||
out.write(bundle.getString("current_status"));
|
||||
out.write(":</td><td><div><img src='");
|
||||
out.write(context.getExternalContext().getRequestContextPath());
|
||||
out.write("/images/icons/broken_link.gif' style='vertical-align: -4px; padding-right: 4px;' >");
|
||||
out.write(stillBroken);
|
||||
out.write("<img src='");
|
||||
out.write(context.getExternalContext().getRequestContextPath());
|
||||
out.write("/images/icons/fixed_link.gif' style='vertical-align: -4px; padding-left: 6px; padding-right: 4px;' >");
|
||||
out.write(linksFixed);
|
||||
out.write(" ");
|
||||
Utils.encodeRecursive(context, updateStatusAction);
|
||||
out.write("</div></td></tr>");
|
||||
out.write("</table></div>");
|
||||
out.write("</div>");
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private UICommand aquireAction(FacesContext context, String actionId)
|
||||
{
|
||||
|
@@ -36,6 +36,7 @@ import org.alfresco.web.ui.common.tag.HtmlComponentTag;
|
||||
public class LinkValidationSummaryTag extends HtmlComponentTag
|
||||
{
|
||||
private String value;
|
||||
private String initialCheckOnly;
|
||||
|
||||
/**
|
||||
* @see javax.faces.webapp.UIComponentTag#getComponentType()
|
||||
@@ -61,6 +62,7 @@ public class LinkValidationSummaryTag extends HtmlComponentTag
|
||||
super.setProperties(component);
|
||||
|
||||
setStringProperty(component, "value", this.value);
|
||||
setBooleanProperty(component, "initialCheckOnly", this.initialCheckOnly);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,6 +72,7 @@ public class LinkValidationSummaryTag extends HtmlComponentTag
|
||||
{
|
||||
super.release();
|
||||
this.value = null;
|
||||
this.initialCheckOnly = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,4 +82,12 @@ public class LinkValidationSummaryTag extends HtmlComponentTag
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param initialCheckOnly true will make the component only show the initial check summary info
|
||||
*/
|
||||
public void setInitialCheckOnly(String initialCheckOnly)
|
||||
{
|
||||
this.initialCheckOnly = initialCheckOnly;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user