fix: 🐛 Allow Group description to be empty string

pull/1580/head
Dominik Frantisek Bucik 2022-03-23 07:03:37 +01:00
parent 3f4a70969b
commit 76899b4477
No known key found for this signature in database
GPG Key ID: 25014C8DB2E7E62D
3 changed files with 9 additions and 6 deletions

View File

@ -60,8 +60,8 @@ public class Group extends Model {
}
public void setDescription(String description) {
if (Strings.isNullOrEmpty(description)) {
throw new IllegalArgumentException("description cannot be null nor empty");
if (null == description) {
throw new IllegalArgumentException("description cannot be null");
}
this.description = description;

View File

@ -114,7 +114,7 @@ public class RpcMapper {
Long id = getRequiredFieldAsLong(json, ID);
Long parentGroupId = getFieldAsLong(json, PARENT_GROUP_ID);
String name = getRequiredFieldAsString(json, NAME);
String name = getFieldAsString(json, NAME);
String description = getFieldAsString(json, DESCRIPTION);
Long voId = getRequiredFieldAsLong(json, VO_ID);
String uuid = getRequiredFieldAsString(json, UUID);

View File

@ -557,15 +557,18 @@ public class PerunAdapterLdap extends PerunAdapterWithMappingServices implements
PERUN_VO_ID, PERUN_PARENT_GROUP_ID, UUID};
EntryMapper<Group> mapper = e -> {
if (!checkHasAttributes(e, new String[]{
PERUN_GROUP_ID, CN, DESCRIPTION, PERUN_UNIQUE_GROUP_NAME, PERUN_VO_ID, UUID }))
if (!checkHasAttributes(e,
new String[]{ PERUN_GROUP_ID, CN, PERUN_UNIQUE_GROUP_NAME, PERUN_VO_ID, UUID }))
{
return null;
}
Long id = Long.valueOf(e.get(PERUN_GROUP_ID).getString());
String name = e.get(CN).getString();
String description = e.get(DESCRIPTION).getString();
String description = "";
if (e.containsAttribute(DESCRIPTION)) {
description = e.get(DESCRIPTION).getString();
}
String uniqueName = e.get(PERUN_UNIQUE_GROUP_NAME).getString();
Long voId = Long.valueOf(e.get(PERUN_VO_ID).getString());
Long parentGroupId = null;