completed role permission setup
This commit is contained in:
@ -13,7 +13,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.ejb.EJB;
|
import javax.ejb.EJB;
|
||||||
import javax.enterprise.context.SessionScoped;
|
import javax.enterprise.context.SessionScoped;
|
||||||
import javax.inject.Named;
|
import javax.faces.bean.ManagedBean;
|
||||||
|
import javax.faces.bean.ManagedProperty;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -21,13 +22,15 @@ import org.slf4j.LoggerFactory;
|
|||||||
*
|
*
|
||||||
* @author jomu
|
* @author jomu
|
||||||
*/
|
*/
|
||||||
|
@ManagedBean(name = "accountView")
|
||||||
@SessionScoped
|
@SessionScoped
|
||||||
@Named
|
|
||||||
public class AccountView implements Serializable {
|
public class AccountView implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = -8050582392249849438L;
|
private static final long serialVersionUID = -8050582392249849438L;
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(AccountView.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(AccountView.class);
|
||||||
|
|
||||||
|
@ManagedProperty(value = "#{applicationView}")
|
||||||
|
private ApplicationView applicationView;
|
||||||
@EJB
|
@EJB
|
||||||
private AccountControl accountService;
|
private AccountControl accountService;
|
||||||
@EJB
|
@EJB
|
||||||
@ -57,8 +60,9 @@ public class AccountView implements Serializable {
|
|||||||
return accountList;
|
return accountList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ApplicationRoleEntity> getAllApplicationRoles(ApplicationEntity application) {
|
public List<ApplicationRoleEntity> getAllApplicationRoles() {
|
||||||
if (applicationRoles == null) {
|
if (applicationRoles == null) {
|
||||||
|
ApplicationEntity application = applicationView.getCurrentApplication();
|
||||||
applicationRoles = appliationRoleService.getAllRoles(application);
|
applicationRoles = appliationRoleService.getAllRoles(application);
|
||||||
}
|
}
|
||||||
return applicationRoles;
|
return applicationRoles;
|
||||||
@ -146,6 +150,15 @@ public class AccountView implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* **** getter / setter **** */
|
/* **** getter / setter **** */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* setter for managed property applicationView
|
||||||
|
* @param applicationView the applicaton view to inject
|
||||||
|
*/
|
||||||
|
public void setApplicationView(ApplicationView applicationView) {
|
||||||
|
this.applicationView = applicationView;
|
||||||
|
}
|
||||||
|
|
||||||
public AccountEntity getCurrentAccount() {
|
public AccountEntity getCurrentAccount() {
|
||||||
return currentAccount;
|
return currentAccount;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,9 +27,9 @@ public class ApplicationView implements Serializable {
|
|||||||
ApplicationService applicationService;
|
ApplicationService applicationService;
|
||||||
|
|
||||||
private ApplicationEntity currentApplication = null;
|
private ApplicationEntity currentApplication = null;
|
||||||
private List<ApplicationEntity> applicationList = null;
|
|
||||||
private ApplicationEntity editApplication = null;
|
private ApplicationEntity editApplication = null;
|
||||||
|
private List<ApplicationEntity> applicationList = null;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void selectDefaultCurrentApplication() {
|
public void selectDefaultCurrentApplication() {
|
||||||
// force applications to be loaded from database
|
// force applications to be loaded from database
|
||||||
|
|||||||
@ -25,9 +25,9 @@ import java.io.Serializable;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.ejb.EJB;
|
import javax.ejb.EJB;
|
||||||
import javax.enterprise.context.SessionScoped;
|
|
||||||
import javax.faces.bean.ManagedBean;
|
import javax.faces.bean.ManagedBean;
|
||||||
import javax.faces.bean.ManagedProperty;
|
import javax.faces.bean.ManagedProperty;
|
||||||
|
import javax.faces.bean.SessionScoped;
|
||||||
import org.primefaces.event.SelectEvent;
|
import org.primefaces.event.SelectEvent;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -57,6 +57,10 @@ public class RoleView implements Serializable {
|
|||||||
private ApplicationPermissionEntity currentPermission;
|
private ApplicationPermissionEntity currentPermission;
|
||||||
private ApplicationPermissionEntity newPermission;
|
private ApplicationPermissionEntity newPermission;
|
||||||
|
|
||||||
|
public ApplicationEntity getCurrentApplication() {
|
||||||
|
return applicationView.getCurrentApplication();
|
||||||
|
}
|
||||||
|
|
||||||
public List<ApplicationRoleEntity> getAllRoles() {
|
public List<ApplicationRoleEntity> getAllRoles() {
|
||||||
if (allRoles == null) {
|
if (allRoles == null) {
|
||||||
allRoles = applicationRoleControl.getAllRoles(applicationView.getCurrentApplication());
|
allRoles = applicationRoleControl.getAllRoles(applicationView.getCurrentApplication());
|
||||||
@ -66,6 +70,10 @@ public class RoleView implements Serializable {
|
|||||||
|
|
||||||
public void startNewRole() {
|
public void startNewRole() {
|
||||||
this.currentRole = new ApplicationRoleEntity(applicationView.getCurrentApplication());
|
this.currentRole = new ApplicationRoleEntity(applicationView.getCurrentApplication());
|
||||||
|
if (LOGGER.isDebugEnabled()) {
|
||||||
|
LOGGER.debug("Created new current role: {}", currentRole.toString());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelEditRole() {
|
public void cancelEditRole() {
|
||||||
@ -80,7 +88,7 @@ public class RoleView implements Serializable {
|
|||||||
allRoles = null; // force reload
|
allRoles = null; // force reload
|
||||||
FacesUtil.addGlobalInfoMessage("Info", "Role " + currentRole.getRoleName() + " created");
|
FacesUtil.addGlobalInfoMessage("Info", "Role " + currentRole.getRoleName() + " created");
|
||||||
} else {
|
} else {
|
||||||
applicationRoleControl.create(currentRole);
|
applicationRoleControl.update(currentRole);
|
||||||
allRoles = null; // force reload
|
allRoles = null; // force reload
|
||||||
FacesUtil.addGlobalInfoMessage("Info", "Role " + currentRole.getRoleName() + " updated");
|
FacesUtil.addGlobalInfoMessage("Info", "Role " + currentRole.getRoleName() + " updated");
|
||||||
}
|
}
|
||||||
@ -106,10 +114,18 @@ public class RoleView implements Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getRoleSelected() {
|
||||||
|
return currentRole != null;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean getPermissionSelected() {
|
public boolean getPermissionSelected() {
|
||||||
return currentPermission != null;
|
return currentPermission != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getMissingPermissionAvailable() {
|
||||||
|
return ((missingApplicationsPermissions != null) && (!missingApplicationsPermissions.isEmpty()));
|
||||||
|
}
|
||||||
|
|
||||||
public void onRoleSelect(SelectEvent event) {
|
public void onRoleSelect(SelectEvent event) {
|
||||||
currentRolePermissions = null;
|
currentRolePermissions = null;
|
||||||
currentRolePermissions = getRolePermissions();
|
currentRolePermissions = getRolePermissions();
|
||||||
@ -192,14 +208,6 @@ public class RoleView implements Serializable {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void selectPermission() {
|
|
||||||
// this.isPermissionSelected = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void deselectPermission() {
|
|
||||||
// this.isPermissionSelected = false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/* *** getter / setter *** */
|
/* *** getter / setter *** */
|
||||||
public void setApplicationView(ApplicationView applicationView) {
|
public void setApplicationView(ApplicationView applicationView) {
|
||||||
this.applicationView = applicationView;
|
this.applicationView = applicationView;
|
||||||
|
|||||||
@ -0,0 +1,60 @@
|
|||||||
|
package de.muehlencord.shared.account.web.presentation;
|
||||||
|
|
||||||
|
import de.muehlencord.shared.account.business.account.boundary.ApplicationPermissionControl;
|
||||||
|
import de.muehlencord.shared.account.business.account.boundary.ApplicationRoleControl;
|
||||||
|
import de.muehlencord.shared.account.business.account.entity.ApplicationPermissionEntity;
|
||||||
|
import de.muehlencord.shared.account.business.account.entity.ApplicationRoleEntity;
|
||||||
|
import de.muehlencord.shared.account.business.application.entity.ApplicationEntity;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import javax.ejb.EJB;
|
||||||
|
import javax.faces.application.FacesMessage;
|
||||||
|
import javax.faces.component.UIComponent;
|
||||||
|
import javax.faces.context.FacesContext;
|
||||||
|
import javax.faces.validator.FacesValidator;
|
||||||
|
import javax.faces.validator.Validator;
|
||||||
|
import javax.faces.validator.ValidatorException;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Joern Muehlencord <joern at muehlencord.de>
|
||||||
|
*/
|
||||||
|
@FacesValidator("uniqueApplicationRoleNameValidator")
|
||||||
|
public class UniqueApplicationRoleNameValidator implements Validator, Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 8165013107453616719L;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
EntityManager em;
|
||||||
|
|
||||||
|
@EJB
|
||||||
|
ApplicationRoleControl applicationRoleControl;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
|
||||||
|
Object applicationObj = component.getAttributes().get("application");
|
||||||
|
if ((applicationObj != null) && (applicationObj instanceof ApplicationEntity)) {
|
||||||
|
ApplicationEntity application = (ApplicationEntity) applicationObj;
|
||||||
|
if (value == null) {
|
||||||
|
throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Role name invalid", "Role name must not be empty"));
|
||||||
|
}
|
||||||
|
if (value instanceof String) {
|
||||||
|
String roleName = (String) value;
|
||||||
|
ApplicationRoleEntity existingRole = applicationRoleControl.findByName(application, roleName);
|
||||||
|
if (existingRole != null) {
|
||||||
|
throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Role name invalid", "Role already exists"));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Role name invalid", "Role name must be a string value"));
|
||||||
|
// TODO add IPRS logger - someone is trying to cheat
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Application not set", "Permission name cannot be set if application is unknown"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -52,4 +52,5 @@ roles.unauthorizedUrl = /error/accessDenied.xhtml
|
|||||||
/javax.faces.resource/**=anon
|
/javax.faces.resource/**=anon
|
||||||
/login.xhtml=authc
|
/login.xhtml=authc
|
||||||
/logout.xhtml=logout
|
/logout.xhtml=logout
|
||||||
/web/**=authc
|
/**=authc
|
||||||
|
# /web/**=authc
|
||||||
|
|||||||
@ -68,7 +68,6 @@
|
|||||||
<span class="ui-inputgroup-addon"><i style="font-size: 20px" class="fa fa-edit"></i></span>
|
<span class="ui-inputgroup-addon"><i style="font-size: 20px" class="fa fa-edit"></i></span>
|
||||||
<p:inputText id="newName" value="#{permissionView.currentPermission.permissionName}" maxlength="80" size="30" placeholder="#{msgs.label_name}" >
|
<p:inputText id="newName" value="#{permissionView.currentPermission.permissionName}" maxlength="80" size="30" placeholder="#{msgs.label_name}" >
|
||||||
<f:validator validatorId="uniquePermissionNameValidator"/>
|
<f:validator validatorId="uniquePermissionNameValidator"/>
|
||||||
<!--<f:attribute name="permissionName" value="#{permissionView.currentPermission.permissionName}" />-->
|
|
||||||
<f:attribute name="application" value="#{permissionView.currentApplication}" />
|
<f:attribute name="application" value="#{permissionView.currentApplication}" />
|
||||||
</p:inputText>
|
</p:inputText>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -20,7 +20,9 @@
|
|||||||
<h:form id="roleForm">
|
<h:form id="roleForm">
|
||||||
<p:dataTable id="roleTable" value="#{roleView.allRoles}" var="role" rowKey="#{role.id}" styleClass="box-primary"
|
<p:dataTable id="roleTable" value="#{roleView.allRoles}" var="role" rowKey="#{role.id}" styleClass="box-primary"
|
||||||
selectionMode="single" selection="#{roleView.currentRole}">
|
selectionMode="single" selection="#{roleView.currentRole}">
|
||||||
<!--<p:ajax event="rowSelect" update="roleForm:permissionTable:addPermissionButton,:roleForm:permissionTable:deletePermissionButton" listener="#{roleView.onRoleSelect}" />-->
|
<p:ajax event="rowSelect" update=":roleForm:permissionTable, editRoleButton, deleteRoleButton" listener="#{roleView.onRoleSelect}"/>
|
||||||
|
<p:ajax event="rowUnselect" update=":roleForm:permissionTable, editRoleButton, deleteRoleButton" />
|
||||||
|
|
||||||
<p:column headerText="Role name">
|
<p:column headerText="Role name">
|
||||||
<h:outputText value="#{role.roleName}" />
|
<h:outputText value="#{role.roleName}" />
|
||||||
</p:column>
|
</p:column>
|
||||||
@ -36,11 +38,12 @@
|
|||||||
update="editDialog" oncomplete="PF('editDialogVar').show();" styleClass="btn-primary btn-block"/>
|
update="editDialog" oncomplete="PF('editDialogVar').show();" styleClass="btn-primary btn-block"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-12 col-md-2" style="margin-top:10px">
|
<div class="col-sm-12 col-md-2" style="margin-top:10px">
|
||||||
<p:commandButton id="editRoleButton" icon="fa fa-pencil" value="#{msgs.button_edit}"
|
<p:commandButton id="editRoleButton" icon="fa fa-pencil" value="#{msgs.button_edit}" disabled="#{!roleView.roleSelected}"
|
||||||
update="editDialog" oncomplete="PF('editDialogVar').show();" styleClass="btn-teal btn-block"/>
|
update="editDialog" oncomplete="PF('editDialogVar').show();" styleClass="btn-teal btn-block"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-12 col-md-2" style="margin-top:10px">
|
<div class="col-sm-12 col-md-2" style="margin-top:10px">
|
||||||
<p:commandButton id="deleteRoleButton" icon="fa fa-trash-o" value="#{msgs.button_delete}" action="#{roleView.deleteRole}" update="roleTable" styleClass="btn-danger btn-block">
|
<p:commandButton id="deleteRoleButton" icon="fa fa-trash-o" value="#{msgs.button_delete}" disabled="#{!roleView.roleSelected}"
|
||||||
|
action="#{roleView.deleteRole}" update=":roleForm:roleTable" styleClass="btn-danger btn-block">
|
||||||
<p:confirm header="Confirmation" message="Are you sure?" icon="fa fa-exclamation-triangle" />
|
<p:confirm header="Confirmation" message="Are you sure?" icon="fa fa-exclamation-triangle" />
|
||||||
</p:commandButton>
|
</p:commandButton>
|
||||||
</div>
|
</div>
|
||||||
@ -62,12 +65,12 @@
|
|||||||
<h:outputText value="#{permission.permissionDescription}" />
|
<h:outputText value="#{permission.permissionDescription}" />
|
||||||
</p:column>
|
</p:column>
|
||||||
<f:facet name="footer" >
|
<f:facet name="footer" >
|
||||||
<p:selectOneMenu value="#{roleView.newPermission}" converter="omnifaces.SelectItemsConverter" >
|
<p:selectOneMenu value="#{roleView.newPermission}" converter="omnifaces.SelectItemsConverter" >
|
||||||
<f:selectItems id="permissionListItems" value="#{roleView.missingPermissions}" var="missingPermission" itemLabel="#{missingPermission.permissionName}" itemValue="#{missingPermission}" />
|
<f:selectItems id="permissionListItems" value="#{roleView.missingPermissions}" var="missingPermission" itemLabel="#{missingPermission.permissionName}" itemValue="#{missingPermission}" />
|
||||||
</p:selectOneMenu>
|
</p:selectOneMenu>
|
||||||
<div class="ui-g-12 ui-md-2">
|
<div class="ui-g-12 ui-md-2">
|
||||||
<p:commandButton id="addPermissionButton" icon="fa fa-plus" value="#{msgs.button_add}" action="#{roleView.addRolePermission}"
|
<p:commandButton id="addPermissionButton" icon="fa fa-plus" value="#{msgs.button_add}" action="#{roleView.addRolePermission}"
|
||||||
update=":roleForm:permissionTable" styleClass="btn-primary btn-block" disabled="#"/>
|
update="permissionTable" styleClass="btn-primary btn-block" disabled="#{!roleView.missingPermissionAvailable}" />
|
||||||
</div>
|
</div>
|
||||||
<div class="ui-g-12 ui-md-2">
|
<div class="ui-g-12 ui-md-2">
|
||||||
<p:commandButton id="deletePermissionButton" icon="fa fa-trash-o" value="#{msgs.button_delete}" update=":roleForm:permissionTable"
|
<p:commandButton id="deletePermissionButton" icon="fa fa-trash-o" value="#{msgs.button_delete}" update=":roleForm:permissionTable"
|
||||||
@ -95,34 +98,37 @@
|
|||||||
<p:outputLabel for="newName" value="Role name" />
|
<p:outputLabel for="newName" value="Role name" />
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-12 col-md-6">
|
<div class="col-sm-12 col-md-6">
|
||||||
<p:inputText id="newName" value="#{roleView.currentRole.roleName}" placeholder="#{msgs.label_name}" maxlength="80" size="30" />
|
<p:inputText id="newName" value="#{roleView.currentRole.roleName}" placeholder="#{msgs.label_name}" maxlength="80" size="40">
|
||||||
</div>
|
<f:validator validatorId="uniqueApplicationRoleNameValidator"/>
|
||||||
<div class="col-sm-12 col-md-3">
|
<f:attribute name="application" value="#{roleView.currentApplication}" />
|
||||||
<p:message for="newName"><p:autoUpdate /></p:message>
|
</p:inputText>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-12 col-md-3">
|
<div class="col-sm-12 col-md-3">
|
||||||
<p:outputLabel for="newDescription" value="Description" />
|
<p:message for="newName"><p:autoUpdate /></p:message>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-12 col-md-6">
|
<div class="col-sm-12 col-md-3">
|
||||||
<p:inputText id="newDescription" value="#{roleView.currentRole.roleDescription}" placeholder="#{msgs.label_description}" maxlength="200" size="40" />
|
<p:outputLabel for="newDescription" value="Description" />
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-12 col-md-3">
|
<div class="col-sm-12 col-md-6">
|
||||||
<p:message for="newDescription"><p:autoUpdate /></p:message>
|
<p:inputText id="newDescription" value="#{roleView.currentRole.roleDescription}" placeholder="#{msgs.label_description}" maxlength="200" size="40" />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-sm-12 col-md-3">
|
||||||
|
<p:message for="newDescription"><p:autoUpdate /></p:message>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="col-sm-12 col-md-6">
|
<div class="col-sm-12 col-md-6">
|
||||||
<p:spacer height="10px" />
|
<p:spacer height="10px" />
|
||||||
<p:commandButton value="Save" action="#{roleView.saveEditRole}" styleClass="btn-primary btn-block"
|
<p:commandButton value="Save" action="#{roleView.saveEditRole}" styleClass="btn-primary btn-block"
|
||||||
oncomplete="if (args && !args.validationFailed) PF('editDialogVar').hide();" update=":roleForm:roleTable" />
|
oncomplete="if (args && !args.validationFailed) PF('editDialogVar').hide();" update=":roleForm:roleTable" />
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-12 col-md-6">
|
||||||
|
<p:spacer height="10px" />
|
||||||
|
<p:commandButton value="Cancel" action="#{roleView.cancelEditRole}" immediate="true" styleClass="btn-teal btn-block"
|
||||||
|
oncomplete="PF('editDialogVar').hide();" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-12 col-md-6">
|
</h:form>
|
||||||
<p:spacer height="10px" />
|
</p:dialog>
|
||||||
<p:commandButton value="Cancel" action="#{roleView.cancelEditRole}" immediate="true" styleClass="btn-teal btn-block"
|
</ui:define>
|
||||||
oncomplete="PF('editDialogVar').hide();" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</h:form>
|
|
||||||
</p:dialog>
|
|
||||||
</ui:define>
|
|
||||||
|
|
||||||
</ui:composition>
|
</ui:composition>
|
||||||
|
|||||||
@ -52,7 +52,7 @@ public class ApplicationRoleControl implements Serializable {
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void createOrUpdate(ApplicationEntity application, String name, String description) {
|
public void createOrUpdate(ApplicationEntity application, String name, String description) {
|
||||||
ApplicationRoleEntity role = findByName(name);
|
ApplicationRoleEntity role = findByName(application, name);
|
||||||
if (role == null) {
|
if (role == null) {
|
||||||
role = new ApplicationRoleEntity(application, name, description);
|
role = new ApplicationRoleEntity(application, name, description);
|
||||||
em.persist(role);
|
em.persist(role);
|
||||||
@ -85,8 +85,9 @@ public class ApplicationRoleControl implements Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ApplicationRoleEntity findByName(String name) {
|
public ApplicationRoleEntity findByName(ApplicationEntity application, String name) {
|
||||||
Query query = em.createNamedQuery("ApplicationRoleEntity.findByRoleName");
|
Query query = em.createNamedQuery("ApplicationRoleEntity.findByRoleName");
|
||||||
|
query.setParameter("application", application);
|
||||||
query.setParameter("roleName", name);
|
query.setParameter("roleName", name);
|
||||||
List<ApplicationRoleEntity> permissions = query.getResultList();
|
List<ApplicationRoleEntity> permissions = query.getResultList();
|
||||||
if ((permissions == null) || (permissions.isEmpty())) {
|
if ((permissions == null) || (permissions.isEmpty())) {
|
||||||
|
|||||||
@ -74,8 +74,8 @@ public class ApplicationRoleEntity implements Serializable {
|
|||||||
public ApplicationRoleEntity(ApplicationEntity application) {
|
public ApplicationRoleEntity(ApplicationEntity application) {
|
||||||
this.id = null;
|
this.id = null;
|
||||||
this.application = application;
|
this.application = application;
|
||||||
this.roleName = null;
|
this.roleName = "";
|
||||||
this.roleDescription = null;
|
this.roleDescription = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApplicationRoleEntity(ApplicationEntity application, String roleName, String roleDescription) {
|
public ApplicationRoleEntity(ApplicationEntity application, String roleName, String roleDescription) {
|
||||||
|
|||||||
Reference in New Issue
Block a user