This commit is contained in:
René Pfeuffer
2018-07-04 11:43:53 +02:00
15 changed files with 84 additions and 168 deletions

View File

@@ -59,7 +59,7 @@ public interface HandlerBase<T extends TypedObject, E extends Exception>
* @throws E
* @throws IOException
*/
public void create(T object) throws E, IOException;
public void create(T object) throws E;
/**
* Removes a persistent object.
@@ -70,7 +70,7 @@ public interface HandlerBase<T extends TypedObject, E extends Exception>
* @throws E
* @throws IOException
*/
public void delete(T object) throws E, IOException;
public void delete(T object) throws E;
/**
* Modifies a persistent object.
@@ -81,5 +81,5 @@ public interface HandlerBase<T extends TypedObject, E extends Exception>
* @throws E
* @throws IOException
*/
public void modify(T object) throws E, IOException;
public void modify(T object) throws E;
}

View File

@@ -33,7 +33,6 @@
package sonia.scm;
import java.io.IOException;
import java.util.Collection;
import java.util.Comparator;
@@ -56,9 +55,8 @@ public interface Manager<T extends ModelObject, E extends Exception>
* @param object to refresh
*
* @throws E
* @throws IOException
*/
void refresh(T object) throws E, IOException;
void refresh(T object) throws E;
//~--- get methods ----------------------------------------------------------

View File

@@ -35,7 +35,6 @@ package sonia.scm;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.util.Collection;
import java.util.Comparator;
@@ -78,7 +77,7 @@ public class ManagerDecorator<T extends ModelObject, E extends Exception>
* {@inheritDoc}
*/
@Override
public void create(T object) throws E, IOException
public void create(T object) throws E
{
decorated.create(object);
}
@@ -87,7 +86,7 @@ public class ManagerDecorator<T extends ModelObject, E extends Exception>
* {@inheritDoc}
*/
@Override
public void delete(T object) throws E, IOException
public void delete(T object) throws E
{
decorated.delete(object);
}
@@ -105,7 +104,7 @@ public class ManagerDecorator<T extends ModelObject, E extends Exception>
* {@inheritDoc}
*/
@Override
public void modify(T object) throws E, IOException
public void modify(T object) throws E
{
decorated.modify(object);
}
@@ -114,7 +113,7 @@ public class ManagerDecorator<T extends ModelObject, E extends Exception>
* {@inheritDoc}
*/
@Override
public void refresh(T object) throws E, IOException
public void refresh(T object) throws E
{
decorated.refresh(object);
}

View File

@@ -48,9 +48,9 @@ public class GroupAlreadyExistsException extends GroupException
/**
* Constructs a new instance.
*
* @param message exception message
* @param name The name (aka id) of the group
*/
public GroupAlreadyExistsException(String message) {
super(message);
public GroupAlreadyExistsException(String name) {
super(name + " group already exists");
}
}

View File

@@ -52,39 +52,7 @@ public class GroupNotFoundException extends GroupException
* Constructs a new GroupNotFoundException.
*
*/
public GroupNotFoundException() {}
/**
* Constructs a new GroupNotFoundException.
*
*
* @param message message for the exception
*/
public GroupNotFoundException(String message)
{
super(message);
}
/**
* Constructs a new GroupNotFoundException.
*
*
* @param throwable root cause
*/
public GroupNotFoundException(Throwable throwable)
{
super(throwable);
}
/**
* Constructs a new GroupNotFoundException.
*
*
* @param message message for the exception
* @param throwable root cause
*/
public GroupNotFoundException(String message, Throwable throwable)
{
super(message, throwable);
public GroupNotFoundException() {
super("group does not exists");
}
}

View File

@@ -38,23 +38,20 @@ package sonia.scm.repository;
import com.google.common.base.Charsets;
import com.google.common.base.Throwables;
import com.google.common.io.Resources;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.ConfigurationException;
import sonia.scm.io.CommandResult;
import sonia.scm.io.ExtendedCommand;
import sonia.scm.io.FileSystem;
import sonia.scm.store.ConfigurationStoreFactory;
import sonia.scm.util.IOUtil;
//~--- JDK imports ------------------------------------------------------------
import java.io.File;
import java.io.IOException;
import java.net.URL;
import sonia.scm.store.ConfigurationStoreFactory;
//~--- JDK imports ------------------------------------------------------------
/**
*
@@ -109,7 +106,7 @@ public abstract class AbstractSimpleRepositoryHandler<C extends SimpleRepository
*/
@Override
public void create(Repository repository)
throws RepositoryException, IOException
throws RepositoryException
{
File directory = getDirectory(repository);
@@ -137,11 +134,14 @@ public abstract class AbstractSimpleRepositoryHandler<C extends SimpleRepository
directory);
}
fileSystem.destroy(directory);
try {
fileSystem.destroy(directory);
} catch (IOException e) {
logger.error("could not delete directory after failed repository creation: {}", directory, e);
}
}
Throwables.propagateIfPossible(ex, RepositoryException.class,
IOException.class);
Throwables.propagateIfPossible(ex, RepositoryException.class);
}
}
@@ -173,14 +173,17 @@ public abstract class AbstractSimpleRepositoryHandler<C extends SimpleRepository
* @throws RepositoryException
*/
@Override
public void delete(Repository repository)
throws RepositoryException, IOException
public void delete(Repository repository) throws RepositoryException
{
File directory = getDirectory(repository);
if (directory.exists())
{
fileSystem.destroy(directory);
try {
fileSystem.destroy(directory);
} catch (IOException e) {
throw new RepositoryException("could not delete repository", e);
}
cleanupEmptyDirectories(config.getRepositoryDirectory(),
directory.getParentFile());
}
@@ -232,8 +235,7 @@ public abstract class AbstractSimpleRepositoryHandler<C extends SimpleRepository
* @throws RepositoryException
*/
@Override
public void modify(Repository repository)
throws RepositoryException, IOException
public void modify(Repository repository) throws RepositoryException
{
// nothing todo

View File

@@ -30,12 +30,10 @@ package sonia.scm.security;
import com.google.common.collect.ImmutableList;
import com.google.inject.Inject;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.SimpleAuthenticationInfo;
import org.apache.shiro.subject.SimplePrincipalCollection;
import sonia.scm.group.Group;
import sonia.scm.group.GroupException;
import sonia.scm.group.GroupManager;
@@ -46,9 +44,6 @@ import sonia.scm.user.UserException;
import sonia.scm.user.UserManager;
import sonia.scm.web.security.AdministrationContext;
import java.io.IOException;
import java.util.Collection;
/**
@@ -134,7 +129,7 @@ public final class SyncingRealmHelper {
groupManager.create(group);
}
}
catch (GroupException | IOException ex) {
catch (GroupException ex) {
throw new AuthenticationException("could not store group", ex);
}
});
@@ -155,7 +150,7 @@ public final class SyncingRealmHelper {
userManager.create(user);
}
}
catch (UserException | IOException ex) {
catch (UserException ex) {
throw new AuthenticationException("could not store user", ex);
}
});

View File

@@ -49,11 +49,11 @@ public class UserAlreadyExistsException extends UserException
/**
* Constructs a new instance.
*
* @param message message of exception
* @param name The name (aka id) of the user
* @since 1.5
*/
public UserAlreadyExistsException(String message)
public UserAlreadyExistsException(String name)
{
super(message);
super(name + " user already exists");
}
}

View File

@@ -51,39 +51,7 @@ public class UserNotFoundException extends UserException
* Constructs a new UserNotFoundException.
*
*/
public UserNotFoundException() {}
/**
* Constructs a new UserNotFoundException.
*
*
* @param message message for the exception
*/
public UserNotFoundException(String message)
{
super(message);
}
/**
* Constructs a new UserNotFoundException.
*
*
* @param throwable root cause
*/
public UserNotFoundException(Throwable throwable)
{
super(throwable);
}
/**
* Constructs a new UserNotFoundException.
*
*
* @param message message for the exception
* @param throwable root cause
*/
public UserNotFoundException(String message, Throwable throwable)
{
super(message, throwable);
public UserNotFoundException() {
super("user does not exists");
}
}