diff --git a/src/core/server/saved_objects/service/saved_objects_client.ts b/src/core/server/saved_objects/service/saved_objects_client.ts index 8ed3b6266237..a4ddd66991f6 100644 --- a/src/core/server/saved_objects/service/saved_objects_client.ts +++ b/src/core/server/saved_objects/service/saved_objects_client.ts @@ -465,35 +465,35 @@ export class SavedObjectsClient { return await this._repository.addToWorkspaces(objects, workspaces, options); }; - /** - * Bulk Updates multiple SavedObject at once - * - * @param objects - */ - async bulkUpdate( - objects: Array>, - options?: SavedObjectsBulkUpdateOptions - ): Promise> { - return await this._repository.bulkUpdate(objects, options); - } - /** * Different DB may have different query DSL for given params */ - async getPermissionQueryDSL( + getPermissionQueryDSL = async ( props: Parameters[0] - ) { + ) => { return await this._repository.getPermissionQueryDSL(props); - } + }; /** * Different DB may have different query to find granted objects, * provide a placeholder here for other query implementation */ - async processFindOptions(props: { + processFindOptions = async (props: { options: SavedObjectsFindOptions; principals: Principals; - }): Promise { + }): Promise => { return await this._repository.processFindOptions(props); + }; + + /** + * Bulk Updates multiple SavedObject at once + * + * @param objects + */ + async bulkUpdate( + objects: Array>, + options?: SavedObjectsBulkUpdateOptions + ): Promise> { + return await this._repository.bulkUpdate(objects, options); } } diff --git a/src/plugins/workspace/server/saved_objects/workspace_saved_objects_client_wrapper.ts b/src/plugins/workspace/server/saved_objects/workspace_saved_objects_client_wrapper.ts index 077d01bd81c5..e89e9674bb36 100644 --- a/src/plugins/workspace/server/saved_objects/workspace_saved_objects_client_wrapper.ts +++ b/src/plugins/workspace/server/saved_objects/workspace_saved_objects_client_wrapper.ts @@ -4,7 +4,6 @@ */ import { i18n } from '@osd/i18n'; -import Boom from '@hapi/boom'; import { Observable } from 'rxjs'; import { first } from 'rxjs/operators'; @@ -29,23 +28,29 @@ import { SavedObjectsPermissionControlContract, WORKSPACE_TYPE, WorkspacePermissionMode, + SavedObjectsErrorHelpers, } from '../../../../core/server'; import { ConfigSchema } from '../../config'; import { WorkspaceFindOptions } from '../types'; // Can't throw unauthorized for now, the page will be refreshed if unauthorized -const generateWorkspacePermissionError = () => - Boom.illegal( - i18n.translate('workspace.permission.invalidate', { - defaultMessage: 'Invalid workspace permission', - }) +const generateWorkspacePermissionError = () => { + SavedObjectsErrorHelpers.decorateForbiddenError( + new Error( + i18n.translate('workspace.permission.invalidate', { + defaultMessage: 'Invalid workspace permission', + }) + ) ); +}; const generateSavedObjectsPermissionError = () => - Boom.illegal( - i18n.translate('saved_objects.permission.invalidate', { - defaultMessage: 'Invalid saved objects permission', - }) + SavedObjectsErrorHelpers.decorateForbiddenError( + new Error( + i18n.translate('saved_objects.permission.invalidate', { + defaultMessage: 'Invalid saved objects permission', + }) + ) ); export class WorkspaceSavedObjectsClientWrapper { @@ -347,8 +352,6 @@ export class WorkspaceSavedObjectsClientWrapper { principals, }); return await wrapperOptions.client.find(processedOptions); - - return await wrapperOptions.client.find(options); }; const addToWorkspacesWithPermissionControl = async (