- Partial first cut of initial version of links management UI

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5917 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2007-06-11 20:54:23 +00:00
parent 1be49d2679
commit 3ad9668624
31 changed files with 2248 additions and 2 deletions

View File

@@ -0,0 +1,89 @@
/*
* 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 javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import org.alfresco.web.bean.wcm.LinkValidationState;
import org.alfresco.web.ui.common.component.SelfRenderingComponent;
/**
* Base class for all the link validation report JSF components.
*
* @author gavinc
*/
public abstract class AbstractLinkValidationReportComponent extends SelfRenderingComponent
{
protected LinkValidationState state;
// ------------------------------------------------------------------------------
// Component implementation
@SuppressWarnings("unchecked")
@Override
public void restoreState(FacesContext context, Object state)
{
Object values[] = (Object[])state;
// standard component attributes are restored by the super class
super.restoreState(context, values[0]);
this.state = (LinkValidationState)values[1];
}
@Override
public Object saveState(FacesContext context)
{
Object values[] = new Object[2];
// standard component attributes are saved by the super class
values[0] = super.saveState(context);
values[1] = this.state;
return values;
}
// ------------------------------------------------------------------------------
// Strongly typed component property accessors
/**
* @return The LinkValidationState object holding the report information
*/
public LinkValidationState getValue()
{
ValueBinding vb = getValueBinding("value");
if (vb != null)
{
this.state = (LinkValidationState)vb.getValue(getFacesContext());
}
return this.state;
}
/**
* @param value The LinkValidationState object to get the summary info from
*/
public void setValue(LinkValidationState value)
{
this.state = value;
}
}

View File

@@ -0,0 +1,192 @@
/*
* 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.config.JNDIConstants;
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 file information for a link
* validation report.
*
* @author gavinc
*/
public class UILinkValidationBrokenFiles extends AbstractLinkValidationReportComponent
{
private boolean oddRow = true;
private static Log logger = LogFactory.getLog(UILinkValidationBrokenFiles.class);
// ------------------------------------------------------------------------------
// Component implementation
@Override
public String getFamily()
{
return "org.alfresco.faces.LinkValidationBrokenFiles";
}
@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 files from state object: " + linkState);
// render the list of broken files and their contained links
out.write("<div class='linkValidationBrokenFilesPanel'><div class='linkValidationReportTitle'>");
out.write(Application.getMessage(context, "files_with_broken_links"));
out.write("</div><div class='linkValidationList'><table width='100%' cellpadding='0' cellspacing='0'>");
List<String> brokenFiles = linkState.getStaticFilesWithBrokenLinks();
for (String file : brokenFiles)
{
renderBrokenFile(context, out, file, linkState);
}
out.write("</table></div></div>");
}
// ------------------------------------------------------------------------------
// Helpers
private void renderBrokenFile(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);
}
}
// build the list of broken links for the file
List<String> 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();
// 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/filetypes32/html.gif' 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><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("<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/revert.gif' />&nbsp;");
// out.write("<img src='/alfresco/images/icons/preview_website.gif' />&nbsp;");
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,144 @@
/*
* 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.config.JNDIConstants;
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 fixed files for a link validation report.
*
* @author gavinc
*/
public class UILinkValidationFixedFiles extends AbstractLinkValidationReportComponent
{
private boolean oddRow = true;
private static Log logger = LogFactory.getLog(UILinkValidationFixedFiles.class);
// ------------------------------------------------------------------------------
// Component implementation
@Override
public String getFamily()
{
return "org.alfresco.faces.LinkValidationFixedFiles";
}
@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 fixed files from state object: " + linkState);
// render the list of broken files and their contained links
out.write("<div class='linkValidationFixedFilesPanel'><div class='linkValidationReportTitle'>");
out.write(Application.getMessage(context, "fixed_files"));
out.write("</div><div class='linkValidationList'><table width='100%' cellpadding='0' cellspacing='0'>");
List<String> fixedFiles = linkState.getFixedStaticFiles();
for (String file : fixedFiles)
{
renderFixedFile(context, out, file, linkState);
}
out.write("</table></div></div>");
}
// ------------------------------------------------------------------------------
// Helpers
private void renderFixedFile(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);
}
}
// 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/filetypes32/html.gif' 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></div></td></tr>");
}
}

View File

@@ -0,0 +1,148 @@
/*
* 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.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.el.MethodBinding;
import org.alfresco.web.app.Application;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.SelfRenderingComponent;
import org.alfresco.web.ui.common.component.UIActionLink;
import org.alfresco.web.ui.repo.component.UIActions;
/**
* JSF component that displays information about the workflows a node is involved in.
* <p>
* The node to show workflow information on.
*
* @author gavinc
*/
public class UILinkValidationProgress extends SelfRenderingComponent
{
// ------------------------------------------------------------------------------
// Component Impl
@Override
public String getFamily()
{
return "org.alfresco.faces.LinkValidationProgress";
}
@Override
public void restoreState(FacesContext context, Object state)
{
Object values[] = (Object[])state;
// standard component attributes are restored by the super class
super.restoreState(context, values[0]);
}
@Override
public Object saveState(FacesContext context)
{
Object values[] = new Object[1];
// standard component attributes are saved by the super class
values[0] = super.saveState(context);
return values;
}
@Override
@SuppressWarnings("unchecked")
public void encodeBegin(FacesContext context) throws IOException
{
if (!isRendered()) return;
ResponseWriter out = context.getResponseWriter();
// render the hidden action used to close the dialog
UIActionLink action = findOrCreateHiddenAction(context);
Utils.encodeRecursive(context, action);
// output the script
out.write("<script type='text/javascript' src='");
out.write(context.getExternalContext().getRequestContextPath());
out.write("/scripts/ajax/link-validation-progress.js'></script>\n");
// output the HTML
out.write("<div class='linkValidationProgressPanel'><table border='0' cellspacing='4' cellpadding='2'>");
out.write("<tr><td valign='top'><img src='");
out.write(context.getExternalContext().getRequestContextPath());
out.write("/images/icons/ajax_anim.gif' /></td><td>");
out.write("<div class='linkValidationProgressWait'>");
out.write(Application.getMessage(context, "checking_links_progress"));
out.write("</div><div class='linkValidationProgressStatus'>");
out.write(Application.getMessage(context, "checking_links_status"));
out.write("</div></td></tr></table></div>\n");
}
@Override
public void encodeEnd(FacesContext context) throws IOException
{
if (!isRendered()) return;
}
// ------------------------------------------------------------------------------
// Helper methods
@SuppressWarnings("unchecked")
private UIActionLink findOrCreateHiddenAction(FacesContext fc)
{
UIActionLink action = null;
String actionId = "validation-callback-link";
for (UIComponent component : (List<UIComponent>)getChildren())
{
if (actionId.equals(component.getId()))
{
action = (UIActionLink)component;
break;
}
}
if (action == null)
{
javax.faces.application.Application facesApp = fc.getApplication();
action = (UIActionLink)facesApp.createComponent(UIActions.COMPONENT_ACTIONLINK);
action.setRendererType(UIActions.RENDERER_ACTIONLINK);
action.setId(actionId);
action.setValue("Callback");
action.setShowLink(false);
MethodBinding callback = facesApp.createMethodBinding(
"#{DialogManager.bean.linkCheckCompleted}", new Class[] {});
action.setAction(callback);
action.getAttributes().put("style", "display:none;");
this.getChildren().add(action);
}
return action;
}
}

View File

@@ -0,0 +1,115 @@
/*
* 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.text.MessageFormat;
import java.util.ResourceBundle;
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 summary information for a link
* validation report.
*
* @author gavinc
*/
public class UILinkValidationSummary extends AbstractLinkValidationReportComponent
{
private static Log logger = LogFactory.getLog(UILinkValidationSummary.class);
// ------------------------------------------------------------------------------
// Component implementation
@Override
public String getFamily()
{
return "org.alfresco.faces.LinkValidationSummary";
}
@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 summary from state object: " + linkState);
// resolve all the strings holding data
ResourceBundle bundle = Application.getBundle(context);
String pattern = bundle.getString("files_links_checked");
String initialCheckSummary = MessageFormat.format(pattern,
new Object[] {linkState.getInitialNumberFilesChecked(), linkState.getInitialNumberLinksChecked()});
pattern = bundle.getString("files_links_broken");
String initialBrokenSummary = MessageFormat.format(pattern,
new Object[] {linkState.getInitialNumberBrokenFiles(), linkState.getInitialNumberBrokenLinks()});
pattern = bundle.getString("files_links_still_broken");
String stillBroken = MessageFormat.format(pattern,
new Object[] {linkState.getNumberBrokenFiles(), linkState.getNumberBrokenLinks()});
pattern = bundle.getString("broken_links_fixed");
String linksFixed = MessageFormat.format(pattern,
new Object[] {linkState.getNumberFixedLinks()});
// render the summary area
out.write("<div class='linkValidationSummaryPanel'><div class='linkValidationReportTitle'>");
out.write(bundle.getString("summary"));
out.write("</div><table cellpadding='0' cellspacing='0'><tr>");
out.write("<td valign='top' class='linkValidationReportSubTitle'>");
out.write(bundle.getString("initial_check"));
out.write(":</td><td><div style='margin-bottom: 6px;'>");
out.write(initialCheckSummary);
out.write("</div><div style='margin-bottom: 14px;'><img src='");
out.write(context.getExternalContext().getRequestContextPath());
out.write("/images/icons/warning.gif'' style='vertical-align: -4px; padding-right: 4px;'/>");
out.write(initialBrokenSummary);
out.write("</div></td></tr>");
out.write("<tr><td class='linkValidationReportSubTitle'>");
out.write(bundle.getString("current_status"));
out.write(":</td><td><div><img src='");
out.write(context.getExternalContext().getRequestContextPath());
out.write("/images/icons/warning.gif' style='vertical-align: -4px; padding-right: 4px;' >");
out.write(stillBroken);
out.write("<img src='");
out.write(context.getExternalContext().getRequestContextPath());
out.write("/images/icons/fixed_link.gif' style='vertical-align: -4px; padding-left: 6px; padding-right: 4px;' >");
out.write(linksFixed);
out.write("</div></td></tr>");
out.write("</table></div>");
}
}