[ACS-8597] use endpoint for bulk hold operation status (#10120)

* ACS-8597 add operation status api, use entry for assign response

* ACS-8597 review remarks - property order, docs cosistency
This commit is contained in:
Grzegorz Jaśkowski
2024-08-26 17:15:02 +02:00
committed by GitHub
parent 61faf92d41
commit 94787b5705
14 changed files with 304 additions and 24 deletions

View File

@@ -49,19 +49,26 @@ Manages holds for nodes.
- _nodeId_: `string` - The Id of the node which is unassigned
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<void>`
- **bulkAssignHold**(holdId: `string`, query: [`RequestQuery`](../../../lib/js-api/src/api/search-rest-api/docs/RequestQuery.md)): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`BulkAssignHoldResponse`](../../../lib/js-api/src/api/gs-core-rest-api/docs/BulkAssignHoldResponse.md)`>`<br/>
- **bulkAssignHold**(holdId: `string`, query: [`RequestQuery`](../../../lib/js-api/src/api/search-rest-api/docs/RequestQuery.md)): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`BulkAssignHoldResponseEntry`](../../../lib/js-api/src/api/gs-core-rest-api/docs/BulkAssignHoldResponseEntry.md)`>`<br/>
Assign multiple files to a hold.
- _holdId_: `string` - The hold id
- _query_: [`RequestQuery`](../../../lib/js-api/src/api/search-rest-api/docs/RequestQuery.md) - Search query
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`BulkAssignHoldResponse`](../../../lib/js-api/src/api/gs-core-rest-api/docs/BulkAssignHoldResponse.md)`>` - Bulk status <br/>
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`BulkAssignHoldResponseEntry`](../../../lib/js-api/src/api/gs-core-rest-api/docs/BulkAssignHoldResponseEntry.md)`>` - Bulk operation description <br/>
- **bulkAssignHoldToFolder**(holdId: `string`, folderId: `string`, language: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`BulkAssignHoldResponse`](../../../lib/js-api/src/api/gs-core-rest-api/docs/BulkAssignHoldResponse.md)`>`<br/>
- **bulkAssignHoldToFolder**(holdId: `string`, folderId: `string`, language: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`BulkAssignHoldResponseEntry`](../../../lib/js-api/src/api/gs-core-rest-api/docs/BulkAssignHoldResponseEntry.md)`>`<br/>
Assign a folder to a hold.
- _holdId_: `string` - The hold id
- _folderId_: `string` - The folder id
- _language_: `string` - Language code. `afts` can be used for search query
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`BulkAssignHoldResponse`](../../../lib/js-api/src/api/gs-core-rest-api/docs/BulkAssignHoldResponse.md)`>` - Bulk status <br/>
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`BulkAssignHoldResponseEntry`](../../../lib/js-api/src/api/gs-core-rest-api/docs/BulkAssignHoldResponseEntry.md)`>` - Bulk operation description <br/>
- **getBulkOperationStatus**(bulkStatusId: `string`, holdId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`HoldBulkStatusEntry`](../../../lib/js-api/src/api/gs-core-rest-api/docs/HoldBulkStatusEntry.md)`>`<br/>
Get current status of bulk operation.
- _bulkStatusId_: `string` - The bulk operation id
- _holdId_: `string` - The hold id
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`HoldBulkStatusEntry`](../../../lib/js-api/src/api/gs-core-rest-api/docs/HoldBulkStatusEntry.md)`>` - Current status of bulk operation <br/>
## Details

View File

@@ -18,7 +18,7 @@
import { TestBed } from '@angular/core/testing';
import { LegalHoldService } from './legal-hold.service';
import { ContentTestingModule } from '../../testing/content.testing.module';
import { BulkAssignHoldResponse, Hold, HoldEntry, HoldPaging, RequestQuery, SEARCH_LANGUAGE } from '@alfresco/js-api';
import { BulkAssignHoldResponseEntry, Hold, HoldBulkStatusEntry, HoldEntry, HoldPaging, RequestQuery, SEARCH_LANGUAGE } from '@alfresco/js-api';
describe('LegalHoldsService', () => {
let service: LegalHoldService;
@@ -28,7 +28,29 @@ describe('LegalHoldsService', () => {
const filePlanId = 'mockId';
const nodeId = 'mockNodeId';
const holdId = 'holdId';
const mockBulkResponse: BulkAssignHoldResponse = { totalItems: 3, bulkStatusId: 'bulkStatus' };
const mockBulkResponse: BulkAssignHoldResponseEntry = {
entry: {
totalItems: 3,
bulkStatusId: 'bulkStatus'
}
};
const mockBulkStatusResponse: HoldBulkStatusEntry = {
entry: {
bulkStatusId: 'bulkStatus',
status: 'IN_PROGRESS',
totalItems: 3,
processedItems: 2,
errorsCount: 0,
startTime: new Date('2024'),
holdBulkOperation: {
op: 'ADD',
query: {
query: 'mockQuery',
language: SEARCH_LANGUAGE.AFTS
}
}
}
};
beforeEach(() => {
TestBed.configureTestingModule({
@@ -184,4 +206,17 @@ describe('LegalHoldsService', () => {
});
});
});
describe('getBulkOperationStatus', () => {
it('should get bulk operation status based on bulkStatusId and nodeId', (done) => {
spyOn(service.legalHoldApi, 'getBulkStatus').and.returnValue(Promise.resolve(mockBulkStatusResponse));
const bulkStatusId = 'mockBulkStatusId';
service.getBulkOperationStatus(bulkStatusId, nodeId).subscribe((response) => {
expect(response).toEqual(mockBulkStatusResponse);
expect(service.legalHoldApi.getBulkStatus).toHaveBeenCalledWith(bulkStatusId, nodeId);
done();
});
});
});
});

View File

@@ -16,7 +16,17 @@
*/
import { AlfrescoApiService } from '@alfresco/adf-core';
import { BulkAssignHoldResponse, ContentPagingQuery, Hold, HoldBody, HoldEntry, HoldPaging, LegalHoldApi, RequestQuery } from '@alfresco/js-api';
import {
BulkAssignHoldResponseEntry,
ContentPagingQuery,
Hold,
HoldBody,
HoldBulkStatusEntry,
HoldEntry,
HoldPaging,
LegalHoldApi,
RequestQuery
} from '@alfresco/js-api';
import { Injectable } from '@angular/core';
import { Observable, from } from 'rxjs';
import { map } from 'rxjs/operators';
@@ -104,9 +114,9 @@ export class LegalHoldService {
*
* @param holdId The identifier of a hold
* @param query Search query
* @returns Observable<BulkAssignHoldResponse>
* @returns Observable<BulkAssignHoldResponseEntry>
*/
bulkAssignHold(holdId: string, query: RequestQuery): Observable<BulkAssignHoldResponse> {
bulkAssignHold(holdId: string, query: RequestQuery): Observable<BulkAssignHoldResponseEntry> {
return from(this.legalHoldApi.bulkAssignHold(holdId, query));
}
@@ -116,9 +126,9 @@ export class LegalHoldService {
* @param holdId The identifier of a hold
* @param folderId The identifier of a folder
* @param language Language code
* @returns Observable<BulkAssignHoldResponse>
* @returns Observable<BulkAssignHoldResponseEntry>
*/
bulkAssignHoldToFolder(holdId: string, folderId: string, language: string): Observable<BulkAssignHoldResponse> {
bulkAssignHoldToFolder(holdId: string, folderId: string, language: string): Observable<BulkAssignHoldResponseEntry> {
const query: RequestQuery = {
query: `ANCESTOR:'workspace://SpacesStore/${folderId}' and TYPE:content`,
language
@@ -126,4 +136,15 @@ export class LegalHoldService {
return from(this.legalHoldApi.bulkAssignHold(holdId, query));
}
/**
* Get status of bulk operation with **bulkStatusId** for **holdId**.
*
* @param bulkStatusId The identifier of a bulk status
* @param holdId The identifier of a hold
* @returns Promise<HoldsBulkStatusEntry>
*/
getBulkOperationStatus(bulkStatusId: string, holdId: string): Observable<HoldBulkStatusEntry> {
return from(this.legalHoldApi.getBulkStatus(bulkStatusId, holdId));
}
}

View File

@@ -18,9 +18,9 @@
import { BaseApi } from './base.api';
import { throwIfNotDefined } from '../../../assert';
import { ContentPagingQuery } from '../../content-rest-api';
import { HoldBody, HoldEntry, HoldPaging } from './../model';
import { BulkAssignHoldResponse } from '../model/bulkAssignHoldResponse';
import { BulkAssignHoldResponseEntry, HoldBody, HoldEntry, HoldPaging } from './../model';
import { RequestQuery } from '../../search-rest-api';
import { HoldBulkStatusEntry } from '../model/holdBulkStatusEntry';
/**
* Legal Holds service.
@@ -161,9 +161,9 @@ export class LegalHoldApi extends BaseApi {
*
* @param holdId The identifier of a hold
* @param query Search query
* @returns Promise<BulkAssignHoldResponse>
* @returns Promise<BulkAssignHoldResponseEntry>
*/
bulkAssignHold(holdId: string, query: RequestQuery): Promise<BulkAssignHoldResponse> {
bulkAssignHold(holdId: string, query: RequestQuery): Promise<BulkAssignHoldResponseEntry> {
throwIfNotDefined(holdId, 'holdId');
throwIfNotDefined(query, 'query');
@@ -176,4 +176,22 @@ export class LegalHoldApi extends BaseApi {
}
});
}
/**
* Get status of bulk operation with **bulkStatusId** for **holdId**.
*
* @param bulkStatusId The identifier of a bulk status
* @param holdId The identifier of a hold
* @returns Promise<HoldsBulkStatusEntry>
*/
getBulkStatus(bulkStatusId: string, holdId: string): Promise<HoldBulkStatusEntry> {
throwIfNotDefined(holdId, 'holdId');
throwIfNotDefined(bulkStatusId, 'bulkStatusId');
return this.get({
path: `/holds/{holdId}/bulk-statuses/{bulkStatusId}`,
pathParams: { holdId, bulkStatusId },
returnType: HoldBulkStatusEntry
});
}
}

View File

@@ -0,0 +1,7 @@
# BulkAssignHoldResponseEntry
## Properties
| Name | Type | Description |
| --------- | ------------------------------------------------------- | -------------------------------------------------- |
| **Entry** | [**BulkAssignHoldResponse**](BulkAssignHoldResponse.md) | Response received after bulk assign hold operation |

View File

@@ -0,0 +1,8 @@
# HoldBulkOperation
## Properties
| Name | Type | Default value | Description |
| --------- | -------------------------------------------------------------- | ------------- | ---------------------------------------------------- |
| **op** | **string** | | Operations type. Currently only **ADD** type exists. |
| **query** | [**RequestQuery**](../../search-rest-api/docs/RequestQuery.md) | | Query to get files to assign to a hold. |

View File

@@ -0,0 +1,14 @@
# HoldBulkStatus
## Properties
| Name | Type | Description | Notes |
|---------------------- | --------------------------------------------- | --------------------------------------------- | --------------------------------------------- |
| **bulkStatusId** | **string** | Bulk status id | |
| **errorsCount** | **number** | Number of errors thrown during bulk operation | |
| **holdBulkOperation** | [**HoldBulkOperation**](HoldBulkOperation.md) | Specifies operation type and targeted files | |
| **processedItems** | **number** | Number of processed files | |
| **status** | **string** | Current status of operation | |
| **totalItems** | **number** | Number of targeted files | |
| **startTime** | **Date** | Date and time of operation start | |
| **endTime** | **Date** | Date and time of operation end | Is included only after operation is completed |

View File

@@ -0,0 +1,7 @@
# HoldBulkStatusEntry
## Properties
| Name | Type | Description |
|---------------------- | --------------------------------------------- | --------------------------------------------- |
| **entry** | [**HoldBulkStatus**](HoldBulkStatus.md) | Current status of hulk assign holds operation |

View File

@@ -3,7 +3,7 @@
All URIs are relative to _https://localhost/alfresco/api/-default-/public/gs/versions/1_
| Method | HTTP request | Description |
| ------------------------------------------------ | -------------------------------------------- | ----------------------------- |
| ---------------------------------------------------- | ---------------------------------------------------- | ------------------------------------ |
| [**getHolds**](LegalHoldApi.md#getHolds) | **GET** /file-plans/{filePlanId}/holds | Get legal holds list |
| [**assignHold**](LegalHoldApi.md#assignHold) | **POST** /holds/{holdId}/children | Assign node to legal hold |
| [**assignHolds**](LegalHoldApi.md#assignHolds) | **POST** /holds/{holdId}/children | Assign nodes to legal hold |
@@ -11,6 +11,7 @@ All URIs are relative to _https://localhost/alfresco/api/-default-/public/gs/ver
| [**createHold**](LegalHoldApi.md#createHold) | **POST** /file-plans/{filePlanId}/holds | Create one hold |
| [**createHolds**](LegalHoldApi.md#createHolds) | **POST** /file-plans/{filePlanId}/holds | Create list of holds |
| [**bulkAssignHold**](LegalHoldApi.md#bulkAssignHold) | **POST** /holds/{holdId}/bulk | Bulk add of nodes to the hold |
| [**getBulkStatus**](LegalHoldApi.md#getBulkStatus) | **GET** /holds/{holdId}/bulk-statuses/{bulkStatusId} | Get current status of bulk operation |
<a name="getHolds"></a>
@@ -324,3 +325,43 @@ legalHoldApi.bulkAssignHold('holdId', { query: 'SITE:swsdp and TYPE:content', la
### Return type
[**BulkAssignHoldResponse**](./BulkAssignHoldResponse.md)
# **getBulkStatus**
> HoldBulkStatusEntry getBulkStatus(holdId, bulkOperationId)
Get current status of asynchronous bulk operations with `bulkStatusId` happening for hold with `holdId`
### Example
```javascript
import LegalHoldApi from 'LegalHoldApi';
import { AlfrescoApi } from '@alfresco/js-api';
this.alfrescoApi = new AlfrescoApi();
this.alfrescoApi.setConfig({
hostEcm: 'http://127.0.0.1:8080'
});
const legalHoldApi = new LegalHoldApi(this.alfrescoApi);
legalHoldApi.bulkAssignHold('holdId', 'bulkOperationId').then(
(data) => {
console.log('API called successfully. Returned data: ' + data);
},
function (error) {
console.error(error);
}
);
```
### Parameters
| Name | Type | Default value | Description |
| ------------------- | ---------- | ------------- | ---------------------------------- |
| **holdId** | **string** | | The identifier of a hold |
| **bulkOperationId** | **string** | | The identifies of a bulk operation |
### Return type
[**HoldBulkStatusEntry**](./HoldBulkStatusEntry.md)

View File

@@ -0,0 +1,22 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { BulkAssignHoldResponse } from './bulkAssignHoldResponse';
export interface BulkAssignHoldResponseEntry {
entry: BulkAssignHoldResponse;
}

View File

@@ -0,0 +1,30 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export class HoldBulkOperation {
op: string;
query: {
language: string;
query: string;
};
constructor(input?: Partial<HoldBulkOperation>) {
if (input) {
Object.assign(this, input);
}
}
}

View File

@@ -0,0 +1,38 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { HoldBulkOperation } from './holdBulkOperation';
import { DateAlfresco } from '../../content-custom-api';
export class HoldBulkStatus {
bulkStatusId: string;
errorsCount: number;
holdBulkOperation: HoldBulkOperation;
processedItems: number;
status: string;
totalItems: number;
startTime: Date;
endTime?: Date;
constructor(input?: Partial<HoldBulkStatus>) {
if (input) {
Object.assign(this, input);
this.startTime = input.startTime ? DateAlfresco.parseDate(input.startTime) : undefined;
this.endTime = input.endTime ? DateAlfresco.parseDate(input.endTime) : undefined;
}
}
}

View File

@@ -0,0 +1,28 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { HoldBulkStatus } from './holdBulkStatus';
export class HoldBulkStatusEntry {
entry: HoldBulkStatus;
constructor(input?: Partial<HoldBulkStatusEntry>) {
if (input) {
Object.assign(this, input);
}
}
}

View File

@@ -76,8 +76,12 @@ export * from './unfiledContainerChildAssociation';
export * from './unfiledRecordFolderChildAssociation';
export * from './hold';
export * from './holdBody';
export * from './holdBulkOperation';
export * from './holdBulkStatus';
export * from './holdBulkStatusEntry';
export * from './holdEntry';
export * from './holdPaging';
export * from './holdPagingList';
export * from './nodeAssignedHold';
export * from './bulkAssignHoldResponse';
export * from './bulkAssignHoldResponseEntry';