2018-06-29 17:10:14 +02:00
|
|
|
package sonia.scm.repository;
|
|
|
|
|
|
2018-08-01 09:43:49 +02:00
|
|
|
import com.google.common.base.Strings;
|
2018-07-04 15:46:08 +02:00
|
|
|
import org.apache.shiro.SecurityUtils;
|
2018-06-29 17:10:14 +02:00
|
|
|
import sonia.scm.plugin.Extension;
|
|
|
|
|
|
2018-07-13 12:10:19 +02:00
|
|
|
/**
|
2018-08-01 09:43:49 +02:00
|
|
|
* The DefaultNamespaceStrategy returns the predefined namespace of the given repository, if the namespace was not set
|
|
|
|
|
* the username of the currently loggedin user is used.
|
|
|
|
|
*
|
2018-07-13 12:10:19 +02:00
|
|
|
* @since 2.0.0
|
|
|
|
|
*/
|
2018-06-29 17:10:14 +02:00
|
|
|
@Extension
|
2018-07-04 15:46:08 +02:00
|
|
|
public class DefaultNamespaceStrategy implements NamespaceStrategy {
|
|
|
|
|
|
2018-06-29 17:10:14 +02:00
|
|
|
@Override
|
2018-08-01 09:43:49 +02:00
|
|
|
public String createNamespace(Repository repository) {
|
|
|
|
|
String namespace = repository.getNamespace();
|
|
|
|
|
if (Strings.isNullOrEmpty(namespace)) {
|
|
|
|
|
namespace = SecurityUtils.getSubject().getPrincipal().toString();
|
|
|
|
|
}
|
|
|
|
|
return namespace;
|
2018-06-29 17:10:14 +02:00
|
|
|
}
|
|
|
|
|
}
|