Files
SCM-Manager/scm-webapp/src/main/java/sonia/scm/repository/DefaultNamespaceStrategy.java

25 lines
697 B
Java
Raw Normal View History

package sonia.scm.repository;
import com.google.common.base.Strings;
2018-07-04 15:46:08 +02:00
import org.apache.shiro.SecurityUtils;
import sonia.scm.plugin.Extension;
/**
* 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.
*
* @since 2.0.0
*/
@Extension
2018-07-04 15:46:08 +02:00
public class DefaultNamespaceStrategy implements NamespaceStrategy {
@Override
public String createNamespace(Repository repository) {
String namespace = repository.getNamespace();
if (Strings.isNullOrEmpty(namespace)) {
namespace = SecurityUtils.getSubject().getPrincipal().toString();
}
return namespace;
}
}