synchronized ( subscribers ) {
File file = new File(filename);
if ( file.exists() ) {
try {
FileInputStream inputStream = new FileInputStream(filename);
SimpleImporter importer = new SimpleImporter();
importer.addSimpleImportHandler(new DefaultSimpleImportHandler() {
String callback, notificationType, uri;
int depth, notificationDelay, subscriptionLifetime, id;
List events = new ArrayList();
public void startElement(SimplePath path, String name, AttributesImpl attributes, String leadingCDdata) {
if ( path.matches(E_SUBSCRIPTION) ) {
id = ConversionHelpers.getInt(attributes.getValue(A_ID));
} else if ( path.matches(E_URI) ) {
uri = leadingCDdata;
} else if ( path.matches(E_DEPTH) ) {
depth = Integer.valueOf(leadingCDdata).intValue();
} else if ( path.matches(E_CALLBACK) ) {
callback = leadingCDdata;
} else if ( path.matches(E_NOTIFICATION_DELAY) ) {
notificationDelay = Integer.valueOf(leadingCDdata).intValue();
} else if ( path.matches(E_NOTIFICATION_TYPE) ) {
notificationType = leadingCDdata;
} else if ( path.matches(E_SUBSCRIPTION_END) ) {
subscriptionLifetime = (int)(Long.valueOf(leadingCDdata).longValue() - System.currentTimeMillis());
}
}
public void endElement(SimplePath path, String name) {
if ( path.matches(E_SUBSCRIPTION) ) {
Subscriber subscriber = new Subscriber(uri, callback, notificationType, notificationDelay, subscriptionLifetime, depth);
subscribers.add(subscriber);
refreshSubscriber(subscriber, false);
}
}
});
importer.parse(new InputSource(inputStream));
} catch (Exception e) {
Domain.log("Exception while restoring subscriptions. Skipping...");
}
}
}