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.runtime.model.persistence;
013
014import java.util.List;
015
016/**
017 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
018 */
019public interface ContributionPersistenceManager {
020
021    /**
022     * Gets a list with all persisted contributions.
023     */
024    List<Contribution> getContributions();
025
026    /**
027     * Gets a contribution given its name.
028     */
029    Contribution getContribution(String name);
030
031    /**
032     * Persists a new contribution. The contribution will not be installed. You need to explicitly call
033     * {@link #installContribution(Contribution)} to install the contribution.
034     */
035    Contribution addContribution(Contribution contrib);
036
037    /**
038     * Removes a persisted contribution given its name. The contribution will not be uninstalled before being removed.
039     * You need to explicitly call {@link #uninstallContribution(Contribution)} to uninstall it.
040     *
041     * @return true if the contribution was removed, false if the contribution was not found in persistence.
042     */
043    boolean removeContribution(Contribution contrib);
044
045    /**
046     * Installs the contribution given its name. Return true if contribution install succeeds, false if the contribution
047     * is already installed.
048     * <p>
049     * To be able to install a contribution you need to persist it first.
050     */
051    boolean installContribution(Contribution contrib);
052
053    /**
054     * Uninstalls a contribution given is name. If not already installed return false otherwise return true. The
055     * contribution persisted state is not modified by this operation.
056     */
057    boolean uninstallContribution(Contribution contrib);
058
059    /**
060     * Updates in the storage the given contribution modifications.
061     * <p>
062     * A contribution cannot be renamed. The only permitted modifications are changing the description and the auto
063     * start status.
064     * <p>
065     * Return back the contribution object.
066     */
067    Contribution updateContribution(Contribution contribution);
068
069    /**
070     * Checks whether a contribution is currently installed.
071     */
072    boolean isInstalled(Contribution contrib);
073
074    /**
075     * Checks whether a contribution is currently persisted.
076     */
077    boolean isPersisted(Contribution contrib);
078
079    /**
080     * Starts the service. This will install all persisted contributions that are marked as auto-install. See
081     * {@link Contribution#isDisabled()}
082     */
083    void start();
084
085    /**
086     * Stops the service. This will uninstall all installed contributions.
087     */
088    void stop();
089
090}