Java tutorial
/** * Copyright (c) 2000-present Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ package com.liferay.mobile.android.v62.bookmarksentry; import com.liferay.mobile.android.http.file.UploadData; import com.liferay.mobile.android.service.BaseService; import com.liferay.mobile.android.service.JSONObjectWrapper; import com.liferay.mobile.android.service.Session; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; /** * @author Bruno Farache */ public class BookmarksEntryService extends BaseService { public BookmarksEntryService(Session session) { super(session); } public JSONObject addEntry(long groupId, long folderId, String name, String url, String description, JSONObjectWrapper serviceContext) throws Exception { JSONObject _command = new JSONObject(); try { JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("folderId", folderId); _params.put("name", checkNull(name)); _params.put("url", checkNull(url)); _params.put("description", checkNull(description)); mangleWrapper(_params, "serviceContext", "com.liferay.portal.service.ServiceContext", serviceContext); _command.put("/bookmarksentry/add-entry", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getJSONObject(0); } public void deleteEntry(long entryId) throws Exception { JSONObject _command = new JSONObject(); try { JSONObject _params = new JSONObject(); _params.put("entryId", entryId); _command.put("/bookmarksentry/delete-entry", _params); } catch (JSONException _je) { throw new Exception(_je); } session.invoke(_command); } public JSONArray getEntries(long groupId, long folderId, int start, int end) throws Exception { JSONObject _command = new JSONObject(); try { JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("folderId", folderId); _params.put("start", start); _params.put("end", end); _command.put("/bookmarksentry/get-entries", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getJSONArray(0); } public JSONArray getEntries(long groupId, long folderId, int start, int end, JSONObjectWrapper orderByComparator) throws Exception { JSONObject _command = new JSONObject(); try { JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("folderId", folderId); _params.put("start", start); _params.put("end", end); mangleWrapper(_params, "orderByComparator", "com.liferay.portal.kernel.util.OrderByComparator", orderByComparator); _command.put("/bookmarksentry/get-entries", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getJSONArray(0); } public Integer getEntriesCount(long groupId, long folderId) throws Exception { JSONObject _command = new JSONObject(); try { JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("folderId", folderId); _command.put("/bookmarksentry/get-entries-count", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getInt(0); } public Integer getEntriesCount(long groupId, long folderId, int status) throws Exception { JSONObject _command = new JSONObject(); try { JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("folderId", folderId); _params.put("status", status); _command.put("/bookmarksentry/get-entries-count", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getInt(0); } public JSONObject getEntry(long entryId) throws Exception { JSONObject _command = new JSONObject(); try { JSONObject _params = new JSONObject(); _params.put("entryId", entryId); _command.put("/bookmarksentry/get-entry", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getJSONObject(0); } public Integer getFoldersEntriesCount(long groupId, JSONArray folderIds) throws Exception { JSONObject _command = new JSONObject(); try { JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("folderIds", checkNull(folderIds)); _command.put("/bookmarksentry/get-folders-entries-count", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getInt(0); } public JSONArray getGroupEntries(long groupId, int start, int end) throws Exception { JSONObject _command = new JSONObject(); try { JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("start", start); _params.put("end", end); _command.put("/bookmarksentry/get-group-entries", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getJSONArray(0); } public JSONArray getGroupEntries(long groupId, long userId, int start, int end) throws Exception { JSONObject _command = new JSONObject(); try { JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("userId", userId); _params.put("start", start); _params.put("end", end); _command.put("/bookmarksentry/get-group-entries", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getJSONArray(0); } public JSONArray getGroupEntries(long groupId, long userId, long rootFolderId, int start, int end) throws Exception { JSONObject _command = new JSONObject(); try { JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("userId", userId); _params.put("rootFolderId", rootFolderId); _params.put("start", start); _params.put("end", end); _command.put("/bookmarksentry/get-group-entries", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getJSONArray(0); } public Integer getGroupEntriesCount(long groupId) throws Exception { JSONObject _command = new JSONObject(); try { JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _command.put("/bookmarksentry/get-group-entries-count", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getInt(0); } public Integer getGroupEntriesCount(long groupId, long userId) throws Exception { JSONObject _command = new JSONObject(); try { JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("userId", userId); _command.put("/bookmarksentry/get-group-entries-count", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getInt(0); } public Integer getGroupEntriesCount(long groupId, long userId, long rootFolderId) throws Exception { JSONObject _command = new JSONObject(); try { JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("userId", userId); _params.put("rootFolderId", rootFolderId); _command.put("/bookmarksentry/get-group-entries-count", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getInt(0); } public JSONObject moveEntry(long entryId, long parentFolderId) throws Exception { JSONObject _command = new JSONObject(); try { JSONObject _params = new JSONObject(); _params.put("entryId", entryId); _params.put("parentFolderId", parentFolderId); _command.put("/bookmarksentry/move-entry", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getJSONObject(0); } public JSONObject moveEntryFromTrash(long entryId, long parentFolderId) throws Exception { JSONObject _command = new JSONObject(); try { JSONObject _params = new JSONObject(); _params.put("entryId", entryId); _params.put("parentFolderId", parentFolderId); _command.put("/bookmarksentry/move-entry-from-trash", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getJSONObject(0); } public JSONObject moveEntryToTrash(long entryId) throws Exception { JSONObject _command = new JSONObject(); try { JSONObject _params = new JSONObject(); _params.put("entryId", entryId); _command.put("/bookmarksentry/move-entry-to-trash", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getJSONObject(0); } public JSONObject openEntry(JSONObjectWrapper entry) throws Exception { JSONObject _command = new JSONObject(); try { JSONObject _params = new JSONObject(); mangleWrapper(_params, "entry", "com.liferay.portlet.bookmarks.model.BookmarksEntry", entry); _command.put("/bookmarksentry/open-entry", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getJSONObject(0); } public JSONObject openEntry(long entryId) throws Exception { JSONObject _command = new JSONObject(); try { JSONObject _params = new JSONObject(); _params.put("entryId", entryId); _command.put("/bookmarksentry/open-entry", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getJSONObject(0); } public void restoreEntryFromTrash(long entryId) throws Exception { JSONObject _command = new JSONObject(); try { JSONObject _params = new JSONObject(); _params.put("entryId", entryId); _command.put("/bookmarksentry/restore-entry-from-trash", _params); } catch (JSONException _je) { throw new Exception(_je); } session.invoke(_command); } public JSONObject search(long groupId, long creatorUserId, int status, int start, int end) throws Exception { JSONObject _command = new JSONObject(); try { JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("creatorUserId", creatorUserId); _params.put("status", status); _params.put("start", start); _params.put("end", end); _command.put("/bookmarksentry/search", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getJSONObject(0); } public void subscribeEntry(long entryId) throws Exception { JSONObject _command = new JSONObject(); try { JSONObject _params = new JSONObject(); _params.put("entryId", entryId); _command.put("/bookmarksentry/subscribe-entry", _params); } catch (JSONException _je) { throw new Exception(_je); } session.invoke(_command); } public void unsubscribeEntry(long entryId) throws Exception { JSONObject _command = new JSONObject(); try { JSONObject _params = new JSONObject(); _params.put("entryId", entryId); _command.put("/bookmarksentry/unsubscribe-entry", _params); } catch (JSONException _je) { throw new Exception(_je); } session.invoke(_command); } public JSONObject updateEntry(long entryId, long groupId, long folderId, String name, String url, String description, JSONObjectWrapper serviceContext) throws Exception { JSONObject _command = new JSONObject(); try { JSONObject _params = new JSONObject(); _params.put("entryId", entryId); _params.put("groupId", groupId); _params.put("folderId", folderId); _params.put("name", checkNull(name)); _params.put("url", checkNull(url)); _params.put("description", checkNull(description)); mangleWrapper(_params, "serviceContext", "com.liferay.portal.service.ServiceContext", serviceContext); _command.put("/bookmarksentry/update-entry", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getJSONObject(0); } }