From 820d7492d26fb6e5cf0f934ba4099a1abdd2f04f Mon Sep 17 00:00:00 2001 From: coderfengyun Date: Thu, 20 Mar 2014 11:35:59 +0800 Subject: [PATCH] clean up --- pom.xml | 2 +- .../web/service/CommunicateWithMaster.java | 31 +++--- src/main/webapp/index.jsp | 41 ++++++- .../test/AuthorizeActionControllerTest.java | 105 +++++++++--------- 4 files changed, 107 insertions(+), 72 deletions(-) diff --git a/pom.xml b/pom.xml index cfc39409..6d3a94c4 100644 --- a/pom.xml +++ b/pom.xml @@ -148,7 +148,7 @@ bench4q-share 0.0.1-SNAPSHOT - + commons-fileupload commons-fileupload 1.2 diff --git a/src/main/java/org/bench4q/web/service/CommunicateWithMaster.java b/src/main/java/org/bench4q/web/service/CommunicateWithMaster.java index 001fe5f1..084aa093 100644 --- a/src/main/java/org/bench4q/web/service/CommunicateWithMaster.java +++ b/src/main/java/org/bench4q/web/service/CommunicateWithMaster.java @@ -34,7 +34,8 @@ public class CommunicateWithMaster { private final String BADHTTPRESPONSE = "bad response"; private static final Properties prop = new Properties(); private static final String CONFIG_FILE_NAME = "ipConfig.properties"; - private static String masterAddress=""; + private static String masterAddress = ""; + private HttpRequester getHttpRequester() { return httpRequester; } @@ -44,15 +45,15 @@ public class CommunicateWithMaster { this.httpRequester = httpRequester; } - public static String getMasterAddress(){ + public static String getMasterAddress() { return masterAddress; } - private String addMaseterAddressToUrl(String url){ - return masterAddress+url; - } - - static{ + private String addMaseterAddressToUrl(String url) { + return masterAddress + url; + } + + static { String masterIpFilePath; try { masterIpFilePath = BaseControllerService.class.getClassLoader() @@ -62,20 +63,18 @@ public class CommunicateWithMaster { masterIpFilePath)); prop.load(inputStream); inputStream.close(); - masterAddress = prop.getProperty("masterAddress") ; - } catch (URISyntaxException e1) { - e1.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); + masterAddress = prop.getProperty("masterAddress"); + } catch (Exception e1) { + masterAddress = "133.133.12.1:7979"; } } - + public Object getRespnseObjectByPostXml(String accessToken, String url, Class objectClass, String content, String caller) throws CustomGenericException { try { - url=this.addMaseterAddressToUrl(url); + url = this.addMaseterAddressToUrl(url); HttpResponse httpResponse = this.getHttpRequester().sendPostXml( url, content, this.makeAccessTockenMap(accessToken)); if (HttpRequester.isInvalidResponse(httpResponse)) { @@ -114,7 +113,7 @@ public class CommunicateWithMaster { Class objectClass, Map params, String caller) throws CustomGenericException { try { - url=this.addMaseterAddressToUrl(url); + url = this.addMaseterAddressToUrl(url); HttpResponse httpResponse = this.getHttpRequester().sendGet(url, params, this.makeAccessTockenMap(accessToken)); if (HttpRequester.isInvalidResponse(httpResponse)) { @@ -153,7 +152,7 @@ public class CommunicateWithMaster { String content, Class objectClass, String caller) throws CustomGenericException { try { - url=this.addMaseterAddressToUrl(url); + url = this.addMaseterAddressToUrl(url); HttpResponse httpResponse = this.getHttpRequester().sendPutXml(url, content, this.makeAccessTockenMap(accessToken)); if (HttpRequester.isInvalidResponse(httpResponse)) { diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index 0c20522a..fc659b6c 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -12,8 +12,7 @@ -