Skip to content

Commit

Permalink
Merge pull request #59 from eficode/2.1.12
Browse files Browse the repository at this point in the history
UserRestBean - Made setters a bit more deffencive
  • Loading branch information
farthinder authored Jun 5, 2024
2 parents 849f343 + 33ffe8c commit 593c40a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.eficode.atlassian</groupId>
<artifactId>jirainstancemanager</artifactId>
<version>2.1.11</version>
<version>2.1.12</version>
<description>A groovy library for interacting with Jira REST API.</description>


Expand Down Expand Up @@ -58,7 +58,7 @@
<dependency>
<groupId>com.eficode</groupId>
<artifactId>devstack-standalone</artifactId>
<version>2.3.25</version>
<version>2.3.26</version>
<scope>test</scope>
<exclusions>
<exclusion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonSetter
import org.slf4j.Logger
import org.slf4j.LoggerFactory

class UserRestBean {

Expand All @@ -24,18 +26,37 @@ class UserRestBean {
public String expand
public String lastLoginTime

@JsonIgnore
static Logger log = LoggerFactory.getLogger(UserRestBean.class)


@JsonIgnore
private Map<String, Object> additionalProperties = new LinkedHashMap<String, Object>()

@JsonSetter("groups")
void setGroup(Map rawMap) {
this.groups = (rawMap.get("items") as Map)?.collect {it."name"}
try {
ArrayList<Map> items = rawMap.get("items", null) as ArrayList<Map>
ArrayList<String> groupNames = items?.collect {it.get("name", null)}
this.groups = groupNames
}catch (Throwable ex) {
log.error("Error parsing groups based on raw input:" + rawMap)
throw ex
}

}

@JsonSetter("applicationRoles")
void setApplicationRoles(Map rawMap) {
this.applicationRoles = (rawMap.get("items") as Map)?.collect {it."key"}

try {
ArrayList<Map> items = rawMap.get("items", null) as ArrayList<Map>
ArrayList<String> roleNames = items?.collect {it.get("key", null)}
this.applicationRoles = roleNames
}catch (Throwable ex) {
log.error("Error parsing applicationRoles based on raw input:" + rawMap)
throw ex
}

}

Expand Down

0 comments on commit 593c40a

Please sign in to comment.