mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 00:45:44 +01:00
Introduce new API for modifications
New modifications includes list of 'renames'. Therefore we introduce a new base class Modification.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user