samples/xml/dms/src/main/java/sample/dms/DataSourcePopulator.java
private void createSampleData(String username, String password) {
		Assert.notNull(documentDao, "DocumentDao required");
		Assert.hasText(username, "Username required");

		Authentication auth = new UsernamePasswordAuthenticationToken(username, password);

		try {
			// Set the SecurityContextHolder ThreadLocal so any subclasses
			// automatically know which user is operating
			SecurityContextHolder.getContext().setAuthentication(auth);

			// Create the home directory first
			Directory home = new Directory(username, Directory.ROOT_DIRECTORY);
			documentDao.create(home);
			addPermission(documentDao, home, username, LEVEL_GRANT_ADMIN);
			addPermission(documentDao, home, "ROLE_USER", LEVEL_GRANT_READ);
			createFiles(documentDao, home);

			// Now create the confidential directory
			Directory confid = new Directory("confidential", home);
			documentDao.create(confid);
			addPermission(documentDao, confid, "ROLE_USER", LEVEL_NEGATE_READ);
			createFiles(documentDao, confid);

			// Now create the shared directory
			Directory shared = new Directory("shared", home);
			documentDao.create(shared);
			addPermission(documentDao, shared, "ROLE_USER", LEVEL_GRANT_READ);
			addPermission(documentDao, shared, "ROLE_USER", LEVEL_GRANT_WRITE);
			createFiles(documentDao, shared);
		}
		finally {
			// Clear the SecurityContextHolder ThreadLocal so future calls are
			// guaranteed to be clean
			SecurityContextHolder.clearContext();
		}
	}
private void createSampleData(String username, String password) {
		Assert.notNull(documentDao, "DocumentDao required");
		Assert.hasText(username, "Username required");

		Authentication auth = new UsernamePasswordAuthenticationToken(username, password);

		try {
			// Set the SecurityContextHolder ThreadLocal so any subclasses
			// automatically know which user is operating
			SecurityContextHolder.getContext().setAuthentication(auth);

			// Create the home directory first
			Directory home = new Directory(username, Directory.ROOT_DIRECTORY);
			documentDao.create(home);
			addPermission(documentDao, home, username, LEVEL_GRANT_ADMIN);
			addPermission(documentDao, home, "ROLE_USER", LEVEL_GRANT_READ);
			createFiles(documentDao, home);

			// Now create the confidential directory
			Directory confid = new Directory("confidential", home);
			documentDao.create(confid);
			addPermission(documentDao, confid, "ROLE_USER", LEVEL_NEGATE_READ);
			createFiles(documentDao, confid);

			// Now create the shared directory
			Directory shared = new Directory("shared", home);
			documentDao.create(shared);
			addPermission(documentDao, shared, "ROLE_USER", LEVEL_GRANT_READ);
			addPermission(documentDao, shared, "ROLE_USER", LEVEL_GRANT_WRITE);
			createFiles(documentDao, shared);
		}
		finally {
			// Clear the SecurityContextHolder ThreadLocal so future calls are
			// guaranteed to be clean
			SecurityContextHolder.clearContext();
		}
	}
Creates a directory for the user, and a series of sub-directories. The root
directory is the parent for the user directory. The sub-directories are
"confidential" and "shared". The ROLE_USER will be given read and write access to
"shared".