use of net.sourceforge.processdash.tool.perm.Permission in project processdash by dtuma.
the class RolesReport method writeContents.
@Override
protected void writeContents() throws IOException {
String title = resources.getHTML("RolesReport.Title");
out.println("<html><head>");
out.println("<title>" + title + "</title>");
out.println("<style>");
out.println(" h2 { margin-bottom: 0px }");
out.println(" ul { margin-top: 0px }");
out.println("</style>");
out.println("</head><body>");
out.println("<h1>" + title + "</h1>");
out.println(resources.getHTML("RolesReport.Header"));
for (Role r : PermissionsManager.getInstance().getAllRoles()) {
// print the name of the role as a heading
out.print("<h2>");
out.print(HTMLUtils.escapeEntities(r.getName()));
out.println("</h2>");
// print a list of the permissions in the role
out.println("<ul>");
boolean sawItem = false;
for (Permission p : r.getPermissions()) {
if (!p.isInactive()) {
printPermissionItem(p);
sawItem = true;
}
}
// if no permissions were found, print a "no permission" bullet
if (!sawItem)
out.print("<li><i>" + resources.getHTML("No_Permission") + "</i></li>");
out.println("</ul>");
}
out.println("</body></html>");
}
use of net.sourceforge.processdash.tool.perm.Permission in project processdash by dtuma.
the class WbsPermissionSettingsWriter method writeRoleSettings.
private void writeRoleSettings(XmlSerializer xml, Role r, List<User> allUsers, Set<String> usersToWrite) throws IOException {
// get a list of the active permissions that are assigned to this role
User prototypeUser = new User(null, null, false, Collections.singletonList(r.getId()));
Set<Permission> perms = PermissionsManager.getInstance().getPermissionsForUser(prototypeUser, true);
// filter the list to contain only wbs-specific permissions
for (Iterator i = perms.iterator(); i.hasNext(); ) {
Permission p = (Permission) i.next();
if (!wbsPermissionIDs.contains(p.getSpec().getId()))
i.remove();
}
// the WBS Editor doesn't need to know about it.
if (perms.isEmpty())
return;
// find the users who are assigned to this permission
List<String> userIDs = new ArrayList<String>();
for (User u : allUsers) {
if (u.getRoleIDs().contains(r.getId()))
userIDs.add(u.getUsername());
}
// doesn't need to know about it.
if (userIDs.isEmpty())
return;
// write XML data for this role
xml.startTag(null, ROLE_TAG);
xml.attribute(null, NAME_ATTR, r.getName());
xml.attribute(null, ID_ATTR, r.getId());
// write the list of users, as a comma-separated attribute
xml.attribute(null, USERS_ATTR, StringUtils.join(userIDs, ","));
usersToWrite.removeAll(userIDs);
// write the permissions granted by this role
for (Permission p : perms) PermissionsManager.writePermission(xml, p);
// end the role tag
xml.endTag(null, ROLE_TAG);
}
use of net.sourceforge.processdash.tool.perm.Permission in project processdash by dtuma.
the class GroupPermission method getGrantedMembers.
/**
* Find all the group permissions with the given ID that have been granted
* to the current user, and return a set of dataset IDs for the groups in
* question.
*
* @param permissionID
* the ID of a group permission
* @return null if the user does not have this permission; the EVERYONE
* group if the user has been granted it; otherwise, a set of
* dataset IDs representing the combined set of people in all the
* granted groups
*/
public static UserFilter getGrantedMembers(String permissionID) {
// in personal mode, return "everyone" to indicate all permissions
if (Settings.isTeamMode() == false)
return UserGroup.EVERYONE;
// find all the granted permissions
Set<Permission> perms = PermissionsManager.getInstance().getCurrentPermissions(permissionID);
if (perms.isEmpty())
return null;
// collect the dataset IDs from all the granted groups
MemberSet result = new MemberSet(permissionID);
for (Permission onePerm : perms) {
if (onePerm instanceof GroupPermission) {
UserGroup oneGroup = ((GroupPermission) onePerm).getGroup();
if (UserGroup.isEveryone(oneGroup))
return UserGroup.EVERYONE;
else if (oneGroup != null)
result.addAll(oneGroup.getDatasetIDs());
}
}
result.remove(null);
result.remove("");
return result;
}
Aggregations