Пример #1
0
 /** DAO cannot find acl object identity. */
 @Test
 public final void doesNotFindAclObjectIdentityByItem() {
   final Item item = new Item();
   final Long iid = 99L;
   item.setId(iid);
   Assert.assertNull(this.dao.findByItem(item));
 }
Пример #2
0
 /** DAO can find acl object identity related to the specified item. */
 @Test
 public final void findsAclObjectIdentityByItem() {
   final AclClass clazz = new AclClass(this.getClass().getCanonicalName());
   final AclSid sid = new AclSid("*****@*****.**", true);
   final AclObjectIdentity ident = new AclObjectIdentity();
   ident.setAclClass(clazz);
   final Long obj = 10L;
   ident.setObjectId(obj);
   ident.setAclSid(sid);
   this.dao.save(ident);
   final Item item = new Item();
   item.setId(obj);
   final AclObjectIdentity found = this.dao.findByItem(item);
   Assert.assertNotNull(found);
 }
Пример #3
0
  @Override
  @Transactional
  @Secured("ACL_ADD_ITEM") // Protection from inMemory realization from /acl
  public void save(Item item) {

    if (item.getId() == null) {
      em.persist(item);
    } else {
      em.merge(item);
    }
  }
Пример #4
0
 @Override
 @PostAuthorize("hasPermission(#item, 'WRITE')") // protection from acl tables
 public boolean delete(Item item) {
   return em.createNamedQuery(Item.DELETE).setParameter("id", item.getId()).executeUpdate() != 0;
 }