// Path: src/main/java/com/sugarcrm/api/SugarApiException.java
// public class SugarApiException extends Exception {
//   
//   private static final long serialVersionUID = 1L;
//   
//   protected int number = 0;
//   protected String description = "";
// 
//   public SugarApiException(String message){
//     super(message);
//   }
// 
//   public SugarApiException(String message, Throwable rootCause){
//     super(message, rootCause);
//   }
//   
//   public void setNumber(int number) {
//     this.number = number;
//   }
//   
//   public void setDescription(String description) {
//     this.description = description;
//   }
//   
//   /**
//    * Error identifying number returned from server
//    * Zero value indicates a wrapped exception meaning you should check {@link Exception#getCause()} for more details.
//    * @return error number
//    */
//   public int getNumber() {
//     return number;
//   }
//   
//   public String getDescription() {
//     return description;
//   }
// 
// }
// 
// Path: src/main/java/com/sugarcrm/api/SugarCredentials.java
// public class SugarCredentials {
// 
// 	private String user_name;
// 	private String password;
// 	
// 	public SugarCredentials() throws SugarApiException{
// 		this(null, null);
// 	}
// 	
// 	public SugarCredentials(String userId, String plaintextPassword) throws SugarApiException{
// 	  this.user_name = userId;
// 	  if(plaintextPassword != null){
// 	    setPassword(plaintextPassword);
// 	  }
// 	}
// 	
// 	public void setPassword(String plaintextPassword) throws SugarApiException{
// 	  try {
// 	    this.password = Hex.encodeHexString(MessageDigest.getInstance("MD5").digest(plaintextPassword.getBytes()));
// 	  }catch(NoSuchAlgorithmException ex){
// 	    SugarApiException sae = new SugarApiException("Unable to generate Sugar password value because this JRE does not support MD5", ex);
// 	    throw sae;
// 	  }
// 	}
// 
// 	public String getUserName(){
// 		return user_name;
// 	}
// 	
// 	public String getEncodedPassword(){
// 		return password;
// 	}
// 	
// 
// }
// 
// Path: src/main/java/com/sugarcrm/api/SugarEntity.java
// public interface SugarEntity
// {
// 	String get(String fieldName);
// 
// 	ArrayList<HashMap<String, String>> getData();
// 
// 	Collection<String> getFieldNames();
// 
// 	String getId();
// 
// 	String getModuleName();
// 
// 	String set(String fieldName, String value);
// }
// 
// Path: src/main/java/com/sugarcrm/api/SugarSession.java
// public interface SugarSession {
// 	
//   public String getSessionID();
//   public User getUser();
// 
// }


import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import org.apache.commons.codec.EncoderException;
import org.apache.commons.codec.net.URLCodec;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.annotations.SerializedName;
import com.sugarcrm.api.SugarApiException;
import com.sugarcrm.api.SugarCredentials;
import com.sugarcrm.api.SugarEntity;
import com.sugarcrm.api.SugarSession;
			e.printStackTrace();
			throw new SugarApiException("Could not fetch bean.", e);
		}
		catch (final Exception e)
		{
			e.printStackTrace();
			throw new SugarApiException("Could not fetch bean.", e);
		}

		final GetEntryListResponse entryResp = this.json.fromJson(response, GetEntryListResponse.class);
		final SugarBeanReference[] entryList = entryResp.getEntryList();
		if (entryList == null)
		{
			final ErrorResponse error = this.json.fromJson(response, ErrorResponse.class);
			final SugarApiException ex = new SugarApiException(error.getName());
			ex.setDescription(error.getDescription());
			ex.setNumber(error.getNumber());
			throw ex;
		}

		final List<SugarEntity> result = new ArrayList<SugarEntity>(entryList.length);
		for (final SugarBeanReference ref : entryList)
		{
			result.add(getBean(session, moduleName, ref.getId()));
		}

		return result;
	}


// Path: src/main/java/com/sugarcrm/api/SugarApiException.java
// public class SugarApiException extends Exception {
//   
//   private static final long serialVersionUID = 1L;
//   
//   protected int number = 0;
//   protected String description = "";
// 
//   public SugarApiException(String message){
//     super(message);
//   }
// 
//   public SugarApiException(String message, Throwable rootCause){
//     super(message, rootCause);
//   }
//   
//   public void setNumber(int number) {
//     this.number = number;
//   }
//   
//   public void setDescription(String description) {
//     this.description = description;
//   }
//   
//   /**
//    * Error identifying number returned from server
//    * Zero value indicates a wrapped exception meaning you should check {@link Exception#getCause()} for more details.
//    * @return error number
//    */
//   public int getNumber() {
//     return number;
//   }
//   
//   public String getDescription() {
//     return description;
//   }
// 
// }
// 
// Path: src/main/java/com/sugarcrm/api/SugarCredentials.java
// public class SugarCredentials {
// 
// 	private String user_name;
// 	private String password;
// 	
// 	public SugarCredentials() throws SugarApiException{
// 		this(null, null);
// 	}
// 	
// 	public SugarCredentials(String userId, String plaintextPassword) throws SugarApiException{
// 	  this.user_name = userId;
// 	  if(plaintextPassword != null){
// 	    setPassword(plaintextPassword);
// 	  }
// 	}
// 	
// 	public void setPassword(String plaintextPassword) throws SugarApiException{
// 	  try {
// 	    this.password = Hex.encodeHexString(MessageDigest.getInstance("MD5").digest(plaintextPassword.getBytes()));
// 	  }catch(NoSuchAlgorithmException ex){
// 	    SugarApiException sae = new SugarApiException("Unable to generate Sugar password value because this JRE does not support MD5", ex);
// 	    throw sae;
// 	  }
// 	}
// 
// 	public String getUserName(){
// 		return user_name;
// 	}
// 	
// 	public String getEncodedPassword(){
// 		return password;
// 	}
// 	
// 
// }
// 
// Path: src/main/java/com/sugarcrm/api/SugarEntity.java
// public interface SugarEntity
// {
// 	String get(String fieldName);
// 
// 	ArrayList<HashMap<String, String>> getData();
// 
// 	Collection<String> getFieldNames();
// 
// 	String getId();
// 
// 	String getModuleName();
// 
// 	String set(String fieldName, String value);
// }
// 
// Path: src/main/java/com/sugarcrm/api/SugarSession.java
// public interface SugarSession {
// 	
//   public String getSessionID();
//   public User getUser();
// 
// }


// Path: src/main/java/com/sugarcrm/api/v4/impl/SugarApi.java
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import org.apache.commons.codec.EncoderException;
import org.apache.commons.codec.net.URLCodec;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.annotations.SerializedName;
import com.sugarcrm.api.SugarApiException;
import com.sugarcrm.api.SugarCredentials;
import com.sugarcrm.api.SugarEntity;
import com.sugarcrm.api.SugarSession;

			e.printStackTrace();
			throw new SugarApiException("Could not fetch bean.", e);
		}
		catch (final Exception e)
		{
			e.printStackTrace();
			throw new SugarApiException("Could not fetch bean.", e);
		}

		final GetEntryListResponse entryResp = this.json.fromJson(response, GetEntryListResponse.class);
		final SugarBeanReference[] entryList = entryResp.getEntryList();
		if (entryList == null)
		{
			final ErrorResponse error = this.json.fromJson(response, ErrorResponse.class);
			final SugarApiException ex = new SugarApiException(error.getName());
			ex.setDescription(error.getDescription());
			ex.setNumber(error.getNumber());
			throw ex;
		}

		final List<SugarEntity> result = new ArrayList<SugarEntity>(entryList.length);
		for (final SugarBeanReference ref : entryList)
		{
			result.add(getBean(session, moduleName, ref.getId()));
		}

		return result;
	}


	public SugarSession getSugarSession(final SugarCredentials credentials) throws SugarApiException