Introduce ManagerDaoAdapter for create and modify

This commit is contained in:
René Pfeuffer
2018-07-12 10:15:32 +02:00
parent 8593e1dc58
commit 4e207713bf
12 changed files with 185 additions and 218 deletions

View File

@@ -53,5 +53,11 @@ public interface ModelObject
*
* @return unique id
*/
public String getId();
String getId();
void setLastModified(Long timestamp);
Long getCreationDate();
void setCreationDate(Long timestamp);
}

View File

@@ -42,15 +42,9 @@ package sonia.scm.group;
public class GroupAlreadyExistsException extends GroupException
{
/** Field description */
private static final long serialVersionUID = 4042878550219750430L;
/**
* Constructs a new instance.
*
* @param name The name (aka id) of the group
*/
public GroupAlreadyExistsException(String name) {
super(name + " group already exists");
public GroupAlreadyExistsException(Group group) {
super(group.getName() + " group already exists");
}
}

View File

@@ -53,6 +53,6 @@ public class GroupNotFoundException extends GroupException
*
*/
public GroupNotFoundException() {
super("group does not exists");
super("group does not exist");
}
}

View File

@@ -52,17 +52,11 @@ public class RepositoryNotFoundException extends RepositoryException
* error detail message.
*
*/
public RepositoryNotFoundException() {}
public RepositoryNotFoundException() {
super("repository does not exist");
}
/**
* Constructs a new {@link RepositoryNotFoundException} with the specified
* error detail message.
*
*
* @param message error detail message
*/
public RepositoryNotFoundException(String message)
{
super(message);
public RepositoryNotFoundException(String repositoryId) {
super("repository with id " + repositoryId + " does not exist");
}
}

View File

@@ -37,20 +37,19 @@ package sonia.scm.repository.api;
import com.github.legman.ReferenceType;
import com.github.legman.Subscribe;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.collect.Sets;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.HandlerEventType;
import sonia.scm.cache.Cache;
import sonia.scm.cache.CacheManager;
import sonia.scm.config.ScmConfiguration;
import sonia.scm.event.ScmEventBus;
import sonia.scm.repository.ClearRepositoryCacheEvent;
import sonia.scm.repository.PostReceiveRepositoryHookEvent;
import sonia.scm.repository.PreProcessorUtil;
import sonia.scm.repository.Repository;
@@ -63,11 +62,9 @@ import sonia.scm.repository.spi.RepositoryServiceProvider;
import sonia.scm.repository.spi.RepositoryServiceResolver;
import sonia.scm.security.ScmSecurityException;
//~--- JDK imports ------------------------------------------------------------
import java.util.Set;
import sonia.scm.event.ScmEventBus;
import sonia.scm.repository.ClearRepositoryCacheEvent;
//~--- JDK imports ------------------------------------------------------------
/**
* The {@link RepositoryServiceFactory} is the entrypoint of the repository api.
@@ -179,8 +176,7 @@ public final class RepositoryServiceFactory
if (repository == null)
{
throw new RepositoryNotFoundException(
"could not find a repository with id ".concat(repositoryId));
throw new RepositoryNotFoundException(repositoryId);
}
return create(repository);

View File

@@ -41,19 +41,11 @@ package sonia.scm.user;
public class UserAlreadyExistsException extends UserException
{
/** Field description */
private static final long serialVersionUID = 9182294539718090814L;
//~--- constructors ---------------------------------------------------------
/**
* Constructs a new instance.
*
* @param name The name (aka id) of the user
* @since 1.5
*/
public UserAlreadyExistsException(String name)
{
super(name + " user already exists");
public UserAlreadyExistsException(User user) {
super(user.getName() + " user already exists");
}
}

View File

@@ -52,6 +52,6 @@ public class UserNotFoundException extends UserException
*
*/
public UserNotFoundException() {
super("user does not exists");
super("user does not exist");
}
}