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 2006/08/22 10:36:05 UTC
svn commit: r433561 [2/2] - in /lenya/trunk/src:
impl/java/org/apache/lenya/cms/publication/
impl/test/org/apache/lenya/cms/publication/
impl/test/org/apache/lenya/cms/site/
impl/test/org/apache/lenya/cms/site/simple/
java/org/apache/lenya/cms/cocoon/s...
Modified: lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java?rev=433561&r1=433560&r2=433561&view=diff
==============================================================================
--- lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java (original)
+++ lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java Tue Aug 22 01:36:01 2006
@@ -19,13 +19,14 @@
import java.util.ArrayList;
import java.util.List;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
import org.apache.lenya.cms.publication.Document;
-import org.apache.lenya.cms.publication.DocumentFactory;
import org.apache.lenya.cms.publication.DocumentManager;
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.PublicationException;
-import org.apache.lenya.cms.publication.util.DocumentSet;
-import org.apache.lenya.cms.publication.util.DocumentVisitor;
+import org.apache.lenya.cms.site.NodeIterator;
+import org.apache.lenya.cms.site.NodeSet;
import org.apache.lenya.cms.site.SiteNode;
import org.apache.lenya.cms.site.SiteUtil;
import org.apache.lenya.cms.site.usecases.AssetUtil;
@@ -34,15 +35,12 @@
import org.apache.lenya.cms.workflow.WorkflowUtil;
import org.apache.lenya.workflow.WorkflowException;
-import org.apache.excalibur.source.SourceResolver;
-import org.apache.excalibur.source.Source;
-
/**
* Deactivate usecase handler.
*
* @version $Id$
*/
-public class Deactivate extends DocumentUsecase implements DocumentVisitor {
+public class Deactivate extends DocumentUsecase {
/**
* Checks if the workflow event is supported and the parent of the document exists in the live
@@ -75,11 +73,10 @@
addInfoMessage("The single document cannot be deactivated because the workflow event cannot be invoked.");
}
- DocumentFactory map = getSourceDocument().getFactory();
Document liveDoc = getSourceDocument().getAreaVersion(Publication.LIVE_AREA);
- DocumentSet subSite = SiteUtil.getSubSite(this.manager, liveDoc);
+ NodeSet subSite = SiteUtil.getSubSite(this.manager, liveDoc.getLink().getNode());
SiteNode node = liveDoc.getLink().getNode();
- subSite.removeAll(SiteUtil.getExistingDocuments(this.manager, map, node));
+ subSite.remove(node);
if (!subSite.isEmpty()) {
allowSingle = false;
@@ -96,15 +93,15 @@
protected org.apache.lenya.cms.repository.Node[] getNodesToLock() throws UsecaseException {
try {
List nodes = new ArrayList();
- DocumentSet set = new DocumentSet();
+ NodeSet siteNodes = new NodeSet(this.manager);
Document doc = getSourceDocument();
- set.addAll(SiteUtil.getSubSite(this.manager, doc));
+ siteNodes.addAll(SiteUtil.getSubSite(this.manager, doc.getLink().getNode()));
Document liveDoc = doc.getAreaVersion(Publication.LIVE_AREA);
- set.addAll(SiteUtil.getSubSite(this.manager, liveDoc));
+ siteNodes.addAll(SiteUtil.getSubSite(this.manager, liveDoc.getLink().getNode()));
- Document[] documents = set.getDocuments();
+ Document[] documents = siteNodes.getDocuments();
for (int i = 0; i < documents.length; i++) {
nodes.add(documents[i].getRepositoryNode());
nodes.addAll(AssetUtil.getAssetNodes(documents[i], this.manager, getLogger()));
@@ -195,10 +192,11 @@
}
try {
- DocumentSet set = SiteUtil.getSubSite(this.manager, document);
- SiteUtil.sortDescending(this.manager, set);
- set.visit(this);
- } catch (PublicationException e) {
+ NodeSet set = SiteUtil.getSubSite(this.manager, document.getLink().getNode());
+ for (NodeIterator i = set.descending(); i.hasNext();) {
+ deactivateAllLanguageVersions(i.next());
+ }
+ } catch (Exception e) {
throw new RuntimeException(e);
}
@@ -218,42 +216,19 @@
}
/**
- * @throws PublicationException
- * @see org.apache.lenya.cms.publication.util.DocumentVisitor#visitDocument(org.apache.lenya.cms.publication.Document)
- */
- public void visitDocument(Document document) throws PublicationException {
-
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Visiting resource [" + document + "]");
- }
-
- try {
- deactivateAllLanguageVersions(document);
- } catch (WorkflowException e) {
- throw new PublicationException(e);
- }
- }
-
- /**
* Publishes all existing language versions of a document.
*
- * @param document The document.
+ * @param node The document.
* @throws PublicationException if an error occurs.
* @throws WorkflowException
*/
- protected void deactivateAllLanguageVersions(Document document) throws PublicationException,
+ protected void deactivateAllLanguageVersions(SiteNode node) throws PublicationException,
WorkflowException {
- String[] languages = document.getPublication().getLanguages();
+ String[] languages = node.getLanguages();
for (int i = 0; i < languages.length; i++) {
- if (document.existsVersion(Publication.LIVE_AREA, languages[i])) {
- Document version = document.getVersion(Publication.LIVE_AREA, languages[i]);
- if (WorkflowUtil.canInvoke(this.manager,
- getSession(),
- getLogger(),
- version,
- getEvent())) {
- deactivate(version);
- }
+ Document version = node.getLink(languages[i]).getDocument();
+ if (WorkflowUtil.canInvoke(this.manager, getSession(), getLogger(), version, getEvent())) {
+ deactivate(version);
}
}
}
Modified: lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java?rev=433561&r1=433560&r2=433561&view=diff
==============================================================================
--- lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java (original)
+++ lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java Tue Aug 22 01:36:01 2006
@@ -37,8 +37,8 @@
import org.apache.lenya.cms.publication.Proxy;
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.PublicationException;
-import org.apache.lenya.cms.publication.util.DocumentSet;
-import org.apache.lenya.cms.publication.util.DocumentVisitor;
+import org.apache.lenya.cms.site.NodeIterator;
+import org.apache.lenya.cms.site.NodeSet;
import org.apache.lenya.cms.site.SiteManager;
import org.apache.lenya.cms.site.SiteNode;
import org.apache.lenya.cms.site.SiteStructure;
@@ -57,7 +57,7 @@
*
* @version $Id$
*/
-public class Publish extends DocumentUsecase implements DocumentVisitor {
+public class Publish extends DocumentUsecase {
protected static final String MESSAGE_SUBJECT = "notification-message";
protected static final String MESSAGE_DOCUMENT_PUBLISHED = "document-published";
@@ -87,10 +87,15 @@
protected org.apache.lenya.cms.repository.Node[] getNodesToLock() throws UsecaseException {
try {
List nodes = new ArrayList();
- DocumentSet set = new DocumentSet();
+ NodeSet set = new NodeSet(this.manager);
Document doc = getSourceDocument();
- set.addAll(SiteUtil.getSubSite(this.manager, doc));
+ set.addAll(SiteUtil.getSubSite(this.manager, doc.getLink().getNode()));
+
+ Document[] docs = set.getDocuments();
+ for (int i = 0; i < docs.length; i++) {
+ nodes.add(docs[i].getRepositoryNode());
+ }
nodes.add(SiteUtil.getSiteStructure(this.manager,
getDocumentFactory(),
@@ -300,9 +305,10 @@
}
try {
- DocumentSet set = SiteUtil.getSubSite(this.manager, document);
- SiteUtil.sortAscending(this.manager, set);
- set.visit(this);
+ NodeSet set = SiteUtil.getSubSite(this.manager, document.getLink().getNode());
+ for (NodeIterator i = set.ascending(); i.hasNext();) {
+ publishAllLanguageVersions(i.next());
+ }
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -323,55 +329,25 @@
}
/**
- * @throws PublicationException
- * @see org.apache.lenya.cms.publication.util.DocumentVisitor#visitDocument(org.apache.lenya.cms.publication.Document)
- */
- public void visitDocument(Document document) throws PublicationException {
-
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Visiting resource [" + document + "]");
- }
-
- try {
- DocumentLocator parentLocator = document.getLocator().getParent();
- Document parent = document.getFactory().get(parentLocator);
- boolean publish = true;
- if (parent != null) {
- Document liveParent = parent.getAreaVersion(Publication.LIVE_AREA);
- if (!liveParent.exists()) {
- publish = false;
- }
- }
- if (publish) {
- publishAllLanguageVersions(document);
- }
- } catch (WorkflowException e) {
- throw new PublicationException(e);
- }
- }
-
- /**
* Publishes all existing language versions of a document.
*
- * @param document The document.
+ * @param node The document.
* @throws PublicationException if an error occurs.
* @throws WorkflowException
*/
- protected void publishAllLanguageVersions(Document document) throws PublicationException,
+ protected void publishAllLanguageVersions(SiteNode node) throws PublicationException,
WorkflowException {
- String[] languages = document.getPublication().getLanguages();
+ String[] languages = node.getLanguages();
try {
for (int i = 0; i < languages.length; i++) {
- if (document.existsTranslation(languages[i])) {
- Document version = document.getTranslation(languages[i]);
- if (WorkflowUtil.canInvoke(this.manager,
- getSession(),
- getLogger(),
- version,
- getEvent())) {
- publish(version);
- }
+ Document version = node.getLink(languages[i]).getDocument();
+ if (WorkflowUtil.canInvoke(this.manager,
+ getSession(),
+ getLogger(),
+ version,
+ getEvent())) {
+ publish(version);
}
}
} catch (Exception e) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org