Creating ParseObject after migration to mLab with Heroku

121 views Asked by At

Good evening,

Firstly, I have just ported my Parse.com database over to Heroku, and am using the mLab mongo database add on. Secondly, the application that connects to the database is written in java. To connect to the two together, I am using the Parse4J library.

I can successfully connect to the database and view the entries within the database, so i guess there's a win there. However, when I am trying to create objects within certain tables, it is not creating them on the database side. Whereas, on others it works just fine. I have double checked the code to see if I have made a stupid grammatical error, but I can't see any.

This is a simple method that should create a new version record of the software:

(The table in the database is called "version", it has the parameters of "version","link" and "latest" as well as the default Parse.com created ones)

public void addNewVersion(){
    ParseObject object = new ParseObject("version");
    object.put("version", "1.3.3");
    object.put("link", "www.example.com");
    object.put("latest", false);
    object.saveInBackground()
    System.out.println("Version Saved Successfully);
}

What is strange, is that no errors print out, and the println() statement prints to the console successfully.

Thank you for reading this essay of a question, any input would be greatly appreciated.

:)

Edit: As requested, here is my main method, where the Parse connection is initialised:

public static void main(String args[]) {
    //Establishes which operating system is being used, for look and feel purposes
    getOS();

    Parse.initialize("applicationId", "restAPIKey", "serverPath");

    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new GUI().setVisible(true);
        }
    });
}

The arguments within the Parse.initalize() method are filled out with the relevant information, although the restAPI key is no longer available for heroku, so I am not too sure if I need to allow the REST functionality? Having said that, the retrieve methods within the application work absolutely fine, so I'm stumped.

Edit 2: Okay, so I just thought I should try it with a callback to see if I could get any further information, and I was glad to see that there is an error printed to the console:

errorParseException [code=119, error=Permission denied for action create on class version.]
1

There are 1 answers

0
Paulo On BEST ANSWER

Okay, So after checking the callback exception, I noticed that the action "create" was denied. Therefore, I went in to the Schema table on mLab and noticed that the create section did not say "true"

{
"_id": "version",
"_metadata": {
    "class_permissions": {
        "get": {
            "*": true
        },
        "find": {
            "*": true
        },
        "update": {
            "*": true
        },
        "create": {
            "*": true
        },
        "delete": {},
        "addField": {
            "*": true
        },
        "readUserFields": [],
        "writeUserFields": []
    }
},
"version": "string",
"link": "string",
"latest": "boolean"

}

After I had changed the state of the class permissions, everything worked as intended. To anyone else, who has recently migrated from Parse.com to Heroku with the MongoDB add on, please check that the _SCHEMA section has the right permissions, it saves you a lot of time and prevents you from thinking that you are going insane. :)