forked from Archives/Athou_commafeed
allow empty names for modification requests, not modifying the name (fix #263)
This commit is contained in:
@@ -18,7 +18,7 @@ public class CategoryModificationRequest implements Serializable {
|
|||||||
@ApiProperty(value = "id", required = true)
|
@ApiProperty(value = "id", required = true)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@ApiProperty(value = "new name")
|
@ApiProperty(value = "new name, null if not changed")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@ApiProperty(value = "new parent category id")
|
@ApiProperty(value = "new parent category id")
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class FeedModificationRequest implements Serializable {
|
|||||||
@ApiProperty(value = "id", required = true)
|
@ApiProperty(value = "id", required = true)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@ApiProperty(value = "new name")
|
@ApiProperty(value = "new name, null if not changed")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@ApiProperty(value = "new parent category id")
|
@ApiProperty(value = "new parent category id")
|
||||||
|
|||||||
@@ -252,11 +252,13 @@ public class CategoryREST extends AbstractResourceREST {
|
|||||||
@ApiParam(required = true) CategoryModificationRequest req) {
|
@ApiParam(required = true) CategoryModificationRequest req) {
|
||||||
Preconditions.checkNotNull(req);
|
Preconditions.checkNotNull(req);
|
||||||
Preconditions.checkNotNull(req.getId());
|
Preconditions.checkNotNull(req.getId());
|
||||||
Preconditions.checkArgument(StringUtils.isNotBlank(req.getName()));
|
|
||||||
|
|
||||||
FeedCategory category = feedCategoryDAO
|
FeedCategory category = feedCategoryDAO
|
||||||
.findById(getUser(), req.getId());
|
.findById(getUser(), req.getId());
|
||||||
category.setName(req.getName());
|
|
||||||
|
if (StringUtils.isNotBlank(req.getName())) {
|
||||||
|
category.setName(req.getName());
|
||||||
|
}
|
||||||
|
|
||||||
FeedCategory parent = null;
|
FeedCategory parent = null;
|
||||||
if (req.getParentId() != null
|
if (req.getParentId() != null
|
||||||
@@ -274,10 +276,11 @@ public class CategoryREST extends AbstractResourceREST {
|
|||||||
Collections.sort(categories, new Comparator<FeedCategory>() {
|
Collections.sort(categories, new Comparator<FeedCategory>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(FeedCategory o1, FeedCategory o2) {
|
public int compare(FeedCategory o1, FeedCategory o2) {
|
||||||
return ObjectUtils.compare(o1.getPosition(), o2.getPosition());
|
return ObjectUtils.compare(o1.getPosition(),
|
||||||
|
o2.getPosition());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
int existingIndex = -1;
|
int existingIndex = -1;
|
||||||
for (int i = 0; i < categories.size(); i++) {
|
for (int i = 0; i < categories.size(); i++) {
|
||||||
if (ObjectUtils.equals(categories.get(i).getId(),
|
if (ObjectUtils.equals(categories.get(i).getId(),
|
||||||
|
|||||||
@@ -317,11 +317,13 @@ public class FeedREST extends AbstractResourceREST {
|
|||||||
@ApiParam(value = "subscription id", required = true) FeedModificationRequest req) {
|
@ApiParam(value = "subscription id", required = true) FeedModificationRequest req) {
|
||||||
Preconditions.checkNotNull(req);
|
Preconditions.checkNotNull(req);
|
||||||
Preconditions.checkNotNull(req.getId());
|
Preconditions.checkNotNull(req.getId());
|
||||||
Preconditions.checkNotNull(req.getName());
|
|
||||||
|
|
||||||
FeedSubscription subscription = feedSubscriptionDAO.findById(getUser(),
|
FeedSubscription subscription = feedSubscriptionDAO.findById(getUser(),
|
||||||
req.getId());
|
req.getId());
|
||||||
subscription.setTitle(req.getName());
|
|
||||||
|
if (StringUtils.isNotBlank(req.getName())) {
|
||||||
|
subscription.setTitle(req.getName());
|
||||||
|
}
|
||||||
|
|
||||||
FeedCategory parent = null;
|
FeedCategory parent = null;
|
||||||
if (req.getCategoryId() != null
|
if (req.getCategoryId() != null
|
||||||
@@ -337,10 +339,11 @@ public class FeedREST extends AbstractResourceREST {
|
|||||||
Collections.sort(subs, new Comparator<FeedSubscription>() {
|
Collections.sort(subs, new Comparator<FeedSubscription>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(FeedSubscription o1, FeedSubscription o2) {
|
public int compare(FeedSubscription o1, FeedSubscription o2) {
|
||||||
return ObjectUtils.compare(o1.getPosition(), o2.getPosition());
|
return ObjectUtils.compare(o1.getPosition(),
|
||||||
|
o2.getPosition());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
int existingIndex = -1;
|
int existingIndex = -1;
|
||||||
for (int i = 0; i < subs.size(); i++) {
|
for (int i = 0; i < subs.size(); i++) {
|
||||||
if (ObjectUtils.equals(subs.get(i).getId(),
|
if (ObjectUtils.equals(subs.get(i).getId(),
|
||||||
|
|||||||
Reference in New Issue
Block a user