subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hwri...@apache.org
Subject svn commit: r917842 - in /subversion/trunk/subversion/bindings/javahl: native/ src/org/apache/subversion/javahl/ src/org/tigris/subversion/javahl/ tests/org/apache/subversion/javahl/
Date Tue, 02 Mar 2010 02:41:39 GMT
Author: hwright
Date: Tue Mar  2 02:41:39 2010
New Revision: 917842

URL: http://svn.apache.org/viewvc?rev=917842&view=rev
Log:
JavaHL: Completely remove the PropertyData class from the new package, and
move the constants previously defined therein to the Property class.

* tests/org/apache/subversion/javahl/SVNAdminTests.java
  (testSetRevProp): Update test to reflect the new API for pulling back
    revprops.

* tests/org/apache/subversion/javahl/BasicTests.java
  (testBasicProperties): Use the Map in place of the PropertyData array.
  (testBasicLocking): Update the constant class name.
  (collectProperties): Update for the lack of PropertyData.

* native/CreateJ.cpp,
  native/CreateJ.h
  (Property): Remove.

* native/SVNClient.h,
  native/SVNClient.cpp
  (revProperties): Return the created property Map object.

* native/org_apache_subversion_javahl_SVNClient.cpp
  (Java_org_apache_subversion_javahl_SVNClient_revProperties):
    Update return type.
 
* src/org/tigris/subversion/javahl/SVNClient.java
  (revProperties): Update wrapper.

* src/org/tigris/subversion/javahl/PropertyData.java:
  Remove backward compat constructor.

* src/org/apache/subversion/javahl/PropertyData.java:
  Remove.

* src/org/apache/subversion/javahl/Property.java:
  New.

* src/org/apache/subversion/javahl/SVNClient.java
  (revProperties): Update return type.

* src/org/apache/subversion/javahl/ISVNClient.java
  (revProperties): Same.

Added:
    subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/Property.java
      - copied, changed from r917772, subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/PropertyData.java
Removed:
    subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/PropertyData.java
Modified:
    subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp
    subversion/trunk/subversion/bindings/javahl/native/CreateJ.h
    subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp
    subversion/trunk/subversion/bindings/javahl/native/SVNClient.h
    subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp
    subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNClient.java
    subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java
    subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/PropertyData.java
    subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/SVNClient.java
    subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java
    subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNAdminTests.java

Modified: subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp?rev=917842&r1=917841&r2=917842&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp Tue Mar  2 02:41:39 2010
@@ -353,64 +353,6 @@
     return jlock;
 }
 
-jobject
-CreateJ::Property(jobject jthis, const char *path, const char *name,
-                  svn_string_t *value)
-{
-    JNIEnv *env = JNIUtil::getEnv();
-    jclass clazz = env->FindClass(JAVA_PACKAGE"/PropertyData");
-    if (JNIUtil::isJavaExceptionThrown())
-        return NULL;
-
-    static jmethodID mid = 0;
-    if (mid == 0)
-    {
-        mid = env->GetMethodID(clazz, "<init>",
-                               "(L"JAVA_PACKAGE"/ISVNClient;"
-                               "Ljava/lang/String;Ljava/lang/String;"
-                               "Ljava/lang/String;[B)V");
-        if (JNIUtil::isJavaExceptionThrown())
-            return NULL;
-    }
-
-    jstring jPath = JNIUtil::makeJString(path);
-    if (JNIUtil::isJavaExceptionThrown())
-        return NULL;
-    jstring jName = JNIUtil::makeJString(name);
-    if (JNIUtil::isJavaExceptionThrown())
-        return NULL;
-    jstring jValue = JNIUtil::makeJString(value->data);
-    if (JNIUtil::isJavaExceptionThrown())
-        return NULL;
-    jbyteArray jData = JNIUtil::makeJByteArray((const signed char *)value->data,
-                                               value->len);
-    if (JNIUtil::isJavaExceptionThrown())
-        return NULL;
-
-    jobject jprop = env->NewObject(clazz, mid, jthis, jPath, jName, jValue,
-                                  jData);
-    if (JNIUtil::isJavaExceptionThrown())
-        return NULL;
-
-    env->DeleteLocalRef(clazz);
-    if (JNIUtil::isJavaExceptionThrown())
-        return NULL;
-    env->DeleteLocalRef(jPath);
-    if (JNIUtil::isJavaExceptionThrown())
-        return NULL;
-    env->DeleteLocalRef(jName);
-    if (JNIUtil::isJavaExceptionThrown())
-        return NULL;
-    env->DeleteLocalRef(jValue);
-    if (JNIUtil::isJavaExceptionThrown())
-        return NULL;
-    env->DeleteLocalRef(jData);
-    if (JNIUtil::isJavaExceptionThrown())
-        return NULL;
-
-    return jprop;
-}
-
 
 jobjectArray
 CreateJ::RevisionRangeArray(apr_array_header_t *ranges)

Modified: subversion/trunk/subversion/bindings/javahl/native/CreateJ.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/CreateJ.h?rev=917842&r1=917841&r2=917842&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/CreateJ.h (original)
+++ subversion/trunk/subversion/bindings/javahl/native/CreateJ.h Tue Mar  2 02:41:39 2010
@@ -47,10 +47,6 @@
   static jobject
   Lock(const svn_lock_t *lock);
 
-  static jobject
-  Property(jobject jthis, const char *path, const char *name,
-           svn_string_t *value);
-
   static jobjectArray
   RevisionRangeArray(apr_array_header_t *ranges);
 

Modified: subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp?rev=917842&r1=917841&r2=917842&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp Tue Mar  2 02:41:39 2010
@@ -1885,8 +1885,8 @@
     SVN_JNI_ERR(svn_client_upgrade(path, ctx, requestPool.pool()), );
 }
 
-jobjectArray SVNClient::revProperties(jobject jthis, const char *path,
-                                      Revision &revision)
+jobject SVNClient::revProperties(jobject jthis, const char *path,
+                                 Revision &revision)
 {
     apr_hash_t *props;
     SVN::Pool requestPool;
@@ -1909,45 +1909,7 @@
                                         &set_rev, ctx, requestPool.pool()),
                 NULL);
 
-    apr_hash_index_t *hi;
-
-    int count = apr_hash_count(props);
-
-    JNIEnv *env = JNIUtil::getEnv();
-    jclass clazz = env->FindClass(JAVA_PACKAGE"/PropertyData");
-    if (JNIUtil::isJavaExceptionThrown())
-        return NULL;
-
-    jobjectArray jprops = env->NewObjectArray(count, clazz, NULL);
-    if (JNIUtil::isJavaExceptionThrown())
-        return NULL;
-
-    env->DeleteLocalRef(clazz);
-    if (JNIUtil::isJavaExceptionThrown())
-        return NULL;
-
-    int i = 0;
-    for (hi = apr_hash_first(requestPool.pool(), props);
-         hi;
-         hi = apr_hash_next(hi), ++i)
-    {
-        const char *key;
-        svn_string_t *val;
-
-        apr_hash_this(hi, (const void **)&key, NULL, (void**)&val);
-
-        jobject object = CreateJ::Property(jthis, path, key, val);
-
-        env->SetObjectArrayElement(jprops, i, object);
-        if (JNIUtil::isJavaExceptionThrown())
-            return NULL;
-
-        env->DeleteLocalRef(object);
-        if (JNIUtil::isJavaExceptionThrown())
-            return NULL;
-    }
-
-    return jprops;
+    return ProplistCallback::makeMapFromHash(props, requestPool.pool());
 }
 
 struct info_baton

Modified: subversion/trunk/subversion/bindings/javahl/native/SVNClient.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/SVNClient.h?rev=917842&r1=917841&r2=917842&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/SVNClient.h (original)
+++ subversion/trunk/subversion/bindings/javahl/native/SVNClient.h Tue Mar  2 02:41:39 2010
@@ -65,8 +65,7 @@
              InfoCallback *callback);
   void unlock(Targets &targets, bool force);
   void lock(Targets &targets, const char *comment, bool force);
-  jobjectArray revProperties(jobject jthis, const char *path,
-                             Revision &revision);
+  jobject revProperties(jobject jthis, const char *path, Revision &revision);
   void cancelOperation();
   void commitMessageHandler(CommitMessage *commitMessage);
   const char *getConfigDirectory();

Modified: subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp?rev=917842&r1=917841&r2=917842&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp
(original)
+++ subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp
Tue Mar  2 02:41:39 2010
@@ -1046,7 +1046,7 @@
   return cl->revProperty(jthis, path, name, revision);
 }
 
-JNIEXPORT jobjectArray JNICALL
+JNIEXPORT jobject JNICALL
 Java_org_apache_subversion_javahl_SVNClient_revProperties
 (JNIEnv *env, jobject jthis, jstring jpath, jobject jrevision)
 {

Modified: subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNClient.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNClient.java?rev=917842&r1=917841&r2=917842&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNClient.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNClient.java
Tue Mar  2 02:41:39 2010
@@ -731,7 +731,7 @@
      * @throws ClientException
      * @since 1.2
      */
-    PropertyData[] revProperties(String path, Revision rev)
+    Map<String, byte[]> revProperties(String path, Revision rev)
             throws ClientException;
 
     /**

Copied: subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/Property.java
(from r917772, subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/PropertyData.java)
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/Property.java?p2=subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/Property.java&p1=subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/PropertyData.java&r1=917772&r2=917842&rev=917842&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/PropertyData.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/Property.java
Tue Mar  2 02:41:39 2010
@@ -24,37 +24,11 @@
 package org.apache.subversion.javahl;
 
 /**
- * This class describes one property managed by Subversion.
+ * This class describes standard Subversion known properties
  */
-public class PropertyData
+public class Property
 {
     /**
-     * the name of the property
-     */
-    private String name;
-
-    /**
-     * the string value of the property
-     */
-    private String value;
-
-    /**
-     * the byte array value of the property
-     */
-    private byte[] data;
-
-    /**
-     * path of the subversion to change or delete this property
-     */
-    private String path;
-
-    /**
-     * reference to the creating ISVNClient object to change or delete this
-     * property
-     */
-    private ISVNClient client;
-
-    /**
      * Standard subversion known properties
      */
 
@@ -119,117 +93,4 @@
      * flag property if a lock is needed to modify this node
      */
     public static final String NEEDS_LOCK = "svn:needs-lock";
-
-    /**
-     * this constructor is only used by the JNI code
-     * @param cl    the client object, which created this object
-     * @param p     the path of the item owning this property
-     * @param n     the name of the property
-     * @param v     the string value of the property
-     * @param d     the byte array value of the property
-     */
-    PropertyData(ISVNClient cl, String p, String n, String v, byte[] d)
-    {
-        path = p;
-        name = n;
-        value = v;
-        client = cl;
-        data = d;
-    }
-
-    /**
-     * this contructor is used when building a thin wrapper around other
-     * property retrieval methods
-     * @param p     the path of the item owning this property
-     * @param n     the name of the property
-     * @param v     the string value of the property
-     */
-    PropertyData(String p, String n, String v)
-    {
-        path = p;
-        name = n;
-        value = v;
-        client = null;
-        data = v.getBytes();
-    }
-
-    /**
-     * Returns the name of the property
-     * @return the name
-     */
-    public String getName()
-    {
-        return name;
-    }
-
-    /**
-     * Returns the string value of the property.
-     * There is no protocol if a property is a string or a binary value
-     * @return the string value
-     */
-    public String getValue()
-    {
-        return value;
-    }
-
-    /**
-     * Return the path of the item which owns this property
-     * @return the path
-     */
-    public String getPath()
-    {
-        return path;
-    }
-
-    /**
-     * Returns the byte array value of the property
-     * There is no protocol if a property is a string or a binary value
-     * @return the byte array value
-     */
-    public byte[] getData()
-    {
-        return data;
-    }
-
-    /**
-     * modify the string value of a property
-     * The byte array value is cleared
-     * @param newValue          the new string value
-     * @param recurse           if operation should recurse directories
-     * @throws ClientException
-     */
-    public void setValue(String newValue, boolean recurse)
-            throws ClientException
-    {
-        client.propertySet(path, name, newValue, Depth.infinityOrEmpty(recurse),
-                           null, false, null);
-        value = newValue;
-        data = null;
-    }
-
-    /**
-     * modify the byte array value of a property
-     * The string array value is cleared
-     * @param newValue          the new byte array value
-     * @param recurse           if operation should recurse directories
-     * @throws ClientException
-     */
-    public void setValue(byte[] newValue, boolean recurse)
-            throws ClientException
-    {
-        client.propertySet(path, name, new String(newValue),
-                           Depth.infinityOrEmpty(recurse), null, false, null);
-        data = newValue;
-        value = null;
-    }
-
-    /**
-     * remove this property from subversion
-     * @param recurse           if operation should recurse directories
-     * @throws ClientException
-     */
-    public void remove(boolean recurse) throws ClientException
-    {
-        client.propertyRemove(path, name, Depth.infinityOrEmpty(recurse), null);
-    }
 }

Modified: subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java?rev=917842&r1=917841&r2=917842&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java
Tue Mar  2 02:41:39 2010
@@ -653,7 +653,7 @@
     /**
      * @since 1.2
      */
-    public native PropertyData[] revProperties(String path, Revision rev)
+    public native Map<String, byte[]> revProperties(String path, Revision rev)
             throws ClientException;
 
     /**

Modified: subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/PropertyData.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/PropertyData.java?rev=917842&r1=917841&r2=917842&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/PropertyData.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/PropertyData.java
Tue Mar  2 02:41:39 2010
@@ -154,15 +154,6 @@
     }
 
     /**
-     * this constructor is used for backward compat
-     */
-    PropertyData(org.apache.subversion.javahl.PropertyData aPropertyData)
-    {
-        this(aPropertyData.getPath(), aPropertyData.getName(),
-             aPropertyData.getValue());
-    }
-
-    /**
      * Returns the name of the property
      * @return the name
      */

Modified: subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/SVNClient.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/SVNClient.java?rev=917842&r1=917841&r2=917842&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/SVNClient.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/SVNClient.java
Tue Mar  2 02:41:39 2010
@@ -1929,14 +1929,17 @@
     {
         try
         {
-            org.apache.subversion.javahl.PropertyData[] aPropData =
+            Map<String, byte[]> aProps =
                               aSVNClient.revProperties(path,
                                           rev == null ? null : rev.toApache());
-            PropertyData[] propData = new PropertyData[aPropData.length];
+            PropertyData[] propData = new PropertyData[aProps.size()];
 
-            for (int i = 0; i < aPropData.length; i++)
+            int i = 0;
+            for (String key : aProps.keySet())
             {
-                propData[i] = new PropertyData(aPropData[i]);
+                propData[i] = new PropertyData(path, key,
+                                               new String(aProps.get(key)));
+                i++;
             }
 
             return propData;

Modified: subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java?rev=917842&r1=917841&r2=917842&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java
Tue Mar  2 02:41:39 2010
@@ -745,12 +745,10 @@
 
         client.propertySet(itemPath, "abc", "def", Depth.empty, null, false,
                 null);
-        PropertyData[] properties = collectProperties(itemPath, null, null,
-                                        Depth.empty, null);
+        Map<String, byte[]> properties = collectProperties(itemPath, null,
+                                                    null, Depth.empty, null);
 
-        PropertyData prop = properties[0];
-        assertEquals("abc", prop.getName());
-        assertEquals("def", prop.getValue());
+        assertEquals("def", new String(properties.get("abc")));
 
         wc.setItemPropStatus("iota", Status.Kind.modified);
         thisTest.checkStatus();
@@ -2166,7 +2164,7 @@
         muPathSet.add(thisTest.getWCPath()+"/A/mu");
 
         client.propertySet(thisTest.getWCPath()+"/A/mu",
-                           PropertyData.NEEDS_LOCK, "*", Depth.empty,
+                           Property.NEEDS_LOCK, "*", Depth.empty,
                            null, false, null);
 
         addExpectedCommitItem(thisTest.getWCPath(),
@@ -3642,7 +3640,8 @@
         }
     }
 
-    private PropertyData[] collectProperties(String path, Revision revision,
+    private Map<String, byte[]> collectProperties(String path,
+                                             Revision revision,
                                              Revision pegRevision, int depth,
                                              Collection<String> changelists)
         throws ClientException
@@ -3667,20 +3666,7 @@
         client.properties(path, revision, revision, depth, changelists,
                 callback);
 
-        Map<String, byte[]> propMap = callback.getProperties(path);
-        if (propMap == null)
-            return new PropertyData[0];
-        PropertyData[] props = new PropertyData[propMap.size()];
-
-        int i = 0;
-        for (String key : propMap.keySet())
-        {
-            props[i] = new PropertyData(path, key,
-                                        new String(propMap.get(key)));
-            i++;
-        }
-
-        return props;
+        return callback.getProperties(path);
     }
 
     private DirEntry[] collectDirEntries(String url, Revision revision,

Modified: subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNAdminTests.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNAdminTests.java?rev=917842&r1=917841&r2=917842&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNAdminTests.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNAdminTests.java
Tue Mar  2 02:41:39 2010
@@ -26,6 +26,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.util.Map;
 
 /**
  * This class is used for testing the SVNAdmin class
@@ -61,19 +62,11 @@
         final String MSG = "Initial repository creation";
         admin.setRevProp(thisTest.getRepositoryPath(), Revision.getInstance(0),
                          "svn:log", MSG, false, false);
-        PropertyData[] pdata = client.revProperties(
+        Map<String, byte[]> pdata = client.revProperties(
                                       makeReposUrl(thisTest.getRepository()),
                                       Revision.getInstance(0));
         assertNotNull("expect non null rev props");
-        String logMessage = null;
-        for (int i = 0; i < pdata.length; i++)
-        {
-            if ("svn:log".equals(pdata[i].getName()))
-            {
-                logMessage = pdata[i].getValue();
-                break;
-            }
-        }
+        String logMessage = new String(pdata.get("svn:log"));
         assertEquals("expect rev prop change to take effect", MSG, logMessage);
     }
     public void testLoadRepo()



Mime
View raw message