rsanchez
2017-03-21 45029ab3bc4f6c293f3a59af233f015b71cc0c09
#3527 fix - Ignoring unknown properties for unmarshall
6 files modified
changed files
securis/src/main/java/net/curisit/securis/db/Application.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/db/ApplicationMetadata.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/db/LicenseTypeMetadata.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/db/Organization.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/db/PackMetadata.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/db/User.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/db/Application.java
....@@ -20,6 +20,7 @@
2020
2121 import com.fasterxml.jackson.annotation.JsonAutoDetect;
2222 import com.fasterxml.jackson.annotation.JsonIgnore;
23
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
2324 import com.fasterxml.jackson.annotation.JsonInclude;
2425 import com.fasterxml.jackson.annotation.JsonInclude.Include;
2526 import com.fasterxml.jackson.annotation.JsonManagedReference;
....@@ -31,121 +32,120 @@
3132 */
3233 @JsonAutoDetect
3334 @JsonInclude(Include.NON_NULL)
35
+@JsonIgnoreProperties(ignoreUnknown = true)
3436 @Entity
3537 @Table(name = "application")
36
-@NamedQueries({
37
- @NamedQuery(name = "list-applications", query = "SELECT a FROM Application a")
38
-})
38
+@NamedQueries({ @NamedQuery(name = "list-applications", query = "SELECT a FROM Application a") })
3939 public class Application implements Serializable {
4040
41
- private static final Logger LOG = LogManager.getLogger(Application.class);
41
+ private static final Logger LOG = LogManager.getLogger(Application.class);
4242
43
- private static final long serialVersionUID = 1L;
43
+ private static final long serialVersionUID = 1L;
4444
45
- @Id
46
- @GeneratedValue
47
- private Integer id;
45
+ @Id
46
+ @GeneratedValue
47
+ private Integer id;
4848
49
- private String code;
50
- private String name;
51
- private String description;
49
+ private String code;
50
+ private String name;
51
+ private String description;
5252
53
- @Column(name = "license_filename")
54
- @JsonProperty("license_filename")
55
- private String licenseFilename;
53
+ @Column(name = "license_filename")
54
+ @JsonProperty("license_filename")
55
+ private String licenseFilename;
5656
57
- @Column(name = "creation_timestamp")
58
- @JsonProperty("creation_timestamp")
59
- private Date creationTimestamp;
57
+ @Column(name = "creation_timestamp")
58
+ @JsonProperty("creation_timestamp")
59
+ private Date creationTimestamp;
6060
61
- // We don't include the referenced entities to limit the size of each row at
62
- // // the listing
63
- @JsonIgnore
64
- @OneToMany(fetch = FetchType.LAZY, mappedBy = "application")
65
- private Set<LicenseType> licenseTypes;
61
+ // We don't include the referenced entities to limit the size of each row at
62
+ // // the listing
63
+ @JsonIgnore
64
+ @OneToMany(fetch = FetchType.LAZY, mappedBy = "application")
65
+ private Set<LicenseType> licenseTypes;
6666
67
- @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "application")
68
- @JsonManagedReference
69
- private Set<ApplicationMetadata> metadata;
67
+ @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "application")
68
+ @JsonManagedReference
69
+ private Set<ApplicationMetadata> metadata;
7070
71
- public Integer getId() {
72
- return id;
73
- }
71
+ public Integer getId() {
72
+ return id;
73
+ }
7474
75
- public void setId(Integer id) {
76
- this.id = id;
77
- }
75
+ public void setId(Integer id) {
76
+ this.id = id;
77
+ }
7878
79
- public String getName() {
80
- return name;
81
- }
79
+ public String getName() {
80
+ return name;
81
+ }
8282
83
- public void setName(String name) {
84
- this.name = name;
85
- }
83
+ public void setName(String name) {
84
+ this.name = name;
85
+ }
8686
87
- public String getDescription() {
88
- return description;
89
- }
87
+ public String getDescription() {
88
+ return description;
89
+ }
9090
91
- public void setDescription(String description) {
92
- this.description = description;
93
- }
91
+ public void setDescription(String description) {
92
+ this.description = description;
93
+ }
9494
95
- public Date getCreationTimestamp() {
96
- return creationTimestamp;
97
- }
95
+ public Date getCreationTimestamp() {
96
+ return creationTimestamp;
97
+ }
9898
99
- public void setCreationTimestamp(Date creationTimestamp) {
100
- this.creationTimestamp = creationTimestamp;
101
- }
99
+ public void setCreationTimestamp(Date creationTimestamp) {
100
+ this.creationTimestamp = creationTimestamp;
101
+ }
102102
103
- @JsonProperty("metadata")
104
- public Set<ApplicationMetadata> getApplicationMetadata() {
105
- return metadata;
106
- }
103
+ @JsonProperty("metadata")
104
+ public Set<ApplicationMetadata> getApplicationMetadata() {
105
+ return metadata;
106
+ }
107107
108
- @JsonProperty("metadata")
109
- public void setApplicationMetadata(Set<ApplicationMetadata> metadata) {
110
- this.metadata = metadata;
111
- }
108
+ @JsonProperty("metadata")
109
+ public void setApplicationMetadata(Set<ApplicationMetadata> metadata) {
110
+ this.metadata = metadata;
111
+ }
112112
113
- @Override
114
- public boolean equals(Object obj) {
115
- if (!(obj instanceof Application))
116
- return false;
117
- Application other = (Application) obj;
118
- return id.equals(other.id);
119
- }
113
+ @Override
114
+ public boolean equals(Object obj) {
115
+ if (!(obj instanceof Application))
116
+ return false;
117
+ Application other = (Application) obj;
118
+ return id.equals(other.id);
119
+ }
120120
121
- @Override
122
- public int hashCode() {
121
+ @Override
122
+ public int hashCode() {
123123
124
- return (id == null ? 0 : id.hashCode());
125
- }
124
+ return (id == null ? 0 : id.hashCode());
125
+ }
126126
127
- public String getLicenseFilename() {
128
- return licenseFilename;
129
- }
127
+ public String getLicenseFilename() {
128
+ return licenseFilename;
129
+ }
130130
131
- public void setLicenseFilename(String licenseFilename) {
132
- this.licenseFilename = licenseFilename;
133
- }
131
+ public void setLicenseFilename(String licenseFilename) {
132
+ this.licenseFilename = licenseFilename;
133
+ }
134134
135
- public Set<LicenseType> getLicenseTypes() {
136
- LOG.info("Getting list license types!!!!");
137
- return licenseTypes;
138
- }
135
+ public Set<LicenseType> getLicenseTypes() {
136
+ LOG.info("Getting list license types!!!!");
137
+ return licenseTypes;
138
+ }
139139
140
- public void setLicenseTypes(Set<LicenseType> licenseTypes) {
141
- this.licenseTypes = licenseTypes;
142
- }
140
+ public void setLicenseTypes(Set<LicenseType> licenseTypes) {
141
+ this.licenseTypes = licenseTypes;
142
+ }
143143
144
- public String getCode() {
145
- return code;
146
- }
144
+ public String getCode() {
145
+ return code;
146
+ }
147147
148
- public void setCode(String code) {
149
- this.code = code;
150
- }
148
+ public void setCode(String code) {
149
+ this.code = code;
150
+ }
151151 }
securis/src/main/java/net/curisit/securis/db/ApplicationMetadata.java
....@@ -30,7 +30,7 @@
3030 @JsonInclude(Include.NON_NULL)
3131 @Entity
3232 @Table(name = "application_metadata")
33
-@JsonIgnoreProperties(value = { "readonly" })
33
+@JsonIgnoreProperties(ignoreUnknown = true)
3434 @NamedQueries({ @NamedQuery(name = "list-application-metadata", query = "SELECT a FROM ApplicationMetadata a where a.application.id = :applicationId") })
3535 public class ApplicationMetadata implements Serializable {
3636
securis/src/main/java/net/curisit/securis/db/LicenseTypeMetadata.java
....@@ -25,7 +25,7 @@
2525 @JsonInclude(Include.NON_NULL)
2626 @Entity
2727 @Table(name = "licensetype_metadata")
28
-@JsonIgnoreProperties(value = { "readonly" })
28
+@JsonIgnoreProperties(ignoreUnknown = true)
2929 @NamedQueries({ @NamedQuery(name = "list-licensetype-metadata", query = "SELECT a FROM LicenseTypeMetadata a where a.licenseType.id = :licenseTypeId") })
3030 public class LicenseTypeMetadata implements Serializable {
3131
securis/src/main/java/net/curisit/securis/db/Organization.java
....@@ -26,6 +26,7 @@
2626
2727 import com.fasterxml.jackson.annotation.JsonAutoDetect;
2828 import com.fasterxml.jackson.annotation.JsonIgnore;
29
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
2930 import com.fasterxml.jackson.annotation.JsonInclude;
3031 import com.fasterxml.jackson.annotation.JsonInclude.Include;
3132 import com.fasterxml.jackson.annotation.JsonProperty;
....@@ -36,164 +37,159 @@
3637 */
3738 @JsonAutoDetect
3839 @JsonInclude(Include.NON_NULL)
40
+@JsonIgnoreProperties(ignoreUnknown = true)
3941 @Entity
4042 @Table(name = "organization")
41
-@NamedQueries({
42
- @NamedQuery(name = "list-organizations", query = "SELECT o FROM Organization o"),
43
- @NamedQuery(name = "list-organizations-by-ids", query = "SELECT o FROM Organization o where id in :list_ids"),
44
- @NamedQuery(name = "find-children-org", query = "SELECT o FROM Organization o where o.parentOrganization = :parentOrganization")
45
-})
43
+@NamedQueries({ @NamedQuery(name = "list-organizations", query = "SELECT o FROM Organization o"),
44
+ @NamedQuery(name = "list-organizations-by-ids", query = "SELECT o FROM Organization o where id in :list_ids"),
45
+ @NamedQuery(name = "find-children-org", query = "SELECT o FROM Organization o where o.parentOrganization = :parentOrganization") })
4646 public class Organization implements Serializable {
4747
48
- @SuppressWarnings("unused")
49
- private static final Logger LOG = LogManager.getLogger(Organization.class);
48
+ @SuppressWarnings("unused")
49
+ private static final Logger LOG = LogManager.getLogger(Organization.class);
5050
51
- private static final long serialVersionUID = 1L;
51
+ private static final long serialVersionUID = 1L;
5252
53
- @Id
54
- @GeneratedValue
55
- private Integer id;
53
+ @Id
54
+ @GeneratedValue
55
+ private Integer id;
5656
57
- private String code;
58
- private String name;
59
- private String description;
57
+ private String code;
58
+ private String name;
59
+ private String description;
6060
61
- @Column(name = "creation_timestamp")
62
- @JsonProperty("creation_timestamp")
63
- private Date creationTimestamp;
61
+ @Column(name = "creation_timestamp")
62
+ @JsonProperty("creation_timestamp")
63
+ private Date creationTimestamp;
6464
65
- @JsonIgnore
66
- // We don't include the users to limit the size of each row a the listing
67
- @ManyToMany(cascade = CascadeType.REMOVE)
68
- @JoinTable(name = "user_organization", //
69
- joinColumns = {
70
- @JoinColumn(name = "organization_id", referencedColumnName = "id")
71
- }, //
72
- inverseJoinColumns = {
73
- @JoinColumn(name = "username", referencedColumnName = "username")
74
- })
75
- private Set<User> users;
65
+ @JsonIgnore
66
+ // We don't include the users to limit the size of each row a the listing
67
+ @ManyToMany(cascade = CascadeType.REMOVE)
68
+ @JoinTable(name = "user_organization", //
69
+ joinColumns = { @JoinColumn(name = "organization_id", referencedColumnName = "id") }, //
70
+ inverseJoinColumns = { @JoinColumn(name = "username", referencedColumnName = "username") })
71
+ private Set<User> users;
7672
77
- @JsonIgnore
78
- // We don't include the users to limit the size of each row a the listing
79
- @ManyToOne
80
- @JoinColumn(name = "org_parent_id")
81
- private Organization parentOrganization;
73
+ @JsonIgnore
74
+ // We don't include the users to limit the size of each row a the listing
75
+ @ManyToOne
76
+ @JoinColumn(name = "org_parent_id")
77
+ private Organization parentOrganization;
8278
83
- @JsonIgnore
84
- // We don't include the users to limit the size of each row a the listing
85
- @OneToMany(fetch = FetchType.LAZY, mappedBy = "parentOrganization")
86
- private Set<Organization> childOrganizations;
79
+ @JsonIgnore
80
+ // We don't include the users to limit the size of each row a the listing
81
+ @OneToMany(fetch = FetchType.LAZY, mappedBy = "parentOrganization")
82
+ private Set<Organization> childOrganizations;
8783
88
- public Integer getId() {
89
- return id;
90
- }
84
+ public Integer getId() {
85
+ return id;
86
+ }
9187
92
- public void setId(Integer id) {
93
- this.id = id;
94
- }
88
+ public void setId(Integer id) {
89
+ this.id = id;
90
+ }
9591
96
- public String getName() {
97
- return name;
98
- }
92
+ public String getName() {
93
+ return name;
94
+ }
9995
100
- public void setName(String name) {
101
- this.name = name;
102
- }
96
+ public void setName(String name) {
97
+ this.name = name;
98
+ }
10399
104
- public String getDescription() {
105
- return description;
106
- }
100
+ public String getDescription() {
101
+ return description;
102
+ }
107103
108
- public void setDescription(String description) {
109
- this.description = description;
110
- }
104
+ public void setDescription(String description) {
105
+ this.description = description;
106
+ }
111107
112
- public String getCode() {
113
- return code;
114
- }
108
+ public String getCode() {
109
+ return code;
110
+ }
115111
116
- public void setCode(String code) {
117
- this.code = code;
118
- }
112
+ public void setCode(String code) {
113
+ this.code = code;
114
+ }
119115
120
- public Date getCreationTimestamp() {
121
- return creationTimestamp;
122
- }
116
+ public Date getCreationTimestamp() {
117
+ return creationTimestamp;
118
+ }
123119
124
- public void setCreationTimestamp(Date creationTimestamp) {
125
- this.creationTimestamp = creationTimestamp;
126
- }
120
+ public void setCreationTimestamp(Date creationTimestamp) {
121
+ this.creationTimestamp = creationTimestamp;
122
+ }
127123
128
- public Set<User> getUsers() {
129
- return users;
130
- }
124
+ public Set<User> getUsers() {
125
+ return users;
126
+ }
131127
132
- public void setUsers(Set<User> users) {
133
- this.users = users;
134
- }
128
+ public void setUsers(Set<User> users) {
129
+ this.users = users;
130
+ }
135131
136
- public Organization getParentOrganization() {
137
- return parentOrganization;
138
- }
132
+ public Organization getParentOrganization() {
133
+ return parentOrganization;
134
+ }
139135
140
- public void setParentOrganization(Organization parentOrganization) {
141
- this.parentOrganization = parentOrganization;
142
- }
136
+ public void setParentOrganization(Organization parentOrganization) {
137
+ this.parentOrganization = parentOrganization;
138
+ }
143139
144
- // Roberto: Following methods are necessary to include in the REST list
145
- // response
146
- // information about the referenced entities.
147
- @JsonProperty("org_parent_id")
148
- public void setParentOrgId(Integer orgId) {
149
- if (orgId != null) {
150
- parentOrganization = new Organization();
151
- parentOrganization.setId(orgId);
152
- } else {
153
- parentOrganization = null;
154
- }
155
- }
140
+ // Roberto: Following methods are necessary to include in the REST list
141
+ // response
142
+ // information about the referenced entities.
143
+ @JsonProperty("org_parent_id")
144
+ public void setParentOrgId(Integer orgId) {
145
+ if (orgId != null) {
146
+ parentOrganization = new Organization();
147
+ parentOrganization.setId(orgId);
148
+ } else {
149
+ parentOrganization = null;
150
+ }
151
+ }
156152
157
- @JsonProperty("org_parent_id")
158
- public Integer getParentOrgId() {
159
- return parentOrganization == null ? null : parentOrganization.getId();
160
- }
153
+ @JsonProperty("org_parent_id")
154
+ public Integer getParentOrgId() {
155
+ return parentOrganization == null ? null : parentOrganization.getId();
156
+ }
161157
162
- @JsonProperty("org_parent_name")
163
- public String getParentOrgName() {
164
- return parentOrganization == null ? null : parentOrganization.getName();
165
- }
158
+ @JsonProperty("org_parent_name")
159
+ public String getParentOrgName() {
160
+ return parentOrganization == null ? null : parentOrganization.getName();
161
+ }
166162
167
- @JsonProperty("users_ids")
168
- public void setUsersIds(List<String> usersIds) {
169
- users = new HashSet<>();
170
- if (usersIds != null) {
171
- for (String userid : usersIds) {
172
- User u = new User();
173
- u.setUsername(userid);
174
- users.add(u);
175
- }
176
- }
177
- }
163
+ @JsonProperty("users_ids")
164
+ public void setUsersIds(List<String> usersIds) {
165
+ users = new HashSet<>();
166
+ if (usersIds != null) {
167
+ for (String userid : usersIds) {
168
+ User u = new User();
169
+ u.setUsername(userid);
170
+ users.add(u);
171
+ }
172
+ }
173
+ }
178174
179
- @JsonProperty("users_ids")
180
- public Set<String> getUsersIds() {
181
- if (users == null) {
182
- return null;
183
- }
184
- Set<String> ids = new HashSet<>();
185
- for (User user : users) {
186
- ids.add(user.getUsername());
187
- }
188
- return ids;
189
- }
175
+ @JsonProperty("users_ids")
176
+ public Set<String> getUsersIds() {
177
+ if (users == null) {
178
+ return null;
179
+ }
180
+ Set<String> ids = new HashSet<>();
181
+ for (User user : users) {
182
+ ids.add(user.getUsername());
183
+ }
184
+ return ids;
185
+ }
190186
191
- public Set<Organization> getChildOrganizations() {
192
- return childOrganizations;
193
- }
187
+ public Set<Organization> getChildOrganizations() {
188
+ return childOrganizations;
189
+ }
194190
195
- public void setChildOrganizations(Set<Organization> childOrganizations) {
196
- this.childOrganizations = childOrganizations;
197
- }
191
+ public void setChildOrganizations(Set<Organization> childOrganizations) {
192
+ this.childOrganizations = childOrganizations;
193
+ }
198194
199195 }
securis/src/main/java/net/curisit/securis/db/PackMetadata.java
....@@ -26,7 +26,7 @@
2626 @JsonInclude(Include.NON_NULL)
2727 @Entity
2828 @Table(name = "pack_metadata")
29
-@JsonIgnoreProperties(value = { "readonly" })
29
+@JsonIgnoreProperties(ignoreUnknown = true)
3030 @NamedQueries({ @NamedQuery(name = "list-pack-metadata", query = "SELECT a FROM PackMetadata a where a.pack.id = :packId") })
3131 public class PackMetadata implements Serializable {
3232
securis/src/main/java/net/curisit/securis/db/User.java
....@@ -19,6 +19,7 @@
1919
2020 import com.fasterxml.jackson.annotation.JsonAutoDetect;
2121 import com.fasterxml.jackson.annotation.JsonIgnore;
22
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
2223 import com.fasterxml.jackson.annotation.JsonInclude;
2324 import com.fasterxml.jackson.annotation.JsonInclude.Include;
2425 import com.fasterxml.jackson.annotation.JsonProperty;
....@@ -29,217 +30,209 @@
2930 */
3031 @JsonAutoDetect
3132 @JsonInclude(Include.NON_NULL)
33
+@JsonIgnoreProperties(ignoreUnknown = true)
3234 @Entity
3335 @Table(name = "user")
34
-@NamedQueries({
35
- @NamedQuery(name = "list-users", query = "SELECT u FROM User u"),
36
- @NamedQuery(name = "get-user", query = "SELECT u FROM User u where u.username = :username"),
37
- @NamedQuery(name = "auth-user", query = "SELECT u FROM User u where u.username = :username and u.password = :password"),
38
- @NamedQuery(name = "delete-all-users", query = "delete FROM User u")
39
-})
36
+@NamedQueries({ @NamedQuery(name = "list-users", query = "SELECT u FROM User u"), @NamedQuery(name = "get-user", query = "SELECT u FROM User u where u.username = :username"),
37
+ @NamedQuery(name = "auth-user", query = "SELECT u FROM User u where u.username = :username and u.password = :password"),
38
+ @NamedQuery(name = "delete-all-users", query = "delete FROM User u") })
4039 public class User implements Serializable {
4140
42
- private static final long serialVersionUID = 1L;
41
+ private static final long serialVersionUID = 1L;
4342
44
- @Id
45
- private String username;
43
+ @Id
44
+ private String username;
4645
47
- private String password;
46
+ private String password;
4847
49
- @JsonProperty(value = "first_name")
50
- @Column(name = "first_name")
51
- private String firstName;
48
+ @JsonProperty(value = "first_name")
49
+ @Column(name = "first_name")
50
+ private String firstName;
5251
53
- @JsonProperty(value = "last_name")
54
- @Column(name = "last_name")
55
- private String lastName;
52
+ @JsonProperty(value = "last_name")
53
+ @Column(name = "last_name")
54
+ private String lastName;
5655
57
- private int roles;
56
+ private int roles;
5857
59
- @Column(name = "last_login")
60
- private Date lastLogin;
58
+ @Column(name = "last_login")
59
+ private Date lastLogin;
6160
62
- @Column(name = "modification_timestamp")
63
- private Date modificationTimestamp;
61
+ @Column(name = "modification_timestamp")
62
+ private Date modificationTimestamp;
6463
65
- @Column(name = "creation_timestamp")
66
- @JsonProperty("creation_timestamp")
67
- private Date creationTimestamp;
64
+ @Column(name = "creation_timestamp")
65
+ @JsonProperty("creation_timestamp")
66
+ private Date creationTimestamp;
6867
69
- private String lang;
68
+ private String lang;
7069
71
- private String email;
70
+ private String email;
7271
73
- @JsonIgnore
74
- @ManyToMany
75
- @JoinTable(name = "user_organization", //
76
- joinColumns = {
77
- @JoinColumn(name = "username", referencedColumnName = "username")
78
- }, //
79
- inverseJoinColumns = {
80
- @JoinColumn(name = "organization_id", referencedColumnName = "id")
81
- } //
82
- )
83
- private Set<Organization> organizations;
72
+ @JsonIgnore
73
+ @ManyToMany
74
+ @JoinTable(name = "user_organization", //
75
+ joinColumns = { @JoinColumn(name = "username", referencedColumnName = "username") }, //
76
+ inverseJoinColumns = { @JoinColumn(name = "organization_id", referencedColumnName = "id") } //
77
+ )
78
+ private Set<Organization> organizations;
8479
85
- public String getUsername() {
86
- return username;
87
- }
80
+ public String getUsername() {
81
+ return username;
82
+ }
8883
89
- public void setUsername(String username) {
90
- this.username = username;
91
- }
84
+ public void setUsername(String username) {
85
+ this.username = username;
86
+ }
9287
93
- @JsonProperty("password")
94
- public String getDummyPassword() {
95
- return null;
96
- }
88
+ @JsonProperty("password")
89
+ public String getDummyPassword() {
90
+ return null;
91
+ }
9792
98
- public String getPassword() {
99
- return password;
100
- }
93
+ public String getPassword() {
94
+ return password;
95
+ }
10196
102
- public void setPassword(String password) {
103
- this.password = password;
104
- }
97
+ public void setPassword(String password) {
98
+ this.password = password;
99
+ }
105100
106
- public List<Integer> getRoles() {
107
- if (roles == 0) {
108
- return null;
109
- }
110
- List<Integer> aux = new ArrayList<>();
111
- for (int rol : Rol.ALL) {
112
- if ((roles & rol) != 0) { // Each rol is a number with only 1 bit ==
113
- // 1 in binary representation
114
- aux.add(rol);
115
- }
116
- }
117
- return aux;
118
- }
101
+ public List<Integer> getRoles() {
102
+ if (roles == 0) {
103
+ return null;
104
+ }
105
+ List<Integer> aux = new ArrayList<>();
106
+ for (int rol : Rol.ALL) {
107
+ if ((roles & rol) != 0) { // Each rol is a number with only 1 bit ==
108
+ // 1 in binary representation
109
+ aux.add(rol);
110
+ }
111
+ }
112
+ return aux;
113
+ }
119114
120
- public void setRoles(List<Integer> roles) {
121
- this.roles = 0;
122
- if (roles != null) {
123
- for (Integer rol : roles) {
124
- this.roles |= rol;
125
- }
126
- }
127
- }
115
+ public void setRoles(List<Integer> roles) {
116
+ this.roles = 0;
117
+ if (roles != null) {
118
+ for (Integer rol : roles) {
119
+ this.roles |= rol;
120
+ }
121
+ }
122
+ }
128123
129
- public String getFirstName() {
130
- return firstName;
131
- }
124
+ public String getFirstName() {
125
+ return firstName;
126
+ }
132127
133
- public void setFirstName(String firstName) {
134
- this.firstName = firstName;
135
- }
128
+ public void setFirstName(String firstName) {
129
+ this.firstName = firstName;
130
+ }
136131
137
- public String getLastName() {
138
- return lastName;
139
- }
132
+ public String getLastName() {
133
+ return lastName;
134
+ }
140135
141
- public void setLastName(String lastName) {
142
- this.lastName = lastName;
143
- }
136
+ public void setLastName(String lastName) {
137
+ this.lastName = lastName;
138
+ }
144139
145
- public Date getLastLogin() {
146
- return lastLogin;
147
- }
140
+ public Date getLastLogin() {
141
+ return lastLogin;
142
+ }
148143
149
- public void setLastLogin(Date lastLogin) {
150
- this.lastLogin = lastLogin;
151
- }
144
+ public void setLastLogin(Date lastLogin) {
145
+ this.lastLogin = lastLogin;
146
+ }
152147
153
- public Date getModificationTimestamp() {
154
- return modificationTimestamp;
155
- }
148
+ public Date getModificationTimestamp() {
149
+ return modificationTimestamp;
150
+ }
156151
157
- public void setModificationTimestamp(Date modificationTimestamp) {
158
- this.modificationTimestamp = modificationTimestamp;
159
- }
152
+ public void setModificationTimestamp(Date modificationTimestamp) {
153
+ this.modificationTimestamp = modificationTimestamp;
154
+ }
160155
161
- public Date getCreationTimestamp() {
162
- return creationTimestamp;
163
- }
156
+ public Date getCreationTimestamp() {
157
+ return creationTimestamp;
158
+ }
164159
165
- public void setCreationTimestamp(Date creationTimestamp) {
166
- this.creationTimestamp = creationTimestamp;
167
- }
160
+ public void setCreationTimestamp(Date creationTimestamp) {
161
+ this.creationTimestamp = creationTimestamp;
162
+ }
168163
169
- @Override
170
- public String toString() {
171
- return "{User: " + username + " Name: " + firstName + " " + lastName + ", last login: " + lastLogin + "}";
172
- }
164
+ @Override
165
+ public String toString() {
166
+ return "{User: " + username + " Name: " + firstName + " " + lastName + ", last login: " + lastLogin + "}";
167
+ }
173168
174
- public String getLang() {
175
- return lang;
176
- }
169
+ public String getLang() {
170
+ return lang;
171
+ }
177172
178
- public void setLang(String lang) {
179
- this.lang = lang;
180
- }
173
+ public void setLang(String lang) {
174
+ this.lang = lang;
175
+ }
181176
182
- public Set<Organization> getOrganizations() {
183
- return organizations;
184
- }
177
+ public Set<Organization> getOrganizations() {
178
+ return organizations;
179
+ }
185180
186
- public void setOrganizations(Set<Organization> organizations) {
187
- this.organizations = organizations;
188
- }
181
+ public void setOrganizations(Set<Organization> organizations) {
182
+ this.organizations = organizations;
183
+ }
189184
190
- @JsonProperty("organizations_ids")
191
- public void setOrgsIds(List<Integer> orgsIds) {
192
- organizations = new HashSet<>();
193
- for (Integer orgid : orgsIds) {
194
- Organization o = new Organization();
195
- o.setId(orgid);
196
- organizations.add(o);
197
- }
198
- }
185
+ @JsonProperty("organizations_ids")
186
+ public void setOrgsIds(List<Integer> orgsIds) {
187
+ organizations = new HashSet<>();
188
+ for (Integer orgid : orgsIds) {
189
+ Organization o = new Organization();
190
+ o.setId(orgid);
191
+ organizations.add(o);
192
+ }
193
+ }
199194
200
- @JsonProperty("organizations_ids")
201
- public Set<Integer> getOrgsIds() {
202
- if (organizations == null) {
203
- return null;
204
- }
205
- Set<Integer> ids = new HashSet<>();
206
- for (Organization org : organizations) {
207
- ids.add(org.getId());
208
- }
209
- return ids;
210
- }
195
+ @JsonProperty("organizations_ids")
196
+ public Set<Integer> getOrgsIds() {
197
+ if (organizations == null) {
198
+ return null;
199
+ }
200
+ Set<Integer> ids = new HashSet<>();
201
+ for (Organization org : organizations) {
202
+ ids.add(org.getId());
203
+ }
204
+ return ids;
205
+ }
211206
212
- @JsonIgnore
213
- public Set<Integer> getAllOrgsIds() {
214
- if (organizations == null) {
215
- return null;
216
- }
217
- Set<Integer> ids = new HashSet<>();
218
- includeAllOrgs(this.organizations, ids);
219
- return ids;
220
- }
207
+ @JsonIgnore
208
+ public Set<Integer> getAllOrgsIds() {
209
+ if (organizations == null) {
210
+ return null;
211
+ }
212
+ Set<Integer> ids = new HashSet<>();
213
+ includeAllOrgs(this.organizations, ids);
214
+ return ids;
215
+ }
221216
222
- private void includeAllOrgs(Set<Organization> list, Set<Integer> orgIds) {
223
- for (Organization org : list) {
224
- orgIds.add(org.getId());
225
- includeAllOrgs(org.getChildOrganizations(), orgIds);
226
- }
227
- }
217
+ private void includeAllOrgs(Set<Organization> list, Set<Integer> orgIds) {
218
+ for (Organization org : list) {
219
+ orgIds.add(org.getId());
220
+ includeAllOrgs(org.getChildOrganizations(), orgIds);
221
+ }
222
+ }
228223
229
- public String getEmail() {
230
- return email;
231
- }
224
+ public String getEmail() {
225
+ return email;
226
+ }
232227
233
- public void setEmail(String email) {
234
- this.email = email;
235
- }
228
+ public void setEmail(String email) {
229
+ this.email = email;
230
+ }
236231
237
- public static class Rol {
238
- public static final int ADVANCE = 0x01;
239
- public static final int ADMIN = 0x02;
240
- public static final int[] ALL = new int[] {
241
- ADVANCE, ADMIN
242
- };
243
- }
232
+ public static class Rol {
233
+ public static final int ADVANCE = 0x01;
234
+ public static final int ADMIN = 0x02;
235
+ public static final int[] ALL = new int[] { ADVANCE, ADMIN };
236
+ }
244237
245238 }