use of com.github.dreamhead.moco.model.Session in project moco by dreamhead.
the class DefaultFailoverExecutor method restoreSessions.
private ImmutableList<Session> restoreSessions(final File file) {
InputStream inputStream = null;
try {
inputStream = new FileInputStream(file);
List<Session> sessions = Jsons.toObject(inputStream, new TypeReference<List<Session>>() {
});
return copyOf(sessions);
} catch (MocoException me) {
logger.error("exception found", me);
return of();
} catch (IOException e) {
throw new MocoException(e);
} finally {
if (inputStream != null) {
Closeables.closeQuietly(inputStream);
}
}
}
use of com.github.dreamhead.moco.model.Session in project moco by dreamhead.
the class DefaultFailoverExecutor method onCompleteResponse.
@Override
public void onCompleteResponse(final HttpRequest request, final HttpResponse httpResponse) {
try {
ObjectWriter writer = mapper.writerWithDefaultPrettyPrinter();
Session targetSession = Session.newSession(request, httpResponse);
writer.writeValue(this.file, prepareTargetSessions(targetSession));
} catch (IOException e) {
throw new MocoException(e);
}
}
Aggregations