List of usage examples for org.json JSONObject put
public JSONObject put(String key, Object value) throws JSONException
From source file:com.liferay.mobile.android.v7.assetentry.AssetEntryService.java
public JSONObject updateEntry(long groupId, long createDate, long modifiedDate, String className, long classPK, String classUuid, long classTypeId, JSONArray categoryIds, JSONArray tagNames, boolean visible, long startDate, long endDate, long expirationDate, String mimeType, String title, String description, String summary, String url, String layoutUuid, int height, int width, int priority, boolean sync) throws Exception { JSONObject _command = new JSONObject(); try {// www .j ava2 s.c o m JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("createDate", createDate); _params.put("modifiedDate", modifiedDate); _params.put("className", checkNull(className)); _params.put("classPK", classPK); _params.put("classUuid", checkNull(classUuid)); _params.put("classTypeId", classTypeId); _params.put("categoryIds", checkNull(categoryIds)); _params.put("tagNames", checkNull(tagNames)); _params.put("visible", visible); _params.put("startDate", startDate); _params.put("endDate", endDate); _params.put("expirationDate", expirationDate); _params.put("mimeType", checkNull(mimeType)); _params.put("title", checkNull(title)); _params.put("description", checkNull(description)); _params.put("summary", checkNull(summary)); _params.put("url", checkNull(url)); _params.put("layoutUuid", checkNull(layoutUuid)); _params.put("height", height); _params.put("width", width); _params.put("priority", priority); _params.put("sync", sync); _command.put("/assetentry/update-entry", _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.assetentry.AssetEntryService.java
public JSONObject updateEntry(long groupId, long createDate, long modifiedDate, String className, long classPK, String classUuid, long classTypeId, JSONArray categoryIds, JSONArray tagNames, boolean visible, long startDate, long endDate, long expirationDate, String mimeType, String title, String description, String summary, String url, String layoutUuid, int height, int width, double priority) throws Exception { JSONObject _command = new JSONObject(); try {//from ww w . j av a2s .c o m JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("createDate", createDate); _params.put("modifiedDate", modifiedDate); _params.put("className", checkNull(className)); _params.put("classPK", classPK); _params.put("classUuid", checkNull(classUuid)); _params.put("classTypeId", classTypeId); _params.put("categoryIds", checkNull(categoryIds)); _params.put("tagNames", checkNull(tagNames)); _params.put("visible", visible); _params.put("startDate", startDate); _params.put("endDate", endDate); _params.put("expirationDate", expirationDate); _params.put("mimeType", checkNull(mimeType)); _params.put("title", checkNull(title)); _params.put("description", checkNull(description)); _params.put("summary", checkNull(summary)); _params.put("url", checkNull(url)); _params.put("layoutUuid", checkNull(layoutUuid)); _params.put("height", height); _params.put("width", width); _params.put("priority", priority); _command.put("/assetentry/update-entry", _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.assetentry.AssetEntryService.java
public JSONObject fetchEntry(long entryId) throws Exception { JSONObject _command = new JSONObject(); try {/*from ww w.ja v a 2s. c o m*/ JSONObject _params = new JSONObject(); _params.put("entryId", entryId); _command.put("/assetentry/fetch-entry", _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.assetentry.AssetEntryService.java
public JSONObject incrementViewCounter(String className, long classPK) throws Exception { JSONObject _command = new JSONObject(); try {//from w ww . ja v a 2 s . com JSONObject _params = new JSONObject(); _params.put("className", checkNull(className)); _params.put("classPK", classPK); _command.put("/assetentry/increment-view-counter", _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.assetentry.AssetEntryService.java
public Integer getEntriesCount(JSONObjectWrapper entryQuery) throws Exception { JSONObject _command = new JSONObject(); try {// w ww . j a va 2 s. c o m JSONObject _params = new JSONObject(); mangleWrapper(_params, "entryQuery", "com.liferay.asset.kernel.service.persistence.AssetEntryQuery", entryQuery); _command.put("/assetentry/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); }
From source file:com.liferay.mobile.android.v7.assetentry.AssetEntryService.java
public JSONArray getCompanyEntries(long companyId, int start, int end) throws Exception { JSONObject _command = new JSONObject(); try {// w w w . j a v a 2s . co m JSONObject _params = new JSONObject(); _params.put("companyId", companyId); _params.put("start", start); _params.put("end", end); _command.put("/assetentry/get-company-entries", _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.assetentry.AssetEntryService.java
public Integer getCompanyEntriesCount(long companyId) throws Exception { JSONObject _command = new JSONObject(); try {//from w w w . j ava 2 s .c o m JSONObject _params = new JSONObject(); _params.put("companyId", companyId); _command.put("/assetentry/get-company-entries-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.mindmeapp.extensions.ExtensionData.java
/** * Serializes the contents of this object to JSON. *///from ww w. jav a 2s .c o m public JSONObject serialize() throws JSONException { JSONObject data = new JSONObject(); data.put(KEY_VISIBLE, mVisible); data.put(KEY_ICON, mIcon); data.put(KEY_ICON_URI, (mIconUri == null ? null : mIconUri.toString())); data.put(KEY_STATUS_TO_DISPLAY, mStatusToDisplay); data.put(KEY_STATUS_TO_SPEAK, mStatusToSpeak); data.put(KEY_CONTENT_DESCRIPTION, mContentDescription); data.put(KEY_BACKGROUND, mBackground); data.put(KEY_BACKGROUND_URI, (mBackgroundUri == null ? null : mBackgroundUri.toString())); //Decompose Locale object data.put(KEY_LOCALE_LANGUAGE, mLanguageToSpeak.getLanguage()); data.put(KEY_LOCALE_COUNTRY, mLanguageToSpeak.getCountry()); return data; }
From source file:de.kp.ames.webdav.WebDAVClient.java
/** * Determines all level 1 resources of a certain webdav resource, * referred by the given uri; this is a method for a folder-like * listing/* ww w. ja v a2 s . c o m*/ * * @return */ public JSONArray getResources() { /* * Sorter to sort WebDAV folder by name */ Map<String, JSONObject> collector = new TreeMap<String, JSONObject>(new Comparator<String>() { public int compare(String name1, String name2) { return name1.compareTo(name2); } }); try { DavMethod method = new PropFindMethod(uri, DavConstants.PROPFIND_ALL_PROP, DavConstants.DEPTH_1); client.executeMethod(method); MultiStatus multiStatus = method.getResponseBodyAsMultiStatus(); MultiStatusResponse[] responses = multiStatus.getResponses(); MultiStatusResponse response; /* * Determine base uri from uri */ String base_uri = null; int first_slash = uri.indexOf("/", 8); // after http:// if (uri.endsWith("/")) base_uri = uri.substring(first_slash); int status = 200; // http ok for (int i = 0; i < responses.length; i++) { response = responses[i]; String href = response.getHref(); /* * Ignore the current directory */ if (href.equals(base_uri)) continue; String name = href.substring(base_uri.length()); // remove the final / from the name for directories if (name.endsWith("/")) name = name.substring(0, name.length() - 1); // ============= properties ================================= DavPropertySet properties = response.getProperties(status); /* * creationdate */ String creationdate = null; DavProperty<?> creationDate = properties.get("creationdate"); if ((creationDate != null) && (creationDate.getValue() != null)) creationdate = creationDate.getValue().toString(); /* * lastModifiedDate */ String lastmodified = null; DavProperty<?> lastModifiedDate = properties.get("getlastmodified"); if ((lastModifiedDate != null) && (lastModifiedDate.getValue() != null)) { lastmodified = lastModifiedDate.getValue().toString(); } else { lastmodified = creationdate; } /* * contenttype */ String contenttype = "text/plain"; DavProperty<?> contentType = properties.get("getcontenttype"); if ((contentType != null) && (contentType.getValue() != null)) contenttype = contentType.getValue().toString(); /* * getcontentlength */ String contentlength = "0"; DavProperty<?> contentLength = properties.get("getcontentlength"); if ((contentLength != null) && (contentLength.getValue() != null)) contentlength = contentLength.getValue().toString(); /* * resource type */ String resourcetype = null; DavProperty<?> resourceType = properties.get("resourcetype"); if ((resourceType != null) && (resourceType.getValue() != null)) resourcetype = resourceType.getValue().toString(); // title //DavProperty title = properties.get("title"); // supportedlock //DavProperty supportedLock = properties.get("supportedlock"); // displayname //DavProperty displayName = properties.get("displayname"); /* * distinguish folder & file resource */ boolean isfolder = false; if ((resourcetype != null) && (resourcetype.indexOf("collection") != -1)) isfolder = true; /* * determine absolute url */ String resource_uri = uri + name; if (isfolder == true) resource_uri = resource_uri + "/"; // this is a tribute to plone webdav server // we ignore file-like resources with content length = 0 if ((isfolder == false) && (contentlength == "0")) continue; /* * Convert to JSON object */ JSONObject jResource = new JSONObject(); jResource.put("name", name); jResource.put("uri", resource_uri); jResource.put("creationDate", creationdate); jResource.put("lastModified", lastmodified); jResource.put("isFolder", isfolder); if (isfolder == false) { jResource.put("contentLength", contentlength); jResource.put("contentType", contenttype); } collector.put(name, jResource); } return new JSONArray(collector.values()); } catch (Exception e) { e.printStackTrace(); } finally { } return new JSONArray(); }
From source file:edu.stanford.mobisocial.dungbeetle.DBIdentityProvider.java
public String userProfile() { Cursor c = mHelper.getReadableDatabase().rawQuery("SELECT * FROM " + MyInfo.TABLE, new String[] {}); try {//from www .j a v a2 s.c om c.moveToFirst(); JSONObject obj = new JSONObject(); try { obj.put("name", c.getString(c.getColumnIndexOrThrow(MyInfo.NAME))); } catch (JSONException e) { } return JSON.fastAddBase64(obj.toString(), "picture", c.getBlob(c.getColumnIndexOrThrow(MyInfo.PICTURE))); } finally { c.close(); } }