|
|
Choosing A Webhost: |
svn commit: r534338 - in /lenya/trunk/src/modules-core/workflow: java/src/o: msg#00003cms.lenya.cvs
Author: andreas Date: Wed May 2 00:43:25 2007 New Revision: 534338 URL: http://svn.apache.org/viewvc?view=rev&rev=534338 Log: Lazy-load link lists for publish and deactivate usecases Modified: lenya/trunk/src/modules-core/workflow/java/src/org/apache/lenya/cms/workflow/usecases/Deactivate.java lenya/trunk/src/modules-core/workflow/java/src/org/apache/lenya/cms/workflow/usecases/Publish.java lenya/trunk/src/modules-core/workflow/usecases/deactivate.jx lenya/trunk/src/modules-core/workflow/usecases/publish.jx Modified: lenya/trunk/src/modules-core/workflow/java/src/org/apache/lenya/cms/workflow/usecases/Deactivate.java URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/workflow/java/src/org/apache/lenya/cms/workflow/usecases/Deactivate.java?view=diff&rev=534338&r1=534337&r2=534338 ============================================================================== --- lenya/trunk/src/modules-core/workflow/java/src/org/apache/lenya/cms/workflow/usecases/Deactivate.java (original) +++ lenya/trunk/src/modules-core/workflow/java/src/org/apache/lenya/cms/workflow/usecases/Deactivate.java Wed May 2 00:43:25 2007 @@ -22,6 +22,7 @@ import java.util.List; import java.util.Set; +import org.apache.avalon.framework.service.ServiceManager; import org.apache.excalibur.source.Source; import org.apache.excalibur.source.SourceResolver; import org.apache.lenya.cms.linking.LinkManager; @@ -53,16 +54,18 @@ super.doCheckPreconditions(); if (!hasErrors()) { + + Document doc = getSourceDocument(); - if (!getSourceDocument().getArea().equals(Publication.AUTHORING_AREA)) { + if (!doc.getArea().equals(Publication.AUTHORING_AREA)) { addErrorMessage("This usecase can only be invoked from the authoring area."); return; } - if (!getSourceDocument().existsAreaVersion(Publication.LIVE_AREA)) { + if (!doc.existsAreaVersion(Publication.LIVE_AREA)) { addErrorMessage("This usecase can only be invoked when the live version exists."); } else { - Document liveDoc = getSourceDocument().getAreaVersion(Publication.LIVE_AREA); + Document liveDoc = doc.getAreaVersion(Publication.LIVE_AREA); NodeSet subSite = SiteUtil.getSubSite(this.manager, liveDoc.getLink().getNode()); SiteNode node = liveDoc.getLink().getNode(); subSite.remove(node); @@ -70,34 +73,9 @@ if (!subSite.isEmpty()) { addErrorMessage("You can't deactivate this document because it has children."); } - } - - setParameter(LINKS_TO_DOCUMENT, getLinksToDocument()); - } - } - - protected Document[] getLinksToDocument() { - Set docs = new HashSet(); - LinkManager linkMgr = null; - try { - linkMgr = (LinkManager) this.manager.lookup(LinkManager.ROLE); - Document liveVersion = getSourceDocument().getAreaVersion(Publication.LIVE_AREA); - Document[] referencingDocs = linkMgr.getReferencingDocuments(liveVersion); - for (int d = 0; d < referencingDocs.length; d++) { - Document doc = referencingDocs[d]; - if (doc.getArea().equals(Publication.LIVE_AREA)) { - docs.add(doc); - } - } - } catch (Exception e) { - throw new RuntimeException(e); - } - finally { - if (linkMgr != null) { - this.manager.release(linkMgr); + setParameter(LINKS_TO_DOCUMENT, new LinkList(this.manager, doc)); } } - return (Document[]) docs.toArray(new Document[docs.size()]); } /** @@ -167,6 +145,60 @@ protected String getEvent() { return "deactivate"; + } + + /** + * A list of links pointing to a document. Allows lazy loading rom the usecase view. + */ + public static class LinkList { + + private Document document; + private Document[] documents; + private ServiceManager manager; + + /** + * @param manager The manager. + * @param doc The document to resolve the links from. + */ + public LinkList(ServiceManager manager, Document doc) { + this.manager = manager; + this.document = doc; + } + + /** + * @return The link documents. + */ + public Document[] getDocuments() { + if (this.documents == null) { + this.documents = getLinksToDocument(); + } + return this.documents; + } + + protected Document[] getLinksToDocument() { + Set docs = new HashSet(); + LinkManager linkMgr = null; + try { + linkMgr = (LinkManager) this.manager.lookup(LinkManager.ROLE); + Document liveVersion = this.document.getAreaVersion(Publication.LIVE_AREA); + Document[] referencingDocs = linkMgr.getReferencingDocuments(liveVersion); + for (int d = 0; d < referencingDocs.length; d++) { + Document doc = referencingDocs[d]; + if (doc.getArea().equals(Publication.LIVE_AREA)) { + docs.add(doc); + } + } + } catch (Exception e) { + throw new RuntimeException(e); + } + finally { + if (linkMgr != null) { + this.manager.release(linkMgr); + } + } + return (Document[]) docs.toArray(new Document[docs.size()]); + } + } } Modified: lenya/trunk/src/modules-core/workflow/java/src/org/apache/lenya/cms/workflow/usecases/Publish.java URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/workflow/java/src/org/apache/lenya/cms/workflow/usecases/Publish.java?view=diff&rev=534338&r1=534337&r2=534338 ============================================================================== --- lenya/trunk/src/modules-core/workflow/java/src/org/apache/lenya/cms/workflow/usecases/Publish.java (original) +++ lenya/trunk/src/modules-core/workflow/java/src/org/apache/lenya/cms/workflow/usecases/Publish.java Wed May 2 00:43:25 2007 @@ -28,6 +28,7 @@ import java.util.List; import java.util.Set; +import org.apache.avalon.framework.service.ServiceManager; import org.apache.avalon.framework.service.ServiceSelector; import org.apache.cocoon.components.ContextHelper; import org.apache.cocoon.environment.Request; @@ -93,40 +94,10 @@ setParameter(SCHEDULE_TIME, format.format(now)); setParameter(SEND_NOTIFICATION, Boolean.TRUE); - - setParameter(UNPUBLISHED_LINKS, getUnpublishedLinks()); - } - - protected Document[] getUnpublishedLinks() { - Set docs = new HashSet(); - LinkManager linkMgr = null; - LinkResolver resolver = null; - try { - linkMgr = (LinkManager) this.manager.lookup(LinkManager.ROLE); - resolver = (LinkResolver) this.manager.lookup(LinkResolver.ROLE); - org.apache.lenya.cms.linking.Link[] links = linkMgr.getLinksFrom(getSourceDocument()); - for (int i = 0; i < links.length; i++) { - LinkTarget target = resolver.resolve(getSourceDocument(), links[i].getUri()); - if (target.exists()) { - Document doc = target.getDocument(); - if (!doc.existsAreaVersion(Publication.LIVE_AREA)) { - docs.add(doc); - } - } - } - } catch (Exception e) { - throw new RuntimeException(e); - } finally { - if (linkMgr != null) { - this.manager.release(linkMgr); - } - if (resolver != null) { - this.manager.release(resolver); - } - } - return (Document[]) docs.toArray(new Document[docs.size()]); + + setParameter(UNPUBLISHED_LINKS, new LinkList(this.manager, getSourceDocument())); } - + /** * @see org.apache.lenya.cms.usecase.AbstractUsecase#getNodesToLock() */ @@ -355,6 +326,66 @@ path += "/" + steps[s]; s++; } + } + + /** + * A list of links originating from a document. Allows lazy loading rom the usecase view. + */ + public static class LinkList { + + private Document document; + private Document[] documents; + private ServiceManager manager; + + /** + * @param manager The manager. + * @param doc The document to resolve the links from. + */ + public LinkList(ServiceManager manager, Document doc) { + this.manager = manager; + this.document = doc; + } + + /** + * @return The link documents. + */ + public Document[] getDocuments() { + if (this.documents == null) { + this.documents = getUnpublishedLinks(); + } + return this.documents; + } + + protected Document[] getUnpublishedLinks() { + Set docs = new HashSet(); + LinkManager linkMgr = null; + LinkResolver resolver = null; + try { + linkMgr = (LinkManager) this.manager.lookup(LinkManager.ROLE); + resolver = (LinkResolver) this.manager.lookup(LinkResolver.ROLE); + org.apache.lenya.cms.linking.Link[] links = linkMgr.getLinksFrom(this.document); + for (int i = 0; i < links.length; i++) { + LinkTarget target = resolver.resolve(this.document, links[i].getUri()); + if (target.exists()) { + Document doc = target.getDocument(); + if (!doc.existsAreaVersion(Publication.LIVE_AREA)) { + docs.add(doc); + } + } + } + } catch (Exception e) { + throw new RuntimeException(e); + } finally { + if (linkMgr != null) { + this.manager.release(linkMgr); + } + if (resolver != null) { + this.manager.release(resolver); + } + } + return (Document[]) docs.toArray(new Document[docs.size()]); + } + } } Modified: lenya/trunk/src/modules-core/workflow/usecases/deactivate.jx URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/workflow/usecases/deactivate.jx?view=diff&rev=534338&r1=534337&r2=534338 ============================================================================== --- lenya/trunk/src/modules-core/workflow/usecases/deactivate.jx (original) +++ lenya/trunk/src/modules-core/workflow/usecases/deactivate.jx Wed May 2 00:43:25 2007 @@ -48,7 +48,8 @@ "<jx:out value="${title}"/>" </td> </tr> - <jx:if test="${!usecase.hasErrors() && usecase.getParameter('linksToDocument').size() > 0}"> + <jx:set var="linksToDocument" value="${usecase.getParameter('linksToDocument').getDocuments()}"/> + <jx:if test="${!usecase.hasErrors() && linksToDocument.size() > 0}"> <tr> <td class="lenya-entry-caption" valign="top"> <p> @@ -57,7 +58,7 @@ </td> <td> <ul> - <jx:forEach var="link" items="${usecase.getParameter('linksToDocument')}"> + <jx:forEach var="link" items="${linksToDocument}"> <li> <a href="${request.contextPath}${link.getCanonicalWebappURL()}"> <jx:out value="${link.getMetaData('http://purl.org/dc/elements/1.1/').getFirstValue('title')}"/></a> Modified: lenya/trunk/src/modules-core/workflow/usecases/publish.jx URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/workflow/usecases/publish.jx?view=diff&rev=534338&r1=534337&r2=534338 ============================================================================== --- lenya/trunk/src/modules-core/workflow/usecases/publish.jx (original) +++ lenya/trunk/src/modules-core/workflow/usecases/publish.jx Wed May 2 00:43:25 2007 @@ -78,8 +78,8 @@ </ul> </td> </tr> - <jx:if test="${usecase.getParameter('unpublishedLinks') != null && - usecase.getParameter('unpublishedLinks').size() > 0}"> + <jx:set var="unpublishedLinks" value="${usecase.getParameter('unpublishedLinks').getDocuments()}"/> + <jx:if test="${unpublishedLinks != null && unpublishedLinks.size() > 0}"> <tr> <td class="lenya-entry-caption" valign="top"> <p> @@ -88,7 +88,7 @@ </td> <td> <ul> - <jx:forEach var="link" items="${usecase.getParameter('unpublishedLinks')}"> + <jx:forEach var="link" items="${unpublishedLinks}"> <li> <a href="${request.contextPath}${link.getCanonicalWebappURL()}"> <jx:out value="${link.getMetaData('http://purl.org/dc/elements/1.1/').getFirstValue('title')}"/></a>
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |