return current;
	public Collection getOrCreateCollection(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);		Collection current = null;		Lock lock = collectionsDb.getLock();		try {			lock.acquire();			StringTokenizer tok = new StringTokenizer(name, "/");			String temp = tok.nextToken();			String path = ROOT_COLLECTION;			Collection sub;			current = getCollection(ROOT_COLLECTION);			if (current == null) {				LOG.debug("creating root collection /db");				current = new Collection(collectionsDb, ROOT_COLLECTION);				current.getPermissions().setPermissions(0777);				current.getPermissions().setOwner(user);				current.getPermissions().setGroup(user.getPrimaryGroup());				current.setId(getNextCollectionId());				current.setCreationTime(System.currentTimeMillis());				saveCollection(current);			}			while (tok.hasMoreTokens()) {				temp = tok.nextToken();				path = path + "/" + temp;				if (current.hasSubcollection(temp)) {					current = getCollection(path);				} else {					if (!current.getPermissions().validate(user, Permission.WRITE)) {						LOG.debug("permission denied to create collection " + path);						throw new PermissionDeniedException("not allowed to write to collection");					}					LOG.debug("creating collection " + path);					sub = new Collection(collectionsDb, path);					sub.getPermissions().setOwner(user);					sub.getPermissions().setGroup(user.getPrimaryGroup());					sub.setId(getNextCollectionId());					sub.setCreationTime(System.currentTimeMillis());					current.addCollection(sub);					saveCollection(current);					current = sub;				}			}		} catch (ReadOnlyException e) {			LOG.debug("database read-only");			return null;		} catch (LockException e) {			LOG.warn("failed to acquire lock on collections store");		} finally {			lock.release();		}		//			LOG.debug("getOrCreateCollection took " + 		//				(System.currentTimeMillis() - start) + "ms.");		return current;	}