Commits

Luis Montiel committed 49c438f

Some changes, closing connections

  • Participants
  • Parent commits 74a7306

Comments (0)

Files changed (3)

 syntax: regexp
 ^src/main/java/com/google/gson/reflect$
 syntax: regexp
-^src/main/java/com/google/gson$
+^src/main/java/com/google/gson$
+.DS_Store

File src/main/java/urbanairship/UrbanAirShipSimpleClient.java

 	 * @param iOs - iOs push object
 	 * @return merged push object
 	 */
-	private Push merge(Push droid, Push iOs) {
+	protected Push merge(Push droid, Push iOs) {
 		if(droid == null || iOs == null) 
 			return null;
 		
 	 * @param alert - message to send
 	 * @return Android push object
 	 */
-	private Push createAndroidPush(String alert) {
+	protected Push createAndroidPush(String alert) {
 		Push push = createPush(alert);
 		push.setApids(apiD);
 		Android android = new Android();
 	 * @param alert - message to send
 	 * @return iOS push object
 	 */
-	private Push createIOSPush(String alert) {
+	protected Push createIOSPush(String alert) {
 		Push push = createPush(alert);
 		push.setDeviceTokens(dToken);
 		return push;
 	 * @param alert
 	 * @return push notification object
 	 */
-	private Push createPush(String alert) {
+	protected Push createPush(String alert) {
 		APS aps = new APS();
 		aps.setAlert(alert);
 		Push push = new Push();

File src/main/java/urbanairship/UrbanAirshipClient.java

 		}
 	}
 	
-	public void addTagToDevice(String deviceToken, String tag)
+	public HttpResponse addTagToDevice(String deviceToken, String tag)
 	{
 		if (tag.length() > 255)
 		{
 			throw new IllegalArgumentException("maximum tag length is 255. Tag: " + tag);
 		}
 		
-		put("/api/device_tokens/" + encode(deviceToken) + "/tags/" + encode(tag));
+		return put("/api/device_tokens/" + encode(deviceToken) + "/tags/" + encode(tag));
 	}
 	
 	public void removeTagFromDevice(String deviceToken, String tag)
 		}
 	}
 	
-	public void register(Device dev)
+	public HttpResponse register(Device dev)
 	{
 		
 		String identifier = dev.getIdentifier();
 			throw new IllegalStateException("missing device identifier");
 		}
 		
-		put("/api/" 
+		return put("/api/" 
 				+ path 
 				+ "/" 
 				+ encode(identifier), 
 		put("/api/user/" + userid + "/", u);
 	}
 	
-	public void updateUserByAlias(User u, String alias)
+	public HttpResponse updateUserByAlias(User u, String alias)
 	{
 		if (alias == null)
 		{
 			throw new IllegalArgumentException("alias parameter is null");
 		}
-		put("/api/user/alias/" + alias + "/", u);
+		return put("/api/user/alias/" + alias + "/", u);
 	}
 	
 	public UserCredentials reset(UserCredentials creds)
 		post("/api/airmail/send/broadcast/", airmail);
 	}
 	
-	protected void put(String path)
+	protected HttpResponse put(String path)
 	{
-		put(path, null);
+		return put(path, null);
 	}
 	
-	protected void put(String path, Object requestBodyObject)
+	protected HttpResponse put(String path, Object requestBodyObject)
 	{
 		HttpPut put = createHttpPut(path);
 		
 			put.setEntity(toJsonEntity(requestBodyObject));
 		}
 		
-		execute(put);
+		return execute(put);
 	}
 	
 	
 		post("/api/feeds/", feed);
 	}
 	
-	public void updateFeed(Feed feed, String url)
+	public HttpResponse updateFeed(Feed feed, String url)
 	{
-		put(url, feed);
+		return put(url, feed);
 	}
 	
 	public void deleteFeed(String url)
 		HttpResponse response = execute(post);
 
 		if (responseType == null)
-		{
+		{	
+			close(response);
 			return null;
 		}
 		else
 		{
-			return fromJson(response, responseType);
+			T r = fromJson(response, responseType);
+			return r;
 		}
 	}
 
 		}
 	}
 
-	private void close(final HttpResponse resp)
+	protected void close(final HttpResponse resp)
 	{
 		if (resp != null)
 		{
 		}
 	}
 	
-	private void close(final HttpEntity responseEntity)
+	protected void close(final HttpEntity responseEntity)
 	{
 		if (responseEntity != null)
 		{
 	
 	protected HttpResponse execute(HttpRequestBase method)
 	{
+		HttpResponse rsp = null;
 		try
 		{
 			method.setHeader(new BasicHeader("Accept", "application/json"));
-			HttpResponse rsp = getHttpClient().execute(method);
+			rsp = getHttpClient().execute(method);
 			checkResponse(method, rsp);
 			return rsp;
 		}
 	protected void delete(final String path)
 	{
 		HttpDelete delete = createHttpDelete(path);
-		execute(delete);
+		close(execute(delete));
 	}
 
 	private HttpDelete createHttpDelete(final String path)