// Path: src/main/java/com/nickdsantos/onedrive4j/Resource.java
// public enum SharedWith {
// 	Selected("People I selected"), 
// 	JustMe("Just me"), 
// 	Everyone("Everyone (public)"), 
// 	Friends("Friends"), 
// 	FriendsOfFriends("My friends and their friends"), 
// 	PeopleWithLink("People with a link");
// 		
// 	private final String _val;
// 	private SharedWith(String val) {
// 		_val = val;			
// 	}
// 		
// 	@Override
// 	public String toString() {
// 		return _val;			
// 	}
// 		
// 	public static SharedWith parse(String value) throws Exception {
// 		switch (value.toLowerCase()) {
// 			case "people i selected":
// 				return SharedWith.Selected;
// 			case "just me":
// 				return SharedWith.JustMe;
// 			case "everyone (public)":
// 				return SharedWith.Everyone;
// 			case "friends":
// 				return SharedWith.Friends;
// 			case "my friends and their friends":
// 				return SharedWith.FriendsOfFriends;
// 			case "people with a link":
// 				return SharedWith.PeopleWithLink;
// 			default:
// 				throw new Exception("Unsupported value: " + value);
// 		}
// 	}
// }


import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.nickdsantos.onedrive4j.Resource.SharedWith;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicHeader;
import org.apache.log4j.Logger;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
			Gson gson = new GsonBuilder().create();
			String jsonString = gson.toJson(params);
			StringEntity jsonEntity = new StringEntity(jsonString);
			jsonEntity.setContentType(new BasicHeader("Content-Type", "application/json"));

			HttpPost httpPost = new HttpPost(uri);
			httpPost.setHeader("Authorization", "Bearer " + accessToken);
			httpPost.setEntity(jsonEntity);

			Map<Object, Object> rawResponse = httpClient.execute(httpPost, new OneDriveJsonToMapResponseHandler());
			if (rawResponse != null) {
				updatedAlbum = createAlbumFromMap(rawResponse);
				// Do not get the updated id. revert to the original prior to the update
				updatedAlbum.setId(albumId);
			}
		}
	
		return updatedAlbum;
	}
	
	private Album createAlbumFromMap(Map<Object, Object> responseMap) {
		SimpleDateFormat dtFormat = new SimpleDateFormat("YYYY-MM-dd'T'HH:mm:ssZ");		
		Album album;
		try {			
			Map<String, String> fromUserMap = (Map<String, String>) responseMap.get("from");
			User fromUser = new User();
			fromUser.setId(fromUserMap.get("id").toString());
			fromUser.setName(fromUserMap.get("name").toString());
			
			Map<String, String> sharedWithMap = (Map<String, String>) responseMap.get("shared_with");
// Path: src/main/java/com/nickdsantos/onedrive4j/Resource.java
// public enum SharedWith {
// 	Selected("People I selected"), 
// 	JustMe("Just me"), 
// 	Everyone("Everyone (public)"), 
// 	Friends("Friends"), 
// 	FriendsOfFriends("My friends and their friends"), 
// 	PeopleWithLink("People with a link");
// 		
// 	private final String _val;
// 	private SharedWith(String val) {
// 		_val = val;			
// 	}
// 		
// 	@Override
// 	public String toString() {
// 		return _val;			
// 	}
// 		
// 	public static SharedWith parse(String value) throws Exception {
// 		switch (value.toLowerCase()) {
// 			case "people i selected":
// 				return SharedWith.Selected;
// 			case "just me":
// 				return SharedWith.JustMe;
// 			case "everyone (public)":
// 				return SharedWith.Everyone;
// 			case "friends":
// 				return SharedWith.Friends;
// 			case "my friends and their friends":
// 				return SharedWith.FriendsOfFriends;
// 			case "people with a link":
// 				return SharedWith.PeopleWithLink;
// 			default:
// 				throw new Exception("Unsupported value: " + value);
// 		}
// 	}
// }


// Path: src/main/java/com/nickdsantos/onedrive4j/AlbumService.java
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.nickdsantos.onedrive4j.Resource.SharedWith;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicHeader;
import org.apache.log4j.Logger;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

			Gson gson = new GsonBuilder().create();
			String jsonString = gson.toJson(params);
			StringEntity jsonEntity = new StringEntity(jsonString);
			jsonEntity.setContentType(new BasicHeader("Content-Type", "application/json"));

			HttpPost httpPost = new HttpPost(uri);
			httpPost.setHeader("Authorization", "Bearer " + accessToken);
			httpPost.setEntity(jsonEntity);

			Map<Object, Object> rawResponse = httpClient.execute(httpPost, new OneDriveJsonToMapResponseHandler());
			if (rawResponse != null) {
				updatedAlbum = createAlbumFromMap(rawResponse);
				// Do not get the updated id. revert to the original prior to the update
				updatedAlbum.setId(albumId);
			}
		}
	
		return updatedAlbum;
	}
	
	private Album createAlbumFromMap(Map<Object, Object> responseMap) {
		SimpleDateFormat dtFormat = new SimpleDateFormat("YYYY-MM-dd'T'HH:mm:ssZ");		
		Album album;
		try {			
			Map<String, String> fromUserMap = (Map<String, String>) responseMap.get("from");
			User fromUser = new User();
			fromUser.setId(fromUserMap.get("id").toString());
			fromUser.setName(fromUserMap.get("name").toString());
			
			Map<String, String> sharedWithMap = (Map<String, String>) responseMap.get("shared_with");
			SharedWith sharedWith = SharedWith.parse(sharedWithMap.get("access").toString());			