ch.sbb.polarion.extension.api.extender.settings.AuthSettingsModel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ch.sbb.polarion.extension.api-extender Show documentation
Show all versions of ch.sbb.polarion.extension.api-extender Show documentation
This Polarion extension provides additional functionality which is not implemented in standard Polarion API for some reason
The newest version!
package ch.sbb.polarion.extension.api.extender.settings;
import ch.sbb.polarion.extension.generic.settings.SettingsModel;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.polarion.core.util.StringUtils;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.List;
@SuppressWarnings("squid:S2160") //ignore suggestion to create equals() - parent's implementation is sufficient by design
public abstract class AuthSettingsModel extends SettingsModel {
public static final String GLOBAL_ROLES = "globalRoles";
public static final String PROJECT_ROLES = "projectRoles";
@Getter
protected List globalRoles;
@Getter
protected List projectRoles;
public void setGlobalRoles(String... roles) {
globalRoles = Arrays.asList(roles);
}
public void setProjectRoles(String... roles) {
projectRoles = Arrays.asList(roles);
}
@JsonIgnore
public abstract List getAllRoles();
@NotNull
protected String serializeRoles(@Nullable List roles) {
return roles == null ? "" : String.join(",", roles);
}
@NotNull
protected List deserializeRoles(@NotNull String what, @NotNull String serializedString) {
final String roles = deserializeEntry(what, serializedString);
return Arrays.stream(roles.split(",")).filter(s -> !StringUtils.isEmpty(s)).map(String::trim).toList();
}
}