@Override protected File doInBackground(Object... params) { final File currentBulletinDir = (File) params[0]; final MobileClientBulletinStore store = (MobileClientBulletinStore) params[1]; try { SingleBulletinDataBase database = new SingleBulletinDataBase(); store.setDatabase(database); store.saveBulletin(mBulletin); File file = File.createTempFile("tmp_send_" + getCurrentTimeStamp(), ".zip", currentBulletinDir); DebugClass.setDebugToTrue(); DatabaseKey databaseKey = mBulletin.getDatabaseKey(); MartusCrypto signatureGenerator = mBulletin.getSignatureGenerator(); BulletinZipUtilities.exportBulletinPacketsFromDatabaseToZipFile( database, databaseKey, file, signatureGenerator); if (!file.exists()) throw new FileNotFoundException( MainApplication.getInstance() .getString( R.string.error_message_could_not_find_record_zip_file_after_it_was_created)); return file; } catch (Exception e) { Log.e( "martus", MainApplication.getInstance() .getString(R.string.error_message_problem_serializing_record_to_zip), e); return null; } }
protected void retrieveOneBulletin(File destFile, UniversalId uid) throws Exception { FileOutputStream out = new FileOutputStream(destFile); int chunkSize = MIRRORING_MAX_CHUNK_SIZE; ProgressMeterInterface nullProgressMeter = null; int totalLength = BulletinZipUtilities.retrieveBulletinZipToStream( uid, out, chunkSize, gateway, getSecurity(), nullProgressMeter); out.close(); if (destFile.length() != totalLength) { logError("file=" + destFile.length() + ", returned=" + totalLength); throw new ServerErrorException("totalSize didn't match data length"); } }
@Override protected File doInBackground(Object... params) { final File currentBulletinDir = (File) params[0]; final MobileClientBulletinStore store = (MobileClientBulletinStore) params[1]; File file = null; try { store.saveBulletin(bulletin); file = File.createTempFile("tmp_send_" + getCurrentTimeStamp(), ".zip", currentBulletinDir); BulletinZipUtilities.exportBulletinPacketsFromDatabaseToZipFile( store.getDatabase(), bulletin.getDatabaseKey(), file, bulletin.getSignatureGenerator()); removeSavedFormData(); } catch (Exception e) { Log.e("martus", "problem serializing bulletin to zip", e); } return file; }
@Override public void onZipped(Bulletin bulletin, File zippedFile) { try { ZipFile zipFile = new ZipFile(zippedFile); BulletinZipUtilities.validateIntegrityOfZipFilePackets( store.getAccountId(), zipFile, getSecurity()); } catch (Exception e) { Log.e(TAG, getString(R.string.error_message_error_verifying_zip_file), e); indeterminateDialog.dismissAllowingStateLoss(); Toast.makeText(this, getString(R.string.failure_zipping_bulletin), Toast.LENGTH_LONG).show(); finish(); return; } if (zippedFile == null) { Toast.makeText(this, getString(R.string.failure_zipping_bulletin), Toast.LENGTH_SHORT).show(); return; } uploadBulletin(bulletin, zippedFile); }