private static EObject loadRoleInstance(final IRoleInstanceMetaInfo roleInst, final IUser user, final SecurityModel securityModel) throws InconsistentModelException {
Role role = findRole(securityModel, roleInst.getRoleId());
if (role == null) {
role = createRole(securityModel, roleInst);
}
final EFactory securityFactory = securityModel.getEFactoryInstance();
final EObject roInstance = securityFactory.create(role);
final Set<IPermissionInstanceMetaInfo> permissionInstances = roleInst.getPermissionInstances();
for (final IPermissionInstanceMetaInfo instance : permissionInstances) {
final Permission permission = findPermission(securityModel, instance.getPermissionId());
if (permission == null) {
throw new InconsistentModelException("Inconsistent model. Permission " + instance.getPermissionId() //$NON-NLS-1$
+ " is not found. It can be caused by model upgrade on the server. Restart application to load new model."); //$NON-NLS-1$
}
final EReference permissionRef = EMFUtil.getPermission(role, permission);
final EObject permissionInstance = securityFactory.create(permission);
roInstance.eSet(permissionRef, permissionInstance);
final Set<IPermissionParameter> parameters = instance.getPermissionParameters();
for (final IPermissionParameter parameter : parameters) {
final EAttribute attr = findAttribute(permission, parameter.getAttributeName());
if (attr == null) {