diff --git a/config/alfresco/web-client-config-wcm-actions.xml b/config/alfresco/web-client-config-wcm-actions.xml index d033f53511..70613ff1bb 100644 --- a/config/alfresco/web-client-config-wcm-actions.xml +++ b/config/alfresco/web-client-config-wcm-actions.xml @@ -384,6 +384,18 @@ + + + + + + + + + + + + diff --git a/source/java/org/alfresco/web/ui/wcm/component/AbstractLinkValidationReportComponent.java b/source/java/org/alfresco/web/ui/wcm/component/AbstractLinkValidationReportComponent.java index 5af23ac2c8..a0fb95638f 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/AbstractLinkValidationReportComponent.java +++ b/source/java/org/alfresco/web/ui/wcm/component/AbstractLinkValidationReportComponent.java @@ -27,6 +27,7 @@ package org.alfresco.web.ui.wcm.component; import java.io.IOException; import java.util.List; +import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import javax.faces.el.ValueBinding; @@ -35,6 +36,7 @@ import org.alfresco.config.JNDIConstants; import org.alfresco.web.app.Application; import org.alfresco.web.bean.wcm.LinkValidationState; import org.alfresco.web.ui.common.component.SelfRenderingComponent; +import org.alfresco.web.ui.repo.component.UIActions; /** * Base class for all the link validation report JSF components. @@ -67,6 +69,22 @@ public abstract class AbstractLinkValidationReportComponent extends SelfRenderin values[1] = this.state; return values; } + + /** + * @see javax.faces.component.UIComponentBase#getRendersChildren() + */ + public boolean getRendersChildren() + { + return true; + } + + /** + * @see javax.faces.component.UIComponentBase#encodeChildren(javax.faces.context.FacesContext) + */ + public void encodeChildren(FacesContext context) throws IOException + { + // the child components are rendered explicitly during the encodeBegin() + } // ------------------------------------------------------------------------------ // Helper methods @@ -229,6 +247,45 @@ public abstract class AbstractLinkValidationReportComponent extends SelfRenderin return icon; } + /** + * Aquire the UIActions component for the specified action group ID. + * Search for the component in the child list or create as needed. + * + * @param id ActionGroup id of the UIActions component + * + * @return UIActions component + */ + @SuppressWarnings("unchecked") + protected UIActions aquireUIActions(String id, String store) + { + UIActions uiActions = null; + String componentId = id + '_' + store; + + for (UIComponent component : (List)getChildren()) + { + if (componentId.equals(component.getId())) + { + uiActions = (UIActions)component; + break; + } + } + + if (uiActions == null) + { + javax.faces.application.Application facesApp = FacesContext.getCurrentInstance().getApplication(); + uiActions = (UIActions)facesApp.createComponent("org.alfresco.faces.Actions"); + uiActions.setShowLink(false); + uiActions.getAttributes().put("styleClass", "inlineAction"); + uiActions.setId(componentId); + uiActions.setParent(this); + uiActions.setValue(id); + + this.getChildren().add(uiActions); + } + + return uiActions; + } + // ------------------------------------------------------------------------------ // Strongly typed component property accessors diff --git a/source/java/org/alfresco/web/ui/wcm/component/UILinkValidationBrokenFiles.java b/source/java/org/alfresco/web/ui/wcm/component/UILinkValidationBrokenFiles.java index a4df3afa6e..1b1fff8201 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/UILinkValidationBrokenFiles.java +++ b/source/java/org/alfresco/web/ui/wcm/component/UILinkValidationBrokenFiles.java @@ -30,8 +30,16 @@ import java.util.List; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; +import org.alfresco.service.cmr.avm.AVMNodeDescriptor; +import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.web.app.Application; +import org.alfresco.web.bean.repository.Repository; +import org.alfresco.web.bean.wcm.AVMNode; +import org.alfresco.web.bean.wcm.AVMUtil; import org.alfresco.web.bean.wcm.LinkValidationState; +import org.alfresco.web.config.ClientConfigElement; +import org.alfresco.web.ui.common.Utils; +import org.alfresco.web.ui.repo.component.UIActions; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -84,9 +92,19 @@ public class UILinkValidationBrokenFiles extends AbstractLinkValidationReportCom } else { + UIActions actions = aquireUIActions("broken_file_actions", getValue().getStore()); + AVMService avmService = Repository.getServiceRegistry(context).getAVMService(); + int rootPathIndex = AVMUtil.buildSandboxRootPath(linkState.getStore()).length(); + String dns = AVMUtil.lookupStoreDNS(linkState.getStore()); + ClientConfigElement config = Application.getClientConfig(context); + String wcmDomain = config.getWCMDomain(); + String wcmPort = config.getWCMPort(); + + // render each broken file for (String file : brokenFiles) { - renderBrokenFile(context, out, file, linkState); + renderBrokenFile(context, out, file, linkState, actions, avmService, + rootPathIndex, wcmDomain, wcmPort, dns); } } @@ -97,7 +115,10 @@ public class UILinkValidationBrokenFiles extends AbstractLinkValidationReportCom // Helpers private void renderBrokenFile(FacesContext context, ResponseWriter out, - String file, LinkValidationState linkState) throws IOException + String file, LinkValidationState linkState, UIActions actions, + AVMService avmService, int rootPathIndex, String wcmDomain, + String wcmPort, String dns) + throws IOException { // gather the data to show for the file String[] nameAndPath = this.getFileNameAndPath(file); @@ -126,11 +147,19 @@ public class UILinkValidationBrokenFiles extends AbstractLinkValidationReportCom out.write("'>"); renderFile(out, context, fileName, filePath, brokenLinks); out.write("
"); - out.write(" "); -// out.write(" "); -// out.write(" "); -// out.write(" "); -// out.write(" "); + + // setup the context for the actions + AVMNodeDescriptor desc = avmService.lookup(-1, file); + AVMNode node = new AVMNode(desc); + + String assetPath = file.substring(rootPathIndex); + String previewUrl = AVMUtil.buildAssetUrl(assetPath, wcmDomain, wcmPort, dns); + node.getProperties().put("previewUrl", previewUrl); + actions.setContext(node); + + // render the actions + Utils.encodeRecursive(context, actions); + out.write("
"); } } diff --git a/source/java/org/alfresco/web/ui/wcm/component/UILinkValidationBrokenForms.java b/source/java/org/alfresco/web/ui/wcm/component/UILinkValidationBrokenForms.java index fe189380a4..30c72a5eb3 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/UILinkValidationBrokenForms.java +++ b/source/java/org/alfresco/web/ui/wcm/component/UILinkValidationBrokenForms.java @@ -30,8 +30,15 @@ import java.util.List; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; +import org.alfresco.service.cmr.avm.AVMNodeDescriptor; +import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.web.app.Application; +import org.alfresco.web.bean.repository.Repository; +import org.alfresco.web.bean.wcm.AVMNode; +import org.alfresco.web.bean.wcm.AVMUtil; import org.alfresco.web.bean.wcm.LinkValidationState; +import org.alfresco.web.ui.common.Utils; +import org.alfresco.web.ui.repo.component.UIActions; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -84,9 +91,12 @@ public class UILinkValidationBrokenForms extends AbstractLinkValidationReportCom } else { + UIActions actions = aquireUIActions("broken_form_actions", getValue().getStore()); + AVMService avmService = Repository.getServiceRegistry(context).getAVMService(); + for (String form : brokenForms) { - renderBrokenForm(context, out, form, linkState); + renderBrokenForm(context, out, form, linkState, actions, avmService); } } @@ -97,7 +107,8 @@ public class UILinkValidationBrokenForms extends AbstractLinkValidationReportCom // Helpers private void renderBrokenForm(FacesContext context, ResponseWriter out, - String file, LinkValidationState linkState) throws IOException + String file, LinkValidationState linkState, UIActions actions, + AVMService avmService) throws IOException { // get the web form name and path String[] formNamePath = this.getFileNameAndPath(file); @@ -146,7 +157,15 @@ public class UILinkValidationBrokenForms extends AbstractLinkValidationReportCom out.write("
"); out.write(" "); -// out.write(" "); + + // setup the context for the actions + AVMNodeDescriptor desc = avmService.lookup(-1, file); + AVMNode node = new AVMNode(desc); + actions.setContext(node); + + // render the actions + Utils.encodeRecursive(context, actions); + out.write("
"); } }