- From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
- Date: Thu, 17 Sep 2009 16:37:21 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/request In directory hutz:/tmp/cvs-serv2251/src/org/w3c/unicorn/request Modified Files: UploadRequest.java URIRequest.java Request.java DirectRequestGET.java RequestList.java DirectRequestPOST.java Log Message: removed lots of useless thrown exceptions Index: DirectRequestPOST.java =================================================================== RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/request/DirectRequestPOST.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- DirectRequestPOST.java 3 Sep 2009 16:43:19 -0000 1.3 +++ DirectRequestPOST.java 17 Sep 2009 16:37:19 -0000 1.4 @@ -15,7 +15,6 @@ import org.w3c.unicorn.contract.EnumInputMethod; import org.w3c.unicorn.input.DirectInputModule; -import org.w3c.unicorn.input.InputModule; import org.w3c.unicorn.response.Response; /** @@ -82,40 +81,30 @@ * odd error occurs */ protected DirectRequestPOST(final String sURL, - final String sInputParameterName, final InputModule aInputModule, - final String responseType) throws IOException { + final String sInputParameterName, DirectInputModule aInputModule, + final String responseType) { super(); - Request.logger.trace("Constructor"); - if (Request.logger.isDebugEnabled()) { - Request.logger.debug("URL : " + sURL + "."); - Request.logger.debug("Input parameter name : " - + sInputParameterName + "."); - Request.logger.debug("Input module : " + aInputModule + "."); - } - if (!(aInputModule instanceof DirectInputModule)) { - throw new IllegalArgumentException("InputModule : " - + aInputModule.toString() + "."); - } - this.mapOfParameter = new Hashtable<String, String>(); + logger.trace("Constructor"); + logger.debug("URL : " + sURL + "."); + logger.debug("Input parameter name : "+ sInputParameterName + "."); + logger.debug("Input module : " + aInputModule + "."); + mapOfParameter = new Hashtable<String, String>(); this.sURL = sURL; - this.addParameter(sInputParameterName, aInputModule.getStringContent()); - this.setResponseType(responseType); + addParameter(sInputParameterName, aInputModule.getStringContent()); + setResponseType(responseType); } @Override - public void addParameter(final String sName, final String sValue) - throws IOException { - Request.logger.trace("addParameter"); - if (Request.logger.isDebugEnabled()) { - Request.logger.debug("Name :" + sName + "."); - Request.logger.debug("Value :" + sValue + "."); - } - this.mapOfParameter.put(sName, sValue); + public void addParameter(final String sName, final String sValue) { + logger.trace("addParameter"); + logger.debug("Name :" + sName + "."); + logger.debug("Value :" + sValue + "."); + mapOfParameter.put(sName, sValue); } @Override public Response doRequest() throws Exception { - Request.logger.trace("doRequest"); + logger.trace("doRequest"); final URL aURL = new URL(sURL); this.aURLConnection = aURL.openConnection(); this.aURLConnection.setDoOutput(true); @@ -128,21 +117,19 @@ } for (final String sName : this.mapOfParameter.keySet()) { final String sValue = this.mapOfParameter.get(sName); - Request.logger.trace("addParameter"); - if (Request.logger.isDebugEnabled()) { - Request.logger.debug("Name :" + sName + "."); - Request.logger.debug("Value :" + sValue + "."); - } - Request.logger.debug("--"); - Request.logger.debug(this.sBoundary); - Request.logger.debug("\r\n"); - Request.logger.debug("Content-Disposition: form-data; name=\""); - Request.logger.debug(sName); - Request.logger.debug('"'); - Request.logger.debug("\r\n"); - Request.logger.debug("\r\n"); - Request.logger.debug(sValue); - Request.logger.debug("\r\n"); + logger.trace("addParameter"); + logger.debug("Name :" + sName + "."); + logger.debug("Value :" + sValue + "."); + logger.debug("--"); + logger.debug(this.sBoundary); + logger.debug("\r\n"); + logger.debug("Content-Disposition: form-data; name=\""); + logger.debug(sName); + logger.debug('"'); + logger.debug("\r\n"); + logger.debug("\r\n"); + logger.debug(sValue); + logger.debug("\r\n"); // boundary this.aOutputStream.write("--".getBytes()); this.aOutputStream.write(this.sBoundary.getBytes()); @@ -160,10 +147,10 @@ this.aOutputStream.write(sValue.getBytes()); this.aOutputStream.write("\r\n".getBytes()); } - Request.logger.debug("--"); - Request.logger.debug(this.sBoundary); - Request.logger.debug("--"); - Request.logger.debug("\r\n"); + logger.debug("--"); + logger.debug(this.sBoundary); + logger.debug("--"); + logger.debug("\r\n"); this.aOutputStream.write("--".getBytes()); this.aOutputStream.write(this.sBoundary.getBytes()); this.aOutputStream.write("--".getBytes()); @@ -177,7 +164,7 @@ @Override public EnumInputMethod getInputMethod() { - Request.logger.trace("getInputMethod"); + logger.trace("getInputMethod"); return EnumInputMethod.DIRECT; } Index: DirectRequestGET.java =================================================================== RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/request/DirectRequestGET.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- DirectRequestGET.java 3 Sep 2009 17:34:53 -0000 1.5 +++ DirectRequestGET.java 17 Sep 2009 16:37:19 -0000 1.6 @@ -6,13 +6,13 @@ import java.io.IOException; import java.io.InputStream; +import java.io.UnsupportedEncodingException; import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; import org.w3c.unicorn.contract.EnumInputMethod; import org.w3c.unicorn.input.DirectInputModule; -import org.w3c.unicorn.input.InputModule; import org.w3c.unicorn.response.Response; /** @@ -47,51 +47,44 @@ * odd error occured */ protected DirectRequestGET(final String sURL, - final String sInputParameterName, final InputModule aInputModule, - final String responseType) throws IOException { + final String sInputParameterName, DirectInputModule aInputModule, + final String responseType) { super(); - Request.logger.trace("Constructor"); - if (Request.logger.isDebugEnabled()) { - Request.logger.debug("URL : " + sURL + "."); - Request.logger.debug("Input parameter name : " - + sInputParameterName + "."); - Request.logger.debug("Input module : " + aInputModule + "."); - } - if (!(aInputModule instanceof DirectInputModule)) { - throw new IllegalArgumentException("InputModule : " - + aInputModule.toString() + "."); - } + logger.trace("Constructor"); + logger.debug("URL : " + sURL + "."); + logger.debug("Input parameter name : " + sInputParameterName + "."); + logger.debug("Input module : " + aInputModule + "."); this.sURL = sURL; - this.addParameter(sInputParameterName, aInputModule.getStringContent()); - this.setResponseType(responseType); + addParameter(sInputParameterName, aInputModule.getStringContent()); + setResponseType(responseType); } @Override - public void addParameter(final String sName, final String sValue) - throws IOException { - Request.logger.trace("addParameter"); - if (Request.logger.isDebugEnabled()) { - Request.logger.debug("Name :" + sName + "."); - Request.logger.debug("Value :" + sValue + "."); - } + public void addParameter(final String sName, final String sValue) { + logger.trace("addParameter"); + logger.debug("Name :" + sName + "."); + logger.debug("Value :" + sValue + "."); if (null == this.sParameter) { this.sParameter = ""; } else { this.sParameter += "&"; } - this.sParameter += sName + "=" - + URLEncoder.encode(sValue, "UTF-8"); - Request.logger.debug("Parameters : " + this.sParameter + "."); + try { + this.sParameter += sName + "=" + URLEncoder.encode(sValue, "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + logger.debug("Parameters : " + this.sParameter + "."); } @Override public Response doRequest() throws Exception { - Request.logger.trace("doRequest"); + logger.trace("doRequest"); final URL aURL; if (null == this.sParameter) { aURL = new URL(this.sURL); } else { - Request.logger.debug(this.sParameter); + logger.debug(this.sParameter); aURL = new URL(this.sURL + "?" + this.sParameter); } final URLConnection aURLConnection = aURL.openConnection(); @@ -104,7 +97,7 @@ @Override public EnumInputMethod getInputMethod() { - Request.logger.trace("getInputMethod"); + logger.trace("getInputMethod"); return EnumInputMethod.DIRECT; } Index: UploadRequest.java =================================================================== RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/request/UploadRequest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- UploadRequest.java 4 Sep 2009 15:49:48 -0000 1.4 +++ UploadRequest.java 17 Sep 2009 16:37:18 -0000 1.5 @@ -11,7 +11,6 @@ import java.util.Map; import org.w3c.unicorn.contract.EnumInputMethod; -import org.w3c.unicorn.input.InputModule; import org.w3c.unicorn.input.UploadInputModule; import org.w3c.unicorn.response.Response; import org.w3c.unicorn.util.ClientHttpRequest; @@ -65,21 +64,13 @@ * odd error occured */ protected UploadRequest(final String sURL, - final String sInputParameterName, final InputModule aInputModule, - final String responseType) throws MalformedURLException, - IOException { + final String sInputParameterName, final UploadInputModule aInputModule, + final String responseType) { super(); - Request.logger.trace("Constructor"); - if (Request.logger.isDebugEnabled()) { - Request.logger.debug("URL : " + sURL + "."); - Request.logger.debug("Input parameter name : " - + sInputParameterName + "."); - Request.logger.debug("Input module : " + aInputModule + "."); - } - if (!(aInputModule instanceof UploadInputModule)) { - throw new IllegalArgumentException("InputModule : " - + aInputModule.toString() + "."); - } + logger.trace("Constructor"); + logger.debug("URL : " + sURL + "."); + logger.debug("Input parameter name : " + sInputParameterName + "."); + logger.debug("Input module : " + aInputModule + "."); this.sURL = sURL; this.sInputParameterName = sInputParameterName; this.aUploadInputModule = (UploadInputModule) aInputModule; @@ -88,21 +79,18 @@ } @Override - public void addParameter(final String sName, final String sValue) - throws IOException { - Request.logger.trace("addParameter"); - if (Request.logger.isDebugEnabled()) { - Request.logger.debug("Name :" + sName + "."); - Request.logger.debug("Value :" + sValue + "."); - } + public void addParameter(final String sName, final String sValue) { + logger.trace("addParameter"); + logger.debug("Name :" + sName + "."); + logger.debug("Value :" + sValue + "."); this.mapOfParameter.put(sName, sValue); } @Override public Response doRequest() throws Exception { - Request.logger.trace("doRequest"); + logger.trace("doRequest"); this.aClientHttpRequest = new ClientHttpRequest(sURL); - Request.logger.debug("Lang : " + this.sLang + "."); + logger.debug("Lang : " + this.sLang + "."); this.aClientHttpRequest.setLang(sLang); this.aClientHttpRequest.setParameter(this.sInputParameterName, this.aUploadInputModule.getFileName(), @@ -110,11 +98,9 @@ this.aUploadInputModule.getMimeType()); for (final String sName : this.mapOfParameter.keySet()) { final String sValue = this.mapOfParameter.get(sName); - Request.logger.trace("addParameter"); - if (Request.logger.isDebugEnabled()) { - Request.logger.debug("Name :" + sName + "."); - Request.logger.debug("Value :" + sValue + "."); - } + logger.trace("addParameter"); + logger.debug("Name :" + sName + "."); + logger.debug("Value :" + sValue + "."); this.aClientHttpRequest.setParameter(sName, sValue); } InputStream is = this.aClientHttpRequest.post(); @@ -124,7 +110,7 @@ @Override public EnumInputMethod getInputMethod() { - Request.logger.trace("getInputMethod"); + logger.trace("getInputMethod"); return EnumInputMethod.UPLOAD; } Index: RequestList.java =================================================================== RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/request/RequestList.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- RequestList.java 28 Aug 2009 12:39:48 -0000 1.2 +++ RequestList.java 17 Sep 2009 16:37:19 -0000 1.3 @@ -34,7 +34,7 @@ * language of the list */ public RequestList(final String sLang) { - RequestList.logger.debug("Lang : " + sLang + "."); + logger.debug("Lang : " + sLang + "."); this.sLang = sLang; } @@ -49,7 +49,7 @@ * @return */ public Map<String, Request> getRequestMap() { - RequestList.logger.trace("getRequestMap"); + logger.trace("getRequestMap"); return this.mapOfRequest; } @@ -61,10 +61,8 @@ * @return */ public Request getRequest(final String sNodeID) { - RequestList.logger.trace("getRequest"); - if (RequestList.logger.isDebugEnabled()) { - RequestList.logger.debug("Observer ID : " + sNodeID + "."); - } + logger.trace("getRequest"); + logger.debug("Observer ID : " + sNodeID + "."); return this.mapOfRequest.get(sNodeID); } @@ -77,14 +75,10 @@ * @throws IOException */ - public void addRequest(final Request aRequest, final String sNodeID) - throws IOException { - - RequestList.logger.trace("addRequest"); - if (RequestList.logger.isDebugEnabled()) { - RequestList.logger.debug("Request : " + aRequest + "."); - RequestList.logger.debug("String node ID : " + sNodeID + "."); - } + public void addRequest(final Request aRequest, final String sNodeID) { + logger.trace("addRequest"); + logger.debug("Request : " + aRequest + "."); + logger.debug("String node ID : " + sNodeID + "."); aRequest.setLang(this.sLang); this.mapOfRequest.put(sNodeID, aRequest); } Index: URIRequest.java =================================================================== RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/request/URIRequest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- URIRequest.java 9 Sep 2009 12:09:38 -0000 1.4 +++ URIRequest.java 17 Sep 2009 16:37:18 -0000 1.5 @@ -12,7 +12,6 @@ import java.net.URLEncoder; import org.w3c.unicorn.contract.EnumInputMethod; -import org.w3c.unicorn.input.InputModule; import org.w3c.unicorn.input.URIInputModule; import org.w3c.unicorn.response.Response; @@ -48,20 +47,16 @@ * odd error occured */ public URIRequest(final String sURL, final String sInputParameterName, - final InputModule aInputModule, final String responseType) - throws IOException { + URIInputModule aInputModule, final String responseType) { super(); - Request.logger.trace("Constructor"); - if (Request.logger.isDebugEnabled()) { - Request.logger.debug("URL : " + sURL + "."); - Request.logger.debug("Input parameter name : " - + sInputParameterName + "."); - Request.logger.debug("Input module : " + aInputModule + "."); - } - if (!(aInputModule instanceof URIInputModule)) { + logger.trace("Constructor"); + logger.debug("URL : " + sURL + "."); + logger.debug("Input parameter name : " + sInputParameterName + "."); + logger.debug("Input module : " + aInputModule + "."); + /*if (!(aInputModule instanceof URIInputModule)) { throw new IllegalArgumentException("InputModule : " + aInputModule.toString() + "."); - } + }*/ this.sURL = sURL; final URIInputModule aURIInputModule = (URIInputModule) aInputModule; this.addParameter(sInputParameterName, aURIInputModule.getURI()); @@ -77,20 +72,21 @@ * value of the parameter to add */ @Override - public void addParameter(final String sName, final String sValue) - throws UnsupportedEncodingException { - Request.logger.trace("addParameter"); - if (Request.logger.isDebugEnabled()) { - Request.logger.debug("sName : " + sName + "."); - Request.logger.debug("sValue : " + sValue + "."); - } + public void addParameter(final String sName, final String sValue) { + logger.trace("addParameter"); + logger.debug("sName : " + sName + "."); + logger.debug("sValue : " + sValue + "."); if (null == this.sParameter) { this.sParameter = ""; } else { this.sParameter += "&"; } - this.sParameter += sName + "=" + URLEncoder.encode(sValue, "UTF-8"); - Request.logger.debug("Parameters : " + this.sParameter + "."); + try { + this.sParameter += sName + "=" + URLEncoder.encode(sValue, "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + logger.debug("Parameters : " + this.sParameter + "."); } /** @@ -99,19 +95,17 @@ */ @Override public Response doRequest() throws Exception { - Request.logger.trace("doRequest"); - if (Request.logger.isDebugEnabled()) { - Request.logger.debug("URL : " + this.sURL + " ."); - Request.logger.debug("Parameters : " + this.sParameter + " ."); - } + logger.trace("doRequest"); + logger.debug("URL : " + this.sURL + " ."); + logger.debug("Parameters : " + this.sParameter + " ."); final URL aURL; if (null == this.sParameter) { aURL = new URL(this.sURL); } else { - Request.logger.debug(this.sParameter); + logger.debug(this.sParameter); aURL = new URL(this.sURL + "?" + this.sParameter); } - Request.logger.debug("URL : " + aURL + " ."); + logger.debug("URL : " + aURL + " ."); final URLConnection aURLConnection = aURL.openConnection(); aURLConnection.setRequestProperty("Accept-Language", this.sLang); @@ -125,7 +119,7 @@ @Override public EnumInputMethod getInputMethod() { - Request.logger.trace("getInputMethod"); + logger.trace("getInputMethod"); return EnumInputMethod.URI; } Index: Request.java =================================================================== RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/request/Request.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Request.java 3 Sep 2009 17:07:46 -0000 1.4 +++ Request.java 17 Sep 2009 16:37:19 -0000 1.5 @@ -11,7 +11,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.w3c.unicorn.contract.EnumInputMethod; +import org.w3c.unicorn.input.DirectInputModule; import org.w3c.unicorn.input.InputModule; +import org.w3c.unicorn.input.URIInputModule; +import org.w3c.unicorn.input.UploadInputModule; import org.w3c.unicorn.response.Response; import org.w3c.unicorn.response.parser.ResponseParserFactory; @@ -43,8 +46,8 @@ * @throws IOException * odd error occured */ - public void setLang(final String sLang) throws IOException { - Request.logger.debug("setLang(" + sLang + ")"); + public void setLang(final String sLang) { + logger.debug("setLang(" + sLang + ")"); this.sLang = sLang; } @@ -58,8 +61,7 @@ * @throws IOException * odd error occured */ - public abstract void addParameter(final String sName, final String sValue) - throws IOException; + public abstract void addParameter(final String sName, final String sValue); /** * Do the request to the observer @@ -93,32 +95,28 @@ */ public static Request createRequest(final InputModule aInputModule, final String sURL, final String sInputParameterName, - final boolean bIsPost, final String responseType) - throws IOException { + final boolean bIsPost, final String responseType) { - Request.logger.trace("createRequest"); - if (Request.logger.isDebugEnabled()) { - Request.logger.debug("InputModule : " + aInputModule + "."); - Request.logger.debug("URL : " + sURL + "."); - Request.logger.debug("Input parameter name : " - + sInputParameterName + "."); - Request.logger.debug("POST method : " + bIsPost + "."); - } + logger.trace("createRequest"); + logger.debug("InputModule : " + aInputModule + "."); + logger.debug("URL : " + sURL + "."); + logger.debug("Input parameter name : " + sInputParameterName + "."); + logger.debug("POST method : " + bIsPost + "."); switch (aInputModule.getEnumInputMethod()) { case DIRECT: if (bIsPost) { - return new DirectRequestPOST(sURL, sInputParameterName, - aInputModule, responseType); + return new DirectRequestPOST(sURL, sInputParameterName, + (DirectInputModule) aInputModule, responseType); } else { return new DirectRequestGET(sURL, sInputParameterName, - aInputModule, responseType); + (DirectInputModule) aInputModule, responseType); } case UPLOAD: - return new UploadRequest(sURL, sInputParameterName, aInputModule, - responseType); + return new UploadRequest(sURL, sInputParameterName, + (UploadInputModule) aInputModule, responseType); case URI: - return new URIRequest(sURL, sInputParameterName, aInputModule, - responseType); + return new URIRequest(sURL, sInputParameterName, + (URIInputModule) aInputModule, responseType); } return null; }
Received on Thursday, 17 September 2009 16:37:38 UTC