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) {
throw new InconsistentModelException(MessageFormat.format("Inconsistent model. Attribute {0} of {1} permission is not found. It can be caused by model upgrade on the server. Restart application to load new model.", //$NON-NLS-1$
instance.getPermissionId(), parameter.getAttributeName()));
}
final String isUser = EcoreUtil.getAnnotation(attr, UamPackage.eNS_URI, IAttributeConstant.ANNOTATION_KEY_RUNTIME);
boolean isUserAttr = false;
if (isUser != null) {
try {
isUserAttr = Boolean.parseBoolean(isUser);
} catch (final Exception e) {
// do nothing
}
}
Object value = null;
if (isUserAttr) {
try {
if ("uid".equals(parameter.getAttributeName())) { //$NON-NLS-1$
value = user.getUid();
} else {
value = user.getAttribute(parameter.getAttributeName());
}
} catch (final UserAttributeNotFoundException ex) {
throw new InconsistentModelException(ex);
}
} else {
value = parameter.getValue();
}
if (value instanceof String) {