[ADF-5426] Remove compatibility layer from Lib (#7110)

* remove compatibility step 1

* remove compatibility step 2

* remove compatibility step 3

* remove compatibility step 4

* remove compatibility step 5
This commit is contained in:
Eugenio Romano
2021-08-04 17:31:35 +02:00
committed by GitHub
parent 5d5b582e32
commit f30b20cc46
113 changed files with 1375 additions and 2348 deletions

View File

@@ -17,7 +17,7 @@
import { Injectable } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { ContentApi, MinimalNode, Node, NodeEntry } from '@alfresco/js-api';
import { ContentApi, MinimalNode, Node, NodeEntry, NodesApi } from '@alfresco/js-api';
import { Observable, Subject, from, throwError } from 'rxjs';
import { FolderCreatedEvent } from '../events/folder-created.event';
import { AlfrescoApiService } from './alfresco-api.service';
@@ -38,12 +38,17 @@ export class ContentService {
folderCreate: Subject<MinimalNode> = new Subject<MinimalNode>();
folderEdit: Subject<MinimalNode> = new Subject<MinimalNode>();
private contentApi: ContentApi;
private nodesApi: NodesApi;
constructor(public authService: AuthenticationService,
public apiService: AlfrescoApiService,
private logService: LogService,
private sanitizer: DomSanitizer,
private downloadService: DownloadService,
private thumbnailService: ThumbnailService) {
this.contentApi = new ContentApi(apiService.getInstance());
this.nodesApi = new NodesApi(apiService.getInstance());
}
/**
@@ -56,26 +61,6 @@ export class ContentService {
this.downloadService.downloadBlob(blob, fileName);
}
/**
* @deprecated in 3.2.0, use DownloadService instead.
* Invokes content download for a data array with a file name.
* @param data Data to download.
* @param fileName Name of the resulting file.
*/
downloadData(data: any, fileName: string): void {
this.downloadService.downloadData(data, fileName);
}
/**
* @deprecated in 3.2.0, use DownloadService instead.
* Invokes content download for a JSON object with a file name.
* @param json JSON object to download.
* @param fileName Name of the resulting file.
*/
downloadJSON(json: any, fileName: string): void {
this.downloadService.downloadJSON(json, fileName);
}
/**
* Creates a trusted object URL from the Blob.
* WARNING: calling this method with untrusted user data exposes your application to XSS security risks!
@@ -87,10 +72,6 @@ export class ContentService {
return <string> this.sanitizer.bypassSecurityTrustUrl(url);
}
private get contentApi(): ContentApi {
return this.apiService.getInstance().content;
}
/**
* @deprecated in 3.2.0, use ThumbnailService instead.
* Gets a thumbnail URL for the given document node.
@@ -132,7 +113,7 @@ export class ContentService {
* @returns Content data
*/
getNodeContent(nodeId: string): Observable<any> {
return from(this.apiService.getInstance().core.nodesApi.getFileContent(nodeId))
return from(this.nodesApi.getNodeContent(nodeId))
.pipe(
catchError((err: any) => this.handleError(err))
);
@@ -145,7 +126,7 @@ export class ContentService {
* @returns Details of the folder
*/
getNode(nodeId: string, opts?: any): Observable<NodeEntry> {
return from(this.apiService.getInstance().nodes.getNode(nodeId, opts));
return from(this.nodesApi.getNode(nodeId, opts));
}
/**
@@ -159,13 +140,13 @@ export class ContentService {
let hasPermissions = false;
userId = userId ?? this.authService.getEcmUsername();
const permissions = [ ...(node.permissions?.locallySet || []), ...(node.permissions?.inherited || []) ]
.filter((currentPermission) => currentPermission.authorityId === userId);
const permissions = [...(node.permissions?.locallySet || []), ...(node.permissions?.inherited || [])]
.filter((currentPermission) => currentPermission.authorityId === userId);
if (permissions.length) {
if (permission && permission.startsWith('!')) {
hasPermissions = permissions.find((currentPermission) => currentPermission.name === permission.replace('!', '')) ? false : true;
hasPermissions = !permissions.find((currentPermission) => currentPermission.name === permission.replace('!', ''));
} else {
hasPermissions = permissions.find((currentPermission) => currentPermission.name === permission) ? true : false;
hasPermissions = !!permissions.find((currentPermission) => currentPermission.name === permission);
}
} else {
@@ -193,9 +174,9 @@ export class ContentService {
if (node && node.allowableOperations) {
if (allowableOperation && allowableOperation.startsWith('!')) {
hasAllowableOperations = node.allowableOperations.find((currentOperation) => currentOperation === allowableOperation.replace('!', '')) ? false : true;
hasAllowableOperations = !node.allowableOperations.find((currentOperation) => currentOperation === allowableOperation.replace('!', ''));
} else {
hasAllowableOperations = node.allowableOperations.find((currentOperation) => currentOperation === allowableOperation) ? true : false;
hasAllowableOperations = !!node.allowableOperations.find((currentOperation) => currentOperation === allowableOperation);
}
} else {