Example usage for org.json JSONObject put

List of usage examples for org.json JSONObject put

Introduction

In this page you can find the example usage for org.json JSONObject put.

Prototype

public JSONObject put(String key, Object value) throws JSONException 

Source Link

Document

Put a key/value pair in the JSONObject.

Usage

From source file:com.liferay.mobile.android.v7.journalfolder.JournalFolderService.java

public Integer getFoldersCount(long groupId, long parentFolderId) throws Exception {
    JSONObject _command = new JSONObject();

    try {/*from   ww  w  .j a  v a 2 s . c  o m*/
        JSONObject _params = new JSONObject();

        _params.put("groupId", groupId);
        _params.put("parentFolderId", parentFolderId);

        _command.put("/journal.journalfolder/get-folders-count", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getInt(0);
}

From source file:com.liferay.mobile.android.v7.journalfolder.JournalFolderService.java

public JSONArray getSubfolderIds(long groupId, long folderId, boolean recurse) throws Exception {
    JSONObject _command = new JSONObject();

    try {/*  ww  w . j  a v a2  s.c  om*/
        JSONObject _params = new JSONObject();

        _params.put("groupId", groupId);
        _params.put("folderId", folderId);
        _params.put("recurse", recurse);

        _command.put("/journal.journalfolder/get-subfolder-ids", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getJSONArray(0);
}

From source file:com.liferay.mobile.android.v7.journalfolder.JournalFolderService.java

public void getSubfolderIds(JSONArray folderIds, long groupId, long folderId) throws Exception {
    JSONObject _command = new JSONObject();

    try {/*  w  w  w .ja va 2  s  .c o  m*/
        JSONObject _params = new JSONObject();

        _params.put("folderIds", checkNull(folderIds));
        _params.put("groupId", groupId);
        _params.put("folderId", folderId);

        _command.put("/journal.journalfolder/get-subfolder-ids", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    session.invoke(_command);
}

From source file:com.liferay.mobile.android.v7.journalfolder.JournalFolderService.java

public void getSubfolderIds(JSONArray folderIds, long groupId, long folderId, boolean recurse)
        throws Exception {
    JSONObject _command = new JSONObject();

    try {//from  www . j a  v  a  2s  . co  m
        JSONObject _params = new JSONObject();

        _params.put("folderIds", checkNull(folderIds));
        _params.put("groupId", groupId);
        _params.put("folderId", folderId);
        _params.put("recurse", recurse);

        _command.put("/journal.journalfolder/get-subfolder-ids", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    session.invoke(_command);
}

From source file:com.liferay.mobile.android.v7.journalfolder.JournalFolderService.java

public JSONObject moveFolderFromTrash(long folderId, long parentFolderId, JSONObjectWrapper serviceContext)
        throws Exception {
    JSONObject _command = new JSONObject();

    try {//from   w w w . j ava2  s. c  o m
        JSONObject _params = new JSONObject();

        _params.put("folderId", folderId);
        _params.put("parentFolderId", parentFolderId);
        mangleWrapper(_params, "serviceContext", "com.liferay.portal.kernel.service.ServiceContext",
                serviceContext);

        _command.put("/journal.journalfolder/move-folder-from-trash", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getJSONObject(0);
}

From source file:com.liferay.mobile.android.v7.journalfolder.JournalFolderService.java

public JSONObject moveFolderToTrash(long folderId) throws Exception {
    JSONObject _command = new JSONObject();

    try {/*  ww w  . j  a va2s.co  m*/
        JSONObject _params = new JSONObject();

        _params.put("folderId", folderId);

        _command.put("/journal.journalfolder/move-folder-to-trash", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getJSONObject(0);
}

From source file:com.liferay.mobile.android.v7.journalfolder.JournalFolderService.java

public void restoreFolderFromTrash(long folderId) throws Exception {
    JSONObject _command = new JSONObject();

    try {/*www . j  ava 2 s  .c o m*/
        JSONObject _params = new JSONObject();

        _params.put("folderId", folderId);

        _command.put("/journal.journalfolder/restore-folder-from-trash", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    session.invoke(_command);
}

From source file:com.liferay.mobile.android.v7.journalfolder.JournalFolderService.java

public void deleteFolder(long folderId) throws Exception {
    JSONObject _command = new JSONObject();

    try {/*from w  w  w. ja  v  a  2s .  c  o m*/
        JSONObject _params = new JSONObject();

        _params.put("folderId", folderId);

        _command.put("/journal.journalfolder/delete-folder", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    session.invoke(_command);
}

From source file:com.liferay.mobile.android.v7.journalfolder.JournalFolderService.java

public void deleteFolder(long folderId, boolean includeTrashedEntries) throws Exception {
    JSONObject _command = new JSONObject();

    try {//from  w  w w . ja v  a  2s .c  o  m
        JSONObject _params = new JSONObject();

        _params.put("folderId", folderId);
        _params.put("includeTrashedEntries", includeTrashedEntries);

        _command.put("/journal.journalfolder/delete-folder", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    session.invoke(_command);
}

From source file:com.liferay.mobile.android.v7.journalfolder.JournalFolderService.java

public JSONObject addFolder(long groupId, long parentFolderId, String name, String description,
        JSONObjectWrapper serviceContext) throws Exception {
    JSONObject _command = new JSONObject();

    try {//from  ww  w. j  a v a  2  s .c om
        JSONObject _params = new JSONObject();

        _params.put("groupId", groupId);
        _params.put("parentFolderId", parentFolderId);
        _params.put("name", checkNull(name));
        _params.put("description", checkNull(description));
        mangleWrapper(_params, "serviceContext", "com.liferay.portal.kernel.service.ServiceContext",
                serviceContext);

        _command.put("/journal.journalfolder/add-folder", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getJSONObject(0);
}