mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
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)
|
||||
private Long id;
|
||||
|
||||
@ApiProperty(value = "new name")
|
||||
@ApiProperty(value = "new name, null if not changed")
|
||||
private String name;
|
||||
|
||||
@ApiProperty(value = "new parent category id")
|
||||
|
||||
@@ -18,7 +18,7 @@ public class FeedModificationRequest implements Serializable {
|
||||
@ApiProperty(value = "id", required = true)
|
||||
private Long id;
|
||||
|
||||
@ApiProperty(value = "new name")
|
||||
@ApiProperty(value = "new name, null if not changed")
|
||||
private String name;
|
||||
|
||||
@ApiProperty(value = "new parent category id")
|
||||
|
||||
@@ -252,11 +252,13 @@ public class CategoryREST extends AbstractResourceREST {
|
||||
@ApiParam(required = true) CategoryModificationRequest req) {
|
||||
Preconditions.checkNotNull(req);
|
||||
Preconditions.checkNotNull(req.getId());
|
||||
Preconditions.checkArgument(StringUtils.isNotBlank(req.getName()));
|
||||
|
||||
FeedCategory category = feedCategoryDAO
|
||||
.findById(getUser(), req.getId());
|
||||
category.setName(req.getName());
|
||||
|
||||
if (StringUtils.isNotBlank(req.getName())) {
|
||||
category.setName(req.getName());
|
||||
}
|
||||
|
||||
FeedCategory parent = null;
|
||||
if (req.getParentId() != null
|
||||
@@ -274,10 +276,11 @@ public class CategoryREST extends AbstractResourceREST {
|
||||
Collections.sort(categories, new Comparator<FeedCategory>() {
|
||||
@Override
|
||||
public int compare(FeedCategory o1, FeedCategory o2) {
|
||||
return ObjectUtils.compare(o1.getPosition(), o2.getPosition());
|
||||
return ObjectUtils.compare(o1.getPosition(),
|
||||
o2.getPosition());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
int existingIndex = -1;
|
||||
for (int i = 0; i < categories.size(); i++) {
|
||||
if (ObjectUtils.equals(categories.get(i).getId(),
|
||||
|
||||
@@ -317,11 +317,13 @@ public class FeedREST extends AbstractResourceREST {
|
||||
@ApiParam(value = "subscription id", required = true) FeedModificationRequest req) {
|
||||
Preconditions.checkNotNull(req);
|
||||
Preconditions.checkNotNull(req.getId());
|
||||
Preconditions.checkNotNull(req.getName());
|
||||
|
||||
FeedSubscription subscription = feedSubscriptionDAO.findById(getUser(),
|
||||
req.getId());
|
||||
subscription.setTitle(req.getName());
|
||||
|
||||
if (StringUtils.isNotBlank(req.getName())) {
|
||||
subscription.setTitle(req.getName());
|
||||
}
|
||||
|
||||
FeedCategory parent = null;
|
||||
if (req.getCategoryId() != null
|
||||
@@ -337,10 +339,11 @@ public class FeedREST extends AbstractResourceREST {
|
||||
Collections.sort(subs, new Comparator<FeedSubscription>() {
|
||||
@Override
|
||||
public int compare(FeedSubscription o1, FeedSubscription o2) {
|
||||
return ObjectUtils.compare(o1.getPosition(), o2.getPosition());
|
||||
return ObjectUtils.compare(o1.getPosition(),
|
||||
o2.getPosition());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
int existingIndex = -1;
|
||||
for (int i = 0; i < subs.size(); i++) {
|
||||
if (ObjectUtils.equals(subs.get(i).getId(),
|
||||
|
||||
Reference in New Issue
Block a user