001/*
002 * (C) Copyright 2009-2012 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 *     Alexandre Russel
016 *     Florent Guillaume
017 */
018package org.nuxeo.ecm.platform.routing.core.api;
019
020import java.io.Serializable;
021import java.util.Map;
022
023import org.nuxeo.ecm.core.api.CoreSession;
024import org.nuxeo.ecm.platform.routing.api.DocumentRoute;
025import org.nuxeo.ecm.platform.routing.api.DocumentRoutingService;
026
027/**
028 * The DocumentRoutingEngineService is responsible for managing the lifecycle of the DocumentRoute. This is an internal
029 * service, you should use method on the {@link DocumentRoutingService} to start a route.
030 */
031public interface DocumentRoutingEngineService {
032
033    /**
034     * Starts a route.
035     *
036     * @param routeInstance the route instance
037     * @param map the values to pass as initial workflow variables
038     * @param session the session
039     * @since 5.6
040     */
041    void start(DocumentRoute routeInstance, Map<String, Serializable> map, CoreSession session);
042
043    /**
044     * Resumes a route, optionnally for a given task only.
045     *
046     * @param routeInstance the route instance
047     * @param nodeId the node id to resume on (optional)
048     * @param taskId the task id that resumes (optional)
049     * @param data the data coming from UI form
050     * @param status the name of the button clicked to submit the associated task form
051     * @param session the session
052     * @since 5.6
053     */
054    void resume(DocumentRoute routeInstance, String nodeId, String taskId, Map<String, Object> data, String status,
055            CoreSession session);
056
057    /**
058     * Cancels a route using an unrestricted session. (@since 5.7.2 the event 'workflowCanceled' is notified.)
059     * 
060     * @param routeInstance the route instance
061     * @param session the session
062     * @since 5.6
063     */
064    void cancel(DocumentRoute routeInstance, CoreSession session);
065}