~ubuntu-branches/ubuntu/trusty/subversion/trusty-proposed

« back to all changes in this revision

Viewing changes to subversion/bindings/javahl/native/CreateJ.cpp

  • Committer: Package Import Robot
  • Author(s): Andy Whitcroft
  • Date: 2012-06-21 15:36:36 UTC
  • mfrom: (0.4.13 sid)
  • Revision ID: package-import@ubuntu.com-20120621153636-amqqmuidgwgxz1ly
Tags: 1.7.5-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - Create pot file on build.
  - Build a python-subversion-dbg package.
  - Build-depend on python-dbg.
  - Build-depend on default-jre-headless/-jdk.
  - Do not apply java-build patch.
  - debian/rules: Manually create the doxygen output directory, otherwise
    we get weird build failures when running parallel builds.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
2
 * @copyright
3
3
 * ====================================================================
4
 
 * Copyright (c) 2007-2009 CollabNet.  All rights reserved.
5
 
 *
6
 
 * This software is licensed as described in the file COPYING, which
7
 
 * you should have received as part of this distribution.  The terms
8
 
 * are also available at http://subversion.tigris.org/license-1.html.
9
 
 * If newer versions of this license are posted there, you may use a
10
 
 * newer version instead, at your option.
11
 
 *
12
 
 * This software consists of voluntary contributions made by many
13
 
 * individuals.  For exact contribution history, see the revision
14
 
 * history and logs, available at http://subversion.tigris.org/.
 
4
 *    Licensed to the Apache Software Foundation (ASF) under one
 
5
 *    or more contributor license agreements.  See the NOTICE file
 
6
 *    distributed with this work for additional information
 
7
 *    regarding copyright ownership.  The ASF licenses this file
 
8
 *    to you under the Apache License, Version 2.0 (the
 
9
 *    "License"); you may not use this file except in compliance
 
10
 *    with the License.  You may obtain a copy of the License at
 
11
 *
 
12
 *      http://www.apache.org/licenses/LICENSE-2.0
 
13
 *
 
14
 *    Unless required by applicable law or agreed to in writing,
 
15
 *    software distributed under the License is distributed on an
 
16
 *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 
17
 *    KIND, either express or implied.  See the License for the
 
18
 *    specific language governing permissions and limitations
 
19
 *    under the License.
15
20
 * ====================================================================
16
21
 * @endcopyright
17
22
 *
26
31
#include "EnumMapper.h"
27
32
#include "RevisionRange.h"
28
33
#include "CreateJ.h"
 
34
#include "../include/org_apache_subversion_javahl_types_Revision.h"
 
35
#include "../include/org_apache_subversion_javahl_CommitItemStateFlags.h"
 
36
 
 
37
#include "svn_path.h"
 
38
#include "private/svn_wc_private.h"
29
39
 
30
40
jobject
31
 
CreateJ::ConflictDescriptor(const svn_wc_conflict_description_t *desc)
 
41
CreateJ::ConflictDescriptor(const svn_wc_conflict_description2_t *desc)
32
42
{
33
43
  JNIEnv *env = JNIUtil::getEnv();
34
44
 
35
45
  if (desc == NULL)
36
46
    return NULL;
37
47
 
 
48
  // Create a local frame for our references
 
49
  env->PushLocalFrame(LOCAL_FRAME_SIZE);
 
50
  if (JNIUtil::isJavaExceptionThrown())
 
51
    return NULL;
 
52
 
38
53
  // Create an instance of the conflict descriptor.
39
 
  static jmethodID ctor = 0;
40
54
  jclass clazz = env->FindClass(JAVA_PACKAGE "/ConflictDescriptor");
41
55
  if (JNIUtil::isJavaExceptionThrown())
42
 
    return NULL;
 
56
    POP_AND_RETURN_NULL;
43
57
 
 
58
  static jmethodID ctor = 0;
44
59
  if (ctor == 0)
45
60
    {
46
 
      ctor = env->GetMethodID(clazz, "<init>", "(Ljava/lang/String;II"
47
 
                              "Ljava/lang/String;ZLjava/lang/String;III"
48
 
                              "Ljava/lang/String;Ljava/lang/String;"
49
 
                              "Ljava/lang/String;Ljava/lang/String;"
50
 
                              "L"JAVA_PACKAGE"/ConflictVersion;"
51
 
                              "L"JAVA_PACKAGE"/ConflictVersion;)V");
 
61
      ctor = env->GetMethodID(clazz, "<init>", "(Ljava/lang/String;"
 
62
                              "L"JAVA_PACKAGE"/ConflictDescriptor$Kind;"
 
63
                              "L"JAVA_PACKAGE"/types/NodeKind;"
 
64
                              "Ljava/lang/String;ZLjava/lang/String;"
 
65
                              "L"JAVA_PACKAGE"/ConflictDescriptor$Action;"
 
66
                              "L"JAVA_PACKAGE"/ConflictDescriptor$Reason;"
 
67
                              "L"JAVA_PACKAGE"/ConflictDescriptor$Operation;"
 
68
                              "Ljava/lang/String;Ljava/lang/String;"
 
69
                              "Ljava/lang/String;Ljava/lang/String;"
 
70
                              "L"JAVA_PACKAGE"/types/ConflictVersion;"
 
71
                              "L"JAVA_PACKAGE"/types/ConflictVersion;)V");
52
72
      if (JNIUtil::isJavaExceptionThrown() || ctor == 0)
53
 
        return NULL;
 
73
        POP_AND_RETURN_NULL;
54
74
    }
55
75
 
56
 
  jstring jpath = JNIUtil::makeJString(desc->path);
 
76
  jstring jpath = JNIUtil::makeJString(desc->local_abspath);
57
77
  if (JNIUtil::isJavaExceptionThrown())
58
 
    return NULL;
 
78
    POP_AND_RETURN_NULL;
59
79
  jstring jpropertyName = JNIUtil::makeJString(desc->property_name);
60
80
  if (JNIUtil::isJavaExceptionThrown())
61
 
    return NULL;
 
81
    POP_AND_RETURN_NULL;
62
82
  jstring jmimeType = JNIUtil::makeJString(desc->mime_type);
63
83
  if (JNIUtil::isJavaExceptionThrown())
64
 
    return NULL;
65
 
  jstring jbasePath = JNIUtil::makeJString(desc->base_file);
66
 
  if (JNIUtil::isJavaExceptionThrown())
67
 
    return NULL;
68
 
  jstring jreposPath = JNIUtil::makeJString(desc->their_file);
69
 
  if (JNIUtil::isJavaExceptionThrown())
70
 
    return NULL;
71
 
  jstring juserPath = JNIUtil::makeJString(desc->my_file);
72
 
  if (JNIUtil::isJavaExceptionThrown())
73
 
    return NULL;
 
84
    POP_AND_RETURN_NULL;
 
85
  jstring jbasePath = JNIUtil::makeJString(desc->base_abspath);
 
86
  if (JNIUtil::isJavaExceptionThrown())
 
87
    POP_AND_RETURN_NULL;
 
88
  jstring jreposPath = JNIUtil::makeJString(desc->their_abspath);
 
89
  if (JNIUtil::isJavaExceptionThrown())
 
90
    POP_AND_RETURN_NULL;
 
91
  jstring juserPath = JNIUtil::makeJString(desc->my_abspath);
 
92
  if (JNIUtil::isJavaExceptionThrown())
 
93
    POP_AND_RETURN_NULL;
74
94
  jstring jmergedPath = JNIUtil::makeJString(desc->merged_file);
75
95
  if (JNIUtil::isJavaExceptionThrown())
76
 
    return NULL;
 
96
    POP_AND_RETURN_NULL;
77
97
  jobject jsrcLeft = CreateJ::ConflictVersion(desc->src_left_version);
78
98
  if (JNIUtil::isJavaExceptionThrown())
79
 
    return NULL;
 
99
    POP_AND_RETURN_NULL;
80
100
  jobject jsrcRight = ConflictVersion(desc->src_right_version);
81
101
  if (JNIUtil::isJavaExceptionThrown())
82
 
    return NULL;
 
102
    POP_AND_RETURN_NULL;
 
103
  jobject jnodeKind = EnumMapper::mapNodeKind(desc->node_kind);
 
104
  if (JNIUtil::isJavaExceptionThrown())
 
105
    POP_AND_RETURN_NULL;
 
106
  jobject jconflictKind = EnumMapper::mapConflictKind(desc->kind);
 
107
  if (JNIUtil::isJavaExceptionThrown())
 
108
    POP_AND_RETURN_NULL;
 
109
  jobject jconflictAction = EnumMapper::mapConflictAction(desc->action);
 
110
  if (JNIUtil::isJavaExceptionThrown())
 
111
    POP_AND_RETURN_NULL;
 
112
  jobject jconflictReason = EnumMapper::mapConflictReason(desc->reason);
 
113
  if (JNIUtil::isJavaExceptionThrown())
 
114
    POP_AND_RETURN_NULL;
 
115
  jobject joperation = EnumMapper::mapOperation(desc->operation);
 
116
  if (JNIUtil::isJavaExceptionThrown())
 
117
    POP_AND_RETURN_NULL;
83
118
 
84
119
  // Instantiate the conflict descriptor.
85
 
  jobject jdesc = env->NewObject(clazz, ctor, jpath,
86
 
                                 EnumMapper::mapConflictKind(desc->kind),
87
 
                                 EnumMapper::mapNodeKind(desc->node_kind),
88
 
                                 jpropertyName,
 
120
  jobject jdesc = env->NewObject(clazz, ctor, jpath, jconflictKind,
 
121
                                 jnodeKind, jpropertyName,
89
122
                                 (jboolean) desc->is_binary, jmimeType,
90
 
                                 EnumMapper::mapConflictAction(desc->action),
91
 
                                 EnumMapper::mapConflictReason(desc->reason),
92
 
                                 EnumMapper::mapOperation(desc->operation),
 
123
                                 jconflictAction, jconflictReason, joperation,
93
124
                                 jbasePath, jreposPath, juserPath,
94
125
                                 jmergedPath, jsrcLeft, jsrcRight);
95
126
  if (JNIUtil::isJavaExceptionThrown())
96
 
    return NULL;
97
 
 
98
 
  env->DeleteLocalRef(clazz);
99
 
  if (JNIUtil::isJavaExceptionThrown())
100
 
    return NULL;
101
 
 
102
 
  env->DeleteLocalRef(jpath);
103
 
  if (JNIUtil::isJavaExceptionThrown())
104
 
    return NULL;
105
 
  env->DeleteLocalRef(jpropertyName);
106
 
  if (JNIUtil::isJavaExceptionThrown())
107
 
    return NULL;
108
 
  env->DeleteLocalRef(jmimeType);
109
 
  if (JNIUtil::isJavaExceptionThrown())
110
 
    return NULL;
111
 
  env->DeleteLocalRef(jbasePath);
112
 
  if (JNIUtil::isJavaExceptionThrown())
113
 
    return NULL;
114
 
  env->DeleteLocalRef(jreposPath);
115
 
  if (JNIUtil::isJavaExceptionThrown())
116
 
    return NULL;
117
 
  env->DeleteLocalRef(juserPath);
118
 
  if (JNIUtil::isJavaExceptionThrown())
119
 
    return NULL;
120
 
  env->DeleteLocalRef(jmergedPath);
121
 
  if (JNIUtil::isJavaExceptionThrown())
122
 
    return NULL;
123
 
  env->DeleteLocalRef(jsrcRight);
124
 
  if (JNIUtil::isJavaExceptionThrown())
125
 
    return NULL;
126
 
  env->DeleteLocalRef(jsrcLeft);
127
 
  if (JNIUtil::isJavaExceptionThrown())
128
 
    return NULL;
129
 
 
130
 
  return jdesc;
 
127
    POP_AND_RETURN_NULL;
 
128
 
 
129
  return env->PopLocalFrame(jdesc);
131
130
}
132
131
 
133
132
jobject
138
137
  if (version == NULL)
139
138
    return NULL;
140
139
 
 
140
  // Create a local frame for our references
 
141
  env->PushLocalFrame(LOCAL_FRAME_SIZE);
 
142
  if (JNIUtil::isJavaExceptionThrown())
 
143
    return NULL;
 
144
 
141
145
  // Create an instance of the conflict version.
142
 
  static jmethodID ctor = 0;
143
 
  jclass clazz = env->FindClass(JAVA_PACKAGE "/ConflictVersion");
 
146
  jclass clazz = env->FindClass(JAVA_PACKAGE "/types/ConflictVersion");
144
147
  if (JNIUtil::isJavaExceptionThrown())
145
 
    return NULL;
 
148
    POP_AND_RETURN_NULL;
146
149
 
 
150
  static jmethodID ctor = 0;
147
151
  if (ctor == 0)
148
152
    {
149
153
      ctor = env->GetMethodID(clazz, "<init>", "(Ljava/lang/String;J"
150
 
                                               "Ljava/lang/String;I)V");
 
154
                                               "Ljava/lang/String;"
 
155
                                               "L"JAVA_PACKAGE"/types/NodeKind;"
 
156
                                               ")V");
151
157
      if (JNIUtil::isJavaExceptionThrown() || ctor == 0)
152
 
        return NULL;
 
158
        POP_AND_RETURN_NULL;
153
159
    }
154
160
 
155
161
  jstring jreposURL = JNIUtil::makeJString(version->repos_url);
156
162
  if (JNIUtil::isJavaExceptionThrown())
157
 
    return NULL;
 
163
    POP_AND_RETURN_NULL;
158
164
  jstring jpathInRepos = JNIUtil::makeJString(version->path_in_repos);
159
165
  if (JNIUtil::isJavaExceptionThrown())
160
 
    return NULL;
 
166
    POP_AND_RETURN_NULL;
 
167
  jobject jnodeKind = EnumMapper::mapNodeKind(version->node_kind);
 
168
  if (JNIUtil::isJavaExceptionThrown())
 
169
    POP_AND_RETURN_NULL;
161
170
 
162
171
  jobject jversion = env->NewObject(clazz, ctor, jreposURL,
163
 
                                 (jlong)version->peg_rev, jpathInRepos,
164
 
                                 EnumMapper::mapNodeKind(version->node_kind));
165
 
  if (JNIUtil::isJavaExceptionThrown())
166
 
    return NULL;
167
 
 
168
 
  env->DeleteLocalRef(clazz);
169
 
  if (JNIUtil::isJavaExceptionThrown())
170
 
    return NULL;
171
 
 
172
 
  env->DeleteLocalRef(jreposURL);
173
 
  if (JNIUtil::isJavaExceptionThrown())
174
 
    return NULL;
175
 
  env->DeleteLocalRef(jpathInRepos);
176
 
  if (JNIUtil::isJavaExceptionThrown())
177
 
    return NULL;
178
 
 
179
 
  return jversion;
180
 
}
181
 
 
182
 
jobject
183
 
CreateJ::Info(const svn_wc_entry_t *entry)
184
 
{
185
 
    if (entry == NULL)
186
 
        return NULL;
187
 
 
188
 
    JNIEnv *env = JNIUtil::getEnv();
189
 
 
190
 
    jclass clazz = env->FindClass(JAVA_PACKAGE"/Info");
191
 
    if (JNIUtil::isJavaExceptionThrown())
192
 
        return NULL;
193
 
 
194
 
    static jmethodID mid = 0;
195
 
    if (mid == 0)
196
 
    {
197
 
        mid = env->GetMethodID(clazz, "<init>",
198
 
                               "(Ljava/lang/String;Ljava/lang/String;"
 
172
                                    (jlong)version->peg_rev, jpathInRepos,
 
173
                                    jnodeKind);
 
174
  if (JNIUtil::isJavaExceptionThrown())
 
175
    POP_AND_RETURN_NULL;
 
176
 
 
177
  return env->PopLocalFrame(jversion);
 
178
}
 
179
 
 
180
jobject
 
181
CreateJ::Checksum(const svn_checksum_t *checksum)
 
182
{
 
183
  if (!checksum)
 
184
    return NULL;
 
185
 
 
186
  JNIEnv *env = JNIUtil::getEnv();
 
187
 
 
188
  // Create a local frame for our references
 
189
  env->PushLocalFrame(LOCAL_FRAME_SIZE);
 
190
  if (JNIUtil::isJavaExceptionThrown())
 
191
    return NULL;
 
192
 
 
193
  jclass clazz = env->FindClass(JAVA_PACKAGE"/types/Checksum");
 
194
  if (JNIUtil::isExceptionThrown())
 
195
    POP_AND_RETURN_NULL;
 
196
 
 
197
  // Get the method id for the CommitItem constructor.
 
198
  static jmethodID midConstructor = 0;
 
199
  if (midConstructor == 0)
 
200
    {
 
201
      midConstructor = env->GetMethodID(clazz, "<init>",
 
202
                                        "([B"
 
203
                                        "L"JAVA_PACKAGE"/types/Checksum$Kind;"
 
204
                                        ")V");
 
205
      if (JNIUtil::isExceptionThrown())
 
206
        POP_AND_RETURN_NULL;
 
207
    }
 
208
 
 
209
  jbyteArray jdigest = JNIUtil::makeJByteArray(
 
210
                            (const signed char *)checksum->digest,
 
211
                            svn_checksum_size(checksum));
 
212
  if (JNIUtil::isExceptionThrown())
 
213
    POP_AND_RETURN_NULL;
 
214
 
 
215
  jobject jkind = EnumMapper::mapChecksumKind(checksum->kind);
 
216
  if (JNIUtil::isExceptionThrown())
 
217
    POP_AND_RETURN_NULL;
 
218
 
 
219
  // create the Java object
 
220
  jobject jchecksum = env->NewObject(clazz, midConstructor, jdigest, jkind);
 
221
  if (JNIUtil::isExceptionThrown())
 
222
    POP_AND_RETURN_NULL;
 
223
 
 
224
  return env->PopLocalFrame(jchecksum);
 
225
}
 
226
 
 
227
jobject
 
228
CreateJ::Info(const char *path, const svn_client_info2_t *info)
 
229
{
 
230
  JNIEnv *env = JNIUtil::getEnv();
 
231
 
 
232
  // Create a local frame for our references
 
233
  env->PushLocalFrame(LOCAL_FRAME_SIZE);
 
234
  if (JNIUtil::isJavaExceptionThrown())
 
235
    return NULL;
 
236
 
 
237
  jclass clazz = env->FindClass(JAVA_PACKAGE "/types/Info");
 
238
  if (JNIUtil::isJavaExceptionThrown())
 
239
    POP_AND_RETURN_NULL;
 
240
 
 
241
  static jmethodID mid = 0;
 
242
  if (mid == 0)
 
243
    {
 
244
      mid = env->GetMethodID(clazz, "<init>",
 
245
                             "(Ljava/lang/String;Ljava/lang/String;"
 
246
                             "Ljava/lang/String;J"
 
247
                             "L"JAVA_PACKAGE"/types/NodeKind;"
 
248
                             "Ljava/lang/String;Ljava/lang/String;"
 
249
                             "JJLjava/lang/String;"
 
250
                             "L"JAVA_PACKAGE"/types/Lock;Z"
 
251
                             "L"JAVA_PACKAGE"/types/Info$ScheduleKind;"
 
252
                             "Ljava/lang/String;JJ"
 
253
                             "L"JAVA_PACKAGE"/types/Checksum;"
 
254
                             "Ljava/lang/String;JJ"
 
255
                             "L"JAVA_PACKAGE"/types/Depth;Ljava/util/Set;)V");
 
256
      if (mid == 0 || JNIUtil::isJavaExceptionThrown())
 
257
        POP_AND_RETURN_NULL;
 
258
    }
 
259
 
 
260
  jstring jpath = JNIUtil::makeJString(path);
 
261
  if (JNIUtil::isJavaExceptionThrown())
 
262
    POP_AND_RETURN_NULL;
 
263
 
 
264
  jstring jwcroot = NULL;
 
265
  jstring jcopyFromUrl = NULL;
 
266
  jobject jchecksum = NULL;
 
267
  jstring jchangelist = NULL;
 
268
  jobject jconflicts = NULL;
 
269
  jobject jscheduleKind = NULL;
 
270
  jobject jdepth = NULL;
 
271
  jlong jworkingSize = -1;
 
272
  jlong jcopyfrom_rev = -1;
 
273
  jlong jtext_time = -1;
 
274
  if (info->wc_info)
 
275
    {
 
276
      jwcroot = JNIUtil::makeJString(info->wc_info->wcroot_abspath);
 
277
      if (JNIUtil::isJavaExceptionThrown())
 
278
        POP_AND_RETURN_NULL;
 
279
 
 
280
      jcopyFromUrl = JNIUtil::makeJString(info->wc_info->copyfrom_url);
 
281
      if (JNIUtil::isJavaExceptionThrown())
 
282
        POP_AND_RETURN_NULL;
 
283
 
 
284
      jchecksum = Checksum(info->wc_info->checksum);
 
285
      if (JNIUtil::isJavaExceptionThrown())
 
286
        POP_AND_RETURN_NULL;
 
287
 
 
288
      jchangelist = JNIUtil::makeJString(info->wc_info->changelist);
 
289
      if (JNIUtil::isJavaExceptionThrown())
 
290
        POP_AND_RETURN_NULL;
 
291
 
 
292
      jscheduleKind = EnumMapper::mapScheduleKind(info->wc_info->schedule);
 
293
      if (JNIUtil::isJavaExceptionThrown())
 
294
        POP_AND_RETURN_NULL;
 
295
 
 
296
      jdepth = EnumMapper::mapDepth(info->wc_info->depth);
 
297
      if (JNIUtil::isJavaExceptionThrown())
 
298
        POP_AND_RETURN_NULL;
 
299
 
 
300
      /* ### Maybe rename the java fields while we can */
 
301
      jworkingSize = info->wc_info->recorded_size;
 
302
      jtext_time = info->wc_info->recorded_time;
 
303
 
 
304
      jcopyfrom_rev = info->wc_info->copyfrom_rev;
 
305
 
 
306
      if (info->wc_info->conflicts && info->wc_info->conflicts->nelts > 0)
 
307
        {
 
308
          std::vector<jobject> jconflict_vec;
 
309
 
 
310
          for (int i = 0; i < info->wc_info->conflicts->nelts; i++)
 
311
            {
 
312
              const svn_wc_conflict_description2_t *conflict = APR_ARRAY_IDX(
 
313
                                info->wc_info->conflicts, i,
 
314
                                const svn_wc_conflict_description2_t *);
 
315
 
 
316
              jobject jconflict = ConflictDescriptor(conflict);
 
317
              if (JNIUtil::isJavaExceptionThrown())
 
318
                POP_AND_RETURN_NULL;
 
319
 
 
320
              jconflict_vec.push_back(jconflict);
 
321
            }
 
322
 
 
323
          jconflicts = Set(jconflict_vec);
 
324
          if (JNIUtil::isJavaExceptionThrown())
 
325
            POP_AND_RETURN_NULL;
 
326
        }
 
327
    }
 
328
 
 
329
  jstring jurl = JNIUtil::makeJString(info->URL);
 
330
  if (JNIUtil::isJavaExceptionThrown())
 
331
    POP_AND_RETURN_NULL;
 
332
 
 
333
  jstring jreposRootUrl = JNIUtil::makeJString(info->repos_root_URL);
 
334
  if (JNIUtil::isJavaExceptionThrown())
 
335
    POP_AND_RETURN_NULL;
 
336
 
 
337
  jstring jreportUUID = JNIUtil::makeJString(info->repos_UUID);
 
338
  if (JNIUtil::isJavaExceptionThrown())
 
339
    POP_AND_RETURN_NULL;
 
340
 
 
341
  jstring jlastChangedAuthor =
 
342
    JNIUtil::makeJString(info->last_changed_author);
 
343
  if (JNIUtil::isJavaExceptionThrown())
 
344
    POP_AND_RETURN_NULL;
 
345
 
 
346
  jobject jlock = CreateJ::Lock(info->lock);
 
347
  if (JNIUtil::isJavaExceptionThrown())
 
348
    POP_AND_RETURN_NULL;
 
349
 
 
350
  jobject jnodeKind = EnumMapper::mapNodeKind(info->kind);
 
351
  if (JNIUtil::isJavaExceptionThrown())
 
352
    POP_AND_RETURN_NULL;
 
353
 
 
354
  jobject jinfo2 = env->NewObject(clazz, mid, jpath, jwcroot, jurl,
 
355
                                  (jlong) info->rev,
 
356
                                  jnodeKind, jreposRootUrl, jreportUUID,
 
357
                                  (jlong) info->last_changed_rev,
 
358
                                  (jlong) info->last_changed_date,
 
359
                                  jlastChangedAuthor, jlock,
 
360
                                  info->wc_info ? JNI_TRUE : JNI_FALSE,
 
361
                                  jscheduleKind, jcopyFromUrl,
 
362
                                  jcopyfrom_rev, jtext_time, jchecksum,
 
363
                                  jchangelist, jworkingSize,
 
364
                                  (jlong) info->size, jdepth, jconflicts);
 
365
 
 
366
  return env->PopLocalFrame(jinfo2);
 
367
}
 
368
 
 
369
jobject
 
370
CreateJ::Lock(const svn_lock_t *lock)
 
371
{
 
372
  if (lock == NULL)
 
373
    return NULL;
 
374
 
 
375
  JNIEnv *env = JNIUtil::getEnv();
 
376
 
 
377
  // Create a local frame for our references
 
378
  env->PushLocalFrame(LOCAL_FRAME_SIZE);
 
379
  if (JNIUtil::isJavaExceptionThrown())
 
380
    return NULL;
 
381
 
 
382
  jclass clazz = env->FindClass(JAVA_PACKAGE"/types/Lock");
 
383
  if (JNIUtil::isJavaExceptionThrown())
 
384
    POP_AND_RETURN_NULL;
 
385
 
 
386
  static jmethodID mid = 0;
 
387
  if (mid == 0)
 
388
    {
 
389
      mid = env->GetMethodID(clazz, "<init>",
 
390
                             "(Ljava/lang/String;Ljava/lang/String;"
 
391
                             "Ljava/lang/String;"
 
392
                             "Ljava/lang/String;JJ)V");
 
393
      if (JNIUtil::isJavaExceptionThrown())
 
394
        POP_AND_RETURN_NULL;
 
395
    }
 
396
 
 
397
  jstring jOwner = JNIUtil::makeJString(lock->owner);
 
398
  if (JNIUtil::isJavaExceptionThrown())
 
399
    POP_AND_RETURN_NULL;
 
400
  jstring jPath = JNIUtil::makeJString(lock->path);
 
401
  if (JNIUtil::isJavaExceptionThrown())
 
402
    POP_AND_RETURN_NULL;
 
403
  jstring jToken = JNIUtil::makeJString(lock->token);
 
404
  if (JNIUtil::isJavaExceptionThrown())
 
405
    POP_AND_RETURN_NULL;
 
406
  jstring jComment = JNIUtil::makeJString(lock->comment);
 
407
  if (JNIUtil::isJavaExceptionThrown())
 
408
    POP_AND_RETURN_NULL;
 
409
 
 
410
  jlong jCreationDate = lock->creation_date;
 
411
  jlong jExpirationDate = lock->expiration_date;
 
412
  jobject jlock = env->NewObject(clazz, mid, jOwner, jPath, jToken, jComment,
 
413
                                 jCreationDate, jExpirationDate);
 
414
  if (JNIUtil::isJavaExceptionThrown())
 
415
    POP_AND_RETURN_NULL;
 
416
 
 
417
  return env->PopLocalFrame(jlock);
 
418
}
 
419
 
 
420
jobject
 
421
CreateJ::ChangedPath(const char *path, svn_log_changed_path2_t *log_item)
 
422
{
 
423
  JNIEnv *env = JNIUtil::getEnv();
 
424
 
 
425
  // Create a local frame for our references
 
426
  env->PushLocalFrame(LOCAL_FRAME_SIZE);
 
427
  if (JNIUtil::isJavaExceptionThrown())
 
428
    return NULL;
 
429
 
 
430
  jclass clazzCP = env->FindClass(JAVA_PACKAGE"/types/ChangePath");
 
431
  if (JNIUtil::isJavaExceptionThrown())
 
432
    POP_AND_RETURN(SVN_NO_ERROR);
 
433
 
 
434
  static jmethodID midCP = 0;
 
435
  if (midCP == 0)
 
436
    {
 
437
      midCP = env->GetMethodID(clazzCP,
 
438
                               "<init>",
 
439
                               "(Ljava/lang/String;JLjava/lang/String;"
 
440
                               "L"JAVA_PACKAGE"/types/ChangePath$Action;"
 
441
                               "L"JAVA_PACKAGE"/types/NodeKind;"
 
442
                               "L"JAVA_PACKAGE"/types/Tristate;"
 
443
                               "L"JAVA_PACKAGE"/types/Tristate;)V");
 
444
      if (JNIUtil::isJavaExceptionThrown())
 
445
        POP_AND_RETURN(SVN_NO_ERROR);
 
446
    }
 
447
 
 
448
  jstring jpath = JNIUtil::makeJString(path);
 
449
  if (JNIUtil::isJavaExceptionThrown())
 
450
    POP_AND_RETURN_NULL;
 
451
 
 
452
  jstring jcopyFromPath = JNIUtil::makeJString(log_item->copyfrom_path);
 
453
  if (JNIUtil::isJavaExceptionThrown())
 
454
    POP_AND_RETURN_NULL;
 
455
 
 
456
  jobject jaction = EnumMapper::mapChangePathAction(log_item->action);
 
457
  if (JNIUtil::isJavaExceptionThrown())
 
458
    POP_AND_RETURN_NULL;
 
459
 
 
460
  jobject jnodeKind = EnumMapper::mapNodeKind(log_item->node_kind);
 
461
  if (JNIUtil::isJavaExceptionThrown())
 
462
    POP_AND_RETURN_NULL;
 
463
 
 
464
  jlong jcopyFromRev = log_item->copyfrom_rev;
 
465
 
 
466
  jobject jcp = env->NewObject(clazzCP, midCP, jpath, jcopyFromRev,
 
467
                      jcopyFromPath, jaction, jnodeKind,
 
468
                      EnumMapper::mapTristate(log_item->text_modified),
 
469
                      EnumMapper::mapTristate(log_item->props_modified));
 
470
  if (JNIUtil::isJavaExceptionThrown())
 
471
    POP_AND_RETURN_NULL;
 
472
 
 
473
  return env->PopLocalFrame(jcp);
 
474
}
 
475
 
 
476
jobject
 
477
CreateJ::Status(svn_wc_context_t *wc_ctx,
 
478
                const svn_client_status_t *status,
 
479
                apr_pool_t *pool)
 
480
{
 
481
  if (status == NULL)
 
482
    return NULL;
 
483
 
 
484
  JNIEnv *env = JNIUtil::getEnv();
 
485
 
 
486
  // Create a local frame for our references
 
487
  env->PushLocalFrame(LOCAL_FRAME_SIZE);
 
488
  if (JNIUtil::isJavaExceptionThrown())
 
489
    return NULL;
 
490
 
 
491
  jclass clazz = env->FindClass(JAVA_PACKAGE"/types/Status");
 
492
  if (JNIUtil::isJavaExceptionThrown())
 
493
    POP_AND_RETURN_NULL;
 
494
 
 
495
  static jmethodID mid = 0;
 
496
  if (mid == 0)
 
497
    {
 
498
      mid = env->GetMethodID(clazz, "<init>",
 
499
                             "(Ljava/lang/String;Ljava/lang/String;"
 
500
                             "L"JAVA_PACKAGE"/types/NodeKind;"
 
501
                             "JJJLjava/lang/String;"
 
502
                             "L"JAVA_PACKAGE"/types/Status$Kind;"
 
503
                             "L"JAVA_PACKAGE"/types/Status$Kind;"
 
504
                             "L"JAVA_PACKAGE"/types/Status$Kind;"
 
505
                             "L"JAVA_PACKAGE"/types/Status$Kind;"
 
506
                             "ZZZZZL"JAVA_PACKAGE"/types/Lock;"
 
507
                             "L"JAVA_PACKAGE"/types/Lock;"
 
508
                             "JJL"JAVA_PACKAGE"/types/NodeKind;"
 
509
                             "Ljava/lang/String;Ljava/lang/String;)V");
 
510
      if (JNIUtil::isJavaExceptionThrown())
 
511
        POP_AND_RETURN_NULL;
 
512
    }
 
513
 
 
514
  /* ### Calculate the old style text_status value to make
 
515
     ### the tests pass. It is probably better to do this in
 
516
     ### the tigris package and then switch the apache package
 
517
     ### to three statuses. */
 
518
  jstring jUrl = NULL;
 
519
  jobject jNodeKind = NULL;
 
520
  jlong jRevision =
 
521
    org_apache_subversion_javahl_types_Revision_SVN_INVALID_REVNUM;
 
522
  jlong jLastChangedRevision =
 
523
    org_apache_subversion_javahl_types_Revision_SVN_INVALID_REVNUM;
 
524
  jlong jLastChangedDate = 0;
 
525
  jstring jLastCommitAuthor = NULL;
 
526
  jobject jLocalLock = NULL;
 
527
  jstring jChangelist = NULL;
 
528
 
 
529
  enum svn_wc_status_kind text_status = status->node_status;
 
530
 
 
531
  /* Avoid using values that might come from prop changes */
 
532
  if (text_status == svn_wc_status_modified
 
533
      || text_status == svn_wc_status_conflicted)
 
534
    text_status = status->text_status;
 
535
 
 
536
  enum svn_wc_status_kind repos_text_status = status->repos_node_status;
 
537
 
 
538
  if (repos_text_status == svn_wc_status_modified
 
539
      || repos_text_status == svn_wc_status_conflicted)
 
540
    repos_text_status = status->repos_text_status;
 
541
 
 
542
  jboolean jIsConflicted = (status->conflicted == 1) ? JNI_TRUE : JNI_FALSE;
 
543
  jobject jTextType = EnumMapper::mapStatusKind(text_status);
 
544
  jobject jPropType = EnumMapper::mapStatusKind(status->prop_status);
 
545
  jobject jRepositoryTextType = EnumMapper::mapStatusKind(repos_text_status);
 
546
  jobject jRepositoryPropType = EnumMapper::mapStatusKind(
 
547
                                                  status->repos_prop_status);
 
548
  jboolean jIsCopied = (status->copied == 1) ? JNI_TRUE: JNI_FALSE;
 
549
  jboolean jIsLocked = (status->wc_is_locked == 1) ? JNI_TRUE: JNI_FALSE;
 
550
  jboolean jIsSwitched = (status->switched == 1) ? JNI_TRUE: JNI_FALSE;
 
551
  jboolean jIsFileExternal = (status->file_external == 1) ? JNI_TRUE
 
552
                                                          : JNI_FALSE;
 
553
 
 
554
  jstring jPath = JNIUtil::makeJString(status->local_abspath);
 
555
  if (JNIUtil::isJavaExceptionThrown())
 
556
    POP_AND_RETURN_NULL;
 
557
 
 
558
  jobject jReposLock = CreateJ::Lock(status->repos_lock);
 
559
  if (JNIUtil::isJavaExceptionThrown())
 
560
    POP_AND_RETURN_NULL;
 
561
 
 
562
  if (status->repos_root_url)
 
563
    {
 
564
      jUrl = JNIUtil::makeJString(svn_path_url_add_component2(
 
565
                                    status->repos_root_url,
 
566
                                    status->repos_relpath,
 
567
                                    pool));
 
568
      if (JNIUtil::isJavaExceptionThrown())
 
569
        POP_AND_RETURN_NULL;
 
570
    }
 
571
 
 
572
  jlong jOODLastCmtRevision = status->ood_changed_rev;
 
573
  jlong jOODLastCmtDate = status->ood_changed_date;
 
574
  jobject jOODKind = EnumMapper::mapNodeKind(status->ood_kind);
 
575
  jstring jOODLastCmtAuthor = JNIUtil::makeJString(status->ood_changed_author);
 
576
  if (JNIUtil::isJavaExceptionThrown())
 
577
    POP_AND_RETURN_NULL;
 
578
 
 
579
  if (status->versioned)
 
580
    {
 
581
      jNodeKind = EnumMapper::mapNodeKind(status->kind);
 
582
      jRevision = status->revision;
 
583
      jLastChangedRevision = status->changed_rev;
 
584
      jLastChangedDate = status->changed_date;
 
585
      jLastCommitAuthor = JNIUtil::makeJString(status->changed_author);
 
586
 
 
587
      if (JNIUtil::isJavaExceptionThrown())
 
588
        POP_AND_RETURN_NULL;
 
589
 
 
590
      jLocalLock = Lock(status->lock);
 
591
      if (JNIUtil::isJavaExceptionThrown())
 
592
        POP_AND_RETURN_NULL;
 
593
 
 
594
      jChangelist = JNIUtil::makeJString(status->changelist);
 
595
      if (JNIUtil::isJavaExceptionThrown())
 
596
        POP_AND_RETURN_NULL;
 
597
    }
 
598
 
 
599
  jobject ret = env->NewObject(clazz, mid, jPath, jUrl, jNodeKind, jRevision,
 
600
                               jLastChangedRevision, jLastChangedDate,
 
601
                               jLastCommitAuthor, jTextType, jPropType,
 
602
                               jRepositoryTextType, jRepositoryPropType,
 
603
                               jIsLocked, jIsCopied, jIsConflicted,
 
604
                               jIsSwitched, jIsFileExternal, jLocalLock,
 
605
                               jReposLock,
 
606
                               jOODLastCmtRevision, jOODLastCmtDate,
 
607
                               jOODKind, jOODLastCmtAuthor, jChangelist);
 
608
 
 
609
  return env->PopLocalFrame(ret);
 
610
}
 
611
 
 
612
jobject
 
613
CreateJ::ClientNotifyInformation(const svn_wc_notify_t *wcNotify)
 
614
{
 
615
  JNIEnv *env = JNIUtil::getEnv();
 
616
 
 
617
  // Create a local frame for our references
 
618
  env->PushLocalFrame(LOCAL_FRAME_SIZE);
 
619
  if (JNIUtil::isJavaExceptionThrown())
 
620
    return NULL;
 
621
 
 
622
  static jmethodID midCT = 0;
 
623
  jclass clazz = env->FindClass(JAVA_PACKAGE"/ClientNotifyInformation");
 
624
  if (JNIUtil::isJavaExceptionThrown())
 
625
    POP_AND_RETURN_NULL;
 
626
 
 
627
  if (midCT == 0)
 
628
    {
 
629
      midCT = env->GetMethodID(clazz, "<init>",
 
630
                               "(Ljava/lang/String;"
 
631
                               "L"JAVA_PACKAGE"/ClientNotifyInformation$Action;"
 
632
                               "L"JAVA_PACKAGE"/types/NodeKind;"
 
633
                               "Ljava/lang/String;"
 
634
                               "L"JAVA_PACKAGE"/types/Lock;"
 
635
                               "Ljava/lang/String;"
 
636
                               "L"JAVA_PACKAGE"/ClientNotifyInformation$Status;"
 
637
                               "L"JAVA_PACKAGE"/ClientNotifyInformation$Status;"
 
638
                               "L"JAVA_PACKAGE"/ClientNotifyInformation$LockStatus;"
 
639
                               "JLjava/lang/String;"
 
640
                               "L"JAVA_PACKAGE"/types/RevisionRange;"
199
641
                               "Ljava/lang/String;Ljava/lang/String;"
200
 
                               "IILjava/lang/String;JJLjava/util/Date;"
201
 
                               "Ljava/util/Date;Ljava/util/Date;"
202
 
                               "ZZZZJLjava/lang/String;)V");
203
 
        if (JNIUtil::isJavaExceptionThrown())
204
 
            return NULL;
205
 
    }
206
 
 
207
 
    jstring jName = JNIUtil::makeJString(entry->name);
208
 
    if (JNIUtil::isJavaExceptionThrown())
209
 
        return NULL;
210
 
    jstring jUrl = JNIUtil::makeJString(entry->url);
211
 
    if (JNIUtil::isJavaExceptionThrown())
212
 
        return NULL;
213
 
    jstring jUuid = JNIUtil::makeJString(entry->uuid);
214
 
    if (JNIUtil::isJavaExceptionThrown())
215
 
        return NULL;
216
 
    jstring jRepository = JNIUtil::makeJString(entry->repos);
217
 
    if (JNIUtil::isJavaExceptionThrown())
218
 
        return NULL;
219
 
    jint jSchedule = EnumMapper::mapScheduleKind(entry->schedule);
220
 
    jint jNodeKind = EnumMapper::mapNodeKind(entry->kind);
221
 
    jstring jAuthor = JNIUtil::makeJString(entry->cmt_author);
222
 
    if (JNIUtil::isJavaExceptionThrown())
223
 
        return NULL;
224
 
    jlong jRevision = entry->revision;
225
 
    jlong jLastChangedRevision = entry->cmt_rev;
226
 
    jobject jLastChangedDate = JNIUtil::createDate(entry->cmt_date);
227
 
    if (JNIUtil::isJavaExceptionThrown())
228
 
        return NULL;
229
 
    jobject jLastDateTextUpdate = JNIUtil::createDate(entry->text_time);
230
 
    if (JNIUtil::isJavaExceptionThrown())
231
 
        return NULL;
232
 
    jobject jLastDatePropsUpdate = JNIUtil::createDate(entry->prop_time);
233
 
    if (JNIUtil::isJavaExceptionThrown())
234
 
        return NULL;
235
 
    jboolean jCopied = entry->copied ? JNI_TRUE : JNI_FALSE;
236
 
    jboolean jDeleted = entry->deleted ? JNI_TRUE : JNI_FALSE;
237
 
    jboolean jAbsent = entry->absent ? JNI_TRUE : JNI_FALSE;
238
 
    jboolean jIncomplete = entry->incomplete ? JNI_TRUE : JNI_FALSE;
239
 
    jlong jCopyRev = entry->copyfrom_rev;
240
 
    jstring jCopyUrl = JNIUtil::makeJString(entry->copyfrom_url);
241
 
    if (JNIUtil::isJavaExceptionThrown())
242
 
        return NULL;
243
 
 
244
 
    jobject jinfo = env->NewObject(clazz, mid, jName, jUrl, jUuid, jRepository,
245
 
                                   jSchedule, jNodeKind, jAuthor, jRevision,
246
 
                                   jLastChangedRevision, jLastChangedDate,
247
 
                                   jLastDateTextUpdate, jLastDatePropsUpdate,
248
 
                                   jCopied, jDeleted, jAbsent, jIncomplete,
249
 
                                   jCopyRev, jCopyUrl);
250
 
    if (JNIUtil::isJavaExceptionThrown())
251
 
        return NULL;
252
 
 
253
 
    env->DeleteLocalRef(clazz);
254
 
    if (JNIUtil::isJavaExceptionThrown())
255
 
        return NULL;
256
 
 
257
 
    env->DeleteLocalRef(jName);
258
 
    if (JNIUtil::isJavaExceptionThrown())
259
 
        return NULL;
260
 
    env->DeleteLocalRef(jUrl);
261
 
    if (JNIUtil::isJavaExceptionThrown())
262
 
        return NULL;
263
 
    env->DeleteLocalRef(jUuid);
264
 
    if (JNIUtil::isJavaExceptionThrown())
265
 
        return NULL;
266
 
    env->DeleteLocalRef(jRepository);
267
 
    if (JNIUtil::isJavaExceptionThrown())
268
 
        return NULL;
269
 
    env->DeleteLocalRef(jAuthor);
270
 
    if (JNIUtil::isJavaExceptionThrown())
271
 
        return NULL;
272
 
    env->DeleteLocalRef(jLastChangedDate);
273
 
    if (JNIUtil::isJavaExceptionThrown())
274
 
        return NULL;
275
 
    env->DeleteLocalRef(jLastDateTextUpdate);
276
 
    if (JNIUtil::isJavaExceptionThrown())
277
 
        return NULL;
278
 
    env->DeleteLocalRef(jLastDatePropsUpdate);
279
 
    if (JNIUtil::isJavaExceptionThrown())
280
 
        return NULL;
281
 
    env->DeleteLocalRef(jCopyUrl);
282
 
    if (JNIUtil::isJavaExceptionThrown())
283
 
        return NULL;
284
 
 
285
 
    return jinfo;
286
 
}
287
 
 
288
 
 
289
 
jobject
290
 
CreateJ::Lock(const svn_lock_t *lock)
291
 
{
292
 
    if (lock == NULL)
293
 
        return NULL;
294
 
    JNIEnv *env = JNIUtil::getEnv();
295
 
 
296
 
    jclass clazz = env->FindClass(JAVA_PACKAGE"/Lock");
297
 
    if (JNIUtil::isJavaExceptionThrown())
298
 
        return NULL;
299
 
 
300
 
    static jmethodID mid = 0;
301
 
    if (mid == 0)
302
 
    {
303
 
        mid = env->GetMethodID(clazz, "<init>",
304
 
                               "(Ljava/lang/String;Ljava/lang/String;"
305
 
                               "Ljava/lang/String;"
306
 
                               "Ljava/lang/String;JJ)V");
307
 
        if (JNIUtil::isJavaExceptionThrown())
308
 
            return NULL;
309
 
    }
310
 
 
311
 
    jstring jOwner = JNIUtil::makeJString(lock->owner);
312
 
    if (JNIUtil::isJavaExceptionThrown())
313
 
        return NULL;
314
 
    jstring jPath = JNIUtil::makeJString(lock->path);
315
 
    if (JNIUtil::isJavaExceptionThrown())
316
 
        return NULL;
317
 
    jstring jToken = JNIUtil::makeJString(lock->token);
318
 
    if (JNIUtil::isJavaExceptionThrown())
319
 
        return NULL;
320
 
    jstring jComment = JNIUtil::makeJString(lock->comment);
321
 
    if (JNIUtil::isJavaExceptionThrown())
322
 
        return NULL;
323
 
 
324
 
    jlong jCreationDate = lock->creation_date;
325
 
    jlong jExpirationDate = lock->expiration_date;
326
 
    jobject jlock = env->NewObject(clazz, mid, jOwner, jPath, jToken, jComment,
327
 
                                   jCreationDate, jExpirationDate);
328
 
    if (JNIUtil::isJavaExceptionThrown())
329
 
        return NULL;
330
 
 
331
 
    env->DeleteLocalRef(clazz);
332
 
    if (JNIUtil::isJavaExceptionThrown())
333
 
        return NULL;
334
 
 
335
 
    env->DeleteLocalRef(jOwner);
336
 
    if (JNIUtil::isJavaExceptionThrown())
337
 
        return NULL;
338
 
    env->DeleteLocalRef(jPath);
339
 
    if (JNIUtil::isJavaExceptionThrown())
340
 
        return NULL;
341
 
    env->DeleteLocalRef(jToken);
342
 
    if (JNIUtil::isJavaExceptionThrown())
343
 
        return NULL;
344
 
    env->DeleteLocalRef(jComment);
345
 
    if (JNIUtil::isJavaExceptionThrown())
346
 
        return NULL;
347
 
 
348
 
    return jlock;
349
 
}
350
 
 
351
 
jobject
352
 
CreateJ::Property(jobject jthis, const char *path, const char *name,
353
 
                  svn_string_t *value)
354
 
{
355
 
    JNIEnv *env = JNIUtil::getEnv();
356
 
    jclass clazz = env->FindClass(JAVA_PACKAGE"/PropertyData");
357
 
    if (JNIUtil::isJavaExceptionThrown())
358
 
        return NULL;
359
 
 
360
 
    static jmethodID mid = 0;
361
 
    if (mid == 0)
362
 
    {
363
 
        mid = env->GetMethodID(clazz, "<init>",
364
 
                               "(L"JAVA_PACKAGE"/SVNClient;Ljava/lang/String;"
365
 
                               "Ljava/lang/String;Ljava/lang/String;[B)V");
366
 
        if (JNIUtil::isJavaExceptionThrown())
367
 
            return NULL;
368
 
    }
369
 
 
370
 
    jstring jPath = JNIUtil::makeJString(path);
371
 
    if (JNIUtil::isJavaExceptionThrown())
372
 
        return NULL;
373
 
    jstring jName = JNIUtil::makeJString(name);
374
 
    if (JNIUtil::isJavaExceptionThrown())
375
 
        return NULL;
376
 
    jstring jValue = JNIUtil::makeJString(value->data);
377
 
    if (JNIUtil::isJavaExceptionThrown())
378
 
        return NULL;
379
 
    jbyteArray jData = JNIUtil::makeJByteArray((const signed char *)value->data,
380
 
                                               value->len);
381
 
    if (JNIUtil::isJavaExceptionThrown())
382
 
        return NULL;
383
 
 
384
 
    jobject jprop = env->NewObject(clazz, mid, jthis, jPath, jName, jValue,
385
 
                                  jData);
386
 
    if (JNIUtil::isJavaExceptionThrown())
387
 
        return NULL;
388
 
 
389
 
    env->DeleteLocalRef(clazz);
390
 
    if (JNIUtil::isJavaExceptionThrown())
391
 
        return NULL;
392
 
    env->DeleteLocalRef(jPath);
393
 
    if (JNIUtil::isJavaExceptionThrown())
394
 
        return NULL;
395
 
    env->DeleteLocalRef(jName);
396
 
    if (JNIUtil::isJavaExceptionThrown())
397
 
        return NULL;
398
 
    env->DeleteLocalRef(jValue);
399
 
    if (JNIUtil::isJavaExceptionThrown())
400
 
        return NULL;
401
 
    env->DeleteLocalRef(jData);
402
 
    if (JNIUtil::isJavaExceptionThrown())
403
 
        return NULL;
404
 
 
405
 
    return jprop;
406
 
}
407
 
 
408
 
 
409
 
jobjectArray
410
 
CreateJ::RevisionRangeArray(apr_array_header_t *ranges)
411
 
{
412
 
    JNIEnv *env = JNIUtil::getEnv();
413
 
 
414
 
    jclass clazz = env->FindClass(JAVA_PACKAGE "/RevisionRange");
415
 
    if (JNIUtil::isJavaExceptionThrown())
416
 
        return NULL;
417
 
 
418
 
    jobjectArray jranges = env->NewObjectArray(ranges->nelts, clazz, NULL);
419
 
 
420
 
    for (int i = 0; i < ranges->nelts; ++i)
421
 
    {
422
 
        // Convert svn_merge_range_t *'s to Java RevisionRange objects.
423
 
        svn_merge_range_t *range =
424
 
            APR_ARRAY_IDX(ranges, i, svn_merge_range_t *);
425
 
        jobject jrange = RevisionRange::makeJRevisionRange(range);
426
 
        if (jrange == NULL)
427
 
            return NULL;
428
 
 
429
 
        env->SetObjectArrayElement(jranges, i, jrange);
430
 
        if (JNIUtil::isJavaExceptionThrown())
431
 
            return NULL;
432
 
 
433
 
        env->DeleteLocalRef(jrange);
434
 
        if (JNIUtil::isJavaExceptionThrown())
435
 
            return NULL;
436
 
    }
437
 
 
438
 
    return jranges;
 
642
                               "Ljava/util/Map;JJJJJJI)V");
 
643
      if (JNIUtil::isJavaExceptionThrown() || midCT == 0)
 
644
        POP_AND_RETURN_NULL;
 
645
    }
 
646
 
 
647
  // convert the parameter to their Java relatives
 
648
  jstring jPath = JNIUtil::makeJString(wcNotify->path);
 
649
  if (JNIUtil::isJavaExceptionThrown())
 
650
    POP_AND_RETURN_NULL;
 
651
 
 
652
  jobject jAction = EnumMapper::mapNotifyAction(wcNotify->action);
 
653
  if (JNIUtil::isJavaExceptionThrown())
 
654
    POP_AND_RETURN_NULL;
 
655
 
 
656
  jobject jKind = EnumMapper::mapNodeKind(wcNotify->kind);
 
657
  if (JNIUtil::isJavaExceptionThrown())
 
658
    POP_AND_RETURN_NULL;
 
659
 
 
660
  jstring jMimeType = JNIUtil::makeJString(wcNotify->mime_type);
 
661
  if (JNIUtil::isJavaExceptionThrown())
 
662
    POP_AND_RETURN_NULL;
 
663
 
 
664
  jobject jLock = CreateJ::Lock(wcNotify->lock);
 
665
  if (JNIUtil::isJavaExceptionThrown())
 
666
    POP_AND_RETURN_NULL;
 
667
 
 
668
  jstring jErr = JNIUtil::makeSVNErrorMessage(wcNotify->err);
 
669
  if (JNIUtil::isJavaExceptionThrown())
 
670
    POP_AND_RETURN_NULL;
 
671
 
 
672
  jobject jContentState = EnumMapper::mapNotifyState(wcNotify->content_state);
 
673
  if (JNIUtil::isJavaExceptionThrown())
 
674
    POP_AND_RETURN_NULL;
 
675
 
 
676
  jobject jPropState = EnumMapper::mapNotifyState(wcNotify->prop_state);
 
677
  if (JNIUtil::isJavaExceptionThrown())
 
678
    POP_AND_RETURN_NULL;
 
679
 
 
680
  jobject jLockState = EnumMapper::mapNotifyLockState(wcNotify->lock_state);
 
681
  if (JNIUtil::isJavaExceptionThrown())
 
682
    POP_AND_RETURN_NULL;
 
683
 
 
684
  jstring jChangelistName = JNIUtil::makeJString(wcNotify->changelist_name);
 
685
  if (JNIUtil::isJavaExceptionThrown())
 
686
    POP_AND_RETURN_NULL;
 
687
 
 
688
  jobject jMergeRange = NULL;
 
689
  if (wcNotify->merge_range)
 
690
    {
 
691
      jMergeRange = RevisionRange::makeJRevisionRange(wcNotify->merge_range);
 
692
      if (jMergeRange == NULL)
 
693
        POP_AND_RETURN_NULL;
 
694
    }
 
695
 
 
696
  jstring jpathPrefix = JNIUtil::makeJString(wcNotify->path_prefix);
 
697
  if (JNIUtil::isJavaExceptionThrown())
 
698
    POP_AND_RETURN_NULL;
 
699
 
 
700
  jstring jpropName = JNIUtil::makeJString(wcNotify->prop_name);
 
701
  if (JNIUtil::isJavaExceptionThrown())
 
702
    POP_AND_RETURN_NULL;
 
703
 
 
704
  jobject jrevProps = CreateJ::PropertyMap(wcNotify->rev_props);
 
705
  if (JNIUtil::isJavaExceptionThrown())
 
706
    POP_AND_RETURN_NULL;
 
707
 
 
708
  jlong joldRevision = wcNotify->old_revision;
 
709
  jlong jhunkOriginalStart = wcNotify->hunk_original_start;
 
710
  jlong jhunkOriginalLength = wcNotify->hunk_original_length;
 
711
  jlong jhunkModifiedStart = wcNotify->hunk_modified_start;
 
712
  jlong jhunkModifiedLength = wcNotify->hunk_modified_length;
 
713
  jlong jhunkMatchedLine = wcNotify->hunk_matched_line;
 
714
  jint jhunkFuzz = wcNotify->hunk_fuzz;
 
715
 
 
716
  // call the Java method
 
717
  jobject jInfo = env->NewObject(clazz, midCT, jPath, jAction,
 
718
                                 jKind, jMimeType, jLock, jErr,
 
719
                                 jContentState, jPropState, jLockState,
 
720
                                 (jlong) wcNotify->revision, jChangelistName,
 
721
                                 jMergeRange, jpathPrefix, jpropName,
 
722
                                 jrevProps, joldRevision,
 
723
                                 jhunkOriginalStart, jhunkOriginalLength,
 
724
                                 jhunkModifiedStart, jhunkModifiedLength,
 
725
                                 jhunkMatchedLine, jhunkFuzz);
 
726
  if (JNIUtil::isJavaExceptionThrown())
 
727
    POP_AND_RETURN_NULL;
 
728
 
 
729
  return env->PopLocalFrame(jInfo);
 
730
}
 
731
 
 
732
jobject
 
733
CreateJ::ReposNotifyInformation(const svn_repos_notify_t *reposNotify)
 
734
{
 
735
  JNIEnv *env = JNIUtil::getEnv();
 
736
 
 
737
  // Create a local frame for our references
 
738
  env->PushLocalFrame(LOCAL_FRAME_SIZE);
 
739
  if (JNIUtil::isJavaExceptionThrown())
 
740
    return NULL;
 
741
 
 
742
  static jmethodID midCT = 0;
 
743
  jclass clazz = env->FindClass(JAVA_PACKAGE"/ReposNotifyInformation");
 
744
  if (JNIUtil::isJavaExceptionThrown())
 
745
    POP_AND_RETURN_NULL;
 
746
 
 
747
  if (midCT == 0)
 
748
    {
 
749
      midCT = env->GetMethodID(clazz, "<init>",
 
750
                               "(L"JAVA_PACKAGE"/ReposNotifyInformation$Action;"
 
751
                               "JLjava/lang/String;JJJ"
 
752
                               "L"JAVA_PACKAGE"/ReposNotifyInformation$NodeAction;"
 
753
                               "Ljava/lang/String;)V");
 
754
      if (JNIUtil::isJavaExceptionThrown() || midCT == 0)
 
755
        POP_AND_RETURN_NULL;
 
756
    }
 
757
 
 
758
  // convert the parameters to their Java relatives
 
759
  jobject jAction = EnumMapper::mapReposNotifyAction(reposNotify->action);
 
760
  if (JNIUtil::isJavaExceptionThrown())
 
761
    POP_AND_RETURN_NULL;
 
762
 
 
763
  jstring jWarning = JNIUtil::makeJString(reposNotify->warning_str);
 
764
  if (JNIUtil::isJavaExceptionThrown())
 
765
    POP_AND_RETURN_NULL;
 
766
 
 
767
  jlong jRevision = (jlong)reposNotify->revision;
 
768
  jlong jShard = (jlong)reposNotify->shard;
 
769
  jlong jnewRevision = (jlong)reposNotify->new_revision;
 
770
  jlong joldRevision = (jlong)reposNotify->old_revision;
 
771
 
 
772
  jobject jnodeAction = EnumMapper::mapReposNotifyNodeAction(
 
773
                                                    reposNotify->node_action);
 
774
  if (JNIUtil::isJavaExceptionThrown())
 
775
    POP_AND_RETURN_NULL;
 
776
 
 
777
  jstring jpath = JNIUtil::makeJString(reposNotify->path);
 
778
  if (JNIUtil::isJavaExceptionThrown())
 
779
    POP_AND_RETURN_NULL;
 
780
 
 
781
  // call the Java method
 
782
  jobject jInfo = env->NewObject(clazz, midCT, jAction, jRevision, jWarning,
 
783
                                 jShard, jnewRevision, joldRevision,
 
784
                                 jnodeAction, jpath);
 
785
  if (JNIUtil::isJavaExceptionThrown())
 
786
    POP_AND_RETURN_NULL;
 
787
 
 
788
  return env->PopLocalFrame(jInfo);
 
789
}
 
790
 
 
791
jobject
 
792
CreateJ::CommitItem(svn_client_commit_item3_t *item)
 
793
{
 
794
  JNIEnv *env = JNIUtil::getEnv();
 
795
 
 
796
  // Create a local frame for our references
 
797
  env->PushLocalFrame(LOCAL_FRAME_SIZE);
 
798
  if (JNIUtil::isJavaExceptionThrown())
 
799
    return NULL;
 
800
 
 
801
  jclass clazz = env->FindClass(JAVA_PACKAGE"/CommitItem");
 
802
  if (JNIUtil::isExceptionThrown())
 
803
    POP_AND_RETURN_NULL;
 
804
 
 
805
  // Get the method id for the CommitItem constructor.
 
806
  static jmethodID midConstructor = 0;
 
807
  if (midConstructor == 0)
 
808
    {
 
809
      midConstructor = env->GetMethodID(clazz, "<init>",
 
810
                                        "(Ljava/lang/String;"
 
811
                                        "L"JAVA_PACKAGE"/types/NodeKind;"
 
812
                                        "ILjava/lang/String;"
 
813
                                        "Ljava/lang/String;J)V");
 
814
      if (JNIUtil::isExceptionThrown())
 
815
        POP_AND_RETURN_NULL;
 
816
    }
 
817
 
 
818
  jstring jpath = JNIUtil::makeJString(item->path);
 
819
 
 
820
  jobject jnodeKind = EnumMapper::mapNodeKind(item->kind);
 
821
  if (JNIUtil::isJavaExceptionThrown())
 
822
    POP_AND_RETURN_NULL;
 
823
 
 
824
  jint jstateFlags = 0;
 
825
  if (item->state_flags & SVN_CLIENT_COMMIT_ITEM_ADD)
 
826
    jstateFlags |=
 
827
      org_apache_subversion_javahl_CommitItemStateFlags_Add;
 
828
  if (item->state_flags & SVN_CLIENT_COMMIT_ITEM_DELETE)
 
829
    jstateFlags |=
 
830
      org_apache_subversion_javahl_CommitItemStateFlags_Delete;
 
831
  if (item->state_flags & SVN_CLIENT_COMMIT_ITEM_TEXT_MODS)
 
832
    jstateFlags |=
 
833
      org_apache_subversion_javahl_CommitItemStateFlags_TextMods;
 
834
  if (item->state_flags & SVN_CLIENT_COMMIT_ITEM_PROP_MODS)
 
835
    jstateFlags |=
 
836
      org_apache_subversion_javahl_CommitItemStateFlags_PropMods;
 
837
  if (item->state_flags & SVN_CLIENT_COMMIT_ITEM_IS_COPY)
 
838
    jstateFlags |=
 
839
      org_apache_subversion_javahl_CommitItemStateFlags_IsCopy;
 
840
 
 
841
  jstring jurl = JNIUtil::makeJString(item->url);
 
842
  if (JNIUtil::isJavaExceptionThrown())
 
843
    POP_AND_RETURN_NULL;
 
844
 
 
845
  jstring jcopyUrl = JNIUtil::makeJString(item->copyfrom_url);
 
846
  if (JNIUtil::isJavaExceptionThrown())
 
847
    POP_AND_RETURN_NULL;
 
848
 
 
849
  jlong jcopyRevision = item->revision;
 
850
 
 
851
  // create the Java object
 
852
  jobject jitem = env->NewObject(clazz, midConstructor, jpath,
 
853
                                 jnodeKind, jstateFlags, jurl,
 
854
                                 jcopyUrl, jcopyRevision);
 
855
  if (JNIUtil::isJavaExceptionThrown())
 
856
    POP_AND_RETURN_NULL;
 
857
 
 
858
  return env->PopLocalFrame(jitem);
 
859
}
 
860
 
 
861
jobject
 
862
CreateJ::CommitInfo(const svn_commit_info_t *commit_info)
 
863
{
 
864
  JNIEnv *env = JNIUtil::getEnv();
 
865
 
 
866
  // Create a local frame for our references
 
867
  env->PushLocalFrame(LOCAL_FRAME_SIZE);
 
868
  if (JNIUtil::isJavaExceptionThrown())
 
869
    return NULL;
 
870
 
 
871
  static jmethodID midCT = 0;
 
872
  jclass clazz = env->FindClass(JAVA_PACKAGE"/CommitInfo");
 
873
  if (JNIUtil::isJavaExceptionThrown())
 
874
    POP_AND_RETURN_NULL;
 
875
 
 
876
  if (midCT == 0)
 
877
    {
 
878
      midCT = env->GetMethodID(clazz, "<init>",
 
879
                               "(JLjava/lang/String;Ljava/lang/String;"
 
880
                               "Ljava/lang/String;Ljava/lang/String;)V");
 
881
      if (JNIUtil::isJavaExceptionThrown() || midCT == 0)
 
882
        POP_AND_RETURN_NULL;
 
883
    }
 
884
 
 
885
  jstring jAuthor = JNIUtil::makeJString(commit_info->author);
 
886
  if (JNIUtil::isJavaExceptionThrown())
 
887
    POP_AND_RETURN_NULL;
 
888
 
 
889
  jstring jDate = JNIUtil::makeJString(commit_info->date);
 
890
  if (JNIUtil::isJavaExceptionThrown())
 
891
    POP_AND_RETURN_NULL;
 
892
 
 
893
  jlong jRevision = commit_info->revision;
 
894
 
 
895
  jstring jPostCommitError = JNIUtil::makeJString(
 
896
                                            commit_info->post_commit_err);
 
897
  if (JNIUtil::isJavaExceptionThrown())
 
898
    POP_AND_RETURN_NULL;
 
899
 
 
900
  jstring jReposRoot = JNIUtil::makeJString(commit_info->repos_root);
 
901
  if (JNIUtil::isJavaExceptionThrown())
 
902
    POP_AND_RETURN_NULL;
 
903
 
 
904
  // call the Java method
 
905
  jobject jInfo = env->NewObject(clazz, midCT, jRevision, jDate, jAuthor,
 
906
                                 jPostCommitError, jReposRoot);
 
907
  if (JNIUtil::isJavaExceptionThrown())
 
908
    POP_AND_RETURN_NULL;
 
909
 
 
910
  return env->PopLocalFrame(jInfo);
 
911
}
 
912
 
 
913
jobject
 
914
CreateJ::RevisionRangeList(apr_array_header_t *ranges)
 
915
{
 
916
  JNIEnv *env = JNIUtil::getEnv();
 
917
 
 
918
  // Create a local frame for our references
 
919
  env->PushLocalFrame(LOCAL_FRAME_SIZE);
 
920
  if (JNIUtil::isJavaExceptionThrown())
 
921
    return NULL;
 
922
 
 
923
  jclass clazz = env->FindClass("java/util/ArrayList");
 
924
  if (JNIUtil::isJavaExceptionThrown())
 
925
    POP_AND_RETURN_NULL;
 
926
 
 
927
  static jmethodID init_mid = 0;
 
928
  if (init_mid == 0)
 
929
    {
 
930
      init_mid = env->GetMethodID(clazz, "<init>", "()V");
 
931
      if (JNIUtil::isJavaExceptionThrown())
 
932
        POP_AND_RETURN_NULL;
 
933
    }
 
934
 
 
935
  static jmethodID add_mid = 0;
 
936
  if (add_mid == 0)
 
937
    {
 
938
      add_mid = env->GetMethodID(clazz, "add", "(Ljava/lang/Object;)Z");
 
939
      if (JNIUtil::isJavaExceptionThrown())
 
940
        POP_AND_RETURN_NULL;
 
941
    }
 
942
 
 
943
  jobject jranges = env->NewObject(clazz, init_mid);
 
944
 
 
945
  for (int i = 0; i < ranges->nelts; ++i)
 
946
    {
 
947
      // Convert svn_merge_range_t *'s to Java RevisionRange objects.
 
948
      svn_merge_range_t *range =
 
949
          APR_ARRAY_IDX(ranges, i, svn_merge_range_t *);
 
950
 
 
951
      jobject jrange = RevisionRange::makeJRevisionRange(range);
 
952
      if (JNIUtil::isJavaExceptionThrown())
 
953
        POP_AND_RETURN_NULL;
 
954
 
 
955
      env->CallBooleanMethod(jranges, add_mid, jrange);
 
956
      if (JNIUtil::isJavaExceptionThrown())
 
957
        POP_AND_RETURN_NULL;
 
958
 
 
959
      env->DeleteLocalRef(jrange);
 
960
    }
 
961
 
 
962
  return env->PopLocalFrame(jranges);
 
963
}
 
964
 
 
965
jobject
 
966
CreateJ::StringSet(apr_array_header_t *strings)
 
967
{
 
968
  std::vector<jobject> jstrs;
 
969
 
 
970
  for (int i = 0; i < strings->nelts; ++i)
 
971
    {
 
972
      const char *str = APR_ARRAY_IDX(strings, i, const char *);
 
973
      jstring jstr = JNIUtil::makeJString(str);
 
974
      if (JNIUtil::isJavaExceptionThrown())
 
975
        return NULL;
 
976
 
 
977
      jstrs.push_back(jstr);
 
978
    }
 
979
 
 
980
  return CreateJ::Set(jstrs);
 
981
}
 
982
 
 
983
jobject CreateJ::PropertyMap(apr_hash_t *prop_hash)
 
984
{
 
985
  JNIEnv *env = JNIUtil::getEnv();
 
986
 
 
987
  if (prop_hash == NULL)
 
988
    return NULL;
 
989
 
 
990
  // Create a local frame for our references
 
991
  env->PushLocalFrame(LOCAL_FRAME_SIZE);
 
992
  if (JNIUtil::isJavaExceptionThrown())
 
993
    return NULL;
 
994
 
 
995
  jclass clazz = env->FindClass("java/util/HashMap");
 
996
  if (JNIUtil::isJavaExceptionThrown())
 
997
    POP_AND_RETURN_NULL;
 
998
 
 
999
  static jmethodID init_mid = 0;
 
1000
  if (init_mid == 0)
 
1001
    {
 
1002
      init_mid = env->GetMethodID(clazz, "<init>", "()V");
 
1003
      if (JNIUtil::isJavaExceptionThrown())
 
1004
        POP_AND_RETURN_NULL;
 
1005
    }
 
1006
 
 
1007
  static jmethodID put_mid = 0;
 
1008
  if (put_mid == 0)
 
1009
    {
 
1010
      put_mid = env->GetMethodID(clazz, "put",
 
1011
                                 "(Ljava/lang/Object;Ljava/lang/Object;)"
 
1012
                                 "Ljava/lang/Object;");
 
1013
      if (JNIUtil::isJavaExceptionThrown())
 
1014
        POP_AND_RETURN_NULL;
 
1015
    }
 
1016
 
 
1017
  jobject map = env->NewObject(clazz, init_mid);
 
1018
  if (JNIUtil::isJavaExceptionThrown())
 
1019
    POP_AND_RETURN_NULL;
 
1020
 
 
1021
  apr_hash_index_t *hi;
 
1022
  int i = 0;
 
1023
  for (hi = apr_hash_first(apr_hash_pool_get(prop_hash), prop_hash);
 
1024
       hi; hi = apr_hash_next(hi), ++i)
 
1025
    {
 
1026
      const char *key;
 
1027
      svn_string_t *val;
 
1028
 
 
1029
      apr_hash_this(hi, (const void **)&key, NULL, (void **)&val);
 
1030
 
 
1031
      jstring jpropName = JNIUtil::makeJString(key);
 
1032
      if (JNIUtil::isJavaExceptionThrown())
 
1033
        POP_AND_RETURN_NULL;
 
1034
 
 
1035
      jbyteArray jpropVal = JNIUtil::makeJByteArray(
 
1036
                                    (const signed char *)val->data, val->len);
 
1037
      if (JNIUtil::isJavaExceptionThrown())
 
1038
        POP_AND_RETURN_NULL;
 
1039
 
 
1040
      env->CallObjectMethod(map, put_mid, jpropName, jpropVal);
 
1041
      if (JNIUtil::isJavaExceptionThrown())
 
1042
        POP_AND_RETURN_NULL;
 
1043
 
 
1044
      env->DeleteLocalRef(jpropName);
 
1045
      env->DeleteLocalRef(jpropVal);
 
1046
    }
 
1047
 
 
1048
  return env->PopLocalFrame(map);
 
1049
}
 
1050
 
 
1051
jobject CreateJ::Set(std::vector<jobject> &objects)
 
1052
{
 
1053
  JNIEnv *env = JNIUtil::getEnv();
 
1054
 
 
1055
  // Create a local frame for our references
 
1056
  env->PushLocalFrame(LOCAL_FRAME_SIZE);
 
1057
  if (JNIUtil::isJavaExceptionThrown())
 
1058
    return NULL;
 
1059
 
 
1060
  jclass clazz = env->FindClass("java/util/HashSet");
 
1061
  if (JNIUtil::isJavaExceptionThrown())
 
1062
    POP_AND_RETURN_NULL;
 
1063
 
 
1064
  static jmethodID init_mid = 0;
 
1065
  if (init_mid == 0)
 
1066
    {
 
1067
      init_mid = env->GetMethodID(clazz, "<init>", "()V");
 
1068
      if (JNIUtil::isJavaExceptionThrown())
 
1069
        POP_AND_RETURN_NULL;
 
1070
    }
 
1071
 
 
1072
  static jmethodID add_mid = 0;
 
1073
  if (add_mid == 0)
 
1074
    {
 
1075
      add_mid = env->GetMethodID(clazz, "add", "(Ljava/lang/Object;)Z");
 
1076
      if (JNIUtil::isJavaExceptionThrown())
 
1077
        POP_AND_RETURN_NULL;
 
1078
    }
 
1079
 
 
1080
  jobject set = env->NewObject(clazz, init_mid);
 
1081
  if (JNIUtil::isJavaExceptionThrown())
 
1082
    POP_AND_RETURN_NULL;
 
1083
 
 
1084
  std::vector<jobject>::const_iterator it;
 
1085
  for (it = objects.begin(); it < objects.end(); ++it)
 
1086
    {
 
1087
      jobject jthing = *it;
 
1088
 
 
1089
      env->CallBooleanMethod(set, add_mid, jthing);
 
1090
      if (JNIUtil::isJavaExceptionThrown())
 
1091
        POP_AND_RETURN_NULL;
 
1092
 
 
1093
      env->DeleteLocalRef(jthing);
 
1094
    }
 
1095
 
 
1096
  return env->PopLocalFrame(set);
439
1097
}