Skip to content

Commit

Permalink
[ACS-8597] use endpoint for bulk hold operation status (#10120)
Browse files Browse the repository at this point in the history
* ACS-8597 add operation status api, use entry for assign response

* ACS-8597 review remarks - property order, docs cosistency
  • Loading branch information
g-jaskowski authored Aug 26, 2024
1 parent 61faf92 commit 94787b5
Show file tree
Hide file tree
Showing 14 changed files with 304 additions and 24 deletions.
15 changes: 11 additions & 4 deletions docs/content-services/services/legal-hold.service.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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({
Expand Down Expand Up @@ -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();
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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));
}

Expand All @@ -116,14 +126,25 @@ 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
};

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));
}
}
26 changes: 22 additions & 4 deletions lib/js-api/src/api/gs-core-rest-api/api/legal-hold.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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');

Expand All @@ -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
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# BulkAssignHoldResponseEntry

## Properties

| Name | Type | Description |
| --------- | ------------------------------------------------------- | -------------------------------------------------- |
| **Entry** | [**BulkAssignHoldResponse**](BulkAssignHoldResponse.md) | Response received after bulk assign hold operation |
8 changes: 8 additions & 0 deletions lib/js-api/src/api/gs-core-rest-api/docs/HoldBulkOperation.md
Original file line number Diff line number Diff line change
@@ -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. |
14 changes: 14 additions & 0 deletions lib/js-api/src/api/gs-core-rest-api/docs/HoldBulkStatus.md
Original file line number Diff line number Diff line change
@@ -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 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# HoldBulkStatusEntry

## Properties

| Name | Type | Description |
|---------------------- | --------------------------------------------- | --------------------------------------------- |
| **entry** | [**HoldBulkStatus**](HoldBulkStatus.md) | Current status of hulk assign holds operation |
59 changes: 50 additions & 9 deletions lib/js-api/src/api/gs-core-rest-api/docs/LegalHoldApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

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 |
| [**unassignHold**](LegalHoldApi.md#unassignHold) | **DELETE** /holds/{holdId}/children/{nodeId} | Unassign node from legal hold |
| [**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 |
| 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 |
| [**unassignHold**](LegalHoldApi.md#unassignHold) | **DELETE** /holds/{holdId}/children/{nodeId} | Unassign node from legal hold |
| [**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>

Expand Down Expand Up @@ -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)
Original file line number Diff line number Diff line change
@@ -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;
}
30 changes: 30 additions & 0 deletions lib/js-api/src/api/gs-core-rest-api/model/holdBulkOperation.ts
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
Loading

0 comments on commit 94787b5

Please sign in to comment.