List of usage examples for org.json JSONArray getJSONArray
public JSONArray getJSONArray(int index) throws JSONException
From source file:com.google.blockly.model.FieldDropdown.java
/** * Loads a FieldDropdown from JSON. This is usually used for the {@link BlockFactory}'s * prototype instances./* ww w. j a v a 2s. c o m*/ * * @param json The JSON representing the object. * @return A new FieldDropdown instance. * @throws BlockLoadingException */ public static FieldDropdown fromJson(JSONObject json) throws BlockLoadingException { String name = json.optString("name"); if (TextUtils.isEmpty(name)) { throw new BlockLoadingException("field_dropdown \"name\" attribute must not be empty."); } JSONArray jsonOptions = json.optJSONArray("options"); ArrayList<Option> optionList = null; if (jsonOptions != null) { int count = jsonOptions == null ? 0 : jsonOptions.length(); optionList = new ArrayList<>(count); for (int i = 0; i < count; i++) { JSONArray option = null; try { option = jsonOptions.getJSONArray(i); } catch (JSONException e) { throw new BlockLoadingException("Error reading dropdown options.", e); } if (option != null && option.length() == 2) { try { String displayName = option.getString(0); String value = option.getString(1); if (TextUtils.isEmpty(value)) { throw new BlockLoadingException("Option values may not be empty"); } optionList.add(new Option(value, displayName)); } catch (JSONException e) { throw new BlockLoadingException("Error reading option values.", e); } } } } return new FieldDropdown(name, new Options(optionList)); }
From source file:com.liferay.mobile.android.v7.journalfolder.JournalFolderService.java
public JSONArray getFolders(long groupId, long parentFolderId, int status) throws Exception { JSONObject _command = new JSONObject(); try {/*w ww. j av a 2 s . co m*/ JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("parentFolderId", parentFolderId); _params.put("status", status); _command.put("/journal.journalfolder/get-folders", _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 JSONArray getFolders(long groupId) throws Exception { JSONObject _command = new JSONObject(); try {/*from w w w . j a v a2 s . com*/ JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _command.put("/journal.journalfolder/get-folders", _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 JSONArray getFolders(long groupId, long parentFolderId) throws Exception { JSONObject _command = new JSONObject(); try {//w w w. ja v a2 s .c om JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("parentFolderId", parentFolderId); _command.put("/journal.journalfolder/get-folders", _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 JSONArray getFolders(long groupId, long parentFolderId, int status, int start, int end) throws Exception { JSONObject _command = new JSONObject(); try {//from ww w . ja v a 2 s. c o m JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("parentFolderId", parentFolderId); _params.put("status", status); _params.put("start", start); _params.put("end", end); _command.put("/journal.journalfolder/get-folders", _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 JSONArray getFolders(long groupId, long parentFolderId, int start, int end) throws Exception { JSONObject _command = new JSONObject(); try {/*from w w w . j a va 2 s . c o m*/ JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("parentFolderId", parentFolderId); _params.put("start", start); _params.put("end", end); _command.put("/journal.journalfolder/get-folders", _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 JSONArray getDdmStructures(JSONArray groupIds, long folderId, int restrictionType) throws Exception { JSONObject _command = new JSONObject(); try {/*from www. j a va2s. co m*/ JSONObject _params = new JSONObject(); _params.put("groupIds", checkNull(groupIds)); _params.put("folderId", folderId); _params.put("restrictionType", restrictionType); _command.put("/journal.journalfolder/get-ddm-structures", _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 JSONArray getFolderIds(long groupId, long folderId) throws Exception { JSONObject _command = new JSONObject(); try {// w ww . j a v a2 s.c o m JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("folderId", folderId); _command.put("/journal.journalfolder/get-folder-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 JSONArray getSubfolderIds(long groupId, long folderId, boolean recurse) throws Exception { JSONObject _command = new JSONObject(); try {/* w w w .ja va 2 s . c o m*/ 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 JSONArray getFoldersAndArticles(long groupId, long folderId, int start, int end, JSONObjectWrapper obc) throws Exception { JSONObject _command = new JSONObject(); try {//from w ww . j a va 2s .c om JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("folderId", folderId); _params.put("start", start); _params.put("end", end); mangleWrapper(_params, "obc", "com.liferay.portal.kernel.util.OrderByComparator", obc); _command.put("/journal.journalfolder/get-folders-and-articles", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getJSONArray(0); }