001/*
002 * (C) Copyright 2010-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.impl;
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.DocumentRouteElement;
028
029/**
030 * Runner responsible to run or undo an element of a route.
031 */
032public interface ElementRunner {
033
034    /**
035     * Run this element.
036     */
037    void run(CoreSession session, DocumentRouteElement element, Map<String, Serializable> map);
038
039    /**
040     * Run this element. If an exception is thrown while doing, it cancels the route.
041     */
042    void run(CoreSession session, DocumentRouteElement element);
043
044    /**
045     * Resumes this graph route on a given node.
046     *
047     * @since 5.6
048     */
049    void resume(CoreSession session, DocumentRouteElement element, String nodeId, String taskId,
050            Map<String, Object> data, String status);
051
052    /**
053     * Run the undo chain on this element. If this element is not a step, then throw an exception.
054     *
055     * @deprecated since 5.9.2 - Use only routes of type 'graph'
056     */
057    @Deprecated
058    void undo(CoreSession session, DocumentRouteElement element);
059
060    /**
061     * Cancel this element.
062     *
063     * @see DocumentRoute#cancel(CoreSession)
064     */
065    void cancel(CoreSession session, DocumentRouteElement element);
066}