Merging base branch back into feature

This commit is contained in:
René Pfeuffer
2018-07-11 14:01:17 +02:00
50 changed files with 1472 additions and 123 deletions

View File

@@ -53,13 +53,9 @@ public interface HandlerBase<T extends TypedObject, E extends Exception>
/**
* Persists a new object.
*
*
* @param object to store
*
* @throws E
* @throws IOException
* @return The persisted object.
*/
public void create(T object) throws E;
public T create(T object) throws E;
/**
* Removes a persistent object.

View File

@@ -77,9 +77,9 @@ public class ManagerDecorator<T extends ModelObject, E extends Exception>
* {@inheritDoc}
*/
@Override
public void create(T object) throws E
public T create(T object) throws E
{
decorated.create(object);
return decorated.create(object);
}
/**

View File

@@ -80,7 +80,7 @@ public abstract class AbstractSimpleRepositoryHandler<C extends SimpleRepository
}
@Override
public void create(Repository repository)
public Repository create(Repository repository)
throws RepositoryException {
File directory = getDirectory(repository);
@@ -94,6 +94,7 @@ public abstract class AbstractSimpleRepositoryHandler<C extends SimpleRepository
fileSystem.create(directory);
create(repository, directory);
postCreate(repository, directory);
return repository;
} catch (Exception ex) {
if (directory.exists()) {
if (logger.isDebugEnabled()) {
@@ -109,6 +110,8 @@ public abstract class AbstractSimpleRepositoryHandler<C extends SimpleRepository
}
Throwables.propagateIfPossible(ex, RepositoryException.class);
// This point will never be reached
return null;
}
}

View File

@@ -41,6 +41,7 @@ import sonia.scm.TypeManager;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Collection;
import java.util.Optional;
//~--- JDK imports ------------------------------------------------------------
@@ -134,4 +135,11 @@ public interface RepositoryManager
*/
@Override
public RepositoryHandler getHandler(String type);
default Optional<Repository> getByNamespace(String namespace, String name) {
return getAll()
.stream()
.filter(r -> r.getName().equals(name) && r.getNamespace().equals(namespace))
.findFirst();
}
}

View File

@@ -14,8 +14,10 @@ public class VndMediaType {
public static final String USER = PREFIX + "user" + SUFFIX;
public static final String GROUP = PREFIX + "group" + SUFFIX;
public static final String REPOSITORY = PREFIX + "repository" + SUFFIX;
public static final String USER_COLLECTION = PREFIX + "userCollection" + SUFFIX;
public static final String GROUP_COLLECTION = PREFIX + "groupCollection" + SUFFIX;
public static final String REPOSITORY_COLLECTION = PREFIX + "repositoryCollection" + SUFFIX;
private VndMediaType() {
}