Index: main/trunk/greenstone2/common-src/indexers/mgpp/jni/MGPPSearchWrapperImpl.cpp
===================================================================
--- main/trunk/greenstone2/common-src/indexers/mgpp/jni/MGPPSearchWrapperImpl.cpp	(revision 25244)
+++ main/trunk/greenstone2/common-src/indexers/mgpp/jni/MGPPSearchWrapperImpl.cpp	(revision 25245)
@@ -35,4 +35,7 @@
 #include "GSDLQueryParser.h"
 #include "MGQuery.h"
+
+// turning on debugging
+#define _DEBUG
   
 MGPPSearchData::MGPPSearchData() {
@@ -162,6 +165,21 @@
 Java_org_greenstone_mgpp_MGPPSearchWrapper_initCppSide (JNIEnv *j_env, jobject j_obj){
 
+#ifdef _DEBUG
+  cerr << "**** JNI debugging for GS3. initCppSide: SetLongField()\n";
+#endif
+
   MGPPSearchData * data = new MGPPSearchData();
+
+#ifdef _DEBUG
+  fprintf (stderr, "1a. data before SetLongField() is: %ld and as hex: %lX\n", data, data);
+  fprintf (stderr, "1b. FID_mgpp_data before SetLongField() is: %ld and as hex: %lX\n", FID_mgpp_data, FID_mgpp_data);
+#endif
+
   j_env->SetLongField(j_obj, FID_mgpp_data, (long)data);
+
+#ifdef _DEBUG
+  fprintf (stderr, "1a. data after SetLongField() is: %ld and as hex: %lX\n", data, data);
+  fprintf (stderr, "1b. FID_mgpp_data after SetLongField() is: %ld and as hex: %lX\n", FID_mgpp_data, FID_mgpp_data);
+#endif
 
   return true;
@@ -177,6 +195,14 @@
 JNIEXPORT jboolean JNICALL 
 Java_org_greenstone_mgpp_MGPPSearchWrapper_loadIndexData (JNIEnv *j_env, jobject j_obj,  jstring j_index_name) {
+#ifdef _DEBUG
+  fprintf (stderr, "in loadIndexData\n");
+#endif
 
   jlong data_ptr = j_env->GetLongField(j_obj, FID_mgpp_data);
+
+#ifdef _DEBUG
+  fprintf (stderr, "1. data_ptr at start is: %ld and as hex: %lX\n", data_ptr, data_ptr);
+#endif
+
   MGPPSearchData * data = (MGPPSearchData *)data_ptr;
 
@@ -210,5 +236,14 @@
 Java_org_greenstone_mgpp_MGPPSearchWrapper_unloadIndexData (JNIEnv *j_env, jobject j_obj) {
 
+#ifdef _DEBUG
+  fprintf (stderr, "in unloadIndexData\n");
+#endif
+
   jlong data_ptr = j_env->GetLongField(j_obj, FID_mgpp_data);
+
+#ifdef _DEBUG
+  fprintf (stderr, "1. data_ptr at start is: %ld and as hex: %lX\n", data_ptr, data_ptr);
+#endif
+
   MGPPSearchData * data = (MGPPSearchData *)data_ptr;
 
@@ -428,19 +463,63 @@
 						    jobject j_obj, 
 						    jstring j_level){
+  // print to stderr start of setReturnLevel, print out FID..
+  // %ld or %x -> need to print out pointer - 
+  // Later consider field containing unsignedlong instead of long
+  
+#ifdef _DEBUG
+  cerr << "In MGPPSearchWrapperImpl.setReturnLevel()\n";
+  fprintf (stderr, "1. FID_mgpp_data at start is: %ld and as hex: %lX\n", FID_mgpp_data, FID_mgpp_data);
+#endif
 
   jlong data_ptr = j_env->GetLongField(j_obj, FID_mgpp_data);
-  MGPPSearchData * data = (MGPPSearchData *)j_env->GetLongField(j_obj, FID_mgpp_data);
-
-
+
+#ifdef _DEBUG
+  fprintf (stderr, "1a. data_ptr at start is: %ld and as hex: %lX\n", data_ptr, data_ptr);
+#endif
+
+  MGPPSearchData * data = (MGPPSearchData *)j_env->GetLongField(j_obj, FID_mgpp_data);
+
+#ifdef _DEBUG
+  fprintf (stderr, "2a. FID_mgpp_data after data instantiation: %ld and as hex: %lX\n", FID_mgpp_data, FID_mgpp_data);
+  fprintf (stderr, "2b. Pointer value of data upon inst: %ld and as hex: %lX\n", data, data);
+#endif
+
+  // print out FID again.. as long decimal and as hex
+  // %ld or %x -> need to print out pointer - 
+  // in the C code in the Setlong bit in this file
+  // And the place on the java side, maybe in the configure 
+  //  org.greenstone.gsdl3.service.GS2MGPPSearch.configure(Lorg/w3c/dom/Element;Lorg/w3c/dom/Element;)Z+18
+  // find out what value we're SETTING the value of the pointer to
   const char * level = j_env->GetStringUTFChars(j_level, NULL);
   if (level==NULL) {
     return; // exception already thrown
   }
+
+#ifdef _DEBUG
+  fprintf (stderr, "3a. FID_mgpp_data after level: %ld and as hex: %lX\n", FID_mgpp_data, FID_mgpp_data);
+  fprintf (stderr, "3b. Pointer value of data after level: %ld and as hex: %lX\n", data, data);
+#endif
   
   data->level.clear();
+
+#ifdef _DEBUG
+  fprintf (stderr, "4a. FID_mgpp_data after data->level.clear(): %ld and as hex: %lX\n", FID_mgpp_data, FID_mgpp_data);
+  fprintf (stderr, "4b. Pointer value of data after level.clear(): %ld and as hex: %lX\n", data, data);
+#endif
+
   SetCStr(data->level, level);
+
+#ifdef _DEBUG
+  fprintf (stderr, "5a. FID_mgpp_data after SetCStr on data: %ld and as hex: %lX\n", FID_mgpp_data, FID_mgpp_data);
+  fprintf (stderr, "5b. Pointer value of data after SetCStr: %ld and as hex: %lX\n", data, data);
+#endif
   
   // release the java stuff
   j_env->ReleaseStringUTFChars(j_level, level);
+
+#ifdef _DEBUG
+  fprintf (stderr, "5a. FID_mgpp_data at end of setReturnLevel: %ld and as hex: %lX\n", FID_mgpp_data, FID_mgpp_data);
+  fprintf (stderr, "5b. Pointer value of data at end of SetReturnLevel: %ld and as hex: %lX\n", data, data);
+#endif
 
 }
