From 1c65e45424a36cae2ae4028e8cf156a8829a34c6 Mon Sep 17 00:00:00 2001 From: DaryaBalvanovich Date: Wed, 29 May 2024 12:38:14 +0200 Subject: [PATCH] ACS-8055 add listAssignedHolds API --- .../lib/common/services/nodes-api.service.ts | 26 +++++++++- .../src/api/content-rest-api/api/nodes.api.ts | 45 +++++++++++++++++ .../src/api/content-rest-api/model/index.ts | 12 +++-- .../model/nodeAssignedHold.ts | 48 +++++++++++++++++++ .../model/nodeAssignedHoldEntry.ts | 29 +++++++++++ .../model/nodeAssignedHoldPagingList.ts | 34 +++++++++++++ .../model/nodeAssinedHoldsPaging.ts | 29 +++++++++++ .../gs-classification-rest-api/model/index.ts | 1 + .../model/nodeHold.ts | 23 +++++++++ 9 files changed, 242 insertions(+), 5 deletions(-) create mode 100644 lib/js-api/src/api/content-rest-api/model/nodeAssignedHold.ts create mode 100644 lib/js-api/src/api/content-rest-api/model/nodeAssignedHoldEntry.ts create mode 100644 lib/js-api/src/api/content-rest-api/model/nodeAssignedHoldPagingList.ts create mode 100644 lib/js-api/src/api/content-rest-api/model/nodeAssinedHoldsPaging.ts create mode 100644 lib/js-api/src/api/gs-classification-rest-api/model/nodeHold.ts diff --git a/lib/content-services/src/lib/common/services/nodes-api.service.ts b/lib/content-services/src/lib/common/services/nodes-api.service.ts index 14b05a5f55..e258b0439d 100644 --- a/lib/content-services/src/lib/common/services/nodes-api.service.ts +++ b/lib/content-services/src/lib/common/services/nodes-api.service.ts @@ -16,7 +16,7 @@ */ import { Injectable } from '@angular/core'; -import { NodeEntry, NodePaging, NodesApi, TrashcanApi, Node } from '@alfresco/js-api'; +import { NodeEntry, NodePaging, NodesApi, TrashcanApi, Node, NodeHold } from '@alfresco/js-api'; import { Subject, from, Observable, throwError } from 'rxjs'; import { AlfrescoApiService, UserPreferencesService } from '@alfresco/adf-core'; import { catchError, map } from 'rxjs/operators'; @@ -239,4 +239,28 @@ export class NodesApiService { return new NodeMetadata(metadata, nodeEntry.entry.nodeType); } + + /** + * Gets the list of holds assigned to the node. + * + * @param nodeId ID of the target node + * @returns List of assigned holds + */ + getNodeAssignHolds(nodeId: string): Observable { + const queryOptions = Object.assign({ + maxItems: this.preferences.paginationSize, + skipCount: 0, + where: `(assocType='rma:frozenContent')` + }); + + return from(this.nodesApi.listAssignedHolds(nodeId, queryOptions)).pipe( + map((holds) => + holds.list?.entries?.map((entity) => ({ + id: entity.entry.id, + name: entity.entry.name + })) + ), + catchError((err) => throwError(err)) + ); + } } diff --git a/lib/js-api/src/api/content-rest-api/api/nodes.api.ts b/lib/js-api/src/api/content-rest-api/api/nodes.api.ts index 3a551af21a..1f0abe347c 100644 --- a/lib/js-api/src/api/content-rest-api/api/nodes.api.ts +++ b/lib/js-api/src/api/content-rest-api/api/nodes.api.ts @@ -34,6 +34,7 @@ import { BaseApi } from './base.api'; import { throwIfNotDefined } from '../../../assert'; import { buildCollectionParam } from '../../../alfrescoApiClient'; import { ContentPagingQuery } from './types'; +import { NodeAssignedHoldPaging } from '../model/nodeAssinedHoldsPaging'; export type NodesIncludeQuery = { /** @@ -982,4 +983,48 @@ export class NodesApi extends BaseApi { returnType: DirectAccessUrlEntry }); } + + /** + * List Assigned Holds + * + * **Note:** this endpoint is available in Alfresco 7.1 and newer versions. + * + * Gets a list of assigned holds that are associated with the current **nodeId**. + * + * @param nodeId The identifier of a child node. You can also use one of these well-known aliases: + * - -my- + * - -shared- + * - -root- + * @param opts Optional parameters + * @param opts.where Optionally filter the list by **frozenContent**: + * - where=(assocType='rma:frozenContent') + * @returns Promise + */ + + listAssignedHolds( + nodeId: string, + opts?: { + where?: string; + } & ContentPagingQuery + ): Promise { + throwIfNotDefined(nodeId, 'nodeId'); + opts = opts || {}; + + const pathParams = { + nodeId + }; + + const queryParams = { + where: opts?.where, + skipCount: opts?.skipCount, + maxItems: opts?.maxItems + }; + + return this.get({ + path: '/nodes/{nodeId}/parents', + pathParams, + queryParams, + returnType: NodeAssignedHoldPaging + }); + } } 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 16ad8dad1d..a21d94d20c 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 @@ -162,10 +162,10 @@ export * from './siteMember'; export * from './siteMemberEntry'; export * from './siteMemberPaging'; export * from './siteMemberPagingList'; -export * from './siteGroup'; -export * from './siteGroupEntry'; -export * from './siteGroupPaging'; -export * from './siteGroupPagingList'; +export * from './siteGroup'; +export * from './siteGroupEntry'; +export * from './siteGroupPaging'; +export * from './siteGroupPagingList'; export * from './siteMembershipApprovalBody'; export * from './siteMembershipBodyCreate'; export * from './siteMembershipBodyUpdate'; @@ -199,3 +199,7 @@ export * from './versionPagingList'; export * from './deletedNode'; export * from './nodeAssociation'; export * from './nodeChildAssociation'; +export * from './nodeAssignedHoldPagingList'; +export * from './nodeAssinedHoldsPaging'; +export * from './nodeAssignedHoldEntry'; +export * from './nodeAssignedHold'; diff --git a/lib/js-api/src/api/content-rest-api/model/nodeAssignedHold.ts b/lib/js-api/src/api/content-rest-api/model/nodeAssignedHold.ts new file mode 100644 index 0000000000..4b109bbe0c --- /dev/null +++ b/lib/js-api/src/api/content-rest-api/model/nodeAssignedHold.ts @@ -0,0 +1,48 @@ +/*! + * @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 { DateAlfresco } from '../../content-custom-api'; +import { UserInfo } from './userInfo'; +import { ChildAssociationInfo } from './childAssociationInfo'; + +export class NodeAssignedHold { + 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; + nodeType: string; + isFolder: boolean; + isFile: boolean; + modifiedAt: Date; + modifiedByUser: UserInfo; + createdAt: Date; + createdByUser: UserInfo; + parentId?: string; + association?: ChildAssociationInfo; + + constructor(input?: Partial) { + if (input) { + Object.assign(this, input); + this.modifiedAt = input.modifiedAt ? DateAlfresco.parseDate(input.modifiedAt) : undefined; + this.modifiedByUser = input.modifiedByUser ? new UserInfo(input.modifiedByUser) : undefined; + this.createdAt = input.createdAt ? DateAlfresco.parseDate(input.createdAt) : undefined; + this.createdByUser = input.createdByUser ? new UserInfo(input.createdByUser) : undefined; + } + } +} diff --git a/lib/js-api/src/api/content-rest-api/model/nodeAssignedHoldEntry.ts b/lib/js-api/src/api/content-rest-api/model/nodeAssignedHoldEntry.ts new file mode 100644 index 0000000000..16afa4e824 --- /dev/null +++ b/lib/js-api/src/api/content-rest-api/model/nodeAssignedHoldEntry.ts @@ -0,0 +1,29 @@ +/*! + * @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 { NodeAssignedHold } from './nodeAssignedHold'; + +export class NodeAssignedHoldEntry { + entry: NodeAssignedHold; + + constructor(input?: Partial) { + if (input) { + Object.assign(this, input); + this.entry = input.entry ? new NodeAssignedHold(input.entry) : undefined; + } + } +} diff --git a/lib/js-api/src/api/content-rest-api/model/nodeAssignedHoldPagingList.ts b/lib/js-api/src/api/content-rest-api/model/nodeAssignedHoldPagingList.ts new file mode 100644 index 0000000000..3c32be7fec --- /dev/null +++ b/lib/js-api/src/api/content-rest-api/model/nodeAssignedHoldPagingList.ts @@ -0,0 +1,34 @@ +/*! + * @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 { Pagination } from '..'; +import { NodeAssignedHoldEntry } from './nodeAssignedHoldEntry'; + +export class NodeAssignedHoldPagingList { + pagination: Pagination; + entries: NodeAssignedHoldEntry[]; + + constructor(input?: Partial) { + if (input) { + Object.assign(this, input); + this.pagination = input.pagination ? new Pagination(input.pagination) : undefined; + if (input.entries) { + this.entries = input.entries.map((item) => new NodeAssignedHoldEntry(item)); + } + } + } +} diff --git a/lib/js-api/src/api/content-rest-api/model/nodeAssinedHoldsPaging.ts b/lib/js-api/src/api/content-rest-api/model/nodeAssinedHoldsPaging.ts new file mode 100644 index 0000000000..3669707610 --- /dev/null +++ b/lib/js-api/src/api/content-rest-api/model/nodeAssinedHoldsPaging.ts @@ -0,0 +1,29 @@ +/*! + * @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 { NodeAssignedHoldPagingList } from './nodeAssignedHoldPagingList'; + +export class NodeAssignedHoldPaging { + list?: NodeAssignedHoldPagingList; + + constructor(input?: Partial) { + if (input) { + Object.assign(this, input); + this.list = input.list ? new NodeAssignedHoldPagingList(input.list) : undefined; + } + } +} diff --git a/lib/js-api/src/api/gs-classification-rest-api/model/index.ts b/lib/js-api/src/api/gs-classification-rest-api/model/index.ts index 7aa60783a2..74ec41e9af 100644 --- a/lib/js-api/src/api/gs-classification-rest-api/model/index.ts +++ b/lib/js-api/src/api/gs-classification-rest-api/model/index.ts @@ -71,3 +71,4 @@ export * from './combinedInstructionBody'; export * from './classificationGuide'; export * from './classificationGuides'; export * from './nodeSecurityMarkBody'; +export * from './nodeHold'; diff --git a/lib/js-api/src/api/gs-classification-rest-api/model/nodeHold.ts b/lib/js-api/src/api/gs-classification-rest-api/model/nodeHold.ts new file mode 100644 index 0000000000..f395068745 --- /dev/null +++ b/lib/js-api/src/api/gs-classification-rest-api/model/nodeHold.ts @@ -0,0 +1,23 @@ +/*! + * @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 interface NodeHold { + id: string; + name: string; + reason?: string; + description?: string; +}