diff --git a/docs/core/services/nodes-api.service.md b/docs/core/services/nodes-api.service.md index 65c4884e3b..28685d9f51 100644 --- a/docs/core/services/nodes-api.service.md +++ b/docs/core/services/nodes-api.service.md @@ -83,7 +83,10 @@ Accesses and manipulates ACS document nodes using their node IDs. - _nodeId:_ `string` - ID of the target node - _nodeBody:_ `any` - New data for the node - _options:_ `any` - Optional parameters supported by JS-API - - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`MinimalNode`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/NodeMinimalEntry.md)`>` - Updated node information + - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`MinimalNode`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/NodeMinimalEntry.md)`>` - Updated node information
+ Getting legal holds assigned to a node. + - _nodeId:_ `string` - ID of the target node + - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`Hold[]`](../../../lib/js-api/src/api/gs-core-rest-api/docs/Hold.md)`>` - Updated node information ## Details 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 2a61bd7351..d53d9867e2 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 @@ -38,21 +38,16 @@ export class LegalHoldService { * * @param filePlanId The identifier of a file plan. You can also use the -filePlan- alias. * @param options Optional parameters supported by JS-API - * @returns List of assigned holds + * @returns List of assigned holds Hold[] */ getHolds(filePlanId: string, options: ContentPagingQuery = {}): Observable { - const queryOptions = Object.assign({ - maxItems: options?.maxItems, - skipCount: options?.skipCount - }); - - return from(this.legalHoldApi.getHolds(filePlanId, queryOptions)).pipe( - map((holds) => - holds.list?.entries?.map((entity) => ({ - id: entity.entry.id, - name: entity.entry.name, - reason: entity.entry.reason, - description: entity.entry.description + return from(this.legalHoldApi.getHolds(filePlanId, options)).pipe( + map(({ list }) => + list?.entries?.map(({ entry }) => ({ + id: entry?.id, + name: entry?.name, + reason: entry?.reason, + description: entry?.description })) ), catchError((err) => throwError(err)) 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 32de1ff55a..e31feac06f 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 @@ -17,16 +17,56 @@ import { TestBed } from '@angular/core/testing'; import { LegalHoldService } from './legal-hold.service'; +import { ContentTestingModule } from '../../testing/content.testing.module'; +import { Hold, NodeChildAssociationPaging } from '@alfresco/js-api'; describe('LegalHoldsService', () => { let service: LegalHoldService; + let legalHolds: NodeChildAssociationPaging; + let returnedHolds: Hold[]; + const mockId = 'mockId'; beforeEach(() => { - TestBed.configureTestingModule({}); + TestBed.configureTestingModule({ + imports: [ContentTestingModule] + }); service = TestBed.inject(LegalHoldService); + legalHolds = { + list: { + entries: [ + { + entry: { + id: mockId, + name: 'some name', + reason: 'some description' + } + } + ] + } + } as NodeChildAssociationPaging; + returnedHolds = [ + { + id: mockId, + name: 'some name', + reason: 'some description', + description: undefined + } + ]; }); it('should be created', () => { expect(service).toBeTruthy(); }); + + describe('getHolds', () => { + it('should return array of Hold interface', (done) => { + spyOn(service.legalHoldApi, 'getHolds').and.returnValue(Promise.resolve(legalHolds)); + + service.getHolds(mockId).subscribe((holds) => { + expect(holds).toEqual(returnedHolds); + expect(service.legalHoldApi.getHolds).toHaveBeenCalledWith(mockId, {}); + done(); + }); + }); + }); }); diff --git a/lib/js-api/src/api/content-rest-api/model/index.ts b/lib/js-api/src/api/content-rest-api/model/index.ts index 40193439e3..4f6f3ddb21 100644 --- a/lib/js-api/src/api/content-rest-api/model/index.ts +++ b/lib/js-api/src/api/content-rest-api/model/index.ts @@ -199,4 +199,3 @@ export * from './versionPagingList'; export * from './deletedNode'; export * from './nodeAssociation'; export * from './nodeChildAssociation'; -export * from './nodeHold'; diff --git a/lib/js-api/src/api/content-rest-api/model/nodeHold.ts b/lib/js-api/src/api/content-rest-api/model/nodeHold.ts deleted file mode 100644 index 0eeb4c4a2d..0000000000 --- a/lib/js-api/src/api/content-rest-api/model/nodeHold.ts +++ /dev/null @@ -1,33 +0,0 @@ -/*! - * @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 NodeHold { - id: string; - /** - * The name must not contain spaces or the following special characters: * \" < > \\ / ? : and |. - * The character . must not be used at the end of the name. - */ - name: string; - reason: string; - description: string; - - constructor(input?: Partial) { - if (input) { - Object.assign(this, input); - } - } -} diff --git a/lib/js-api/src/api/gs-core-rest-api/README.md b/lib/js-api/src/api/gs-core-rest-api/README.md index 7c7fbaa2ac..93c1cbc44a 100644 --- a/lib/js-api/src/api/gs-core-rest-api/README.md +++ b/lib/js-api/src/api/gs-core-rest-api/README.md @@ -21,6 +21,7 @@ Class | Method | HTTP request | Description *.GssitesApi* | [**deleteRMSite**](docs/GssitesApi.md#deleteRMSite) | **DELETE** /gs-sites/rm | Delete the Records Management (RM) site *.GssitesApi* | [**getRMSite**](docs/GssitesApi.md#getRMSite) | **GET** /gs-sites/rm | Get the Records Management (RM) site *.GssitesApi* | [**updateRMSite**](docs/GssitesApi.md#updateRMSite) | **PUT** /gs-sites/rm | Update the Records Management (RM) site +*.LegalHoldApi* | [**getHolds**](docs/LegalHoldApi.md#getHolds) | **GET** /file-plans/{filePlanId}/holds | Get legal hold list *.RecordCategoriesApi* | [**createRecordCategoryChild**](docs/RecordCategoriesApi.md#createRecordCategoryChild) | **POST** /record-categories/{recordCategoryId}/children | Create a record category or a record folder *.RecordCategoriesApi* | [**deleteRecordCategory**](docs/RecordCategoriesApi.md#deleteRecordCategory) | **DELETE** /record-categories/{recordCategoryId} | Delete a record category *.RecordCategoriesApi* | [**getRecordCategory**](docs/RecordCategoriesApi.md#getRecordCategory) | **GET** /record-categories/{recordCategoryId} | Get a record category @@ -63,6 +64,7 @@ Class | Method | HTTP request | Description - [FilePlanComponentBodyUpdate](docs/FilePlanComponentBodyUpdate.md) - [FilePlanEntry](docs/FilePlanEntry.md) - [ModelError](docs/ModelError.md) + - [NodeChildAssociationPaging](../content-rest-api/docs/NodesApi.md#NodeChildAssociationPaging) - [Pagination](docs/Pagination.md) - [PathElement](docs/PathElement.md) - [PathInfo](docs/PathInfo.md) 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 72be0f88cc..9cb26cffb0 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 @@ -22,15 +22,15 @@ import { ContentPagingQuery, NodeChildAssociationPaging } from '../../content-re /** * Legal Holds service. * - * @module RecordsApi + * @module LegalHoldApi */ export class LegalHoldApi extends BaseApi { /** * List of legal holds * * @param filePlanId The identifier of a file plan. You can also use the -filePlan- alias. - * @param opts Optional parameters - * @returns Promise + * @param opt Optional parameters + * @returns Promise */ getHolds(filePlanId: string = '-filePlan-', opts?: ContentPagingQuery): Promise { throwIfNotDefined(filePlanId, 'filePlanId'); diff --git a/lib/js-api/src/api/gs-core-rest-api/docs/Hold.md b/lib/js-api/src/api/gs-core-rest-api/docs/Hold.md new file mode 100644 index 0000000000..a0f1eb9099 --- /dev/null +++ b/lib/js-api/src/api/gs-core-rest-api/docs/Hold.md @@ -0,0 +1,21 @@ +# Hold + +## Basic usage + +```ts +export interface Hold { + id: string; + name: string; + reason?: string; + description?: string; + selected?: string; +} +``` + +## Properties +Name | Type | Default value | Description +------------ | ------------- | ------------- | ------------- +**id** | **string** | | hold id +**name** | **string** | | hold name +**reason** | **string** | | hold reason +**description** | **string** | | [optional] [additional information for a hold] 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 new file mode 100644 index 0000000000..014ace31a5 --- /dev/null +++ b/lib/js-api/src/api/gs-core-rest-api/docs/LegalHoldApi.md @@ -0,0 +1,50 @@ +# LegalHoldApi + +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 + + +# **getHolds** +> NodeChildAssociationPaging getHolds(filePlanId, opts) + +Get 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' +}); + +let legalHoldApi = new LegalHoldApi(this.alfrescoApi); + +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. +}; + +legalHoldApi.getHolds('-filePlan-', opts).then((data) => { + console.log('API called successfully. Returned data: ' + data); +}, function(error) { + console.error(error); +}); + +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **filePlanId** | **string** | The site details | + **skipCount** | **number**| The number of entities that exist in the collection before those included in this list. | [optional] + **maxItems** | **number**| The maximum number of items to return in the list. | [optional] + +### Return type + +[**NodeChildAssociationPaging**](NodeChildAssociationPaging.md) diff --git a/lib/js-api/src/api/gs-classification-rest-api/model/nodeHold.ts b/lib/js-api/src/api/gs-core-rest-api/model/nodeHold.ts similarity index 97% rename from lib/js-api/src/api/gs-classification-rest-api/model/nodeHold.ts rename to lib/js-api/src/api/gs-core-rest-api/model/nodeHold.ts index edabc1d414..4c7543f52e 100644 --- a/lib/js-api/src/api/gs-classification-rest-api/model/nodeHold.ts +++ b/lib/js-api/src/api/gs-core-rest-api/model/nodeHold.ts @@ -20,4 +20,5 @@ export interface Hold { name: string; reason?: string; description?: string; + selected?: string; }