mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 17:05:43 +01:00
improve post receive hook api
This commit is contained in:
@@ -66,6 +66,36 @@ public interface PostReceiveHookSupport
|
|||||||
public void firePostReceiveEvent(Repository repository,
|
public void firePostReceiveEvent(Repository repository,
|
||||||
List<Changeset> changesets);
|
List<Changeset> changesets);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fires a post receive hook event. This methods calls the
|
||||||
|
* {@link PostReceiveHook#onPostReceive(Repository, List)} of each registered
|
||||||
|
* {@link PostReceiveHook}.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param type of the repository
|
||||||
|
* @param name of the repository
|
||||||
|
* @param changesets which modified the repository
|
||||||
|
*
|
||||||
|
* @throws RepositoryNotFoundException if the repository could not be found.
|
||||||
|
*/
|
||||||
|
public void firePostReceiveEvent(String type, String name,
|
||||||
|
List<Changeset> changesets)
|
||||||
|
throws RepositoryNotFoundException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fires a post receive hook event. This methods calls the
|
||||||
|
* {@link PostReceiveHook#onPostReceive(Repository, List)} of each registered
|
||||||
|
* {@link PostReceiveHook}.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param id of the repository
|
||||||
|
* @param changesets which modified the repository
|
||||||
|
*
|
||||||
|
* @throws RepositoryNotFoundException if the repository could not be found
|
||||||
|
*/
|
||||||
|
public void firePostReceiveEvent(String id, List<Changeset> changesets)
|
||||||
|
throws RepositoryNotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregisters the given {@link PostReceiveHook}.
|
* Unregisters the given {@link PostReceiveHook}.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2010, Sebastian Sdorra
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* http://bitbucket.org/sdorra/scm-manager
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
package sonia.scm.repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Sebastian Sdorra
|
||||||
|
* @since 1.6
|
||||||
|
*/
|
||||||
|
public class RepositoryNotFoundException extends RepositoryException
|
||||||
|
{
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private static final long serialVersionUID = -6583078808900520166L;
|
||||||
|
}
|
||||||
@@ -58,6 +58,7 @@ import sonia.scm.repository.RepositoryBrowser;
|
|||||||
import sonia.scm.repository.RepositoryException;
|
import sonia.scm.repository.RepositoryException;
|
||||||
import sonia.scm.repository.RepositoryHandler;
|
import sonia.scm.repository.RepositoryHandler;
|
||||||
import sonia.scm.repository.RepositoryHandlerNotFoundException;
|
import sonia.scm.repository.RepositoryHandlerNotFoundException;
|
||||||
|
import sonia.scm.repository.RepositoryNotFoundException;
|
||||||
import sonia.scm.security.ScmSecurityException;
|
import sonia.scm.security.ScmSecurityException;
|
||||||
import sonia.scm.store.Store;
|
import sonia.scm.store.Store;
|
||||||
import sonia.scm.store.StoreFactory;
|
import sonia.scm.store.StoreFactory;
|
||||||
@@ -225,6 +226,54 @@ public class XmlRepositoryManager extends AbstractRepositoryManager
|
|||||||
fireEvent(repository, HandlerEvent.DELETE);
|
fireEvent(repository, HandlerEvent.DELETE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO protect
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @param name
|
||||||
|
* @param changesets
|
||||||
|
*
|
||||||
|
* @throws RepositoryNotFoundException
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void firePostReceiveEvent(String type, String name,
|
||||||
|
List<Changeset> changesets)
|
||||||
|
throws RepositoryNotFoundException
|
||||||
|
{
|
||||||
|
Repository repository = repositoryDB.get(type, name);
|
||||||
|
|
||||||
|
if (repository != null)
|
||||||
|
{
|
||||||
|
throw new RepositoryNotFoundException();
|
||||||
|
}
|
||||||
|
|
||||||
|
firePostReceiveEvent(repository, changesets);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO protect
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @param changesets
|
||||||
|
*
|
||||||
|
* @throws RepositoryNotFoundException
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void firePostReceiveEvent(String id, List<Changeset> changesets)
|
||||||
|
throws RepositoryNotFoundException
|
||||||
|
{
|
||||||
|
Repository repository = repositoryDB.get(id);
|
||||||
|
|
||||||
|
if (repository != null)
|
||||||
|
{
|
||||||
|
throw new RepositoryNotFoundException();
|
||||||
|
}
|
||||||
|
|
||||||
|
firePostReceiveEvent(repository, changesets);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user