saveCollection(transaction, current);
	public Collection getOrCreateCollection(Txn transaction, String name)		throws PermissionDeniedException {		//		final long start = System.currentTimeMillis();		name = normalizeCollectionName(name);		if (name.length() > 0 && name.charAt(0) != '/')			name = "/" + name;		if (!name.startsWith(ROOT_COLLECTION))			name = ROOT_COLLECTION + name;		if (name.endsWith("/") && name.length() > 1)			name = name.substring(0, name.length() - 1);		final CollectionCache collectionsCache = pool.getCollectionsCache();		synchronized(collectionsCache) {			try {				StringTokenizer tok = new StringTokenizer(name, "/");				String temp = tok.nextToken();				String path = ROOT_COLLECTION;				Collection sub;				Collection current = getCollection(ROOT_COLLECTION);				if (current == null) {					LOG.debug("creating root collection " + ROOT_COLLECTION);					current = new Collection(ROOT_COLLECTION);					current.getPermissions().setPermissions(0777);					current.getPermissions().setOwner(user);					current.getPermissions().setGroup(user.getPrimaryGroup());					current.setId(getNextCollectionId(transaction));					current.setCreationTime(System.currentTimeMillis());                    if (transaction != null)                        transaction.acquireLock(current.getLock(), Lock.WRITE_LOCK);					saveCollection(transaction, current);				}				while (tok.hasMoreTokens()) {					temp = tok.nextToken();					path = path + "/" + temp;					if (current.hasSubcollection(temp)) {						current = getCollection(path);                        if (current == null)                            LOG.debug("Collection " + path + " not found!");					} else {						if (!current.getPermissions().validate(user, Permission.WRITE)) {							LOG.debug("permission denied to create collection " + path);							throw new PermissionDeniedException("User '"+ user.getName() + "' not allowed to write to collection '" + current.getName() + "'");						}						LOG.debug("creating collection " + path);						sub = new Collection(path);						sub.getPermissions().setOwner(user);						sub.getPermissions().setGroup(user.getPrimaryGroup());						sub.setId(getNextCollectionId(transaction));						sub.setCreationTime(System.currentTimeMillis());                        if (transaction != null)                            transaction.acquireLock(sub.getLock(), Lock.WRITE_LOCK);						saveCollection(transaction, current);                        current.addCollection(sub);						current = sub;					}				}				//			LOG.debug("getOrCreateCollection took " + 				//				(System.currentTimeMillis() - start) + "ms.");				return current;			} catch(ReadOnlyException e) {				throw new PermissionDeniedException(DATABASE_IS_READ_ONLY);			} catch (LockException e) {                LOG.warn("Failed to acquire lock on collection", e);            }            return null;		}	}