mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 08:25:44 +01:00
Use default implementation to keep compatibility
This commit is contained in:
@@ -45,5 +45,7 @@ public interface NamespaceStrategy {
|
|||||||
*
|
*
|
||||||
* @return namespace can be changed
|
* @return namespace can be changed
|
||||||
*/
|
*/
|
||||||
boolean canBeChanged();
|
default boolean canBeChanged() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,9 +50,4 @@ public class CurrentYearNamespaceStrategy implements NamespaceStrategy {
|
|||||||
public String createNamespace(Repository repository) {
|
public String createNamespace(Repository repository) {
|
||||||
return String.valueOf(Year.now(clock).getValue());
|
return String.valueOf(Year.now(clock).getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canBeChanged() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sonia.scm.repository;
|
package sonia.scm.repository;
|
||||||
|
|
||||||
import sonia.scm.plugin.Extension;
|
import sonia.scm.plugin.Extension;
|
||||||
@@ -32,9 +32,4 @@ public class RepositoryTypeNamespaceStrategy implements NamespaceStrategy {
|
|||||||
public String createNamespace(Repository repository) {
|
public String createNamespace(Repository repository) {
|
||||||
return repository.getType();
|
return repository.getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canBeChanged() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sonia.scm.repository;
|
package sonia.scm.repository;
|
||||||
|
|
||||||
import org.apache.shiro.SecurityUtils;
|
import org.apache.shiro.SecurityUtils;
|
||||||
@@ -34,9 +34,4 @@ public class UsernameNamespaceStrategy implements NamespaceStrategy {
|
|||||||
public String createNamespace(Repository repository) {
|
public String createNamespace(Repository repository) {
|
||||||
return SecurityUtils.getSubject().getPrincipal().toString();
|
return SecurityUtils.getSubject().getPrincipal().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canBeChanged() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sonia.scm.api.v2.resources;
|
package sonia.scm.api.v2.resources;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
@@ -68,7 +68,7 @@ class NamespaceStrategyResourceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Set<NamespaceStrategy> allStrategies() {
|
private Set<NamespaceStrategy> allStrategies() {
|
||||||
return strategies(new AwesomeNamespaceStrategy(), new SuperNamespaceStrategy(), new MegaNamespaceStrategy());
|
return strategies(new AwesomeNamespaceStrategy(), new SuperNamespaceStrategy(), new MegaNamespaceStrategy());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<NamespaceStrategy> strategies(NamespaceStrategy... strategies) {
|
private Set<NamespaceStrategy> strategies(NamespaceStrategy... strategies) {
|
||||||
@@ -80,11 +80,6 @@ class NamespaceStrategyResourceTest {
|
|||||||
public String createNamespace(Repository repository) {
|
public String createNamespace(Repository repository) {
|
||||||
return "awesome";
|
return "awesome";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canBeChanged() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SuperNamespaceStrategy implements NamespaceStrategy {
|
private static class SuperNamespaceStrategy implements NamespaceStrategy {
|
||||||
@@ -92,11 +87,6 @@ class NamespaceStrategyResourceTest {
|
|||||||
public String createNamespace(Repository repository) {
|
public String createNamespace(Repository repository) {
|
||||||
return "super";
|
return "super";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canBeChanged() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class MegaNamespaceStrategy implements NamespaceStrategy {
|
private static class MegaNamespaceStrategy implements NamespaceStrategy {
|
||||||
@@ -104,10 +94,5 @@ class NamespaceStrategyResourceTest {
|
|||||||
public String createNamespace(Repository repository) {
|
public String createNamespace(Repository repository) {
|
||||||
return "mega";
|
return "mega";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canBeChanged() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sonia.scm.repository;
|
package sonia.scm.repository;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -66,17 +66,12 @@ class NamespaceStrategyProviderTest {
|
|||||||
return new LinkedHashSet<>(Arrays.asList(new Trillian(), new Zaphod(), new Arthur()));
|
return new LinkedHashSet<>(Arrays.asList(new Trillian(), new Zaphod(), new Arthur()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Trillian implements NamespaceStrategy {
|
private static class Trillian implements NamespaceStrategy{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String createNamespace(Repository repository) {
|
public String createNamespace(Repository repository) {
|
||||||
return "trillian";
|
return "trillian";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canBeChanged() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Zaphod implements NamespaceStrategy {
|
private static class Zaphod implements NamespaceStrategy {
|
||||||
@@ -85,11 +80,6 @@ class NamespaceStrategyProviderTest {
|
|||||||
public String createNamespace(Repository repository) {
|
public String createNamespace(Repository repository) {
|
||||||
return "zaphod";
|
return "zaphod";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canBeChanged() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Arthur implements NamespaceStrategy {
|
private static class Arthur implements NamespaceStrategy {
|
||||||
@@ -98,11 +88,6 @@ class NamespaceStrategyProviderTest {
|
|||||||
public String createNamespace(Repository repository) {
|
public String createNamespace(Repository repository) {
|
||||||
return "arthur";
|
return "arthur";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canBeChanged() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sonia.scm.repository;
|
package sonia.scm.repository;
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
@@ -30,7 +30,7 @@ import sonia.scm.ScmConstraintViolationException;
|
|||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
class NamespaceStrategyValidatorTest {
|
class NamespaceStrategyValidatorTest {
|
||||||
|
|
||||||
@@ -52,11 +52,6 @@ class NamespaceStrategyValidatorTest {
|
|||||||
public String createNamespace(Repository repository) {
|
public String createNamespace(Repository repository) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canBeChanged() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user