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 *     bstefanescu
011 */
012package org.nuxeo.ecm.automation;
013
014/**
015 * The base exception of the operation service.
016 *
017 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
018 */
019public class OperationException extends Exception {
020
021    private static final long serialVersionUID = 1L;
022
023    protected boolean rollback = true;
024
025    public OperationException(String message) {
026        super(message);
027    }
028
029    public OperationException(Throwable cause) {
030        super(cause);
031    }
032
033    public OperationException(String message, Throwable cause) {
034        super(message, cause);
035    }
036
037    /**
038     * Whether this exception should rollback the current transaction. The default is true if not explicitly set by
039     * calling {@link #setNoRollback()}.
040     *
041     * @return
042     */
043    public boolean isRollback() {
044        return rollback;
045    }
046
047    public OperationException setNoRollback() {
048        rollback = false;
049        return this;
050    }
051}