use of org.opencastproject.security.api.JaxbGroup in project opencast by opencast.
the class GroupsListProvider method getList.
@Override
public Map<String, String> getList(String listName, ResourceListQuery query, Organization organization) {
Map<String, String> groupsList = new HashMap<String, String>();
List<JaxbGroup> groups = null;
int limit = 0;
int offset = 0;
if (query != null) {
if (query.getLimit().isSome())
limit = query.getLimit().get();
if (query.getOffset().isSome())
offset = query.getOffset().get();
}
try {
groups = groupRoleProvider.getGroupsAsJson(limit, offset).getGroups();
} catch (IOException e) {
logger.error("Not able to get the group list: " + e);
return groupsList;
}
for (JaxbGroup g : groups) {
if (NAME.equals(listName)) {
groupsList.put(g.getName(), g.getName());
} else if (DESCRIPTION.equals(listName)) {
groupsList.put(g.getDescription(), g.getDescription());
} else {
groupsList.put(g.getGroupId(), g.getName());
}
}
return groupsList;
}
use of org.opencastproject.security.api.JaxbGroup in project opencast by opencast.
the class GroupParsingTest method testUnmarshalUser.
@Test
public void testUnmarshalUser() throws Exception {
Set<JaxbRole> roles = new HashSet<JaxbRole>();
roles.add(new JaxbRole("ROLE_COURSE_ADMIN", ORGANIZATION));
roles.add(new JaxbRole("ROLE_USER", ORGANIZATION));
Set<String> members = new HashSet<String>();
members.add("admin1");
members.add("admin2");
JaxbGroup expectedGroup = new JaxbGroup("admin", ORGANIZATION, "Admin", "Admin group", roles, members);
StreamSource streamSource = new StreamSource(getClass().getResourceAsStream(GROUP_XML_FILE));
JaxbGroup group = jaxbContext.createUnmarshaller().unmarshal(streamSource, JaxbGroup.class).getValue();
assertEquals(expectedGroup.getGroupId(), group.getGroupId());
assertEquals(expectedGroup.getName(), group.getName());
assertEquals(expectedGroup.getDescription(), group.getDescription());
assertEquals(expectedGroup.getRole(), group.getRole());
assertEquals(expectedGroup.getOrganization(), group.getOrganization());
assertEquals(expectedGroup.getRoles(), group.getRoles());
assertEquals(expectedGroup.getMembers(), group.getMembers());
}
use of org.opencastproject.security.api.JaxbGroup in project opencast by opencast.
the class GroupParsingTest method testMarshalUser.
@Test
public void testMarshalUser() throws Exception {
StringWriter writer = new StringWriter();
StringWriter writer2 = new StringWriter();
Set<JaxbRole> roles = new HashSet<JaxbRole>();
roles.add(new JaxbRole("ROLE_COURSE_ADMIN", ORGANIZATION));
roles.add(new JaxbRole("ROLE_USER", ORGANIZATION));
Set<String> members = new HashSet<String>();
members.add("admin1");
members.add("admin2");
JaxbGroup group = new JaxbGroup("admin", ORGANIZATION, "Admin", "Admin group", roles, members);
jaxbContext.createMarshaller().marshal(group, writer);
String expectedOutput = IOUtils.toString(getClass().getResourceAsStream(GROUP_XML_FILE), "UTF-8");
StreamSource streamSource = new StreamSource(getClass().getResourceAsStream(GROUP_XML_FILE));
JaxbGroup groupFromFile = jaxbContext.createUnmarshaller().unmarshal(streamSource, JaxbGroup.class).getValue();
jaxbContext.createMarshaller().marshal(groupFromFile, writer2);
Diff diff = new Diff(writer2.toString(), writer.toString());
/* We don't care about ordering. */
diff.overrideElementQualifier(new ElementNameAndTextQualifier());
XMLAssert.assertXMLEqual(diff, true);
}
Aggregations