001/* 002 * (C) Copyright 2009 Nuxeo SA (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.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 * arussel 016 */ 017package org.nuxeo.ecm.platform.routing.api; 018 019import org.nuxeo.ecm.core.api.CoreSession; 020import org.nuxeo.ecm.core.api.DocumentModel; 021 022/** 023 * The DocumentRoutingPersister is responsible creating a folder structure to persist {@link DocumentRoute} instance, 024 * persisting new {@link DocumentRoute} instances and creating {@link DocumentRoute} model from {@link DocumentRoute} 025 * instance. 026 * 027 * @author arussel 028 */ 029public interface DocumentRoutingPersister { 030 /** 031 * The name of the document in which will be create 032 */ 033 String DocumentRouteInstanceRootName = "DocumentRouteInstancesRoot"; 034 035 /** 036 * Get or create the parent folder for a {@link DocumentRoute} route instance. 037 * 038 * @param document The {@link DocumentRoute} model from which the instance will be created. Its metadata may be used 039 * when creating the parent. 040 * @return The parent folder in which the {@link DocumentRoute} will be persisted. 041 */ 042 DocumentModel getParentFolderForDocumentRouteInstance(DocumentModel document, CoreSession session); 043 044 /** 045 * Creates a blank {@link DocumentRoute} instance from a model. 046 * 047 * @param model the model 048 * @return The created {@link DocumentRoute} 049 */ 050 DocumentModel createDocumentRouteInstanceFromDocumentRouteModel(DocumentModel model, CoreSession session); 051 052 /** 053 * @param routeInstance 054 * @param parentFolder 055 * @return 056 */ 057 DocumentModel saveDocumentRouteInstanceAsNewModel(DocumentModel routeInstance, DocumentModel parentFolder, 058 String newName, CoreSession session); 059 060 /** 061 * Will get, and create if it does not exists the root document in which {@link DocumentRoute} structure will be 062 * created. 063 * 064 * @param session The session use to get or create the document. 065 * @return The root of the {@link DocumentRoute} structure. 066 */ 067 DocumentModel getOrCreateRootOfDocumentRouteInstanceStructure(CoreSession session); 068 069 /** 070 * Returns a folder in which new model, created from an instance of route will be stored. 071 * 072 * @param session the session of the user 073 * @param instance the instance that will be persisted as new model. 074 */ 075 DocumentModel getParentFolderForNewModel(CoreSession session, DocumentModel instance); 076 077 /** 078 * Return the new name of a model when it is created from an instance. 079 * 080 * @see DocumentRoutingService#saveRouteAsNewModel(DocumentRoute, String, CoreSession) 081 * @return the new name 082 */ 083 String getNewModelName(DocumentModel instance); 084 085 /** 086 * Gets or creates the parent folder for a {@link DocumentRoute} route instance. 087 * 088 * @return The parent folder in which the {@link DocumentRoute} will be persisted. 089 * @since 5.6 090 */ 091 DocumentModel getParentFolderForDocumentRouteModels(CoreSession session); 092}