public static void handleLogIn(DataInputStream dis) throws Exception { try { int size = dis.readInt(); if (size == 0) { throw new IOException(Text.NO_ORGUNIT_ERROR()); } else { for (int i = 0; i < size; i++) { OrgUnit orgUnit = new OrgUnit(); orgUnit.deSerialize(dis); orgUnitVector.addElement(orgUnit); OrgUnitRecordStore.saveOrgUnit(orgUnit); } ConnectionManager.getDhisMIDlet().getPinView().preparePinFormForFirstTime(); ConnectionManager.getDhisMIDlet().getPinView().showView(); // ConnectionManager.downloadAllResource( orgUnitVector ); } } finally { try { if (dis != null) dis.close(); System.gc(); } catch (IOException ioe) { ioe.printStackTrace(); LogMan.log("Network,Login," + CLASS_TAG, ioe); } } }
public void run() { try { inputStream = this.download(); SettingRecordStore settingRecordStore = new SettingRecordStore(); String clientVersion = settingRecordStore.get(SettingRecordStore.CLIENT_VERSION); LogMan.log(LogMan.INFO, "Network," + CLASS_TAG, "Client Version: " + clientVersion); if (clientVersion == "") { LogMan.log(LogMan.INFO, "Network," + CLASS_TAG, "Setting Client Version to: " + "2.8"); settingRecordStore.put(SettingRecordStore.CLIENT_VERSION, "2.8"); settingRecordStore.save(); } serverVersion = getServerVersion(); boolean isNewVersionAvailable = orgUnit.checkNewVersion(serverVersion); if (isNewVersionAvailable == true) { ConnectionManager.getDhisMIDlet().getUpdateNewVersionView().showView(); } else { handleLogIn(inputStream); } } catch (Exception e) { e.printStackTrace(); LogMan.log("Network,Authentication," + CLASS_TAG, e); LoginView loginView = ConnectionManager.getDhisMIDlet().getLoginView(); loginView.resetTextField(); loginView.switchDisplayable( Alerts.getErrorAlert(Text.ERROR(), e.getMessage()), loginView.getLoginForm()); } finally { try { if (inputStream != null) inputStream.close(); } catch (IOException e) { e.printStackTrace(); } System.gc(); } }