diff --git a/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java b/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java index 771574ab66..3a9fe64bf4 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java @@ -45,6 +45,7 @@ import javax.transaction.UserTransaction; import org.alfresco.config.ConfigElement; import org.alfresco.config.ConfigService; import org.alfresco.linkvalidation.HrefValidationProgress; +import org.alfresco.linkvalidation.LinkValidationService; import org.alfresco.model.ContentModel; import org.alfresco.model.WCMAppModel; import org.alfresco.repo.avm.AVMNodeConverter; @@ -104,6 +105,7 @@ import org.alfresco.web.ui.wcm.component.UIUserSandboxes; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.web.jsf.FacesContextUtils; /** * Bean backing up the AVM specific browse screens @@ -228,10 +230,12 @@ public class AVMBrowseBean implements IContextListener /** The SearchService reference */ transient private SearchService searchService; + /** The LinkValidationService */ + transient private LinkValidationService linkValidationService; + /** The PermissionService reference */ transient protected PermissionService permissionService; - /** * Default Constructor */ @@ -320,6 +324,22 @@ public class AVMBrowseBean implements IContextListener return workflowService; } + public void setLinkValidationService(LinkValidationService service) + { + this.linkValidationService = service; + } + + protected LinkValidationService getLinkValidationService() + { + if (linkValidationService == null) + { + linkValidationService = (LinkValidationService)FacesContextUtils.getRequiredWebApplicationContext( + FacesContext.getCurrentInstance()).getBean("LinkValidationService"); + } + + return this.linkValidationService; + } + /** * @param searchService The Searcher to set. */ @@ -675,6 +695,14 @@ public class AVMBrowseBean implements IContextListener { this.linkValidationState = state; } + + /** + * @return Determines whether the link validation service is enabled + */ + public boolean isLinkValidationEnabled() + { + return (this.getLinkValidationService().getPollInterval() > 0); + } public List getNodesForSubmit() { diff --git a/source/java/org/alfresco/web/ui/wcm/component/UIUserSandboxes.java b/source/java/org/alfresco/web/ui/wcm/component/UIUserSandboxes.java index 4e2fe1a46e..6d733400be 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/UIUserSandboxes.java +++ b/source/java/org/alfresco/web/ui/wcm/component/UIUserSandboxes.java @@ -63,6 +63,7 @@ import org.alfresco.web.app.servlet.FacesHelper; import org.alfresco.web.bean.BrowseBean; import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.User; +import org.alfresco.web.bean.wcm.AVMBrowseBean; import org.alfresco.web.bean.wcm.AVMNode; import org.alfresco.web.bean.wcm.AVMUtil; import org.alfresco.web.bean.wcm.DeploymentUtil; @@ -303,7 +304,7 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa UserTransaction tx = null; try { - tx = Repository.getUserTransaction(FacesContext.getCurrentInstance(), true); + tx = Repository.getUserTransaction(context, true); tx.begin(); NodeRef websiteRef = getValue(); @@ -323,6 +324,14 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa // sort the user list alphabetically and insert the current user at the top of the list List userRoleWrappers = buildSortedUserRoles(nodeService, currentUserName, userInfoRefs); + // determine whether the check links action should be shown + boolean linkValidationEnabled = true; + AVMBrowseBean avmBrowseBean = (AVMBrowseBean)FacesHelper.getManagedBean(context, "AVMBrowseBean"); + if (avmBrowseBean != null) + { + linkValidationEnabled = avmBrowseBean.isLinkValidationEnabled(); + } + // determine whether the deploy action should be shown boolean deployServersConfigured = false; List deployToServers = DeploymentUtil.findTestServers(websiteRef, false); @@ -447,17 +456,20 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa menu.getChildren().clear(); // Check Links action - Map params = new HashMap(6); - params.put("store", mainStore); - params.put("username", username); - params.put("webapp", this.getWebapp()); - params.put("mode", "runReport"); - params.put("compareToStaging", "true"); - UIActionLink checkLinks = createAction(context, mainStore, username, - ACT_SANDBOX_CHECK_LINKS, "/images/icons/run_link_validation.gif", - "#{DialogManager.setupParameters}", "dialog:linkValidation", - null, params, false); - menu.getChildren().add(checkLinks); + if (linkValidationEnabled) + { + Map params = new HashMap(6); + params.put("store", mainStore); + params.put("username", username); + params.put("webapp", this.getWebapp()); + params.put("mode", "runReport"); + params.put("compareToStaging", "true"); + UIActionLink checkLinks = createAction(context, mainStore, username, + ACT_SANDBOX_CHECK_LINKS, "/images/icons/run_link_validation.gif", + "#{DialogManager.setupParameters}", "dialog:linkValidation", + null, params, false); + menu.getChildren().add(checkLinks); + } // Deploy action if (deployServersConfigured) diff --git a/source/web/WEB-INF/faces-config-beans.xml b/source/web/WEB-INF/faces-config-beans.xml index 9b9960f16f..cd48079f17 100644 --- a/source/web/WEB-INF/faces-config-beans.xml +++ b/source/web/WEB-INF/faces-config-beans.xml @@ -3395,6 +3395,10 @@ searchService #{SearchService} + + linkValidationService + #{LinkValidationService} + permissionService #{PermissionService} diff --git a/source/web/jsp/wcm/browse-website.jsp b/source/web/jsp/wcm/browse-website.jsp index d159020d40..70420df03a 100644 --- a/source/web/jsp/wcm/browse-website.jsp +++ b/source/web/jsp/wcm/browse-website.jsp @@ -140,7 +140,8 @@ + actionListener="#{DialogManager.setupParameters}" action="dialog:linkValidation" + rendered="#{AVMBrowseBean.linkValidationEnabled}">