Hello!

I just started using svnkit and things are working smoothly.

I did have one issue that came up, and that is that I am attempting to add
some String properties
and they come back as binary..

I'm using the low level interface since that works best for my particular
needs.  Here's the code I'm using:

In one method I do this:
       HashMap<String, String> newProperties = new HashMap<String, String>
();
       newProperties.put("Accesscode", "DONP");
       newProperties.put("Note", "1234, 2345");
       newProperties.put("SCR", "2345");

I then pass newProperties to another method that does this:

       ISVNEditor editor = repository.getCommitEditor(msg, null);
       editor.openRoot(-1);
       editor.openDir(dirPath, -1);
       editor.openFile(filePath, -1);
       editor.applyTextDelta(filePath, null);
       SVNDeltaGenerator deltaGenerator = new SVNDeltaGenerator();
       String checksum = deltaGenerator.sendDelta(filePath
              ,new ByteArrayInputStream(oldData)
              ,0
              ,new ByteArrayInputStream(newData)
              ,editor
              ,true
              );

       /*
        * Now do any new properties.
        */
       if (newProperties != null) {
          Iterator<String> iterator = newProperties.keySet ().iterator ();
          while (iterator.hasNext ()) {
             String propertyName = iterator.next ();
             String propertyValueStr = newProperties.get (propertyName);
             SVNPropertyValue propertyValue = SVNPropertyValue.create
(propertyValueStr);
             System.out.println ("File property: " + propertyName + "=" +
propertyValue
                   + ", isString " + propertyValue.isString()
                   );
             editor.changeFileProperty (filePath, propertyName,
propertyValue);
          }
       }

       editor.closeFile(filePath, checksum);
       // Close the directory.
       editor.closeDir();
       // Close the root directory.
       editor.closeDir();
       return editor.closeEdit();

I then call my printProperties method to check my results:

   private static void printProperties () throws SVNException {
      System.out.println("-> printProperties");
      ByteArrayOutputStream existingStream = new ByteArrayOutputStream ();
      Map<String, SVNPropertyValue> newProperties = new HashMap<String,
SVNPropertyValue>();
      SVNProperties props = new SVNProperties ();
      repository.getFile(filePath
                        ,-1
                        ,props
                        ,existingStream
                        );
      newProperties = props.asMap();
      if (newProperties != null) {
         Iterator<String> iterator = newProperties.keySet ().iterator ();
         while (iterator.hasNext ()) {
            String propertyName = iterator.next ();
            SVNPropertyValue propertyValue = (SVNPropertyValue)
newProperties.get(propertyName);
            System.out.println( "File property: " + propertyName + "=" +
propertyValue
                  + ", isString " + propertyValue.isString()
                  );
         }
      }
      System.out.println("<- printProperties");
   } // printProperties

Here is my trace out:

File property: Accesscode=DONP, isString true
File property: SCR=2345, isString true
File property: Note=1234, 2345, isString true
-> printProperties
File property: Accesscode=property is binary, isString false
File property: svn:entry:uuid=5d85c6ed-626b-2d4c-8abd-8f48f83f7eeb,
isString true
File property: Note=property is binary, isString false
File property: SCR=property is binary, isString false
File property: svn:entry:revision=10, isString true
File property: svn:entry:committed-date=2012-09-10T11:59:50.088155Z,
isString true
File property: svn:entry:checksum=09848a8f1a278ee0b4f8b62096b2da6a,
isString true
File property: svn:entry:last-author=donp, isString true
File property: svn:entry:committed-rev=10, isString true
<- printProperties

Notice that the Accesscode, Note and SCR (my properties) are "isString
true" on the way in, and false after.

Any ideas?

Thanks.
Don Payette
FSS19 Production Management
Contractor for the GSA FAME Program
2345 Crystal Dr. Suite 250, Rm 208A.
(w) 703-236-3523
(c) 571-305-0105
(h) 479-437-3084 - telework Monday and Wednesday
Internal only extension 7706

Reply via email to