package org.bodington.server;

import java.util.Date;

import org.bodington.server.realm.User;

public interface EasyEditorSession extends BuildingSession {

	/**
	 * Lock the current resource.
	 * @return <code>true</code> if the resource was sucessfully locked and
	 * <code>false</code> if we couldn't lock the resource because there is already a
	 * lock on it.
	 * @throws BuildingServerException If there was a more serious underlying problem.
	 */
	public abstract boolean lock() throws BuildingServerException;

	/**
	 * Break someone elses lock on this resource.
	 * @return <code>true</code> if we broken a lock on this resource and <code>false</code>
	 * if there wasn't a lock to break.
	 * @throws BuildingServerException 
	 */
	public abstract boolean breakLock() throws BuildingServerException;

	/**
	 * Get the date when the lock will expire.
	 * @return The date of expiry or <code>null</code> if there isn't a lock.
	 */
	public abstract Date getExpire();

	/**
	 * Get the user who owns the lock on this resource.
	 * @return The user who owns the lock or <code>null</code> if there isn't a lock.
	 */
	public abstract User getLocker();

    /**
     * Update the text for this resource.
     * @param text
     * @return <code>true</code> if the resource was sucessfully updated.
     * @throws BuildingServerException 
     */
    public abstract boolean update(String text) throws BuildingServerException;
}