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