mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[MNT-21789] ADW - Disable ACS Thumbnail Generation cause ADF Upload Service to fail any file upload with 501 error (#6114)
* Disable ACS Thumbnail Generation cause ADF Upload Service to fail any file upload with 501 error * * fixed config
This commit is contained in:
@@ -18,13 +18,13 @@
|
|||||||
import { Component, Input, OnChanges, OnInit, ViewChild, OnDestroy } from '@angular/core';
|
import { Component, Input, OnChanges, OnInit, ViewChild, OnDestroy } from '@angular/core';
|
||||||
import { ProcessInstance, ProcessService ,
|
import { ProcessInstance, ProcessService ,
|
||||||
ProcessAttachmentListComponent, ProcessUploadService } from '@alfresco/adf-process-services';
|
ProcessAttachmentListComponent, ProcessUploadService } from '@alfresco/adf-process-services';
|
||||||
import { UploadService, AlfrescoApiService, AppConfigService } from '@alfresco/adf-core';
|
import { UploadService, AlfrescoApiService, AppConfigService, DiscoveryApiService } from '@alfresco/adf-core';
|
||||||
import { PreviewService } from '../../services/preview.service';
|
import { PreviewService } from '../../services/preview.service';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
|
|
||||||
export function processUploadServiceFactory(api: AlfrescoApiService, config: AppConfigService) {
|
export function processUploadServiceFactory(api: AlfrescoApiService, config: AppConfigService, discoveryApiService: DiscoveryApiService) {
|
||||||
return new ProcessUploadService(api, config);
|
return new ProcessUploadService(api, config, discoveryApiService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -35,7 +35,7 @@ export function processUploadServiceFactory(api: AlfrescoApiService, config: App
|
|||||||
{
|
{
|
||||||
provide: UploadService,
|
provide: UploadService,
|
||||||
useFactory: (processUploadServiceFactory),
|
useFactory: (processUploadServiceFactory),
|
||||||
deps: [AlfrescoApiService, AppConfigService]
|
deps: [AlfrescoApiService, AppConfigService, DiscoveryApiService]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
@@ -22,13 +22,13 @@ import {
|
|||||||
TaskUploadService,
|
TaskUploadService,
|
||||||
TaskDetailsModel
|
TaskDetailsModel
|
||||||
} from '@alfresco/adf-process-services';
|
} from '@alfresco/adf-process-services';
|
||||||
import { UploadService, AlfrescoApiService, AppConfigService } from '@alfresco/adf-core';
|
import { UploadService, AlfrescoApiService, AppConfigService, DiscoveryApiService } from '@alfresco/adf-core';
|
||||||
import { PreviewService } from '../../services/preview.service';
|
import { PreviewService } from '../../services/preview.service';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
|
|
||||||
export function taskUploadServiceFactory(api: AlfrescoApiService, config: AppConfigService) {
|
export function taskUploadServiceFactory(api: AlfrescoApiService, config: AppConfigService, discoveryApiService: DiscoveryApiService) {
|
||||||
return new TaskUploadService(api, config);
|
return new TaskUploadService(api, config, discoveryApiService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -39,7 +39,7 @@ export function taskUploadServiceFactory(api: AlfrescoApiService, config: AppCon
|
|||||||
{
|
{
|
||||||
provide: UploadService,
|
provide: UploadService,
|
||||||
useFactory: (taskUploadServiceFactory),
|
useFactory: (taskUploadServiceFactory),
|
||||||
deps: [AlfrescoApiService, AppConfigService]
|
deps: [AlfrescoApiService, AppConfigService, DiscoveryApiService]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
@@ -16,21 +16,34 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { from, throwError, Observable } from 'rxjs';
|
import { from, merge, Observable, BehaviorSubject, throwError } from 'rxjs';
|
||||||
import { BpmProductVersionModel, EcmProductVersionModel } from '../models/product-version.model';
|
import { BpmProductVersionModel, EcmProductVersionModel } from '../models/product-version.model';
|
||||||
import { AlfrescoApiService } from './alfresco-api.service';
|
import { AlfrescoApiService } from './alfresco-api.service';
|
||||||
import { map, catchError } from 'rxjs/operators';
|
import { catchError, filter, map, switchMap } from 'rxjs/operators';
|
||||||
import {
|
import { Activiti, SystemPropertiesRepresentation } from '@alfresco/js-api';
|
||||||
SystemPropertiesRepresentation,
|
import { AuthenticationService } from './authentication.service';
|
||||||
Activiti
|
|
||||||
} from '@alfresco/js-api';
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class DiscoveryApiService {
|
export class DiscoveryApiService {
|
||||||
|
|
||||||
constructor(private apiService: AlfrescoApiService) { }
|
/**
|
||||||
|
* Gets product information for Content Services.
|
||||||
|
*/
|
||||||
|
ecmProductInfo$ = new BehaviorSubject<EcmProductVersionModel>(null);
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private apiService: AlfrescoApiService,
|
||||||
|
private authenticationService: AuthenticationService) {
|
||||||
|
|
||||||
|
merge(this.apiService.alfrescoApiInitialized, this.authenticationService.onLogin)
|
||||||
|
.pipe(
|
||||||
|
filter(() => this.apiService.getInstance()?.isEcmLoggedIn()),
|
||||||
|
switchMap(() => this.getEcmProductInfo())
|
||||||
|
)
|
||||||
|
.subscribe((info) => this.ecmProductInfo$.next(info));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets product information for Content Services.
|
* Gets product information for Content Services.
|
||||||
@@ -63,10 +76,10 @@ export class DiscoveryApiService {
|
|||||||
public getBPMSystemProperties(): Observable<SystemPropertiesRepresentation> {
|
public getBPMSystemProperties(): Observable<SystemPropertiesRepresentation> {
|
||||||
return from(this.systemPropertiesApi.getProperties())
|
return from(this.systemPropertiesApi.getProperties())
|
||||||
.pipe(
|
.pipe(
|
||||||
map( (res) => {
|
map((res) => {
|
||||||
if ('string' === typeof(res)) {
|
if ('string' === typeof (res)) {
|
||||||
throw new Error('Not valid response');
|
throw new Error('Not valid response');
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}),
|
}),
|
||||||
catchError((err) => throwError(err.error))
|
catchError((err) => throwError(err.error))
|
||||||
|
@@ -27,18 +27,30 @@ import { setupTestBed } from '../testing/setup-test-bed';
|
|||||||
import { CoreTestingModule } from '../testing/core.testing.module';
|
import { CoreTestingModule } from '../testing/core.testing.module';
|
||||||
import { AssocChildBody, AssociationBody } from '@alfresco/js-api';
|
import { AssocChildBody, AssociationBody } from '@alfresco/js-api';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { DiscoveryApiService } from './discovery-api.service';
|
||||||
|
import { BehaviorSubject } from 'rxjs';
|
||||||
|
import { EcmProductVersionModel } from '../models';
|
||||||
|
|
||||||
declare let jasmine: any;
|
declare let jasmine: any;
|
||||||
|
|
||||||
describe('UploadService', () => {
|
describe('UploadService', () => {
|
||||||
let service: UploadService;
|
let service: UploadService;
|
||||||
let alfrescoApiService: AlfrescoApiService;
|
let alfrescoApiService: AlfrescoApiService;
|
||||||
|
const mockProductInfo = new BehaviorSubject<EcmProductVersionModel>(null);
|
||||||
|
|
||||||
setupTestBed({
|
setupTestBed({
|
||||||
imports: [
|
imports: [
|
||||||
TranslateModule.forRoot(),
|
TranslateModule.forRoot(),
|
||||||
CoreTestingModule,
|
CoreTestingModule,
|
||||||
AppConfigModule
|
AppConfigModule
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
{
|
||||||
|
provide: DiscoveryApiService,
|
||||||
|
useValue: {
|
||||||
|
ecmProductInfo$: mockProductInfo
|
||||||
|
}
|
||||||
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -67,6 +79,7 @@ describe('UploadService', () => {
|
|||||||
service.queue = [];
|
service.queue = [];
|
||||||
service.activeTask = null;
|
service.activeTask = null;
|
||||||
jasmine.Ajax.install();
|
jasmine.Ajax.install();
|
||||||
|
mockProductInfo.next({ status: { isThumbnailGenerationEnabled: true } } as EcmProductVersionModel);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@@ -425,4 +438,28 @@ describe('UploadService', () => {
|
|||||||
|
|
||||||
expect(service.fileUploadCancelled.next).toHaveBeenCalled();
|
expect(service.fileUploadCancelled.next).toHaveBeenCalled();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('Should not pass rendition if it is disabled', () => {
|
||||||
|
mockProductInfo.next({ status: { isThumbnailGenerationEnabled: false } } as EcmProductVersionModel);
|
||||||
|
|
||||||
|
const uploadFileSpy = spyOn(alfrescoApiService.getInstance().upload, 'uploadFile').and.callThrough();
|
||||||
|
const emitter = new EventEmitter();
|
||||||
|
|
||||||
|
const filesFake = new FileModel(<File> { name: 'fake-name', size: 10 }, {
|
||||||
|
newVersion: true
|
||||||
|
});
|
||||||
|
service.addToQueue(filesFake);
|
||||||
|
service.uploadFilesInTheQueue(emitter);
|
||||||
|
|
||||||
|
expect(uploadFileSpy).toHaveBeenCalledWith({
|
||||||
|
name: 'fake-name',
|
||||||
|
size: 10
|
||||||
|
}, undefined, undefined, { newVersion: true }, {
|
||||||
|
include: ['allowableOperations'],
|
||||||
|
overwrite: true,
|
||||||
|
majorVersion: undefined,
|
||||||
|
comment: undefined,
|
||||||
|
name: 'fake-name'
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -27,6 +27,8 @@ import {
|
|||||||
} from '../events/file.event';
|
} from '../events/file.event';
|
||||||
import { FileModel, FileUploadProgress, FileUploadStatus } from '../models/file.model';
|
import { FileModel, FileUploadProgress, FileUploadStatus } from '../models/file.model';
|
||||||
import { AlfrescoApiService } from './alfresco-api.service';
|
import { AlfrescoApiService } from './alfresco-api.service';
|
||||||
|
import { DiscoveryApiService } from './discovery-api.service';
|
||||||
|
import { filter } from 'rxjs/operators';
|
||||||
|
|
||||||
const MIN_CANCELLABLE_FILE_SIZE = 1000000;
|
const MIN_CANCELLABLE_FILE_SIZE = 1000000;
|
||||||
const MAX_CANCELLABLE_FILE_PERCENTAGE = 50;
|
const MAX_CANCELLABLE_FILE_PERCENTAGE = 50;
|
||||||
@@ -44,6 +46,7 @@ export class UploadService {
|
|||||||
private matchingOptions: any = null;
|
private matchingOptions: any = null;
|
||||||
private folderMatchingOptions: any = null;
|
private folderMatchingOptions: any = null;
|
||||||
private abortedFile: string;
|
private abortedFile: string;
|
||||||
|
private isThumbnailGenerationEnabled: boolean;
|
||||||
|
|
||||||
activeTask: Promise<any> = null;
|
activeTask: Promise<any> = null;
|
||||||
queue: FileModel[] = [];
|
queue: FileModel[] = [];
|
||||||
@@ -73,8 +76,15 @@ export class UploadService {
|
|||||||
>();
|
>();
|
||||||
fileDeleted: Subject<string> = new Subject<string>();
|
fileDeleted: Subject<string> = new Subject<string>();
|
||||||
|
|
||||||
constructor(protected apiService: AlfrescoApiService, private appConfigService: AppConfigService) {
|
constructor(
|
||||||
|
protected apiService: AlfrescoApiService,
|
||||||
|
private appConfigService: AppConfigService,
|
||||||
|
private discoveryApiService: DiscoveryApiService) {
|
||||||
|
|
||||||
|
this.discoveryApiService.ecmProductInfo$.pipe(filter(info => !!info))
|
||||||
|
.subscribe(({ status }) => {
|
||||||
|
this.isThumbnailGenerationEnabled = status.isThumbnailGenerationEnabled;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -220,10 +230,13 @@ export class UploadService {
|
|||||||
*/
|
*/
|
||||||
getUploadPromise(file: FileModel): any {
|
getUploadPromise(file: FileModel): any {
|
||||||
const opts: any = {
|
const opts: any = {
|
||||||
renditions: 'doclib',
|
|
||||||
include: ['allowableOperations']
|
include: ['allowableOperations']
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (this.isThumbnailGenerationEnabled) {
|
||||||
|
opts.renditions = 'doclib';
|
||||||
|
}
|
||||||
|
|
||||||
if (file.options.newVersion === true) {
|
if (file.options.newVersion === true) {
|
||||||
opts.overwrite = true;
|
opts.overwrite = true;
|
||||||
opts.majorVersion = file.options.majorVersion;
|
opts.majorVersion = file.options.majorVersion;
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { AlfrescoApiService, AppConfigService, UploadService } from '@alfresco/adf-core';
|
import { AlfrescoApiService, AppConfigService, DiscoveryApiService, UploadService } from '@alfresco/adf-core';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { throwError } from 'rxjs';
|
import { throwError } from 'rxjs';
|
||||||
|
|
||||||
@@ -24,8 +24,8 @@ import { throwError } from 'rxjs';
|
|||||||
})
|
})
|
||||||
export class ProcessUploadService extends UploadService {
|
export class ProcessUploadService extends UploadService {
|
||||||
|
|
||||||
constructor(apiService: AlfrescoApiService, appConfigService: AppConfigService) {
|
constructor(protected apiService: AlfrescoApiService, appConfigService: AppConfigService, discoveryApiService: DiscoveryApiService) {
|
||||||
super(apiService, appConfigService);
|
super(apiService, appConfigService, discoveryApiService);
|
||||||
}
|
}
|
||||||
|
|
||||||
getUploadPromise(file: any): any {
|
getUploadPromise(file: any): any {
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { AlfrescoApiService, AppConfigService, UploadService } from '@alfresco/adf-core';
|
import { AlfrescoApiService, AppConfigService, DiscoveryApiService, UploadService } from '@alfresco/adf-core';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { throwError } from 'rxjs';
|
import { throwError } from 'rxjs';
|
||||||
|
|
||||||
@@ -24,8 +24,8 @@ import { throwError } from 'rxjs';
|
|||||||
})
|
})
|
||||||
export class TaskUploadService extends UploadService {
|
export class TaskUploadService extends UploadService {
|
||||||
|
|
||||||
constructor(apiService: AlfrescoApiService, appConfigService: AppConfigService) {
|
constructor(protected apiService: AlfrescoApiService, appConfigService: AppConfigService, discoveryApiService: DiscoveryApiService) {
|
||||||
super(apiService, appConfigService);
|
super(apiService, appConfigService, discoveryApiService);
|
||||||
}
|
}
|
||||||
|
|
||||||
getUploadPromise(file: any): any {
|
getUploadPromise(file: any): any {
|
||||||
|
Reference in New Issue
Block a user