improve handler and manager api

This commit is contained in:
Sebastian Sdorra
2010-11-05 18:19:43 +01:00
parent 137279c30a
commit fb20f3a26d
20 changed files with 326 additions and 191 deletions

View File

@@ -29,12 +29,15 @@
* *
*/ */
package sonia.scm.repository; package sonia.scm.repository;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------
import com.google.inject.Singleton; import com.google.inject.Singleton;
import sonia.scm.Type;
import sonia.scm.io.CommandResult; import sonia.scm.io.CommandResult;
import sonia.scm.io.ExtendedCommand; import sonia.scm.io.ExtendedCommand;
@@ -59,8 +62,7 @@ public class GitRepositoryHandler
public static final String TYPE_NAME = "git"; public static final String TYPE_NAME = "git";
/** Field description */ /** Field description */
public static final RepositoryType TYPE = new RepositoryType(TYPE_NAME, public static final Type TYPE = new Type(TYPE_NAME, TYPE_DISPLAYNAME);
TYPE_DISPLAYNAME);
//~--- get methods ---------------------------------------------------------- //~--- get methods ----------------------------------------------------------
@@ -71,7 +73,7 @@ public class GitRepositoryHandler
* @return * @return
*/ */
@Override @Override
public RepositoryType getType() public Type getType()
{ {
return TYPE; return TYPE;
} }

View File

@@ -29,6 +29,8 @@
* *
*/ */
package sonia.scm.repository; package sonia.scm.repository;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------
@@ -39,6 +41,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import sonia.scm.ConfigurationException; import sonia.scm.ConfigurationException;
import sonia.scm.Type;
import sonia.scm.io.CommandResult; import sonia.scm.io.CommandResult;
import sonia.scm.io.ExtendedCommand; import sonia.scm.io.ExtendedCommand;
import sonia.scm.io.INIConfiguration; import sonia.scm.io.INIConfiguration;
@@ -75,8 +78,7 @@ public class HgRepositoryHandler extends AbstractRepositoryHandler<HgConfig>
public static final String TYPE_NAME = "hg"; public static final String TYPE_NAME = "hg";
/** Field description */ /** Field description */
public static final RepositoryType TYPE = new RepositoryType(TYPE_NAME, public static final Type TYPE = new Type(TYPE_NAME, TYPE_DISPLAYNAME);
TYPE_DISPLAYNAME);
/** Field description */ /** Field description */
private static final Logger logger = private static final Logger logger =
@@ -275,7 +277,7 @@ public class HgRepositoryHandler extends AbstractRepositoryHandler<HgConfig>
* @return * @return
*/ */
@Override @Override
public RepositoryType getType() public Type getType()
{ {
return TYPE; return TYPE;
} }

View File

@@ -29,10 +29,13 @@
* *
*/ */
package sonia.scm.repository; package sonia.scm.repository;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------
import sonia.scm.Type;
import sonia.scm.io.ExtendedCommand; import sonia.scm.io.ExtendedCommand;
//~--- JDK imports ------------------------------------------------------------ //~--- JDK imports ------------------------------------------------------------
@@ -54,8 +57,7 @@ public class SvnRepositoryHandler
public static final String TYPE_NAME = "svn"; public static final String TYPE_NAME = "svn";
/** Field description */ /** Field description */
public static final RepositoryType TYPE = new RepositoryType(TYPE_NAME, public static final Type TYPE = new Type(TYPE_NAME, TYPE_DISPLAYNAME);
TYPE_DISPLAYNAME);
//~--- get methods ---------------------------------------------------------- //~--- get methods ----------------------------------------------------------
@@ -66,7 +68,7 @@ public class SvnRepositoryHandler
* @return * @return
*/ */
@Override @Override
public RepositoryType getType() public Type getType()
{ {
return TYPE; return TYPE;
} }

View File

@@ -29,15 +29,10 @@
* *
*/ */
package sonia.scm; package sonia.scm;
//~--- JDK imports ------------------------------------------------------------
import java.io.Closeable;
import java.io.IOException;
import java.util.Collection;
/** /**
* *
* @author Sebastian Sdorra * @author Sebastian Sdorra
@@ -45,65 +40,17 @@ import java.util.Collection;
* @param <T> * @param <T>
* @param <E> * @param <E>
*/ */
public interface Handler<T, E extends Exception> extends Initable, Closeable public interface Handler<T extends TypedObject, E extends Exception>
extends HandlerBase<T, E>
{ {
/** /**
* Method description * 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 id
*
* @return * @return
*/ */
public T get(String id); public Type getType();
/** /**
* Method description * Method description
@@ -111,5 +58,5 @@ public interface Handler<T, E extends Exception> extends Initable, Closeable
* *
* @return * @return
*/ */
public Collection<T> getAll(); public boolean isConfigured();
} }

View File

@@ -0,0 +1,110 @@
/**
* 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;
import java.io.Closeable;
import java.io.IOException;
import java.util.Collection;
/**
*
* @author Sebastian Sdorra
*/
public interface HandlerBase<T extends TypedObject, 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 id
*
* @return
*/
public T get(String id);
/**
* Method description
*
*
* @return
*/
public Collection<T> getAll();
}

View File

@@ -29,10 +29,10 @@
* *
*/ */
package sonia.scm.repository; package sonia.scm;
/** /**
* *
* @author Sebastian Sdorra * @author Sebastian Sdorra
*/ */
public enum RepositoryEvent { CREATE, MODIFY, DELETE } public enum HandlerEvent { CREATE, MODIFY, DELETE }

View File

@@ -0,0 +1,58 @@
/**
* 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;
//~--- JDK imports ------------------------------------------------------------
import java.util.Collection;
/**
*
* @author Sebastian Sdorra
*
* @param <T>
* @param <E>
*/
public interface Manager<T extends TypedObject, E extends Exception>
extends HandlerBase<T, E>
{
/**
* Method description
*
*
* @return
*/
public Collection<Type> getTypes();
}

View File

@@ -29,20 +29,27 @@
* *
*/ */
package sonia.scm.repository;
package sonia.scm;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.util.AssertUtil;
import sonia.scm.util.Util;
/** /**
* *
* @author Sebastian Sdorra * @author Sebastian Sdorra
*/ */
public class RepositoryType public class Type
{ {
/** /**
* Constructs ... * Constructor is required for JAXB
* *
*/ */
public RepositoryType() {} public Type() {}
/** /**
* Constructs ... * Constructs ...
@@ -51,14 +58,84 @@ public class RepositoryType
* @param name * @param name
* @param displayName * @param displayName
*/ */
public RepositoryType(String name, String displayName) public Type(String name, String displayName)
{ {
AssertUtil.assertIsNotEmpty(name);
this.name = name; this.name = name;
this.displayName = displayName;
if (Util.isNotEmpty(displayName))
{
this.displayName = displayName;
}
else
{
this.displayName = name;
}
} }
//~--- methods -------------------------------------------------------------- //~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param obj
*
* @return
*/
@Override
public boolean equals(Object obj)
{
if (obj == null)
{
return false;
}
if (getClass() != obj.getClass())
{
return false;
}
final Type other = (Type) obj;
if ((this.name == null)
? (other.name != null)
: !this.name.equals(other.name))
{
return false;
}
if ((this.displayName == null)
? (other.displayName != null)
: !this.displayName.equals(other.displayName))
{
return false;
}
return true;
}
/**
* Method description
*
*
* @return
*/
@Override
public int hashCode()
{
int hash = 5;
hash = 37 * hash + ((this.name != null)
? this.name.hashCode()
: 0);
hash = 37 * hash + ((this.displayName != null)
? this.displayName.hashCode()
: 0);
return hash;
}
/** /**
* Method description * Method description
* *
@@ -68,11 +145,11 @@ public class RepositoryType
@Override @Override
public String toString() public String toString()
{ {
StringBuilder msg = new StringBuilder(name); StringBuilder out = new StringBuilder("Type{name=");
msg.append(" (").append(displayName).append(")"); out.append(name).append(", displayName=").append(displayName).append("}");
return msg.toString(); return out.toString();
} }
//~--- get methods ---------------------------------------------------------- //~--- get methods ----------------------------------------------------------

View File

@@ -29,10 +29,13 @@
* *
*/ */
package sonia.scm.group; package sonia.scm.group;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------
import sonia.scm.TypedObject;
import sonia.scm.util.Util; import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------ //~--- JDK imports ------------------------------------------------------------
@@ -56,7 +59,7 @@ import javax.xml.bind.annotation.XmlType;
@XmlRootElement(name = "groups") @XmlRootElement(name = "groups")
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = { "type", "name", "members" }) @XmlType(propOrder = { "type", "name", "members" })
public class Group implements Serializable public class Group implements TypedObject, Serializable
{ {
/** Field description */ /** Field description */
@@ -220,6 +223,7 @@ public class Group implements Serializable
* *
* @return * @return
*/ */
@Override
public String getType() public String getType()
{ {
return type; return type;

View File

@@ -29,6 +29,8 @@
* *
*/ */
package sonia.scm.group; package sonia.scm.group;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------
@@ -39,14 +41,4 @@ import sonia.scm.Handler;
* *
* @author Sebastian Sdorra * @author Sebastian Sdorra
*/ */
public interface GroupManager extends Handler<Group, GroupException> public interface GroupManager extends Handler<Group, GroupException> {}
{
/**
* Method description
*
*
* @return
*/
public String getType();
}

View File

@@ -33,6 +33,7 @@ package sonia.scm.repository;
//~--- JDK imports ------------------------------------------------------------ //~--- JDK imports ------------------------------------------------------------
import sonia.scm.HandlerEvent;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@@ -74,7 +75,7 @@ public abstract class AbstractRepositoryManager implements RepositoryManager
* @param repository * @param repository
* @param event * @param event
*/ */
protected void fireEvent(Repository repository, RepositoryEvent event) protected void fireEvent(Repository repository, HandlerEvent event)
{ {
for (RepositoryListener listener : listenerSet) for (RepositoryListener listener : listenerSet)
{ {

View File

@@ -40,6 +40,7 @@ import sonia.scm.SCMContextProvider;
import java.io.IOException; import java.io.IOException;
import java.util.Collection; import java.util.Collection;
import sonia.scm.Type;
/** /**
* *
@@ -60,20 +61,6 @@ public abstract class AbstractRepositoryManagerDecorator
this.orginal = orginal; this.orginal = orginal;
} }
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param handler
*/
@Override
public void addHandler(RepositoryHandler handler)
{
orginal.addHandler(handler);
}
/** /**
* Method description * Method description
* *
@@ -145,7 +132,7 @@ public abstract class AbstractRepositoryManagerDecorator
* @return * @return
*/ */
@Override @Override
public Collection<RepositoryType> getTypes() public Collection<Type> getTypes()
{ {
return orginal.getTypes(); return orginal.getTypes();
} }

View File

@@ -33,6 +33,7 @@ package sonia.scm.repository;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------
import sonia.scm.HandlerEvent;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Singleton; import com.google.inject.Singleton;
@@ -56,6 +57,7 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import sonia.scm.Type;
/** /**
* *
@@ -81,7 +83,7 @@ public class BasicRepositoryManager extends AbstractRepositoryManager
public BasicRepositoryManager(Set<RepositoryHandler> handlerSet) public BasicRepositoryManager(Set<RepositoryHandler> handlerSet)
{ {
handlerMap = new HashMap<String, RepositoryHandler>(); handlerMap = new HashMap<String, RepositoryHandler>();
types = new ArrayList<RepositoryType>(); types = new ArrayList<Type>();
for (RepositoryHandler handler : handlerSet) for (RepositoryHandler handler : handlerSet)
{ {
@@ -91,18 +93,11 @@ public class BasicRepositoryManager extends AbstractRepositoryManager
//~--- methods -------------------------------------------------------------- //~--- methods --------------------------------------------------------------
/** private void addHandler(RepositoryHandler handler)
* Method description
*
*
* @param handler
*/
@Override
public void addHandler(RepositoryHandler handler)
{ {
AssertUtil.assertIsNotNull(handler); AssertUtil.assertIsNotNull(handler);
RepositoryType type = handler.getType(); Type type = handler.getType();
AssertUtil.assertIsNotNull(type); AssertUtil.assertIsNotNull(type);
@@ -158,7 +153,7 @@ public class BasicRepositoryManager extends AbstractRepositoryManager
} }
getHandler(repository).create(repository); getHandler(repository).create(repository);
fireEvent(repository, RepositoryEvent.CREATE); fireEvent(repository, HandlerEvent.CREATE);
} }
/** /**
@@ -181,7 +176,7 @@ public class BasicRepositoryManager extends AbstractRepositoryManager
} }
getHandler(repository).delete(repository); getHandler(repository).delete(repository);
fireEvent(repository, RepositoryEvent.DELETE); fireEvent(repository, HandlerEvent.DELETE);
} }
/** /**
@@ -213,7 +208,7 @@ public class BasicRepositoryManager extends AbstractRepositoryManager
} }
getHandler(repository).modify(repository); getHandler(repository).modify(repository);
fireEvent(repository, RepositoryEvent.MODIFY); fireEvent(repository, HandlerEvent.MODIFY);
} }
/** /**
@@ -322,7 +317,7 @@ public class BasicRepositoryManager extends AbstractRepositoryManager
* @return * @return
*/ */
@Override @Override
public Collection<RepositoryType> getTypes() public Collection<Type> getTypes()
{ {
return types; return types;
} }
@@ -363,5 +358,5 @@ public class BasicRepositoryManager extends AbstractRepositoryManager
private Map<String, RepositoryHandler> handlerMap; private Map<String, RepositoryHandler> handlerMap;
/** Field description */ /** Field description */
private List<RepositoryType> types; private List<Type> types;
} }

View File

@@ -29,6 +29,8 @@
* *
*/ */
package sonia.scm.repository; package sonia.scm.repository;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------
@@ -44,22 +46,4 @@ import sonia.scm.ListenerSupport;
*/ */
public interface RepositoryHandler public interface RepositoryHandler
extends Handler<Repository, RepositoryException>, extends Handler<Repository, RepositoryException>,
ListenerSupport<ConfigChangedListener> ListenerSupport<ConfigChangedListener> {}
{
/**
* Method description
*
*
* @return
*/
public RepositoryType getType();
/**
* Method description
*
*
* @return
*/
public boolean isConfigured();
}

View File

@@ -31,6 +31,8 @@
package sonia.scm.repository; package sonia.scm.repository;
import sonia.scm.HandlerEvent;
/** /**
* *
* @author Sebastian Sdorra * @author Sebastian Sdorra
@@ -45,5 +47,5 @@ public interface RepositoryListener
* @param repository * @param repository
* @param event * @param event
*/ */
public void onEvent(Repository repository, RepositoryEvent event); public void onEvent(Repository repository, HandlerEvent event);
} }

View File

@@ -29,36 +29,24 @@
* *
*/ */
package sonia.scm.repository; package sonia.scm.repository;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------
import sonia.scm.Handler;
import sonia.scm.ListenerSupport; import sonia.scm.ListenerSupport;
import sonia.scm.Manager;
//~--- JDK imports ------------------------------------------------------------
import java.util.Collection;
/** /**
* *
* @author Sebastian Sdorra * @author Sebastian Sdorra
*/ */
public interface RepositoryManager public interface RepositoryManager
extends Handler<Repository, RepositoryException>, extends Manager<Repository, RepositoryException>,
ListenerSupport<RepositoryListener> ListenerSupport<RepositoryListener>
{ {
/**
* Method description
*
*
* @param handler
*/
public void addHandler(RepositoryHandler handler);
//~--- get methods ----------------------------------------------------------
/** /**
* Method description * Method description
* *
@@ -68,12 +56,4 @@ public interface RepositoryManager
* @return * @return
*/ */
public RepositoryHandler getHandler(String type); public RepositoryHandler getHandler(String type);
/**
* Method description
*
*
* @return
*/
public Collection<RepositoryType> getTypes();
} }

View File

@@ -29,12 +29,13 @@
* *
*/ */
package sonia.scm; package sonia.scm;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------
import sonia.scm.user.User; import sonia.scm.user.User;
import sonia.scm.repository.RepositoryType;
//~--- JDK imports ------------------------------------------------------------ //~--- JDK imports ------------------------------------------------------------
@@ -65,7 +66,7 @@ public class ScmState
* @param user * @param user
* @param repositoryTypes * @param repositoryTypes
*/ */
public ScmState(User user, RepositoryType[] repositoryTypes) public ScmState(User user, Type[] repositoryTypes)
{ {
this.user = user; this.user = user;
this.repositoryTypes = repositoryTypes; this.repositoryTypes = repositoryTypes;
@@ -79,7 +80,7 @@ public class ScmState
* *
* @return * @return
*/ */
public RepositoryType[] getRepositoryTypes() public Type[] getRepositoryTypes()
{ {
return repositoryTypes; return repositoryTypes;
} }
@@ -114,7 +115,7 @@ public class ScmState
* *
* @param repositoryTypes * @param repositoryTypes
*/ */
public void setRepositoryTypes(RepositoryType[] repositoryTypes) public void setRepositoryTypes(Type[] repositoryTypes)
{ {
this.repositoryTypes = repositoryTypes; this.repositoryTypes = repositoryTypes;
} }
@@ -145,7 +146,7 @@ public class ScmState
/** Field description */ /** Field description */
@XmlElement(name = "repositoryTypes") @XmlElement(name = "repositoryTypes")
private RepositoryType[] repositoryTypes; private Type[] repositoryTypes;
/** Field description */ /** Field description */
private boolean success = true; private boolean success = true;

View File

@@ -29,6 +29,8 @@
* *
*/ */
package sonia.scm.api.rest.resources; package sonia.scm.api.rest.resources;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------
@@ -37,9 +39,9 @@ import com.google.inject.Inject;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import sonia.scm.ScmState; import sonia.scm.ScmState;
import sonia.scm.user.User; import sonia.scm.Type;
import sonia.scm.repository.RepositoryManager; import sonia.scm.repository.RepositoryManager;
import sonia.scm.repository.RepositoryType; import sonia.scm.user.User;
import sonia.scm.web.security.SecurityContext; import sonia.scm.web.security.SecurityContext;
//~--- JDK imports ------------------------------------------------------------ //~--- JDK imports ------------------------------------------------------------
@@ -162,8 +164,7 @@ public class AuthenticationResource
ScmState state = new ScmState(); ScmState state = new ScmState();
state.setUser(user); state.setUser(user);
state.setRepositoryTypes( state.setRepositoryTypes(repositoryManger.getTypes().toArray(new Type[0]));
repositoryManger.getTypes().toArray(new RepositoryType[0]));
return state; return state;
} }

View File

@@ -29,6 +29,8 @@
* *
*/ */
package sonia.scm.cache; package sonia.scm.cache;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------
@@ -37,13 +39,12 @@ import com.google.inject.Inject;
import sonia.scm.ConfigChangedListener; import sonia.scm.ConfigChangedListener;
import sonia.scm.SCMContextProvider; import sonia.scm.SCMContextProvider;
import sonia.scm.Type;
import sonia.scm.Undecorated; import sonia.scm.Undecorated;
import sonia.scm.repository.AbstractRepositoryManagerDecorator; import sonia.scm.repository.AbstractRepositoryManagerDecorator;
import sonia.scm.repository.Repository; import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryException; import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.RepositoryHandler;
import sonia.scm.repository.RepositoryManager; import sonia.scm.repository.RepositoryManager;
import sonia.scm.repository.RepositoryType;
import sonia.scm.util.AssertUtil; import sonia.scm.util.AssertUtil;
import sonia.scm.util.Util; import sonia.scm.util.Util;
@@ -88,19 +89,6 @@ public class CacheRepositoryManagerDecorator
//~--- methods -------------------------------------------------------------- //~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param handler
*/
@Override
public void addHandler(RepositoryHandler handler)
{
super.addHandler(handler);
handler.addListener(this);
}
/** /**
* Method description * Method description
* *
@@ -158,7 +146,7 @@ public class CacheRepositoryManagerDecorator
{ {
super.init(context); super.init(context);
for (RepositoryType type : getTypes()) for (Type type : getTypes())
{ {
getHandler(type.getName()).addListener(this); getHandler(type.getName()).addListener(this);
} }

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/scm-webapp"/>