diff --git a/docs/content-services/services/legal-hold.service.md b/docs/content-services/services/legal-hold.service.md
index 849c172247..231f075843 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.
@@ -17,15 +17,25 @@ Manages holds for nodes.
Gets the list of holds for a node.
- _filePlanId_: `string` - The identifier of a file plan. You can also use the -filePlan- alias
- _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
+ - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`Hold`](../../../lib/js-api/src/api/gs-core-rest-api/docs/Hold.md)`[]>` - List of holds
+- **createHold**(filePlanId: `string`, hold: [`Hold`](../../../lib/js-api/src/api/gs-core-rest-api/docs/Hold.md)): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`HoldEntry`](../../../lib/js-api/src/api/gs-core-rest-api/docs/HoldEntry.md)`>`
+ Create new hold in File Plan.
+ - _filePlanId_: `string` - The identifier of a file plan. You can also use the -filePlan- alias
+ - _hold_: [`Hold`](../../../lib/js-api/src/api/gs-core-rest-api/docs/Hold.md) - Hold that should be created
+ - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`HoldEntry`](../../../lib/js-api/src/api/gs-core-rest-api/docs/HoldEntry.md)`>` - Hold entry
+- **createHolds**(filePlanId: `string`, holds: [`Hold`](../../../lib/js-api/src/api/gs-core-rest-api/docs/Hold.md)`[]`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`Hold`](../../../lib/js-api/src/api/gs-core-rest-api/docs/Hold.md)`[]>`
+ Create new holds in File Plan.
+ - _filePlanId_: `string` - The identifier of a file plan. You can also use the -filePlan- alias
+ - _holds_: `<`[`Hold`](../../../lib/js-api/src/api/gs-core-rest-api/docs/Hold.md)`[]>` - Array of holds that should be created
+ - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`HoldPaging`](../../../lib/js-api/src/api/gs-core-rest-api/docs/HoldPaging.md)`>` - List of paginated holds entries
-- **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)`>`
+- **assignHold**(nodeId: `string`, holdId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`HoldEntry`](../../../lib/js-api/src/api/gs-core-rest-api/docs/HoldEntry.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)`>`
+- **assignHolds**(nodeIds: `<{id: string}[]>`, holdId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`HoldPaging`](../../../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
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 3f2eb6acc4..902d1467c3 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
@@ -34,7 +34,7 @@ export class LegalHoldService {
constructor(private readonly apiService: AlfrescoApiService) {}
/**
- * Gets the list of holds.
+ * Gets the list of holds available in the file plan.
*
* @param filePlanId The identifier of a file plan. You can also use the -filePlan- alias.
* @param options Optional parameters supported by JS-API
@@ -83,4 +83,26 @@ export class LegalHoldService {
unassignHold(holdId: string, nodeId: string): Observable {
return from(this.legalHoldApi.unassignHold(holdId, nodeId));
}
+
+ /**
+ * Create hold.
+ *
+ * @param filePlanId The identifier of a file plan. You can also use the -filePlan- alias.
+ * @param hold Hold to create
+ * @returns List of created holds Observable
+ */
+ createHold(filePlanId: string, hold: Hold): Observable {
+ return from(this.legalHoldApi.createHold(filePlanId, hold));
+ }
+
+ /**
+ * Create list of holds.
+ *
+ * @param filePlanId The identifier of a file plan. You can also use the -filePlan- alias.
+ * @param holds Array of holds to create
+ * @returns List of created holds Observable
+ */
+ createHolds(filePlanId: string, holds: Hold[]): Observable {
+ return from(this.legalHoldApi.createHolds(filePlanId, holds));
+ }
}
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 3a91d33b5a..c9c149c790 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
@@ -18,11 +18,12 @@
import { TestBed } from '@angular/core/testing';
import { LegalHoldService } from './legal-hold.service';
import { ContentTestingModule } from '../../testing/content.testing.module';
-import { Hold, HoldPaging } from '@alfresco/js-api';
+import { Hold, HoldEntry, HoldPaging } from '@alfresco/js-api';
describe('LegalHoldsService', () => {
let service: LegalHoldService;
let legalHolds: HoldPaging;
+ let legalHoldEntry: HoldEntry;
let returnedHolds: Hold[];
const mockId = 'mockId';
@@ -34,24 +35,23 @@ describe('LegalHoldsService', () => {
legalHolds = {
list: {
- entries: [
- {
- entry: {
- id: mockId,
- name: 'some name',
- reason: 'some description'
- }
- }
- ]
+ entries: [legalHoldEntry]
}
} as HoldPaging;
+ legalHoldEntry = {
+ entry: {
+ id: mockId,
+ name: 'some name',
+ reason: 'some reason',
+ description: 'some description'
+ }
+ };
+
returnedHolds = [
{
id: mockId,
- name: 'some name',
- reason: 'some description',
- description: undefined
+ name: 'some name'
}
];
});
@@ -66,7 +66,7 @@ describe('LegalHoldsService', () => {
service.getHolds(mockId).subscribe((holds) => {
expect(holds).toEqual(returnedHolds);
- expect(service.legalHoldApi.getHolds).toHaveBeenCalledWith(mockId, {});
+ expect(service.legalHoldApi.getHolds).toHaveBeenCalledWith(mockId, undefined);
done();
});
});
@@ -89,7 +89,7 @@ describe('LegalHoldsService', () => {
describe('assignHolds', () => {
it('should assign nodes to existing hold', (done) => {
- const nodeIds = [{ id: 'qwe' }, { id: 'abc'}];
+ const nodeIds = [{ id: 'qwe' }, { id: 'abc' }];
const holdId = 'foo';
spyOn(service.legalHoldApi, 'assignHolds').and.returnValue(Promise.resolve(legalHolds));
@@ -114,4 +114,42 @@ describe('LegalHoldsService', () => {
});
});
});
+
+ describe('createHold', () => {
+ it('should create new hold', (done) => {
+ const mockHold = {
+ name: 'Hold 1',
+ reason: 'reason 1'
+ };
+ spyOn(service.legalHoldApi, 'createHold').and.returnValue(Promise.resolve(legalHoldEntry));
+
+ service.createHold(mockId, mockHold).subscribe((hold) => {
+ expect(hold).toEqual(legalHoldEntry);
+ expect(service.legalHoldApi.createHold).toHaveBeenCalledWith(mockId, mockHold);
+ done();
+ });
+ });
+ });
+
+ describe('createHolds', () => {
+ it('should create list of holds', (done) => {
+ const mockHolds = [
+ {
+ name: 'Hold 1',
+ reason: 'reason 1'
+ },
+ {
+ name: 'Hold 2',
+ reason: 'reason 2'
+ }
+ ];
+ spyOn(service.legalHoldApi, 'createHolds').and.returnValue(Promise.resolve(legalHolds));
+
+ service.createHolds(mockId, mockHolds).subscribe((holds) => {
+ expect(holds).toEqual(legalHolds);
+ expect(service.legalHoldApi.createHolds).toHaveBeenCalledWith(mockId, mockHolds);
+ 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 6a6d2eb1d6..b091d1bf00 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
@@ -18,8 +18,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';
+import { Hold, HoldEntry, HoldPaging } from './../model';
/**
* Legal Holds service.
@@ -108,4 +107,50 @@ export class LegalHoldApi extends BaseApi {
pathParams: { holdId, nodeId }
});
}
+
+ /**
+ * Create new hold
+ *
+ * @param filePlanId The identifier of a file plan. You can also use the -filePlan- alias.
+ * @param hold Hold to create
+ * @returns Promise
+ */
+ createHold(filePlanId: string, hold: Hold): Promise {
+ throwIfNotDefined(filePlanId, 'filePlanId');
+ throwIfNotDefined(hold, 'hold');
+
+ const pathParams = {
+ filePlanId
+ };
+
+ return this.post({
+ path: '/file-plans/{filePlanId}/holds',
+ pathParams,
+ bodyParam: [hold],
+ returnType: HoldEntry
+ });
+ }
+
+ /**
+ * Create list of new holds
+ *
+ * @param filePlanId The identifier of a file plan. You can also use the -filePlan- alias.
+ * @param holds Array of holds
+ * @returns Promise
+ */
+ createHolds(filePlanId = '-filePlan-', holds: Hold[]): Promise {
+ throwIfNotDefined(filePlanId, 'filePlanId');
+ throwIfNotDefined(holds, 'holds');
+
+ const pathParams = {
+ filePlanId
+ };
+
+ return this.post({
+ path: '/file-plans/{filePlanId}/holds',
+ pathParams,
+ bodyParam: holds,
+ returnType: HoldPaging
+ });
+ }
}
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 d7d79592eb..dd4b3e497a 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
@@ -8,6 +8,8 @@ All URIs are relative to _https://localhost/alfresco/api/-default-/public/gs/ver
| [**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
@@ -28,7 +30,7 @@ this.alfrescoApi.setConfig({
hostEcm: 'http://127.0.0.1:8080'
});
-let legalHoldApi = new LegalHoldApi(this.alfrescoApi);
+const legalHoldApi = new LegalHoldApi(this.alfrescoApi);
let opts = {
'skipCount': 56 // | The number of entities that exist in the collection before those included in this list.
@@ -180,3 +182,96 @@ legalHoldApi.unassignHold('holdId', 'nodeId').then(
### Return type
**void**
+
+
+# **createHold**
+> HoldEntry createHold(filePlanId, holds)
+
+Create 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'
+});
+
+const legalHoldApi = new LegalHoldApi(this.alfrescoApi);
+
+const hold = {
+ name: 'Hold 1',
+ reason: 'Reason 1'
+};
+
+legalHoldApi.createHold('-filePlan-', hold).then((data) => {
+ console.log('API called successfully. Returned data: ' + data);
+}, function(error) {
+ console.error(error);
+});
+
+```
+
+### Parameters
+
+Name | Type | Default value | Description
+------------- | ------------- | ------------- | -------------
+ **filePlanId** | **string** | | The site details
+ **hold** | **Hold**| | Hold to create.
+
+### Return type
+
+[**HoldEntry**](./HoldEntry.md)
+
+
+# **createHolds**
+> HoldPaging createHolds(filePlanId, holds)
+
+Create legal holds list.
+
+### 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);
+
+let opts = [
+ {
+ name: 'Hold 1',
+ reason: 'Reason 1'
+ },
+ {
+ name: 'Hold 2',
+ reason: 'Reason 2',
+ description: 'Description'
+ }
+];
+
+legalHoldApi.createHolds('-filePlan-', holds).then((data) => {
+ console.log('API called successfully. Returned data: ' + data);
+}, function(error) {
+ console.error(error);
+});
+
+```
+
+### Parameters
+
+Name | Type | Default value | Description
+------------- | ------------- | ------------- | -------------
+ **filePlanId** | **string** | | The site details
+ **holds** | **Hold[]**| | Array of new holds.
+
+### Return type
+
+[**HoldPaging**](./HoldPaging.md)