subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1492940 - in /subversion/branches/javahl-ra/subversion/bindings/javahl: native/ tests/org/apache/subversion/javahl/
Date Fri, 14 Jun 2013 03:02:55 GMT
Author: brane
Date: Fri Jun 14 03:02:54 2013
New Revision: 1492940

URL: http://svn.apache.org/r1492940
Log:
On the javahl_ra branch:
Implement the SVNClient.openRemoteSession factory method.

[in subversion/bindings/javahl/native]
* OperationContext.h, OperationContext.cpp
  (OperationContext::getSelf, OperationContext::getUsername,
   OperationContext::getPassword, OperationContext::getPrompter):
   Add accessor methods for the configuration parameters so that
   the native code can use them directly.

* SVNClient.h, SVNClient.cpp (SVNClient::openRemoteSession): New.
* org_apache_subversion_javahl_SVNClient.cpp
  (Java_org_apache_subversion_javahl_SVNClient_openRemoteSession):
   Implement native wrapper.

* RemoteSession.cpp (RemoteSession::open): Check returned pointer.
* org_apache_subversion_javahl_remote_RemoteFactory.cpp
  (Java_org_apache_subversion_javahl_remote_RemoteFactory_open):
   Do not delete the session object on failure; RemoteSession::open does that.

[in subversion/bindings/javahl/tests/org/apache/subversion/javahl]
* SVNRemoteTests.java (SVNRemoteTests.testGetUrl_viaSVNClient):
   Add a test case for SVNClient.openRemoteSession.

Modified:
    subversion/branches/javahl-ra/subversion/bindings/javahl/native/OperationContext.cpp
    subversion/branches/javahl-ra/subversion/bindings/javahl/native/OperationContext.h
    subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.cpp
    subversion/branches/javahl-ra/subversion/bindings/javahl/native/SVNClient.cpp
    subversion/branches/javahl-ra/subversion/bindings/javahl/native/SVNClient.h
    subversion/branches/javahl-ra/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp
    subversion/branches/javahl-ra/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteFactory.cpp
    subversion/branches/javahl-ra/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java

Modified: subversion/branches/javahl-ra/subversion/bindings/javahl/native/OperationContext.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/bindings/javahl/native/OperationContext.cpp?rev=1492940&r1=1492939&r2=1492940&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/bindings/javahl/native/OperationContext.cpp (original)
+++ subversion/branches/javahl-ra/subversion/bindings/javahl/native/OperationContext.cpp Fri
Jun 14 03:02:54 2013
@@ -213,6 +213,14 @@ OperationContext::getAuthBaton(SVN::Pool
   return ab;
 }
 
+jobject OperationContext::getSelf() const
+{
+  jobject jctx = JNIUtil::getEnv()->NewGlobalRef(m_jctx);
+  if (JNIUtil::isJavaExceptionThrown())
+    return NULL;
+  return jctx;
+}
+
 void
 OperationContext::username(const char *pi_username)
 {
@@ -248,7 +256,24 @@ OperationContext::setConfigDirectory(con
 const char *
 OperationContext::getConfigDirectory() const
 {
-  return m_configDir.c_str();
+  return (m_configDir.empty() ? NULL : m_configDir.c_str());
+}
+
+const char *
+OperationContext::getUsername() const
+{
+  return (m_userName.empty() ? NULL : m_userName.c_str());
+}
+
+const char *
+OperationContext::getPassword() const
+{
+  return (m_passWord.empty() ? NULL : m_passWord.c_str());
+}
+
+const Prompter& OperationContext::getPrompter() const
+{
+  return *m_prompter;
 }
 
 void

Modified: subversion/branches/javahl-ra/subversion/bindings/javahl/native/OperationContext.h
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/bindings/javahl/native/OperationContext.h?rev=1492940&r1=1492939&r2=1492940&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/bindings/javahl/native/OperationContext.h (original)
+++ subversion/branches/javahl-ra/subversion/bindings/javahl/native/OperationContext.h Fri
Jun 14 03:02:54 2013
@@ -74,7 +74,11 @@ class OperationContext
   void cancelOperation();
   void resetCancelRequest();
   virtual bool isCancelledOperation();
+  jobject getSelf() const;
   const char *getConfigDirectory() const;
+  const char *getUsername() const;
+  const char *getPassword() const;
+  const Prompter& getPrompter() const;
 
   /**
    * Set the configuration directory, taking the usual steps to

Modified: subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.cpp?rev=1492940&r1=1492939&r2=1492940&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.cpp (original)
+++ subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.cpp Fri
Jun 14 03:02:54 2013
@@ -92,7 +92,7 @@ RemoteSession::open(jobject* jthis_out, 
   RemoteSession* session = new RemoteSession(
       jthis_out, url, uuid, configDirectory,
       usernameStr, passwordStr, prompter, jprogress);
-  if (JNIUtil::isJavaExceptionThrown())
+  if (JNIUtil::isJavaExceptionThrown() || !session)
     {
       delete session;
       delete prompter;

Modified: subversion/branches/javahl-ra/subversion/bindings/javahl/native/SVNClient.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/bindings/javahl/native/SVNClient.cpp?rev=1492940&r1=1492939&r2=1492940&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/bindings/javahl/native/SVNClient.cpp (original)
+++ subversion/branches/javahl-ra/subversion/bindings/javahl/native/SVNClient.cpp Fri Jun
14 03:02:54 2013
@@ -30,6 +30,7 @@
 #include "DiffSummaryReceiver.h"
 #include "ClientContext.h"
 #include "Prompter.h"
+#include "RemoteSession.h"
 #include "Pool.h"
 #include "Targets.h"
 #include "Revision.h"
@@ -1525,6 +1526,67 @@ SVNClient::patch(const char *patchPath, 
                                  ctx, subPool.getPool()), );
 }
 
+jobject
+SVNClient::openRemoteSession(const char* path)
+{
+    static const svn_opt_revision_t HEAD = { svn_opt_revision_head, {0}};
+    static const svn_opt_revision_t NONE = { svn_opt_revision_unspecified, {0}};
+
+    SVN_JNI_NULL_PTR_EX(path, "path", NULL);
+
+    SVN::Pool subPool(pool);
+    svn_client_ctx_t *ctx = context.getContext(NULL, subPool);
+    if (ctx == NULL)
+        return NULL;
+
+    Path checkedPath(path, subPool);
+    SVN_JNI_ERR(checkedPath.error_occurred(), NULL);
+
+    struct PathInfo
+    {
+        const char *url;
+        const char *uuid;
+        static svn_error_t *callback(void *baton,
+                                     const char *,
+                                     const svn_client_info2_t *info,
+                                     apr_pool_t *)
+          {
+              PathInfo* const pi = static_cast<PathInfo*>(baton);
+              pi->url = info->URL;
+              pi->uuid = info->repos_UUID;
+              return SVN_NO_ERROR;
+          }
+    } path_info;
+
+    SVN_JNI_ERR(svn_client_info3(
+                    checkedPath.c_str(), &NONE,
+                    (svn_path_is_url(checkedPath.c_str()) ? &HEAD : &NONE),
+                    svn_depth_empty, FALSE, TRUE, NULL,
+                    PathInfo::callback, &path_info,
+                    ctx, subPool.getPool()), NULL);
+
+    jobject jctx = context.getSelf();
+    if (JNIUtil::isJavaExceptionThrown())
+        return NULL;
+
+    Prompter* prompter = new Prompter(context.getPrompter());
+    jobject jremoteSession = NULL;
+    RemoteSession* session = new RemoteSession(
+        &jremoteSession, path_info.url, path_info.uuid,
+        context.getConfigDirectory(),
+        context.getUsername(), context.getPassword(),
+        prompter, jctx);
+    if (JNIUtil::isJavaExceptionThrown() || !session)
+    {
+        JNIUtil::getEnv()->DeleteGlobalRef(jctx);
+        jremoteSession = NULL;
+        delete session;
+        delete prompter;
+    }
+
+    return jremoteSession;
+}
+
 ClientContext &
 SVNClient::getClientContext()
 {

Modified: subversion/branches/javahl-ra/subversion/bindings/javahl/native/SVNClient.h
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/bindings/javahl/native/SVNClient.h?rev=1492940&r1=1492939&r2=1492940&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/bindings/javahl/native/SVNClient.h (original)
+++ subversion/branches/javahl-ra/subversion/bindings/javahl/native/SVNClient.h Fri Jun 14
03:02:54 2013
@@ -62,6 +62,7 @@ class DiffOptions;
 class SVNClient :public SVNBase
 {
  public:
+  jobject openRemoteSession(const char* path);
   void patch(const char *patchPath, const char *targetPath, bool dryRun,
              int stripCount, bool reverse, bool ignoreWhitespace,
              bool removeTempfiles, PatchCallback *callback);

Modified: subversion/branches/javahl-ra/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp?rev=1492940&r1=1492939&r2=1492940&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp
(original)
+++ subversion/branches/javahl-ra/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp
Fri Jun 14 03:02:54 2013
@@ -1864,11 +1864,9 @@ Java_org_apache_subversion_javahl_SVNCli
       return NULL;
     }
 
-  // TODO: convert path to URL
-  JNIStringHolder url(jpath);
+  JNIStringHolder path(jpath);
   if (JNIUtil::isJavaExceptionThrown())
     return NULL;
 
-  //return cl->openRemoteSession(url);
-  return NULL;
+  return cl->openRemoteSession(path);
 }

Modified: subversion/branches/javahl-ra/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteFactory.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteFactory.cpp?rev=1492940&r1=1492939&r2=1492940&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteFactory.cpp
(original)
+++ subversion/branches/javahl-ra/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteFactory.cpp
Fri Jun 14 03:02:54 2013
@@ -53,10 +53,7 @@ Java_org_apache_subversion_javahl_remote
       &jremoteSession, jurl, juuid, jconfigDirectory,
       jusername, jpassword, jprompter, jprogress);
   if (JNIUtil::isJavaExceptionThrown() || !session)
-    {
-      delete session;
-      return NULL;
-    }
+    return NULL;
 
   return jremoteSession;
 }

Modified: subversion/branches/javahl-ra/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java?rev=1492940&r1=1492939&r2=1492940&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java
(original)
+++ subversion/branches/javahl-ra/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java
Fri Jun 14 03:02:54 2013
@@ -165,4 +165,12 @@ public class SVNRemoteTests extends SVNT
 
         assertEquals(getTestRepoUrl(), session.getUrl());
     }
+
+    public void testGetUrl_viaSVNClient() throws Exception
+    {
+        ISVNRemote session = client.openRemoteSession(getTestRepoUrl());
+
+        assertEquals(getTestRepoUrl(), session.getUrl());
+    }
+
 }



Mime
View raw message