private Stack<BackupDescriptor> getBackupDescriptors(File contents) throws XMLDBException, IOException { final Stack<BackupDescriptor> descriptors = new Stack<BackupDescriptor>(); do { final BackupDescriptor bd = getBackupDescriptor(contents); descriptors.push(bd); // check if the system collection is in the backup. This should be processed first final BackupDescriptor sysDescriptor = bd.getChildBackupDescriptor(XmldbURI.SYSTEM_COLLECTION_NAME); // check if the system/security collection is in the backup, this must be the first system // collection processed if (sysDescriptor != null) { descriptors.push(sysDescriptor); final BackupDescriptor secDescriptor = sysDescriptor.getChildBackupDescriptor("security"); if (secDescriptor != null) { descriptors.push(secDescriptor); } } contents = null; final Properties properties = bd.getProperties(); if ((properties != null) && "yes".equals(properties.getProperty("incremental", "no"))) { final String previous = properties.getProperty("previous", ""); if (previous.length() > 0) { contents = new File(bd.getParentDir(), previous); if (!contents.canRead()) { throw new XMLDBException( ErrorCodes.PERMISSION_DENIED, "Required part of incremental backup not found: " + contents.getAbsolutePath()); } } } } while (contents != null); return descriptors; }