if (SecurityManager.SYSTEM.equals(current.getName()) && SecurityManager.ACL_FILE.equals(name) && SecurityManager.DBA_USER.equals(username)) { User admin = service.getUser(SecurityManager.DBA_USER); adminPass = admin.getPassword(); admin.setPassword(pass); try { service.updateUser(admin); } catch (XMLDBException e) { } }
	public void startElement(String namespaceURI, String localName, String qName, Attributes atts)		throws SAXException {		if (namespaceURI.equals(NS)) {			if (localName.equals("collection")) {				final String name = atts.getValue("name");				final String owner = atts.getValue("owner");				final String group = atts.getValue("group");				final String mode = atts.getValue("mode");				final String created = atts.getValue("created");								if (name == null)					throw new SAXException("collection requires a name " + "attribute");				try {					if(dialog != null)						dialog.displayMessage("creating collection " + name);																				Date date_created = null;										if (created != null)						try {							date_created = (Date)(new DateTimeValue(created)).getDate();						} catch (XPathException e2) {						} 					 										current = mkcol(name, date_created);					UserManagementService service =						(UserManagementService) current.getService("UserManagementService", "1.0");					User u = new User(owner, null, group);					service.chown(u, group);					service.chmod(Integer.parseInt(mode, 8));				} catch (Exception e) {                    if (dialog != null) {                    showErrorMessage("An unrecoverable error occurred while restoring\ncollection '" + name + "'. " +                            "Aborting restore!");                    } else {                        System.err.println("An unrecoverable error occurred while restoring\ncollection '" + name + "'. " +                            "Aborting restore!");                    }                    e.printStackTrace();					throw new SAXException(e.getMessage(), e);				}				if(dialog != null)					dialog.setCollection(name);			} else if (localName.equals("subcollection")) {								 String name = atts.getValue("filename");								if (name == null) name = atts.getValue("name");				final String fname =					contents.getParentFile().getAbsolutePath()						+ File.separatorChar						+ name						+ File.separatorChar						+ "__contents__.xml";				final File f = new File(fname);				if (f.exists() && f.canRead())					stack.push(f);				else					System.err.println(f.getAbsolutePath() + " does not exist or is not readable.");			} else if (localName.equals("resource")) {				String type = atts.getValue("type");				if(type == null)					type ="XMLResource";				final String name = atts.getValue("name");				final String owner = atts.getValue("owner");				final String group = atts.getValue("group");				final String perms = atts.getValue("mode");								String filename = atts.getValue("filename");				final String mimetype = atts.getValue("mimetype");				final String created = atts.getValue("created");				final String modified = atts.getValue("modified");																if (filename == null) filename = name;				if (name == null) {                    if (dialog != null)                        dialog.displayMessage("Wrong entry in backup descriptor: resource requires a name attribute.");                    else                        System.err.println("Wrong entry in backup descriptor: resource requires a name attribute.");                }				final File f =					new File(						contents.getParentFile().getAbsolutePath() + File.separatorChar + filename);				try {					if (dialog != null && current instanceof Observable) {						((Observable) current).addObserver(dialog.getObserver());					}					if(dialog != null)						dialog.setResource(name);					final Resource res =						current.createResource(name, type);					if (mimetype != null)						((EXistResource)res).setMimeType(mimetype);										res.setContent(f);					if(dialog == null)						System.out.println("Restoring " + name);										Date date_created = null;					Date date_modified = null;										if (created != null)						try {							date_created = (Date)(new DateTimeValue(created)).getDate();						} catch (XPathException e2) {                            System.err.println("Illegal creation date. Skipping ...");						} 										if (modified != null)						try {							date_modified = (Date)(new DateTimeValue(modified)).getDate();						} catch (XPathException e2) {                            System.err.println("Illegal modification date. Skipping ...");						} 										current.storeResource(res, date_created, date_modified);					UserManagementService service =						(UserManagementService) current.getService("UserManagementService", "1.0");					User u = new User(owner, null, group);					try {						service.chown(res, u, group);					} catch (XMLDBException e1) {						if(dialog != null) {							dialog.displayMessage("Failed to change owner on document '" + name + "'; skipping ...");                        }					}					service.chmod(res, Integer.parseInt(perms, 8));					if(dialog != null)						dialog.displayMessage("restored " + name);				} catch (Exception e) {                    if (dialog != null) {                             dialog.displayMessage("Failed to restore resource '" + name + "'\nfrom file '" +                                    f.getAbsolutePath() + "'.\nReason: " + e.getMessage());                            showErrorMessage(                                    "Failed to restore resource '" + name + "' from file: '" +                                    f.getAbsolutePath() + "'.\n\nReason: " + e.getMessage()                            );                    } else {                        System.err.println("Failed to restore resource '" + name + "' from file '" +					        f.getAbsolutePath() + "'");                        e.printStackTrace();                    }				}			}		}	}