[Yanel-commits] rev 22355 - in public/yanel/trunk/src:
core/java/org/wyona/yanel/core/api/attributes
core/java/org/wyona/yanel/core/attributes
core/java/org/wyona/yanel/core/attributes/versionable
core/java/org/wyona/yanel/servlet
resources/file/src/java/org/wyona/yanel/impl/resources
resources/xml/src/java/org/wyona/yanel/impl/resources
josias at wyona.com
josias at wyona.com
Thu Feb 1 15:46:05 CET 2007
Author: josias
Date: 2007-02-01 15:46:04 +0100 (Thu, 01 Feb 2007)
New Revision: 22355
Added:
public/yanel/trunk/src/core/java/org/wyona/yanel/core/attributes/versionable/
public/yanel/trunk/src/core/java/org/wyona/yanel/core/attributes/versionable/RevisionInformation.java
Modified:
public/yanel/trunk/src/core/java/org/wyona/yanel/core/api/attributes/VersionableV2.java
public/yanel/trunk/src/core/java/org/wyona/yanel/servlet/YanelServlet.java
public/yanel/trunk/src/resources/file/src/java/org/wyona/yanel/impl/resources/NodeResource.java
public/yanel/trunk/src/resources/xml/src/java/org/wyona/yanel/impl/resources/XMLResource.java
Log:
some changes to versioning: resources return a RevisionInformation object, s.t. additional information about a revision (date, user, comment) may be presented to the user. further added a comment parameter to the checkin method
Modified: public/yanel/trunk/src/core/java/org/wyona/yanel/core/api/attributes/VersionableV2.java
===================================================================
--- public/yanel/trunk/src/core/java/org/wyona/yanel/core/api/attributes/VersionableV2.java 2007-02-01 14:44:00 UTC (rev 22354)
+++ public/yanel/trunk/src/core/java/org/wyona/yanel/core/api/attributes/VersionableV2.java 2007-02-01 14:46:04 UTC (rev 22355)
@@ -18,6 +18,7 @@
import java.util.Date;
+import org.wyona.yanel.core.attributes.versionable.RevisionInformation;
import org.wyona.yanel.core.attributes.viewable.View;
/**
@@ -26,11 +27,11 @@
public interface VersionableV2 {
/**
- * Gets an array of revision names.
+ * Gets an array of revision information objects.
* @return
* @throws Exception
*/
- public String[] getRevisionNames() throws Exception;
+ public RevisionInformation[] getRevisions() throws Exception;
/**
* Gets the view of a certain revision.
@@ -59,7 +60,7 @@
* Puts this resource into checked-in state, and creates a new revision.
* @throws Exception
*/
- public void checkin() throws Exception;
+ public void checkin(String comment) throws Exception;
/**
Added: public/yanel/trunk/src/core/java/org/wyona/yanel/core/attributes/versionable/RevisionInformation.java
===================================================================
--- public/yanel/trunk/src/core/java/org/wyona/yanel/core/attributes/versionable/RevisionInformation.java 2007-02-01 14:44:00 UTC (rev 22354)
+++ public/yanel/trunk/src/core/java/org/wyona/yanel/core/attributes/versionable/RevisionInformation.java 2007-02-01 14:46:04 UTC (rev 22355)
@@ -0,0 +1,65 @@
+package org.wyona.yanel.core.attributes.versionable;
+
+import java.util.Date;
+
+import org.wyona.yarep.core.RepositoryException;
+import org.wyona.yarep.core.Revision;
+
+/**
+ * This class is a simple container for information about a revision of a resource.
+ */
+public class RevisionInformation {
+
+ protected String name;
+ protected Date date;
+ protected String user;
+ protected String comment;
+
+
+ public RevisionInformation(Revision revision) throws RepositoryException {
+ this.name = revision.getRevisionName();
+ this.date = revision.getCreationDate();
+ this.user = revision.getCreator();
+ this.comment = revision.getComment();
+ }
+
+ public RevisionInformation(String name, Date date, String user, String comment) {
+ this.name = name;
+ this.date = date;
+ this.user = user;
+ this.comment = comment;
+ }
+
+ /**
+ * Gets the revision name, which may be actually be a number in some repository implementations.
+ * @return
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Gets a comment which may have been entered when the revision was created.
+ * @return comment or empty string if there is no comment.
+ */
+ public String getComment() {
+ return comment;
+ }
+
+ /**
+ * Gets the date when the revision was created.
+ * @return
+ */
+ public Date getDate() {
+ return date;
+ }
+
+ /**
+ * Gets a string which identifies the person who created the revision.
+ * @return
+ */
+ public String getUser() {
+ return user;
+ }
+
+}
\ No newline at end of file
Property changes on: public/yanel/trunk/src/core/java/org/wyona/yanel/core/attributes/versionable/RevisionInformation.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: public/yanel/trunk/src/core/java/org/wyona/yanel/servlet/YanelServlet.java
===================================================================
--- public/yanel/trunk/src/core/java/org/wyona/yanel/servlet/YanelServlet.java 2007-02-01 14:44:00 UTC (rev 22354)
+++ public/yanel/trunk/src/core/java/org/wyona/yanel/servlet/YanelServlet.java 2007-02-01 14:46:04 UTC (rev 22355)
@@ -33,10 +33,12 @@
import org.wyona.yanel.core.api.attributes.VersionableV2;
import org.wyona.yanel.core.api.attributes.ViewableV1;
import org.wyona.yanel.core.api.attributes.ViewableV2;
+import org.wyona.yanel.core.attributes.versionable.RevisionInformation;
import org.wyona.yanel.core.attributes.viewable.View;
import org.wyona.yanel.core.attributes.viewable.ViewDescriptor;
import org.wyona.yanel.core.navigation.Node;
import org.wyona.yanel.core.navigation.Sitetree;
+import org.wyona.yanel.core.util.DateUtil;
import org.wyona.yanel.core.map.Map;
import org.wyona.yanel.core.map.Realm;
@@ -335,13 +337,21 @@
if (ResourceAttributeHelper.hasAttributeImplemented(res, "Versionable", "2")) {
// retrieve the revisions, but only in the meta usecase (for performance reasons):
if (request.getParameter("yanel.resource.meta") != null) {
- String[] revisions = ((VersionableV2)res).getRevisionNames();
+ RevisionInformation[] revisions = ((VersionableV2)res).getRevisions();
Element revisionsElement = (Element) resourceElement.appendChild(doc.createElement("revisions"));
if (revisions != null) {
for (int i=0; i<revisions.length; i++) {
Element revisionElement = (Element) revisionsElement.appendChild(doc.createElement("revision"));
- revisionElement.appendChild(doc.createTextNode(revisions[i]));
+ Element revisionNameElement = (Element) revisionElement.appendChild(doc.createElement("name"));
+ revisionNameElement.appendChild(doc.createTextNode(revisions[i].getName()));
+ Element revisionDateElement = (Element) revisionElement.appendChild(doc.createElement("date"));
+ revisionDateElement.appendChild(doc.createTextNode(DateUtil.format(revisions[i].getDate())));
+ Element revisionUserElement = (Element) revisionElement.appendChild(doc.createElement("user"));
+ revisionUserElement.appendChild(doc.createTextNode(revisions[i].getUser()));
+ Element revisionCommentElement = (Element) revisionElement.appendChild(doc.createElement("comment"));
+ revisionCommentElement.appendChild(doc.createTextNode(revisions[i].getComment()));
}
+
} else {
Element noRevisionsYetElement = (Element) resourceElement.appendChild(doc.createElement("no-revisions-yet"));
}
@@ -773,7 +783,7 @@
if (ResourceAttributeHelper.hasAttributeImplemented(resource, "Versionable", "2")) {
VersionableV2 versionable = (VersionableV2)resource;
try {
- versionable.checkin();
+ versionable.checkin("updated");
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new ServletException("Could not check in resource: " + resource.getPath()
Modified: public/yanel/trunk/src/resources/file/src/java/org/wyona/yanel/impl/resources/NodeResource.java
===================================================================
--- public/yanel/trunk/src/resources/file/src/java/org/wyona/yanel/impl/resources/NodeResource.java 2007-02-01 14:44:00 UTC (rev 22354)
+++ public/yanel/trunk/src/resources/file/src/java/org/wyona/yanel/impl/resources/NodeResource.java 2007-02-01 14:46:04 UTC (rev 22355)
@@ -24,6 +24,7 @@
import org.wyona.yanel.core.api.attributes.ModifiableV2;
import org.wyona.yanel.core.api.attributes.VersionableV2;
import org.wyona.yanel.core.api.attributes.ViewableV2;
+import org.wyona.yanel.core.attributes.versionable.RevisionInformation;
import org.wyona.yanel.core.attributes.viewable.View;
import org.wyona.yanel.core.attributes.viewable.ViewDescriptor;
import org.wyona.yanel.core.util.PathUtil;
@@ -213,19 +214,19 @@
/**
*
*/
- public String[] getRevisionNames() throws Exception {
+ public RevisionInformation[] getRevisions() throws Exception {
Revision[] revisions = getRealm().getRepository().getNode(getPath()).getRevisions();
- String[] revisionNames = new String[revisions.length];
-
+ RevisionInformation[] revisionInfos = new RevisionInformation[revisions.length];
+
for (int i=0; i<revisions.length; i++) {
- revisionNames[i] = revisions[i].getRevisionName();
+ revisionInfos[i] = new RevisionInformation(revisions[i]);
}
- return revisionNames;
+ return revisionInfos;
}
-
- public void checkin() throws Exception {
+
+ public void checkin(String comment) throws Exception {
Node node = getRealm().getRepository().getNode(getPath());
- node.checkin();
+ node.checkin(comment);
/*
if (node.isCheckedOut()) {
String checkoutUserID = node.getCheckoutUserID();
Modified: public/yanel/trunk/src/resources/xml/src/java/org/wyona/yanel/impl/resources/XMLResource.java
===================================================================
--- public/yanel/trunk/src/resources/xml/src/java/org/wyona/yanel/impl/resources/XMLResource.java 2007-02-01 14:44:00 UTC (rev 22354)
+++ public/yanel/trunk/src/resources/xml/src/java/org/wyona/yanel/impl/resources/XMLResource.java 2007-02-01 14:46:04 UTC (rev 22355)
@@ -25,6 +25,7 @@
import org.wyona.yanel.core.api.attributes.VersionableV2;
import org.wyona.yanel.core.api.attributes.ViewableV1;
import org.wyona.yanel.core.api.attributes.ViewableV2;
+import org.wyona.yanel.core.attributes.versionable.RevisionInformation;
import org.wyona.yanel.core.attributes.viewable.View;
import org.wyona.yanel.core.attributes.viewable.ViewDescriptor;
@@ -311,19 +312,22 @@
return true;
}
- public String[] getRevisionNames() throws Exception {
+ /**
+ *
+ */
+ public RevisionInformation[] getRevisions() throws Exception {
Revision[] revisions = getRealm().getRepository().getNode(getPath()).getRevisions();
- String[] revisionNames = new String[revisions.length];
-
+ RevisionInformation[] revisionInfos = new RevisionInformation[revisions.length];
+
for (int i=0; i<revisions.length; i++) {
- revisionNames[i] = revisions[i].getRevisionName();
+ revisionInfos[i] = new RevisionInformation(revisions[i]);
}
- return revisionNames;
+ return revisionInfos;
}
- public void checkin() throws Exception {
+ public void checkin(String comment) throws Exception {
Node node = getRealm().getRepository().getNode(getPath());
- node.checkin();
+ node.checkin(comment);
/*
if (node.isCheckedOut()) {
String checkoutUserID = node.getCheckoutUserID();
More information about the Yanel-commits
mailing list