|
45 | 45 | import ru.mystamps.web.validation.jsr303.MaxFileSize;
|
46 | 46 | import ru.mystamps.web.validation.jsr303.MaxFileSize.Unit;
|
47 | 47 | import ru.mystamps.web.validation.jsr303.NotEmptyFile;
|
| 48 | +import ru.mystamps.web.validation.jsr303.NotEmptyFilename; |
48 | 49 | import ru.mystamps.web.validation.jsr303.NotNullIfFirstField;
|
49 | 50 | import ru.mystamps.web.validation.jsr303.Price;
|
50 | 51 | import ru.mystamps.web.validation.jsr303.ReleaseDateIsNotInFuture;
|
|
63 | 64 | // TODO: image and downloadedImage should be filled together
|
64 | 65 | // TODO: combine price with currency to separate class
|
65 | 66 | @SuppressWarnings({"PMD.TooManyFields", "PMD.AvoidDuplicateLiterals"})
|
66 |
| -@RequireImageOrImageUrl |
| 67 | +@RequireImageOrImageUrl(groups = AddSeriesForm.ImageUrl1Checks.class) |
67 | 68 | @NotNullIfFirstField.List({
|
68 | 69 | @NotNullIfFirstField(
|
69 | 70 | first = "month", second = "year", message = "{month.requires.year}",
|
@@ -136,22 +137,21 @@ public class AddSeriesForm implements AddSeriesDto, HasImageOrImageUrl {
|
136 | 137 |
|
137 | 138 | // Name of this field should match with the value of
|
138 | 139 | // DownloadImageInterceptor.UPLOADED_IMAGE_FIELD_NAME.
|
139 |
| - //@NotEmptyFilename(groups = Image1Checks.class) |
140 |
| - @NotEmptyFile(groups = Image2Checks.class) |
141 |
| - @MaxFileSize(value = MAX_IMAGE_SIZE, unit = Unit.Kbytes, groups = Image3Checks.class) |
| 140 | + @NotEmptyFilename(groups = RequireImageCheck.class) |
| 141 | + @NotEmptyFile(groups = Image1Checks.class) |
| 142 | + @MaxFileSize(value = MAX_IMAGE_SIZE, unit = Unit.Kbytes, groups = Image2Checks.class) |
142 | 143 | @ImageFile(groups = Image3Checks.class)
|
143 | 144 | private MultipartFile image;
|
144 | 145 |
|
145 | 146 | // Name of this field must match with the value of DownloadImageInterceptor.URL_PARAMETER_NAME.
|
146 |
| - @URL |
| 147 | + @URL(groups = AddSeriesForm.ImageUrl2Checks.class) |
147 | 148 | private String imageUrl;
|
148 | 149 |
|
149 | 150 | // This field holds a file that was downloaded from imageUrl.
|
150 | 151 | // Name of this field must match with the value of
|
151 | 152 | // DownloadImageInterceptor.DOWNLOADED_IMAGE_FIELD_NAME.
|
152 |
| - //@NotEmptyFilename(groups = Image1Checks.class) |
153 |
| - @NotEmptyFile(groups = Image2Checks.class) |
154 |
| - @MaxFileSize(value = MAX_IMAGE_SIZE, unit = Unit.Kbytes, groups = Image3Checks.class) |
| 153 | + @NotEmptyFile(groups = Image1Checks.class) |
| 154 | + @MaxFileSize(value = MAX_IMAGE_SIZE, unit = Unit.Kbytes, groups = Image2Checks.class) |
155 | 155 | @ImageFile(groups = Image3Checks.class)
|
156 | 156 | private MultipartFile downloadedImage;
|
157 | 157 |
|
@@ -195,6 +195,22 @@ public interface ReleaseDate2Checks {
|
195 | 195 | public interface ReleaseDate3Checks {
|
196 | 196 | }
|
197 | 197 |
|
| 198 | + public interface RequireImageCheck { |
| 199 | + } |
| 200 | + |
| 201 | + @GroupSequence({ |
| 202 | + ImageUrl1Checks.class, |
| 203 | + ImageUrl2Checks.class, |
| 204 | + }) |
| 205 | + public interface ImageUrlChecks { |
| 206 | + } |
| 207 | + |
| 208 | + public interface ImageUrl1Checks { |
| 209 | + } |
| 210 | + |
| 211 | + public interface ImageUrl2Checks { |
| 212 | + } |
| 213 | + |
198 | 214 | @GroupSequence({
|
199 | 215 | Image1Checks.class,
|
200 | 216 | Image2Checks.class,
|
|
0 commit comments