[ADF-] update library to use new js-api 3.0.0 (#4097)

This commit is contained in:
Eugenio Romano
2019-01-08 16:29:30 +00:00
committed by Eugenio Romano
parent 2acd1b4e26
commit 3ef7d3b7ea
430 changed files with 1966 additions and 2149 deletions
+22 -30
View File
@@ -17,21 +17,13 @@
import { Injectable } from '@angular/core';
import {
AlfrescoApi,
ContentApi,
FavoritesApi,
NodesApi,
PeopleApi,
RenditionsApi,
SharedlinksApi,
SitesApi,
VersionsApi,
ClassesApi,
Core,
Activiti,
SearchApi,
GroupsApi,
MinimalNodeEntryEntity
} from 'alfresco-js-api';
import * as alfrescoApi from 'alfresco-js-api';
Node
} from '@alfresco/js-api';
import { AlfrescoApiCompatibility } from '@alfresco/js-api';
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
import { StorageService } from './storage.service';
import { Subject } from 'rxjs';
@@ -46,47 +38,47 @@ export class AlfrescoApiService {
/**
* Publish/subscribe to events related to node updates.
*/
nodeUpdated = new Subject<MinimalNodeEntryEntity>();
nodeUpdated = new Subject<Node>();
protected alfrescoApi: AlfrescoApi;
protected alfrescoApi: AlfrescoApiCompatibility;
getInstance(): AlfrescoApi {
getInstance(): AlfrescoApiCompatibility {
return this.alfrescoApi;
}
get taskApi(): alfrescoApi.TaskApi {
get taskApi(): Activiti.TaskApi {
return this.getInstance().activiti.taskApi;
}
get modelsApi(): alfrescoApi.ModelsApi {
return this.getInstance().activiti.modelsApi;
}
// get modelsApi(): Core.ModelsApi {
// return this.getInstance().activiti.modelsApi;
// }
get contentApi(): ContentApi {
return this.getInstance().content;
}
get nodesApi(): NodesApi {
get nodesApi(): Core.NodesApi {
return this.getInstance().nodes;
}
get renditionsApi(): RenditionsApi {
get renditionsApi(): Core.RenditionsApi {
return this.getInstance().core.renditionsApi;
}
get sharedLinksApi(): SharedlinksApi {
get sharedLinksApi(): Core.SharedlinksApi {
return this.getInstance().core.sharedlinksApi;
}
get sitesApi(): SitesApi {
get sitesApi(): Core.SitesApi {
return this.getInstance().core.sitesApi;
}
get favoritesApi(): FavoritesApi {
get favoritesApi(): Core.FavoritesApi {
return this.getInstance().core.favoritesApi;
}
get peopleApi(): PeopleApi {
get peopleApi(): Core.PeopleApi {
return this.getInstance().core.peopleApi;
}
@@ -94,15 +86,15 @@ export class AlfrescoApiService {
return this.getInstance().search.searchApi;
}
get versionsApi(): VersionsApi {
get versionsApi(): Core.VersionsApi {
return this.getInstance().core.versionsApi;
}
get classesApi(): ClassesApi {
get classesApi(): Core.ClassesApi {
return this.getInstance().core.classesApi;
}
get groupsApi(): GroupsApi {
get groupsApi(): Core.GroupsApi {
return this.getInstance().core.groupsApi;
}
@@ -141,7 +133,7 @@ export class AlfrescoApiService {
if (this.alfrescoApi) {
this.alfrescoApi.configureJsApi(config);
} else {
this.alfrescoApi = <AlfrescoApi> new alfrescoApi(config);
this.alfrescoApi = new AlfrescoApiCompatibility(config);
}
}
+1 -1
View File
@@ -16,7 +16,7 @@
*/
import { Injectable } from '@angular/core';
import { AppDefinitionRepresentation } from 'alfresco-js-api';
import { AppDefinitionRepresentation } from '@alfresco/js-api';
import { Observable, from, throwError } from 'rxjs';
import { AlfrescoApiService } from './alfresco-api.service';
import { LogService } from './log.service';
@@ -22,7 +22,7 @@ import { CookieService } from './cookie.service';
import { AppConfigService } from '../app-config/app-config.service';
import { setupTestBed } from '../testing/setupTestBed';
import { CoreTestingModule } from '../testing/core.testing.module';
import { UserRepresentation } from 'alfresco-js-api';
import { UserRepresentation } from '@alfresco/js-api';
declare let jasmine: any;
@@ -54,71 +54,6 @@ describe('AuthenticationService', () => {
jasmine.Ajax.uninstall();
});
describe('remember me', () => {
beforeEach(() => {
appConfigService.config.providers = 'ECM';
appConfigService.load();
apiService.reset();
});
it('[ECM] should save the remember me cookie as a session cookie after successful login', (done) => {
let disposableLogin = authService.login('fake-username', 'fake-password', false).subscribe(() => {
expect(cookie['ALFRESCO_REMEMBER_ME']).not.toBeUndefined();
expect(cookie['ALFRESCO_REMEMBER_ME'].expiration).toBeNull();
disposableLogin.unsubscribe();
done();
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 201,
contentType: 'application/json',
responseText: JSON.stringify({ 'entry': { 'id': 'fake-post-ticket', 'userId': 'admin' } })
});
});
it('[ECM] should save the remember me cookie as a persistent cookie after successful login', (done) => {
let disposableLogin = authService.login('fake-username', 'fake-password', true).subscribe(() => {
expect(cookie['ALFRESCO_REMEMBER_ME']).not.toBeUndefined();
expect(cookie['ALFRESCO_REMEMBER_ME'].expiration).not.toBeNull();
disposableLogin.unsubscribe();
done();
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 201,
contentType: 'application/json',
responseText: JSON.stringify({ 'entry': { 'id': 'fake-post-ticket', 'userId': 'admin' } })
});
});
it('[ECM] should not save the remember me cookie after failed login', (done) => {
let disposableLogin = authService.login('fake-username', 'fake-password').subscribe(
(res) => {
},
(err: any) => {
expect(cookie['ALFRESCO_REMEMBER_ME']).toBeUndefined();
disposableLogin.unsubscribe();
done();
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 403,
contentType: 'application/json',
responseText: JSON.stringify({
'error': {
'errorKey': 'Login failed',
'statusCode': 403,
'briefSummary': '05150009 Login failed',
'stackTrace': 'For security reasons the stack trace is no longer displayed, but the property is kept for previous versions.',
'descriptionURL': 'https://api-explorer.alfresco.com'
}
})
});
});
});
describe('when the setting is ECM', () => {
beforeEach(() => {
@@ -127,17 +62,6 @@ describe('AuthenticationService', () => {
apiService.reset();
});
it('should require remember me set for ECM check', () => {
spyOn(cookie, 'isEnabled').and.returnValue(true);
spyOn(authService, 'isRememberMeSet').and.returnValue(false);
spyOn(authService, 'isECMProvider').and.returnValue(true);
spyOn(authService, 'isOauth').and.returnValue(false);
spyOn(apiService, 'getInstance').and.callThrough();
expect(authService.isEcmLoggedIn()).toBeFalsy();
expect(apiService.getInstance).not.toHaveBeenCalled();
});
it('should not require cookie service enabled for ECM check', () => {
spyOn(cookie, 'isEnabled').and.returnValue(false);
spyOn(authService, 'isRememberMeSet').and.returnValue(false);
@@ -149,6 +73,17 @@ describe('AuthenticationService', () => {
expect(apiService.getInstance).toHaveBeenCalled();
});
it('should require remember me set for ECM check', () => {
spyOn(cookie, 'isEnabled').and.returnValue(true);
spyOn(authService, 'isRememberMeSet').and.returnValue(false);
spyOn(authService, 'isECMProvider').and.returnValue(true);
spyOn(authService, 'isOauth').and.returnValue(false);
spyOn(apiService, 'getInstance').and.callThrough();
expect(authService.isEcmLoggedIn()).toBeFalsy();
expect(apiService.getInstance).not.toHaveBeenCalled();
});
it('[ECM] should return an ECM ticket after the login done', (done) => {
let disposableLogin = authService.login('fake-username', 'fake-password').subscribe(() => {
expect(authService.isLoggedIn()).toBe(true);
@@ -365,6 +300,71 @@ describe('AuthenticationService', () => {
});
});
describe('remember me', () => {
beforeEach(() => {
appConfigService.config.providers = 'ECM';
appConfigService.load();
apiService.reset();
});
it('[ECM] should save the remember me cookie as a session cookie after successful login', (done) => {
let disposableLogin = authService.login('fake-username', 'fake-password', false).subscribe(() => {
expect(cookie['ALFRESCO_REMEMBER_ME']).not.toBeUndefined();
expect(cookie['ALFRESCO_REMEMBER_ME'].expiration).toBeNull();
disposableLogin.unsubscribe();
done();
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 201,
contentType: 'application/json',
responseText: JSON.stringify({ 'entry': { 'id': 'fake-post-ticket', 'userId': 'admin' } })
});
});
it('[ECM] should save the remember me cookie as a persistent cookie after successful login', (done) => {
let disposableLogin = authService.login('fake-username', 'fake-password', true).subscribe(() => {
expect(cookie['ALFRESCO_REMEMBER_ME']).not.toBeUndefined();
expect(cookie['ALFRESCO_REMEMBER_ME'].expiration).not.toBeNull();
disposableLogin.unsubscribe();
done();
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 201,
contentType: 'application/json',
responseText: JSON.stringify({ 'entry': { 'id': 'fake-post-ticket', 'userId': 'admin' } })
});
});
it('[ECM] should not save the remember me cookie after failed login', (done) => {
let disposableLogin = authService.login('fake-username', 'fake-password').subscribe(
(res) => {
},
(err: any) => {
expect(cookie['ALFRESCO_REMEMBER_ME']).toBeUndefined();
disposableLogin.unsubscribe();
done();
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 403,
contentType: 'application/json',
responseText: JSON.stringify({
'error': {
'errorKey': 'Login failed',
'statusCode': 403,
'briefSummary': '05150009 Login failed',
'stackTrace': 'For security reasons the stack trace is no longer displayed, but the property is kept for previous versions.',
'descriptionURL': 'https://api-explorer.alfresco.com'
}
})
});
});
});
describe('when the setting is both ECM and BPM ', () => {
beforeEach(() => {
@@ -402,9 +402,9 @@ describe('AuthenticationService', () => {
},
(err: any) => {
expect(authService.isLoggedIn()).toBe(false, 'isLoggedIn');
expect(authService.getTicketEcm()).toBe(undefined, 'getTicketEcm');
expect(authService.getTicketEcm()).toBe(null, 'getTicketEcm');
// cspell: disable-next
expect(authService.getTicketBpm()).toBe('Basic ZmFrZS11c2VybmFtZTpmYWtlLXBhc3N3b3Jk', 'getTicketBpm');
expect(authService.getTicketBpm()).toBe(null, 'getTicketBpm');
expect(authService.isEcmLoggedIn()).toBe(false, 'isEcmLoggedIn');
disposableLogin.unsubscribe();
done();
@@ -425,8 +425,8 @@ describe('AuthenticationService', () => {
},
(err: any) => {
expect(authService.isLoggedIn()).toBe(false);
expect(authService.getTicketEcm()).toBe('fake-post-ticket');
expect(authService.getTicketBpm()).toBe(undefined);
expect(authService.getTicketEcm()).toBe(null);
expect(authService.getTicketBpm()).toBe(null);
expect(authService.isBpmLoggedIn()).toBe(false);
disposableLogin.unsubscribe();
done();
@@ -449,8 +449,8 @@ describe('AuthenticationService', () => {
},
(err: any) => {
expect(authService.isLoggedIn()).toBe(false);
expect(authService.getTicketEcm()).toBe(undefined);
expect(authService.getTicketBpm()).toBe(undefined);
expect(authService.getTicketEcm()).toBe(null);
expect(authService.getTicketBpm()).toBe(null);
expect(authService.isBpmLoggedIn()).toBe(false);
expect(authService.isEcmLoggedIn()).toBe(false);
disposableLogin.unsubscribe();
+1 -1
View File
@@ -22,7 +22,7 @@ import { CookieService } from './cookie.service';
import { LogService } from './log.service';
import { RedirectionModel } from '../models/redirection.model';
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
import { UserRepresentation } from 'alfresco-js-api';
import { UserRepresentation } from '@alfresco/js-api';
import { map, catchError, tap } from 'rxjs/operators';
import { HttpHeaders } from '@angular/common/http';
+18 -8
View File
@@ -39,7 +39,7 @@ export class CommentProcessService {
* @returns Details about the comment
*/
addTaskComment(taskId: string, message: string): Observable<CommentModel> {
return from(this.apiService.getInstance().activiti.taskApi.addTaskComment({message: message}, taskId))
return from(this.apiService.getInstance().activiti.taskApi.addTaskComment({ message: message }, taskId))
.pipe(
map((response: CommentModel) => {
return new CommentModel({
@@ -49,7 +49,7 @@ export class CommentProcessService {
createdBy: response.createdBy
});
}),
catchError((err) => this.handleError(err))
catchError((err: any) => this.handleError(err))
);
}
@@ -65,11 +65,16 @@ export class CommentProcessService {
let comments: CommentModel[] = [];
response.data.forEach((comment: CommentModel) => {
let user = new UserProcessModel(comment.createdBy);
comments.push(new CommentModel({id: comment.id, message: comment.message, created: comment.created, createdBy: user}));
comments.push(new CommentModel({
id: comment.id,
message: comment.message,
created: comment.created,
createdBy: user
}));
});
return comments;
}),
catchError((err) => this.handleError(err))
catchError((err: any) => this.handleError(err))
);
}
@@ -85,11 +90,16 @@ export class CommentProcessService {
let comments: CommentModel[] = [];
response.data.forEach((comment: CommentModel) => {
let user = new UserProcessModel(comment.createdBy);
comments.push(new CommentModel({id: comment.id, message: comment.message, created: comment.created, createdBy: user}));
comments.push(new CommentModel({
id: comment.id,
message: comment.message,
created: comment.created,
createdBy: user
}));
});
return comments;
}),
catchError((err) => this.handleError(err))
catchError((err: any) => this.handleError(err))
);
}
@@ -101,7 +111,7 @@ export class CommentProcessService {
*/
addProcessInstanceComment(processInstanceId: string, message: string): Observable<CommentModel> {
return from(
this.apiService.getInstance().activiti.commentsApi.addProcessInstanceComment({message: message}, processInstanceId)
this.apiService.getInstance().activiti.commentsApi.addProcessInstanceComment({ message: message }, processInstanceId)
).pipe(
map((response: CommentModel) => {
return new CommentModel({
@@ -111,7 +121,7 @@ export class CommentProcessService {
createdBy: response.createdBy
});
}),
catchError((err) => this.handleError(err))
catchError((err: any) => this.handleError(err))
);
}
+9 -8
View File
@@ -29,6 +29,7 @@ import { AlfrescoApiService } from './alfresco-api.service';
import { AlfrescoApiServiceMock } from '../mock/alfresco-api.service.mock';
import { TranslationService } from './translation.service';
import { TranslationMock } from '../mock/translation.service.mock';
import { Node } from '@alfresco/js-api';
declare let jasmine: any;
@@ -92,7 +93,7 @@ describe('ContentService', () => {
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 201,
contentType: 'application/json',
responseText: JSON.stringify({'entry': {'id': 'fake-post-ticket', 'userId': 'admin'}})
responseText: JSON.stringify({ 'entry': { 'id': 'fake-post-ticket', 'userId': 'admin' } })
});
});
@@ -107,33 +108,33 @@ describe('ContentService', () => {
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 201,
contentType: 'application/json',
responseText: JSON.stringify({'entry': {'id': 'fake-post-ticket', 'userId': 'admin'}})
responseText: JSON.stringify({ 'entry': { 'id': 'fake-post-ticket', 'userId': 'admin' } })
});
});
it('should havePermission be false if allowableOperation is not present in the node', () => {
let permissionNode = {};
let permissionNode = new Node({});
expect(contentService.hasPermission(permissionNode, 'create')).toBeFalsy();
});
it('should havePermission be true if allowableOperation is present and you have the permission for the request operation', () => {
let permissionNode = {allowableOperations: ['delete', 'update', 'create', 'updatePermissions']};
let permissionNode = new Node({ allowableOperations: ['delete', 'update', 'create', 'updatePermissions'] });
expect(contentService.hasPermission(permissionNode, 'create')).toBeTruthy();
});
it('should havePermission be false if allowableOperation is present but you don\'t have the permission for the request operation', () => {
let permissionNode = {allowableOperations: ['delete', 'update', 'updatePermissions']};
let permissionNode = new Node({ allowableOperations: ['delete', 'update', 'updatePermissions'] });
expect(contentService.hasPermission(permissionNode, 'create')).toBeFalsy();
});
it('should havePermission works in the opposite way with negate value', () => {
let permissionNode = {allowableOperations: ['delete', 'update', 'updatePermissions']};
let permissionNode = new Node({ allowableOperations: ['delete', 'update', 'updatePermissions'] });
expect(contentService.hasPermission(permissionNode, '!create')).toBeTruthy();
});
it('should havePermission return false id no permission parameter are passed', () => {
let permissionNode = {allowableOperations: ['delete', 'update', 'updatePermissions']};
let permissionNode = new Node({ allowableOperations: ['delete', 'update', 'updatePermissions'] });
expect(contentService.hasPermission(permissionNode, null)).toBeFalsy();
});
@@ -152,7 +153,7 @@ describe('ContentService', () => {
done();
});
let blob = new Blob([''], {type: 'text/html'});
let blob = new Blob([''], { type: 'text/html' });
contentService.downloadBlob(blob, 'test_ie');
});
});
+8 -30
View File
@@ -17,14 +17,14 @@
import { Injectable } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { ContentApi, MinimalNodeEntryEntity, Node, NodeEntry } from 'alfresco-js-api';
import { ContentApi, MinimalNode, Node, NodeEntry } from '@alfresco/js-api';
import { Observable, Subject, from, throwError } from 'rxjs';
import { FolderCreatedEvent } from '../events/folder-created.event';
import { PermissionsEnum } from '../models/permissions.enum';
import { AlfrescoApiService } from './alfresco-api.service';
import { AuthenticationService } from './authentication.service';
import { LogService } from './log.service';
import { catchError, tap } from 'rxjs/operators';
import { catchError } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
@@ -34,8 +34,8 @@ export class ContentService {
private saveData: Function;
folderCreated: Subject<FolderCreatedEvent> = new Subject<FolderCreatedEvent>();
folderCreate: Subject<MinimalNodeEntryEntity> = new Subject<MinimalNodeEntryEntity>();
folderEdit: Subject<MinimalNodeEntryEntity> = new Subject<MinimalNodeEntryEntity>();
folderCreate: Subject<MinimalNode> = new Subject<MinimalNode>();
folderEdit: Subject<MinimalNode> = new Subject<MinimalNode>();
constructor(public authService: AuthenticationService,
public apiService: AlfrescoApiService,
@@ -46,15 +46,15 @@ export class ContentService {
document.body.appendChild(a);
a.style.display = 'none';
return function (data, format, fileName) {
return function (fileData, format, fileName) {
let blob = null;
if (format === 'blob' || format === 'data') {
blob = new Blob([data], { type: 'octet/stream' });
blob = new Blob([fileData], { type: 'octet/stream' });
}
if (format === 'object' || format === 'json') {
let json = JSON.stringify(data);
let json = JSON.stringify(fileData);
blob = new Blob([json], { type: 'octet/stream' });
}
@@ -157,29 +157,7 @@ export class ContentService {
getNodeContent(nodeId: string): Observable<any> {
return from(this.apiService.getInstance().core.nodesApi.getFileContent(nodeId))
.pipe(
catchError((err) => this.handleError(err))
);
}
/**
* Creates a folder.
* @param relativePath Location to create the folder
* @param name Folder name
* @param parentId Node ID of parent folder
* @returns Information about the new folder
*/
createFolder(relativePath: string, name: string, parentId?: string): Observable<NodeEntry> {
return from(this.apiService.getInstance().nodes.createFolder(name, relativePath, parentId))
.pipe(
tap((data) => {
this.folderCreated.next(<FolderCreatedEvent> {
relativePath: relativePath,
name: name,
parentId: parentId,
node: data
});
}),
catchError((err) => this.handleError(err))
catchError((err: any) => this.handleError(err))
);
}
@@ -18,7 +18,7 @@
import { Injectable } from '@angular/core';
import { Observable, from, of } from 'rxjs';
import { NodePaging } from 'alfresco-js-api';
import { NodePaging } from '@alfresco/js-api';
import { AlfrescoApiService } from './alfresco-api.service';
import { UserPreferencesService } from './user-preferences.service';
import { catchError } from 'rxjs/operators';
+1 -1
View File
@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { NodeEntry, DownloadEntry, DownloadBodyCreate } from 'alfresco-js-api';
import { NodeEntry, DownloadEntry, DownloadBodyCreate } from '@alfresco/js-api';
import { Injectable } from '@angular/core';
import { Observable, from, throwError } from 'rxjs';
import { LogService } from './log.service';
@@ -17,11 +17,10 @@
import { Injectable } from '@angular/core';
import {
AlfrescoApi,
AlfrescoApiCompatibility,
ContentApi,
NodesApi
} from 'alfresco-js-api';
import * as alfrescoApi from 'alfresco-js-api';
Core
} from '@alfresco/js-api';
/* tslint:disable:adf-file-name */
@Injectable({
@@ -29,9 +28,9 @@ import * as alfrescoApi from 'alfresco-js-api';
})
export class ExternalAlfrescoApiService {
protected alfrescoApi: AlfrescoApi;
protected alfrescoApi: AlfrescoApiCompatibility;
getInstance(): AlfrescoApi {
getInstance(): AlfrescoApiCompatibility {
return this.alfrescoApi;
}
@@ -39,7 +38,7 @@ export class ExternalAlfrescoApiService {
return this.getInstance().content;
}
get nodesApi(): NodesApi {
get nodesApi(): Core.NodesApi {
return this.getInstance().nodes;
}
@@ -61,7 +60,7 @@ export class ExternalAlfrescoApiService {
if (this.alfrescoApi) {
this.alfrescoApi.configureJsApi(config);
} else {
this.alfrescoApi = <AlfrescoApi> new alfrescoApi(config);
this.alfrescoApi = new AlfrescoApiCompatibility(config);
}
}
+1 -1
View File
@@ -16,7 +16,7 @@
*/
import { Injectable } from '@angular/core';
import { NodePaging } from 'alfresco-js-api';
import { NodePaging } from '@alfresco/js-api';
import { Observable, from, of } from 'rxjs';
import { AlfrescoApiService } from './alfresco-api.service';
import { UserPreferencesService } from './user-preferences.service';
+7 -7
View File
@@ -16,7 +16,7 @@
*/
import { Injectable } from '@angular/core';
import { MinimalNodeEntity, MinimalNodeEntryEntity, NodePaging } from 'alfresco-js-api';
import { NodeEntry, MinimalNode, NodePaging } from '@alfresco/js-api';
import { Observable, from, throwError } from 'rxjs';
import { AlfrescoApiService } from './alfresco-api.service';
import { UserPreferencesService } from './user-preferences.service';
@@ -35,7 +35,7 @@ export class NodesApiService {
return this.api.getInstance().core.nodesApi;
}
private getEntryFromEntity(entity: MinimalNodeEntity) {
private getEntryFromEntity(entity: NodeEntry) {
return entity.entry;
}
@@ -45,7 +45,7 @@ export class NodesApiService {
* @param options Optional parameters supported by JS-API
* @returns Node information
*/
getNode(nodeId: string, options: any = {}): Observable<MinimalNodeEntryEntity> {
getNode(nodeId: string, options: any = {}): Observable<MinimalNode> {
const defaults = {
include: [ 'path', 'properties', 'allowableOperations', 'permissions' ]
};
@@ -87,7 +87,7 @@ export class NodesApiService {
* @param options Optional parameters supported by JS-API
* @returns Details of the new node
*/
createNode(parentNodeId: string, nodeBody: any, options: any = {}): Observable<MinimalNodeEntryEntity> {
createNode(parentNodeId: string, nodeBody: any, options: any = {}): Observable<MinimalNode> {
const promise = this.nodesApi
.addNode(parentNodeId, nodeBody, options)
.then(this.getEntryFromEntity);
@@ -104,7 +104,7 @@ export class NodesApiService {
* @param options Optional parameters supported by JS-API
* @returns Details of the new folder
*/
createFolder(parentNodeId: string, nodeBody: any, options: any = {}): Observable<MinimalNodeEntryEntity> {
createFolder(parentNodeId: string, nodeBody: any, options: any = {}): Observable<MinimalNode> {
const body = Object.assign({ nodeType: 'cm:folder' }, nodeBody);
return this.createNode(parentNodeId, body, options);
}
@@ -116,7 +116,7 @@ export class NodesApiService {
* @param options Optional parameters supported by JS-API
* @returns Updated node information
*/
updateNode(nodeId: string, nodeBody: any, options: any = {}): Observable<MinimalNodeEntryEntity> {
updateNode(nodeId: string, nodeBody: any, options: any = {}): Observable<MinimalNode> {
const defaults = {
include: [ 'path', 'properties', 'allowableOperations', 'permissions' ]
};
@@ -150,7 +150,7 @@ export class NodesApiService {
* @param nodeId ID of the node to restore
* @returns Details of the restored node
*/
restoreNode(nodeId: string): Observable<MinimalNodeEntryEntity> {
restoreNode(nodeId: string): Observable<MinimalNode> {
const promise = this.nodesApi
.restoreNode(nodeId)
.then(this.getEntryFromEntity);
+1 -2
View File
@@ -16,7 +16,6 @@
*/
import { Injectable } from '@angular/core';
import { Response } from '@angular/http';
import { Observable, from, throwError } from 'rxjs';
import { UserProcessModel } from '../models/user-process.model';
import { AlfrescoApiService } from './alfresco-api.service';
@@ -104,7 +103,7 @@ export class PeopleProcessService {
* Throw the error
* @param error
*/
private handleError(error: Response) {
private handleError(error: any) {
this.logService.error(error);
return throwError(error || 'Server error');
}
+1 -1
View File
@@ -22,7 +22,7 @@ import { setupTestBed } from '../testing/setupTestBed';
import { CoreModule } from '../core.module';
import { AlfrescoApiService } from './alfresco-api.service';
import { AlfrescoApiServiceMock } from '../mock/alfresco-api.service.mock';
import { RenditionEntry } from 'alfresco-js-api';
import { RenditionEntry } from '@alfresco/js-api';
declare let jasmine: any;
+4 -4
View File
@@ -16,7 +16,7 @@
*/
import { Injectable } from '@angular/core';
import { RenditionEntry, RenditionPaging } from 'alfresco-js-api';
import { RenditionEntry, RenditionPaging } from '@alfresco/js-api';
import { Observable, from, interval, empty } from 'rxjs';
import { AlfrescoApiService } from './alfresco-api.service';
import { concatMap, switchMap, takeWhile, map } from 'rxjs/operators';
@@ -104,7 +104,7 @@ export class RenditionsService {
/** @deprecated */
createRendition(nodeId: string, encoding: string): Observable<{}> {
return from(this.apiService.renditionsApi.createRendition(nodeId, {id: encoding}));
return from(this.apiService.renditionsApi.createRendition(nodeId, { id: encoding }));
}
/** @deprecated */
@@ -121,12 +121,12 @@ export class RenditionsService {
return interval(intervalSize)
.pipe(
switchMap(() => this.getRendition(nodeId, encoding)),
takeWhile((data) => {
takeWhile((renditionEntry: RenditionEntry) => {
attempts += 1;
if (attempts > retries) {
return false;
}
return (data.entry.status.toString() !== 'CREATED');
return (renditionEntry.entry.status.toString() !== 'CREATED');
})
);
}
@@ -16,7 +16,7 @@
*/
import { Injectable } from '@angular/core';
import { QueryBody } from 'alfresco-js-api';
import { QueryBody } from '@alfresco/js-api';
import { SearchConfigurationInterface } from '../interface/search-configuration.interface';
@Injectable({
+8 -8
View File
@@ -16,7 +16,7 @@
*/
import { Injectable } from '@angular/core';
import { NodePaging, QueryBody } from 'alfresco-js-api';
import { NodePaging, QueryBody } from '@alfresco/js-api';
import { Observable, Subject, from, throwError } from 'rxjs';
import { AlfrescoApiService } from './alfresco-api.service';
import { SearchConfigurationService } from './search-configuration.service';
@@ -42,8 +42,8 @@ export class SearchService {
getNodeQueryResults(term: string, options?: SearchOptions): Observable<NodePaging> {
const promise = this.apiService.getInstance().core.queriesApi.findNodes(term, options);
promise.then((data: any) => {
this.dataLoaded.next(data);
promise.then((nodePaging: NodePaging) => {
this.dataLoaded.next(nodePaging);
});
return from(promise).pipe(
@@ -62,8 +62,8 @@ export class SearchService {
const searchQuery = Object.assign(this.searchConfigurationService.generateQueryBody(searchTerm, maxResults, skipCount));
const promise = this.apiService.getInstance().search.searchApi.search(searchQuery);
promise.then((data: any) => {
this.dataLoaded.next(data);
promise.then((nodePaging: NodePaging) => {
this.dataLoaded.next(nodePaging);
});
return from(promise).pipe(
@@ -79,12 +79,12 @@ export class SearchService {
searchByQueryBody(queryBody: QueryBody): Observable<NodePaging> {
const promise = this.apiService.getInstance().search.searchApi.search(queryBody);
promise.then((data: any) => {
this.dataLoaded.next(data);
promise.then((nodePaging: NodePaging) => {
this.dataLoaded.next(nodePaging);
});
return from(promise).pipe(
catchError((err) => this.handleError(err))
catchError((err: any) => this.handleError(err))
);
}
@@ -16,7 +16,7 @@
*/
import { Injectable } from '@angular/core';
import { NodePaging, SharedLinkEntry } from 'alfresco-js-api';
import { NodePaging, SharedLinkEntry } from '@alfresco/js-api';
import { Observable, from, of } from 'rxjs';
import { AlfrescoApiService } from './alfresco-api.service';
import { UserPreferencesService } from './user-preferences.service';
+10 -10
View File
@@ -16,10 +16,9 @@
*/
import { Injectable } from '@angular/core';
import { Response } from '@angular/http';
import { Observable, from, throwError } from 'rxjs';
import { AlfrescoApiService } from './alfresco-api.service';
import { SitePaging, SiteEntry } from 'alfresco-js-api';
import { SitePaging, SiteEntry } from '@alfresco/js-api';
import { catchError } from 'rxjs/operators';
@Injectable({
@@ -28,7 +27,8 @@ import { catchError } from 'rxjs/operators';
export class SitesService {
constructor(
private apiService: AlfrescoApiService) { }
private apiService: AlfrescoApiService) {
}
/**
* Gets a list of all sites in the repository.
@@ -43,7 +43,7 @@ export class SitesService {
const queryOptions = Object.assign({}, defaultOptions, opts);
return from(this.apiService.getInstance().core.sitesApi.getSites(queryOptions))
.pipe(
catchError((err) => this.handleError(err))
catchError((err: any) => this.handleError(err))
);
}
@@ -53,10 +53,10 @@ export class SitesService {
* @param opts Options supported by JS-API
* @returns Information about the site
*/
getSite(siteId: string, opts?: any): Observable<SiteEntry> {
getSite(siteId: string, opts?: any): Observable<SiteEntry | {}> {
return from(this.apiService.getInstance().core.sitesApi.getSite(siteId, opts))
.pipe(
catchError((err) => this.handleError(err))
catchError((err: any) => this.handleError(err))
);
}
@@ -71,7 +71,7 @@ export class SitesService {
options.permanent = permanentFlag;
return from(this.apiService.getInstance().core.sitesApi.deleteSite(siteId, options))
.pipe(
catchError((err) => this.handleError(err))
catchError((err: any) => this.handleError(err))
);
}
@@ -80,7 +80,7 @@ export class SitesService {
* @param siteId ID of the target site
* @returns Site content
*/
getSiteContent(siteId: string): Observable<SiteEntry> {
getSiteContent(siteId: string): Observable<SiteEntry | {}> {
return this.getSite(siteId, { relations: ['containers'] });
}
@@ -89,7 +89,7 @@ export class SitesService {
* @param siteId ID of the target site
* @returns Site members
*/
getSiteMembers(siteId: string): Observable<SiteEntry> {
getSiteMembers(siteId: string): Observable<SiteEntry | {}> {
return this.getSite(siteId, { relations: ['members'] });
}
@@ -101,7 +101,7 @@ export class SitesService {
return this.apiService.getInstance().getEcmUsername();
}
private handleError(error: Response): any {
private handleError(error: any): any {
console.error(error);
return throwError(error || 'Server error');
}
+18 -29
View File
@@ -25,6 +25,7 @@ import { AlfrescoApiService } from './alfresco-api.service';
import { setupTestBed } from '../testing/setupTestBed';
import { CoreTestingModule } from '../testing/core.testing.module';
import { AssocChildBody, AssociationBody } from '@alfresco/js-api';
declare let jasmine: any;
@@ -162,17 +163,6 @@ describe('UploadService', () => {
service.cancelUpload(...file);
});
it('If versioning is true autoRename should not be present and majorVersion should be a param', () => {
let emitter = new EventEmitter();
const filesFake = new FileModel(<File> { name: 'fake-name', size: 10 }, { newVersion: true });
service.addToQueue(filesFake);
service.uploadFilesInTheQueue(emitter);
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('autoRename=true')).toBe(false);
expect(jasmine.Ajax.requests.mostRecent().params.has('majorVersion')).toBe(false);
});
it('If newVersion is set, name should be a param', () => {
let uploadFileSpy = spyOn(alfrescoApiService.getInstance().upload, 'uploadFile').and.callThrough();
@@ -189,7 +179,7 @@ describe('UploadService', () => {
size: 10
}, undefined, undefined, { newVersion: true }, {
renditions: 'doclib',
include: [ 'allowableOperations' ],
include: ['allowableOperations'],
overwrite: true,
majorVersion: undefined,
comment: undefined,
@@ -229,12 +219,12 @@ describe('UploadService', () => {
let filesFake = new FileModel(
<File> { name: 'fake-name', size: 10 },
<FileUploadOptions> { parentId: '123', path: 'fake-dir',
secondaryChildren: [{ assocType: 'assoc-1', childId: 'child-id' }],
association: { assocType: 'fake-assoc' },
targets: [{ assocType: 'target-assoc', targetId: 'fake-target-id' }]
}
);
<FileUploadOptions> {
parentId: '123', path: 'fake-dir',
secondaryChildren: [<AssocChildBody> { assocType: 'assoc-1', childId: 'child-id' }],
association: { assocType: 'fake-assoc' },
targets: [<AssociationBody> { assocType: 'target-assoc', targetId: 'fake-target-id' }]
});
service.addToQueue(filesFake);
service.uploadFilesInTheQueue(emitter);
@@ -243,17 +233,16 @@ describe('UploadService', () => {
size: 10
}, 'fake-dir', '123', {
newVersion: false,
parentId: '123',
path: 'fake-dir',
secondaryChildren: [
{ assocType: 'assoc-1', childId: 'child-id' }],
association: { assocType: 'fake-assoc' },
targets: [{ assocType: 'target-assoc', targetId: 'fake-target-id' }]
}, {
renditions: 'doclib',
include: ['allowableOperations'],
autoRename: true
});
parentId: '123',
path: 'fake-dir',
secondaryChildren: [<AssocChildBody> { assocType: 'assoc-1', childId: 'child-id' }],
association: { assocType: 'fake-assoc' },
targets: [<AssociationBody> { assocType: 'target-assoc', targetId: 'fake-target-id' }]
}, {
renditions: 'doclib',
include: ['allowableOperations'],
autoRename: true
});
});
it('should start downloading the next one if a file of the list is aborted', (done) => {
+2 -5
View File
@@ -161,7 +161,7 @@ export class UploadService {
* @param file The target file
* @returns Promise that is resolved if the upload is successful or error otherwise
*/
getUploadPromise(file: FileModel) {
getUploadPromise(file: FileModel): any {
let opts: any = {
renditions: 'doclib',
include: ['allowableOperations']
@@ -181,9 +181,7 @@ export class UploadService {
}
if (file.id) {
return this.apiService.getInstance().upload.updateFile(
file.file,
file.options.path,
return this.apiService.getInstance().node.updateNodeContent(
file.id,
file.file,
opts
@@ -225,7 +223,6 @@ export class UploadService {
}
})
.catch((err) => {
throw err;
});
return promise;