pnever 2002/07/14 23:19:09
Modified: src/webdav/server/org/apache/slide/webdav/util
VersioningHelper.java
Log:
Fixed potential NPE and removed obsolete methods.
Revision Changes Path
1.63 +29 -116
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java
Index: VersioningHelper.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -r1.62 -r1.63
--- VersioningHelper.java 13 Jul 2002 16:59:50 -0000 1.62
+++ VersioningHelper.java 15 Jul 2002 06:19:09 -0000 1.63
@@ -1420,31 +1420,6 @@
content.store( sToken, vcrUri, vcrRevisionDescriptor, vrContent );
}
-
- /**
- * Backups the properties of the given <code>revisionDescriptor</code>
- * at the 0.0 revision of the NodeRevisionDescriptors of the VCR.
- *
- * @param revisionDescriptors the NodeRevisionDescriptors of the
- * VCR to backup.
- * @param revisionDescriptor the NodeRevisionDescriptor of the
- * VCR to backup.
- *
- * @throws SlideException
- */
- protected void backupProperties(NodeRevisionDescriptors revisionDescriptors,
NodeRevisionDescriptor revisionDescriptor) throws SlideException {
-
- NodeRevisionDescriptor backup =
- cloneRevisionDescriptor(revisionDescriptor,
NodeRevisionNumber.HIDDEN_0_0);
- try {
- content.retrieve(sToken, revisionDescriptors,
backup.getRevisionNumber());
- content.store(sToken, revisionDescriptors.getUri(), backup, null);
- }
- catch (RevisionDescriptorNotFoundException e) {
- content.create(sToken, revisionDescriptors.getUri(),null, backup,
null);
- }
- }
-
/**
* Backups specific live properties of the given <code>revisionDescriptor</code>
* at the 0.0 revision of the NodeRevisionDescriptors of the VCR.
@@ -1461,9 +1436,19 @@
NodeRevisionDescriptor backupNrd =
new NodeRevisionDescriptor( NodeRevisionNumber.HIDDEN_0_0, "backup",
new Vector(), new Hashtable() );
- backupNrd.setProperty( rNrd.getProperty(P_AUTO_VERSION) );
- backupNrd.setProperty( rNrd.getProperty(P_OWNER) );
- backupNrd.setProperty( rNrd.getProperty(P_COMMENT) );
+ NodeProperty p;
+
+ p = rNrd.getProperty( P_AUTO_VERSION );
+ if( p != null )
+ backupNrd.setProperty( p );
+
+ p = rNrd.getProperty( P_OWNER );
+ if( p != null )
+ backupNrd.setProperty( p );
+
+ p = rNrd.getProperty( P_COMMENT );
+ if( p != null )
+ backupNrd.setProperty( p );
try {
content.retrieve( sToken, rNrds, NodeRevisionNumber.HIDDEN_0_0 );
@@ -1475,25 +1460,6 @@
}
/**
- * Restores the properties of the given <code>revisionDescriptor</code>
- * from the hidden 0.0 revision of the NodeRevisionDescriptors of the VCR.
- *
- * @param revisionDescriptors the NodeRevisionDescriptors of the
- * VCR to restore.
- * @param revisionDescriptor the NodeRevisionDescriptor of the
- * VCR to restore.
- *
- * @throws SlideException
- */
- protected void restoreProperties(NodeRevisionDescriptors revisionDescriptors,
NodeRevisionDescriptor revisionDescriptor) throws SlideException {
-
- NodeRevisionDescriptor backup =
- content.retrieve(sToken, revisionDescriptors,
NodeRevisionNumber.HIDDEN_0_0);
- copyRevisionDescriptor(backup, revisionDescriptor);
- content.store(sToken, revisionDescriptors.getUri(), revisionDescriptor,
null);
- }
-
- /**
* Restores specific live properties of the given
<code>revisionDescriptor</code>
* from the hidden 0.0 revision of the NodeRevisionDescriptors of the VCR.
*
@@ -1509,73 +1475,21 @@
NodeRevisionDescriptor backupNrd =
content.retrieve(sToken, rNrds, NodeRevisionNumber.HIDDEN_0_0);
- rNrd.setProperty( backupNrd.getProperty(P_AUTO_VERSION) );
- rNrd.setProperty( backupNrd.getProperty(P_OWNER) );
- rNrd.setProperty( backupNrd.getProperty(P_COMMENT) );
-
- content.store(sToken, rNrds.getUri(), rNrd, null);
- }
-
- /**
- * Returns a clone of the given <code>revisionDescriptor</code> with
- * the given <code>revisionNumber</code>.
- *
- * @param revisionDescriptor the NodeRevisionDescriptor to clone.
- * @param revisionNumber the NodeRevsionNumber to use for the clone.
- *
- * @return the cloned NodeRevisionDescriptor.
- */
- private NodeRevisionDescriptor cloneRevisionDescriptor(NodeRevisionDescriptor
revisionDescriptor, NodeRevisionNumber revisionNumber) {
-
- String branchName = revisionDescriptor.getBranchName();
- Enumeration labelEnum = revisionDescriptor.enumerateLabels();
- Vector labels = new Vector();
- while (labelEnum.hasMoreElements()) {
- labels.add(labelEnum.nextElement());
- }
- Hashtable properties = new Hashtable();
- Enumeration propertiesEnum = revisionDescriptor.enumerateProperties();
- NodeProperty property = null;
- String name = null;
- String namespace = null;
- while (propertiesEnum.hasMoreElements()) {
- property = (NodeProperty)propertiesEnum.nextElement();
- name = property.getName();
- namespace = property.getNamespace();
- if (namespace != null) {
- name = namespace + name;
- }
- properties.put(name, property);
- }
- NodeRevisionDescriptor backup = new NodeRevisionDescriptor(revisionNumber,
branchName, labels, properties);
- return backup;
- }
-
- /**
- * Copies the labels and properties of the given <code>source</code>
- * to the <code>destination</code> NodeRevisionDescriptor.
- *
- * @param source the NodeRevisionDescriptor to copy the labels
- * and properties from.
- * @param destination the NodeRevisionDescriptor to copy the labels
- * and properties to.
- */
- private void copyRevisionDescriptor(NodeRevisionDescriptor source,
NodeRevisionDescriptor destination) {
+ NodeProperty p;
- destination.removeLabels();
- Enumeration labelEnum = source.enumerateLabels();
- while (labelEnum.hasMoreElements()) {
- destination.addLabel((String)labelEnum.nextElement());
- }
+ p = backupNrd.getProperty( P_AUTO_VERSION );
+ if( p != null )
+ rNrd.setProperty( p );
+
+ p = backupNrd.getProperty( P_OWNER );
+ if( p != null )
+ rNrd.setProperty( p );
+
+ p = backupNrd.getProperty( P_COMMENT );
+ if( p != null )
+ rNrd.setProperty( p );
- Enumeration propertiesEnum = destination.enumerateProperties();
- while (propertiesEnum.hasMoreElements()) {
- destination.removeProperty((NodeProperty)propertiesEnum.nextElement());
- }
- propertiesEnum = source.enumerateProperties();
- while (propertiesEnum.hasMoreElements()) {
- destination.setProperty((NodeProperty)propertiesEnum.nextElement());
- }
+ content.store(sToken, rNrds.getUri(), rNrd, null);
}
/**
@@ -2013,7 +1927,6 @@
}
return uri.toString();
}
-
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>