diff options
Diffstat (limited to 'subversion/bindings/javahl/native/CreateJ.cpp')
-rw-r--r-- | subversion/bindings/javahl/native/CreateJ.cpp | 160 |
1 files changed, 141 insertions, 19 deletions
diff --git a/subversion/bindings/javahl/native/CreateJ.cpp b/subversion/bindings/javahl/native/CreateJ.cpp index 8bf9f30..9b40ce7 100644 --- a/subversion/bindings/javahl/native/CreateJ.cpp +++ b/subversion/bindings/javahl/native/CreateJ.cpp @@ -20,8 +20,8 @@ * ==================================================================== * @endcopyright * - * @file ConflictResolverCallback.cpp - * @brief Implementation of the class ConflictResolverCallback. + * @file CreateJ.cpp + * @brief Implementation of the class CreateJ. */ #include "svn_error.h" @@ -35,6 +35,7 @@ #include "../include/org_apache_subversion_javahl_CommitItemStateFlags.h" #include "svn_path.h" +#include "svn_props.h" #include "private/svn_wc_private.h" jobject @@ -150,7 +151,8 @@ CreateJ::ConflictVersion(const svn_wc_conflict_version_t *version) static jmethodID ctor = 0; if (ctor == 0) { - ctor = env->GetMethodID(clazz, "<init>", "(Ljava/lang/String;J" + ctor = env->GetMethodID(clazz, "<init>", "(Ljava/lang/String;" + "Ljava/lang/String;J" "Ljava/lang/String;" "L"JAVA_PACKAGE"/types/NodeKind;" ")V"); @@ -161,6 +163,9 @@ CreateJ::ConflictVersion(const svn_wc_conflict_version_t *version) jstring jreposURL = JNIUtil::makeJString(version->repos_url); if (JNIUtil::isJavaExceptionThrown()) POP_AND_RETURN_NULL; + jstring jreposUUID = JNIUtil::makeJString(version->repos_uuid); + if (JNIUtil::isJavaExceptionThrown()) + POP_AND_RETURN_NULL; jstring jpathInRepos = JNIUtil::makeJString(version->path_in_repos); if (JNIUtil::isJavaExceptionThrown()) POP_AND_RETURN_NULL; @@ -168,7 +173,7 @@ CreateJ::ConflictVersion(const svn_wc_conflict_version_t *version) if (JNIUtil::isJavaExceptionThrown()) POP_AND_RETURN_NULL; - jobject jversion = env->NewObject(clazz, ctor, jreposURL, + jobject jversion = env->NewObject(clazz, ctor, jreposURL, jreposUUID, (jlong)version->peg_rev, jpathInRepos, jnodeKind); if (JNIUtil::isJavaExceptionThrown()) @@ -206,9 +211,9 @@ CreateJ::Checksum(const svn_checksum_t *checksum) POP_AND_RETURN_NULL; } - jbyteArray jdigest = JNIUtil::makeJByteArray( - (const signed char *)checksum->digest, - svn_checksum_size(checksum)); + jbyteArray jdigest + = JNIUtil::makeJByteArray(checksum->digest, + static_cast<int>(svn_checksum_size(checksum))); if (JNIUtil::isExceptionThrown()) POP_AND_RETURN_NULL; @@ -429,7 +434,7 @@ CreateJ::ChangedPath(const char *path, svn_log_changed_path2_t *log_item) jclass clazzCP = env->FindClass(JAVA_PACKAGE"/types/ChangePath"); if (JNIUtil::isJavaExceptionThrown()) - POP_AND_RETURN(SVN_NO_ERROR); + POP_AND_RETURN_NULL; static jmethodID midCP = 0; if (midCP == 0) @@ -442,7 +447,7 @@ CreateJ::ChangedPath(const char *path, svn_log_changed_path2_t *log_item) "L"JAVA_PACKAGE"/types/Tristate;" "L"JAVA_PACKAGE"/types/Tristate;)V"); if (JNIUtil::isJavaExceptionThrown()) - POP_AND_RETURN(SVN_NO_ERROR); + POP_AND_RETURN_NULL; } jstring jpath = JNIUtil::makeJString(path); @@ -506,6 +511,7 @@ CreateJ::Status(svn_wc_context_t *wc_ctx, "ZZZZZL"JAVA_PACKAGE"/types/Lock;" "L"JAVA_PACKAGE"/types/Lock;" "JJL"JAVA_PACKAGE"/types/NodeKind;" + "Ljava/lang/String;Ljava/lang/String;" "Ljava/lang/String;Ljava/lang/String;)V"); if (JNIUtil::isJavaExceptionThrown()) POP_AND_RETURN_NULL; @@ -525,6 +531,8 @@ CreateJ::Status(svn_wc_context_t *wc_ctx, jstring jLastCommitAuthor = NULL; jobject jLocalLock = NULL; jstring jChangelist = NULL; + jstring jMovedFromAbspath = NULL; + jstring jMovedToAbspath = NULL; enum svn_wc_status_kind text_status = status->node_status; @@ -596,6 +604,20 @@ CreateJ::Status(svn_wc_context_t *wc_ctx, POP_AND_RETURN_NULL; } + if (status->moved_from_abspath) + { + jMovedFromAbspath = JNIUtil::makeJString(status->moved_from_abspath); + if (JNIUtil::isJavaExceptionThrown()) + POP_AND_RETURN_NULL; + } + + if (status->moved_to_abspath) + { + jMovedToAbspath = JNIUtil::makeJString(status->moved_to_abspath); + if (JNIUtil::isJavaExceptionThrown()) + POP_AND_RETURN_NULL; + } + jobject ret = env->NewObject(clazz, mid, jPath, jUrl, jNodeKind, jRevision, jLastChangedRevision, jLastChangedDate, jLastCommitAuthor, jTextType, jPropType, @@ -604,7 +626,8 @@ CreateJ::Status(svn_wc_context_t *wc_ctx, jIsSwitched, jIsFileExternal, jLocalLock, jReposLock, jOODLastCmtRevision, jOODLastCmtDate, - jOODKind, jOODLastCmtAuthor, jChangelist); + jOODKind, jOODLastCmtAuthor, jChangelist, + jMovedFromAbspath, jMovedToAbspath); return env->PopLocalFrame(ret); } @@ -711,7 +734,13 @@ CreateJ::ClientNotifyInformation(const svn_wc_notify_t *wcNotify) jlong jhunkModifiedStart = wcNotify->hunk_modified_start; jlong jhunkModifiedLength = wcNotify->hunk_modified_length; jlong jhunkMatchedLine = wcNotify->hunk_matched_line; - jint jhunkFuzz = wcNotify->hunk_fuzz; + jint jhunkFuzz = static_cast<jint>(wcNotify->hunk_fuzz); + if (jhunkFuzz != wcNotify->hunk_fuzz) + { + env->ThrowNew(env->FindClass("java.lang.ArithmeticException"), + "Overflow converting C svn_linenum_t to Java int"); + POP_AND_RETURN_NULL; + } // call the Java method jobject jInfo = env->NewObject(clazz, midCT, jPath, jAction, @@ -810,7 +839,8 @@ CreateJ::CommitItem(svn_client_commit_item3_t *item) "(Ljava/lang/String;" "L"JAVA_PACKAGE"/types/NodeKind;" "ILjava/lang/String;" - "Ljava/lang/String;J)V"); + "Ljava/lang/String;J" + "Ljava/lang/String;)V"); if (JNIUtil::isExceptionThrown()) POP_AND_RETURN_NULL; } @@ -837,6 +867,12 @@ CreateJ::CommitItem(svn_client_commit_item3_t *item) if (item->state_flags & SVN_CLIENT_COMMIT_ITEM_IS_COPY) jstateFlags |= org_apache_subversion_javahl_CommitItemStateFlags_IsCopy; + if (item->state_flags & SVN_CLIENT_COMMIT_ITEM_LOCK_TOKEN) + jstateFlags |= + org_apache_subversion_javahl_CommitItemStateFlags_LockToken; + if (item->state_flags & SVN_CLIENT_COMMIT_ITEM_MOVED_HERE) + jstateFlags |= + org_apache_subversion_javahl_CommitItemStateFlags_MovedHere; jstring jurl = JNIUtil::makeJString(item->url); if (JNIUtil::isJavaExceptionThrown()) @@ -846,12 +882,16 @@ CreateJ::CommitItem(svn_client_commit_item3_t *item) if (JNIUtil::isJavaExceptionThrown()) POP_AND_RETURN_NULL; + jstring jmovedFromPath = JNIUtil::makeJString(item->moved_from_abspath); + if (JNIUtil::isJavaExceptionThrown()) + POP_AND_RETURN_NULL; + jlong jcopyRevision = item->revision; // create the Java object jobject jitem = env->NewObject(clazz, midConstructor, jpath, jnodeKind, jstateFlags, jurl, - jcopyUrl, jcopyRevision); + jcopyUrl, jcopyRevision, jmovedFromPath); if (JNIUtil::isJavaExceptionThrown()) POP_AND_RETURN_NULL; @@ -911,7 +951,7 @@ CreateJ::CommitInfo(const svn_commit_info_t *commit_info) } jobject -CreateJ::RevisionRangeList(apr_array_header_t *ranges) +CreateJ::RevisionRangeList(svn_rangelist_t *ranges) { JNIEnv *env = JNIUtil::getEnv(); @@ -1019,21 +1059,22 @@ jobject CreateJ::PropertyMap(apr_hash_t *prop_hash) POP_AND_RETURN_NULL; apr_hash_index_t *hi; - int i = 0; for (hi = apr_hash_first(apr_hash_pool_get(prop_hash), prop_hash); - hi; hi = apr_hash_next(hi), ++i) + hi; hi = apr_hash_next(hi)) { const char *key; svn_string_t *val; - apr_hash_this(hi, (const void **)&key, NULL, (void **)&val); + apr_hash_this(hi, + reinterpret_cast<const void **>(&key), + NULL, + reinterpret_cast<void **>(&val)); jstring jpropName = JNIUtil::makeJString(key); if (JNIUtil::isJavaExceptionThrown()) POP_AND_RETURN_NULL; - jbyteArray jpropVal = JNIUtil::makeJByteArray( - (const signed char *)val->data, val->len); + jbyteArray jpropVal = JNIUtil::makeJByteArray(val); if (JNIUtil::isJavaExceptionThrown()) POP_AND_RETURN_NULL; @@ -1048,6 +1089,87 @@ jobject CreateJ::PropertyMap(apr_hash_t *prop_hash) return env->PopLocalFrame(map); } +jobject CreateJ::InheritedProps(apr_array_header_t *iprops) +{ + JNIEnv *env = JNIUtil::getEnv(); + + if (iprops == NULL) + return NULL; + + // Create a local frame for our references + env->PushLocalFrame(LOCAL_FRAME_SIZE); + if (JNIUtil::isJavaExceptionThrown()) + return NULL; + + jclass list_cls = env->FindClass("java/util/ArrayList"); + if (JNIUtil::isJavaExceptionThrown()) + POP_AND_RETURN_NULL; + + static volatile jmethodID init_mid = 0; + if (init_mid == 0) + { + init_mid = env->GetMethodID(list_cls, "<init>", "(I)V"); + if (JNIUtil::isJavaExceptionThrown()) + POP_AND_RETURN_NULL; + } + + static volatile jmethodID add_mid = 0; + if (add_mid == 0) + { + add_mid = env->GetMethodID(list_cls, "add", + "(Ljava/lang/Object;)Z"); + if (JNIUtil::isJavaExceptionThrown()) + POP_AND_RETURN_NULL; + } + + jclass item_cls = env->FindClass( + JAVA_PACKAGE"/callback/InheritedProplistCallback$InheritedItem"); + if (JNIUtil::isJavaExceptionThrown()) + POP_AND_RETURN_NULL; + + static volatile jmethodID ctor_mid = 0; + if (ctor_mid == 0) + { + ctor_mid = env->GetMethodID(item_cls, "<init>", + "(Ljava/lang/String;Ljava/util/Map;)V"); + if (JNIUtil::isJavaExceptionThrown()) + POP_AND_RETURN_NULL; + } + + jobject array = env->NewObject(list_cls, init_mid, iprops->nelts); + if (JNIUtil::isJavaExceptionThrown()) + POP_AND_RETURN_NULL; + + for (int i = 0; i < iprops->nelts; ++i) + { + svn_prop_inherited_item_t *iprop = + APR_ARRAY_IDX(iprops, i, svn_prop_inherited_item_t*); + + jstring path_or_url = JNIUtil::makeJString(iprop->path_or_url); + if (JNIUtil::isJavaExceptionThrown()) + POP_AND_RETURN_NULL; + + jobject props = PropertyMap(iprop->prop_hash); + if (JNIUtil::isJavaExceptionThrown()) + POP_AND_RETURN_NULL; + + jobject item = env->NewObject(item_cls, ctor_mid, path_or_url, props); + if (JNIUtil::isJavaExceptionThrown()) + POP_AND_RETURN_NULL; + + env->CallBooleanMethod(array, add_mid, item); + if (JNIUtil::isJavaExceptionThrown()) + POP_AND_RETURN_NULL; + + env->DeleteLocalRef(item); + env->DeleteLocalRef(props); + env->DeleteLocalRef(path_or_url); + } + + return env->PopLocalFrame(array); +} + + jobject CreateJ::Set(std::vector<jobject> &objects) { JNIEnv *env = JNIUtil::getEnv(); |