001/*
002 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Florent Guillaume
018 */
019package org.nuxeo.ecm.core.api;
020
021import java.io.Serializable;
022import java.util.Calendar;
023
024/**
025 * Information about a lock set on a document.
026 * <p>
027 * The lock information holds the owner, which is a user id, and the lock creation time.
028 */
029public class Lock implements Serializable {
030
031    private static final long serialVersionUID = 1L;
032
033    private final String owner;
034
035    private final Calendar created;
036
037    private final boolean failed;
038
039    public Lock(String owner, Calendar created, boolean failed) {
040        this.owner = owner;
041        this.created = created;
042        this.failed = failed;
043    }
044
045    public Lock(String owner, Calendar created) {
046        this(owner, created, false);
047    }
048
049    public Lock(Lock lock, boolean failed) {
050        this(lock.owner, lock.created, failed);
051    }
052
053    /**
054     * The owner of the lock.
055     *
056     * @return the owner, which is a user id
057     */
058    public String getOwner() {
059        return owner;
060    }
061
062    /**
063     * The creation time of the lock.
064     *
065     * @return the creation time
066     */
067    public Calendar getCreated() {
068        return created;
069    }
070
071    /**
072     * The failure state, used for removal results.
073     *
074     * @return the failure state
075     */
076    public boolean getFailed() {
077        return failed;
078    }
079
080}