mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
6636: Temporary hack to fix build. 6637: Better handling of binary string bufs, disable link validation when poll interval is <= 0 6638: Forgotten files for TXT to PDF transformer. 6639: Fix for AWC-1541 6641: Fix for WCM-792. 6642: A little extra PropertyValue support for createNode, too. 6643: Fix for WCM-791 6644: Closure of AR-1528: Check concurrency handling of DuplicateChildNodeNameException 6647: Fix WCM-794 6648: WCM-656 6650: Applied user supplied patch to fix AWC-1546 - Cannot mount AVM using CIFS on new alfresco installation. 6651: Index tidy ups 6654: Various minor updates for passthru authentication debugging and error handling. 6657: Fix for WCM-799 (Some items selected for submission were not present) 6659: Updated installers. 6660: Partial fix to AWC-1524 6661: Fix WCM-803 6664: Including hibernate-3.2.1.jar in $VIRTUAL_TOMCAT_HOME/server/lib/ 6665: adding an automated unit test for output path patterns. 6668: Fixed to add shale-test-1.0.4.jar to Eclipse classpath (PHH oked) 6681: Fixes WCM-811 - Lookup.getIndirectionPath() had a bit of a howler in it. 6684: UncategorizedSQLException with the word 'deadlock' in the message is now cause for retrying a transaction. 6691: Fix for WCM-813 (lock not removed when expiration date set and no workflow on web project) 6696: Imporved SSO filters for SiteMinder etc + test filter 6697: Support for scheduled import 6699: Fix for the compliation target: compile-benchmarkframework 6701: Fix for 1.6 JVMs (1.5 gets by with lucky ordering) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6749 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
397 lines
13 KiB
Java
397 lines
13 KiB
Java
/*
|
|
* 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.io.Serializable;
|
|
import java.text.MessageFormat;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
import javax.faces.context.FacesContext;
|
|
import javax.faces.event.ActionEvent;
|
|
import javax.transaction.UserTransaction;
|
|
|
|
import org.alfresco.linkvalidation.HrefValidationProgress;
|
|
import org.alfresco.linkvalidation.LinkValidationAction;
|
|
import org.alfresco.linkvalidation.LinkValidationReport;
|
|
import org.alfresco.repo.avm.AVMNodeConverter;
|
|
import org.alfresco.repo.domain.PropertyValue;
|
|
import org.alfresco.sandbox.SandboxConstants;
|
|
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.Application;
|
|
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
|
import org.alfresco.web.bean.repository.Repository;
|
|
import org.alfresco.web.ui.common.Utils;
|
|
import org.alfresco.web.ui.common.component.UIActionLink;
|
|
import org.alfresco.web.ui.wcm.component.UILinkValidationReport;
|
|
import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
/**
|
|
* Implementation of the link validation dialog.
|
|
*
|
|
* The dialog is in one of 2 modes, either running a report showing progress
|
|
* or showing the results of an executed link check.
|
|
*
|
|
* @author gavinc
|
|
*/
|
|
public class LinkValidationDialog extends BaseDialogBean
|
|
{
|
|
protected AVMBrowseBean avmBrowseBean;
|
|
protected AVMService avmService;
|
|
protected ActionService actionService;
|
|
|
|
private String store;
|
|
private String webapp;
|
|
private String webappPath;
|
|
private String initialTab;
|
|
private String title;
|
|
private NodeRef webappPathRef;
|
|
private boolean runningReport = false;
|
|
private boolean update = false;
|
|
private boolean compareToStaging = false;
|
|
private boolean sectionsExpanded = false;
|
|
|
|
private static final Log logger = LogFactory.getLog(LinkValidationDialog.class);
|
|
|
|
// ------------------------------------------------------------------------------
|
|
// Dialog implementation
|
|
|
|
@Override
|
|
public void init(Map<String, String> parameters)
|
|
{
|
|
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
|
|
this.webappPath = AVMUtil.buildStoreWebappPath(this.store, this.webapp);
|
|
this.webappPathRef = AVMNodeConverter.ToNodeRef(-1, this.webappPath);
|
|
this.initialTab = UILinkValidationReport.DEFAULT_INTIAL_TAB;
|
|
|
|
this.runningReport = false;
|
|
String modeParam = parameters.get("mode");
|
|
if (modeParam != null && modeParam.equalsIgnoreCase("runReport"))
|
|
{
|
|
this.runningReport = true;
|
|
}
|
|
|
|
this.update = false;
|
|
String updateParam = parameters.get("update");
|
|
if (updateParam != null && updateParam.equals("true"))
|
|
{
|
|
this.update = true;
|
|
}
|
|
|
|
this.compareToStaging = false;
|
|
String compareToStagingParam = parameters.get("compareToStaging");
|
|
if (compareToStagingParam != null && compareToStagingParam.equalsIgnoreCase("true"))
|
|
{
|
|
this.compareToStaging = true;
|
|
}
|
|
|
|
// work out title for dialog by examining store type
|
|
FacesContext context = FacesContext.getCurrentInstance();
|
|
if (this.avmService.getStoreProperty(this.store,
|
|
SandboxConstants.PROP_SANDBOX_AUTHOR_MAIN) != null)
|
|
{
|
|
String pattern = Application.getMessage(context, "link_validaton_dialog_title_user");
|
|
String user = this.store.substring(
|
|
this.store.indexOf(AVMUtil.STORE_SEPARATOR)+AVMUtil.STORE_SEPARATOR.length());
|
|
this.title = MessageFormat.format(pattern,
|
|
new Object[] {user});
|
|
}
|
|
else if (this.avmService.getStoreProperty(this.store,
|
|
SandboxConstants.PROP_SANDBOX_STAGING_MAIN) != null)
|
|
{
|
|
this.title = Application.getMessage(context, "link_validaton_dialog_title_staging");
|
|
}
|
|
else if (this.avmService.getStoreProperty(this.store,
|
|
SandboxConstants.PROP_SANDBOX_WORKFLOW_MAIN) != null)
|
|
{
|
|
this.title = Application.getMessage(context, "link_validaton_dialog_title_workflow");
|
|
}
|
|
|
|
if (logger.isDebugEnabled())
|
|
{
|
|
if (this.runningReport)
|
|
{
|
|
if (this.update)
|
|
logger.debug("Starting update link validation check for webapp '" + this.webappPath + "'");
|
|
else
|
|
logger.debug("Starting initial link validation check for webapp '" + this.webappPath + "'");
|
|
}
|
|
else
|
|
{
|
|
logger.debug("Showing link validation report for webapp '" + this.webappPath + "'");
|
|
}
|
|
}
|
|
|
|
// execute the report if required
|
|
if (this.runningReport)
|
|
{
|
|
executeReport();
|
|
}
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
@Override
|
|
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
|
{
|
|
if (logger.isDebugEnabled())
|
|
logger.debug("Starting fresh link validation check for webapp '" + this.webappPath + "'");
|
|
|
|
// indicate we need a new report produced then execute
|
|
this.update = false;
|
|
this.runningReport = true;
|
|
executeReport();
|
|
|
|
// reset the isFinished flag so we can run the report again
|
|
this.isFinished = false;
|
|
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public String getContainerTitle()
|
|
{
|
|
return this.title;
|
|
}
|
|
|
|
@Override
|
|
public boolean getFinishButtonDisabled()
|
|
{
|
|
return this.runningReport;
|
|
}
|
|
|
|
@Override
|
|
public String getFinishButtonLabel()
|
|
{
|
|
return Application.getMessage(FacesContext.getCurrentInstance(), "rerun_report");
|
|
}
|
|
|
|
@Override
|
|
public String getCancelButtonLabel()
|
|
{
|
|
return Application.getMessage(FacesContext.getCurrentInstance(), "close");
|
|
}
|
|
|
|
// ------------------------------------------------------------------------------
|
|
// Event handlers
|
|
|
|
public String linkCheckCompleted()
|
|
{
|
|
String outcome = null;
|
|
|
|
// indicate that we are now showing a report
|
|
this.runningReport = false;
|
|
|
|
if (logger.isDebugEnabled())
|
|
{
|
|
if (this.update)
|
|
logger.debug("Link check has completed, updating state object");
|
|
else
|
|
logger.debug("Link check has completed, creating state object");
|
|
}
|
|
|
|
// the link validation report should be stored as a store property
|
|
// on the store the link check was run on, retrieve it and see if
|
|
// the link check was successful.
|
|
|
|
FacesContext context = FacesContext.getCurrentInstance();
|
|
UserTransaction tx = null;
|
|
|
|
try
|
|
{
|
|
tx = Repository.getUserTransaction(context, true);
|
|
tx.begin();
|
|
|
|
PropertyValue val = this.avmService.getStoreProperty(this.store,
|
|
SandboxConstants.PROP_LINK_VALIDATION_REPORT);
|
|
if (val != null)
|
|
{
|
|
LinkValidationReport report = (LinkValidationReport)val.getSerializableValue();
|
|
if (report != null)
|
|
{
|
|
// setup the context required by the reporting components to display the results
|
|
if (this.update)
|
|
{
|
|
this.avmBrowseBean.getLinkValidationState().updateState(report);
|
|
}
|
|
else
|
|
{
|
|
LinkValidationState state = new LinkValidationState(report);
|
|
this.avmBrowseBean.setLinkValidationState(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);
|
|
}
|
|
|
|
return outcome;
|
|
}
|
|
|
|
public void toggleSections(ActionEvent event)
|
|
{
|
|
this.sectionsExpanded = !this.sectionsExpanded;
|
|
|
|
UIActionLink link = (UIActionLink)event.getComponent();
|
|
Map<String, String> params = link.getParameterMap();
|
|
String tab = params.get("tab");
|
|
|
|
if (tab != null)
|
|
{
|
|
this.initialTab = tab;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Sets up the dialog to update the status and display the differences
|
|
*
|
|
* @return The outcome, null to stay on this page
|
|
*/
|
|
public String updateStatus()
|
|
{
|
|
if (logger.isDebugEnabled())
|
|
logger.debug("Updating status for link validation report for webapp '" + this.webappPath + "'");
|
|
|
|
// indicate we need an update report produced then execute
|
|
this.update = true;
|
|
this.runningReport = true;
|
|
executeReport();
|
|
|
|
return null;
|
|
}
|
|
|
|
// ------------------------------------------------------------------------------
|
|
// Helpers
|
|
|
|
protected void executeReport()
|
|
{
|
|
if (logger.isDebugEnabled())
|
|
logger.debug("Creating LinkValidationAction to run report 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.webappPathRef, false, true);
|
|
}
|
|
|
|
// ------------------------------------------------------------------------------
|
|
// Bean getters and setters
|
|
|
|
/**
|
|
* @return true if the dialog is currently running a report
|
|
*/
|
|
public boolean getRunningReport()
|
|
{
|
|
return this.runningReport;
|
|
}
|
|
|
|
/**
|
|
* @return true if the dialog is currently showing a report
|
|
*/
|
|
public boolean getShowingReport()
|
|
{
|
|
return !this.runningReport;
|
|
}
|
|
|
|
/**
|
|
* @return true if the broken links and generated files section are expanded
|
|
*/
|
|
public boolean getSectionsExpanded()
|
|
{
|
|
return sectionsExpanded;
|
|
}
|
|
|
|
/**
|
|
* @param sectionsExpanded true if the broken links and generated
|
|
* files section are expanded
|
|
*/
|
|
public void setSectionsExpanded(boolean sectionsExpanded)
|
|
{
|
|
this.sectionsExpanded = sectionsExpanded;
|
|
}
|
|
|
|
/**
|
|
* @return The initial tab to be selected
|
|
*/
|
|
public String getInitialTab()
|
|
{
|
|
return initialTab;
|
|
}
|
|
|
|
/**
|
|
* @param initialTab Sets the initial tab to be selected
|
|
*/
|
|
public void setInitialTab(String initialTab)
|
|
{
|
|
this.initialTab = initialTab;
|
|
}
|
|
|
|
/**
|
|
* @param avmBrowseBean The AVM BrowseBean to set
|
|
*/
|
|
public void setAvmBrowseBean(AVMBrowseBean avmBrowseBean)
|
|
{
|
|
this.avmBrowseBean = avmBrowseBean;
|
|
}
|
|
|
|
public void setAvmService(AVMService avmService)
|
|
{
|
|
this.avmService = avmService;
|
|
}
|
|
|
|
/**
|
|
* @param actionService The actionService to set.
|
|
*/
|
|
public void setActionService(ActionService actionService)
|
|
{
|
|
this.actionService = actionService;
|
|
}
|
|
}
|