001/*
002 * (C) Copyright 2007 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Nuxeo - initial API and implementation
016 *
017 * $Id$
018 */
019
020package org.nuxeo.ecm.platform.api.ws;
021
022import java.io.Serializable;
023
024import org.nuxeo.ecm.core.api.DocumentModel;
025import org.nuxeo.ecm.core.api.PropertyException;
026
027/**
028 * Web service base document descriptor.
029 * <p>
030 * The document descriptor contains minimal information about a document as needed by a client to display it and
031 * navigate through the repository tree.
032 * <p>
033 * The descriptor exposes:
034 * <ul>
035 * <li>the document UUID
036 * <li>the document type
037 * <li>the document title
038 * </ul>
039 * <p>
040 * In the case of version document versions the title is the version label
041 *
042 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
043 */
044public class DocumentDescriptor implements Serializable {
045
046    private static final long serialVersionUID = 1L;
047
048    private String id;
049
050    private String title;
051
052    private String type;
053
054    /**
055     * Emtpy ctor needed by tools like jaxb.
056     */
057    public DocumentDescriptor() {
058    }
059
060    public DocumentDescriptor(DocumentModel doc) {
061        try {
062            title = (String) doc.getProperty("dublincore", "title");
063        } catch (PropertyException e) {
064            title = null;
065        }
066        if (title == null) {
067            title = doc.getName();
068        }
069        id = doc.getId();
070        type = doc.getType();
071    }
072
073    public DocumentDescriptor(DocumentModel doc, String title) {
074        this.title = title;
075        id = doc.getId();
076        type = doc.getType();
077    }
078
079    public String getTitle() {
080        return title;
081    }
082
083    public String getType() {
084        return type;
085    }
086
087    public String getUUID() {
088        return id;
089    }
090
091    /**
092     * @param title the title to set.
093     */
094    public void setTitle(String title) {
095        this.title = title;
096    }
097
098    /**
099     * @param uuid the uuid to set.
100     */
101    public void setUUID(String uuid) {
102        id = uuid;
103    }
104
105    /**
106     * @param type the type to set.
107     */
108    public void setType(String type) {
109        this.type = type;
110    }
111
112    public String getId() {
113        return id;
114    }
115
116    public void setId(String id) {
117        this.id = id;
118    }
119
120}