Skip to content

Commit

Permalink
#2657 Add applicable dvObject Types to permissions confirmation popup
Browse files Browse the repository at this point in the history
  • Loading branch information
sekmiller committed Mar 4, 2016
1 parent 25baf5c commit 6e7a55a
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
49 changes: 49 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/ManagePermissionsPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import edu.harvard.iq.dataverse.authorization.AuthenticationServiceBean;
import edu.harvard.iq.dataverse.authorization.DataverseRole;
import edu.harvard.iq.dataverse.authorization.DataverseRolePermissionHelper;
import edu.harvard.iq.dataverse.authorization.Permission;
import edu.harvard.iq.dataverse.authorization.RoleAssignee;
import edu.harvard.iq.dataverse.authorization.RoleAssigneeDisplayInfo;
Expand Down Expand Up @@ -77,6 +78,9 @@ public class ManagePermissionsPage implements java.io.Serializable {

@Inject
DataverseSession session;

private DataverseRolePermissionHelper dataverseRolePermissionHelper;
private List<DataverseRole> roleList;

DvObject dvObject = new Dataverse(); // by default we use a Dataverse, but this will be overridden in init by the findById

Expand Down Expand Up @@ -112,6 +116,8 @@ public String init() {
if (dvObject instanceof Dataverse) {
initAccessSettings();
}
roleList = roleService.findAll();
dataverseRolePermissionHelper = new DataverseRolePermissionHelper(roleList);
return "";
}

Expand Down Expand Up @@ -379,6 +385,40 @@ public DataverseRole getAssignedRole() {
}
return null;
}

public String getAssignedRoleObjectTypes(){
String retString = "";
if (selectedRoleId != null) {
if (dataverseRolePermissionHelper.hasDataversePermissions(selectedRoleId)){
retString = "Dataverses";
}
if (dataverseRolePermissionHelper.hasDatasetPermissions(selectedRoleId)){
if(!retString.isEmpty()) {
retString +=", Datasets";
} else {
retString = "Datasets";
}

}
if (dataverseRolePermissionHelper.hasFilePermissions(selectedRoleId)){
if(!retString.isEmpty()) {
retString +=", Data Files";
} else {
retString = "Data Files";
}
}
return retString;
}
return null;
}

public String getDefinitionLevelString(){
if (dvObject != null){
if (dvObject instanceof Dataverse) return "Dataverse";
if (dvObject instanceof Dataset) return "Dataset";
}
return null;
}

public void assignRole(ActionEvent evt) {
logger.info("Got to assignRole");
Expand Down Expand Up @@ -487,6 +527,15 @@ public void updateRole(ActionEvent e) {
}
showRoleMessages();
}


public DataverseRolePermissionHelper getDataverseRolePermissionHelper() {
return dataverseRolePermissionHelper;
}

public void setDataverseRolePermissionHelper(DataverseRolePermissionHelper dataverseRolePermissionHelper) {
this.dataverseRolePermissionHelper = dataverseRolePermissionHelper;
}

/*
============================================================================
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/roles-assign.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
<span class="glyphicon glyphicon-warning-sign text-danger"/>
<h:outputFormat styleClass="text-danger" value=" #{bundle['dataverse.permissions.usersOrGroups.assignDialog.role.warning']}">
<f:param value="#{managePermissionsPage.assignedRole.name}"/>
<f:param value="{object types}"/>
<f:param value="{object type}"/>
<f:param value="#{managePermissionsPage.assignedRoleObjectTypes}"/>
<f:param value="#{managePermissionsPage.definitionLevelString}"/>
</h:outputFormat>
</p>
</div>
Expand Down

0 comments on commit 6e7a55a

Please sign in to comment.