Changeset 9392 for extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/session/SessionManager.java
- Timestamp:
- Feb 27, 2011, 1:38:04 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/session/SessionManager.java
r9387 r9392 18 18 19 19 import fr.mael.jiwigo.transverse.enumeration.MethodsEnum; 20 import fr.mael.jiwigo.transverse.util. Outil;20 import fr.mael.jiwigo.transverse.util.Tools; 21 21 22 22 /* … … 65 65 * the entered password 66 66 */ 67 private String motDePasse;67 private String password; 68 68 /** 69 69 * the url of the site … … 103 103 * true : an error was found for the proxy 104 104 */ 105 private boolean erreurProxy;105 private boolean proxyError; 106 106 107 107 /** 108 108 * Constructor 109 109 * @param login the login 110 * @param motDePassethe password110 * @param password the password 111 111 * @param url the url of the site 112 112 */ 113 public SessionManager(String login, String motDePasse, String url) {113 public SessionManager(String login, String password, String url) { 114 114 this.login = login; 115 this. motDePasse = motDePasse;115 this.password = password; 116 116 this.url = url + "/ws.php"; 117 117 MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); … … 140 140 } 141 141 try { 142 doc = execute rReturnDocument(MethodsEnum.LOGIN.getLabel(), "username", login, "password", motDePasse);143 return Outil.checkOk(doc);142 doc = executeReturnDocument(MethodsEnum.LOGIN.getLabel(), "username", login, "password", password); 143 return Tools.checkOk(doc); 144 144 } catch (Exception e) { 145 LOG.error( Outil.getStackTrace(e));145 LOG.error(Tools.getStackTrace(e)); 146 146 } 147 147 return false; … … 155 155 * @throws UnsupportedEncodingException 156 156 */ 157 public String execute rReturnString(String methode, String... parametres) throws UnsupportedEncodingException {157 public String executeReturnString(String methode, String... parametres) throws UnsupportedEncodingException { 158 158 if (parametres.length % 2 != 0 && !(parametres == null)) { 159 159 try { 160 160 throw new Exception("Le nombre de parametres doit etre pair"); 161 161 } catch (Exception e) { 162 LOG.error( Outil.getStackTrace(e));162 LOG.error(Tools.getStackTrace(e)); 163 163 return null; 164 164 } … … 180 180 // System.out.println(Outil.readInputStreamAsString(streamResponse)); 181 181 // String toReturn = method.getResponseBodyAsString(); 182 String toReturn = Outil.readInputStreamAsString(streamResponse);182 String toReturn = Tools.readInputStreamAsString(streamResponse); 183 183 LOG.debug(toReturn); 184 184 return toReturn; 185 185 } catch (HttpException e) { 186 186 // TODO Auto-generated catch block 187 LOG.error( Outil.getStackTrace(e));187 LOG.error(Tools.getStackTrace(e)); 188 188 } catch (IOException e) { 189 189 // TODO Auto-generated catch block 190 LOG.error( Outil.getStackTrace(e));190 LOG.error(Tools.getStackTrace(e)); 191 191 } catch (IllegalArgumentException e) { 192 LOG.error( Outil.getStackTrace(e));192 LOG.error(Tools.getStackTrace(e)); 193 193 } finally { 194 194 method.releaseConnection(); … … 205 205 * @throws IOException 206 206 */ 207 public Document execute rReturnDocument(String methode, String... parametres) throws IOException {207 public Document executeReturnDocument(String methode, String... parametres) throws IOException { 208 208 try { 209 return Outil.stringToDocument(executerReturnString(methode, parametres));209 return Tools.stringToDocument(executeReturnString(methode, parametres)); 210 210 } catch (JDOMException e) { 211 211 // TODO Auto-generated catch block 212 LOG.error( Outil.getStackTrace(e));212 LOG.error(Tools.getStackTrace(e)); 213 213 } 214 214 return null; … … 221 221 * @return the result 222 222 */ 223 public Document execute rReturnDocument(String methode) {223 public Document executeReturnDocument(String methode) { 224 224 try { 225 return Outil.stringToDocument(executerReturnString(methode));225 return Tools.stringToDocument(executeReturnString(methode)); 226 226 } catch (JDOMException e) { 227 227 // TODO Auto-generated catch block 228 LOG.error( Outil.getStackTrace(e));228 LOG.error(Tools.getStackTrace(e)); 229 229 } catch (IOException e) { 230 230 // TODO Auto-generated catch block 231 LOG.error( Outil.getStackTrace(e));231 LOG.error(Tools.getStackTrace(e)); 232 232 } 233 233 return null; … … 250 250 251 251 /** 252 * @return the motDePasse253 */254 public String getMotDePasse() {255 return motDePasse;256 }257 258 /**259 * @param motDePasse the motDePasse to set260 */261 public void setMotDePasse(String motDePasse) {262 this.motDePasse = motDePasse;263 }264 265 /**266 252 * @return the url 267 253 */ … … 312 298 } 313 299 314 /** 315 * @return the erreurProxy 316 */ 317 public boolean isErreurProxy() { 318 return erreurProxy; 300 public String getPassword() { 301 return password; 302 } 303 304 public void setPassword(String password) { 305 this.password = password; 306 } 307 308 public boolean isProxyError() { 309 return proxyError; 310 } 311 312 public void setProxyError(boolean proxyError) { 313 this.proxyError = proxyError; 319 314 } 320 315
Note: See TracChangeset
for help on using the changeset viewer.