Search in sources :

Example 1 with PermissionsApi

use of com.haleconnect.api.projectstore.v1.api.PermissionsApi in project hale by halestudio.

the class HaleConnectServiceImpl method testProjectPermission.

@Override
public boolean testProjectPermission(String permission, Owner owner, String projectId) throws HaleConnectException {
    PermissionsApi api = ProjectStoreHelper.getPermissionsApi(this, this.getSession().getToken());
    String combinedBucketId = MessageFormat.format("{0}.{1}.{2}", owner.getType().getJsonValue(), owner.getId(), projectId);
    try {
        api.testBucketPermission(permission, combinedBucketId);
    } catch (com.haleconnect.api.projectstore.v1.ApiException e) {
        if (e.getCode() == 403) {
            // not allowed
            return false;
        }
        // other codes indicate client error or server-side exception
        throw new HaleConnectException(e.getMessage(), e);
    }
    return true;
}
Also used : PermissionsApi(com.haleconnect.api.projectstore.v1.api.PermissionsApi) HaleConnectException(eu.esdihumboldt.hale.io.haleconnect.HaleConnectException)

Aggregations

PermissionsApi (com.haleconnect.api.projectstore.v1.api.PermissionsApi)1 HaleConnectException (eu.esdihumboldt.hale.io.haleconnect.HaleConnectException)1