Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/bindings/javahl/native/SVNRepos.cpp view on Meta::CPAN
if (path.isNull())
{
JNIUtil::throwNullPointerException("path");
return NULL;
}
SVN_JNI_ERR(svn_repos_open2(&repos, path.getInternalStyle(requestPool),
NULL, requestPool.getPool()), NULL);
/* Fetch all locks on or below the root directory. */
SVN_JNI_ERR(svn_repos_fs_get_locks2(&locks, repos, "/", depth, NULL, NULL,
requestPool.getPool()),
NULL);
JNIEnv *env = JNIUtil::getEnv();
jclass clazz = env->FindClass(JAVA_PACKAGE"/types/Lock");
if (JNIUtil::isJavaExceptionThrown())
return NULL;
std::vector<jobject> jlocks;
for (hi = apr_hash_first(requestPool.getPool(), locks);
hi;
hi = apr_hash_next(hi))
{
void *val;
apr_hash_this(hi, NULL, NULL, &val);
svn_lock_t *lock = reinterpret_cast<svn_lock_t *>(val);
jobject jLock = CreateJ::Lock(lock);
jlocks.push_back(jLock);
}
env->DeleteLocalRef(clazz);
return CreateJ::Set(jlocks);
}
void SVNRepos::rmlocks(File &path, StringArray &locks)
{
SVN::Pool requestPool;
svn_repos_t *repos;
svn_fs_t *fs;
svn_fs_access_t *access;
if (path.isNull())
{
JNIUtil::throwNullPointerException("path");
return;
}
SVN_JNI_ERR(svn_repos_open2(&repos, path.getInternalStyle(requestPool),
NULL, requestPool.getPool()), );
fs = svn_repos_fs(repos);
const char *username = NULL;
/* svn_fs_unlock() demands that some username be associated with the
* filesystem, so just use the UID of the person running 'svnadmin'.*/
{
apr_uid_t uid;
apr_gid_t gid;
char *un;
if (apr_uid_current(&uid, &gid, requestPool.getPool()) == APR_SUCCESS &&
apr_uid_name_get(&un, uid, requestPool.getPool()) == APR_SUCCESS)
{
svn_error_t *err = svn_utf_cstring_to_utf8(&username, un,
requestPool.getPool());
svn_error_clear(err);
if (err)
username = "administrator";
}
}
/* Create an access context describing the current user. */
SVN_JNI_ERR(svn_fs_create_access(&access, username, requestPool.getPool()), );
/* Attach the access context to the filesystem. */
SVN_JNI_ERR(svn_fs_set_access(fs, access), );
SVN::Pool subpool;
const apr_array_header_t *args = locks.array(requestPool);
for (int i = 0; i < args->nelts; ++i)
{
const char *lock_path = APR_ARRAY_IDX(args, i, const char *);
svn_lock_t *lock;
/* Fetch the path's svn_lock_t. */
svn_error_t *err = svn_fs_get_lock(&lock, fs, lock_path, subpool.getPool());
if (err)
goto move_on;
if (! lock)
continue;
/* Now forcibly destroy the lock. */
err = svn_fs_unlock(fs, lock_path,
lock->token, 1 /* force */, subpool.getPool());
if (err)
goto move_on;
move_on:
svn_error_clear(err);
subpool.clear();
}
return;
}
( run in 0.629 second using v1.01-cache-2.11-cpan-96521ef73a4 )