USRE-84 submit all API to repo and ready for testing
This commit is contained in:
parent
e2d2983aa7
commit
6fab43d9bc
17
pom.xml
17
pom.xml
|
@ -42,9 +42,14 @@
|
|||
|
||||
<!-- APACHE COMMONS -->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>${commons-httpclient.version}</version>
|
||||
<groupId>commons-httpclient</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
<version>3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.ant</groupId>
|
||||
<artifactId>ant</artifactId>
|
||||
<version>1.9.4</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
@ -58,6 +63,11 @@
|
|||
<artifactId>javax.activation-api</artifactId>
|
||||
<version>1.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>mail</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
|
||||
<!-- TESTS -->
|
||||
<dependency>
|
||||
|
@ -123,7 +133,6 @@
|
|||
<commons-httpclient.version>4.5.13</commons-httpclient.version>
|
||||
|
||||
|
||||
|
||||
<!-- UTILS -->
|
||||
<guava.version>30.1.1-jre</guava.version>
|
||||
|
||||
|
|
|
@ -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("<!-- RETS REQUEST -->");
|
||||
} 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("<!-- Obtained and Identified Response Stream -->");
|
||||
|
@ -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()) {
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue