Introduce new API for modifications

New modifications includes list of 'renames'. Therefore we introduce
a new base class Modification.
This commit is contained in:
René Pfeuffer
2020-05-14 13:20:56 +02:00
parent 76354aa839
commit 35ffc5c4e2
18 changed files with 326 additions and 127 deletions

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.api.v2.resources;
import de.otto.edison.hal.HalRepresentation;
@@ -54,10 +54,21 @@ public class ModificationsDto extends HalRepresentation {
*/
private List<String> removed;
/**
* Mapping of renamed files
*/
private List<RenamedDto> renamed;
@Override
@SuppressWarnings("squid:S1185") // We want to have this method available in this package
protected HalRepresentation add(Links links) {
return super.add(links);
}
@Getter
@Setter
public static class RenamedDto {
private String oldPath;
private String newPath;
}
}

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.api.v2.resources;
import de.otto.edison.hal.Links;
@@ -30,6 +30,7 @@ import org.mapstruct.Context;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import sonia.scm.repository.Modification;
import sonia.scm.repository.Modifications;
import sonia.scm.repository.Repository;
@@ -52,4 +53,18 @@ public abstract class ModificationsToDtoMapper {
.self(resourceLinks.modifications().self(repository.getNamespace(), repository.getName(), target.getRevision()));
target.add(linksBuilder.build());
}
String map(Modification.Added added) {
return added.getPath();
}
String map(Modification.Removed removed) {
return removed.getPath();
}
String map(Modification.Modified modified) {
return modified.getPath();
}
abstract ModificationsDto.RenamedDto map(Modification.Renamed renamed);
}