[Yanel-commits] rev 46693 - in public/yanel/trunk/src:
contributions/resources/resource-creator/src/java/org/wyona/yanel/impl/resources/rescreator
core/java/org/wyona/yanel/core/navigation
impl/java/org/wyona/yanel/impl/navigation
michi at wyona.com
michi at wyona.com
Wed Dec 16 17:24:27 CET 2009
Author: michi
Date: 2009-12-16 17:24:25 +0100 (Wed, 16 Dec 2009)
New Revision: 46693
Modified:
public/yanel/trunk/src/contributions/resources/resource-creator/src/java/org/wyona/yanel/impl/resources/rescreator/ResourceCreatorResource.java
public/yanel/trunk/src/core/java/org/wyona/yanel/core/navigation/Node.java
public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/navigation/NodeDOMImpl.java
public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/navigation/NodeRTIImpl.java
public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/navigation/NodeResConfigAndDataRepoImpl.java
Log:
introduce type for appendChild method such that isCollection and isResource actually make sense as API methods
Modified: public/yanel/trunk/src/contributions/resources/resource-creator/src/java/org/wyona/yanel/impl/resources/rescreator/ResourceCreatorResource.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/resource-creator/src/java/org/wyona/yanel/impl/resources/rescreator/ResourceCreatorResource.java 2009-12-16 16:18:52 UTC (rev 46692)
+++ public/yanel/trunk/src/contributions/resources/resource-creator/src/java/org/wyona/yanel/impl/resources/rescreator/ResourceCreatorResource.java 2009-12-16 16:24:25 UTC (rev 46693)
@@ -313,7 +313,7 @@
if (getRequest().getParameter("create-new-folder") != null && !getRequest().getParameter("create-new-folder").equals("")) {
try {
- create(getRequest().getParameter("create-new-folder"), getRequest().getParameter("lookin"), "http://www.wyona.org/yanel/resource/1.0::directory");
+ create(getRequest().getParameter("create-new-folder"), getRequest().getParameter("lookin"), "http://www.wyona.org/yanel/resource/1.0::directory", org.wyona.yanel.core.navigation.Node.COLLECTION);
} catch (Exception e) {
sb.append("<p>Could not create folder. Exception: " + e + "</p>");
log.error(e.getMessage(), e);
@@ -441,7 +441,7 @@
* @return Path of new resource
*/
private Path create() throws Exception {
- return create(getRequest().getParameter("create-name"), getRequest().getParameter("lookin"), getRequest().getParameter("resource-type"));
+ return create(getRequest().getParameter("create-name"), getRequest().getParameter("lookin"), getRequest().getParameter("resource-type"), org.wyona.yanel.core.navigation.Node.RESOURCE); // NOTE/TODO: The directory resource for example should be created as COLLECTION, but how do we know that?
}
/**
@@ -451,7 +451,7 @@
* @param String resourceType
* @return Path of new resource
*/
- private Path create(String createName, String lookinPath, String resourceType) throws Exception {
+ private Path create(String createName, String lookinPath, String resourceType, int type) throws Exception {
if (resourceType == null) {
log.error("No resource-type parameter specified!");
return null;
@@ -489,7 +489,7 @@
((CreatableV2) newResource).create(request);
if (pathOfNewResource != null) {
createResourceConfiguration(newResource);
- addToSitetree(newResource);
+ addToSitetree(newResource, type);
}
} else {
throw new Exception("creation NOT successfull!");
@@ -504,14 +504,14 @@
/**
* Add to sitetree
*/
- private void addToSitetree(Resource newResource) throws Exception {
+ private void addToSitetree(Resource newResource, int type) throws Exception {
org.wyona.yanel.core.navigation.Sitetree sitetree = getRealm().getRepoNavigation();
String parentPath = org.wyona.commons.io.PathUtil.getParent(newResource.getPath());
org.wyona.yanel.core.navigation.Node parentNode = sitetree.getNode(getRealm(), parentPath);
if (parentNode != null) {
String nodeName = org.wyona.commons.io.PathUtil.getName(newResource.getPath());
String label = nodeName;
- parentNode.appendChild(sitetree.createNode(nodeName, label)); // Sitetree will be saved persistently automatically within appendChild(Node)
+ parentNode.appendChild(sitetree.createNode(nodeName, label), type); // Sitetree will be saved persistently automatically within appendChild(Node)
} else {
log.error("No such node with path: " + parentPath);
}
Modified: public/yanel/trunk/src/core/java/org/wyona/yanel/core/navigation/Node.java
===================================================================
--- public/yanel/trunk/src/core/java/org/wyona/yanel/core/navigation/Node.java 2009-12-16 16:18:52 UTC (rev 46692)
+++ public/yanel/trunk/src/core/java/org/wyona/yanel/core/navigation/Node.java 2009-12-16 16:24:25 UTC (rev 46693)
@@ -21,6 +21,9 @@
*/
public interface Node {
+ public static int RESOURCE = 1;
+ public static int COLLECTION = 2;
+
/**
* @return new child
*/
@@ -38,8 +41,9 @@
/**
* @return new child
+ * @param type Node type (collection, resource)
*/
- public Node appendChild(Node child);
+ public Node appendChild(Node child, int type);
/**
*/
Modified: public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/navigation/NodeDOMImpl.java
===================================================================
--- public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/navigation/NodeDOMImpl.java 2009-12-16 16:18:52 UTC (rev 46692)
+++ public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/navigation/NodeDOMImpl.java 2009-12-16 16:24:25 UTC (rev 46693)
@@ -31,7 +31,7 @@
private static Logger log = Logger.getLogger(NodeDOMImpl.class);
- org.w3c.dom.Element element;
+ Element element;
SitetreeDOMImpl sitetree;
public NodeDOMImpl(org.w3c.dom.Element element, SitetreeDOMImpl sitetree) {
@@ -64,10 +64,18 @@
}
/**
- * @return new child
+ * @see org.wyona.yanel.core.navigation.Node#appendChild(Node, int)
*/
- public Node appendChild(Node child) {
- this.element.appendChild(((NodeDOMImpl) child).getElement());
+ public Node appendChild(Node child, int type) {
+ log.warn("TODO: Implement type ...");
+ Element childElement = (Element) this.element.appendChild(((NodeDOMImpl) child).getElement());
+ if (type == Node.COLLECTION) {
+ childElement.setAttribute("type", "collection");
+ } else if(type == Node.RESOURCE) {
+ childElement.setAttribute("type", "resource");
+ } else {
+ log.error("No such type: " + type);
+ }
sitetree.save();
return child;
}
Modified: public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/navigation/NodeRTIImpl.java
===================================================================
--- public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/navigation/NodeRTIImpl.java 2009-12-16 16:18:52 UTC (rev 46692)
+++ public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/navigation/NodeRTIImpl.java 2009-12-16 16:24:25 UTC (rev 46693)
@@ -64,9 +64,9 @@
}
/**
- * @return new child
+ * @see org.wyona.yanel.core.navigation.Node#appendChild(Node, int)
*/
- public Node appendChild(Node child) {
+ public Node appendChild(Node child, int type) {
log.warn("Not implemented yet!");
return null;
}
Modified: public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/navigation/NodeResConfigAndDataRepoImpl.java
===================================================================
--- public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/navigation/NodeResConfigAndDataRepoImpl.java 2009-12-16 16:18:52 UTC (rev 46692)
+++ public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/navigation/NodeResConfigAndDataRepoImpl.java 2009-12-16 16:24:25 UTC (rev 46693)
@@ -66,9 +66,9 @@
}
/**
- * @return new child
+ * @see org.wyona.yanel.core.navigation.Node#appendChild(Node, int)
*/
- public Node appendChild(Node child) {
+ public Node appendChild(Node child, int type) {
log.warn("Not implemented yet!");
return null;
}
More information about the Yanel-commits
mailing list