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