diff --git a/pom.xml b/pom.xml index 089ef55..d11ef88 100644 --- a/pom.xml +++ b/pom.xml @@ -42,9 +42,14 @@ - org.apache.httpcomponents - httpclient - ${commons-httpclient.version} + commons-httpclient + commons-httpclient + 3.1 + + + org.apache.ant + ant + 1.9.4 @@ -58,6 +63,11 @@ javax.activation-api 1.2.0 + + javax.mail + mail + 1.4 + @@ -123,7 +133,6 @@ 4.5.13 - 30.1.1-jre diff --git a/src/main/java/org/realtor/rets/retsapi/RETSConnection.java b/src/main/java/org/realtor/rets/retsapi/RETSConnection.java index b932bc7..79be8cc 100644 --- a/src/main/java/org/realtor/rets/retsapi/RETSConnection.java +++ b/src/main/java/org/realtor/rets/retsapi/RETSConnection.java @@ -5,12 +5,13 @@ */ package org.realtor.rets.retsapi; -import com.aftexsw.util.bzip.CBZip2InputStream; +//import com.aftexsw.util.bzip.CBZip2InputStream; + +import ch.qos.logback.classic.BasicConfigurator; import org.apache.commons.httpclient.*; import org.apache.commons.httpclient.cookie.CookiePolicy; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.methods.PostMethod; -import org.apache.log4j.BasicConfigurator; import org.realtor.rets.util.RETSConfigurator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -130,7 +131,7 @@ public class RETSConnection extends java.lang.Object { log = new PrintWriter(new FileWriter(outFile)); log.println(""); } catch (Exception e) { - cat.error("could create output file :" + outFile); + logger.error("could create output file :" + outFile); } } @@ -191,7 +192,7 @@ public class RETSConnection extends java.lang.Object { } } - cat.debug(msg); + logger.debug(msg); } private void writeMapToTransactionLog(Map map) { @@ -292,7 +293,7 @@ public class RETSConnection extends java.lang.Object { HttpMethod method = null; - cat.debug("getURLContent: URL=" + strURL); + logger.debug("getURLContent: URL=" + strURL); try { if (requestMethod.equalsIgnoreCase("GET")) { @@ -427,10 +428,10 @@ public class RETSConnection extends java.lang.Object { try { serverUrl = transaction.getUrl(); - cat.debug(transaction.getRequestType() + " URL : {" + serverUrl + "}"); + logger.debug(transaction.getRequestType() + " URL : {" + serverUrl + "}"); if (serverUrl == null) { - cat.error(transaction.getRequestType() + " URL is null"); + logger.error(transaction.getRequestType() + " URL is null"); transaction.setResponseStatus("20036"); transaction.setResponseStatusText(transaction.getRequestType() + " URL is missing. Successful login is required."); return; // throw exception here @@ -442,7 +443,7 @@ public class RETSConnection extends java.lang.Object { if (transaction.getRequestType().equalsIgnoreCase("Action")) { method = "GET"; } - cat.debug("method: " + method); + logger.debug("method: " + method); InputStream is = getURLContent(serverUrl, method, transaction.getRequestMap()); @@ -458,7 +459,7 @@ public class RETSConnection extends java.lang.Object { Object compressionFmt = responseHeaderMap.get("Content-Encoding"); if (compressionFmt != null) { - cat.debug("Header class : " + compressionFmt.getClass().getName()); + logger.debug("Header class : " + compressionFmt.getClass().getName()); if (compressionFmt.toString().equalsIgnoreCase("[gzip]")) { gzipCompressed = true; @@ -470,7 +471,7 @@ public class RETSConnection extends java.lang.Object { if (gzipCompressed) { is = new GZIPInputStream(is); } else if (bzipCompressed) { - is = new CBZip2InputStream(is); +// is = new CBZip2InputStream(is); } } this.writeToTransactionLog(""); @@ -568,7 +569,7 @@ public class RETSConnection extends java.lang.Object { * @param args the command line arguments */ public static void main(String[] args) { - BasicConfigurator.configure(); +// BasicConfigurator.configure(); RETSConnection rc = new RETSConnection(); RETSLoginTransaction trans = new RETSLoginTransaction(); @@ -612,7 +613,7 @@ public class RETSConnection extends java.lang.Object { } String reqStr = key + "=" + URLEncoder.encode((String) requestMap.get(key)); - cat.debug(reqStr); + logger.debug(reqStr); sb.append(reqStr); if (it.hasNext()) { diff --git a/src/main/java/org/realtor/rets/retsapi/RETSGetObjectTransaction.java b/src/main/java/org/realtor/rets/retsapi/RETSGetObjectTransaction.java index 590b041..581ef5c 100644 --- a/src/main/java/org/realtor/rets/retsapi/RETSGetObjectTransaction.java +++ b/src/main/java/org/realtor/rets/retsapi/RETSGetObjectTransaction.java @@ -1,18 +1,17 @@ package org.realtor.rets.retsapi; -import org.apache.log4j.Category; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import java.io.IOException; -import java.io.InputStream; - -import java.util.Iterator; -import java.util.Collection; -import java.util.ArrayList; - -import javax.mail.internet.MimeMultipart; +import javax.mail.MessagingException; import javax.mail.internet.InternetHeaders; import javax.mail.internet.MimeBodyPart; -import javax.mail.MessagingException; +import javax.mail.internet.MimeMultipart; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; /** * RETSGetObjectTransaction.java @@ -34,7 +33,7 @@ public class RETSGetObjectTransaction extends RETSTransaction * send back only the location of the resource by calling {@link #setLocation}. */ - static Category cat = Category.getInstance(RETSGetObjectTransaction.class); + private final static Logger logger = LoggerFactory.getLogger(RETSLoginTransaction.class); // collection of body parts resulting from the collision of the server response with the MIME parsing code. // protected Collection fBodyParts; protected ArrayList parts; @@ -63,7 +62,7 @@ public class RETSGetObjectTransaction extends RETSTransaction * @param str resource value */ public void setResource(String str) { - cat.debug("set Resource=" + str); + logger.debug("set Resource=" + str); setRequestVariable("Resource", str); } @@ -73,7 +72,7 @@ public class RETSGetObjectTransaction extends RETSTransaction * @param type type attribute value */ public void setType(String str) { - cat.debug("set Type=" + str); + logger.debug("set Type=" + str); setRequestVariable("Type", str); } @@ -84,10 +83,10 @@ public class RETSGetObjectTransaction extends RETSTransaction */ public void setID(String str) { if ( str != null ) { - cat.debug("set ID=" + str.trim()); + logger.debug("set ID=" + str.trim()); setRequestVariable("ID", str.trim()); } else { - cat.debug("set ID=" + str); + logger.debug("set ID=" + str); } } @@ -97,7 +96,7 @@ public class RETSGetObjectTransaction extends RETSTransaction * @param str location attribute value */ public void setLocation(String str) { - cat.debug("set Location=" + str); + logger.debug("set Location=" + str); setRequestVariable("Location", str); } @@ -133,13 +132,13 @@ public class RETSGetObjectTransaction extends RETSTransaction String mimeType; // String contentType = responseHeaderNamed("content-type"); String contentType = super.getResponseHeader("Content-Type"); - cat.debug("====[RETSGetObjectTx] --> " + contentType); + logger.debug("====[RETSGetObjectTx] --> " + contentType); int contentTypeSemicolonIndex = contentType == null ? -1 : contentType.indexOf(";"); // If there was no Content-Type header, we can't do anything here. Punt to the default handler. if (contentType == null) { - cat.debug("====[RETSGetObjectTx] : NO CONTENT TYPE"); + logger.debug("====[RETSGetObjectTx] : NO CONTENT TYPE"); super.setResponseStream(responseStream); return; } @@ -150,7 +149,7 @@ public class RETSGetObjectTransaction extends RETSTransaction else mimeType = contentType.trim(); - cat.debug("====[RETSGetObjectTx] : mime-type -> " + mimeType); + logger.debug("====[RETSGetObjectTx] : mime-type -> " + mimeType); // If the type is text/xml, then this is probably an error response. // We need to parse the input stream nondestructively to find out. @@ -158,7 +157,7 @@ public class RETSGetObjectTransaction extends RETSTransaction handleXMLStream(responseStream, mimeType, contentType); } else if (mimeType.startsWith("multipart/")) { // If it's multipart, take it apart and set up appropriate data structures. - cat.debug("====[RETSGetObjectTx] : RECIEVED MULTIPART"); + logger.debug("====[RETSGetObjectTx] : RECIEVED MULTIPART"); handleMultipartStream(responseStream, mimeType, contentType); } else { // Otherwise, since we do have a MIME type, assume that the response *is* object value. @@ -228,7 +227,7 @@ public class RETSGetObjectTransaction extends RETSTransaction setResponseStatus("0"); } catch (MessagingException messagingException) { if (responseStreamDataSource != null) - cat.debug(responseStreamDataSource.bufferedDataAsString()); + logger.debug(responseStreamDataSource.bufferedDataAsString()); // System.out.println(responseStreamDataSource.bufferedDataAsString()); messagingException.printStackTrace(); @@ -338,7 +337,7 @@ public class RETSGetObjectTransaction extends RETSTransaction if ( part != null ) { Object content = part.getContent(); inputStream = (InputStream) content; - cat.debug("--- MimeBodyPart Content--> " + content); + logger.debug("--- MimeBodyPart Content--> " + content); } } catch (Exception e) { e.printStackTrace();