mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
improve RepositoryManager api
This commit is contained in:
@@ -36,7 +36,7 @@ import javax.xml.bind.JAXB;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class HgRepositoryManager extends AbstractRepositoryManager
|
||||
public class HgRepositoryHandler implements RepositoryHandler
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
@@ -59,7 +59,7 @@ public class HgRepositoryManager extends AbstractRepositoryManager
|
||||
|
||||
/** Field description */
|
||||
private static final Logger logger =
|
||||
Logger.getLogger(HgRepositoryManager.class.getName());
|
||||
Logger.getLogger(HgRepositoryHandler.class.getName());
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
@@ -111,7 +111,6 @@ public class HgRepositoryManager extends AbstractRepositoryManager
|
||||
File hgDirectory = new File(directory, ".hg");
|
||||
|
||||
writeHgrc(repository, hgDirectory);
|
||||
fireEvent(repository, RepositoryEvent.CREATE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,7 +131,6 @@ public class HgRepositoryManager extends AbstractRepositoryManager
|
||||
if (new File(directory, ".hg").exists())
|
||||
{
|
||||
Util.delete(directory);
|
||||
fireEvent(repository, RepositoryEvent.DELETE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -187,7 +185,6 @@ public class HgRepositoryManager extends AbstractRepositoryManager
|
||||
if (hgDirectory.exists())
|
||||
{
|
||||
writeHgrc(repository, hgDirectory);
|
||||
fireEvent(repository, RepositoryEvent.MODIFY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,7 +232,9 @@ public class HgRepositoryManager extends AbstractRepositoryManager
|
||||
|
||||
if (hgDirectory.exists() && hgDirectory.isDirectory())
|
||||
{
|
||||
repository = new Repository(TYPE_NAME, name);
|
||||
repository = new Repository();
|
||||
repository.setType(TYPE_NAME);
|
||||
repository.setName(name);
|
||||
readHgrc(repository, hgDirectory);
|
||||
}
|
||||
}
|
||||
@@ -357,6 +356,15 @@ public class HgRepositoryManager extends AbstractRepositoryManager
|
||||
repository.setPermissions(permissions);
|
||||
}
|
||||
}
|
||||
|
||||
INISection scmSection = iniConfig.getSection("scm");
|
||||
|
||||
if (scmSection != null)
|
||||
{
|
||||
String id = scmSection.getParameter("id");
|
||||
|
||||
repository.setId(id);
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
@@ -402,9 +410,14 @@ public class HgRepositoryManager extends AbstractRepositoryManager
|
||||
appendPermission(section, permissions);
|
||||
}
|
||||
|
||||
INISection scmSection = new INISection("scm");
|
||||
|
||||
section.setParameter("id", repository.getId());
|
||||
|
||||
INIConfiguration iniConfig = new INIConfiguration();
|
||||
|
||||
iniConfig.addSection(section);
|
||||
iniConfig.addSection(scmSection);
|
||||
|
||||
File hgrc = new File(hgDirectory, "hgrc");
|
||||
INIConfigurationWriter writer = new INIConfigurationWriter();
|
||||
@@ -0,0 +1 @@
|
||||
sonia.scm.repository.HgRepositoryHandler
|
||||
@@ -1 +0,0 @@
|
||||
sonia.scm.repository.HgRepositoryManager
|
||||
@@ -10,8 +10,8 @@ package sonia.scm;
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.group.GroupManager;
|
||||
import sonia.scm.repository.BasicRepositoryManager;
|
||||
import sonia.scm.repository.RepositoryManager;
|
||||
import sonia.scm.repository.RepositoryType;
|
||||
import sonia.scm.util.ServiceUtil;
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
@@ -20,7 +20,6 @@ import sonia.scm.util.Util;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -68,10 +67,7 @@ public class BasicContextProvider implements SCMContextProvider
|
||||
manager.close();
|
||||
}
|
||||
|
||||
for (RepositoryManager manager : repositoryManagerMap.values())
|
||||
{
|
||||
manager.close();
|
||||
}
|
||||
repositoryManager.close();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,7 +78,7 @@ public class BasicContextProvider implements SCMContextProvider
|
||||
public void init()
|
||||
{
|
||||
loadGroupManagers();
|
||||
loadRepositoryManagers();
|
||||
loadRepositoryManager();
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
@@ -117,26 +113,13 @@ public class BasicContextProvider implements SCMContextProvider
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param type
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public RepositoryManager getRepositoryManager(String type)
|
||||
public RepositoryManager getRepositoryManager()
|
||||
{
|
||||
return repositoryManagerMap.get(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<RepositoryType> getRepositoryTypes()
|
||||
{
|
||||
return repositoryTypes;
|
||||
return repositoryManager;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
@@ -194,20 +177,16 @@ public class BasicContextProvider implements SCMContextProvider
|
||||
* Method description
|
||||
*
|
||||
*/
|
||||
private void loadRepositoryManagers()
|
||||
private void loadRepositoryManager()
|
||||
{
|
||||
repositoryManagerMap = new HashMap<String, RepositoryManager>();
|
||||
repositoryTypes = new ArrayList<RepositoryType>();
|
||||
repositoryManager = ServiceUtil.getService(RepositoryManager.class);
|
||||
|
||||
List<RepositoryManager> repositoryManagers =
|
||||
ServiceUtil.getServices(RepositoryManager.class);
|
||||
|
||||
for (RepositoryManager manager : repositoryManagers)
|
||||
if (repositoryManager == null)
|
||||
{
|
||||
manager.init(this);
|
||||
repositoryManagerMap.put(manager.getType().getName(), manager);
|
||||
repositoryTypes.add(manager.getType());
|
||||
repositoryManager = new BasicRepositoryManager();
|
||||
}
|
||||
|
||||
repositoryManager.init(this);
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
@@ -219,8 +198,5 @@ public class BasicContextProvider implements SCMContextProvider
|
||||
private Map<String, GroupManager> groupManagerMap;
|
||||
|
||||
/** Field description */
|
||||
private Map<String, RepositoryManager> repositoryManagerMap;
|
||||
|
||||
/** Field description */
|
||||
private List<RepositoryType> repositoryTypes;
|
||||
private RepositoryManager repositoryManager;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.Collection;
|
||||
* @param <T>
|
||||
* @param <E>
|
||||
*/
|
||||
public interface Manager<T, E extends Exception> extends Initable, Closeable
|
||||
public interface Handler<T, E extends Exception> extends Initable, Closeable
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -78,7 +78,7 @@ public interface Manager<T, E extends Exception> extends Initable, Closeable
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public T get(String name);
|
||||
public T get(String id);
|
||||
|
||||
/**
|
||||
* Method description
|
||||
@@ -87,12 +87,4 @@ public interface Manager<T, E extends Exception> extends Initable, Closeable
|
||||
* @return
|
||||
*/
|
||||
public Collection<T> getAll();
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isConfigured();
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import sonia.scm.repository.RepositoryType;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
@@ -57,16 +58,7 @@ public interface SCMContextProvider extends Closeable
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public RepositoryManager getRepositoryManager(String type);
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Collection<RepositoryType> getRepositoryTypes();
|
||||
public RepositoryManager getRepositoryManager();
|
||||
}
|
||||
|
||||
@@ -9,13 +9,13 @@ package sonia.scm.group;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.Manager;
|
||||
import sonia.scm.Handler;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public interface GroupManager extends Manager<Group, GroupException>
|
||||
public interface GroupManager extends Handler<Group, GroupException>
|
||||
{
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,251 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.repository;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.SCMContextProvider;
|
||||
import sonia.scm.util.ServiceUtil;
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class BasicRepositoryManager extends AbstractRepositoryManager
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
public BasicRepositoryManager()
|
||||
{
|
||||
handlerMap = new HashMap<String, RepositoryHandler>();
|
||||
types = new ArrayList<RepositoryType>();
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void close() throws IOException
|
||||
{
|
||||
for (RepositoryHandler manager : handlerMap.values())
|
||||
{
|
||||
manager.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Override
|
||||
public void create(Repository repository)
|
||||
throws RepositoryException, IOException
|
||||
{
|
||||
getHandler(repository).create(repository);
|
||||
fireEvent(repository, RepositoryEvent.CREATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Override
|
||||
public void delete(Repository repository)
|
||||
throws RepositoryException, IOException
|
||||
{
|
||||
getHandler(repository).delete(repository);
|
||||
fireEvent(repository, RepositoryEvent.DELETE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
@Override
|
||||
public void init(SCMContextProvider context)
|
||||
{
|
||||
List<RepositoryHandler> handlerList =
|
||||
ServiceUtil.getServices(RepositoryHandler.class);
|
||||
|
||||
if (Util.isNotEmpty(handlerList))
|
||||
{
|
||||
for (RepositoryHandler handler : handlerList)
|
||||
{
|
||||
RepositoryType type = handler.getType();
|
||||
|
||||
types.add(type);
|
||||
handlerMap.put(type.getName(), handler);
|
||||
handler.init(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Override
|
||||
public void modify(Repository repository)
|
||||
throws RepositoryException, IOException
|
||||
{
|
||||
getHandler(repository).modify(repository);
|
||||
fireEvent(repository, RepositoryEvent.MODIFY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Override
|
||||
public void refresh(Repository repository)
|
||||
throws RepositoryException, IOException
|
||||
{
|
||||
getHandler(repository).refresh(repository);
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Repository get(String id)
|
||||
{
|
||||
Repository repository = null;
|
||||
|
||||
for (RepositoryHandler handler : handlerMap.values())
|
||||
{
|
||||
repository = handler.get(id);
|
||||
|
||||
if (repository != null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Collection<Repository> getAll()
|
||||
{
|
||||
Set<Repository> repositories = new HashSet<Repository>();
|
||||
|
||||
for (RepositoryHandler handler : handlerMap.values())
|
||||
{
|
||||
Collection<Repository> handlerRepositories = handler.getAll();
|
||||
|
||||
if (handlerRepositories != null)
|
||||
{
|
||||
repositories.addAll(handlerRepositories);
|
||||
}
|
||||
}
|
||||
|
||||
return repositories;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Collection<RepositoryType> getTypes()
|
||||
{
|
||||
return types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws RepositoryHandlerNotFoundException
|
||||
*/
|
||||
private RepositoryHandler getHandler(Repository repository)
|
||||
throws RepositoryHandlerNotFoundException
|
||||
{
|
||||
String type = repository.getType();
|
||||
RepositoryHandler handler = handlerMap.get(type);
|
||||
|
||||
if (handler == null)
|
||||
{
|
||||
throw new RepositoryHandlerNotFoundException(
|
||||
"could not find handler for ".concat(type));
|
||||
}
|
||||
|
||||
return handler;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private Map<String, RepositoryHandler> handlerMap;
|
||||
|
||||
/** Field description */
|
||||
private List<RepositoryType> types;
|
||||
}
|
||||
@@ -29,7 +29,7 @@ import javax.xml.bind.annotation.XmlType;
|
||||
@XmlRootElement(name = "repositories")
|
||||
@XmlType(propOrder =
|
||||
{
|
||||
"type", "name", "contact", "description", "permissions"
|
||||
"id", "type", "name", "contact", "description", "permissions"
|
||||
})
|
||||
public class Repository implements Serializable
|
||||
{
|
||||
@@ -49,11 +49,14 @@ public class Repository implements Serializable
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param id
|
||||
* @param type
|
||||
* @param name
|
||||
*/
|
||||
public Repository(String type, String name)
|
||||
public Repository(String id, String type, String name)
|
||||
{
|
||||
this.id = id;
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
}
|
||||
@@ -62,15 +65,18 @@ public class Repository implements Serializable
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param id
|
||||
* @param type
|
||||
* @param name
|
||||
* @param contact
|
||||
* @param description
|
||||
* @param permissions
|
||||
*/
|
||||
public Repository(String type, String name, String contact,
|
||||
public Repository(String id, String type, String name, String contact,
|
||||
String description, Permission... permissions)
|
||||
{
|
||||
this.id = id;
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
this.contact = contact;
|
||||
@@ -107,6 +113,17 @@ public class Repository implements Serializable
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -164,6 +181,17 @@ public class Repository implements Serializable
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -205,6 +233,9 @@ public class Repository implements Serializable
|
||||
/** Field description */
|
||||
private String description;
|
||||
|
||||
/** Field description */
|
||||
private String id;
|
||||
|
||||
/** Field description */
|
||||
private String name;
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.repository;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.Handler;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public interface RepositoryHandler
|
||||
extends Handler<Repository, RepositoryException>
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isConfigured();
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public RepositoryType getType();
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.repository;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class RepositoryHandlerNotFoundException extends RepositoryException
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
private static final long serialVersionUID = 5270463060802850944L;
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
public RepositoryHandlerNotFoundException() {}
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
public RepositoryHandlerNotFoundException(String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -9,15 +9,20 @@ package sonia.scm.repository;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.Handler;
|
||||
import sonia.scm.ListenerSupport;
|
||||
import sonia.scm.Manager;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public interface RepositoryManager
|
||||
extends Manager<Repository, RepositoryException>, ListenerSupport<RepositoryListener>
|
||||
extends Handler<Repository, RepositoryException>,
|
||||
ListenerSupport<RepositoryListener>
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -26,5 +31,5 @@ public interface RepositoryManager
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public RepositoryType getType();
|
||||
public Collection<RepositoryType> getTypes();
|
||||
}
|
||||
|
||||
@@ -16,10 +16,12 @@ import com.google.inject.servlet.ServletModule;
|
||||
|
||||
import sonia.scm.api.rest.UriExtensionsConfig;
|
||||
import sonia.scm.filter.GZipFilter;
|
||||
import sonia.scm.filter.SecurityFilter;
|
||||
import sonia.scm.filter.StaticResourceFilter;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.RepositoryManager;
|
||||
import sonia.scm.security.Authenticator;
|
||||
import sonia.scm.security.DemoAuthenticator;
|
||||
import sonia.scm.security.SecurityFilter;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
@@ -79,8 +81,12 @@ public class ContextListener extends GuiceServletContextListener
|
||||
@Override
|
||||
protected void configureServlets()
|
||||
{
|
||||
SCMContextProvider context = SCMContext.getContext();
|
||||
|
||||
bind(Authenticator.class).to(DemoAuthenticator.class);
|
||||
bind(SCMContextProvider.class).toInstance(SCMContext.getContext());
|
||||
bind(SCMContextProvider.class).toInstance(context);
|
||||
bind(RepositoryManager.class).toInstance(
|
||||
context.getRepositoryManager());
|
||||
|
||||
// filters
|
||||
filter(PATTERN_PAGE,
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.google.inject.Inject;
|
||||
import sonia.scm.SCMContext;
|
||||
import sonia.scm.ScmState;
|
||||
import sonia.scm.User;
|
||||
import sonia.scm.repository.RepositoryManager;
|
||||
import sonia.scm.repository.RepositoryType;
|
||||
import sonia.scm.security.Authenticator;
|
||||
|
||||
@@ -111,8 +112,7 @@ public class AuthenticationResource
|
||||
|
||||
state.setUser(user);
|
||||
state.setRepositoryTypes(
|
||||
SCMContext.getContext().getRepositoryTypes().toArray(
|
||||
new RepositoryType[0]));
|
||||
repositoryManger.getTypes().toArray(new RepositoryType[0]));
|
||||
|
||||
return state;
|
||||
}
|
||||
@@ -122,4 +122,8 @@ public class AuthenticationResource
|
||||
/** Field description */
|
||||
@Inject
|
||||
private Authenticator authenticator;
|
||||
|
||||
/** Field description */
|
||||
@Inject
|
||||
private RepositoryManager repositoryManger;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import sonia.scm.repository.Repository;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
@@ -45,29 +45,31 @@ public class RepositoryResource extends AbstractResource<Repository>
|
||||
{
|
||||
repositoryStore = new LinkedHashMap<String, Repository>();
|
||||
repositoryStore.put("sonia.lib",
|
||||
new Repository("hg", "sonia.lib", "csit@ostfalia.de",
|
||||
"SONIA Library",
|
||||
new Repository(createId(), "hg", "sonia.lib",
|
||||
"csit@ostfalia.de", "SONIA Library",
|
||||
new Permission("csit", true, true,
|
||||
true)));
|
||||
repositoryStore.put("sonia.misc",
|
||||
new Repository("hg", "sonia.misc", "csit@ostfalia.de",
|
||||
new Repository(createId(), "hg", "sonia.misc",
|
||||
"csit@ostfalia.de",
|
||||
"SONIA Miscelanious",
|
||||
new Permission("csit", true, true,
|
||||
true)));
|
||||
repositoryStore.put("PWA",
|
||||
new Repository("svn", "PWA",
|
||||
new Repository(createId(), "svn", "PWA",
|
||||
"csit@fh-wolfenbuettel.de", "PWA",
|
||||
new Permission("th", true, true),
|
||||
new Permission("sdorra", true, true),
|
||||
new Permission("oelkersd", true,
|
||||
false)));
|
||||
repositoryStore.put("sonia.app",
|
||||
new Repository("hg", "sonia.app", "csit@ostfalia.de",
|
||||
new Repository(createId(), "hg", "sonia.app",
|
||||
"csit@ostfalia.de",
|
||||
"SONIA Applications",
|
||||
new Permission("csit", true, true,
|
||||
true)));
|
||||
repositoryStore.put("sonia.webapps",
|
||||
new Repository("hg", "sonia.webapps",
|
||||
new Repository(createId(), "hg", "sonia.webapps",
|
||||
"csit@ostfalia.de",
|
||||
"SONIA WebApplications",
|
||||
new Permission("csit", true, true,
|
||||
@@ -173,6 +175,19 @@ public class RepositoryResource extends AbstractResource<Repository>
|
||||
return PATH_PART;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String createId()
|
||||
{
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
|
||||
|
||||
package sonia.scm.security;
|
||||
package sonia.scm.filter;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
@@ -13,7 +13,6 @@ import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import sonia.scm.User;
|
||||
import sonia.scm.filter.HttpFilter;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
@@ -26,6 +25,7 @@ import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import sonia.scm.security.Authenticator;
|
||||
|
||||
/**
|
||||
*
|
||||
Reference in New Issue
Block a user