예제 #1
0
  @Test
  public void testUpdateReadonlyMultidir() throws Exception {
    MultiDirectory readonlyMultidir =
        (MultiDirectory) directoryService.getDirectory("readonlymulti");
    MultiDirectorySession readonlyDir = (MultiDirectorySession) readonlyMultidir.getSession();
    Session dir1 = memdir1.getSession();
    Session dir2 = memdir2.getSession();
    Session dir3 = memdir3.getSession();

    // multi-subdirs update
    DocumentModel e = readonlyDir.getEntry("1");
    assertEquals("foo1", e.getProperty("schema3", "thefoo"));
    assertEquals("bar1", e.getProperty("schema3", "thebar"));
    e.setProperty("schema3", "thefoo", "fffooo1");
    e.setProperty("schema3", "thebar", "babar1");

    readonlyDir.updateEntry(e);
    e = readonlyDir.getEntry("1");
    // the multidirectory entry was not updated
    assertEquals("foo1", e.getProperty("schema3", "thefoo"));
    assertEquals("bar1", e.getProperty("schema3", "thebar"));

    // neither the underlying directories
    assertEquals("foo1", dir1.getEntry("1").getProperty("schema1", "foo"));
    assertEquals("bar1", dir2.getEntry("1").getProperty("schema2", "bar"));
    assertNull(dir3.getEntry("1"));
  }
예제 #2
0
  @Test
  public void testReadOnlyEntryFromMultidirectory() throws Exception {
    MultiDirectory readonlyMultidir =
        (MultiDirectory) directoryService.getDirectory("readonlymulti");
    MultiDirectorySession readonlyDir = (MultiDirectorySession) readonlyMultidir.getSession();

    // all should be readonly
    assertTrue(BaseSession.isReadOnlyEntry(readonlyDir.getEntry("1")));
    assertTrue(BaseSession.isReadOnlyEntry(readonlyDir.getEntry("2")));
    assertTrue(BaseSession.isReadOnlyEntry(readonlyDir.getEntry("3")));
    assertTrue(BaseSession.isReadOnlyEntry(readonlyDir.getEntry("4")));
  }
예제 #3
0
  @Before
  public void setUp() throws Exception {
    // mem dir factory
    directoryService = Framework.getLocalService(DirectoryService.class);
    memoryDirectoryFactory = new MemoryDirectoryFactory();
    directoryService.registerDirectory("memdirs", memoryDirectoryFactory);

    // create and register mem directories
    Map<String, Object> e;

    // dir 1
    Set<String> schema1Set = new HashSet<String>(Arrays.asList("uid", "foo"));
    memdir1 = new MemoryDirectory("dir1", "schema1", schema1Set, "uid", "foo");
    memoryDirectoryFactory.registerDirectory(memdir1);

    Session dir1 = memdir1.getSession();
    e = new HashMap<String, Object>();
    e.put("uid", "1");
    e.put("foo", "foo1");
    dir1.createEntry(e);
    e = new HashMap<String, Object>();
    e.put("uid", "2");
    e.put("foo", "foo2");
    dir1.createEntry(e);

    // dir 2
    Set<String> schema2Set = new HashSet<String>(Arrays.asList("id", "bar"));
    memdir2 = new MemoryDirectory("dir2", "schema2", schema2Set, "id", null);
    memoryDirectoryFactory.registerDirectory(memdir2);

    Session dir2 = memdir2.getSession();
    e = new HashMap<String, Object>();
    e.put("id", "1");
    e.put("bar", "bar1");
    dir2.createEntry(e);
    e = new HashMap<String, Object>();
    e.put("id", "2");
    e.put("bar", "bar2");
    dir2.createEntry(e);

    // dir 3
    Set<String> schema3Set = new HashSet<String>(Arrays.asList("uid", "thefoo", "thebar"));
    memdir3 = new MemoryDirectory("dir3", "schema3", schema3Set, "uid", "thefoo");
    memoryDirectoryFactory.registerDirectory(memdir3);

    Session dir3 = memdir3.getSession();
    e = new HashMap<String, Object>();
    e.put("uid", "3");
    e.put("thefoo", "foo3");
    e.put("thebar", "bar3");
    dir3.createEntry(e);
    e = new HashMap<String, Object>();
    e.put("uid", "4");
    e.put("thefoo", "foo4");
    e.put("thebar", "bar4");
    dir3.createEntry(e);

    // the multi directory
    multiDir = (MultiDirectory) directoryService.getDirectory("multi");
    dir = (MultiDirectorySession) multiDir.getSession();
  }