001/*
002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     Florent Guillaume
011 */
012package org.nuxeo.ecm.core.api;
013
014import java.io.Serializable;
015import java.util.Calendar;
016
017/**
018 * Information about a lock set on a document.
019 * <p>
020 * The lock information holds the owner, which is a user id, and the lock creation time.
021 */
022public class Lock implements Serializable {
023
024    private static final long serialVersionUID = 1L;
025
026    private final String owner;
027
028    private final Calendar created;
029
030    private final boolean failed;
031
032    public Lock(String owner, Calendar created, boolean failed) {
033        this.owner = owner;
034        this.created = created;
035        this.failed = failed;
036    }
037
038    public Lock(String owner, Calendar created) {
039        this(owner, created, false);
040    }
041
042    public Lock(Lock lock, boolean failed) {
043        this(lock.owner, lock.created, failed);
044    }
045
046    /**
047     * The owner of the lock.
048     *
049     * @return the owner, which is a user id
050     */
051    public String getOwner() {
052        return owner;
053    }
054
055    /**
056     * The creation time of the lock.
057     *
058     * @return the creation time
059     */
060    public Calendar getCreated() {
061        return created;
062    }
063
064    /**
065     * The failure state, used for removal results.
066     *
067     * @return the failure state
068     */
069    public boolean getFailed() {
070        return failed;
071    }
072
073}