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
12
* http://www.apache.org/licenses/LICENSE-2.0
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
20
* ====================================================================
23
* @file StateReporter.cpp
24
* @brief Implementation of the class StateReporter
30
#include "JNIStringHolder.h"
31
#include "StateReporter.h"
32
#include "EnumMapper.h"
35
#include "svn_private_config.h"
37
StateReporter::StateReporter()
42
m_target_revision(SVN_INVALID_REVNUM)
45
StateReporter::~StateReporter()
51
StateReporter::getCppObject(jobject jthis)
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));
60
StateReporter::dispose(jobject jthis)
62
//DEBUG:fprintf(stderr, " (n) StateReporter::dispose()\n");
67
static jfieldID fid = 0;
68
SVNBase::dispose(jthis, &fid, JAVAHL_CLASS("/remote/StateReporter"));
72
void throw_reporter_inactive()
74
JNIUtil::raiseThrowable("java/lang/IllegalStateException",
75
_("The reporter is not active"));
77
} // anonymous namespace
80
StateReporter::setPath(jstring jpath, jlong jrevision, jobject jdepth,
81
jboolean jstart_empty, jstring jlock_token)
83
//DEBUG:fprintf(stderr, " (n) StateReporter::setPath()\n");
85
if (!m_valid) { throw_reporter_inactive(); return; }
87
JNIStringHolder lock_token(jlock_token);
88
if (JNIUtil::isJavaExceptionThrown())
91
SVN::Pool subPool(pool);
92
Relpath path(jpath, subPool);
93
if (JNIUtil::isJavaExceptionThrown())
95
svn_depth_t depth = EnumMapper::toDepth(jdepth);
96
if (JNIUtil::isJavaExceptionThrown())
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()),);
106
StateReporter::deletePath(jstring jpath)
108
//DEBUG:fprintf(stderr, " (n) StateReporter::deletePath()\n");
110
if (!m_valid) { throw_reporter_inactive(); return; }
112
SVN::Pool subPool(pool);
113
Relpath path(jpath, subPool);
114
if (JNIUtil::isJavaExceptionThrown())
117
SVN_JNI_ERR(m_raw_reporter->delete_path(m_report_baton, path.c_str(),
118
subPool.getPool()),);
122
StateReporter::linkPath(jstring jurl, jstring jpath,
123
jlong jrevision, jobject jdepth,
124
jboolean jstart_empty, jstring jlock_token)
126
//DEBUG:fprintf(stderr, " (n) StateReporter::linkPath()\n");
128
if (!m_valid) { throw_reporter_inactive(); return; }
130
JNIStringHolder lock_token(jlock_token);
131
if (JNIUtil::isJavaExceptionThrown())
134
SVN::Pool subPool(pool);
135
Relpath path(jpath, subPool);
136
if (JNIUtil::isJavaExceptionThrown())
138
URL url(jurl, subPool);
139
if (JNIUtil::isJavaExceptionThrown())
141
svn_depth_t depth = EnumMapper::toDepth(jdepth);
142
if (JNIUtil::isJavaExceptionThrown())
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),
149
subPool.getPool()),);
153
StateReporter::finishReport()
155
//DEBUG:fprintf(stderr, " (n) StateReporter::finishReport()\n");
157
if (!m_valid) { throw_reporter_inactive(); return SVN_INVALID_REVNUM; }
159
SVN::Pool subPool(pool);
160
SVN_JNI_ERR(m_raw_reporter->finish_report(m_report_baton,
164
return jlong(m_target_revision);
168
StateReporter::abortReport()
170
//DEBUG:fprintf(stderr, " (n) StateReporter::abortReport()\n");
172
if (!m_valid) { throw_reporter_inactive(); return; }
174
SVN::Pool subPool(pool);
175
SVN_JNI_ERR(m_raw_reporter->abort_report(m_report_baton,
176
subPool.getPool()),);
181
StateReporter::set_reporter_data(const svn_ra_reporter3_t* raw_reporter,
185
//DEBUG:fprintf(stderr, " (n) StateReporter::set_reporter_data()\n");
188
m_raw_reporter = raw_reporter;
189
m_report_baton = report_baton;