cmlenz 02/02/24 15:24:51
Modified: src/share/org/apache/slide/content Tag: SLIDE_1_0
NodeRevisionDescriptor.java
Log:
Porting bugfixes/enhancements from the HEAD branch:
- Committed by juergen, 01/12/07 05:50:56
"1) BUG: PropPatch did not rollback, if one action could not be executed
2) The property itself decides, if it is read-only or can be modified by
propPatch
3) all live properties have get/set methods, they are now used."
- Committed by juergen, 02/01/04 07:25:27
"added user path to owner url."
[NOTE: this change seems to have been reverted elsewhere, but not here.
Reasons? Oversight?]
- Committed by juergen, 02/01/10 07:48:13
"if the namespace is not specified (is null), access the properties
hashtable with an empty namespace string. (no NPE
Revision Changes Path
No revision
No revision
1.19.2.1 +166 -23
jakarta-slide/src/share/org/apache/slide/content/NodeRevisionDescriptor.java
Index: NodeRevisionDescriptor.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/share/org/apache/slide/content/NodeRevisionDescriptor.java,v
retrieving revision 1.19
retrieving revision 1.19.2.1
diff -u -r1.19 -r1.19.2.1
--- NodeRevisionDescriptor.java 4 Sep 2001 17:37:56 -0000 1.19
+++ NodeRevisionDescriptor.java 24 Feb 2002 23:24:51 -0000 1.19.2.1
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/share/org/apache/slide/content/NodeRevisionDescriptor.java,v
1.19 2001/09/04 17:37:56 juergen Exp $
- * $Revision: 1.19 $
- * $Date: 2001/09/04 17:37:56 $
+ * $Header:
/home/cvs/jakarta-slide/src/share/org/apache/slide/content/NodeRevisionDescriptor.java,v
1.19.2.1 2002/02/24 23:24:51 cmlenz Exp $
+ * $Revision: 1.19.2.1 $
+ * $Date: 2002/02/24 23:24:51 $
*
* ====================================================================
*
@@ -81,7 +81,7 @@
* Node Revision Descriptor class.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Remy Maucherat</a>
- * @version $Revision: 1.19 $
+ * @version $Revision: 1.19.2.1 $
*/
public final class NodeRevisionDescriptor implements Serializable, Cloneable {
@@ -110,7 +110,8 @@
/**
* Type.
*/
- public static final String TYPE = "resourcetype";
+ public static final String RESOURCE_TYPE = "resourcetype";
+ public static final String TYPE = RESOURCE_TYPE;
/**
@@ -120,6 +121,12 @@
/**
+ * Owner.
+ */
+ public static final String OWNER = "owner";
+
+
+ /**
* MIME type of the content.
*/
public static final String CONTENT_TYPE = "getcontenttype";
@@ -362,7 +369,7 @@
*/
public boolean exists(String name, String namespace) {
if (name != null)
- return (properties.get(namespace + name) != null);
+ return (properties.get(getNamespacedPropertyName(namespace,name)) !=
null);
else
return (false);
}
@@ -387,7 +394,7 @@
* @return String property value
*/
public NodeProperty getProperty(String name, String namespace) {
- Object result = properties.get(namespace + name);
+ Object result = properties.get(getNamespacedPropertyName(namespace,name));
if (result != null) {
return (NodeProperty) result;
} else {
@@ -424,7 +431,7 @@
*
* @param name Property name
* @param value Property value
- * @param standard True if one of the standrad properties
+ * @param standard True if one of the standard properties
*/
protected void setProperty(String name, Object value, boolean standard) {
setProperty(new NodeProperty(name, value, standard));
@@ -437,7 +444,8 @@
* @param property Property
*/
public void setProperty(NodeProperty property) {
- properties.put(property.getNamespace() + property.getName(),
+ properties.put(getNamespacedPropertyName(property.getNamespace(),
+ property.getName()) ,
property);
}
@@ -448,7 +456,8 @@
* @param property Property
*/
public void removeProperty(NodeProperty property) {
- properties.remove(property.getNamespace() + property.getName());
+ properties.remove(getNamespacedPropertyName(property.getNamespace(),
+ property.getName()));
}
@@ -458,7 +467,7 @@
* @param property Property
*/
public void removeProperty(String property) {
- properties.remove(NodeProperty.DEFAULT_NAMESPACE + property);
+ properties.remove(getNamespacedPropertyName(NodeProperty.DEFAULT_NAMESPACE,
property));
}
@@ -468,7 +477,7 @@
* @param property Property
*/
public void removeProperty(String property, String nameSpace) {
- properties.remove(nameSpace + property);
+ properties.remove(getNamespacedPropertyName(nameSpace, property));
}
@@ -542,11 +551,128 @@
* @param name New name
*/
public void setName(String name) {
- setProperty(NAME, "<![CDATA[" + name + "]]>", true);
+ setProperty(NAME, "<![CDATA[" + name + "]]>", false); // live property,
but can be modified
}
/**
+ * Get the ETAG property (if any).
+ *
+ * @return String
+ */
+ public String getETag() {
+ NodeProperty contentType = getProperty(ETAG);
+ if (contentType == null) {
+ return new String();
+ } else {
+ return (String) contentType.getValue();
+ }
+ }
+
+
+ /**
+ * Set ETAG property.
+ *
+ * @param eTag New etag
+ */
+ public void setETag(String eTag) {
+ setProperty(ETAG, eTag, true); // live property, can not be modified
+ }
+
+
+
+
+
+ /**
+ * Get the owner property (if any).
+ *
+ * @return String
+ */
+ public String getOwner() {
+ NodeProperty owner = getProperty(OWNER);
+ if (owner == null) {
+ return new String();
+ } else {
+ return (String) owner.getValue();
+ }
+ }
+
+
+ /**
+ * Set owner property.
+ *
+ * @param eTag New etag
+ */
+ public void setOwner(String owner) {
+ setProperty(OWNER, owner, true); // live property, can not be modified
+ }
+
+ /**
+ * Set owner property.
+ *
+ * @param eTag New etag
+ */
+ public void setOwner(String owner, String userpath) {
+ setProperty(OWNER, userpath + "/" + owner, true); // live property, can
not be modified
+ }
+
+ /**
+ * Get the source property (if any).
+ *
+ * @return String
+ */
+ public String getSource() {
+ NodeProperty source = getProperty(SOURCE);
+ if (source == null) {
+ return new String();
+ } else {
+ return (String) source.getValue();
+ }
+ }
+
+
+ /**
+ * Set owner property.
+ *
+ * @param eTag New etag
+ */
+ public void setSource(String source) {
+ setProperty(SOURCE, source, true); // live property, can not be modified
+ }
+
+
+
+
+
+
+ /**
+ * Get the ResourceType property (if any).
+ *
+ * @return String
+ */
+ public String getResourceType() {
+ NodeProperty resourceType = getProperty(RESOURCE_TYPE);
+ if (resourceType == null) {
+ return new String();
+ } else {
+ return (String) resourceType.getValue();
+ }
+ }
+
+
+ /**
+ * Set ResourceType property.
+ *
+ * @param ResourceType New ResourceType
+ */
+ public void setResourceType(String resourceType) {
+ setProperty(RESOURCE_TYPE, resourceType, true); // live property, can not
be modified
+ }
+
+
+
+
+ /**
* Get the MIME content type of the data (if any).
*
* @return String
@@ -567,7 +693,7 @@
* @param contentType New content type
*/
public void setContentType(String contentType) {
- setProperty(CONTENT_TYPE, contentType, true);
+ setProperty(CONTENT_TYPE, contentType, true); // live property, can not be
modified
}
@@ -592,7 +718,7 @@
* @param contentLanguage New content language
*/
public void setContentLanguage(String contentLanguage) {
- setProperty(CONTENT_LANGUAGE, contentLanguage, true);
+ setProperty(CONTENT_LANGUAGE, contentLanguage, true); // live property,
can not be modified
}
@@ -650,8 +776,9 @@
* @param creationDate New creation date
*/
public void setCreationDate(Date creationDate) {
- setProperty
- (CREATION_DATE, creationDateFormat.format(creationDate), true);
+ // live property, can not be modified
+ setProperty(
+ CREATION_DATE, creationDateFormat.format(creationDate), true);
}
@@ -661,7 +788,7 @@
* @param creationDate New creation date
*/
public void setCreationDate(String creationDate) {
- setProperty(CREATION_DATE, creationDate, true);
+ setProperty(CREATION_DATE, creationDate, true); // live property, can not
be modified
}
@@ -719,6 +846,7 @@
* @param lastModified New last modified date
*/
public void setLastModified(Date lastModified) {
+ // live property, can not be modified
setProperty(LAST_MODIFIED, format.format(lastModified), true);
}
@@ -729,7 +857,7 @@
* @param lastModified New last modified
*/
public void setLastModified(String lastModified) {
- setProperty(LAST_MODIFIED, lastModified, true);
+ setProperty(LAST_MODIFIED, lastModified, true); // live property, can not
be modified
}
@@ -739,7 +867,7 @@
* @param creationLength New content length
*/
public void setContentLength(long contentLength) {
- setProperty(CONTENT_LENGTH, new Long(contentLength), true);
+ setProperty(CONTENT_LENGTH, new Long(contentLength), true); // live
property, can not be modified
}
@@ -758,7 +886,7 @@
if (contentLengthValue == null) {
contentLengthValue = new Long(0);
}
- setProperty(CONTENT_LENGTH, contentLengthValue, true);
+ setProperty(CONTENT_LENGTH, contentLengthValue, true); // live property,
can not be modified
}
@@ -811,11 +939,26 @@
setCreationDate(new Date());
setName("");
// By default, a resource is a collection
- setProperty(TYPE, "<collection/>", true);
- setProperty(SOURCE, "", true);
+ setResourceType("<collection/>");
+ setProperty(SOURCE, "", true); // live property, can not be modified
setContentLength(-1);
setLastModified(new Date());
+ }
+
+ /**
+ * Calculate the property name concatenated with the namespace, if available
+ *
+ * @param namespace the namespace name, possibly null
+ * @return propertyName the property name
+ *
+ * @return String the property name, including the namespace
+ */
+ public String getNamespacedPropertyName(String namespace, String propertyName) {
+ String result;
+ if (namespace == null) result = propertyName;
+ else result = namespace + propertyName;
+ return result;
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>