コード例 #1
0
		void runTask() {
			status(su, StatusUpdate.LEVEL_GENERIC, GRI18n.getString(MODULE, "newAlbm", new Object[] { album.getName(), g.toString() }));

			try {
				List<NameValuePair> formparams = new ArrayList<NameValuePair>();
				JSONObject jsonEntity = new JSONObject();
				jsonEntity.put("type", "album");
				if (album.getName() != null)
					jsonEntity.put("name", album.getName());
				if (album.getTitle() != null)
					jsonEntity.put("title", album.getTitle());
				if (album.getDescription() != null)
					jsonEntity.put("description", album.getDescription());
				formparams.add(new BasicNameValuePair("entity", jsonEntity.toJSONString()));

				BufferedReader entityReader = sendRequest(album.getParentAlbum().getUrl(), "post", formparams);

				String url = ((JSONObject) JSONValue.parse(entityReader)).get("url").toString();
				status(su, StatusUpdate.LEVEL_GENERIC, GRI18n.getString(MODULE, "crateAlbmOk"));
				album.setUrl(url);

				Log.log(Log.LEVEL_INFO, "Created album " + album.toString());
			} catch (IOException ioe) {
				Log.logException(Log.LEVEL_ERROR, MODULE, ioe);
				Object[] params2 = {ioe.toString()};
				error(su, GRI18n.getString(MODULE, "error", params2));
			}
		}