assertNotNull(page.getParent());
assertEquals(page.getParent().getId(), folder.getId());
assertEquals(3, folder.getPages().size());
assertEquals(3, pageManager.getPages(folder).size());
Link link = pageManager.newLink("/default.link");
assertEquals("Default", link.getTitle());
link.setTitle("Default Link");
link.setVersion("1.23");
link.setShortTitle("Default");
link.setTarget("top");
link.setUrl("http://www.default.org/");
metadata = link.getMetadata();
metadata.addField(Locale.FRENCH, "title", "[fr] Default Link");
metadata.addField(Locale.GERMAN, "title", "[de] Default Link");
SecurityConstraints linkConstraints = link.newSecurityConstraints();
linkConstraints.setOwner("user");
List inlineLinkConstraints = new ArrayList(1);
SecurityConstraint linkConstraint = link.newSecurityConstraint();
linkConstraint.setUsers(Shared.makeListFromCSV("jetspeed"));
linkConstraint.setPermissions(Shared.makeListFromCSV("edit"));
inlineLinkConstraints.add(linkConstraint);
linkConstraints.setSecurityConstraints(inlineLinkConstraints);
List linkConstraintsRefs = new ArrayList(1);
linkConstraintsRefs.add("manager-edit");
linkConstraints.setSecurityConstraintsRefs(linkConstraintsRefs);
link.setSecurityConstraints(linkConstraints);
pageManager.updateLink(link);
assertNotNull(link.getParent());
assertEquals(link.getParent().getId(), folder.getId());
assertNotNull(folder.getLinks());
assertEquals(1, folder.getLinks().size());
assertNotNull(pageManager.getLinks(folder));
assertEquals(1, pageManager.getLinks(folder).size());
PageSecurity pageSecurity = pageManager.newPageSecurity();
List constraintsDefs = new ArrayList(2);
SecurityConstraintsDef constraintsDef = pageManager.newSecurityConstraintsDef();
constraintsDef.setName("public-view");
List defConstraints = new ArrayList(1);
SecurityConstraint defConstraint = pageSecurity.newSecurityConstraint();
defConstraint.setUsers(Shared.makeListFromCSV("*"));
defConstraint.setPermissions(Shared.makeListFromCSV("view"));
defConstraints.add(defConstraint);
constraintsDef.setSecurityConstraints(defConstraints);
constraintsDefs.add(constraintsDef);
constraintsDef = pageSecurity.newSecurityConstraintsDef();
constraintsDef.setName("admin-all");
defConstraints = new ArrayList(2);
defConstraint = pageSecurity.newSecurityConstraint();
defConstraint.setRoles(Shared.makeListFromCSV("admin"));
defConstraint.setPermissions(Shared.makeListFromCSV("view,edit"));
defConstraints.add(defConstraint);
defConstraint = pageSecurity.newSecurityConstraint();
defConstraint.setRoles(Shared.makeListFromCSV("nobody"));
defConstraints.add(defConstraint);
constraintsDef.setSecurityConstraints(defConstraints);
constraintsDefs.add(constraintsDef);
pageSecurity.setSecurityConstraintsDefs(constraintsDefs);
List globalConstraintsRefs = new ArrayList(2);
globalConstraintsRefs.add("admin-all");
globalConstraintsRefs.add("public-view");
pageSecurity.setGlobalSecurityConstraintsRefs(globalConstraintsRefs);
pageManager.updatePageSecurity(pageSecurity);
assertNotNull(pageSecurity.getParent());
assertEquals(pageSecurity.getParent().getId(), folder.getId());
assertNotNull(folder.getPageSecurity());
// test duplicate creates
try
{
Folder dupFolder = pageManager.newFolder("/");
pageManager.updateFolder(dupFolder);
assertTrue("Duplicate Folder / CREATED", false);
}
catch (FolderNotUpdatedException e)
{
}
try
{
Page dupPage = pageManager.newPage("/default-page.psml");
pageManager.updatePage(dupPage);
assertTrue("Duplicate Page / CREATED", false);
}
catch (PageNotUpdatedException e)
{
}
try
{
Link dupLink = pageManager.newLink("/default.link");
pageManager.updateLink(dupLink);
assertTrue("Duplicate Link / CREATED", false);
}
catch (FailedToUpdateDocumentException e)
{