001/*
002 * (C) Copyright 2014 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-2.1.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 *     Thierry Delprat
016 */
017package org.nuxeo.ecm.core.uidgen;
018
019import org.nuxeo.ecm.core.api.DocumentModel;
020import org.nuxeo.ecm.core.api.model.PropertyNotFoundException;
021import org.nuxeo.ecm.core.uidgen.UIDGenerator;
022import org.nuxeo.ecm.core.uidgen.UIDSequencer;
023
024public interface UIDGeneratorService {
025
026    /**
027     * Retrieves the default {@link UIDSequencer}
028     *
029     * @return the default {@link UIDSequencer}
030     * @since 7.3
031     */
032    UIDSequencer getSequencer();
033
034    /**
035     * Retrieves {@link UIDSequencer} by it's name
036     *
037     * @param name the name of the {@link UIDSequencer}
038     * @return the {@link UIDSequencer} matching the name
039     * @since 7.3
040     */
041    UIDSequencer getSequencer(String name);
042
043    /**
044     * Returns the uid generator to use for this document.
045     * <p>
046     * Choice is made following the document type and the generator configuration.
047     */
048    UIDGenerator getUIDGeneratorFor(DocumentModel doc);
049
050    /**
051     * Creates a new UID for the given doc and sets the field configured in the generator component with this value.
052     */
053    void setUID(DocumentModel doc) throws PropertyNotFoundException;
054
055    /**
056     * @return a new UID for the given document
057     */
058    String createUID(DocumentModel doc);
059
060}