mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 06:25:45 +01:00
added basic structure
This commit is contained in:
29
scm-core/src/main/java/sonia/scm/BasicContextProvider.java
Normal file
29
scm-core/src/main/java/sonia/scm/BasicContextProvider.java
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package sonia.scm;
|
||||||
|
|
||||||
|
import sonia.scm.group.GroupManager;
|
||||||
|
import sonia.scm.repository.RepositoryManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Sebastian Sdorra
|
||||||
|
*/
|
||||||
|
public class BasicContextProvider implements SCMContextProvider {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GroupManager getGroupManager()
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException("Not supported yet.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RepositoryManager getRepositoryManager()
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException("Not supported yet.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
24
scm-core/src/main/java/sonia/scm/Initable.java
Normal file
24
scm-core/src/main/java/sonia/scm/Initable.java
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
package sonia.scm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Sebastian Sdorra
|
||||||
|
*/
|
||||||
|
public interface Initable
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
*/
|
||||||
|
public void init(SCMContextProvider context);
|
||||||
|
}
|
||||||
90
scm-core/src/main/java/sonia/scm/Manager.java
Normal file
90
scm-core/src/main/java/sonia/scm/Manager.java
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
package sonia.scm;
|
||||||
|
|
||||||
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Sebastian Sdorra
|
||||||
|
*
|
||||||
|
* @param <T>
|
||||||
|
* @param <E>
|
||||||
|
*/
|
||||||
|
public interface Manager<T, E extends Exception> extends Initable, Closeable
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param object
|
||||||
|
*
|
||||||
|
* @throws E
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public void create(T object) throws E, IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param object
|
||||||
|
*
|
||||||
|
* @throws E
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public void delete(T object) throws E, IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param object
|
||||||
|
*
|
||||||
|
* @throws E
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public void modify(T object) throws E, IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param object
|
||||||
|
*
|
||||||
|
* @throws E
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public void refresh(T object) throws E, IOException;
|
||||||
|
|
||||||
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public T get(String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Collection<T> getAll();
|
||||||
|
}
|
||||||
52
scm-core/src/main/java/sonia/scm/SCMContext.java
Normal file
52
scm-core/src/main/java/sonia/scm/SCMContext.java
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
package sonia.scm;
|
||||||
|
|
||||||
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
|
import sonia.scm.util.ServiceUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Sebastian Sdorra
|
||||||
|
*/
|
||||||
|
public class SCMContext
|
||||||
|
{
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private static volatile SCMContextProvider provider;
|
||||||
|
|
||||||
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static SCMContextProvider getContext()
|
||||||
|
{
|
||||||
|
if (provider == null)
|
||||||
|
{
|
||||||
|
synchronized (SCMContext.class)
|
||||||
|
{
|
||||||
|
if (provider == null)
|
||||||
|
{
|
||||||
|
provider = ServiceUtil.getService(SCMContextProvider.class);
|
||||||
|
|
||||||
|
if (provider == null)
|
||||||
|
{
|
||||||
|
provider = new BasicContextProvider();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return provider;
|
||||||
|
}
|
||||||
|
}
|
||||||
37
scm-core/src/main/java/sonia/scm/SCMContextProvider.java
Normal file
37
scm-core/src/main/java/sonia/scm/SCMContextProvider.java
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
package sonia.scm;
|
||||||
|
|
||||||
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
|
import sonia.scm.group.GroupManager;
|
||||||
|
import sonia.scm.repository.RepositoryManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Sebastian Sdorra
|
||||||
|
*/
|
||||||
|
public interface SCMContextProvider
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public GroupManager getGroupManager();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public RepositoryManager getRepositoryManager();
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm;
|
package sonia.scm.group;
|
||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
package sonia.scm.group;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Sebastian Sdorra
|
||||||
|
*/
|
||||||
|
public class GroupAllreadyExistExeption extends GroupException
|
||||||
|
{
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private static final long serialVersionUID = 4042878550219750430L;
|
||||||
|
}
|
||||||
64
scm-core/src/main/java/sonia/scm/group/GroupException.java
Normal file
64
scm-core/src/main/java/sonia/scm/group/GroupException.java
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
package sonia.scm.group;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Sebastian Sdorra
|
||||||
|
*/
|
||||||
|
public class GroupException extends Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private static final long serialVersionUID = 5191341492098994225L;
|
||||||
|
|
||||||
|
//~--- constructors ---------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs ...
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public GroupException()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs ...
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
*/
|
||||||
|
public GroupException(String message)
|
||||||
|
{
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs ...
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param cause
|
||||||
|
*/
|
||||||
|
public GroupException(Throwable cause)
|
||||||
|
{
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs ...
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
* @param cause
|
||||||
|
*/
|
||||||
|
public GroupException(String message, Throwable cause)
|
||||||
|
{
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
}
|
||||||
18
scm-core/src/main/java/sonia/scm/group/GroupManager.java
Normal file
18
scm-core/src/main/java/sonia/scm/group/GroupManager.java
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
package sonia.scm.group;
|
||||||
|
|
||||||
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
|
import sonia.scm.Manager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Sebastian Sdorra
|
||||||
|
*/
|
||||||
|
public interface GroupManager extends Manager<Group, GroupException> {}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm;
|
package sonia.scm.repository;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
package sonia.scm.repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Sebastian Sdorra
|
||||||
|
*/
|
||||||
|
public class RepositoryAllreadyExistExeption extends RepositoryException
|
||||||
|
{
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private static final long serialVersionUID = -774929917214137675L;
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
package sonia.scm.repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Sebastian Sdorra
|
||||||
|
*/
|
||||||
|
public class RepositoryException extends Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private static final long serialVersionUID = -4939196278070910058L;
|
||||||
|
|
||||||
|
//~--- constructors ---------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs ...
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public RepositoryException()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs ...
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
*/
|
||||||
|
public RepositoryException(String message)
|
||||||
|
{
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs ...
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param cause
|
||||||
|
*/
|
||||||
|
public RepositoryException(Throwable cause)
|
||||||
|
{
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs ...
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
* @param cause
|
||||||
|
*/
|
||||||
|
public RepositoryException(String message, Throwable cause)
|
||||||
|
{
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
package sonia.scm.repository;
|
||||||
|
|
||||||
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
|
import sonia.scm.Manager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Sebastian Sdorra
|
||||||
|
*/
|
||||||
|
public interface RepositoryManager
|
||||||
|
extends Manager<Repository, RepositoryException> {}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm;
|
package sonia.scm.repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
119
scm-core/src/main/java/sonia/scm/util/ServiceUtil.java
Normal file
119
scm-core/src/main/java/sonia/scm/util/ServiceUtil.java
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package sonia.scm.util;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
import java.util.ServiceLoader;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Sebastian Sdorra
|
||||||
|
*/
|
||||||
|
public class ServiceUtil
|
||||||
|
{
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private static final Logger logger =
|
||||||
|
Logger.getLogger(ServiceUtil.class.getName());
|
||||||
|
|
||||||
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @param def
|
||||||
|
* @param <T>
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static <T> T getService(Class<T> type, T def)
|
||||||
|
{
|
||||||
|
T result = getService(type);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
result = def;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @param <T>
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static <T> T getService(Class<T> type)
|
||||||
|
{
|
||||||
|
T result = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ServiceLoader<T> loader = ServiceLoader.load(type);
|
||||||
|
|
||||||
|
if (loader != null)
|
||||||
|
{
|
||||||
|
result = loader.iterator().next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (NoSuchElementException ex)
|
||||||
|
{
|
||||||
|
if (logger.isLoggable(Level.FINEST))
|
||||||
|
{
|
||||||
|
logger.log(Level.FINEST, null, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @param <T>
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static <T> List<T> getServices(Class<T> type)
|
||||||
|
{
|
||||||
|
List<T> result = new ArrayList<T>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ServiceLoader<T> loader = ServiceLoader.load(type);
|
||||||
|
|
||||||
|
if (loader != null)
|
||||||
|
{
|
||||||
|
for (T service : loader)
|
||||||
|
{
|
||||||
|
result.add(service);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (NoSuchElementException ex)
|
||||||
|
{
|
||||||
|
if (logger.isLoggable(Level.FINEST))
|
||||||
|
{
|
||||||
|
logger.log(Level.FINEST, null, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -9,6 +9,7 @@ package sonia.scm;
|
|||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
|
import sonia.scm.repository.RepositoryType;
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ package sonia.scm.api.rest;
|
|||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
import sonia.scm.Group;
|
import sonia.scm.group.Group;
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
import com.sun.jersey.api.json.JSONConfiguration;
|
import com.sun.jersey.api.json.JSONConfiguration;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ package sonia.scm.api.rest.resources;
|
|||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
import sonia.scm.RepositoryType;
|
import sonia.scm.repository.RepositoryType;
|
||||||
import sonia.scm.ScmState;
|
import sonia.scm.ScmState;
|
||||||
import sonia.scm.User;
|
import sonia.scm.User;
|
||||||
import sonia.scm.security.Authenticator;
|
import sonia.scm.security.Authenticator;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ package sonia.scm.api.rest.resources;
|
|||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
import sonia.scm.Group;
|
import sonia.scm.group.Group;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ package sonia.scm.api.rest.resources;
|
|||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
import sonia.scm.Repository;
|
import sonia.scm.repository.Repository;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user