use of org.teiid.adminapi.DataPolicy.DataPermission in project teiid by teiid.
the class DatabaseUtil method convert.
private static Permission convert(DataPermission dp) {
Permission p = new Permission();
p.setAllowAlter(dp.getAllowAlter());
p.setAllowDelete(dp.getAllowDelete());
p.setAllowExecute(dp.getAllowExecute());
p.setAllowInsert(dp.getAllowCreate());
p.setAllowSelect(dp.getAllowRead());
p.setAllowUpdate(dp.getAllowUpdate());
p.setResourceName(dp.getResourceName());
if (dp.getAllowLanguage() != null && dp.getAllowLanguage()) {
p.setAllowUsage(true);
p.setResourceType(ResourceType.LANGUAGE);
} else if (dp.getResourceType() != null) {
p.setResourceType(ResourceType.valueOf(dp.getResourceType().name()));
} else {
// $NON-NLS-1$ //$NON-NLS-2$
int dotCount = dp.getResourceName().length() - dp.getResourceName().replaceAll("\\.", "").length();
if (dotCount == 0) {
p.setResourceType(ResourceType.SCHEMA);
} else if (dp.getAllowExecute() != null && dp.getAllowExecute()) {
// this may not be correct as it could be a function as well
p.setResourceType(ResourceType.PROCEDURE);
} else if (dotCount >= 2) {
// this may not be correct as it could be a table
p.setResourceType(ResourceType.COLUMN);
} else {
p.setResourceType(ResourceType.TABLE);
}
}
if (dp.getMask() != null) {
p.setMask(dp.getMask());
p.setMaskOrder(dp.getOrder());
}
if (dp.getCondition() != null) {
p.setCondition(dp.getCondition(), dp.getConstraint());
}
return p;
}
Aggregations