Java Question Parse Library problem with new open source Parse Server

Serdar K.

Member
Licensed User
Longtime User
Hello,

As you know, we need to change/set the server address with the Parse SDK, and since it is hardcoded in the
old SDK, we need to compile a new library working with the sources which are now open.

I tried to wrap the Parse SDK 1.13 with library (https://github.com/ParsePlatform/Parse-SDK-Android)
And also i downloaded the JAR snapshot file. I was able to compile the SDK code also with Android Studio.

But i couldn't succeed to make a wrapper library (or update the existing). Even the present tutorials which are well appreciated and given through hard work, could'nt help me (yet). This was a more complicated task for me and not a good start point for wrappers, for sure.

I had been able to compile the older library with old SDK JAR(Parse SDK 1.7, which has no open source code) with SLC.
Then i tried to compile the old Wrapper library code with the new Parse SDK by examining it's code. Compiler first raised an error, and i solved that by adding (bolts-tasks-1.4.0.jar) to the libs folder of SLC. But now i am getting the error log below (which i didn't get when compiling with older SDK):

B4X:
Starting step: Compiling Java code.
javac 1.8.0_66
D:\SLCSerdar\Parse\src\anywheresoftware\b4a\objects\ParseObjectWrapper.java:396: error: cannot find symbol
        if (ba.processBA != null) b = ba.processBA;
              ^
  symbol:   variable processBA
  location: variable ba of type BA
Note: D:\SLCSerdar\Parse\src\anywheresoftware\b4a\objects\ParseObjectWrapper.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: D:\SLCSerdar\Parse\src\anywheresoftware\b4a\objects\ParseObjectWrapper.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error


Error.

By the way, i use B4A 6.50 .

Do you have any clue, or do you have any suggestions for changing the server address ?

Also i think there are other problems with using old SDK, because now the server is Parse Server and has slight differences from the older one. I have seen problems like returning 0 counts when working through the (api.parse.com).

Thanks in advance!

Serdar
 

Serdar K.

Member
Licensed User
Longtime User
I think I am not a beginner at library wrapping, but i have to try.
I am using Parse cloud NoSQL database part, i don't need push functions.

Since i have two important applications running in the field using a Parse.com as a single Parse platform (one is one i took over from another developer who left the company and written in NSBasic) , and i started the migration process by setting up a Parse Server at Amazon, and i completed the other one. To get the fieldwork going on, i need new Parse SDK and setting the server URL.
Also the old B4A Parse library returns zero record count for my queries falsely, after moving to new server and api.parse.com redirection (finalization).

I tried rewriting a library with REST for query, insert and update needs. But i hadn't luck there with HTTP, OKHTTP and OKHTTPUtils. Because i have to do a batch process (marking "downloaded" field as "1" when specific "route" records downloaded) and HTTPJob raises an "EMFILE (Too many open files)" message, since i have a process queue of 500+ records. With HTTP and OKHTTP the problem is, i don't have response events for some requests in "ParseHttpClient_ResponseSuccess", "ParseHttpClient_ResponseError" and "ParseHttpClientResponse_StreamFinish" for some records. Some times i have got every process returned a response somehow. But since it is a commercial survey application, it has to be sure for all requests (false or true, so i can retry with the erronous ones).

The final solution is renewing the Parse library interface for Parse Server SDK.


On the last try, i removed the "Push" parts from the wrapper, and i came to another point where i have got the log :

B4X:
Starting step: Compiling Java code.
javac 1.8.0_66
D:\SLCSerdar\Parse\src\anywheresoftware\b4a\objects\ParseObjectWrapper.java:583: error: <anonymous anywheresoftware.b4a.objects.ParseObjectWrapper$$1> is not abstract and does not override abstract method done(Object,Throwable) in ParseCallback2
            {
            ^
Note: D:\SLCSerdar\Parse\src\anywheresoftware\b4a\objects\ParseObjectWrapper.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: D:\SLCSerdar\Parse\src\anywheresoftware\b4a\objects\ParseObjectWrapper.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error


Error.



The code part related is :

B4X:
public void GetById(final BA ba, final String EventName, final String ObjectId, final int TaskId)
        {
            getObject().getInBackground(ObjectId, new GetCallback()
            {
                  @Override
                public void done(ParseObject object, ParseException e)
                {
                    setLastException(ba, e);
                    ba.raiseEventFromDifferentThread(getObject(), null, 0, EventName.toLowerCase(BA.cul) + "_doneget", true,
                            new Object[] { e == null, object, TaskId });
                }

            });
        }


In fact, it seems like doing the override.
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
I tried rewriting a library with REST for query, insert and update needs. But i hadn't luck there with HTTP, OKHTTP and OKHTTPUtils. Because i have to do a batch process (marking "downloaded" field as "1" when specific "route" records downloaded) and HTTPJob raises an "EMFILE (Too many open files)" message, since i have a process queue of 500+ records. With HTTP and OKHTTP the problem is, i don't have response events for some requests in "ParseHttpClient_ResponseSuccess",
I'm sure that it can be solved. Don't send 500 requests at once. Send 100 requests and then send more requests when previous requests finish.

I'm not familiar with the original library so cannot help you with the code.
 

Serdar K.

Member
Licensed User
Longtime User
Hi Erel,

How can i wait for responses ? What would you suggest about it ? If i make an endless loop and wait "_Jobdone" or "" events with a flag or state, i'm not sure it can succeed. What is the way to wait an asynchronous process in B4A for a state?
I will work to find a way, because
the time is coming. After api.parse.com has been stopped before the end of this month, no work can be done with this application.

There are also some method implementations missing in OKHTTPUtils2, like "DELETE" method. How could i initialize such a job ?

Thanks & regards,
Serdar
 

DonManfred

Expert
Licensed User
Longtime User
If i make an endless loop and wait "_Jobdone"
you can not WAIT

Call a job, wait for the jobdone event. In the jobdone you call the next job, wait again for JobDone event....
 

Serdar K.

Member
Licensed User
Longtime User
Hi DonManfred,

I will think about it, that is similar to what i did when i used Parse Library, but the transactions will part in more pieces now, since i don't have methods like "save()". There will be seperate processes but i will try to figure out somehow.
One-by-one is the only way i can use, it seems.

Thanks and regards,
Serdar
 
Top