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
This commit is contained in:
Gavin Cornwell
2007-06-12 20:35:11 +00:00
parent 21b9367f7f
commit 9abfab20ab
12 changed files with 657 additions and 172 deletions

View File

@@ -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. 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 initial_check=Initial check
current_status=Current status 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_broken={0} broken link(s) were found in {1} file(s).
files_links_still_broken={0} link(s) still broken 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. 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 broken_links=Broken Links
rerun_report=Re-Run Report 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 Wizard messages
new_user_title=New User Wizard new_user_title=New User Wizard

View File

@@ -25,12 +25,20 @@
package org.alfresco.web.bean.wcm; package org.alfresco.web.bean.wcm;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.linkvalidation.LinkValidationReport; 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.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@@ -50,6 +58,7 @@ import org.apache.commons.logging.LogFactory;
public class LinkValidationState public class LinkValidationState
{ {
private String store; private String store;
private Date initialCheckedCompletedAt;
private boolean checkBeenReRun = false; private boolean checkBeenReRun = false;
private int noFilesCheckedStart = 0; private int noFilesCheckedStart = 0;
@@ -73,14 +82,11 @@ public class LinkValidationState
private List<String> brokenStaticFilesLast; private List<String> brokenStaticFilesLast;
private List<String> brokenFormsLast; private List<String> brokenFormsLast;
private List<String> fixedStaticFiles; private List<String> fixedFiles;
private List<String> fixedForms; private List<String> fixedForms;
private List<String> fixedStaticFilesLast;
private List<String> fixedFormsLast;
private Map<String, List<String>> brokenLinksByFile; private Map<String, List<String>> brokenLinksByFile;
private Map<String, List<String>> brokenLinksByForm; private Map<String, List<String>> brokenFilesByForm;
private static Log logger = LogFactory.getLog(LinkValidationState.class); private static Log logger = LogFactory.getLog(LinkValidationState.class);
@@ -90,6 +96,7 @@ public class LinkValidationState
public LinkValidationState(String store, LinkValidationReport initialReport) public LinkValidationState(String store, LinkValidationReport initialReport)
{ {
this.store = store; this.store = store;
this.initialCheckedCompletedAt = new Date();
processReport(initialReport, false); processReport(initialReport, false);
} }
@@ -97,6 +104,22 @@ public class LinkValidationState
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Getters // 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 * @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 * @param form The name of a form to find broken files for
* @return The list of broken files generated by the given form * @return The list of broken files generated by the given form
*/ */
public List<String> getFilesBrokenByForm(String form) public List<String> 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 * initial link check
*/ */
public List<String> getFixedStaticFiles() public List<String> 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<String> getFixedForms() public List<String> getFixedForms()
{ {
return this.fixedForms; return this.fixedForms;
} }
/**
* @return The list of non-generated files fixed in the last run of the link check
*/
public List<String> getStaticFilesFixedInLastRun()
{
return this.fixedStaticFilesLast;
}
/**
* @return The list of forms fixed in the last run of the link check
*/
public List<String> getFormsFixedInLastRun()
{
return this.fixedFormsLast;
}
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Implementation // Implementation
@@ -279,6 +287,7 @@ public class LinkValidationState
processReport(newReport, true); processReport(newReport, true);
} }
@Override
public String toString() public String toString()
{ {
StringBuilder buffer = new StringBuilder(super.toString()); StringBuilder buffer = new StringBuilder(super.toString());
@@ -289,11 +298,11 @@ public class LinkValidationState
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Private Helpers // 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 // setup initial counts
this.noBrokenFilesStart = report.getNumberBrokenFiles(); this.noBrokenFilesStart = report.getNumberBrokenFiles();
@@ -305,27 +314,13 @@ public class LinkValidationState
this.noFilesCheckedLast = report.getNumberFilesChecked(); this.noFilesCheckedLast = report.getNumberFilesChecked();
this.noLinksCheckedLast = report.getNumberLinksChecked(); this.noLinksCheckedLast = report.getNumberLinksChecked();
// setup initial lists // setup fixed lists
this.brokenStaticFilesStart = report.getFilesWithBrokenLinks(); this.fixedFiles = new ArrayList<String>(this.noBrokenFilesStart);
this.brokenFormsStart = Collections.emptyList(); this.fixedForms = new ArrayList<String>(this.noBrokenFilesStart);
this.brokenStaticFilesLast = report.getFilesWithBrokenLinks();
this.brokenFormsLast = Collections.emptyList(); // process the broken files and determine which ones are static files
// and which ones are generated
this.fixedStaticFiles = Collections.emptyList(); processFiles(report.getFilesWithBrokenLinks(), rerunReport, report);
this.fixedForms = Collections.emptyList();
this.fixedFormsLast = Collections.emptyList();
this.fixedStaticFiles = Collections.emptyList();
this.fixedStaticFilesLast = Collections.emptyList();
// setup initial maps
this.brokenLinksByFile = new HashMap<String, List<String>>();
this.brokenLinksByForm = Collections.emptyMap();
// populate initial maps
for (String file : this.brokenStaticFilesLast)
{
this.brokenLinksByFile.put(file, report.getBrokenLinksForFile(file));
}
} }
else else
{ {
@@ -347,27 +342,111 @@ public class LinkValidationState
this.noFixedLinks = 0; 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 // were fixed in the last re-run of the report
this.brokenStaticFilesLast = report.getFilesWithBrokenLinks();
this.fixedStaticFiles = new ArrayList<String>();
this.fixedStaticFilesLast = new ArrayList<String>();
for (String file : this.brokenStaticFilesStart) 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.fixedFiles.add(file);
this.fixedStaticFiles.add(file);
} }
} }
for (String file : this.brokenFormsStart)
// update the broken files info
this.brokenLinksByFile.clear();
for (String file : this.brokenStaticFilesLast)
{ {
if (this.brokenFormsLast.contains(file) == false &&
this.fixedForms.contains(file) == false)
{
this.fixedForms.add(file);
}
}
}
}
protected void processFiles(List<String> 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<String>(this.noBrokenFilesLast);
this.brokenFormsLast = new ArrayList<String>(this.noBrokenFilesLast);
this.brokenFilesByForm = new HashMap<String, List<String>>(this.noBrokenFilesLast);
this.brokenLinksByFile = new HashMap<String, List<String>>(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<String> genFiles = this.brokenFilesByForm.get(xmlPath);
if (genFiles == null)
{
genFiles = new ArrayList<String>(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)); 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<String>(this.brokenStaticFilesLast.size());
this.brokenStaticFilesStart.addAll(this.brokenStaticFilesLast);
this.brokenFormsStart = new ArrayList<String>(this.brokenFormsLast.size());
this.brokenFormsStart.addAll(this.brokenFormsLast);
}
} }
} }

View File

@@ -24,9 +24,15 @@
*/ */
package org.alfresco.web.ui.wcm.component; package org.alfresco.web.ui.wcm.component;
import java.io.IOException;
import java.util.List;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.el.ValueBinding; 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.bean.wcm.LinkValidationState;
import org.alfresco.web.ui.common.component.SelfRenderingComponent; import org.alfresco.web.ui.common.component.SelfRenderingComponent;
@@ -62,6 +68,167 @@ public abstract class AbstractLinkValidationReportComponent extends SelfRenderin
return values; 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<String> 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("<table cellpadding='0' cellspacing='0'><tr><td valign='top'><img src='");
out.write(context.getExternalContext().getRequestContextPath());
out.write(getIcon(fileName));
out.write("' style='padding: 5px;' /></td>");
out.write("<td width='100%'><div style='padding: 5px;'><div style='font-weight: bold;'>");
out.write(fileName);
out.write("</div><div style='padding-top: 2px;'>");
out.write(filePath);
out.write("</div>");
if (brokenLinks != null && brokenLinks.length() > 0)
{
out.write("<div style='padding-top: 4px; color: #888;'>");
out.write(Application.getMessage(context, "broken_links"));
out.write(":</div><div style='padding-top: 2px;'>");
out.write(brokenLinks);
out.write("</div>");
}
out.write("</div></td></tr></table>");
}
/**
* 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("<tr><td><div style='padding: 6px;'>");
out.write(Application.getMessage(context, "no_items"));
out.write("</div></td></tr>");
}
/**
* 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 // Strongly typed component property accessors

View File

@@ -30,7 +30,6 @@ import java.util.List;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter; import javax.faces.context.ResponseWriter;
import org.alfresco.config.JNDIConstants;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
import org.alfresco.web.bean.wcm.LinkValidationState; import org.alfresco.web.bean.wcm.LinkValidationState;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@@ -77,11 +76,18 @@ public class UILinkValidationBrokenFiles extends AbstractLinkValidationReportCom
out.write("<div class='linkValidationBrokenFilesPanel'><div class='linkValidationReportTitle'>"); out.write("<div class='linkValidationBrokenFilesPanel'><div class='linkValidationReportTitle'>");
out.write(Application.getMessage(context, "files_with_broken_links")); out.write(Application.getMessage(context, "files_with_broken_links"));
out.write("</div><div class='linkValidationList'><table width='100%' cellpadding='0' cellspacing='0'>"); out.write("</div><div class='linkValidationList'><table width='100%' cellpadding='0' cellspacing='0'>");
List<String> brokenFiles = linkState.getStaticFilesWithBrokenLinks(); List<String> 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("</table></div></div>"); out.write("</table></div></div>");
@@ -94,43 +100,12 @@ public class UILinkValidationBrokenFiles extends AbstractLinkValidationReportCom
String file, LinkValidationState linkState) throws IOException String file, LinkValidationState linkState) throws IOException
{ {
// gather the data to show for the file // gather the data to show for the file
String fileName = file; String[] nameAndPath = this.getFileNameAndPath(file);
String filePath = file; String fileName = nameAndPath[0];
String filePath = nameAndPath[1];
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);
}
}
// build the list of broken links for the file // build the list of broken links for the file
List<String> brokenLinks = linkState.getBrokenLinksForFile(file); String brokenLinks = getBrokenLinks(file, linkState);
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();
// render the row with the appropriate background style // render the row with the appropriate background style
out.write("<tr class='"); out.write("<tr class='");
@@ -148,19 +123,9 @@ public class UILinkValidationBrokenFiles extends AbstractLinkValidationReportCom
this.oddRow = !this.oddRow; this.oddRow = !this.oddRow;
// render the data // render the data
out.write("'><td valign='top'><img src='"); out.write("'><td>");
out.write(context.getExternalContext().getRequestContextPath()); renderFile(out, context, fileName, filePath, brokenLinks);
out.write("/images/filetypes32/html.gif' style='padding: 5px;' /></td>"); out.write("</td><td align='right' valign='top'><div style='white-space: nowrap; padding-top: 10px; padding-right: 20px;'>");
out.write("<td width='100%'><div style='padding: 5px;'><div style='font-weight: bold;'>");
out.write(fileName);
out.write("</div><div style='padding-top: 2px;'>");
out.write(filePath);
out.write("</div><div style='padding-top: 4px; color: #aaa;'>");
out.write(Application.getMessage(context, "broken_links"));
out.write(":</div><div style='padding-top: 2px;'>");
out.write(brokenLinksList);
out.write("</div></div></td><td align='right' valign='top'>");
out.write("<div style='white-space: nowrap; padding: 5px; padding-right: 10px;'>");
out.write("&nbsp;"); out.write("&nbsp;");
// out.write("<img src='/alfresco/images/icons/edit_icon.gif' />&nbsp;"); // out.write("<img src='/alfresco/images/icons/edit_icon.gif' />&nbsp;");
// out.write("<img src='/alfresco/images/icons/update.gif' />&nbsp;"); // out.write("<img src='/alfresco/images/icons/update.gif' />&nbsp;");
@@ -168,23 +133,6 @@ public class UILinkValidationBrokenFiles extends AbstractLinkValidationReportCom
// out.write("<img src='/alfresco/images/icons/preview_website.gif' />&nbsp;"); // out.write("<img src='/alfresco/images/icons/preview_website.gif' />&nbsp;");
out.write("</div></td></tr>"); out.write("</div></td></tr>");
} }
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;
}
} }

View File

@@ -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("<div class='linkValidationBrokenFormsPanel'><div class='linkValidationReportTitle'>");
out.write(Application.getMessage(context, "forms_with_broken_links"));
out.write("</div><div class='linkValidationList'><table width='100%' cellpadding='0' cellspacing='0'>");
List<String> brokenForms = linkState.getFormsWithBrokenLinks();
if (brokenForms == null || brokenForms.size() == 0)
{
renderNoItems(out, context);
}
else
{
for (String form : brokenForms)
{
renderBrokenForm(context, out, form, linkState);
}
}
out.write("</table></div></div>");
}
// ------------------------------------------------------------------------------
// 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("<tr class='");
if (this.oddRow)
{
out.write("linkValidationListOddRow");
}
else
{
out.write("linkValidationListEvenRow");
}
// toggle the type of row
this.oddRow = !this.oddRow;
// render the data
out.write("'><td valign='top'><img src='");
out.write(context.getExternalContext().getRequestContextPath());
out.write("/images/icons/webform_large.gif' style='padding: 5px;' /></td><td width='100%'>");
out.write("<div style='font-weight: bold; padding-top: 5px;'>");
out.write(formName);
out.write("</div><div style='padding-top: 2px;'>");
out.write(formPath);
out.write("</div><div style='padding-top: 4px; color: #888;'>");
out.write(Application.getMessage(context, "generated_files"));
out.write(":</div><div style='padding-top: 2px;'>");
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("</div>");
out.write("</td><td align='right' valign='top'><div style='white-space: nowrap; padding-top: 10px; padding-right: 20px;'>");
out.write("&nbsp;");
// out.write("<img src='/alfresco/images/icons/edit_icon.gif' />&nbsp;");
out.write("</div></td></tr>");
}
}

View File

@@ -30,7 +30,6 @@ import java.util.List;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter; import javax.faces.context.ResponseWriter;
import org.alfresco.config.JNDIConstants;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
import org.alfresco.web.bean.wcm.LinkValidationState; import org.alfresco.web.bean.wcm.LinkValidationState;
import org.apache.commons.logging.Log; 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 // render the list of broken files and their contained links
out.write("<div class='linkValidationFixedFilesPanel'><div class='linkValidationReportTitle'>"); out.write("<div class='linkValidationFixedFilesPanel'><div class='linkValidationReportTitle'>");
out.write(Application.getMessage(context, "fixed_files")); out.write(Application.getMessage(context, "fixed_items"));
out.write("</div><div class='linkValidationList'><table width='100%' cellpadding='0' cellspacing='0'>"); out.write("</div><div class='linkValidationList'><table width='100%' cellpadding='0' cellspacing='0'>");
List<String> fixedFiles = linkState.getFixedStaticFiles(); int fixedItems = 0;
for (String file : fixedFiles) List<String> fixedFiles = linkState.getFixedFiles();
List<String> 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("</table></div></div>"); out.write("</table></div></div>");
@@ -89,28 +111,13 @@ public class UILinkValidationFixedFiles extends AbstractLinkValidationReportComp
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Helpers // Helpers
private void renderFixedFile(FacesContext context, ResponseWriter out, private void renderFixedItem(FacesContext context, ResponseWriter out,
String file, LinkValidationState linkState) throws IOException String file, LinkValidationState linkState) throws IOException
{ {
// gather the data to show for the file // gather the data to show for the file
String fileName = file; String[] nameAndPath = this.getFileNameAndPath(file);
String filePath = file; String fileName = nameAndPath[0];
String filePath = nameAndPath[1];
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);
}
}
// render the row with the appropriate background style // render the row with the appropriate background style
out.write("<tr class='"); out.write("<tr class='");
@@ -128,14 +135,9 @@ public class UILinkValidationFixedFiles extends AbstractLinkValidationReportComp
this.oddRow = !this.oddRow; this.oddRow = !this.oddRow;
// render the data // render the data
out.write("'><td valign='top'><img src='"); out.write("'><td>");
out.write(context.getExternalContext().getRequestContextPath()); renderFile(out, context, fileName, filePath, null);
out.write("/images/filetypes32/html.gif' style='padding: 5px;' /></td>"); out.write("</td></tr>");
out.write("<td width='100%'><div style='padding: 5px;'><div style='font-weight: bold;'>");
out.write(fileName);
out.write("</div><div style='padding-top: 2px;'>");
out.write(filePath);
out.write("</div></div></td></tr>");
} }
} }

View File

@@ -26,6 +26,7 @@ package org.alfresco.web.ui.wcm.component;
import java.io.IOException; import java.io.IOException;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.Date;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
@@ -33,6 +34,7 @@ import javax.faces.context.ResponseWriter;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
import org.alfresco.web.bean.wcm.LinkValidationState; 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.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@@ -74,8 +76,11 @@ public class UILinkValidationSummary extends AbstractLinkValidationReportCompone
// resolve all the strings holding data // resolve all the strings holding data
ResourceBundle bundle = Application.getBundle(context); ResourceBundle bundle = Application.getBundle(context);
String pattern = bundle.getString("files_links_checked"); String pattern = bundle.getString("files_links_checked");
Date initialCheck = linkState.getInitialCheckCompletedAt();
String initialCheckTime = Utils.getDateTimeFormat(context).format(initialCheck);
String initialCheckSummary = MessageFormat.format(pattern, String initialCheckSummary = MessageFormat.format(pattern,
new Object[] {linkState.getInitialNumberFilesChecked(), linkState.getInitialNumberLinksChecked()}); new Object[] {initialCheckTime, linkState.getInitialNumberFilesChecked(),
linkState.getInitialNumberLinksChecked()});
pattern = bundle.getString("files_links_broken"); pattern = bundle.getString("files_links_broken");
String initialBrokenSummary = MessageFormat.format(pattern, String initialBrokenSummary = MessageFormat.format(pattern,
new Object[] {linkState.getInitialNumberBrokenFiles(), linkState.getInitialNumberBrokenLinks()}); new Object[] {linkState.getInitialNumberBrokenFiles(), linkState.getInitialNumberBrokenLinks()});

View File

@@ -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;
}
}

View File

@@ -54,6 +54,11 @@
<component-class>org.alfresco.web.ui.wcm.component.UILinkValidationBrokenFiles</component-class> <component-class>org.alfresco.web.ui.wcm.component.UILinkValidationBrokenFiles</component-class>
</component> </component>
<component>
<component-type>org.alfresco.faces.LinkValidationBrokenForms</component-type>
<component-class>org.alfresco.web.ui.wcm.component.UILinkValidationBrokenForms</component-class>
</component>
<component> <component>
<component-type>org.alfresco.faces.LinkValidationFixedFiles</component-type> <component-type>org.alfresco.faces.LinkValidationFixedFiles</component-type>
<component-class>org.alfresco.web.ui.wcm.component.UILinkValidationFixedFiles</component-class> <component-class>org.alfresco.web.ui.wcm.component.UILinkValidationFixedFiles</component-class>

View File

@@ -346,6 +346,35 @@
</attribute> </attribute>
</tag> </tag>
<tag>
<name>linkValidationBrokenForms</name>
<tag-class>org.alfresco.web.ui.wcm.tag.LinkValidationBrokenFormsTag</tag-class>
<body-content>JSP</body-content>
<display-name>Link Validation Broken Forms</display-name>
<description>Displays broken form information for a link validation report</description>
<attribute>
<name>value</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<description>The link validation state object holding the report data</description>
</attribute>
<attribute>
<name>id</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>The component identifier for this component</description>
</attribute>
<attribute>
<name>rendered</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>Flag to determine whether component should be rendered</description>
</attribute>
</tag>
<tag> <tag>
<name>linkValidationFixedFiles</name> <name>linkValidationFixedFiles</name>
<tag-class>org.alfresco.web.ui.wcm.tag.LinkValidationFixedFilesTag</tag-class> <tag-class>org.alfresco.web.ui.wcm.tag.LinkValidationFixedFilesTag</tag-class>

View File

@@ -755,6 +755,7 @@ a.sidebarButtonLink, a.sidebarButtonLink:link, a.sidebarButtonLink:visited
.linkValidationSummaryPanel .linkValidationSummaryPanel
{ {
margin: 6px; margin: 6px;
margin-top: 3px;
padding: 8px; padding: 8px;
background-color: white; background-color: white;
/* border: 1px solid #babfc5; */ /* border: 1px solid #babfc5; */
@@ -763,7 +764,14 @@ a.sidebarButtonLink, a.sidebarButtonLink:link, a.sidebarButtonLink:visited
.linkValidationBrokenFilesPanel .linkValidationBrokenFilesPanel
{ {
margin: 6px; margin: 6px;
margin-top: 10px; padding: 8px;
background-color: white;
/* border: 1px solid #babfc5; */
}
.linkValidationBrokenFormsPanel
{
margin: 6px;
padding: 8px; padding: 8px;
background-color: white; background-color: white;
/* border: 1px solid #babfc5; */ /* border: 1px solid #babfc5; */
@@ -772,7 +780,6 @@ a.sidebarButtonLink, a.sidebarButtonLink:link, a.sidebarButtonLink:visited
.linkValidationFixedFilesPanel .linkValidationFixedFilesPanel
{ {
margin: 6px; margin: 6px;
margin-top: 10px;
padding: 8px; padding: 8px;
background-color: white; background-color: white;
/* border: 1px solid #babfc5; */ /* border: 1px solid #babfc5; */
@@ -781,7 +788,7 @@ a.sidebarButtonLink, a.sidebarButtonLink:link, a.sidebarButtonLink:visited
.linkValidationList .linkValidationList
{ {
overflow: auto; overflow: auto;
height: 150px; height: 130px;
border: 1px solid #aaa; border: 1px solid #aaa;
} }

View File

@@ -34,6 +34,7 @@
<w:linkValidationSummary value="#{AVMBrowseBean.linkValidationState}" /> <w:linkValidationSummary value="#{AVMBrowseBean.linkValidationState}" />
<w:linkValidationBrokenFiles value="#{AVMBrowseBean.linkValidationState}" /> <w:linkValidationBrokenFiles value="#{AVMBrowseBean.linkValidationState}" />
<w:linkValidationBrokenForms value="#{AVMBrowseBean.linkValidationState}" />
<w:linkValidationFixedFiles value="#{AVMBrowseBean.linkValidationState}" /> <w:linkValidationFixedFiles value="#{AVMBrowseBean.linkValidationState}" />