Search in sources :

Example 1 with CallContext

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);
    }
}
Also used : SystemCallContext(ru.curs.celesta.SystemCallContext) PermissionsCursor(ru.curs.celesta.syscursors.PermissionsCursor) SystemCallContext(ru.curs.celesta.SystemCallContext) CallContext(ru.curs.celesta.CallContext)

Example 2 with CallContext

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();
    }
}
Also used : SystemCallContext(ru.curs.celesta.SystemCallContext) GrainsCursor(ru.curs.celesta.syscursors.GrainsCursor) CallContext(ru.curs.celesta.CallContext) SystemCallContext(ru.curs.celesta.SystemCallContext)

Example 3 with CallContext

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);
    }
}
Also used : GrainsCursor(ru.curs.celesta.syscursors.GrainsCursor) TablesCursor(ru.curs.celesta.syscursors.TablesCursor) CallContext(ru.curs.celesta.CallContext) SystemCallContext(ru.curs.celesta.SystemCallContext)

Example 4 with CallContext

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();
        }
    }
}
Also used : CalllogCursor(ru.curs.celesta.syscursors.CalllogCursor) SystemCallContext(ru.curs.celesta.SystemCallContext) SystemCallContext(ru.curs.celesta.SystemCallContext) CallContext(ru.curs.celesta.CallContext)

Aggregations

CallContext (ru.curs.celesta.CallContext)4 SystemCallContext (ru.curs.celesta.SystemCallContext)4 GrainsCursor (ru.curs.celesta.syscursors.GrainsCursor)2 CalllogCursor (ru.curs.celesta.syscursors.CalllogCursor)1 PermissionsCursor (ru.curs.celesta.syscursors.PermissionsCursor)1 TablesCursor (ru.curs.celesta.syscursors.TablesCursor)1