From 9abfab20ab07db47b3b83973d12063d98c73acea Mon Sep 17 00:00:00 2001 From: Gavin Cornwell Date: Tue, 12 Jun 2007 20:35:11 +0000 Subject: [PATCH] More functionality added to links management UI - Report now shows date/time when report was executed - Report now shows forms with broken links - Fixed items are now displayed - Current status stats are now correct git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5922 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/messages/webclient.properties | 10 +- .../web/bean/wcm/LinkValidationState.java | 205 ++++++++++++------ ...AbstractLinkValidationReportComponent.java | 167 ++++++++++++++ .../UILinkValidationBrokenFiles.java | 88 ++------ .../UILinkValidationBrokenForms.java | 156 +++++++++++++ .../component/UILinkValidationFixedFiles.java | 66 +++--- .../component/UILinkValidationSummary.java | 7 +- .../wcm/tag/LinkValidationBrokenFormsTag.java | 82 +++++++ source/web/WEB-INF/faces-config-wcm.xml | 5 + source/web/WEB-INF/wcm.tld | 29 +++ source/web/css/main.css | 13 +- source/web/jsp/wcm/link-validation-report.jsp | 1 + 12 files changed, 657 insertions(+), 172 deletions(-) create mode 100644 source/java/org/alfresco/web/ui/wcm/component/UILinkValidationBrokenForms.java create mode 100644 source/java/org/alfresco/web/ui/wcm/tag/LinkValidationBrokenFormsTag.java diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties index 572ef27c39..25bd83ff98 100644 --- a/config/alfresco/messages/webclient.properties +++ b/config/alfresco/messages/webclient.properties @@ -1142,14 +1142,18 @@ link_validaton_report_title=Link Validation Report link_validaton_report_desc=This dialog shows the results of the last link validation and allows broken links to be fixed. initial_check=Initial check current_status=Current status -files_links_checked={0} file(s) were checked, {1} link(s) were found. +files_links_checked=The check was completed at {0}, {1} file(s) were checked and {2} link(s) were found. files_links_broken={0} broken link(s) were found in {1} file(s). files_links_still_broken={0} link(s) still broken in {1} file(s). broken_links_fixed={0} broken link(s) have been fixed. -files_with_broken_links=Files with broken links +files_with_broken_links=Files with broken links (not generated by web forms) +forms_with_broken_links=Files with broken links (generated by web forms) +generated_files=Generated Files broken_links=Broken Links rerun_report=Re-Run Report -fixed_files=Files that have been fixed +update_status=Update Status +fixed_items=Items you have fixed +no_items=No items to display # New User Wizard messages new_user_title=New User Wizard diff --git a/source/java/org/alfresco/web/bean/wcm/LinkValidationState.java b/source/java/org/alfresco/web/bean/wcm/LinkValidationState.java index 783c5ab33a..96614864e5 100644 --- a/source/java/org/alfresco/web/bean/wcm/LinkValidationState.java +++ b/source/java/org/alfresco/web/bean/wcm/LinkValidationState.java @@ -25,12 +25,20 @@ package org.alfresco.web.bean.wcm; import java.util.ArrayList; -import java.util.Collections; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.faces.context.FacesContext; + import org.alfresco.linkvalidation.LinkValidationReport; +import org.alfresco.model.WCMAppModel; +import org.alfresco.repo.avm.AVMNodeConverter; +import org.alfresco.service.cmr.avm.AVMService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.web.bean.repository.Repository; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -50,6 +58,7 @@ import org.apache.commons.logging.LogFactory; public class LinkValidationState { private String store; + private Date initialCheckedCompletedAt; private boolean checkBeenReRun = false; private int noFilesCheckedStart = 0; @@ -73,14 +82,11 @@ public class LinkValidationState private List brokenStaticFilesLast; private List brokenFormsLast; - private List fixedStaticFiles; + private List fixedFiles; private List fixedForms; - private List fixedStaticFilesLast; - private List fixedFormsLast; - private Map> brokenLinksByFile; - private Map> brokenLinksByForm; + private Map> brokenFilesByForm; private static Log logger = LogFactory.getLog(LinkValidationState.class); @@ -90,6 +96,7 @@ public class LinkValidationState public LinkValidationState(String store, LinkValidationReport initialReport) { this.store = store; + this.initialCheckedCompletedAt = new Date(); processReport(initialReport, false); } @@ -97,6 +104,22 @@ public class LinkValidationState // ------------------------------------------------------------------------------ // Getters + /** + * @return The store this validation state represents + */ + public String getStore() + { + return this.store; + } + + /** + * @return The date the initial check was completed + */ + public Date getInitialCheckCompletedAt() + { + return this.initialCheckedCompletedAt; + } + /** * @return The number of files checked by the initial link check */ @@ -206,9 +229,9 @@ public class LinkValidationState * @param form The name of a form to find broken files for * @return The list of broken files generated by the given form */ - public List getFilesBrokenByForm(String form) + public List getBrokenFilesByForm(String form) { - return this.brokenLinksByForm.get(form); + return this.brokenFilesByForm.get(form); } /** @@ -221,38 +244,23 @@ public class LinkValidationState } /** - * @return The list of non-generated files that have been fixed since the + * @return The list of files that have been fixed since the * initial link check */ - public List getFixedStaticFiles() + public List getFixedFiles() { - return this.fixedStaticFiles; + return this.fixedFiles; } /** - * @return The list of forms that have been fixed since the initial link check + * @return The list of forms that have been fixed since the + * initial link check */ public List getFixedForms() { return this.fixedForms; } - /** - * @return The list of non-generated files fixed in the last run of the link check - */ - public List getStaticFilesFixedInLastRun() - { - return this.fixedStaticFilesLast; - } - - /** - * @return The list of forms fixed in the last run of the link check - */ - public List getFormsFixedInLastRun() - { - return this.fixedFormsLast; - } - // ------------------------------------------------------------------------------ // Implementation @@ -279,6 +287,7 @@ public class LinkValidationState processReport(newReport, true); } + @Override public String toString() { StringBuilder buffer = new StringBuilder(super.toString()); @@ -289,11 +298,11 @@ public class LinkValidationState // ------------------------------------------------------------------------------ // Private Helpers - public void processReport(LinkValidationReport report, boolean updatedReport) + public void processReport(LinkValidationReport report, boolean rerunReport) { - this.checkBeenReRun = updatedReport; + this.checkBeenReRun = rerunReport; - if (updatedReport == false) + if (rerunReport == false) { // setup initial counts this.noBrokenFilesStart = report.getNumberBrokenFiles(); @@ -305,27 +314,13 @@ public class LinkValidationState this.noFilesCheckedLast = report.getNumberFilesChecked(); this.noLinksCheckedLast = report.getNumberLinksChecked(); - // setup initial lists - this.brokenStaticFilesStart = report.getFilesWithBrokenLinks(); - this.brokenFormsStart = Collections.emptyList(); - this.brokenStaticFilesLast = report.getFilesWithBrokenLinks(); - this.brokenFormsLast = Collections.emptyList(); - - this.fixedStaticFiles = Collections.emptyList(); - this.fixedForms = Collections.emptyList(); - this.fixedFormsLast = Collections.emptyList(); - this.fixedStaticFiles = Collections.emptyList(); - this.fixedStaticFilesLast = Collections.emptyList(); - - // setup initial maps - this.brokenLinksByFile = new HashMap>(); - this.brokenLinksByForm = Collections.emptyMap(); - - // populate initial maps - for (String file : this.brokenStaticFilesLast) - { - this.brokenLinksByFile.put(file, report.getBrokenLinksForFile(file)); - } + // setup fixed lists + this.fixedFiles = new ArrayList(this.noBrokenFilesStart); + this.fixedForms = new ArrayList(this.noBrokenFilesStart); + + // process the broken files and determine which ones are static files + // and which ones are generated + processFiles(report.getFilesWithBrokenLinks(), rerunReport, report); } else { @@ -347,27 +342,111 @@ public class LinkValidationState this.noFixedLinks = 0; } - // go through the list of files still broken and find which ones + // 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 - this.brokenStaticFilesLast = report.getFilesWithBrokenLinks(); - this.fixedStaticFiles = new ArrayList(); - this.fixedStaticFilesLast = new ArrayList(); for (String file : this.brokenStaticFilesStart) { - if (this.brokenStaticFilesLast.contains(file) == false) + if (this.brokenStaticFilesLast.contains(file) == false && + this.fixedFiles.contains(file) == false) { - this.fixedStaticFilesLast.add(file); - this.fixedStaticFiles.add(file); + this.fixedFiles.add(file); } } - - // update the broken files info - this.brokenLinksByFile.clear(); - for (String file : this.brokenStaticFilesLast) + for (String file : this.brokenFormsStart) { + if (this.brokenFormsLast.contains(file) == false && + this.fixedForms.contains(file) == false) + { + this.fixedForms.add(file); + } + } + } + } + + protected void processFiles(List files, boolean rerunReport, LinkValidationReport report) + { + AVMService avmService = Repository.getServiceRegistry( + FacesContext.getCurrentInstance()).getAVMService(); + NodeService nodeService = Repository.getServiceRegistry( + FacesContext.getCurrentInstance()).getNodeService(); + + if (logger.isDebugEnabled()) + { + if (rerunReport) + logger.debug("Processing files from updated report: " + report); + else + logger.debug("Processing files from initial report: " + report); + } + + // reset the 'last' lists and the maps + this.brokenStaticFilesLast = new ArrayList(this.noBrokenFilesLast); + this.brokenFormsLast = new ArrayList(this.noBrokenFilesLast); + this.brokenFilesByForm = new HashMap>(this.noBrokenFilesLast); + this.brokenLinksByFile = new HashMap>(this.noBrokenFilesLast); + + // iterate around the files and determine which ones are generated and static + for (String file : files) + { + if (avmService.hasAspect(-1, file, WCMAppModel.ASPECT_FORM_INSTANCE_DATA)) + { + if (avmService.hasAspect(-1, file, WCMAppModel.ASPECT_RENDITION)) + { + if (logger.isDebugEnabled()) + logger.debug("Processing generated file: " + file); + + // store the broken links in the file + this.brokenLinksByFile.put(file, report.getBrokenLinksForFile(file)); + + // find the XML that generated this file + NodeRef nodeRef = AVMNodeConverter.ToNodeRef(-1, file); + String xmlPath = (String)nodeService.getProperty(nodeRef, + WCMAppModel.PROP_PRIMARY_FORM_INSTANCE_DATA); + xmlPath = this.store + ":" + xmlPath; + + if (logger.isDebugEnabled()) + logger.debug("Found source XML for '" + file + "': " + xmlPath); + + // store the XML as a broken form (if not already) + if (this.brokenFormsLast.contains(xmlPath) == false) + { + this.brokenFormsLast.add(xmlPath); + } + + // store the list of files generated by the XML in the map + List genFiles = this.brokenFilesByForm.get(xmlPath); + if (genFiles == null) + { + genFiles = new ArrayList(1); + } + genFiles.add(file); + this.brokenFilesByForm.put(xmlPath, genFiles); + } + } + else + { + if (logger.isDebugEnabled()) + logger.debug("Processing static file: " + file); + + // the file does not have the form instance data aspect so it must + // have been added manually + this.brokenStaticFilesLast.add(file); this.brokenLinksByFile.put(file, report.getBrokenLinksForFile(file)); } } + + // if this is the first run of the report setup the initial lists + if (rerunReport == false) + { + this.brokenStaticFilesStart = new ArrayList(this.brokenStaticFilesLast.size()); + this.brokenStaticFilesStart.addAll(this.brokenStaticFilesLast); + + this.brokenFormsStart = new ArrayList(this.brokenFormsLast.size()); + this.brokenFormsStart.addAll(this.brokenFormsLast); + } } } 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 325652cc28..5af23ac2c8 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/AbstractLinkValidationReportComponent.java +++ b/source/java/org/alfresco/web/ui/wcm/component/AbstractLinkValidationReportComponent.java @@ -24,9 +24,15 @@ */ package org.alfresco.web.ui.wcm.component; +import java.io.IOException; +import java.util.List; + import javax.faces.context.FacesContext; +import javax.faces.context.ResponseWriter; import javax.faces.el.ValueBinding; +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; @@ -62,6 +68,167 @@ public abstract class AbstractLinkValidationReportComponent extends SelfRenderin return values; } + // ------------------------------------------------------------------------------ + // Helper methods + + /** + * Returns the name and path for the given avm path + * + * @param avmPath The path to split + * @return A String array with the name in the first position and the path in the + * second position. + */ + protected String[] getFileNameAndPath(String avmPath) + { + String fileName = avmPath; + String filePath = avmPath; + + int idx = avmPath.lastIndexOf("/"); + if (idx != -1) + { + fileName = avmPath.substring(idx+1); + + int appbaseIdx = avmPath.indexOf(JNDIConstants.DIR_DEFAULT_APPBASE); + if (appbaseIdx != -1) + { + filePath = avmPath.substring(appbaseIdx+JNDIConstants.DIR_DEFAULT_APPBASE.length(), idx); + } + else + { + filePath = avmPath.substring(0, idx); + } + } + + return new String[] {fileName, filePath}; + } + + /** + * Constructs a comma separated list of broken links for the given avm path + * + * @param avmPath The avm path to get the broken links for + * @param linkState The current link valiation state + * @return Comma separated list of broken links + */ + protected String getBrokenLinks(String avmPath, LinkValidationState linkState) + { + List brokenLinks = linkState.getBrokenLinksForFile(avmPath); + StringBuilder builder = new StringBuilder(); + boolean first = true; + for (String link : brokenLinks) + { + if (first == false) + { + builder.append(", "); + } + else + { + first = false; + } + + builder.append(parseBrokenLink(link)); + } + + return builder.toString(); + } + + /** + * Removes the virtulisation server host name from the link if appropriate + * + * @param linkUrl The URL that is broken + * @return Parsed URL + */ + protected String parseBrokenLink(String linkUrl) + { + String link = linkUrl; + + if (linkUrl.startsWith("http://") && linkUrl.indexOf("www--sandbox") != -1) + { + // remove the virtualisation server host name + int idx = linkUrl.indexOf("/", 7); + if (idx != -1) + { + link = linkUrl.substring(idx); + } + } + + return link; + } + + /** + * Renders the HTML to display a file and it's optional broken links + * + * @param out ResponseWriter instance to write to + * @param context FacesContext + * @param fileName Name of the file + * @param filePath Path to the file + * @param brokenLinks List of broken links in the file + * @throws IOException + */ + protected void renderFile(ResponseWriter out, FacesContext context, + String fileName, String filePath, String brokenLinks) throws IOException + { + out.write(""); + out.write("
"); + out.write(fileName); + out.write("
"); + out.write(filePath); + out.write("
"); + + if (brokenLinks != null && brokenLinks.length() > 0) + { + out.write("
"); + out.write(Application.getMessage(context, "broken_links")); + out.write(":
"); + out.write(brokenLinks); + out.write("
"); + } + + out.write("
"); + } + + /** + * Renders the "No items to display" message + * + * @param out ResponseWriter instance to write to + * @param context FacesContext + * @throws IOException + */ + protected void renderNoItems(ResponseWriter out, FacesContext context) + throws IOException + { + out.write("
"); + out.write(Application.getMessage(context, "no_items")); + out.write("
"); + } + + /** + * Returns the icon to use given a file name + * + * @param fileName File name to find an icon for + * @return The path to the icon to use + */ + protected String getIcon(String fileName) + { + // work out what icon to use + String icon = "/images/filetypes32/html.gif"; + String ext = ""; + int idx = fileName.indexOf("."); + if (idx != -1) + { + ext = fileName.substring(idx); + } + + if (ext.equals(".xml")) + { + icon = "/images/icons/webform_large.gif"; + } + + return icon; + } + // ------------------------------------------------------------------------------ // 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 8ac1acf895..a4df3afa6e 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/UILinkValidationBrokenFiles.java +++ b/source/java/org/alfresco/web/ui/wcm/component/UILinkValidationBrokenFiles.java @@ -30,7 +30,6 @@ import java.util.List; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; -import org.alfresco.config.JNDIConstants; import org.alfresco.web.app.Application; import org.alfresco.web.bean.wcm.LinkValidationState; import org.apache.commons.logging.Log; @@ -77,11 +76,18 @@ public class UILinkValidationBrokenFiles extends AbstractLinkValidationReportCom out.write("
"); out.write(Application.getMessage(context, "files_with_broken_links")); out.write("
"); - + List brokenFiles = linkState.getStaticFilesWithBrokenLinks(); - for (String file : brokenFiles) + if (brokenFiles == null || brokenFiles.size() == 0) { - renderBrokenFile(context, out, file, linkState); + renderNoItems(out, context); + } + else + { + for (String file : brokenFiles) + { + renderBrokenFile(context, out, file, linkState); + } } out.write("
"); @@ -94,43 +100,12 @@ public class UILinkValidationBrokenFiles extends AbstractLinkValidationReportCom String file, LinkValidationState linkState) throws IOException { // gather the data to show for the file - String fileName = file; - String filePath = file; - - int idx = file.lastIndexOf("/"); - if (idx != -1) - { - fileName = file.substring(idx+1); - - int appbaseIdx = file.indexOf(JNDIConstants.DIR_DEFAULT_APPBASE); - if (appbaseIdx != -1) - { - filePath = file.substring(appbaseIdx+JNDIConstants.DIR_DEFAULT_APPBASE.length(), idx); - } - else - { - filePath = file.substring(0, idx); - } - } - + String[] nameAndPath = this.getFileNameAndPath(file); + String fileName = nameAndPath[0]; + String filePath = nameAndPath[1]; + // build the list of broken links for the file - List brokenLinks = linkState.getBrokenLinksForFile(file); - StringBuilder builder = new StringBuilder(); - boolean first = true; - for (String link : brokenLinks) - { - if (first == false) - { - builder.append(", "); - } - else - { - first = false; - } - - builder.append(parseBrokenLink(link)); - } - String brokenLinksList = builder.toString(); + String brokenLinks = getBrokenLinks(file, linkState); // render the row with the appropriate background style out.write(""); - out.write("
"); - out.write(fileName); - out.write("
"); - out.write(filePath); - out.write("
"); - out.write(Application.getMessage(context, "broken_links")); - out.write(":
"); - out.write(brokenLinksList); - out.write("
"); - out.write("
"); + out.write("'>"); + renderFile(out, context, fileName, filePath, brokenLinks); + out.write("
"); out.write(" "); // out.write(" "); // out.write(" "); @@ -168,23 +133,6 @@ public class UILinkValidationBrokenFiles extends AbstractLinkValidationReportCom // out.write(" "); out.write("
"); } - - private String parseBrokenLink(String linkUrl) - { - String link = linkUrl; - - if (linkUrl.startsWith("http://") && linkUrl.indexOf("www--sandbox") != -1) - { - // remove the virtualisation server host name - int idx = linkUrl.indexOf("/", 7); - if (idx != -1) - { - link = linkUrl.substring(idx); - } - } - - return link; - } } diff --git a/source/java/org/alfresco/web/ui/wcm/component/UILinkValidationBrokenForms.java b/source/java/org/alfresco/web/ui/wcm/component/UILinkValidationBrokenForms.java new file mode 100644 index 0000000000..fe189380a4 --- /dev/null +++ b/source/java/org/alfresco/web/ui/wcm/component/UILinkValidationBrokenForms.java @@ -0,0 +1,156 @@ +/* + * 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.ui.wcm.component; + +import java.io.IOException; +import java.util.List; + +import javax.faces.context.FacesContext; +import javax.faces.context.ResponseWriter; + +import org.alfresco.web.app.Application; +import org.alfresco.web.bean.wcm.LinkValidationState; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * JSF component that shows the broken form information for a link + * validation report. + * + * @author gavinc + */ +public class UILinkValidationBrokenForms extends AbstractLinkValidationReportComponent +{ + private boolean oddRow = true; + + private static Log logger = LogFactory.getLog(UILinkValidationBrokenForms.class); + + // ------------------------------------------------------------------------------ + // Component implementation + + @Override + public String getFamily() + { + return "org.alfresco.faces.LinkValidationBrokenForms"; + } + + @SuppressWarnings("unchecked") + @Override + public void encodeBegin(FacesContext context) throws IOException + { + if (isRendered() == false) + { + return; + } + + // get the link validation state object to get the data from + ResponseWriter out = context.getResponseWriter(); + LinkValidationState linkState = getValue(); + + if (logger.isDebugEnabled()) + logger.debug("Rendering broken forms from state object: " + linkState); + + // render the list of broken files and their contained links + out.write("
"); + out.write(Application.getMessage(context, "forms_with_broken_links")); + out.write("
"); + + List brokenForms = linkState.getFormsWithBrokenLinks(); + if (brokenForms == null || brokenForms.size() == 0) + { + renderNoItems(out, context); + } + else + { + for (String form : brokenForms) + { + renderBrokenForm(context, out, form, linkState); + } + } + + out.write("
"); + } + + // ------------------------------------------------------------------------------ + // Helpers + + private void renderBrokenForm(FacesContext context, ResponseWriter out, + String file, LinkValidationState linkState) throws IOException + { + // get the web form name and path + String[] formNamePath = this.getFileNameAndPath(file); + String formName = formNamePath[0]; + String formPath = formNamePath[1]; + + // render the row with the appropriate background style + out.write(""); + out.write("
"); + out.write(formName); + out.write("
"); + out.write(formPath); + out.write("
"); + out.write(Application.getMessage(context, "generated_files")); + out.write(":
"); + + for (String brokenFile : linkState.getBrokenFilesByForm(file)) + { + String[] nameAndPath = this.getFileNameAndPath(brokenFile); + String fileName = nameAndPath[0]; + String filePath = nameAndPath[1]; + + // build the list of broken links for the file + String brokenLinks = getBrokenLinks(brokenFile, linkState); + renderFile(out, context, fileName, filePath, brokenLinks); + } + + out.write("
"); + + out.write("
"); + out.write(" "); +// out.write(" "); + out.write("
"); + } +} + + + + diff --git a/source/java/org/alfresco/web/ui/wcm/component/UILinkValidationFixedFiles.java b/source/java/org/alfresco/web/ui/wcm/component/UILinkValidationFixedFiles.java index 8e15f13209..5fa2f5e8a0 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/UILinkValidationFixedFiles.java +++ b/source/java/org/alfresco/web/ui/wcm/component/UILinkValidationFixedFiles.java @@ -30,7 +30,6 @@ import java.util.List; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; -import org.alfresco.config.JNDIConstants; import org.alfresco.web.app.Application; import org.alfresco.web.bean.wcm.LinkValidationState; import org.apache.commons.logging.Log; @@ -74,13 +73,36 @@ public class UILinkValidationFixedFiles extends AbstractLinkValidationReportComp // render the list of broken files and their contained links out.write("
"); - out.write(Application.getMessage(context, "fixed_files")); + out.write(Application.getMessage(context, "fixed_items")); out.write("
"); - List fixedFiles = linkState.getFixedStaticFiles(); - for (String file : fixedFiles) + int fixedItems = 0; + List fixedFiles = linkState.getFixedFiles(); + List fixedForms = linkState.getFixedForms(); + if (fixedFiles != null) { - renderFixedFile(context, out, file, linkState); + fixedItems = fixedFiles.size(); + } + if (fixedForms != null) + { + fixedItems += fixedForms.size(); + } + + if (fixedItems == 0) + { + renderNoItems(out, context); + } + else + { + for (String file : fixedFiles) + { + renderFixedItem(context, out, file, linkState); + } + + for (String file : fixedForms) + { + renderFixedItem(context, out, file, linkState); + } } out.write("
"); @@ -89,28 +111,13 @@ public class UILinkValidationFixedFiles extends AbstractLinkValidationReportComp // ------------------------------------------------------------------------------ // Helpers - private void renderFixedFile(FacesContext context, ResponseWriter out, + private void renderFixedItem(FacesContext context, ResponseWriter out, String file, LinkValidationState linkState) throws IOException { // gather the data to show for the file - String fileName = file; - String filePath = file; - - int idx = file.lastIndexOf("/"); - if (idx != -1) - { - fileName = file.substring(idx+1); - - int appbaseIdx = file.indexOf(JNDIConstants.DIR_DEFAULT_APPBASE); - if (appbaseIdx != -1) - { - filePath = file.substring(appbaseIdx+JNDIConstants.DIR_DEFAULT_APPBASE.length(), idx); - } - else - { - filePath = file.substring(0, idx); - } - } + String[] nameAndPath = this.getFileNameAndPath(file); + String fileName = nameAndPath[0]; + String filePath = nameAndPath[1]; // render the row with the appropriate background style out.write(""); - out.write("
"); - out.write(fileName); - out.write("
"); - out.write(filePath); - out.write("
"); + out.write("'>"); + renderFile(out, context, fileName, filePath, null); + out.write(""); } } diff --git a/source/java/org/alfresco/web/ui/wcm/component/UILinkValidationSummary.java b/source/java/org/alfresco/web/ui/wcm/component/UILinkValidationSummary.java index afcae3b3d1..dcebfa070a 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/UILinkValidationSummary.java +++ b/source/java/org/alfresco/web/ui/wcm/component/UILinkValidationSummary.java @@ -26,6 +26,7 @@ package org.alfresco.web.ui.wcm.component; import java.io.IOException; import java.text.MessageFormat; +import java.util.Date; import java.util.ResourceBundle; import javax.faces.context.FacesContext; @@ -33,6 +34,7 @@ import javax.faces.context.ResponseWriter; import org.alfresco.web.app.Application; import org.alfresco.web.bean.wcm.LinkValidationState; +import org.alfresco.web.ui.common.Utils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -74,8 +76,11 @@ public class UILinkValidationSummary extends AbstractLinkValidationReportCompone // resolve all the strings holding data ResourceBundle bundle = Application.getBundle(context); String pattern = bundle.getString("files_links_checked"); + Date initialCheck = linkState.getInitialCheckCompletedAt(); + String initialCheckTime = Utils.getDateTimeFormat(context).format(initialCheck); String initialCheckSummary = MessageFormat.format(pattern, - new Object[] {linkState.getInitialNumberFilesChecked(), linkState.getInitialNumberLinksChecked()}); + new Object[] {initialCheckTime, linkState.getInitialNumberFilesChecked(), + linkState.getInitialNumberLinksChecked()}); pattern = bundle.getString("files_links_broken"); String initialBrokenSummary = MessageFormat.format(pattern, new Object[] {linkState.getInitialNumberBrokenFiles(), linkState.getInitialNumberBrokenLinks()}); diff --git a/source/java/org/alfresco/web/ui/wcm/tag/LinkValidationBrokenFormsTag.java b/source/java/org/alfresco/web/ui/wcm/tag/LinkValidationBrokenFormsTag.java new file mode 100644 index 0000000000..85a6d59038 --- /dev/null +++ b/source/java/org/alfresco/web/ui/wcm/tag/LinkValidationBrokenFormsTag.java @@ -0,0 +1,82 @@ +/* + * 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.ui.wcm.tag; + +import javax.faces.component.UIComponent; + +import org.alfresco.web.ui.common.tag.HtmlComponentTag; + +/** + * Tag class for adding the UILinkValidationBrokenForms component to a JSP page. + * + * @author gavinc + */ +public class LinkValidationBrokenFormsTag extends HtmlComponentTag +{ + private String value; + + /** + * @see javax.faces.webapp.UIComponentTag#getComponentType() + */ + public String getComponentType() + { + return "org.alfresco.faces.LinkValidationBrokenForms"; + } + + /** + * @see javax.faces.webapp.UIComponentTag#getRendererType() + */ + public String getRendererType() + { + return null; + } + + /** + * @see javax.faces.webapp.UIComponentTag#setProperties(javax.faces.component.UIComponent) + */ + protected void setProperties(UIComponent component) + { + super.setProperties(component); + + setStringProperty(component, "value", this.value); + } + + /** + * @see org.alfresco.web.ui.common.tag.HtmlComponentTag#release() + */ + public void release() + { + super.release(); + this.value = null; + } + + /** + * @param value the value (the list of servers to deploy to) + */ + public void setValue(String value) + { + this.value = value; + } +} diff --git a/source/web/WEB-INF/faces-config-wcm.xml b/source/web/WEB-INF/faces-config-wcm.xml index dc680cc2bd..bba753278a 100644 --- a/source/web/WEB-INF/faces-config-wcm.xml +++ b/source/web/WEB-INF/faces-config-wcm.xml @@ -54,6 +54,11 @@ org.alfresco.web.ui.wcm.component.UILinkValidationBrokenFiles + + org.alfresco.faces.LinkValidationBrokenForms + org.alfresco.web.ui.wcm.component.UILinkValidationBrokenForms + + org.alfresco.faces.LinkValidationFixedFiles org.alfresco.web.ui.wcm.component.UILinkValidationFixedFiles diff --git a/source/web/WEB-INF/wcm.tld b/source/web/WEB-INF/wcm.tld index 3f31e3df83..2cc1f7e6aa 100644 --- a/source/web/WEB-INF/wcm.tld +++ b/source/web/WEB-INF/wcm.tld @@ -346,6 +346,35 @@ + + linkValidationBrokenForms + org.alfresco.web.ui.wcm.tag.LinkValidationBrokenFormsTag + JSP + Link Validation Broken Forms + Displays broken form information for a link validation report + + + value + true + true + The link validation state object holding the report data + + + + id + false + true + The component identifier for this component + + + + rendered + false + true + Flag to determine whether component should be rendered + + + linkValidationFixedFiles org.alfresco.web.ui.wcm.tag.LinkValidationFixedFilesTag diff --git a/source/web/css/main.css b/source/web/css/main.css index cc1db08499..0c717e83a8 100644 --- a/source/web/css/main.css +++ b/source/web/css/main.css @@ -755,6 +755,7 @@ a.sidebarButtonLink, a.sidebarButtonLink:link, a.sidebarButtonLink:visited .linkValidationSummaryPanel { margin: 6px; + margin-top: 3px; padding: 8px; background-color: white; /* border: 1px solid #babfc5; */ @@ -763,7 +764,14 @@ a.sidebarButtonLink, a.sidebarButtonLink:link, a.sidebarButtonLink:visited .linkValidationBrokenFilesPanel { margin: 6px; - margin-top: 10px; + padding: 8px; + background-color: white; + /* border: 1px solid #babfc5; */ +} + +.linkValidationBrokenFormsPanel +{ + margin: 6px; padding: 8px; background-color: white; /* border: 1px solid #babfc5; */ @@ -772,7 +780,6 @@ a.sidebarButtonLink, a.sidebarButtonLink:link, a.sidebarButtonLink:visited .linkValidationFixedFilesPanel { margin: 6px; - margin-top: 10px; padding: 8px; background-color: white; /* border: 1px solid #babfc5; */ @@ -781,7 +788,7 @@ a.sidebarButtonLink, a.sidebarButtonLink:link, a.sidebarButtonLink:visited .linkValidationList { overflow: auto; - height: 150px; + height: 130px; border: 1px solid #aaa; } diff --git a/source/web/jsp/wcm/link-validation-report.jsp b/source/web/jsp/wcm/link-validation-report.jsp index 8a7a5a221c..02eb9264a7 100644 --- a/source/web/jsp/wcm/link-validation-report.jsp +++ b/source/web/jsp/wcm/link-validation-report.jsp @@ -34,6 +34,7 @@ +