rsanchez
2015-08-03 85aa3a5834bf381b603f63e9e769920c368fa53d
securis/src/main/java/net/curisit/securis/services/PackResource.java
....@@ -2,6 +2,7 @@
22
33 import java.security.Principal;
44 import java.util.Date;
5
+import java.util.HashSet;
56 import java.util.List;
67 import java.util.Set;
78
....@@ -236,6 +237,16 @@
236237 pack.setLicenseType(lt);
237238 }
238239
240
+ private Set<String> getMdKeys(Set<PackMetadata> mds) {
241
+ Set<String> ids = new HashSet<String>();
242
+ if (mds != null) {
243
+ for (PackMetadata md : mds) {
244
+ ids.add(md.getKey());
245
+ }
246
+ }
247
+ return ids;
248
+ }
249
+
239250 @PUT
240251 @POST
241252 @Path("/{packId}")
....@@ -271,16 +282,18 @@
271282 currentPack.setRenewValidPeriod(pack.getRenewValidPeriod());
272283
273284 Set<PackMetadata> newMD = pack.getMetadata();
285
+ Set<String> newMdKeys = getMdKeys(newMD);
274286 for (PackMetadata currentMd : currentPack.getMetadata()) {
275
- if (newMD == null || !newMD.contains(currentMd)) {
287
+ if (!newMdKeys.contains(currentMd.getKey())) {
276288 em.remove(currentMd);
277289 }
278290 }
279291
280292 if (newMD != null) {
281293 Set<PackMetadata> oldMD = currentPack.getMetadata();
294
+ Set<String> oldMdKeys = getMdKeys(newMD);
282295 for (PackMetadata md : newMD) {
283
- if (oldMD.contains(md)) {
296
+ if (oldMdKeys.contains(md.getKey())) {
284297 em.merge(md);
285298 } else {
286299 md.setPack(currentPack);