diff --git a/lib/content-services/src/lib/audit/audit.service.spec.ts b/lib/content-services/src/lib/audit/audit.service.spec.ts deleted file mode 100644 index dad1a0330e..0000000000 --- a/lib/content-services/src/lib/audit/audit.service.spec.ts +++ /dev/null @@ -1,202 +0,0 @@ -/*! - * @license - * Copyright © 2005-2023 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 { AuditService } from './audit.service'; -import { AppConfigService } from '@alfresco/adf-core'; -import { TranslateModule } from '@ngx-translate/core'; -import { ContentTestingModule } from '../testing/content.testing.module'; -import { TestBed } from '@angular/core/testing'; - -declare let jasmine: any; - -describe('AuditService', () => { - let service: AuditService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ - TranslateModule.forRoot(), - ContentTestingModule - ] - }); - const appConfig: AppConfigService = TestBed.inject(AppConfigService); - appConfig.config = { - ecmHost: 'http://localhost:9876/ecm', - files: { - excluded: ['.DS_Store', 'desktop.ini', '.git', '*.git'] - } - }; - service = TestBed.inject(AuditService); - jasmine.Ajax.install(); - }); - - afterEach(() => { - jasmine.Ajax.uninstall(); - }); - - it('Should get Audit Applications', (done) => { - service.getAuditApps().subscribe((data) => { - expect(data.list.pagination.count).toBe(3); - done(); - }); - - jasmine.Ajax.requests.mostRecent().respondWith({ - status: 200, - contentType: 'json', - responseText: { - list: { - pagination: { - count: 3, - hasMoreItems: false, - totalItems: 3, - skipCount: 0, - maxItems: 100 - }, - entries: [ - { - entry: { - isEnabled: true, - name: 'Alfresco Tagging Service', - id: 'tagging' - } - }, - { - entry: { - isEnabled: true, - name: 'ShareSiteAccess', - id: 'share-site-access' - } - }, - { - entry: { - isEnabled: true, - name: 'alfresco-access', - id: 'alfresco-access' - } - } - ] - } - } - }); - }); - - it('Should get an Audit Application', (done) => { - service.getAuditApp('alfresco-access').subscribe((data) => { - expect(data.entry.id).toBe('alfresco-access'); - expect(data.entry.name).toBe('alfresco-access'); - done(); - }); - - jasmine.Ajax.requests.mostRecent().respondWith({ - status: 200, - contentType: 'json', - responseText: { - entry: { - id: 'alfresco-access', - name: 'alfresco-access', - isEnabled: true - } - } - }); - }); - - it('Should get Audit Entries', (done) => { - service.getAuditEntries('alfresco-access').subscribe((data) => { - expect(data.list.pagination.count).toBe(3); - done(); - }); - - jasmine.Ajax.requests.mostRecent().respondWith({ - status: 200, - contentType: 'json', - responseText: { - list: { - pagination: { - count: 3, - hasMoreItems: false, - totalItems: 3, - skipCount: 0, - maxItems: 100 - }, - entries: [ - { - entry: { - id: '1', - auditApplicationId: 'alfresco-access', - createdByUser: { - displayName: 'admin', - id: 'admin' - }, - createdAt: '2020-08-11T13:11:59.141Z', - values: {} - } - }, - { - entry: { - id: '2', - auditApplicationId: 'alfresco-access', - createdByUser: { - displayName: 'admin', - id: 'admin' - }, - createdAt: '2020-08-11T13:11:59.141Z', - values: {} - } - }, - { - entry: { - id: '3', - auditApplicationId: 'alfresco-access', - createdByUser: { - displayName: 'admin', - id: 'admin' - }, - createdAt: '2020-08-11T13:11:59.141Z', - values: {} - } - } - ] - } - } - }); - }); - - it('Should get an Audit Entry', (done) => { - service.getAuditEntry('alfresco-access', '1').subscribe((data) => { - expect(data.entry.id).toBe('1'); - expect(data.entry.auditApplicationId).toBe('alfresco-access'); - done(); - }); - - jasmine.Ajax.requests.mostRecent().respondWith({ - status: 200, - contentType: 'json', - responseText: { - entry: { - id: '1', - auditApplicationId: 'alfresco-access', - createdByUser: { - displayName: 'admin', - id: 'admin' - }, - createdAt: '2020-08-11T13:11:59.148Z', - values: {} - } - } - }); - }); -}); diff --git a/lib/content-services/src/lib/audit/audit.service.ts b/lib/content-services/src/lib/audit/audit.service.ts index fc06a6da88..ab5a55ce07 100644 --- a/lib/content-services/src/lib/audit/audit.service.ts +++ b/lib/content-services/src/lib/audit/audit.service.ts @@ -16,10 +16,9 @@ */ import { Injectable } from '@angular/core'; -import { Observable, from, throwError } from 'rxjs'; -import { AlfrescoApiService, LogService } from '@alfresco/adf-core'; -import { AuditApi, AuditAppPaging, AuditAppEntry, AuditApp, AuditBodyUpdate, AuditEntryPaging, AuditEntryEntry } from '@alfresco/js-api'; -import { catchError } from 'rxjs/operators'; +import { Observable, from } from 'rxjs'; +import { AlfrescoApiService } from '@alfresco/adf-core'; +import { AuditApi, AuditAppPaging, AuditApp, AuditBodyUpdate, AuditEntryPaging, AuditEntryEntry } from '@alfresco/js-api'; @Injectable({ providedIn: 'root' @@ -31,7 +30,7 @@ export class AuditService { return this._auditApi; } - constructor(private apiService: AlfrescoApiService, private logService: LogService) {} + constructor(private apiService: AlfrescoApiService) {} /** * Gets a list of audit applications. @@ -44,7 +43,7 @@ export class AuditService { skipCount: 0 }; const queryOptions = Object.assign({}, defaultOptions, opts); - return from(this.auditApi.listAuditApps(queryOptions)).pipe(catchError((err: any) => this.handleError(err))); + return from(this.auditApi.listAuditApps(queryOptions)); } /** @@ -54,12 +53,12 @@ export class AuditService { * @param opts Options. * @returns status of an audit application. */ - getAuditApp(auditApplicationId: string, opts?: any): Observable { + getAuditApp(auditApplicationId: string, opts?: any): Observable { const defaultOptions = { auditApplicationId }; const queryOptions = Object.assign({}, defaultOptions, opts); - return from(this.auditApi.getAuditApp(queryOptions)).pipe(catchError((err: any) => this.handleError(err))); + return from(this.auditApi.getAuditApp(queryOptions)); } /** @@ -73,9 +72,7 @@ export class AuditService { updateAuditApp(auditApplicationId: string, auditAppBodyUpdate: boolean, opts?: any): Observable { const defaultOptions = {}; const queryOptions = Object.assign({}, defaultOptions, opts); - return from(this.auditApi.updateAuditApp(auditApplicationId, new AuditBodyUpdate({ isEnabled: auditAppBodyUpdate }), queryOptions)).pipe( - catchError((err: any) => this.handleError(err)) - ); + return from(this.auditApi.updateAuditApp(auditApplicationId, new AuditBodyUpdate({ isEnabled: auditAppBodyUpdate }), queryOptions)); } /** @@ -91,9 +88,7 @@ export class AuditService { maxItems: 100 }; const queryOptions = Object.assign({}, defaultOptions, opts); - return from(this.auditApi.listAuditEntriesForAuditApp(auditApplicationId, queryOptions)).pipe( - catchError((err: any) => this.handleError(err)) - ); + return from(this.auditApi.listAuditEntriesForAuditApp(auditApplicationId, queryOptions)); } /** @@ -107,9 +102,7 @@ export class AuditService { getAuditEntry(auditApplicationId: string, auditEntryId: string, opts?: any): Observable { const defaultOptions = {}; const queryOptions = Object.assign({}, defaultOptions, opts); - return from(this.auditApi.getAuditEntry(auditApplicationId, auditEntryId, queryOptions)).pipe( - catchError((err: any) => this.handleError(err)) - ); + return from(this.auditApi.getAuditEntry(auditApplicationId, auditEntryId, queryOptions)); } /** @@ -124,7 +117,7 @@ export class AuditService { nodeId }; const queryOptions = Object.assign({}, defaultOptions, opts); - return from(this.auditApi.listAuditEntriesForNode(queryOptions)).pipe(catchError((err: any) => this.handleError(err))); + return from(this.auditApi.listAuditEntriesForNode(queryOptions)); } /** @@ -135,7 +128,7 @@ export class AuditService { * @returns void operation */ deleteAuditEntries(auditApplicationId: string, where: string): Observable { - return from(this.auditApi.deleteAuditEntriesForAuditApp(auditApplicationId, where)).pipe(catchError((err: any) => this.handleError(err))); + return from(this.auditApi.deleteAuditEntriesForAuditApp(auditApplicationId, where)); } /** @@ -146,11 +139,6 @@ export class AuditService { * @returns void operation */ deleteAuditEntry(auditApplicationId: string, auditEntryId: string): Observable { - return from(this.auditApi.deleteAuditEntry(auditApplicationId, auditEntryId)).pipe(catchError((err: any) => this.handleError(err))); - } - - private handleError(error: any): any { - this.logService.error(error); - return throwError(error || 'Server error'); + return from(this.auditApi.deleteAuditEntry(auditApplicationId, auditEntryId)); } } diff --git a/lib/content-services/src/lib/common/services/sites.service.spec.ts b/lib/content-services/src/lib/common/services/sites.service.spec.ts deleted file mode 100644 index 915a6b1c20..0000000000 --- a/lib/content-services/src/lib/common/services/sites.service.spec.ts +++ /dev/null @@ -1,156 +0,0 @@ -/*! - * @license - * Copyright © 2005-2023 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 { TestBed } from '@angular/core/testing'; -import { AppConfigService, CoreTestingModule } from '@alfresco/adf-core'; -import { SitesService } from './sites.service'; -import { TranslateModule } from '@ngx-translate/core'; - -declare let jasmine: any; - -describe('Sites service', () => { - let service: SitesService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ - TranslateModule.forRoot(), - CoreTestingModule - ] - }); - const appConfig: AppConfigService = TestBed.inject(AppConfigService); - appConfig.config = { - ecmHost: 'http://localhost:9876/ecm', - files: { - excluded: ['.DS_Store', 'desktop.ini', '.git', '*.git'] - } - }; - - service = TestBed.inject(SitesService); - jasmine.Ajax.install(); - }); - - afterEach(() => { - jasmine.Ajax.uninstall(); - }); - - it('Should get a list of users sites', (done) => { - service.getSites().subscribe((data) => { - expect(data.list.entries[0].entry.title).toBe('FAKE'); - done(); - }); - - jasmine.Ajax.requests.mostRecent().respondWith({ - status: 200, - contentType: 'json', - responseText: { - list: { - pagination: { - count: 1, - hasMoreItems: false, - totalItems: 1, - skipCount: 0, - maxItems: 100 - }, - entries: [ - { - entry: { - role: 'SiteManager', - visibility: 'PUBLIC', - guid: 'b4cff62a-664d-4d45-9302-98723eac1319', - description: 'This is a Sample Alfresco Team site.', - id: 'swsdp', - title: 'FAKE' - } - } - ] - } - } - }); - }); - - it('Should get single sites via siteId', (done) => { - service.getSite('fake-site-id').subscribe((data) => { - expect(data.entry.title).toBe('FAKE-SINGLE-TITLE'); - done(); - }); - - jasmine.Ajax.requests.mostRecent().respondWith({ - status: 200, - contentType: 'json', - responseText: { - entry: { - role: 'SiteManager', - visibility: 'PUBLIC', - guid: 'b4cff62a-664d-4d45-9302-98723eac1319', - description: 'This is a Sample Alfresco Team site.', - id: 'swsdp', - preset: 'site-dashboard', - title: 'FAKE-SINGLE-TITLE' - } - } - }); - }); - - it('should get a list of membership requests', (done) => { - service.getSiteMembershipRequests().subscribe((data) => { - expect(data.list.entries[0].entry.site.id).toBe('site-id'); - expect(data.list.entries[0].entry.person.id).toBe('user-id'); - done(); - }); - - jasmine.Ajax.requests.mostRecent().respondWith({ - status: 200, - contentType: 'json', - responseText: { - list: { - pagination: { - count: 1, - hasMoreItems: false, - totalItems: 1, - skipCount: 0, - maxItems: 100 - }, - entries: [ - { - entry: { - id: 'site-id', - createdAt: '2020-05-13T07:46:36.180Z', - site: { - id: 'site-id', - guid: 'b4cff62a-664d-4d45-9302-98723eac1319', - title: 'Sample Site', - description: '', - visibility: 'MODERATED', - preset: 'preset', - role: 'Manager' - }, - person: { - id: 'user-id', - firstName: 'string', - lastName: 'string', - displayName: 'string' - }, - message: 'message' - } - } - ] - } - } - }); - }); -}); diff --git a/lib/content-services/src/lib/common/services/sites.service.ts b/lib/content-services/src/lib/common/services/sites.service.ts index e2cabb5508..aeb0b44a2d 100644 --- a/lib/content-services/src/lib/common/services/sites.service.ts +++ b/lib/content-services/src/lib/common/services/sites.service.ts @@ -16,8 +16,8 @@ */ import { Injectable } from '@angular/core'; -import { from, Observable, throwError } from 'rxjs'; -import { AlfrescoApiService, LogService } from '@alfresco/adf-core'; +import { from, Observable } from 'rxjs'; +import { AlfrescoApiService } from '@alfresco/adf-core'; import { Node, SiteBodyCreate, @@ -32,7 +32,6 @@ import { SitePaging, SitesApi } from '@alfresco/js-api'; -import { catchError } from 'rxjs/operators'; @Injectable({ providedIn: 'root' @@ -44,7 +43,7 @@ export class SitesService { return this._sitesApi; } - constructor(private apiService: AlfrescoApiService, private logService: LogService) {} + constructor(private apiService: AlfrescoApiService) {} /** * Create a site @@ -53,7 +52,7 @@ export class SitesService { * @returns site SiteEntry */ createSite(siteBody: SiteBodyCreate): Observable { - return from(this.sitesApi.createSite(siteBody)).pipe(catchError((err: any) => this.handleError(err))); + return from(this.sitesApi.createSite(siteBody)); } /** @@ -68,7 +67,7 @@ export class SitesService { include: ['properties'] }; const queryOptions = Object.assign({}, defaultOptions, opts); - return from(this.sitesApi.listSites(queryOptions)).pipe(catchError((err: any) => this.handleError(err))); + return from(this.sitesApi.listSites(queryOptions)); } /** @@ -79,7 +78,7 @@ export class SitesService { * @returns Information about the site */ getSite(siteId: string, opts?: any): Observable { - return from(this.sitesApi.getSite(siteId, opts)).pipe(catchError((err: any) => this.handleError(err))); + return from(this.sitesApi.getSite(siteId, opts)); } /** @@ -92,7 +91,7 @@ export class SitesService { deleteSite(siteId: string, permanentFlag: boolean = true): Observable { const options: any = {}; options.permanent = permanentFlag; - return from(this.sitesApi.deleteSite(siteId, options)).pipe(catchError((err: any) => this.handleError(err))); + return from(this.sitesApi.deleteSite(siteId, options)); } /** @@ -149,7 +148,7 @@ export class SitesService { * @returns Site membership requests */ getSiteMembershipRequests(opts?: any): Observable { - return from(this.sitesApi.getSiteMembershipRequests(opts)).pipe(catchError((err: any) => this.handleError(err))); + return from(this.sitesApi.getSiteMembershipRequests(opts)); } /** @@ -161,7 +160,7 @@ export class SitesService { * @returns Observable */ createSiteMembership(siteId: string, siteMembershipBodyCreate: SiteMembershipBodyCreate, opts?: any): Observable { - return from(this.sitesApi.createSiteMembership(siteId, siteMembershipBodyCreate, opts)).pipe(catchError((err: any) => this.handleError(err))); + return from(this.sitesApi.createSiteMembership(siteId, siteMembershipBodyCreate, opts)); } /** @@ -179,9 +178,7 @@ export class SitesService { siteMembershipBodyUpdate: SiteMembershipBodyUpdate, opts?: any ): Observable { - return from(this.sitesApi.updateSiteMembership(siteId, personId, siteMembershipBodyUpdate, opts)).pipe( - catchError((err: any) => this.handleError(err)) - ); + return from(this.sitesApi.updateSiteMembership(siteId, personId, siteMembershipBodyUpdate, opts)); } /** @@ -192,7 +189,7 @@ export class SitesService { * @returns Null response notifying when the operation is complete */ deleteSiteMembership(siteId: string, personId: string): Observable { - return from(this.sitesApi.deleteSiteMembership(siteId, personId)).pipe(catchError((err: any) => this.handleError(err))); + return from(this.sitesApi.deleteSiteMembership(siteId, personId)); } /** @@ -204,7 +201,7 @@ export class SitesService { * @returns Null response notifying when the operation is complete */ approveSiteMembershipRequest(siteId: string, inviteeId: string, opts?: any): Observable { - return from(this.sitesApi.approveSiteMembershipRequest(siteId, inviteeId, opts)).pipe(catchError((err: any) => this.handleError(err))); + return from(this.sitesApi.approveSiteMembershipRequest(siteId, inviteeId, opts)); } /** @@ -216,7 +213,7 @@ export class SitesService { * @returns Null response notifying when the operation is complete */ rejectSiteMembershipRequest(siteId: string, inviteeId: string, opts?: any): Observable { - return from(this.sitesApi.rejectSiteMembershipRequest(siteId, inviteeId, opts)).pipe(catchError((err: any) => this.handleError(err))); + return from(this.sitesApi.rejectSiteMembershipRequest(siteId, inviteeId, opts)); } /** @@ -227,7 +224,7 @@ export class SitesService { * @returns Observable */ listSiteGroups(siteId: string, opts?: any): Observable { - return from(this.sitesApi.listSiteGroups(siteId, opts)).pipe(catchError((err: any) => this.handleError(err))); + return from(this.sitesApi.listSiteGroups(siteId, opts)); } /** @@ -238,7 +235,7 @@ export class SitesService { * @returns Observable */ createSiteGroupMembership(siteId: string, siteMembershipBodyCreate: SiteMembershipBodyCreate): Observable { - return from(this.sitesApi.createSiteGroupMembership(siteId, siteMembershipBodyCreate)).pipe(catchError((err: any) => this.handleError(err))); + return from(this.sitesApi.createSiteGroupMembership(siteId, siteMembershipBodyCreate)); } /** @@ -249,7 +246,7 @@ export class SitesService { * @returns Observable */ getSiteGroupMembership(siteId: string, groupId: string): Observable { - return from(this.sitesApi.getSiteGroupMembership(siteId, groupId)).pipe(catchError((err: any) => this.handleError(err))); + return from(this.sitesApi.getSiteGroupMembership(siteId, groupId)); } /** @@ -261,9 +258,7 @@ export class SitesService { * @returns Observable */ updateSiteGroupMembership(siteId: string, groupId: string, siteMembershipBodyUpdate: SiteMembershipBodyUpdate): Observable { - return from(this.sitesApi.updateSiteGroupMembership(siteId, groupId, siteMembershipBodyUpdate)).pipe( - catchError((err: any) => this.handleError(err)) - ); + return from(this.sitesApi.updateSiteGroupMembership(siteId, groupId, siteMembershipBodyUpdate)); } /** @@ -274,11 +269,6 @@ export class SitesService { * @returns Observable */ deleteSiteGroupMembership(siteId: string, groupId: string): Observable { - return from(this.sitesApi.deleteSiteGroupMembership(siteId, groupId)).pipe(catchError((err: any) => this.handleError(err))); - } - - private handleError(error: any): Observable { - this.logService.error(error); - return throwError(error || 'Server error'); + return from(this.sitesApi.deleteSiteGroupMembership(siteId, groupId)); } } diff --git a/lib/content-services/src/lib/dialogs/download-zip/services/download-zip.service.ts b/lib/content-services/src/lib/dialogs/download-zip/services/download-zip.service.ts index fbdeed077b..165e9dcd67 100755 --- a/lib/content-services/src/lib/dialogs/download-zip/services/download-zip.service.ts +++ b/lib/content-services/src/lib/dialogs/download-zip/services/download-zip.service.ts @@ -17,9 +17,8 @@ import { DownloadEntry, DownloadBodyCreate, DownloadsApi } from '@alfresco/js-api'; import { Injectable } from '@angular/core'; -import { Observable, from, throwError } from 'rxjs'; -import { AlfrescoApiService, LogService } from '@alfresco/adf-core'; -import { catchError } from 'rxjs/operators'; +import { Observable, from } from 'rxjs'; +import { AlfrescoApiService } from '@alfresco/adf-core'; @Injectable({ providedIn: 'root' @@ -32,8 +31,7 @@ export class DownloadZipService { return this._downloadsApi; } - constructor(private apiService: AlfrescoApiService, - private logService: LogService) { + constructor(private apiService: AlfrescoApiService) { } /** @@ -43,9 +41,7 @@ export class DownloadZipService { * @returns Status object for the download */ createDownload(payload: DownloadBodyCreate): Observable { - return from(this.downloadsApi.createDownload(payload)).pipe( - catchError((err) => this.handleError(err)) - ); + return from(this.downloadsApi.createDownload(payload)); } /** @@ -66,9 +62,4 @@ export class DownloadZipService { cancelDownload(downloadId: string) { this.downloadsApi.cancelDownload(downloadId); } - - private handleError(error: any) { - this.logService.error(error); - return throwError(error || 'Server error'); - } } diff --git a/lib/content-services/src/lib/document-list/services/custom-resources.service.ts b/lib/content-services/src/lib/document-list/services/custom-resources.service.ts index 911ee3694c..135ed9b10e 100644 --- a/lib/content-services/src/lib/document-list/services/custom-resources.service.ts +++ b/lib/content-services/src/lib/document-list/services/custom-resources.service.ts @@ -15,9 +15,8 @@ * limitations under the License. */ -import { AlfrescoApiService, LogService, PaginationModel } from '@alfresco/adf-core'; +import { AlfrescoApiService, PaginationModel } from '@alfresco/adf-core'; import { - NodePaging, DeletedNodesPaging, SearchRequest, SharedLinkPaging, @@ -30,11 +29,13 @@ import { FavoritesApi, SharedlinksApi, TrashcanApi, - NodesApi + NodesApi, + SitePaging, + ResultSetPaging } from '@alfresco/js-api'; import { Injectable } from '@angular/core'; -import { Observable, from, of, throwError } from 'rxjs'; -import { catchError, map } from 'rxjs/operators'; +import { Observable, from, of } from 'rxjs'; +import { map } from 'rxjs/operators'; const CREATE_PERMISSION: string = 'create'; @@ -83,7 +84,7 @@ export class CustomResourcesService { return this._nodesApi; } - constructor(private apiService: AlfrescoApiService, private logService: LogService) { + constructor(private apiService: AlfrescoApiService) { } /** @@ -94,7 +95,7 @@ export class CustomResourcesService { * @param filters Specifies additional filters to apply (joined with **AND**) * @returns List of nodes for the recently used files */ - getRecentFiles(personId: string, pagination: PaginationModel, filters?: string[]): Observable { + getRecentFiles(personId: string, pagination: PaginationModel, filters?: string[]): Observable { const defaultFilter = [ 'TYPE:"content"', '-PNAME:"0/wiki"', @@ -165,7 +166,7 @@ export class CustomResourcesService { observer.error(err); observer.complete(); }); - }).pipe(catchError((err) => this.handleError(err))); + }); } /** @@ -176,7 +177,7 @@ export class CustomResourcesService { * @param where A string to restrict the returned objects by using a predicate * @returns List of favorite files */ - loadFavorites(pagination: PaginationModel, includeFields: string[] = [], where?: string): Observable { + loadFavorites(pagination: PaginationModel, includeFields: string[] = [], where?: string): Observable { const includeFieldsRequest = this.getIncludesFields(includeFields); const defaultPredicate = '(EXISTS(target/file) OR EXISTS(target/folder))'; @@ -189,7 +190,7 @@ export class CustomResourcesService { return new Observable((observer) => { this.favoritesApi.listFavorites('-me-', options) - .then((result: FavoritePaging) => { + .then((result) => { const page: FavoritePaging = { list: { entries: result.list.entries @@ -218,7 +219,7 @@ export class CustomResourcesService { observer.error(err); observer.complete(); }); - }).pipe(catchError((err) => this.handleError(err))); + }); } /** @@ -260,7 +261,7 @@ export class CustomResourcesService { observer.error(err); observer.complete(); }); - }).pipe(catchError((err) => this.handleError(err))); + }); } /** @@ -270,7 +271,7 @@ export class CustomResourcesService { * @param where A string to restrict the returned objects by using a predicate * @returns List of sites */ - loadSites(pagination: PaginationModel, where?: string): Observable { + loadSites(pagination: PaginationModel, where?: string): Observable { const options = { include: ['properties', 'aspectNames'], maxItems: pagination.maxItems, @@ -296,7 +297,7 @@ export class CustomResourcesService { observer.error(err); observer.complete(); }); - }).pipe(catchError((err) => this.handleError(err))); + }); } /** @@ -315,9 +316,7 @@ export class CustomResourcesService { skipCount: pagination.skipCount }; - return from(this.trashcanApi.listDeletedNodes(options)) - .pipe(catchError((err) => this.handleError(err))); - + return from(this.trashcanApi.listDeletedNodes(options)); } /** @@ -338,8 +337,7 @@ export class CustomResourcesService { where }; - return from(this.sharedLinksApi.listSharedLinks(options)) - .pipe(catchError((err) => this.handleError(err))); + return from(this.sharedLinksApi.listSharedLinks(options)); } /** @@ -458,9 +456,4 @@ export class CustomResourcesService { return ['path', 'properties', 'allowableOperations', 'permissions', 'aspectNames', ...includeFields] .filter((element, index, array) => index === array.indexOf(element)); } - - private handleError(error: Response) { - this.logService.error(error); - return throwError(error || 'Server error'); - } } diff --git a/lib/content-services/src/lib/document-list/services/document-list.service.ts b/lib/content-services/src/lib/document-list/services/document-list.service.ts index e968cd54fd..a10c176a61 100644 --- a/lib/content-services/src/lib/document-list/services/document-list.service.ts +++ b/lib/content-services/src/lib/document-list/services/document-list.service.ts @@ -15,14 +15,13 @@ * limitations under the License. */ -import { AlfrescoApiService, LogService, PaginationModel } from '@alfresco/adf-core'; +import { AlfrescoApiService, PaginationModel } from '@alfresco/adf-core'; import { NodesApiService } from '../../common/services/nodes-api.service'; - import { Injectable } from '@angular/core'; import { Node, NodeEntry, NodePaging, NodesApi } from '@alfresco/js-api'; import { DocumentLoaderNode } from '../models/document-folder.model'; -import { Observable, from, throwError, forkJoin } from 'rxjs'; -import { catchError, map } from 'rxjs/operators'; +import { Observable, from, forkJoin } from 'rxjs'; +import { map } from 'rxjs/operators'; import { DocumentListLoader } from '../interfaces/document-list-loader.interface'; import { CustomResourcesService } from './custom-resources.service'; @@ -41,7 +40,6 @@ export class DocumentListService implements DocumentListLoader { constructor( private nodesApiService: NodesApiService, private apiService: AlfrescoApiService, - private logService: LogService, private customResourcesService: CustomResourcesService ) {} @@ -63,7 +61,7 @@ export class DocumentListService implements DocumentListLoader { * @returns NodeEntry for the copied node */ copyNode(nodeId: string, targetParentId: string): Observable { - return from(this.nodes.copyNode(nodeId, { targetParentId })).pipe(catchError((err) => this.handleError(err))); + return from(this.nodes.copyNode(nodeId, { targetParentId })); } /** @@ -74,7 +72,7 @@ export class DocumentListService implements DocumentListLoader { * @returns NodeEntry for the moved node */ moveNode(nodeId: string, targetParentId: string): Observable { - return from(this.nodes.moveNode(nodeId, { targetParentId })).pipe(catchError((err) => this.handleError(err))); + return from(this.nodes.moveNode(nodeId, { targetParentId })); } /** @@ -119,7 +117,7 @@ export class DocumentListService implements DocumentListLoader { } } - return from(this.nodes.listNodeChildren(rootNodeId, params)).pipe(catchError((err) => this.handleError(err))); + return from(this.nodes.listNodeChildren(rootNodeId, params)); } /** @@ -159,10 +157,10 @@ export class DocumentListService implements DocumentListLoader { include: includeFieldsRequest }; - return from(this.nodes.getNode(nodeId, opts)).pipe(catchError((err) => this.handleError(err))); + return from(this.nodes.getNode(nodeId, opts)); } - isCustomSourceService(nodeId): boolean { + isCustomSourceService(nodeId: string): boolean { return this.customResourcesService.isCustomSource(nodeId); } @@ -214,9 +212,4 @@ export class DocumentListService implements DocumentListLoader { ) ]).pipe(map((results) => new DocumentLoaderNode(results[0], results[1]))); } - - private handleError(error: any) { - this.logService.error(error); - return throwError(error || 'Server error'); - } } diff --git a/lib/content-services/src/lib/new-version-uploader/new-version-uploader.service.ts b/lib/content-services/src/lib/new-version-uploader/new-version-uploader.service.ts index 66f9a742d6..226d8dae24 100644 --- a/lib/content-services/src/lib/new-version-uploader/new-version-uploader.service.ts +++ b/lib/content-services/src/lib/new-version-uploader/new-version-uploader.service.ts @@ -29,18 +29,13 @@ import { OverlayContainer } from '@angular/cdk/overlay'; providedIn: 'root' }) export class NewVersionUploaderService { - private _versionsApi: VersionsApi; get versionsApi(): VersionsApi { this._versionsApi = this._versionsApi ?? new VersionsApi(this.apiService.getInstance()); return this._versionsApi; } - constructor( - private apiService: AlfrescoApiService, - private dialog: MatDialog, - private overlayContainer: OverlayContainer - ) { } + constructor(private apiService: AlfrescoApiService, private dialog: MatDialog, private overlayContainer: OverlayContainer) {} /** * Open a dialog NewVersionUploaderDialogComponent to display: @@ -53,7 +48,11 @@ export class NewVersionUploaderService { * @param selectorAutoFocusedOnClose element's selector which should be autofocused after closing modal * @returns an Observable represents the triggered dialog action or an error in case of an error condition */ - openUploadNewVersionDialog(data: NewVersionUploaderDialogData, config?: MatDialogConfig, selectorAutoFocusedOnClose?: string) { + openUploadNewVersionDialog( + data: NewVersionUploaderDialogData, + config?: MatDialogConfig, + selectorAutoFocusedOnClose?: string + ): Observable { const { file, node, showVersionsOnly } = data; const showComments = true; const allowDownload = true; @@ -66,11 +65,10 @@ export class NewVersionUploaderService { width: '630px', ...(config && Object.keys(config).length > 0 && config) }); - dialogRef.componentInstance.dialogAction.asObservable() - .subscribe((newVersionUploaderData: NewVersionUploaderData) => { - observer.next(newVersionUploaderData); - }); - dialogRef.componentInstance.uploadError.asObservable().subscribe(error => { + dialogRef.componentInstance.dialogAction.asObservable().subscribe((newVersionUploaderData) => { + observer.next(newVersionUploaderData); + }); + dialogRef.componentInstance.uploadError.asObservable().subscribe((error) => { observer.error(error); }); dialogRef.afterClosed().subscribe(() => { @@ -80,7 +78,6 @@ export class NewVersionUploaderService { this.overlayContainer.getContainerElement().setAttribute('role', 'main'); }); }); - } private composePanelClass(showVersionsOnly: boolean): string | string[] { @@ -90,7 +87,7 @@ export class NewVersionUploaderService { private static focusOnClose(selectorAutoFocusedOnClose: string): void { if (selectorAutoFocusedOnClose) { - document.querySelector(selectorAutoFocusedOnClose).focus(); + document.querySelector(selectorAutoFocusedOnClose)?.focus(); } } } diff --git a/lib/content-services/src/lib/node-comments/services/node-comments.service.ts b/lib/content-services/src/lib/node-comments/services/node-comments.service.ts index a4263018bb..1055c513e0 100644 --- a/lib/content-services/src/lib/node-comments/services/node-comments.service.ts +++ b/lib/content-services/src/lib/node-comments/services/node-comments.service.ts @@ -15,100 +15,72 @@ * limitations under the License. */ -import { - AlfrescoApiService, - LogService, - CommentModel, - CommentsService, - User -} from '@alfresco/adf-core'; +import { AlfrescoApiService, CommentModel, CommentsService, User } from '@alfresco/adf-core'; import { CommentEntry, CommentsApi, Comment } from '@alfresco/js-api'; import { Injectable } from '@angular/core'; -import { Observable, from, throwError } from 'rxjs'; -import { map, catchError } from 'rxjs/operators'; -import { ContentService } from '../../common/services/content.service'; +import { Observable, from } from 'rxjs'; +import { map } from 'rxjs/operators'; +import { ContentService } from '../../common/services/content.service'; @Injectable({ - providedIn: 'root' + providedIn: 'root' }) export class NodeCommentsService implements CommentsService { + private _commentsApi: CommentsApi; + get commentsApi(): CommentsApi { + this._commentsApi = this._commentsApi ?? new CommentsApi(this.apiService.getInstance()); + return this._commentsApi; + } - private _commentsApi: CommentsApi; - get commentsApi(): CommentsApi { - this._commentsApi = this._commentsApi ?? new CommentsApi(this.apiService.getInstance()); - return this._commentsApi; - } + constructor(private apiService: AlfrescoApiService, private contentService: ContentService) {} - constructor( - private apiService: AlfrescoApiService, - private logService: LogService, - private contentService: ContentService - ) {} + /** + * Gets all comments that have been added to a task. + * + * @param id ID of the target task + * @returns Details for each comment + */ + get(id: string): Observable { + return from(this.commentsApi.listComments(id)).pipe( + map((response) => { + const comments: CommentModel[] = []; - /** - * Gets all comments that have been added to a task. - * - * @param id ID of the target task - * @returns Details for each comment - */ - get(id: string): Observable { - return from(this.commentsApi.listComments(id)) - .pipe( - map((response) => { - const comments: CommentModel[] = []; + response.list.entries.forEach((comment: CommentEntry) => { + this.addToComments(comments, comment); + }); - response.list.entries.forEach((comment: CommentEntry) => { - this.addToComments(comments, comment); - }); + return comments; + }) + ); + } - return comments; - }), - catchError( - (err: any) => this.handleError(err) - ) - ); - } + /** + * Adds a comment to a task. + * + * @param id ID of the target task + * @param message Text for the comment + * @returns Details about the comment + */ + add(id: string, message: string): Observable { + return from(this.commentsApi.createComment(id, { content: message })).pipe(map((response) => this.newCommentModel(response.entry))); + } - /** - * Adds a comment to a task. - * - * @param id ID of the target task - * @param message Text for the comment - * @returns Details about the comment - */ - add(id: string, message: string): Observable { - return from(this.commentsApi.createComment(id, { content: message })) - .pipe( - map( - (response: CommentEntry) => this.newCommentModel(response.entry) - ), - catchError( - (err: any) => this.handleError(err) - ) - ); - } + private addToComments(comments: CommentModel[], comment: CommentEntry): void { + const newComment: Comment = comment.entry; - private addToComments(comments: CommentModel[], comment: CommentEntry): void { - const newComment: Comment = comment.entry; + comments.push(this.newCommentModel(newComment)); + } - comments.push(this.newCommentModel(newComment)); - } + private newCommentModel(comment: Comment): CommentModel { + return new CommentModel({ + id: comment.id, + message: comment.content, + created: comment.createdAt, + createdBy: new User(comment.createdBy) + }); + } - private newCommentModel(comment: Comment): CommentModel { - return new CommentModel({ - id: comment.id, - message: comment.content, - created: comment.createdAt, - createdBy: new User(comment.createdBy) - }); - } - - private handleError(error: any) { - this.logService.error(error); - return throwError(error || 'Server error'); - } - - getUserImage(avatarId: string): string { - return this.contentService.getContentUrl(avatarId); - } + getUserImage(avatarId: string): string { + return this.contentService.getContentUrl(avatarId); + } } diff --git a/lib/content-services/src/lib/search/services/search.service.ts b/lib/content-services/src/lib/search/services/search.service.ts index ac1640208a..b9fc53fcc1 100644 --- a/lib/content-services/src/lib/search/services/search.service.ts +++ b/lib/content-services/src/lib/search/services/search.service.ts @@ -17,7 +17,7 @@ import { Injectable } from '@angular/core'; import { NodePaging, QueriesApi, SearchRequest, ResultSetPaging, SearchApi } from '@alfresco/js-api'; -import { Observable, Subject, from, throwError } from 'rxjs'; +import { Observable, Subject, from } from 'rxjs'; import { AlfrescoApiService } from '@alfresco/adf-core'; import { SearchConfigurationService } from './search-configuration.service'; @@ -25,7 +25,7 @@ import { SearchConfigurationService } from './search-configuration.service'; providedIn: 'root' }) export class SearchService { - dataLoaded: Subject = new Subject(); + dataLoaded = new Subject(); private _queriesApi: QueriesApi; get queriesApi(): QueriesApi { @@ -54,8 +54,7 @@ export class SearchService { promise .then((nodePaging) => { this.dataLoaded.next(nodePaging); - }) - .catch((err) => this.handleError(err)); + }); return from(promise); } @@ -75,8 +74,7 @@ export class SearchService { promise .then((nodePaging) => { this.dataLoaded.next(nodePaging); - }) - .catch((err) => this.handleError(err)); + }); return from(promise); } @@ -93,15 +91,10 @@ export class SearchService { promise .then((nodePaging) => { this.dataLoaded.next(nodePaging); - }) - .catch((err) => this.handleError(err)); + }); return from(promise); } - - private handleError(error: any): Observable { - return throwError(error || 'Server error'); - } } export interface SearchOptions { diff --git a/lib/content-services/src/lib/social/services/rating.service.ts b/lib/content-services/src/lib/social/services/rating.service.ts index 25f0b770c1..5e745c75d8 100644 --- a/lib/content-services/src/lib/social/services/rating.service.ts +++ b/lib/content-services/src/lib/social/services/rating.service.ts @@ -15,11 +15,10 @@ * limitations under the License. */ -import { AlfrescoApiService, LogService } from '@alfresco/adf-core'; +import { AlfrescoApiService } from '@alfresco/adf-core'; import { Injectable } from '@angular/core'; import { RatingEntry, RatingBody, RatingsApi } from '@alfresco/js-api'; -import { from, throwError, Observable } from 'rxjs'; -import { catchError } from 'rxjs/operators'; +import { from, Observable } from 'rxjs'; import { RatingServiceInterface } from './rating.service.interface'; @Injectable({ @@ -33,7 +32,7 @@ export class RatingService implements RatingServiceInterface { return this._ratingsApi; } - constructor(private apiService: AlfrescoApiService, private logService: LogService) { + constructor(private apiService: AlfrescoApiService) { } /** @@ -44,10 +43,7 @@ export class RatingService implements RatingServiceInterface { * @returns The rating value */ getRating(nodeId: string, ratingType: any): Observable { - return from(this.ratingsApi.getRating(nodeId, ratingType)) - .pipe( - catchError(this.handleError) - ); + return from(this.ratingsApi.getRating(nodeId, ratingType)); } /** @@ -63,10 +59,7 @@ export class RatingService implements RatingServiceInterface { id: ratingType, myRating: vote }); - return from(this.ratingsApi.createRating(nodeId, ratingBody)) - .pipe( - catchError(this.handleError) - ); + return from(this.ratingsApi.createRating(nodeId, ratingBody)); } /** @@ -77,14 +70,6 @@ export class RatingService implements RatingServiceInterface { * @returns Null response indicating that the operation is complete */ deleteRating(nodeId: string, ratingType: any): Observable { - return from(this.ratingsApi.deleteRating(nodeId, ratingType)) - .pipe( - catchError(this.handleError) - ); - } - - private handleError(error: any): any { - this.logService.error(error); - return throwError(error || 'Server error'); + return from(this.ratingsApi.deleteRating(nodeId, ratingType)); } } diff --git a/lib/insights/src/lib/diagram/services/diagrams.service.ts b/lib/insights/src/lib/diagram/services/diagrams.service.ts index 1f103d55fa..af093e2d16 100644 --- a/lib/insights/src/lib/diagram/services/diagrams.service.ts +++ b/lib/insights/src/lib/diagram/services/diagrams.service.ts @@ -15,41 +15,26 @@ * limitations under the License. */ -import { AlfrescoApiService, LogService } from '@alfresco/adf-core'; +import { AlfrescoApiService } from '@alfresco/adf-core'; import { Injectable } from '@angular/core'; -import { Observable, from, throwError } from 'rxjs'; -import { catchError } from 'rxjs/operators'; +import { Observable, from } from 'rxjs'; import { ModelJsonBpmnApi } from '@alfresco/js-api'; @Injectable({ providedIn: 'root' }) export class DiagramsService { - private _modelJsonBpmnApi: ModelJsonBpmnApi; get modelJsonBpmnApi(): ModelJsonBpmnApi { this._modelJsonBpmnApi = this._modelJsonBpmnApi ?? new ModelJsonBpmnApi(this.apiService.getInstance()); return this._modelJsonBpmnApi; } - constructor(private apiService: AlfrescoApiService, - private logService: LogService) { - } + constructor(private apiService: AlfrescoApiService) {} getProcessDefinitionModel(processDefinitionId: string): Observable { - return from(this.modelJsonBpmnApi.getModelJSON(processDefinitionId)) - .pipe( - catchError((err) => this.handleError(err)) - ); + return from(this.modelJsonBpmnApi.getModelJSON(processDefinitionId)); } getRunningProcessDefinitionModel(processInstanceId: string): Observable { - return from(this.modelJsonBpmnApi.getModelJSONForProcessDefinition(processInstanceId)) - .pipe( - catchError((err) => this.handleError(err)) - ); - } - - private handleError(error: any) { - this.logService.error(error); - return throwError(error || 'Server error'); + return from(this.modelJsonBpmnApi.getModelJSONForProcessDefinition(processInstanceId)); } } diff --git a/lib/process-services-cloud/src/lib/app/services/apps-process-cloud.service.ts b/lib/process-services-cloud/src/lib/app/services/apps-process-cloud.service.ts index 7a9d415431..ded241a64e 100644 --- a/lib/process-services-cloud/src/lib/app/services/apps-process-cloud.service.ts +++ b/lib/process-services-cloud/src/lib/app/services/apps-process-cloud.service.ts @@ -16,9 +16,9 @@ */ import { Injectable } from '@angular/core'; -import { Observable, from, throwError, of } from 'rxjs'; -import { map, catchError } from 'rxjs/operators'; -import { AppConfigService, LogService } from '@alfresco/adf-core'; +import { Observable, from, of } from 'rxjs'; +import { map } from 'rxjs/operators'; +import { AppConfigService } from '@alfresco/adf-core'; import { ApplicationInstanceModel } from '../models/application-instance.model'; import { Environment } from '../../common/interface/environment.interface'; import { AdfHttpClient } from '@alfresco/adf-core/api'; @@ -26,13 +26,9 @@ import { RequestOptions } from '@alfresco/js-api'; @Injectable({ providedIn: 'root' }) export class AppsProcessCloudService { - deployedApps: ApplicationInstanceModel[]; - constructor( - private adfHttpClient: AdfHttpClient, - private logService: LogService, - private appConfigService: AppConfigService) { + constructor(private adfHttpClient: AdfHttpClient, private appConfigService: AppConfigService) { this.loadApps(); } @@ -76,7 +72,7 @@ export class AppsProcessCloudService { } const path = this.getApplicationUrl(); const pathParams = {}; - const queryParams = { status, roles : role, sort: 'name' }; + const queryParams = { status, roles: role, sort: 'name' }; const httpMethod = 'GET'; const headerParams = {}; const formParams = {}; @@ -95,19 +91,12 @@ export class AppsProcessCloudService { httpMethod }; - return from(this.adfHttpClient.request(path, requestOptions)) - .pipe( - map((applications: any) => applications.list.entries.map((application) => application.entry)), - catchError((err) => this.handleError(err)) - ); + return from(this.adfHttpClient.request(path, requestOptions)).pipe( + map((applications) => applications.list.entries.map((application) => application.entry)) + ); } private getApplicationUrl(): string { return `${this.appConfigService.get('bpmHost')}/deployment-service/v1/applications`; } - - private handleError(error?: any) { - this.logService.error(error); - return throwError(error || 'Server error'); - } } diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.spec.ts b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.spec.ts index 6dd0b71aaa..5ea0dbe8c2 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.spec.ts @@ -877,7 +877,7 @@ describe('AttachFileCloudWidgetComponent', () => { notificationService = TestBed.inject(NotificationService); newVersionUploaderService = TestBed.inject(NewVersionUploaderService); spyOnOpenUploadNewVersionDialog = spyOn(newVersionUploaderService, 'openUploadNewVersionDialog').and.returnValue( - of({ action: NewVersionUploaderDataAction.refresh }) + of({ action: NewVersionUploaderDataAction.refresh } as any) ); spyOnReplaceOldFileVersionWithNew = spyOn(widget, 'replaceOldFileVersionWithNew'); spyOnShowError = spyOn(notificationService, 'showError'); diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.ts b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.ts index 13f17aa618..6e1a26c4f7 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.ts @@ -35,7 +35,7 @@ import { ContentCloudNodeSelectorService } from '../../../services/content-cloud import { ProcessCloudContentService } from '../../../services/process-cloud-content.service'; import { UploadCloudWidgetComponent } from './upload-cloud.widget'; import { DestinationFolderPathModel, DestinationFolderPathType } from '../../../models/form-cloud-representation.model'; -import { ContentNodeSelectorPanelService, NewVersionUploaderData, NewVersionUploaderDataAction, NewVersionUploaderDialogData, NewVersionUploaderService, VersionManagerUploadData } from '@alfresco/adf-content-services'; +import { ContentNodeSelectorPanelService, NewVersionUploaderDataAction, NewVersionUploaderDialogData, NewVersionUploaderService, VersionManagerUploadData } from '@alfresco/adf-content-services'; export const RETRIEVE_METADATA_OPTION = 'retrieveMetadata'; export const ALIAS_ROOT_FOLDER = '-root-'; @@ -65,7 +65,7 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i rootNodeId = ALIAS_USER_FOLDER; selectedNode: Node; - _nodesApi: NodesApi; + private _nodesApi: NodesApi; get nodesApi(): NodesApi { this._nodesApi = this._nodesApi ?? new NodesApi(this.apiService.getInstance()); return this._nodesApi; @@ -214,7 +214,7 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i } onUploadNewFileVersion(node: NewVersionUploaderDialogData): void { - this.newVersionUploaderService.openUploadNewVersionDialog(node).subscribe((newVersionUploaderData: NewVersionUploaderData) => { + this.newVersionUploaderService.openUploadNewVersionDialog(node).subscribe((newVersionUploaderData) => { if (newVersionUploaderData.action === NewVersionUploaderDataAction.upload) { this.replaceOldFileVersionWithNew(newVersionUploaderData as VersionManagerUploadData); } diff --git a/lib/process-services-cloud/src/lib/form/services/process-cloud-content.service.ts b/lib/process-services-cloud/src/lib/form/services/process-cloud-content.service.ts index c101de3d1b..ccbb4c99dc 100644 --- a/lib/process-services-cloud/src/lib/form/services/process-cloud-content.service.ts +++ b/lib/process-services-cloud/src/lib/form/services/process-cloud-content.service.ts @@ -16,9 +16,9 @@ */ import { Injectable } from '@angular/core'; -import { throwError, Observable, from } from 'rxjs'; -import { catchError, map } from 'rxjs/operators'; -import { AlfrescoApiService, LogService, DownloadService } from '@alfresco/adf-core'; +import { Observable, from } from 'rxjs'; +import { map } from 'rxjs/operators'; +import { AlfrescoApiService, DownloadService } from '@alfresco/adf-core'; import { ContentService, NodesApiService } from '@alfresco/adf-content-services'; import { AuthenticationApi, Node, UploadApi } from '@alfresco/js-api'; @@ -40,7 +40,6 @@ export class ProcessCloudContentService { constructor( private apiService: AlfrescoApiService, - private logService: LogService, private nodesApiService: NodesApiService, private contentService: ContentService, private downloadService: DownloadService @@ -51,8 +50,7 @@ export class ProcessCloudContentService { map((res: any) => ({ ...res.entry, nodeId: res.entry.id - })), - catchError((err) => this.handleError(err)) + })) ); } @@ -75,9 +73,4 @@ export class ProcessCloudContentService { const ticket = await this.authenticationApi.getTicket(); return ticket?.entry?.id || ''; } - - private handleError(error: any) { - this.logService.error(error); - return throwError(error || 'Server error'); - } } diff --git a/lib/process-services-cloud/src/lib/group/services/identity-group.service.ts b/lib/process-services-cloud/src/lib/group/services/identity-group.service.ts index d7b69f6af3..46aaa35f47 100644 --- a/lib/process-services-cloud/src/lib/group/services/identity-group.service.ts +++ b/lib/process-services-cloud/src/lib/group/services/identity-group.service.ts @@ -17,8 +17,7 @@ import { Injectable } from '@angular/core'; import { AppConfigService, OAuth2Service } from '@alfresco/adf-core'; -import { EMPTY, Observable, throwError } from 'rxjs'; -import { catchError } from 'rxjs/operators'; +import { EMPTY, Observable } from 'rxjs'; import { IdentityGroupServiceInterface } from './identity-group.service.interface'; import { IdentityGroupFilterInterface } from './identity-group-filter.interface'; import { IdentityGroupModel } from '../models/identity-group.model'; @@ -50,25 +49,19 @@ export class IdentityGroupService implements IdentityGroupServiceInterface { private searchGroupsByName(name: string): Observable { this.buildQueryParam(name); - return this.invokeIdentityGroupApi().pipe( - catchError((err) => this.handleError(err)) - ); + return this.invokeIdentityGroupApi(); } private searchGroupsWithGlobalRoles(name: string, roles: string []): Observable { this.buildQueryParam(name, roles); - return this.invokeIdentityGroupApi().pipe( - catchError((err) => this.handleError(err)) - ); + return this.invokeIdentityGroupApi(); } private searchGroupsWithinApp(name: string, applicationName: string, roles?: string []): Observable { this.buildQueryParam(name, roles, applicationName); - return this.invokeIdentityGroupApi().pipe( - catchError((err) => this.handleError(err)) - ); + return this.invokeIdentityGroupApi(); } private invokeIdentityGroupApi(): Observable { @@ -101,10 +94,6 @@ export class IdentityGroupService implements IdentityGroupServiceInterface { return roles.filter( role => role.trim() ? true : false); } - private handleError(error: any) { - return throwError(error || 'Server error'); - } - private get identityHost(): string { return `${this.appConfigService.get('bpmHost')}`; } diff --git a/lib/process-services-cloud/src/lib/people/services/identity-user.service.ts b/lib/process-services-cloud/src/lib/people/services/identity-user.service.ts index 131f25b245..e0020bb720 100644 --- a/lib/process-services-cloud/src/lib/people/services/identity-user.service.ts +++ b/lib/process-services-cloud/src/lib/people/services/identity-user.service.ts @@ -16,13 +16,8 @@ */ import { Injectable } from '@angular/core'; -import { - AppConfigService, - JwtHelperService, - OAuth2Service -} from '@alfresco/adf-core'; -import { EMPTY, Observable, throwError } from 'rxjs'; -import { catchError } from 'rxjs/operators'; +import { AppConfigService, JwtHelperService, OAuth2Service } from '@alfresco/adf-core'; +import { EMPTY, Observable } from 'rxjs'; import { IdentityUserServiceInterface } from './identity-user.service.interface'; import { IdentityUserModel } from '../models/identity-user.model'; import { IdentityUserFilterInterface } from './identity-user-filter.interface'; @@ -33,15 +28,9 @@ const IDENTITY_MICRO_SERVICE_INGRESS = 'identity-adapter-service'; providedIn: 'root' }) export class IdentityUserService implements IdentityUserServiceInterface { - queryParams: { search: string; application?: string; roles?: string[]; groups?: string[] }; - constructor( - private jwtHelperService: JwtHelperService, - private oAuth2Service: OAuth2Service, - private appConfigService: AppConfigService) { - - } + constructor(private jwtHelperService: JwtHelperService, private oAuth2Service: OAuth2Service, private appConfigService: AppConfigService) {} /** * Gets the name and other basic details of the current user. @@ -80,33 +69,25 @@ export class IdentityUserService implements IdentityUserServiceInterface { private searchUsersByName(name: string): Observable { this.buildQueryParam(name); - return this.invokeIdentityUserApi().pipe( - catchError((err) => this.handleError(err)) - ); + return this.invokeIdentityUserApi(); } - private searchUsersWithGlobalRoles(name: string, roles: string []): Observable { - this.buildQueryParam(name, {roles}); + private searchUsersWithGlobalRoles(name: string, roles: string[]): Observable { + this.buildQueryParam(name, { roles }); - return this.invokeIdentityUserApi().pipe( - catchError((err) => this.handleError(err)) - ); + return this.invokeIdentityUserApi(); } - private searchUsersWithinApp(name: string, withinApplication: string, roles?: string []): Observable { - this.buildQueryParam(name, {roles, withinApplication}); + private searchUsersWithinApp(name: string, withinApplication: string, roles?: string[]): Observable { + this.buildQueryParam(name, { roles, withinApplication }); - return this.invokeIdentityUserApi().pipe( - catchError((err) => this.handleError(err)) - ); + return this.invokeIdentityUserApi(); } private searchUsersWithGroups(name: string, filters: IdentityUserFilterInterface): Observable { this.buildQueryParam(name, filters); - return this.invokeIdentityUserApi().pipe( - catchError((err) => this.handleError(err)) - ); + return this.invokeIdentityUserApi(); } private invokeIdentityUserApi(): Observable { @@ -121,7 +102,7 @@ export class IdentityUserService implements IdentityUserServiceInterface { this.addOptionalCommaValueToQueryParam('group', filters?.groups); } - private addOptionalCommaValueToQueryParam(key: string, values: string []) { + private addOptionalCommaValueToQueryParam(key: string, values: string[]) { if (values?.length > 0) { const valuesNotEmpty = this.filterOutEmptyValue(values); if (valuesNotEmpty?.length > 0) { @@ -136,15 +117,11 @@ export class IdentityUserService implements IdentityUserServiceInterface { } } - private filterOutEmptyValue(values: string []): string [] { - return values.filter( value => value.trim() ? true : false); + private filterOutEmptyValue(values: string[]): string[] { + return values.filter((value) => value.trim()); } private get identityHost(): string { return `${this.appConfigService.get('bpmHost')}`; } - - private handleError(error: any) { - return throwError(error || 'Server error'); - } } diff --git a/lib/process-services/src/lib/app-list/services/apps-process.service.ts b/lib/process-services/src/lib/app-list/services/apps-process.service.ts index 6544f7153c..10cd0be66b 100644 --- a/lib/process-services/src/lib/app-list/services/apps-process.service.ts +++ b/lib/process-services/src/lib/app-list/services/apps-process.service.ts @@ -17,24 +17,21 @@ import { Injectable } from '@angular/core'; import { RuntimeAppDefinitionsApi, AppDefinitionRepresentation } from '@alfresco/js-api'; -import { Observable, from, throwError } from 'rxjs'; -import { AlfrescoApiService, LogService } from '@alfresco/adf-core'; -import { map, catchError } from 'rxjs/operators'; +import { Observable, from } from 'rxjs'; +import { AlfrescoApiService } from '@alfresco/adf-core'; +import { map } from 'rxjs/operators'; @Injectable({ providedIn: 'root' }) export class AppsProcessService { - private _appsApi: RuntimeAppDefinitionsApi; get appsApi(): RuntimeAppDefinitionsApi { this._appsApi = this._appsApi ?? new RuntimeAppDefinitionsApi(this.apiService.getInstance()); return this._appsApi; } - constructor(private apiService: AlfrescoApiService, - private logService: LogService) { - } + constructor(private apiService: AlfrescoApiService) {} /** * Gets a list of deployed apps for this user. @@ -42,11 +39,7 @@ export class AppsProcessService { * @returns The list of deployed apps */ getDeployedApplications(): Observable { - return from(this.appsApi.getAppDefinitions()) - .pipe( - map((response: any) => response.data), - catchError((err) => this.handleError(err)) - ); + return from(this.appsApi.getAppDefinitions()).pipe(map((response) => response.data)); } /** @@ -56,11 +49,7 @@ export class AppsProcessService { * @returns The list of deployed apps */ getDeployedApplicationsByName(name: string): Observable { - return from(this.appsApi.getAppDefinitions()) - .pipe( - map((response: any) => response.data.find((app) => app.name === name)), - catchError((err) => this.handleError(err)) - ); + return from(this.appsApi.getAppDefinitions()).pipe(map((response) => response.data.find((app) => app.name === name))); } /** @@ -70,16 +59,6 @@ export class AppsProcessService { * @returns Details of the app */ getApplicationDetailsById(appId: number): Observable { - return from(this.appsApi.getAppDefinitions()) - .pipe( - map((response: any) => response.data.find((app) => app.id === appId)), - catchError((err) => this.handleError(err)) - ); + return from(this.appsApi.getAppDefinitions()).pipe(map((response) => response.data.find((app) => app.id === appId))); } - - private handleError(error: any) { - this.logService.error(error); - return throwError(error || 'Server error'); - } - } diff --git a/lib/process-services/src/lib/process-comments/services/comment-process.service.ts b/lib/process-services/src/lib/process-comments/services/comment-process.service.ts index f65bea2563..6fedc59666 100644 --- a/lib/process-services/src/lib/process-comments/services/comment-process.service.ts +++ b/lib/process-services/src/lib/process-comments/services/comment-process.service.ts @@ -16,9 +16,9 @@ */ import { Injectable } from '@angular/core'; -import { Observable, from, throwError } from 'rxjs'; -import { CommentModel, AlfrescoApiService, LogService, CommentsService, User } from '@alfresco/adf-core'; -import { map, catchError } from 'rxjs/operators'; +import { Observable, from } from 'rxjs'; +import { CommentModel, AlfrescoApiService, CommentsService, User } from '@alfresco/adf-core'; +import { map } from 'rxjs/operators'; import { ActivitiCommentsApi } from '@alfresco/js-api'; import { PeopleProcessService } from '../../common/services/people-process.service'; import { UserProcessModel } from '../../common/models/user-process.model'; @@ -27,18 +27,13 @@ import { UserProcessModel } from '../../common/models/user-process.model'; providedIn: 'root' }) export class CommentProcessService implements CommentsService { - private _commentsApi: ActivitiCommentsApi; get commentsApi(): ActivitiCommentsApi { this._commentsApi = this._commentsApi ?? new ActivitiCommentsApi(this.apiService.getInstance()); return this._commentsApi; } - constructor(private apiService: AlfrescoApiService, - private logService: LogService, - private peopleProcessService: PeopleProcessService - ) { - } + constructor(private apiService: AlfrescoApiService, private peopleProcessService: PeopleProcessService) {} /** * Gets all comments that have been added to a process instance. @@ -47,23 +42,23 @@ export class CommentProcessService implements CommentsService { * @returns Details for each comment */ get(id: string): Observable { - return from(this.commentsApi.getProcessInstanceComments(id)) - .pipe( - map((response) => { - const comments: CommentModel[] = []; - response.data.forEach((comment) => { - const user = new UserProcessModel(comment.createdBy); - comments.push(new CommentModel({ + return from(this.commentsApi.getProcessInstanceComments(id)).pipe( + map((response) => { + const comments: CommentModel[] = []; + response.data.forEach((comment) => { + const user = new UserProcessModel(comment.createdBy); + comments.push( + new CommentModel({ id: comment.id, message: comment.message, created: comment.created, createdBy: new User(user) - })); - }); - return comments; - }), - catchError((err: any) => this.handleError(err)) - ); + }) + ); + }); + return comments; + }) + ); } /** @@ -74,24 +69,19 @@ export class CommentProcessService implements CommentsService { * @returns Details of the comment added */ add(id: string, message: string): Observable { - return from( - this.commentsApi.addProcessInstanceComment({ message }, id) - ).pipe( - map((response) => new CommentModel({ - id: response.id, - message: response.message, - created: response.created, - createdBy: new User(response.createdBy) - })), - catchError((err: any) => this.handleError(err)) + return from(this.commentsApi.addProcessInstanceComment({ message }, id)).pipe( + map( + (response) => + new CommentModel({ + id: response.id, + message: response.message, + created: response.created, + createdBy: new User(response.createdBy) + }) + ) ); } - private handleError(error: any) { - this.logService.error(error); - return throwError(error || 'Server error'); - } - getUserImage(user: UserProcessModel): string { return this.peopleProcessService.getUserImage(user); } diff --git a/lib/process-services/src/lib/task-comments/services/task-comments.service.ts b/lib/process-services/src/lib/task-comments/services/task-comments.service.ts index 12b9c5f87a..75371c9a6f 100644 --- a/lib/process-services/src/lib/task-comments/services/task-comments.service.ts +++ b/lib/process-services/src/lib/task-comments/services/task-comments.service.ts @@ -18,97 +18,77 @@ import { AlfrescoApiService, CommentModel, CommentsService, User } from '@alfresco/adf-core'; import { ActivitiCommentsApi, CommentRepresentation } from '@alfresco/js-api'; import { Injectable } from '@angular/core'; -import { from, Observable, throwError } from 'rxjs'; -import { catchError, map } from 'rxjs/operators'; +import { from, Observable } from 'rxjs'; +import { map } from 'rxjs/operators'; import { UserProcessModel } from '../../common/models/user-process.model'; import { PeopleProcessService } from '../../common/services/people-process.service'; @Injectable({ - providedIn: 'root' + providedIn: 'root' }) export class TaskCommentsService implements CommentsService { + private _commentsApi: ActivitiCommentsApi; + get commentsApi(): ActivitiCommentsApi { + this._commentsApi = this._commentsApi ?? new ActivitiCommentsApi(this.apiService.getInstance()); + return this._commentsApi; + } - private _commentsApi: ActivitiCommentsApi; - get commentsApi(): ActivitiCommentsApi { - this._commentsApi = this._commentsApi ?? new ActivitiCommentsApi(this.apiService.getInstance()); - return this._commentsApi; - } + constructor(private apiService: AlfrescoApiService, private peopleProcessService: PeopleProcessService) {} - constructor( - private apiService: AlfrescoApiService, - private peopleProcessService: PeopleProcessService - ) {} + /** + * Gets all comments that have been added to a task. + * + * @param id ID of the target task + * @returns Details for each comment + */ + get(id: string): Observable { + return from(this.commentsApi.getTaskComments(id)).pipe( + map((response) => { + const comments: CommentModel[] = []; - /** - * Gets all comments that have been added to a task. - * - * @param id ID of the target task - * @returns Details for each comment - */ - get(id: string): Observable { - return from(this.commentsApi.getTaskComments(id)) - .pipe( - map((response) => { - const comments: CommentModel[] = []; + response.data.forEach((comment) => { + this.addToComments(comments, comment); + }); - response.data.forEach((comment: CommentRepresentation) => { - this.addToComments(comments, comment); - }); + return comments; + }) + ); + } - return comments; - }), - catchError( - (err: any) => this.handleError(err) - ) - ); - } + /** + * Adds a comment to a task. + * + * @param id ID of the target task + * @param message Text for the comment + * @returns Details about the comment + */ + add(id: string, message: string): Observable { + return from(this.commentsApi.addTaskComment({ message }, id)).pipe(map((response) => this.newCommentModel(response))); + } - /** - * Adds a comment to a task. - * - * @param id ID of the target task - * @param message Text for the comment - * @returns Details about the comment - */ - add(id: string, message: string): Observable { - return from(this.commentsApi.addTaskComment({ message }, id)) - .pipe( - map( - (response: CommentRepresentation) => this.newCommentModel(response) - ), - catchError( - (err: any) => this.handleError(err) - ) - ); - } + private addToComments(comments: CommentModel[], comment: CommentRepresentation): void { + const user = new UserProcessModel(comment.createdBy); - private addToComments(comments: CommentModel[], comment: CommentRepresentation): void { - const user = new UserProcessModel(comment.createdBy); + const newComment: CommentRepresentation = { + id: comment.id, + message: comment.message, + created: comment.created, + createdBy: user + }; - const newComment: CommentRepresentation = { - id: comment.id, - message: comment.message, - created: comment.created, - createdBy: user - }; + comments.push(this.newCommentModel(newComment)); + } - comments.push(this.newCommentModel(newComment)); - } + private newCommentModel(representation: CommentRepresentation): CommentModel { + return new CommentModel({ + id: representation.id, + message: representation.message, + created: representation.created, + createdBy: new User(representation.createdBy) + }); + } - private newCommentModel(representation: CommentRepresentation): CommentModel { - return new CommentModel({ - id: representation.id, - message: representation.message, - created: representation.created, - createdBy: new User(representation.createdBy) - }); - } - - private handleError(error: any) { - return throwError(error || 'Server error'); - } - - getUserImage(user: UserProcessModel): string { - return this.peopleProcessService.getUserImage(user); - } + getUserImage(user: UserProcessModel): string { + return this.peopleProcessService.getUserImage(user); + } } diff --git a/lib/process-services/src/lib/task-list/services/process-upload.service.ts b/lib/process-services/src/lib/task-list/services/process-upload.service.ts index 50426f600e..3da7e8b58e 100644 --- a/lib/process-services/src/lib/task-list/services/process-upload.service.ts +++ b/lib/process-services/src/lib/task-list/services/process-upload.service.ts @@ -15,17 +15,15 @@ * limitations under the License. */ -import { AlfrescoApiService, AppConfigService} from '@alfresco/adf-core'; +import { AlfrescoApiService, AppConfigService } from '@alfresco/adf-core'; import { DiscoveryApiService, UploadService } from '@alfresco/adf-content-services'; -import { ActivitiContentApi } from '@alfresco/js-api'; +import { ActivitiContentApi, RelatedContentRepresentation } from '@alfresco/js-api'; import { Injectable } from '@angular/core'; -import { throwError } from 'rxjs'; @Injectable({ providedIn: 'root' }) export class ProcessUploadService extends UploadService { - private _contentApi: ActivitiContentApi; get contentApi(): ActivitiContentApi { this._contentApi = this._contentApi ?? new ActivitiContentApi(this.apiService.getInstance()); @@ -36,20 +34,11 @@ export class ProcessUploadService extends UploadService { super(apiService, appConfigService, discoveryApiService); } - getUploadPromise(file: any): any { + getUploadPromise(file: any): Promise { const opts = { isRelatedContent: true }; const processInstanceId = file.options.parentId; - const promise = this.contentApi.createRelatedContentOnProcessInstance(processInstanceId, file.file, opts); - - promise.catch((err) => this.handleError(err)); - - return promise; + return this.contentApi.createRelatedContentOnProcessInstance(processInstanceId, file.file, opts); } - - private handleError(error: any) { - return throwError(error || 'Server error'); - } - } diff --git a/lib/process-services/src/lib/task-list/services/task-filter.service.ts b/lib/process-services/src/lib/task-list/services/task-filter.service.ts index c8ef7a9071..67617c082c 100644 --- a/lib/process-services/src/lib/task-list/services/task-filter.service.ts +++ b/lib/process-services/src/lib/task-list/services/task-filter.service.ts @@ -15,27 +15,24 @@ * limitations under the License. */ -import { AlfrescoApiService, LogService } from '@alfresco/adf-core'; +import { AlfrescoApiService } from '@alfresco/adf-core'; import { Injectable } from '@angular/core'; -import { Observable, forkJoin, from, throwError } from 'rxjs'; +import { Observable, forkJoin, from } from 'rxjs'; import { FilterRepresentationModel } from '../models/filter.model'; -import { map, catchError } from 'rxjs/operators'; +import { map } from 'rxjs/operators'; import { UserFiltersApi } from '@alfresco/js-api'; @Injectable({ providedIn: 'root' }) export class TaskFilterService { - private _userFiltersApi: UserFiltersApi; get userFiltersApi(): UserFiltersApi { this._userFiltersApi = this._userFiltersApi ?? new UserFiltersApi(this.apiService.getInstance()); return this._userFiltersApi; } - constructor(private apiService: AlfrescoApiService, - private logService: LogService) { - } + constructor(private apiService: AlfrescoApiService) {} /** * Creates and returns the default filters for a process app. @@ -57,50 +54,48 @@ export class TaskFilterService { const completeObservable = this.addFilter(completedTasksFilter); return new Observable((observer) => { - forkJoin([ - myTaskObservable, - involvedObservable, - queuedObservable, - completeObservable - ] - ).subscribe( - (res) => { - const filters: FilterRepresentationModel[] = []; - res.forEach((filter) => { - if (!this.isFilterAlreadyExisting(filters, filter.name)) { - if (filter.name === involvedTasksFilter.name) { - filters.push(new FilterRepresentationModel({ + forkJoin([myTaskObservable, involvedObservable, queuedObservable, completeObservable]).subscribe((res) => { + const filters: FilterRepresentationModel[] = []; + res.forEach((filter) => { + if (!this.isFilterAlreadyExisting(filters, filter.name)) { + if (filter.name === involvedTasksFilter.name) { + filters.push( + new FilterRepresentationModel({ ...filter, filter: involvedTasksFilter.filter, appId - })); - } else if (filter.name === myTasksFilter.name) { - filters.push(new FilterRepresentationModel({ + }) + ); + } else if (filter.name === myTasksFilter.name) { + filters.push( + new FilterRepresentationModel({ ...filter, filter: myTasksFilter.filter, appId - })); - } else if (filter.name === queuedTasksFilter.name) { - filters.push(new FilterRepresentationModel({ + }) + ); + } else if (filter.name === queuedTasksFilter.name) { + filters.push( + new FilterRepresentationModel({ ...filter, filter: queuedTasksFilter.filter, appId - })); - } else if (filter.name === completedTasksFilter.name) { - filters.push(new FilterRepresentationModel({ + }) + ); + } else if (filter.name === completedTasksFilter.name) { + filters.push( + new FilterRepresentationModel({ ...filter, filter: completedTasksFilter.filter, appId - })); - } + }) + ); } - }); - observer.next(filters); - observer.complete(); - }, - (err: any) => { - this.logService.error(err); + } }); + observer.next(filters); + observer.complete(); + }); }); } @@ -111,20 +106,18 @@ export class TaskFilterService { * @returns Array of task filter details */ getTaskListFilters(appId?: number): Observable { - return from(this.callApiTaskFilters(appId)) - .pipe( - map((response: any) => { - const filters: FilterRepresentationModel[] = []; - response.data.forEach((filter: FilterRepresentationModel) => { - if (!this.isFilterAlreadyExisting(filters, filter.name)) { - const filterModel = new FilterRepresentationModel(filter); - filters.push(filterModel); - } - }); - return filters; - }), - catchError((err) => this.handleError(err)) - ); + return from(this.callApiTaskFilters(appId)).pipe( + map((response) => { + const filters: FilterRepresentationModel[] = []; + response.data.forEach((filter: FilterRepresentationModel) => { + if (!this.isFilterAlreadyExisting(filters, filter.name)) { + const filterModel = new FilterRepresentationModel(filter); + filters.push(filterModel); + } + }); + return filters; + }) + ); } /** @@ -146,10 +139,7 @@ export class TaskFilterService { * @returns Details of task filter */ getTaskFilterById(filterId: number, appId?: number): Observable { - return from(this.callApiTaskFilters(appId)).pipe( - map((response) => response.data.find((filter) => filter.id === filterId)), - catchError((err) => this.handleError(err)) - ); + return from(this.callApiTaskFilters(appId)).pipe(map((response) => response.data.find((filter) => filter.id === filterId))); } /** @@ -160,10 +150,7 @@ export class TaskFilterService { * @returns Details of task filter */ getTaskFilterByName(taskName: string, appId?: number): Observable { - return from(this.callApiTaskFilters(appId)).pipe( - map((response) => response.data.find((filter) => filter.name === taskName)), - catchError((err) => this.handleError(err)) - ); + return from(this.callApiTaskFilters(appId)).pipe(map((response) => response.data.find((filter) => filter.name === taskName))); } /** @@ -173,11 +160,7 @@ export class TaskFilterService { * @returns Details of task filter just added */ addFilter(filter: FilterRepresentationModel): Observable { - return from(this.userFiltersApi.createUserTaskFilter(filter)) - .pipe( - map((response: FilterRepresentationModel) => response), - catchError((err) => this.handleError(err)) - ); + return from(this.userFiltersApi.createUserTaskFilter(filter)).pipe(map((response: FilterRepresentationModel) => response)); } /** @@ -270,9 +253,4 @@ export class TaskFilterService { index }); } - - private handleError(error: any) { - this.logService.error(error); - return throwError(error || 'Server error'); - } } diff --git a/lib/process-services/src/lib/task-list/services/task-upload.service.ts b/lib/process-services/src/lib/task-list/services/task-upload.service.ts index 2017edada0..48bd29e3d6 100644 --- a/lib/process-services/src/lib/task-list/services/task-upload.service.ts +++ b/lib/process-services/src/lib/task-list/services/task-upload.service.ts @@ -18,14 +18,12 @@ import { AlfrescoApiService, AppConfigService } from '@alfresco/adf-core'; import { DiscoveryApiService, UploadService } from '@alfresco/adf-content-services'; import { Injectable } from '@angular/core'; -import { throwError } from 'rxjs'; -import { ActivitiContentApi } from '@alfresco/js-api'; +import { ActivitiContentApi, RelatedContentRepresentation } from '@alfresco/js-api'; @Injectable({ providedIn: 'root' }) export class TaskUploadService extends UploadService { - private _contentApi: ActivitiContentApi; get contentApi(): ActivitiContentApi { this._contentApi = this._contentApi ?? new ActivitiContentApi(this.apiService.getInstance()); @@ -36,20 +34,11 @@ export class TaskUploadService extends UploadService { super(apiService, appConfigService, discoveryApiService); } - getUploadPromise(file: any): any { + getUploadPromise(file: any): Promise { const opts = { isRelatedContent: true }; const taskId = file.options.parentId; - const promise = this.contentApi.createRelatedContentOnTask(taskId, file.file, opts); - - promise.catch((err) => this.handleError(err)); - - return promise; + return this.contentApi.createRelatedContentOnTask(taskId, file.file, opts); } - - private handleError(error: any) { - return throwError(error || 'Server error'); - } - }