diff --git a/docs/content-services/services/legal-hold.service.md b/docs/content-services/services/legal-hold.service.md
index 623f662f16..849c172247 100644
--- a/docs/content-services/services/legal-hold.service.md
+++ b/docs/content-services/services/legal-hold.service.md
@@ -5,7 +5,7 @@ Status: Active
Last reviewed: 2024-06-19
---
-# [Legal Hold service](../../../lib/content-services/src/lib/legal-hold/services/legal-hold.service.ts "Defined in legal-hold.service.ts")
+# [Legal Hold service](../../../lib/content-services/src/lib/legal-hold/services/legal-hold.service.ts) "Defined in legal-hold.service.ts"
Manages holds for nodes.
@@ -19,6 +19,25 @@ Manages holds for nodes.
- _options_: `ContentPagingQuery` - Optional parameters supported by JS-API
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`Hold`](../../../lib/js-api/src/api/gs-core-rest-api/docs/Hold.md)`[]>` - List of holds
+- **assignHold**(nodeId: `string`, holdId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`Hold`](../../../lib/js-api/src/api/gs-core-rest-api/docs/Hold.md)`>`
+ Assign a node to a hold.
+ - _nodeId_: `string` - The Id of the node which will be assigned to a hold
+ - _holdId_: `string` - The Id of the hold to which nodes will be assigned
+ - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`HoldEntry`](../../../lib/js-api/src/api/gs-core-rest-api/docs/HoldEntry.md)`>` - Entry with the hold
+
+- **assignHolds**(nodeIds: `<{id: string}[]>`, holdId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`Hold`](../../../lib/js-api/src/api/gs-core-rest-api/docs/HoldPaging.md)`>`
+ Assign a node to a hold.
+ - _nodeIds_: `<{id: string}[]>` - The Ids of the nodes which will be assigned to a hold
+ - _holdId_: `string` - The Id of the hold to which nodes will be assigned
+ - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`HoldPaging`](../../../lib/js-api/src/api/gs-core-rest-api/docs/Hold.md)`>` - Hold paging
+
+- **unassignHold**(holdId: `string`, nodeId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`void`]`>`
+ Assign a node to a hold.
+ - _holdId_: `string` - The hold Id
+ - _nodeId_: `string` - The Id of the node which is unassigned
+ - **Returns** [`void`]
+
+
## Details
To create, delete or get holds Records Management should be created and user should be added to it.
diff --git a/lib/content-services/src/lib/legal-hold/services/legal-hold.service.ts b/lib/content-services/src/lib/legal-hold/services/legal-hold.service.ts
index 73d551e08d..3f2eb6acc4 100644
--- a/lib/content-services/src/lib/legal-hold/services/legal-hold.service.ts
+++ b/lib/content-services/src/lib/legal-hold/services/legal-hold.service.ts
@@ -16,7 +16,7 @@
*/
import { AlfrescoApiService } from '@alfresco/adf-core';
-import { ContentPagingQuery, Hold, LegalHoldApi } from '@alfresco/js-api';
+import { ContentPagingQuery, Hold, HoldEntry, HoldPaging, LegalHoldApi } from '@alfresco/js-api';
import { Injectable } from '@angular/core';
import { Observable, from } from 'rxjs';
import { map } from 'rxjs/operators';
@@ -50,4 +50,37 @@ export class LegalHoldService {
)
);
}
+
+ /**
+ * Assign a node to a hold.
+ *
+ * @param nodeId The Id of the node which will be assigned to a hold
+ * @param holdId The Id of the hold to which nodes will be assigned
+ * @returns Observable
+ */
+ assignHold(nodeId: string, holdId: string): Observable {
+ return from(this.legalHoldApi.assignHold(nodeId, holdId));
+ }
+
+ /**
+ * Assign a node to a hold.
+ *
+ * @param nodeIds The list of managed node Ids
+ * @param holdId The Id of the hold to which nodes will be assigned
+ * @returns Observable
+ */
+ assignHolds(nodeIds: { id: string }[], holdId: string): Observable {
+ return from(this.legalHoldApi.assignHolds(nodeIds, holdId));
+ }
+
+ /**
+ * Unassign the relationship between a child with id nodeId and a parent hold with id holdId.
+ *
+ * @param holdId The hold Id
+ * @param nodeId The Id of the node which is unassigned
+ * @returns Empty response
+ */
+ unassignHold(holdId: string, nodeId: string): Observable {
+ return from(this.legalHoldApi.unassignHold(holdId, nodeId));
+ }
}
diff --git a/lib/content-services/src/lib/legal-hold/services/legal-holds.service.spec.ts b/lib/content-services/src/lib/legal-hold/services/legal-holds.service.spec.ts
index 8b2f6a4e15..3a91d33b5a 100644
--- a/lib/content-services/src/lib/legal-hold/services/legal-holds.service.spec.ts
+++ b/lib/content-services/src/lib/legal-hold/services/legal-holds.service.spec.ts
@@ -71,4 +71,47 @@ describe('LegalHoldsService', () => {
});
});
});
+
+ describe('assignHold', () => {
+ it('should assign node to existing hold', (done) => {
+ const nodeId = 'qwe';
+ const holdId = 'foo';
+ const mockResponse = { entry: { id: holdId } };
+ spyOn(service.legalHoldApi, 'assignHold').and.returnValue(Promise.resolve(mockResponse));
+
+ service.assignHold(nodeId, holdId).subscribe((holds) => {
+ expect(holds).toEqual(mockResponse);
+ expect(service.legalHoldApi.assignHold).toHaveBeenCalledWith(nodeId, holdId);
+ done();
+ });
+ });
+ });
+
+ describe('assignHolds', () => {
+ it('should assign nodes to existing hold', (done) => {
+ const nodeIds = [{ id: 'qwe' }, { id: 'abc'}];
+ const holdId = 'foo';
+ spyOn(service.legalHoldApi, 'assignHolds').and.returnValue(Promise.resolve(legalHolds));
+
+ service.assignHolds(nodeIds, holdId).subscribe((holds) => {
+ expect(holds).toEqual(legalHolds);
+ expect(service.legalHoldApi.assignHolds).toHaveBeenCalledWith(nodeIds, holdId);
+ done();
+ });
+ });
+ });
+
+ describe('unassignHold', () => {
+ it('should unassign node from existing hold', (done) => {
+ const nodeId = 'qwe';
+ const holdId = 'foo';
+
+ spyOn(service.legalHoldApi, 'unassignHold').and.returnValue(Promise.resolve(undefined));
+
+ service.unassignHold(holdId, nodeId).subscribe(() => {
+ expect(service.legalHoldApi.unassignHold).toHaveBeenCalledWith(holdId, nodeId);
+ done();
+ });
+ });
+ });
});
diff --git a/lib/js-api/src/api/gs-core-rest-api/api/legal-hold.api.ts b/lib/js-api/src/api/gs-core-rest-api/api/legal-hold.api.ts
index 2e4663bead..6a6d2eb1d6 100644
--- a/lib/js-api/src/api/gs-core-rest-api/api/legal-hold.api.ts
+++ b/lib/js-api/src/api/gs-core-rest-api/api/legal-hold.api.ts
@@ -19,6 +19,7 @@ import { BaseApi } from './base.api';
import { throwIfNotDefined } from '../../../assert';
import { ContentPagingQuery } from '../../content-rest-api';
import { HoldPaging } from '../model/holdPaging';
+import { HoldEntry } from '../model';
/**
* Legal Holds service.
@@ -52,4 +53,59 @@ export class LegalHoldApi extends BaseApi {
returnType: HoldPaging
});
}
+
+ /**
+ * Assign node to legal hold
+ *
+ * @param holdId The identifier of a hold
+ * @param nodeId The id of the node to be assigned to existing hold
+ * @returns Promise
+ */
+ assignHold(nodeId: string, holdId: string): Promise {
+ throwIfNotDefined(holdId, 'holdId');
+ throwIfNotDefined(nodeId, 'nodeId');
+
+ return this.post({
+ path: `/holds/{holdId}/children`,
+ pathParams: { holdId },
+ bodyParam: [nodeId],
+ returnType: HoldEntry
+ });
+ }
+
+ /**
+ * Assign nodes to legal hold
+ *
+ * @param holdId The identifier of a hold
+ * @param nodeIds The list with id of nodes to assign to existing hold
+ * @returns Promise
+ */
+ assignHolds(nodeIds: { id: string }[], holdId: string): Promise {
+ throwIfNotDefined(holdId, 'holdId');
+ throwIfNotDefined(nodeIds, 'nodeIds');
+
+ return this.post({
+ path: `/holds/{holdId}/children`,
+ pathParams: { holdId },
+ bodyParam: nodeIds,
+ returnType: HoldPaging
+ });
+ }
+
+ /**
+ * Deletes the relationship between a child with id nodeId and a parent hold with id holdId
+ *
+ * @param holdId The identifier of a hold
+ * @param nodeId The Id of the node which is unassigned
+ * @returns Empty response
+ */
+ unassignHold(holdId: string, nodeId: string): Promise {
+ throwIfNotDefined(holdId, 'holdId');
+ throwIfNotDefined(nodeId, 'nodeId');
+
+ return this.delete({
+ path: `/holds/{holdId}/children/{nodeId}`,
+ pathParams: { holdId, nodeId }
+ });
+ }
}
diff --git a/lib/js-api/src/api/gs-core-rest-api/docs/LegalHoldApi.md b/lib/js-api/src/api/gs-core-rest-api/docs/LegalHoldApi.md
index 2942b17327..d7d79592eb 100644
--- a/lib/js-api/src/api/gs-core-rest-api/docs/LegalHoldApi.md
+++ b/lib/js-api/src/api/gs-core-rest-api/docs/LegalHoldApi.md
@@ -1,18 +1,24 @@
# LegalHoldApi
-All URIs are relative to *https://localhost/alfresco/api/-default-/public/gs/versions/1*
+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
+| 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 |
+
# **getHolds**
+
> HoldPaging getHolds(filePlanId, opts)
Get legal holds list.
### Example
+
```javascript
import LegalHoldApi from 'LegalHoldApi';
import { AlfrescoApi } from '@alfresco/js-api';
@@ -24,7 +30,7 @@ this.alfrescoApi.setConfig({
let legalHoldApi = new LegalHoldApi(this.alfrescoApi);
-let opts = {
+let opts = {
'skipCount': 56 // | The number of entities that exist in the collection before those included in this list.
'maxItems': 56 // | The maximum number of items to return in the list.
};
@@ -39,12 +45,138 @@ legalHoldApi.getHolds('-filePlan-', opts).then((data) => {
### Parameters
-Name | Type | Default value | Description
-------------- | ------------- | ------------- | -------------
- **filePlanId** | **string** | | The site details
- **skipCount** | **number**| `0` | The number of entities that exist in the collection before those included in this list. [optional]
- **maxItems** | **number**| `100` | The maximum number of items to return in the list. [optional]
+| Name | Type | Default value | Description |
+| -------------- | ---------- | ------------- | -------------------------------------------------------------------------------------------------- |
+| **filePlanId** | **string** | | The site details |
+| **skipCount** | **number** | `0` | The number of entities that exist in the collection before those included in this list. [optional] |
+| **maxItems** | **number** | `100` | The maximum number of items to return in the list. [optional] |
### Return type
[**HoldPaging**](HoldPaging.md)
+
+
+
+# **assignHold**
+
+> HoldEntry assignHold(nodeId, holdId)
+
+Assign node to legal hold.
+
+### 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'
+});
+
+let legalHoldApi = new LegalHoldApi(this.alfrescoApi);
+
+legalHoldApi.assignHold('nodeId', 'holdId').then(
+ (data) => {
+ console.log('API called successfully. Returned data: ' + data);
+ },
+ function (error) {
+ console.error(error);
+ }
+);
+```
+
+### Parameters
+
+| Name | Type | Default value | Description |
+| ---------- | ---------- | ------------- | ----------------------------------------- |
+| **nodeId** | **string** | | The id of the node to be assigned to hold |
+| **holdId** | **string** | | The identifier of a hold. |
+
+### Return type
+
+[**HoldEntry**](HoldEntry.md)
+
+
+
+# **assignHolds**
+
+> HoldPaging assignHolds(nodeIds, holdId)
+
+Assign nodes to legal hold.
+
+### 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'
+});
+
+let legalHoldApi = new LegalHoldApi(this.alfrescoApi);
+
+legalHoldApi.assignHolds([{ id: 'foo' }, { id: 'bar' }], 'holdId').then(
+ (data) => {
+ console.log('API called successfully. Returned data: ' + data);
+ },
+ function (error) {
+ console.error(error);
+ }
+);
+```
+
+### Parameters
+
+| Name | Type | Default value | Description |
+| ----------- |----------------------| ------------- | ---------------------------------------------------- |
+| **nodeIds** | **{ id: string }[]** | | The list with id of nodes to assign to existing hold |
+| **holdId** | **string** | | The identifier of a hold. |
+
+### Return type
+
+[**HoldPaging**](HoldPaging.md)
+
+
+
+# **unassignHold**
+
+> void unassignHold(holdId, nodeId)
+
+Unassign node from legal hold.
+
+### 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'
+});
+
+let legalHoldApi = new LegalHoldApi(this.alfrescoApi);
+
+legalHoldApi.unassignHold('holdId', 'nodeId').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 |
+| **nodeId** | **string** | | The nodeId of the node which is unassigned |
+
+### Return type
+
+**void**
diff --git a/lib/js-api/src/api/gs-core-rest-api/model/hold.ts b/lib/js-api/src/api/gs-core-rest-api/model/hold.ts
index fb6c891d16..2afcc4a176 100644
--- a/lib/js-api/src/api/gs-core-rest-api/model/hold.ts
+++ b/lib/js-api/src/api/gs-core-rest-api/model/hold.ts
@@ -16,8 +16,8 @@
*/
export interface Hold {
- name: string;
id?: string;
+ name?: string;
reason?: string;
description?: string;
selected?: boolean;