XMLLogin login = (XMLLogin) session.getDatasourceLogin();
if (login.getDocumentPreservationPolicy() == null) {
Iterator iterator = session.getProject().getOrderedDescriptors().iterator();
while (iterator.hasNext()) {
Descriptor xmlDescriptor = (Descriptor) iterator.next();
if (xmlDescriptor.shouldPreserveDocument()) {
login.setDocumentPreservationPolicy(new DescriptorLevelDocumentPreservationPolicy());
break;
}
}
}