You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2008/03/06 20:47:06 UTC
svn commit: r634392 - in /lenya/trunk/src/modules-core/administration:
config/cocoon-xconf/ java/src/org/apache/lenya/modules/
java/src/org/apache/lenya/modules/administration/ resources/i18n/ usecases/
Author: andreas
Date: Thu Mar 6 11:47:05 2008
New Revision: 634392
URL: http://svn.apache.org/viewvc?rev=634392&view=rev
Log:
Adding reports usecase.
Added:
lenya/trunk/src/modules-core/administration/config/cocoon-xconf/usecase-admin-reports.xconf
lenya/trunk/src/modules-core/administration/java/src/org/apache/lenya/modules/
lenya/trunk/src/modules-core/administration/java/src/org/apache/lenya/modules/administration/
lenya/trunk/src/modules-core/administration/java/src/org/apache/lenya/modules/administration/Reports.java
lenya/trunk/src/modules-core/administration/usecases/reports.jx
Modified:
lenya/trunk/src/modules-core/administration/config/cocoon-xconf/tabs.xconf
lenya/trunk/src/modules-core/administration/resources/i18n/cmsui.xml
lenya/trunk/src/modules-core/administration/resources/i18n/cmsui_de.xml
Modified: lenya/trunk/src/modules-core/administration/config/cocoon-xconf/tabs.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/administration/config/cocoon-xconf/tabs.xconf?rev=634392&r1=634391&r2=634392&view=diff
==============================================================================
--- lenya/trunk/src/modules-core/administration/config/cocoon-xconf/tabs.xconf (original)
+++ lenya/trunk/src/modules-core/administration/config/cocoon-xconf/tabs.xconf Thu Mar 6 11:47:05 2008
@@ -32,5 +32,6 @@
<tab name="sessions" label="Sessions" usecase="admin.sessions"/>
<tab name="pubConf" label="Publication" usecase="admin.showPubConf"/>
<tab name="siteOverview" label="Overview" usecase="admin.siteOverview"/>
+ <tab name="reports" label="Reports" usecase="admin.reports"/>
</tab-group>
</xconf>
Added: lenya/trunk/src/modules-core/administration/config/cocoon-xconf/usecase-admin-reports.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/administration/config/cocoon-xconf/usecase-admin-reports.xconf?rev=634392&view=auto
==============================================================================
--- lenya/trunk/src/modules-core/administration/config/cocoon-xconf/usecase-admin-reports.xconf (added)
+++ lenya/trunk/src/modules-core/administration/config/cocoon-xconf/usecase-admin-reports.xconf Thu Mar 6 11:47:05 2008
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Id: usecases-workflow-deactivate.xconf 348547 2005-11-23 20:13:01Z chestnut $ -->
+<!--
+ This file defines the publication specific use-cases
+-->
+
+<xconf xpath="/cocoon/usecases" unless="/cocoon/usecases/component-instance[@name = 'admin.reports']">
+
+ <component-instance name="admin.reports" logger="lenya.admin"
+ class="org.apache.lenya.modules.administration.Reports">
+ <view uri="modules/administration/usecases/reports.jx" menu="true" createContinuation="false">
+ <tab group="admin" name="reports"/>
+ </view>
+ </component-instance>
+
+</xconf>
Added: lenya/trunk/src/modules-core/administration/java/src/org/apache/lenya/modules/administration/Reports.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/administration/java/src/org/apache/lenya/modules/administration/Reports.java?rev=634392&view=auto
==============================================================================
--- lenya/trunk/src/modules-core/administration/java/src/org/apache/lenya/modules/administration/Reports.java (added)
+++ lenya/trunk/src/modules-core/administration/java/src/org/apache/lenya/modules/administration/Reports.java Thu Mar 6 11:47:05 2008
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.modules.administration;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.lenya.cms.linking.Link;
+import org.apache.lenya.cms.linking.LinkManager;
+import org.apache.lenya.cms.linking.LinkResolver;
+import org.apache.lenya.cms.linking.LinkTarget;
+import org.apache.lenya.cms.publication.Area;
+import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.publication.PublicationException;
+import org.apache.lenya.cms.publication.URLInformation;
+import org.apache.lenya.cms.usecase.AbstractUsecase;
+import org.apache.lenya.util.Assert;
+
+/**
+ * Various reports about a publication.
+ */
+public class Reports extends AbstractUsecase {
+
+ protected static final String PARAM_REPORT = "report";
+ protected static final Object REPORT_BROKEN_LINKS = "brokenLinks";
+ protected static final String PARAM_BROKEN_LINKS = "brokenLinks";
+
+ protected void prepareView() throws Exception {
+ super.prepareView();
+
+ final String report = getParameterAsString(PARAM_REPORT);
+ if (report == null) {
+ return;
+ }
+
+ if (report.equals(REPORT_BROKEN_LINKS)) {
+ reportBrokenLinks();
+ }
+
+ }
+
+ protected void reportBrokenLinks() throws Exception {
+ List brokenLinks = new ArrayList();
+ Publication pub = getPublication();
+ String[] areaNames = pub.getAreaNames();
+ LinkManager linkManager = null;
+ LinkResolver linkResolver = null;
+ try {
+ linkManager = (LinkManager) this.manager.lookup(LinkManager.ROLE);
+ linkResolver = (LinkResolver) this.manager.lookup(LinkResolver.ROLE);
+ for (int a = 0; a < areaNames.length; a++) {
+ Area area = pub.getArea(areaNames[a]);
+ Document[] docs = area.getDocuments();
+ for (int d = 0; d < docs.length; d++) {
+ Link[] links = linkManager.getLinksFrom(docs[d]);
+ for (int l = 0; l < links.length; l++) {
+ String uri = links[l].getUri();
+ LinkTarget target = linkResolver.resolve(docs[d], uri);
+ if (!target.exists()) {
+ BrokenLink brokenLink = new BrokenLink(docs[d].getCanonicalWebappURL(), uri);
+ brokenLinks.add(brokenLink);
+ }
+ }
+ }
+ }
+ }
+ finally {
+ if (linkManager != null) {
+ this.manager.release(linkManager);
+ }
+ if (linkResolver != null) {
+ this.manager.release(linkResolver);
+ }
+ }
+ setParameter(PARAM_BROKEN_LINKS, brokenLinks);
+ }
+
+ public static class BrokenLink {
+
+ private String sourceUrl;
+ private String targetUrl;
+
+ public BrokenLink(String sourceUrl, String targetUrl) {
+ Assert.notNull("source URL", sourceUrl);
+ Assert.notNull("target URL", targetUrl);
+ this.sourceUrl = sourceUrl;
+ this.targetUrl = targetUrl;
+ }
+
+ public String getSourceUrl() {
+ return this.sourceUrl;
+ }
+
+ public String getTargetUrl() {
+ return this.targetUrl;
+ }
+ }
+
+ /**
+ * @return The current publication.
+ * @throws PublicationException if the usecase isn't invoked inside a publication.
+ */
+ protected Publication getPublication() throws PublicationException {
+ URLInformation info = new URLInformation(getSourceURL());
+ return getDocumentFactory().getPublication(info.getPublicationId());
+ }
+
+}
Modified: lenya/trunk/src/modules-core/administration/resources/i18n/cmsui.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/administration/resources/i18n/cmsui.xml?rev=634392&r1=634391&r2=634392&view=diff
==============================================================================
--- lenya/trunk/src/modules-core/administration/resources/i18n/cmsui.xml (original)
+++ lenya/trunk/src/modules-core/administration/resources/i18n/cmsui.xml Thu Mar 6 11:47:05 2008
@@ -65,6 +65,14 @@
Caution: If you set invalid proxy URLs, you might not be able to access the publication anymore.
</message>
<message key="modules">Modules</message>
- <message key="resource-types">Resource types</message>
+ <message key="resource-types">Resource types</message>
+
+ <!-- reports -->
+ <message key="Reports">Reports</message>
+ <message key="broken-links">Broken Internal Links</message>
+ <message key="find-broken-links">Find broken internal links</message>
+ <message key="no-broken-links">No broken internal links found.</message>
+ <message key="Source">Source</message>
+ <message key="Target">Target</message>
</catalogue>
Modified: lenya/trunk/src/modules-core/administration/resources/i18n/cmsui_de.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/administration/resources/i18n/cmsui_de.xml?rev=634392&r1=634391&r2=634392&view=diff
==============================================================================
--- lenya/trunk/src/modules-core/administration/resources/i18n/cmsui_de.xml (original)
+++ lenya/trunk/src/modules-core/administration/resources/i18n/cmsui_de.xml Thu Mar 6 11:47:05 2008
@@ -67,5 +67,13 @@
<message key="modules">Module</message>
<message key="resource-types">Ressource-Typen</message>
+ <!-- reports -->
+ <message key="Reports">Berichte</message>
+ <message key="broken-links">Tote interne Links</message>
+ <message key="find-broken-links">Tote interne Links finden</message>
+ <message key="no-broken-links">Keine toten internen Links gefunden.</message>
+ <message key="Source">Quelle</message>
+ <message key="Target">Ziel</message>
+
</catalogue>
Added: lenya/trunk/src/modules-core/administration/usecases/reports.jx
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/administration/usecases/reports.jx?rev=634392&view=auto
==============================================================================
--- lenya/trunk/src/modules-core/administration/usecases/reports.jx (added)
+++ lenya/trunk/src/modules-core/administration/usecases/reports.jx Thu Mar 6 11:47:05 2008
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!-- $Id: emptyTrash.jx 164233 2005-04-22 13:01:45Z jwkaltz $ -->
+
+<page:page
+ xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"
+ xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
+ >
+
+ <page:body>
+ <jx:import uri="fallback://lenya/modules/usecase/templates/tabs.jx"/>
+ <div id="contentblock1" class="lenya-tab">
+ <h1><i18n:text>Reports</i18n:text></h1>
+
+ <jx:import uri="fallback://lenya/modules/usecase/templates/messages.jx"/>
+
+ <jx:choose>
+ <jx:when test="${usecase.getParameter('brokenLinks')}">
+ <h2><i18n:text>broken-links</i18n:text></h2>
+ <jx:set var="brokenLinks" value="${usecase.getParameter('brokenLinks')}"/>
+ <jx:choose>
+ <jx:when test="${brokenLinks.isEmpty()}">
+ <i18n:text>no-broken-links</i18n:text>
+ </jx:when>
+ <jx:otherwise>
+ <table class="lenya-table-list">
+ <tr>
+ <th><i18n:text>Source</i18n:text></th>
+ <th><i18n:text>Target</i18n:text></th>
+ </tr>
+ <jx:forEach var="brokenLink" items="${brokenLinks}">
+ <tr>
+ <td><a href="${brokenLink.getSourceUrl()}">${brokenLink.getSourceUrl()}</a></td>
+ <td>${brokenLink.getTargetUrl()}</td>
+ </tr>
+ </jx:forEach>
+ </table>
+ </jx:otherwise>
+ </jx:choose>
+ </jx:when>
+ <jx:otherwise>
+ <table class="lenya-table-noborder">
+ <tr>
+ <td>
+ <i18n:text>find-broken-links</i18n:text>
+ </td>
+ <td>
+ <form id="form-brokenLinks" method="get">
+ <input type="hidden" name="lenya.usecase" value="${usecase.getName()}"/>
+ <input type="hidden" name="report" value="brokenLinks"/>
+ <input type="submit" value="Submit" i18n:attr="value"/>
+ </form>
+ </td>
+ </tr>
+ </table>
+ </jx:otherwise>
+ </jx:choose>
+
+ </div>
+ </page:body>
+</page:page>
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org