{
}
// create test documents and folders
Folder folder = pageManager.newFolder("/");
SecurityConstraints constraints = pageManager.newSecurityConstraints();
constraints.setOwner("admin");
List constraintsRefs = new ArrayList(1);
constraintsRefs.add("public-view");
constraints.setSecurityConstraintsRefs(constraintsRefs);
folder.setSecurityConstraints(constraints);
pageManager.updateFolder(folder);
PageSecurity pageSecurity = pageManager.newPageSecurity();
List constraintsDefs = new ArrayList(2);
SecurityConstraintsDef constraintsDef = pageManager.newSecurityConstraintsDef();
constraintsDef.setName("public-view");
List defConstraints = new ArrayList(1);
SecurityConstraint defConstraint = pageManager.newPageSecuritySecurityConstraint();
defConstraint.setUsers(Shared.makeListFromCSV("*"));
defConstraint.setPermissions(Shared.makeListFromCSV("view"));
defConstraints.add(defConstraint);
constraintsDef.setSecurityConstraints(defConstraints);
constraintsDefs.add(constraintsDef);
constraintsDef = pageManager.newSecurityConstraintsDef();
constraintsDef.setName("admin-all");
defConstraints = new ArrayList(1);
defConstraint = pageManager.newPageSecuritySecurityConstraint();
defConstraint.setRoles(Shared.makeListFromCSV("admin"));
defConstraint.setPermissions(Shared.makeListFromCSV("view,edit"));
defConstraints.add(defConstraint);
constraintsDef.setSecurityConstraints(defConstraints);
constraintsDefs.add(constraintsDef);
pageSecurity.setSecurityConstraintsDefs(constraintsDefs);
List globalConstraintsRefs = new ArrayList(1);
globalConstraintsRefs.add("admin-all");
pageSecurity.setGlobalSecurityConstraintsRefs(globalConstraintsRefs);
pageManager.updatePageSecurity(pageSecurity);
Page page = pageManager.newPage("/default-page.psml");
constraints = pageManager.newSecurityConstraints();
constraints.setOwner("admin");
List inlineConstraints = new ArrayList(1);
SecurityConstraint constraint = pageManager.newPageSecurityConstraint();
constraint.setRoles(Shared.makeListFromCSV("manager"));
constraint.setPermissions(Shared.makeListFromCSV("edit"));
inlineConstraints.add(constraint);
constraints.setSecurityConstraints(inlineConstraints);
constraintsRefs = new ArrayList(1);
constraintsRefs.add("public-view");
constraints.setSecurityConstraintsRefs(constraintsRefs);
page.setSecurityConstraints(constraints);
Fragment root = page.getRootFragment();
root.setName("jetspeed-layouts::VelocityTwoColumns");
Fragment portlet = pageManager.newPortletFragment();
portlet.setName("security::LoginPortlet");
root.getFragments().add(portlet);
portlet = pageManager.newPortletFragment();
portlet.setName("some-app::SomePortlet");
SecurityConstraints fragmentConstraints = pageManager.newSecurityConstraints();
fragmentConstraints.setOwner("user");
portlet.setSecurityConstraints(fragmentConstraints);
root.getFragments().add(portlet);
pageManager.updatePage(page);
TestCase.assertNotNull(page.getRootFragment());
TestCase.assertNotNull(page.getRootFragment().getFragments());