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