Skip to content

Instantly share code, notes, and snippets.

@farmerbradllc
Created November 8, 2012 17:32
Show Gist options
  • Save farmerbradllc/4040259 to your computer and use it in GitHub Desktop.
Save farmerbradllc/4040259 to your computer and use it in GitHub Desktop.
Broken Link Checker
<%
/**
* Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library 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 Lesser General Public License for more
* details.
*/
%>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
<%@ page import="com.liferay.portlet.journal.model.JournalArticle" %>
<%@ page import="com.liferay.portlet.journalcontent.util.JournalContentUtil" %>
<%@ page import="com.liferay.portlet.journal.service.JournalArticleLocalServiceUtil" %>
<%@ page import="java.io.StringReader" %>
<%@ page import="java.util.List" %>
<%@ page import="java.io.Reader" %>
<%@ page import="com.liferay.util.HTMLParser" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.lang.String" %>
<%@ page import="com.liferay.portal.kernel.util.LocaleUtil" %>
<portlet:defineObjects />
<liferay-theme:defineObjects />
<%
long customScopeId = themeDisplay.getScopeGroupId();
List<JournalArticle> journalArticleList = JournalArticleLocalServiceUtil.getArticles(customScopeId);
String langageId = themeDisplay.getLanguageId();
%>
<p>
Change the Scope to view all of the web content of that group
</p>
<ul>
<%
for (JournalArticle journalArticle : journalArticleList) {
%>
<%
if(JournalArticleLocalServiceUtil.isLatestVersion(journalArticle.getGroupId(), journalArticle.getArticleId(), journalArticle.getVersion())){
%>
<li>
<%=langageId%>
<%=journalArticle.getArticleId()%>
<%=journalArticle.getVersion()%>
<%=journalArticle.getGroupId()%>
<%
String webContent = JournalContentUtil.getContent(customScopeId, journalArticle.getArticleId(), null, null, langageId, themeDisplay);
Reader currentContent = new StringReader(webContent);
%>
<%=webContent%>
<%
for (List<String> webContentLinks : new HTMLParser(currentContent).getLinks()) {
%>
<%=webContentLinks%>
<%
}
%>
</li>
<%
}
%>
<%
}
%>
</ul>
This is the <b>Broken Link Portlet</b> portlet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment