~ubuntu-branches/debian/sid/subversion/sid

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): James McCoy
  • Date: 2015-08-07 21:32:47 UTC
  • mfrom: (0.2.15) (4.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20150807213247-ozyewtmgsr6tkewl
Tags: 1.9.0-1
* Upload to unstable
* New upstream release.
  + Security fixes
    - CVE-2015-3184: Mixed anonymous/authenticated path-based authz with
      httpd 2.4
    - CVE-2015-3187: svn_repos_trace_node_locations() reveals paths hidden
      by authz
* Add >= 2.7 requirement for python-all-dev Build-Depends, needed to run
  tests.
* Remove Build-Conflicts against ruby-test-unit.  (Closes: #791844)
* Remove patches/apache_module_dependency in favor of expressing the
  dependencies in authz_svn.load/dav_svn.load.
* Build-Depend on apache2-dev (>= 2.4.16) to ensure ap_some_authn_required()
  is available when building mod_authz_svn and Depend on apache2-bin (>=
  2.4.16) for runtime support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * @copyright
 
3
 * ====================================================================
 
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.
 
20
 * ====================================================================
 
21
 * @endcopyright
 
22
 *
 
23
 * @file StateReporter.cpp
 
24
 * @brief Implementation of the class StateReporter
 
25
 */
 
26
 
 
27
#include <jni.h>
 
28
 
 
29
#include "JNIUtil.h"
 
30
#include "JNIStringHolder.h"
 
31
#include "StateReporter.h"
 
32
#include "EnumMapper.h"
 
33
#include "Path.h"
 
34
 
 
35
#include "svn_private_config.h"
 
36
 
 
37
StateReporter::StateReporter()
 
38
  : m_valid(false),
 
39
    m_raw_reporter(NULL),
 
40
    m_report_baton(NULL),
 
41
    m_editor(NULL),
 
42
    m_target_revision(SVN_INVALID_REVNUM)
 
43
{}
 
44
 
 
45
StateReporter::~StateReporter()
 
46
{
 
47
  delete m_editor;
 
48
}
 
49
 
 
50
StateReporter*
 
51
StateReporter::getCppObject(jobject jthis)
 
52
{
 
53
  static jfieldID fid = 0;
 
54
  jlong cppAddr = SVNBase::findCppAddrForJObject(jthis, &fid,
 
55
      JAVAHL_CLASS("/remote/StateReporter"));
 
56
  return (cppAddr == 0 ? NULL : reinterpret_cast<StateReporter*>(cppAddr));
 
57
}
 
58
 
 
59
void
 
60
StateReporter::dispose(jobject jthis)
 
61
{
 
62
  //DEBUG:fprintf(stderr, "  (n) StateReporter::dispose()\n");
 
63
 
 
64
  if (m_valid)
 
65
    abortReport();
 
66
 
 
67
  static jfieldID fid = 0;
 
68
  SVNBase::dispose(jthis, &fid, JAVAHL_CLASS("/remote/StateReporter"));
 
69
}
 
70
 
 
71
namespace {
 
72
void throw_reporter_inactive()
 
73
{
 
74
  JNIUtil::raiseThrowable("java/lang/IllegalStateException",
 
75
                          _("The reporter is not active"));
 
76
}
 
77
} // anonymous namespace
 
78
 
 
79
void
 
80
StateReporter::setPath(jstring jpath, jlong jrevision, jobject jdepth,
 
81
                       jboolean jstart_empty, jstring jlock_token)
 
82
{
 
83
  //DEBUG:fprintf(stderr, "  (n) StateReporter::setPath()\n");
 
84
 
 
85
  if (!m_valid) { throw_reporter_inactive(); return; }
 
86
 
 
87
  JNIStringHolder lock_token(jlock_token);
 
88
  if (JNIUtil::isJavaExceptionThrown())
 
89
    return;
 
90
 
 
91
  SVN::Pool subPool(pool);
 
92
  Relpath path(jpath, subPool);
 
93
  if (JNIUtil::isJavaExceptionThrown())
 
94
    return;
 
95
  svn_depth_t depth = EnumMapper::toDepth(jdepth);
 
96
  if (JNIUtil::isJavaExceptionThrown())
 
97
    return;
 
98
 
 
99
  SVN_JNI_ERR(m_raw_reporter->set_path(m_report_baton, path.c_str(),
 
100
                                       svn_revnum_t(jrevision), depth,
 
101
                                       bool(jstart_empty), lock_token.c_str(),
 
102
                                       subPool.getPool()),);
 
103
}
 
104
 
 
105
void
 
106
StateReporter::deletePath(jstring jpath)
 
107
{
 
108
  //DEBUG:fprintf(stderr, "  (n) StateReporter::deletePath()\n");
 
109
 
 
110
  if (!m_valid) { throw_reporter_inactive(); return; }
 
111
 
 
112
  SVN::Pool subPool(pool);
 
113
  Relpath path(jpath, subPool);
 
114
  if (JNIUtil::isJavaExceptionThrown())
 
115
    return;
 
116
 
 
117
  SVN_JNI_ERR(m_raw_reporter->delete_path(m_report_baton, path.c_str(),
 
118
                                          subPool.getPool()),);
 
119
}
 
120
 
 
121
void
 
122
StateReporter::linkPath(jstring jurl, jstring jpath,
 
123
                        jlong jrevision, jobject jdepth,
 
124
                        jboolean jstart_empty, jstring jlock_token)
 
125
{
 
126
  //DEBUG:fprintf(stderr, "  (n) StateReporter::linkPath()\n");
 
127
 
 
128
  if (!m_valid) { throw_reporter_inactive(); return; }
 
129
 
 
130
  JNIStringHolder lock_token(jlock_token);
 
131
  if (JNIUtil::isJavaExceptionThrown())
 
132
    return;
 
133
 
 
134
  SVN::Pool subPool(pool);
 
135
  Relpath path(jpath, subPool);
 
136
  if (JNIUtil::isJavaExceptionThrown())
 
137
    return;
 
138
  URL url(jurl, subPool);
 
139
  if (JNIUtil::isJavaExceptionThrown())
 
140
    return;
 
141
  svn_depth_t depth = EnumMapper::toDepth(jdepth);
 
142
  if (JNIUtil::isJavaExceptionThrown())
 
143
    return;
 
144
 
 
145
  SVN_JNI_ERR(m_raw_reporter->link_path(m_report_baton, path.c_str(),
 
146
                                        url.c_str(), svn_revnum_t(jrevision),
 
147
                                        depth, bool(jstart_empty),
 
148
                                        lock_token.c_str(),
 
149
                                        subPool.getPool()),);
 
150
}
 
151
 
 
152
jlong
 
153
StateReporter::finishReport()
 
154
{
 
155
  //DEBUG:fprintf(stderr, "  (n) StateReporter::finishReport()\n");
 
156
 
 
157
  if (!m_valid) { throw_reporter_inactive(); return SVN_INVALID_REVNUM; }
 
158
 
 
159
  SVN::Pool subPool(pool);
 
160
  SVN_JNI_ERR(m_raw_reporter->finish_report(m_report_baton,
 
161
                                            subPool.getPool()),
 
162
              SVN_INVALID_REVNUM);
 
163
  m_valid = false;
 
164
  return jlong(m_target_revision);
 
165
}
 
166
 
 
167
void
 
168
StateReporter::abortReport()
 
169
{
 
170
  //DEBUG:fprintf(stderr, "  (n) StateReporter::abortReport()\n");
 
171
 
 
172
  if (!m_valid) { throw_reporter_inactive(); return; }
 
173
 
 
174
  SVN::Pool subPool(pool);
 
175
  SVN_JNI_ERR(m_raw_reporter->abort_report(m_report_baton,
 
176
                                           subPool.getPool()),);
 
177
  m_valid = false;
 
178
}
 
179
 
 
180
void
 
181
StateReporter::set_reporter_data(const svn_ra_reporter3_t* raw_reporter,
 
182
                                   void* report_baton,
 
183
                                   EditorProxy* editor)
 
184
{
 
185
  //DEBUG:fprintf(stderr, "  (n) StateReporter::set_reporter_data()\n");
 
186
 
 
187
  m_editor = editor;
 
188
  m_raw_reporter = raw_reporter;
 
189
  m_report_baton = report_baton;
 
190
  m_valid = true;
 
191
}