001/*
002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     Florent Guillaume
011 */
012package org.nuxeo.ecm.core.api.pathsegment;
013
014import org.nuxeo.ecm.core.api.DocumentModel;
015
016/**
017 * Service with a method generating a path segment (name) given a {@link DocumentModel} about to be created. Usually the
018 * title is used to derive the path segment.
019 */
020public interface PathSegmentService {
021
022    /**
023     * @since 7.4
024     */
025    public static final String NUXEO_MAX_SEGMENT_SIZE_PROPERTY = "nuxeo.path.segment.maxsize";
026
027    /**
028     * Generate the path segment to use for a {@link DocumentModel} that's about to be created.
029     *
030     * @param doc the document
031     * @return the path segment, which must not contain any {@code /} character
032     */
033    String generatePathSegment(DocumentModel doc);
034
035    /**
036     * Generate the path segment to use from a string.
037     *
038     * @param s the string
039     * @return the path segment, which must not contain any {@code /} character
040     * @since 5.9.2
041     */
042    String generatePathSegment(String s);
043
044    /**
045     * Return the path segment max size
046     *
047     * @since 7.4
048     */
049    int getMaxSize();
050}