* @throws RecorderException if a problem occurred while reading home,
* or if file <code>name</code> doesn't exist.
*/
public Home readHome(String name) throws RecorderException {
URLConnection connection = null;
DefaultHomeInputStream in = null;
try {
// Replace % sequence by %% except %s before formating readHomeURL with home name
String readHomeURL = String.format(this.readHomeURL.replaceAll("(%[^s])", "%$1"),
URLEncoder.encode(name, "UTF-8"));
// Open a home input stream to server
connection = new URL(readHomeURL).openConnection();
connection.setRequestProperty("Content-Type", "charset=UTF-8");
connection.setUseCaches(false);
in = new DefaultHomeInputStream(connection.getInputStream());
// Read home with HomeInputStream
Home home = in.readHome();
return home;
} catch (InterruptedIOException ex) {
throw new InterruptedRecorderException("Read " + name + " interrupted");
} catch (IOException ex) {
throw new RecorderException("Can't read home from " + name, ex);
} catch (ClassNotFoundException ex) {
throw new RecorderException("Missing classes to read home from " + name, ex);
} finally {
try {
if (in != null) {
in.close();
}
} catch (IOException ex) {
throw new RecorderException("Can't close file " + name, ex);
}
}