Skip to content

Commit

Permalink
SapienzaBioHandler: Tentative changes to photo retrieval in getStuden…
Browse files Browse the repository at this point in the history
…tPhoto()
  • Loading branch information
leosarra committed Jul 26, 2019
1 parent c252997 commit 5f116d7
Showing 1 changed file with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import org.apache.commons.io.IOUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
Expand All @@ -22,7 +21,6 @@

import javax.net.ssl.SSLException;
import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
Expand Down Expand Up @@ -263,12 +261,8 @@ private byte[] _getStudentPhoto(Student student) throws OpenstudInvalidResponseE
Response resp = os.getClient().newCall(req).execute();
if (resp.body() == null) throw new OpenstudInvalidResponseException("Infostud answer is not valid");
ResponseBody body = resp.body();
os.log(Level.INFO, body);
if (body == null) return null;
InputStream inputStream = body.byteStream();
byte[] ret = IOUtils.toByteArray(inputStream);
inputStream.close();
return ret;
return body.string().getBytes();
} catch (IOException e) {
if (e instanceof SSLException) {
OpenstudInvalidResponseException invalidResponseException = new OpenstudInvalidResponseException(e);
Expand Down Expand Up @@ -316,9 +310,9 @@ private StudentCard _getStudentCard(Student student) throws OpenstudInvalidRespo
Response resp = os.getClient().newCall(req).execute();
if (resp.body() == null) throw new OpenstudInvalidResponseException("Infostud answer is not valid");
ResponseBody body = resp.body();
os.log(Level.INFO, body);
if (body == null) return null;
String stringBody = body.string();
os.log(Level.INFO, stringBody);
JSONObject response = new JSONObject(stringBody);
if (!response.has("ritorno"))
throw new OpenstudInvalidResponseException("Infostud response is not valid. I guess the token is no longer valid");
Expand Down

0 comments on commit 5f116d7

Please sign in to comment.