| .. | .. |
|---|
| 2 | 2 | |
|---|
| 3 | 3 | import java.security.Principal; |
|---|
| 4 | 4 | import java.util.Date; |
|---|
| 5 | +import java.util.HashSet; |
|---|
| 5 | 6 | import java.util.List; |
|---|
| 6 | 7 | import java.util.Set; |
|---|
| 7 | 8 | |
|---|
| .. | .. |
|---|
| 236 | 237 | pack.setLicenseType(lt); |
|---|
| 237 | 238 | } |
|---|
| 238 | 239 | |
|---|
| 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 | + |
|---|
| 239 | 250 | @PUT |
|---|
| 240 | 251 | @POST |
|---|
| 241 | 252 | @Path("/{packId}") |
|---|
| .. | .. |
|---|
| 271 | 282 | currentPack.setRenewValidPeriod(pack.getRenewValidPeriod()); |
|---|
| 272 | 283 | |
|---|
| 273 | 284 | Set<PackMetadata> newMD = pack.getMetadata(); |
|---|
| 285 | + Set<String> newMdKeys = getMdKeys(newMD); |
|---|
| 274 | 286 | for (PackMetadata currentMd : currentPack.getMetadata()) { |
|---|
| 275 | | - if (newMD == null || !newMD.contains(currentMd)) { |
|---|
| 287 | + if (!newMdKeys.contains(currentMd.getKey())) { |
|---|
| 276 | 288 | em.remove(currentMd); |
|---|
| 277 | 289 | } |
|---|
| 278 | 290 | } |
|---|
| 279 | 291 | |
|---|
| 280 | 292 | if (newMD != null) { |
|---|
| 281 | 293 | Set<PackMetadata> oldMD = currentPack.getMetadata(); |
|---|
| 294 | + Set<String> oldMdKeys = getMdKeys(newMD); |
|---|
| 282 | 295 | for (PackMetadata md : newMD) { |
|---|
| 283 | | - if (oldMD.contains(md)) { |
|---|
| 296 | + if (oldMdKeys.contains(md.getKey())) { |
|---|
| 284 | 297 | em.merge(md); |
|---|
| 285 | 298 | } else { |
|---|
| 286 | 299 | md.setPack(currentPack); |
|---|