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/01/18 12:19:34 UTC
svn commit: r370125 - in /lenya/trunk/src: java/org/apache/lenya/cms/site/
java/org/apache/lenya/cms/site/simple/
java/org/apache/lenya/cms/site/topicmap/
java/org/apache/lenya/cms/site/usecases/
modules/sitetree/java/src/org/apache/lenya/cms/site/tree/
Author: andreas
Date: Wed Jan 18 03:19:15 2006
New Revision: 370125
URL: http://svn.apache.org/viewcvs?rev=370125&view=rev
Log:
Added isVisibleInNav() method to SiteManager. This allows to fix an NPE in the CreateLanguage usecase.
Modified:
lenya/trunk/src/java/org/apache/lenya/cms/site/SiteManager.java
lenya/trunk/src/java/org/apache/lenya/cms/site/simple/SimpleSiteManager.java
lenya/trunk/src/java/org/apache/lenya/cms/site/topicmap/TopicMapSiteManager.java
lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/CreateLanguage.java
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/DefaultSiteTree.java
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTree.java
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeNode.java
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeNodeImpl.java
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/TreeSiteManager.java
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/SiteManager.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/SiteManager.java?rev=370125&r1=370124&r2=370125&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/SiteManager.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/SiteManager.java Wed Jan 18 03:19:15 2006
@@ -147,10 +147,19 @@
* It is meant to hide specific nodes within the "public" navigation whereas the node is visible within the info/site area.
*
* @param document The document.
- * @param label The label.
+ * @param visibleInNav The visibility.
* @throws SiteException if an error occurs.
*/
void setVisibleInNav(Document document, boolean visibleInNav) throws SiteException;
+
+ /**
+ * Returns the visibility of a node in the navigation.
+ *
+ * @param document The document.
+ * @return A boolean value.
+ * @throws SiteException if an error occurs.
+ */
+ boolean isVisibleInNav(Document document) throws SiteException;
/**
* Returns all documents in a certain area.
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/simple/SimpleSiteManager.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/simple/SimpleSiteManager.java?rev=370125&r1=370124&r2=370125&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/simple/SimpleSiteManager.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/simple/SimpleSiteManager.java Wed Jan 18 03:19:15 2006
@@ -201,7 +201,7 @@
/**
* @see org.apache.lenya.cms.site.SiteManager#setVisibleInNav(org.apache.lenya.cms.publication.Document,
- * java.lang.String)
+ * boolean)
*/
public void setVisibleInNav(Document document, boolean visibleInNav) throws SiteException {
}
@@ -234,6 +234,10 @@
*/
public Document getAvailableDocument(Document document) throws SiteException {
return document;
+ }
+
+ public boolean isVisibleInNav(Document document) throws SiteException {
+ return true;
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/topicmap/TopicMapSiteManager.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/topicmap/TopicMapSiteManager.java?rev=370125&r1=370124&r2=370125&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/topicmap/TopicMapSiteManager.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/topicmap/TopicMapSiteManager.java Wed Jan 18 03:19:15 2006
@@ -118,7 +118,7 @@
/**
* @see org.apache.lenya.cms.site.SiteManager#setVisibleInNav(org.apache.lenya.cms.publication.Document,
- * java.lang.String)
+ * boolean)
*/
public void setVisibleInNav(Document document, boolean visibleInNav) throws SiteException {
}
@@ -149,6 +149,10 @@
*/
public Document getAvailableDocument(Document document) throws SiteException {
return document;
+ }
+
+ public boolean isVisibleInNav(Document document) throws SiteException {
+ return true;
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/CreateLanguage.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/CreateLanguage.java?rev=370125&r1=370124&r2=370125&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/CreateLanguage.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/CreateLanguage.java Wed Jan 18 03:19:15 2006
@@ -19,12 +19,14 @@
import java.util.ArrayList;
import java.util.List;
+import org.apache.avalon.framework.service.ServiceSelector;
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentBuildException;
import org.apache.lenya.cms.publication.DocumentException;
import org.apache.lenya.cms.publication.DocumentIdentityMap;
-import org.apache.lenya.cms.publication.ResourceType;
import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.publication.ResourceType;
+import org.apache.lenya.cms.site.SiteManager;
/**
* Usecase to create a new language version of a resource.
@@ -88,6 +90,7 @@
Document source = getSourceDocument();
if (source != null) {
+ setParameter(DOCUMENT_ID, source.getId());
try {
List nonExistingLanguages = getNonExistingLanguages();
setParameter(LANGUAGES, nonExistingLanguages
@@ -140,6 +143,27 @@
}
}
return this.documentTypeName;
+ }
+
+ protected boolean getVisibleInNav() {
+ Document source = getSourceDocument();
+ ServiceSelector selector = null;
+ SiteManager siteManager = null;
+ try {
+ selector = (ServiceSelector) manager.lookup(SiteManager.ROLE + "Selector");
+ siteManager = (SiteManager) selector.select(source.getPublication()
+ .getSiteManagerHint());
+ return siteManager.isVisibleInNav(source);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ if (selector != null) {
+ if (siteManager != null) {
+ selector.release(siteManager);
+ }
+ manager.release(selector);
+ }
+ }
}
}
Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/DefaultSiteTree.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/DefaultSiteTree.java?rev=370125&r1=370124&r2=370125&view=diff
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/DefaultSiteTree.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/DefaultSiteTree.java Wed Jan 18 03:19:15 2006
@@ -120,9 +120,8 @@
Element root = document.getDocumentElement();
root.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
- root
- .setAttribute("xsi:schemaLocation",
- "http://apache.org/cocoon/lenya/sitetree/1.0 ../../../../resources/entities/sitetree.xsd");
+ root.setAttribute("xsi:schemaLocation",
+ "http://apache.org/cocoon/lenya/sitetree/1.0 ../../../../resources/entities/sitetree.xsd");
return document;
}
@@ -177,8 +176,8 @@
* @see org.apache.lenya.cms.site.tree.SiteTree#addNode(java.lang.String, java.lang.String,
* org.apache.lenya.cms.site.Label[], boolean)
*/
- public synchronized void addNode(String parentid, String id, Label[] labels, boolean visibleInNav)
- throws SiteException {
+ public synchronized void addNode(String parentid, String id, Label[] labels,
+ boolean visibleInNav) throws SiteException {
addNode(parentid, id, labels, visibleInNav, null, null, false);
}
@@ -194,8 +193,8 @@
* org.apache.lenya.cms.site.Label[], boolean, java.lang.String, java.lang.String, boolean,
* java.lang.String)
*/
- public synchronized void addNode(String documentid, Label[] labels, boolean visibleInNav, String href, String suffix,
- boolean link, String refDocumentId) throws SiteException {
+ public synchronized void addNode(String documentid, Label[] labels, boolean visibleInNav,
+ String href, String suffix, boolean link, String refDocumentId) throws SiteException {
StringBuffer buf = new StringBuffer();
StringTokenizer st = new StringTokenizer(documentid, "/");
int length = st.countTokens();
@@ -212,8 +211,8 @@
* @see org.apache.lenya.cms.site.tree.SiteTree#addNode(java.lang.String,
* org.apache.lenya.cms.site.Label[], boolean, java.lang.String, java.lang.String, boolean)
*/
- public synchronized void addNode(String documentid, Label[] labels, boolean visibleInNav, String href, String suffix,
- boolean link) throws SiteException {
+ public synchronized void addNode(String documentid, Label[] labels, boolean visibleInNav,
+ String href, String suffix, boolean link) throws SiteException {
addNode(documentid, labels, visibleInNav, href, suffix, link, null);
}
@@ -221,8 +220,8 @@
* @see org.apache.lenya.cms.site.tree.SiteTree#addNode(java.lang.String, java.lang.String,
* org.apache.lenya.cms.site.Label[], boolean, java.lang.String, java.lang.String, boolean)
*/
- public synchronized void addNode(String parentid, String id, Label[] labels, boolean visibleInNav, String href,
- String suffix, boolean link) throws SiteException {
+ public synchronized void addNode(String parentid, String id, Label[] labels,
+ boolean visibleInNav, String href, String suffix, boolean link) throws SiteException {
addNode(parentid, id, labels, visibleInNav, href, suffix, link, null);
}
@@ -231,8 +230,9 @@
* org.apache.lenya.cms.site.Label[], boolean, java.lang.String, java.lang.String, boolean,
* java.lang.String)
*/
- public synchronized void addNode(String parentid, String id, Label[] labels, boolean visibleInNav, String href,
- String suffix, boolean link, String refDocumentId) throws SiteException {
+ public synchronized void addNode(String parentid, String id, Label[] labels,
+ boolean visibleInNav, String href, String suffix, boolean link, String refDocumentId)
+ throws SiteException {
Node parentNode = getNodeInternal(parentid);
@@ -263,7 +263,7 @@
} else {
child.setAttribute(SiteTreeNodeImpl.VISIBLEINNAV_ATTRIBUTE_NAME, "false");
}
-
+
if ((href != null) && (href.length() > 0)) {
child.setAttribute(SiteTreeNodeImpl.HREF_ATTRIBUTE_NAME, href);
}
@@ -514,8 +514,14 @@
String parentId = newParent.getAbsoluteId();
String id = newid;
- this.addNode(parentId, id, subtreeRoot.getLabels(), subtreeRoot.visibleInNav(), subtreeRoot.getHref(), subtreeRoot
- .getSuffix(), subtreeRoot.hasLink(), refDocumentId);
+ this.addNode(parentId,
+ id,
+ subtreeRoot.getLabels(),
+ subtreeRoot.visibleInNav(),
+ subtreeRoot.getHref(),
+ subtreeRoot.getSuffix(),
+ subtreeRoot.hasLink(),
+ refDocumentId);
newParent = this.getNode(parentId + "/" + id);
if (newParent == null) {
throw new SiteException("The added node was not found.");
@@ -546,11 +552,12 @@
throw new RuntimeException(e);
}
}
-
+
/**
* @see org.apache.lenya.cms.site.tree.SiteTree#setVisibleInNav(java.lang.String, boolean)
*/
- public synchronized void setVisibleInNav(String documentId, boolean visibleInNav) throws SiteException {
+ public synchronized void setVisibleInNav(String documentId, boolean visibleInNav)
+ throws SiteException {
SiteTreeNode node = getNode(documentId);
if (visibleInNav) {
node.setNodeAttribute(SiteTreeNodeImpl.VISIBLEINNAV_ATTRIBUTE_NAME, "true");
@@ -599,6 +606,16 @@
*/
public void save() throws SiteException {
saveDocument();
+ }
+
+ public boolean isVisibleInNav(String documentId) throws SiteException {
+ SiteTreeNode node = getNode(documentId);
+ String value = node.getNodeAttribute(SiteTreeNodeImpl.VISIBLEINNAV_ATTRIBUTE_NAME);
+ if (value != null && !value.equals("")) {
+ return Boolean.valueOf(value).booleanValue();
+ } else {
+ return true;
+ }
}
}
Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTree.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTree.java?rev=370125&r1=370124&r2=370125&view=diff
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTree.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTree.java Wed Jan 18 03:19:15 2006
@@ -158,9 +158,19 @@
* Sets the visibility in the navigation of an existing node.
*
* @param documentId the document-id to which the visibility is to be added.
- * @param visiblieInNav
+ * @param visibleInNav The visibility.
+ * @throws SiteException if an error occurs.
*/
- void setVisibleInNav (String documentId, boolean visibleInNav) throws SiteException;
+ void setVisibleInNav(String documentId, boolean visibleInNav) throws SiteException;
+
+ /**
+ * Returns the visibility in the navigation of an existing node.
+ *
+ * @param documentId The document ID.
+ * @return A boolean value.
+ * @throws SiteException
+ */
+ boolean isVisibleInNav(String documentId) throws SiteException;
/**
* Remove a label from a node
Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeNode.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeNode.java?rev=370125&r1=370124&r2=370125&view=diff
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeNode.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeNode.java Wed Jan 18 03:19:15 2006
@@ -205,6 +205,14 @@
void setNodeAttribute (String attributeName, String attributeValue);
/**
+ * Returns an attribute of this node.
+ *
+ * @param attributeName name of the attribute
+ * @return The value.
+ */
+ String getNodeAttribute (String attributeName);
+
+ /**
* Give a list of the children and this node in a pre order way
* @return The list
*/
Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeNodeImpl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeNodeImpl.java?rev=370125&r1=370124&r2=370125&view=diff
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeNodeImpl.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeNodeImpl.java Wed Jan 18 03:19:15 2006
@@ -490,4 +490,9 @@
return list;
}
+ public String getNodeAttribute(String attributeName) {
+ Element element = (Element) this.node;
+ return element.getAttribute(attributeName);
+ }
+
}
Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/TreeSiteManager.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/TreeSiteManager.java?rev=370125&r1=370124&r2=370125&view=diff
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/TreeSiteManager.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/TreeSiteManager.java Wed Jan 18 03:19:15 2006
@@ -302,10 +302,9 @@
/**
* @see org.apache.lenya.cms.site.SiteManager#setVisibleInNav(org.apache.lenya.cms.publication.Document,
- * java.lang.String)
+ * boolean)
*/
public void setVisibleInNav(Document document, boolean visibleInNav) throws SiteException {
-
SiteTree tree = getTree(document);
tree.setVisibleInNav(document.getId(), visibleInNav);
}
@@ -468,5 +467,10 @@
}
return documentId;
+ }
+
+ public boolean isVisibleInNav(Document document) throws SiteException {
+ SiteTree tree = getTree(document);
+ return tree.isVisibleInNav(document.getId());
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org