use of ru.curs.celesta.CallContext in project celesta by CourseOrchestra.
the class PermissionManager method refreshPermissions.
private PermissionCacheEntry refreshPermissions(CallContext c, GrainElement t) {
try (CallContext sysContext = new SystemCallContext(celesta, "refreshPermissions")) {
RoleCacheEntry rce = getRce(c.getUserId(), sysContext);
PermissionsCursor permissions = new PermissionsCursor(sysContext);
int permissionsMask = 0;
for (String roleId : rce.roles) {
if (permissionsMask == FULL_RIGHTS) {
break;
}
if (READER.equals(roleId) || (t.getGrain().getName() + '.' + READER).equals(roleId)) {
permissionsMask |= Action.READ.getMask();
} else if (EDITOR.equals(roleId) || (t.getGrain().getName() + '.' + EDITOR).equals(roleId)) {
permissionsMask = FULL_RIGHTS;
} else if (permissions.tryGet(roleId, t.getGrain().getName(), t.getName())) {
permissionsMask |= permissions.getR() ? Action.READ.getMask() : 0;
permissionsMask |= permissions.getI() ? Action.INSERT.getMask() : 0;
permissionsMask |= permissions.getM() ? Action.MODIFY.getMask() : 0;
permissionsMask |= permissions.getD() ? Action.DELETE.getMask() : 0;
}
}
return new PermissionCacheEntry(c.getUserId(), t, permissionsMask);
}
}
use of ru.curs.celesta.CallContext in project celesta by CourseOrchestra.
the class SchemaAutoupdateTest method lockGrain.
private void lockGrain(String grainName, ICelesta celesta) {
try (CallContext cc = new SystemCallContext(celesta)) {
GrainsCursor gc = new GrainsCursor(cc);
gc.get(grainName);
gc.setState(ISchemaCursor.LOCK);
gc.update();
gc.close();
}
}
use of ru.curs.celesta.CallContext in project celesta by CourseOrchestra.
the class DbUpdaterImpl method updateSysGrain.
/**
* Updates the system grain.
*/
public void updateSysGrain() {
try (CallContext context = createContext()) {
schemaCursor = new GrainsCursor(context);
table = new TablesCursor(context);
updateSysGrain(context);
}
}
use of ru.curs.celesta.CallContext in project celesta by CourseOrchestra.
the class ProfilingManager method logCall.
/**
* Logs information on the call to the profiler.
*
* @param context call context
*/
public void logCall(CallContext context) {
if (this.profilemode && !NO_LOG.equals(context.getProcName())) {
try (CallContext sysContext = new SystemCallContext(celesta)) {
CalllogCursor clc = new CalllogCursor(sysContext);
clc.setProcname(context.getProcName());
clc.setUserid(context.getUserId());
clc.setStarttime(context.getStartTime());
clc.setDuration((int) (context.getDurationNs() / 1000));
clc.insert();
}
}
}
Aggregations