001/* 002 * (C) Copyright 2006-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-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 * Dragos Mihalache 016 */ 017package org.nuxeo.ecm.core.uidgen; 018 019import org.nuxeo.ecm.core.api.DocumentModel; 020import org.nuxeo.ecm.core.api.model.PropertyNotFoundException; 021 022/** 023 * Common interface for UID generators. All UID generators must implement this interface. 024 * 025 * @author <a href="mailto:dm@nuxeo.com>Dragos Mihalache</a> 026 */ 027public interface UIDGenerator { 028 029 /** 030 * Sets the property name used to set the identifier value. 031 * <p> 032 * The property must be a string like 'schemaPrefix:fieldName' ; the syntax 'schemaName:fieldName' is also accepted. 033 * Could be used as a convenient method when there is only one property to set. 034 * 035 * @param propertyName 036 * @see #setPropertyNames(String[]) 037 */ 038 void setPropertyName(String propertyName); 039 040 /** 041 * Get the property name used to set the identifier value. 042 * 043 * @see #getPropertyNames() 044 */ 045 String getPropertyName(); 046 047 /** 048 * Set the properties used to set the identifier value. 049 * 050 * @param propertyNames 051 */ 052 void setPropertyNames(String[] propertyNames); 053 054 /** 055 * Gets the property name used to set the identifier value 056 * 057 * @return 058 */ 059 String[] getPropertyNames(); 060 061 /** 062 * The sequencer used to generate unique numbers sequencially. 063 * 064 * @param sequencer 065 */ 066 void setSequencer(UIDSequencer sequencer); 067 068 String getSequenceKey(DocumentModel document); 069 070 /** 071 * Returns a new UID for the given doc. 072 */ 073 String createUID(DocumentModel document); 074 075 /** 076 * Creates a new UID for the given doc and sets the field configured in the generator component with this value. 077 */ 078 void setUID(DocumentModel document) throws PropertyNotFoundException; 079 080}