AttivitaDidattica getRelatedCorso() { mProtocolCarrier = new ProtocolCarrier(taskcontext, SmartUniDataWS.TOKEN_NAME); MessageRequest request = new MessageRequest( SmartUniDataWS.URL_WS_SMARTUNI, SmartUniDataWS.GET_WS_COURSES_DETAILS(GDS.getCorso())); request.setMethod(Method.GET); MessageResponse response; String body = null; try { response = mProtocolCarrier.invokeSync( request, SmartUniDataWS.TOKEN_NAME, MyUniActivity.getAuthToken()); if (response.getHttpStatus() == 200) { body = response.getBody(); } else { return null; } } catch (ConnectionException e) { e.printStackTrace(); } catch (ProtocolException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (AACException e) { e.printStackTrace(); } return Utils.convertJSONToObject(body, AttivitaDidattica.class); }
private boolean abandonGDS(GruppoDiStudio gds_to_abandon) { mProtocolCarrier = new ProtocolCarrier(GDS_members_activity.this, SmartUniDataWS.TOKEN_NAME); MessageRequest request = new MessageRequest(SmartUniDataWS.URL_WS_SMARTUNI, SmartUniDataWS.POST_ABANDON_GDS); request.setMethod(Method.POST); MessageResponse response; try { request.setBody(gds_to_abandon.getId() + ""); response = mProtocolCarrier.invokeSync( request, SmartUniDataWS.TOKEN_NAME, MyUniActivity.getAuthToken()); if (response.getHttpStatus() == 200) { return true; } else { return false; } } catch (ConnectionException e) { e.printStackTrace(); } catch (ProtocolException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (AACException e) { e.printStackTrace(); } return true; }
private List<CorsoCarriera> getFollowingCourses() { mProtocolCarrier = new ProtocolCarrier(context, SmartUniDataWS.TOKEN_NAME); MessageRequest request = new MessageRequest( SmartUniDataWS.URL_WS_SMARTUNI, SmartUniDataWS.GET_WS_MY_COURSES_NOT_PASSED); request.setMethod(Method.GET); @SuppressWarnings("unused") BasicProfile bp = new BasicProfile(); MessageResponse response; try { response = mProtocolCarrier.invokeSync( request, SmartUniDataWS.TOKEN_NAME, MyUniActivity.getAuthToken()); if (response.getHttpStatus() == 200) { body = response.getBody(); } else { return null; } } catch (ConnectionException e) { e.printStackTrace(); } catch (ProtocolException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (AACException e) { e.printStackTrace(); } return Utils.convertJSONToObjects(body, CorsoCarriera.class); }