fix review findings

This commit is contained in:
Konstantin Schaper
2020-12-01 11:18:19 +01:00
parent 51981dbece
commit e8044747e3
10 changed files with 49 additions and 128 deletions

View File

@@ -1,41 +0,0 @@
/*
* MIT License
*
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository;
import lombok.Value;
import sonia.scm.event.Event;
/**
* This event is fired when a new tag was created by the SCM-Manager.
* Warning: This event will not be fired if a new tag was pushed.
* @since 2.10.0
*/
@Event
@Value
public class TagCreatedEvent {
Repository repository;
String revision;
String tagName;
}

View File

@@ -1,40 +0,0 @@
/*
* MIT License
*
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository;
import lombok.Value;
import sonia.scm.event.Event;
/**
* This event is fired when a tag was deleted by the SCM-Manager.
* Warning: This event will not be fired if a tag was removed by a push of a git client.
* @since 2.10.0
*/
@Event
@Value
public class TagDeletedEvent {
Repository repository;
String tagName;
}

View File

@@ -386,7 +386,7 @@ public final class RepositoryService implements Closeable {
* by the implementation of the repository service provider.
*/
public TagCommandBuilder getTagCommand() {
return new TagCommandBuilder(repository, provider.getTagCommand());
return new TagCommandBuilder(provider.getTagCommand());
}
/**

View File

@@ -24,24 +24,16 @@
package sonia.scm.repository.api;
import sonia.scm.event.ScmEventBus;
import sonia.scm.repository.Repository;
import sonia.scm.repository.Tag;
import sonia.scm.repository.TagCreatedEvent;
import sonia.scm.repository.TagDeletedEvent;
import sonia.scm.repository.spi.TagCommand;
import java.io.IOException;
public class TagCommandBuilder {
private final Repository repository;
private final TagCommand command;
private final ScmEventBus eventBus;
public TagCommandBuilder(Repository repository, TagCommand command) {
this.repository = repository;
public TagCommandBuilder(TagCommand command) {
this.command = command;
this.eventBus = ScmEventBus.getInstance();
}
public TagCreateCommandBuilder create() {
@@ -53,7 +45,7 @@ public class TagCommandBuilder {
}
public class TagCreateCommandBuilder {
private TagCreateRequest request = new TagCreateRequest();
private final TagCreateRequest request = new TagCreateRequest();
public TagCreateCommandBuilder setRevision(String revision) {
request.setRevision(revision);
@@ -66,14 +58,12 @@ public class TagCommandBuilder {
}
public Tag execute() throws IOException {
Tag tag = command.create(request);
eventBus.post(new TagCreatedEvent(repository, request.getRevision(), request.getName()));
return tag;
return command.create(request);
}
}
public class TagDeleteCommandBuilder {
private TagDeleteRequest request = new TagDeleteRequest();
private final TagDeleteRequest request = new TagDeleteRequest();
public TagDeleteCommandBuilder setName(String name) {
request.setName(name);
@@ -82,7 +72,6 @@ public class TagCommandBuilder {
public void execute() throws IOException {
command.delete(request);
eventBus.post(new TagDeletedEvent(repository, request.getName()));
}
}
}

View File

@@ -254,7 +254,7 @@ public abstract class RepositoryServiceProvider implements Closeable
*/
public TagCommand getTagCommand()
{
throw new CommandNotSupportedException(Command.TAGS);
throw new CommandNotSupportedException(Command.TAG);
}
/**