示例#1
0
 private void verifyContains(Collection items, ContentItem content) {
   for (Iterator it = items.iterator(); it.hasNext(); ) {
     Item item = (Item) it.next();
     if (item instanceof ContentItem && item.getName().equals(content.getName())) return;
   }
   Assert.fail("content not found");
 }
示例#2
0
  /* (non-Javadoc)
   * @see org.osaf.cosmo.model.copy.InterfaceTicket#isGranted(org.osaf.cosmo.model.copy.Item)
   */
  public boolean isGranted(Item item) {

    if (item == null) return false;

    for (Ticket ticket : item.getTickets()) {
      if (ticket.equals(this)) return true;
    }

    for (Item parent : item.getParents()) {
      if (isGranted(parent)) return true;
    }

    return false;
  }
示例#3
0
 /* (non-Javadoc)
  * @see org.osaf.cosmo.model.copy.InterfaceCollectionItem#removeTombstone(org.osaf.cosmo.model.copy.Item)
  */
 public boolean removeTombstone(Item item) {
   for (Iterator<Tombstone> it = getTombstones().iterator(); it.hasNext(); ) {
     Tombstone ts = it.next();
     if (ts instanceof ItemTombstone) {
       if (((ItemTombstone) ts).getItemUid().equals(item.getUid())) {
         it.remove();
         return true;
       }
     }
   }
   return false;
 }
示例#4
0
  public void testFindItem() throws Exception {
    User testuser2 = getUser(userDao, "testuser2");

    CollectionItem root = (CollectionItem) contentDao.getRootItem(testuser2);

    CollectionItem a = new HibCollectionItem();
    a.setName("a");
    a.setOwner(getUser(userDao, "testuser2"));

    a = contentDao.createCollection(root, a);

    clearSession();

    Item queryItem = contentDao.findItemByUid(a.getUid());
    Assert.assertNotNull(queryItem);
    Assert.assertTrue(queryItem instanceof CollectionItem);

    queryItem = contentDao.findItemByPath("/testuser2/a");
    Assert.assertNotNull(queryItem);
    Assert.assertTrue(queryItem instanceof CollectionItem);

    ContentItem item = generateTestContent();

    a = contentDao.findCollectionByUid(a.getUid());
    item = contentDao.createContent(a, item);

    clearSession();

    queryItem = contentDao.findItemByPath("/testuser2/a/test");
    Assert.assertNotNull(queryItem);
    Assert.assertTrue(queryItem instanceof ContentItem);

    clearSession();

    queryItem = contentDao.findItemParentByPath("/testuser2/a/test");
    Assert.assertNotNull(queryItem);
    Assert.assertEquals(a.getUid(), queryItem.getUid());
  }
示例#5
0
 /* (non-Javadoc)
  * @see org.osaf.cosmo.model.copy.InterfaceCollectionItem#getChildByName(java.lang.String)
  */
 public Item getChildByName(String name) {
   for (Item child : children) {
     if (child.getName().equals(name)) return child;
   }
   return null;
 }
示例#6
0
 /* (non-Javadoc)
  * @see org.osaf.cosmo.model.copy.InterfaceCollectionItem#getChild(java.lang.String)
  */
 public Item getChild(String uid) {
   for (Item child : children) {
     if (child.getUid().equals(uid)) return child;
   }
   return null;
 }