Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
salimkanoun authored Feb 2, 2018
1 parent ce4c7bc commit 16973b7
Showing 1 changed file with 32 additions and 13 deletions.
45 changes: 32 additions & 13 deletions src/org/petctviewer/ParametreConnexionHttp.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public ParametreConnexionHttp() {
int typeDb = jprefer.getInt("db type" + curDb, 0);
String ip=null;
String port=null;
boolean test=false;

if(typeDb == 5){

Expand All @@ -75,15 +76,36 @@ public ParametreConnexionHttp() {
if(jprefer.get("db user" + curDb, null) != null && jprefer.get("db pass" + curDb, null) != null){
authentication = Base64.getEncoder().encodeToString((jprefer.get("db user" + curDb, null) + ":" + jprefer.get("db pass" + curDb, null)).getBytes());
}
}else{
test=testConnexion();
}
else if (typeDb != 5){
ip = jpreferPerso.get("ip", "http://localhost");
port = jpreferPerso.get("port", "8042");
this.fullAddress = ip + ":" + port;
if(jpreferPerso.get("username", null) != null && jpreferPerso.get("username", null) != null){
authentication = Base64.getEncoder().encodeToString((jpreferPerso.get("username", null) + ":" + jpreferPerso.get("password", null)).getBytes());
}
test=testConnexion();

}

//Si Echec de la connexion defini dans le registery on retente avec les parametres manuels
if (!test && typeDb == 5) {
ip = jpreferPerso.get("ip", "http://localhost");
port = jpreferPerso.get("port", "8042");
this.fullAddress = ip + ":" + port;
if(jpreferPerso.get("username", null) != null && jpreferPerso.get("username", null) != null){
authentication = Base64.getEncoder().encodeToString((jpreferPerso.get("username", null) + ":" + jpreferPerso.get("password", null)).getBytes());
}
test=testConnexion();
}

//Si Toujours echec on signal et on demande d'ouvrir le panneau
if (!test) {
JOptionPane.showMessageDialog(null,"Check Connexion Parameters","Connexion",JOptionPane.ERROR_MESSAGE);
ConnectionSetup.main();
}
testConnexion();


}

Expand Down Expand Up @@ -228,20 +250,17 @@ private int ordinalIndexOf(String str, String substr, int n) {
}

// Display Error message if connexion failed
private void testConnexion(){
private boolean testConnexion(){
boolean test=true;
try {
HttpURLConnection conn = makeGetConnection("/system");
conn.getResponseMessage();
HttpURLConnection conn = makeGetConnection("/system");
conn.getResponseMessage();
} catch (IOException e2) {
e2.printStackTrace();
System.out.println("ici");
JOptionPane.showMessageDialog(null,
"Check Connexion Parameters",
"Connexion",
JOptionPane.ERROR_MESSAGE);
ConnectionSetup.main();
test=false;
//JOptionPane.showMessageDialog(null,"Check Connexion Parameters","Connexion",JOptionPane.ERROR_MESSAGE);
//ConnectionSetup.main();
}
return test;
}


Expand Down

0 comments on commit 16973b7

Please sign in to comment.