|
|
@@ -6,8 +6,8 @@ namespace Usm {
|
|
|
|
|
|
public class ManifestFile {
|
|
|
|
|
|
- public ManifestFilePathBase path_base { get; set; }
|
|
|
- public string path { get; set; }
|
|
|
+ public ManifestFilePathBase? path_base { get; set; }
|
|
|
+ public string? path { get; set; }
|
|
|
public ManifestFileType file_type { get; set; }
|
|
|
public string? destination { get; set; }
|
|
|
public Vector<RemoveType>? keep_on { get; set; }
|
|
|
@@ -15,8 +15,12 @@ namespace Usm {
|
|
|
|
|
|
public static PropertyMapper<ManifestFile> get_mapper() {
|
|
|
return PropertyMapper.build_for<ManifestFile>(cfg => {
|
|
|
- cfg.map<string>("path", o => o.path, (o, v) => o.path = v); // TODO make nullable in some cases, add validtion (i.e. type != reg, and pathBase == as-expected)
|
|
|
- cfg.map<string>("pathBase", o => o.path_base.to_string(), (o, v) => o.path_base = ManifestFilePathBase.from_string(v));
|
|
|
+ cfg.map<string>("path", o => o.path, (o, v) => o.path = v)
|
|
|
+ .undefined_when(o => o.path == null)
|
|
|
+ .when_undefined(o => o.path = null);
|
|
|
+ cfg.map<string>("pathBase", o => o.path_base != null ? o.path_base.to_string() : null, (o, v) => { if (v != null) o.path_base = ManifestFilePathBase.from_string(v); else o.path_base = null; })
|
|
|
+ .undefined_when(o => o.path_base == null)
|
|
|
+ .when_undefined(o => o.path_base = null);
|
|
|
cfg.map<string>("type", o => o.file_type.to_string(), (o, v) => o.file_type = ManifestFileType.from_string(v));
|
|
|
cfg.map<string>("dest", o => o.destination, (o, v) => o.destination = v)
|
|
|
.undefined_when(o => o.destination == null)
|
|
|
@@ -44,6 +48,18 @@ namespace Usm {
|
|
|
}
|
|
|
path = parts[1];
|
|
|
}
|
|
|
+
|
|
|
+ public void validate() throws ManifestError {
|
|
|
+ // Validate that path and pathBase are provided when type is "reg"
|
|
|
+ if (file_type == ManifestFileType.REGULAR) {
|
|
|
+ if (path_base == null) {
|
|
|
+ throw new ManifestError.INVALID_PATH_BASE("pathBase is required when type is 'reg'");
|
|
|
+ }
|
|
|
+ if (path == null && path_base != ManifestFilePathBase.AS_EXPECTED) {
|
|
|
+ throw new ManifestError.INVALID_FILE_PATH("path is required when type is 'reg' and pathBase is not 'as-expected'");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|