Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c2a1c00

Browse files
committedOct 16, 2018
refactor(AddSeriesForm,AddImageForm): rename image to uploadedImage.
Fixing two issues in the same commit because both fields depends on DownloadImageInterceptor.UPLOADED_IMAGE_FIELD_NAME constant and have to be renamed simultaneously. Fix #653 Fix #654 No functional changes.
1 parent 70f8361 commit c2a1c00

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed
 

‎src/main/java/ru/mystamps/web/controller/interceptor/DownloadImageInterceptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public class DownloadImageInterceptor extends HandlerInterceptorAdapter {
6161
* When it's present, we won't download an image from URL because a user should choose only one
6262
* image source.
6363
*/
64-
public static final String UPLOADED_IMAGE_FIELD_NAME = "image";
64+
public static final String UPLOADED_IMAGE_FIELD_NAME = "uploadedImage";
6565

6666
/**
6767
* Name of request attribute, that will be used for storing an error code.

‎src/main/java/ru/mystamps/web/feature/series/AddImageForm.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public class AddImageForm implements AddImageDto, HasImageOrImageUrl, NullableIm
4848
@NotEmptyFile(groups = Group.Level1.class)
4949
@MaxFileSize(value = MAX_IMAGE_SIZE, unit = Unit.Kbytes, groups = Group.Level2.class)
5050
@ImageFile(groups = Group.Level2.class)
51-
private MultipartFile image;
51+
private MultipartFile uploadedImage;
5252

5353
// Name of this field must match with the value of DownloadImageInterceptor.URL_PARAMETER_NAME.
5454
@URL(groups = ImageUrl2Checks.class)
@@ -65,7 +65,7 @@ public class AddImageForm implements AddImageDto, HasImageOrImageUrl, NullableIm
6565
@Override
6666
public MultipartFile getImage() {
6767
if (hasImage()) {
68-
return image;
68+
return uploadedImage;
6969
}
7070

7171
return downloadedImage;
@@ -75,7 +75,7 @@ public MultipartFile getImage() {
7575
// The latter is being used by RequireImageOrImageUrl validator.
7676
@Override
7777
public boolean hasImage() {
78-
return image != null && StringUtils.isNotEmpty(image.getOriginalFilename());
78+
return uploadedImage != null && StringUtils.isNotEmpty(uploadedImage.getOriginalFilename());
7979
}
8080

8181
// This method has to be implemented to satisfy HasImageOrImageUrl requirements.

‎src/main/java/ru/mystamps/web/feature/series/AddSeriesForm.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public class AddSeriesForm implements AddSeriesDto, HasImageOrImageUrl, Nullable
151151
@NotEmptyFile(groups = Image1Checks.class)
152152
@MaxFileSize(value = MAX_IMAGE_SIZE, unit = Unit.Kbytes, groups = Image2Checks.class)
153153
@ImageFile(groups = Image2Checks.class)
154-
private MultipartFile image;
154+
private MultipartFile uploadedImage;
155155

156156
// Name of this field must match with the value of DownloadImageInterceptor.URL_PARAMETER_NAME.
157157
@URL(groups = ImageUrl2Checks.class)
@@ -168,7 +168,7 @@ public class AddSeriesForm implements AddSeriesDto, HasImageOrImageUrl, Nullable
168168
@Override
169169
public MultipartFile getImage() {
170170
if (hasImage()) {
171-
return image;
171+
return uploadedImage;
172172
}
173173

174174
return downloadedImage;
@@ -178,7 +178,7 @@ public MultipartFile getImage() {
178178
// The latter is being used by RequireImageOrImageUrl validator.
179179
@Override
180180
public boolean hasImage() {
181-
return image != null && StringUtils.isNotEmpty(image.getOriginalFilename());
181+
return uploadedImage != null && StringUtils.isNotEmpty(uploadedImage.getOriginalFilename());
182182
}
183183

184184
// This method has to be implemented to satisfy HasImageOrImageUrl requirements.

‎src/main/java/ru/mystamps/web/feature/series/SeriesController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public String processInput(
214214
addYearToModel(model);
215215

216216
// don't try to re-display file upload field
217-
form.setImage(null);
217+
form.setUploadedImage(null);
218218
form.setDownloadedImage(null);
219219
return null;
220220
}
@@ -329,7 +329,7 @@ public String processImage(
329329
addStampsToCollectionForm(model, series);
330330

331331
// don't try to re-display file upload field
332-
form.setImage(null);
332+
form.setUploadedImage(null);
333333

334334
return "series/info";
335335
}

‎src/main/webapp/WEB-INF/views/series/add.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ <h3 th:text="${#strings.capitalize(add_series)}">
222222
</div>
223223
</div>
224224

225-
<div class="form-group form-group-sm" th:classappend="${#fields.hasErrors('image') ? 'has-error' : ''}">
225+
<div class="form-group form-group-sm" th:classappend="${#fields.hasErrors('uploadedImage') ? 'has-error' : ''}">
226226
<label for="image" class="control-label col-sm-3">
227227
<span th:remove="tag" th:text="#{t_image}">
228228
Image
@@ -236,15 +236,15 @@ <h3 th:text="${#strings.capitalize(add_series)}">
236236
type="file"
237237
style="box-shadow: none; border: 0px;"
238238
accept="image/png,image/jpeg"
239-
th:field="*{image}"
239+
th:field="*{uploadedImage}"
240240
th:attr="required=${#authorization.expression('hasAuthority(''DOWNLOAD_IMAGE'')') ? null : 'required'}" />
241241
<small togglz:active="ADD_ADDITIONAL_IMAGES_TO_SERIES" sec:authorize="hasAuthority('ADD_IMAGES_TO_SERIES')">
242242
<span class="hint-block" th:text="#{t_add_more_images_hint}">
243243
Later you will be able to add additional images
244244
</span>
245245
</small>
246246
<!--/*/
247-
<span id="image.errors" class="help-block" th:if="${#fields.hasErrors('image')}" th:each="error : ${#fields.errors('image')}" th:text="${error}"></span>
247+
<span id="image.errors" class="help-block" th:if="${#fields.hasErrors('uploadedImage')}" th:each="error : ${#fields.errors('uploadedImage')}" th:text="${error}"></span>
248248
/*/-->
249249
</div>
250250
</div>

‎src/main/webapp/WEB-INF/views/series/info.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
enctype="multipart/form-data"
9999
th:action="@{${ADD_IMAGE_SERIES_PAGE}(id=${series.id})}"
100100
th:object="${addImageForm}">
101-
<div class="form-group form-group-sm" th:classappend="${#fields.hasErrors('image') ? 'has-error' : ''}">
101+
<div class="form-group form-group-sm" th:classappend="${#fields.hasErrors('uploadedImage') ? 'has-error' : ''}">
102102
<label for="image" class="control-label col-sm-3" th:text="#{t_image}">
103103
Image
104104
</label>
@@ -107,10 +107,10 @@
107107
type="file"
108108
style="box-shadow: none; border: 0px;"
109109
accept="image/png,image/jpeg"
110-
th:field="*{image}"
110+
th:field="*{uploadedImage}"
111111
th:attr="required=${#authorization.expression('hasAuthority(''DOWNLOAD_IMAGE'')') ? null : 'required'}" />
112112
<!--/*/
113-
<span id="image.errors" class="help-block" th:if="${#fields.hasErrors('image')}" th:each="error : ${#fields.errors('image')}" th:text="${error}"></span>
113+
<span id="image.errors" class="help-block" th:if="${#fields.hasErrors('uploadedImage')}" th:each="error : ${#fields.errors('uploadedImage')}" th:text="${error}"></span>
114114
/*/-->
115115
</div>
116116
</div>

‎src/test/groovy/ru/mystamps/web/feature/series/SeriesServiceImplTest.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ class SeriesServiceImplTest extends Specification {
416416

417417
def "add() should pass image to image service"() {
418418
given:
419-
form.setImage(multipartFile)
419+
form.setUploadedImage(multipartFile)
420420
when:
421421
service.add(form, Random.userId(), bool())
422422
then:
@@ -501,7 +501,7 @@ class SeriesServiceImplTest extends Specification {
501501

502502
def "addImageToSeries() should save image"() {
503503
given:
504-
imageForm.setImage(multipartFile)
504+
imageForm.setUploadedImage(multipartFile)
505505
when:
506506
service.addImageToSeries(imageForm, Random.id(), Random.userId())
507507
then:

0 commit comments

Comments
 (0)
Please sign in to comment.