Line 1: |
|
|
+ |
This report will show who has access to what in the system. This report has to be used in conjunction with a report template such as the [[Bar Chart Template]].
|
|
|
|
|
|
|
+ |
----
|
|
|
|
|
|
|
+ |
''Meta-Data Script:''
|
|
|
|
|
|
|
+ |
<pre>import com.urbancode.anthill3.domain.reporting.*;
|
|
|
+ |
import com.urbancode.anthill3.domain.security.*;
|
|
|
|
|
|
|
+ |
rmd = new ReportMetaData();
|
|
|
|
|
|
|
+ |
rmd.addColumn("Resource Type");
|
|
|
+ |
rmd.addColumn("Resource Name");
|
|
|
+ |
rmd.addColumn("Permission");
|
|
|
|
|
|
|
+ |
pmd = new SelectParamMetaData();
|
|
|
+ |
pmd.setLabel("User");
|
|
|
+ |
pmd.setName("userName");
|
|
|
+ |
pmd.setDescription("Select the user to report the permissions of.");
|
|
|
+ |
pmd.setRequired(true);
|
|
|
|
|
|
|
+ |
users = UserFactory.getInstance().restoreAll();
|
|
|
+ |
userNames = new String[users.length];
|
|
|
+ |
for (int u=0; u<users.length; u++) {
|
|
|
+ |
userNames[u] = users[u].getName();
|
|
|
+ |
}
|
|
|
+ |
pmd.setLabels(userNames);
|
|
|
+ |
pmd.setValues(userNames);
|
|
|
|
|
|
|
+ |
rmd.addParameter(pmd);
|
|
|
|
|
|
|
+ |
return rmd;</pre>
|
|
|
|
|
|
|
+ |
----
|
|
|
|
|
|
|
+ |
''Context Script:''
|
|
|
|
|
|
|
+ |
<pre>import com.urbancode.anthill3.domain.reporting.*;
|
|
|
+ |
import com.urbancode.anthill3.domain.security.*;
|
|
|
+ |
import java.util.*;
|
|
|
|
|
|
|
+ |
output = new ReportOutput(metaData);
|
|
|
|
|
|
|
+ |
user = UserFactory.getInstance().restoreForName(userName);
|
|
|
+ |
roles = RoleFactory.getInstance().restoreAllForUser(user);
|
|
|
+ |
permissions = PermissionFactory.getInstance().restoreAll();
|
|
|
|
|
|
|
+ |
comparator = new Comparator() {
|
|
|
+ |
public int compare(Object o1, Object o2) {
|
|
|
+ |
p1 = (Permission) o1;
|
|
|
+ |
p2 = (Permission) o2;
|
|
|
+ |
int result = p1.getResource().getResourceType().getName().compareTo(p2.getResource().getResourceType().getName());
|
|
|
+ |
if (result == 0) {
|
|
|
+ |
result = p1.getResource().getName().compareTo(p2.getResource().getName());
|
|
|
+ |
if (result == 0) {
|
|
|
+ |
result = p1.getAction().compareTo(p2.getAction());
|
|
|
+ |
}
|
|
|
+ |
}
|
|
|
+ |
return result;
|
|
|
+ |
}
|
|
|
+ |
};
|
|
|
|
|
|
|
+ |
rolePermissions = new ArrayList();
|
|
|
|
|
|
|
+ |
for (int p=0; p<permissions.length; p++) {
|
|
|
+ |
for (int r=0; r<roles.length; r++) {
|
|
|
+ |
if (roles[r].equals(permissions[p].getRole())) {
|
|
|
+ |
rolePermissions.add(permissions[p]);
|
|
|
+ |
}
|
|
|
+ |
}
|
|
|
+ |
}
|
|
|
|
|
|
|
+ |
Collections.sort(rolePermissions, comparator);
|
|
|
|
|
|
|
+ |
for (int p=0; p<rolePermissions.size(); p++) {
|
|
|
+ |
permission = rolePermissions.get(p);
|
|
|
+ |
row = new ReportRow(output, String.valueOf(p));
|
|
|
+ |
row.setColumnValue("Resource Type", permission.getResource().getResourceType().getName());
|
|
|
+ |
row.setColumnValue("Resource Name", permission.getResource().getName());
|
|
|
+ |
row.setColumnValue("Permission", permission.getAction());
|
|
|
+ |
output.addRow(row);
|
|
|
+ |
}
|
|
|
|
|
|
|
+ |
return output;</pre>
|
|
|
|
|
|
|
+ |
----
|
|
|
|
|
|
|
+ |
'''Related Content'''
|
|
|
|
|
|
|
+ |
[[AnthillPro Template Reports]]<br/>
|
|
|
+ |
[[Report Templates]]
|