You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by jo...@apache.org on 2006/08/07 16:45:09 UTC
svn commit: r429355 -
/lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUtil.java
Author: josias
Date: Mon Aug 7 07:45:08 2006
New Revision: 429355
URL: http://svn.apache.org/viewvc?rev=429355&view=rev
Log:
getExistingDocuments(): don't throw an exception if no documents are found, but return an empty set instead. (fixes a problem in the precondition checking of the publish usecase, when a document does not exist in the live area)
Modified:
lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUtil.java
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUtil.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUtil.java?rev=429355&r1=429354&r2=429355&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUtil.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUtil.java Mon Aug 7 07:45:08 2006
@@ -141,7 +141,8 @@
* @param factory The document factory.
* @param map An identity map.
* @param node A node.
- * @return All existing documents belonging to the node.
+ * @return All existing documents belonging to the node. Empty set if no documents belong to
+ * the node.
* @throws DocumentBuildException if an error occurs.
* @throws DocumentException if an error occurs.
* @throws SiteException
@@ -149,13 +150,17 @@
public static DocumentSet getExistingDocuments(ServiceManager manager, DocumentFactory factory,
SiteNode node) throws DocumentBuildException, DocumentException, SiteException {
DocumentSet set = new DocumentSet();
- String uuid = SiteUtil.getUUID(manager, factory, node.getPublication(), node.getArea(),
- node.getPath());
- Document document = factory.get(node.getPublication(), node.getArea(), uuid);
- String[] languages = document.getLanguages();
- for (int i = 0; i < languages.length; i++) {
- Document version = document.getTranslation(languages[i]);
- set.add(version);
+
+ if (SiteUtil.contains(manager, factory, node.getPublication(), node.getArea(),
+ node.getPath())) {
+ String uuid = SiteUtil.getUUID(manager, factory, node.getPublication(), node.getArea(),
+ node.getPath());
+ Document document = factory.get(node.getPublication(), node.getArea(), uuid);
+ String[] languages = document.getLanguages();
+ for (int i = 0; i < languages.length; i++) {
+ Document version = document.getTranslation(languages[i]);
+ set.add(version);
+ }
}
return set;
}
@@ -639,6 +644,28 @@
} catch (SiteException e) {
throw e;
} catch (Exception e) {
+ throw new SiteException(e);
+ } finally {
+ if (selector != null) {
+ if (siteManager != null) {
+ selector.release(siteManager);
+ }
+ manager.release(selector);
+ }
+ }
+ }
+
+ public static boolean contains(ServiceManager manager, DocumentFactory factory, Publication pub,
+ String area, String path) throws SiteException {
+ SiteManager siteManager = null;
+ ServiceSelector selector = null;
+
+ try {
+ selector = (ServiceSelector) manager.lookup(SiteManager.ROLE + "Selector");
+ String siteManagerHint = pub.getSiteManagerHint();
+ siteManager = (SiteManager) selector.select(siteManagerHint);
+ return siteManager.contains(factory, pub, area, path);
+ } catch (ServiceException e) {
throw new SiteException(e);
} finally {
if (selector != null) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org