001/*
002 * (C) Copyright 2006-2011 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 *     Florent Guillaume
018 */
019package org.nuxeo.ecm.core.api.pathsegment;
020
021import org.nuxeo.ecm.core.api.DocumentModel;
022
023/**
024 * Service with a method generating a path segment (name) given a {@link DocumentModel} about to be created. Usually the
025 * title is used to derive the path segment.
026 */
027public interface PathSegmentService {
028
029    /**
030     * @since 7.4
031     */
032    public static final String NUXEO_MAX_SEGMENT_SIZE_PROPERTY = "nuxeo.path.segment.maxsize";
033
034    /**
035     * Generate the path segment to use for a {@link DocumentModel} that's about to be created.
036     *
037     * @param doc the document
038     * @return the path segment, which must not contain any {@code /} character
039     */
040    String generatePathSegment(DocumentModel doc);
041
042    /**
043     * Generate the path segment to use from a string.
044     *
045     * @param s the string
046     * @return the path segment, which must not contain any {@code /} character
047     * @since 5.9.2
048     */
049    String generatePathSegment(String s);
050
051    /**
052     * Return the path segment max size
053     *
054     * @since 7.4
055     */
056    int getMaxSize();
057}