mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
added try - catch in api and handleError methods
This commit is contained in:
@@ -121,10 +121,13 @@ describe('Mark items as favorites', () => {
|
||||
|
||||
describe('on Personal Files', () => {
|
||||
afterAll(async (done) => {
|
||||
await apis.user.favorites.addFavoritesByIds('file', [ fileFavUIId, fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]);
|
||||
await apis.user.favorites.addFavoriteById('folder', folderId);
|
||||
await apis.user.favorites.removeFavoritesByIds([ fileNotFavUIId , fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id ]);
|
||||
await apis.user.favorites.waitForApi({ expect: 10 });
|
||||
try {
|
||||
await apis.user.favorites.addFavoritesByIds('file', [ fileFavUIId, fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]);
|
||||
await apis.user.favorites.addFavoriteById('folder', folderId);
|
||||
await apis.user.favorites.removeFavoritesByIds([ fileNotFavUIId , fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id ]);
|
||||
await apis.user.favorites.waitForApi({ expect: 10 });
|
||||
} catch (error) {
|
||||
}
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -204,9 +207,12 @@ describe('Mark items as favorites', () => {
|
||||
|
||||
describe('on Recent Files', () => {
|
||||
afterAll(async (done) => {
|
||||
await apis.user.favorites.addFavoritesByIds('file', [ fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]);
|
||||
await apis.user.favorites.removeFavoritesByIds([ fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id ]);
|
||||
await apis.user.favorites.waitForApi({ expect: 10 });
|
||||
try {
|
||||
await apis.user.favorites.addFavoritesByIds('file', [ fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]);
|
||||
await apis.user.favorites.removeFavoritesByIds([ fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id ]);
|
||||
await apis.user.favorites.waitForApi({ expect: 10 });
|
||||
} catch (error) {
|
||||
}
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -257,9 +263,12 @@ describe('Mark items as favorites', () => {
|
||||
|
||||
describe('on Shared Files', () => {
|
||||
afterAll(async (done) => {
|
||||
await apis.user.favorites.addFavoritesByIds('file', [ fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]);
|
||||
await apis.user.favorites.removeFavoritesByIds([ fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id ]);
|
||||
await apis.user.favorites.waitForApi({ expect: 10 });
|
||||
try {
|
||||
await apis.user.favorites.addFavoritesByIds('file', [ fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]);
|
||||
await apis.user.favorites.removeFavoritesByIds([ fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id ]);
|
||||
await apis.user.favorites.waitForApi({ expect: 10 });
|
||||
} catch (error) {
|
||||
}
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -310,9 +319,12 @@ describe('Mark items as favorites', () => {
|
||||
|
||||
describe('on Favorites', () => {
|
||||
afterAll(async (done) => {
|
||||
await apis.user.favorites.addFavoritesByIds('file', [ fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]);
|
||||
await apis.user.favorites.removeFavoritesByIds([ fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id ]);
|
||||
await apis.user.favorites.waitForApi({ expect: 10 });
|
||||
try {
|
||||
await apis.user.favorites.addFavoritesByIds('file', [ fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]);
|
||||
await apis.user.favorites.removeFavoritesByIds([ fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id ]);
|
||||
await apis.user.favorites.waitForApi({ expect: 10 });
|
||||
} catch (error) {
|
||||
}
|
||||
done();
|
||||
});
|
||||
|
||||
|
@@ -36,7 +36,7 @@ export class AuthenticationApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
await this.alfrescoJsApi.logout();
|
||||
} catch (error) {
|
||||
console.log('--- authentication api logout catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.logout.name}`, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -38,7 +38,7 @@ export class CommentsApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.commentsApi.listComments(nodeId);
|
||||
} catch (error) {
|
||||
console.log('--- comments api getNodeComments catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.getNodeComments.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ export class CommentsApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.commentsApi.createComment(nodeId, { "content": comment });
|
||||
} catch (error) {
|
||||
console.log('--- comments api addComment catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.addComment.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,7 @@ export class CommentsApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.commentsApi.createComment(nodeId, comment);
|
||||
} catch (error) {
|
||||
console.log('--- comments api addComments catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.addComments.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -48,7 +48,7 @@ export class FavoritesApi extends RepoApi {
|
||||
};
|
||||
return await this.favoritesApi.createFavorite('-me-', data);
|
||||
} catch (error) {
|
||||
console.log('--- favorites api addFavorite catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.addFavorite.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ export class FavoritesApi extends RepoApi {
|
||||
};
|
||||
return await this.favoritesApi.createFavorite('-me-', data);
|
||||
} catch (error) {
|
||||
console.log('--- favorites api addFavoriteById catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.addFavoriteById.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,7 @@ export class FavoritesApi extends RepoApi {
|
||||
await this.addFavoriteById(nodeType, current);
|
||||
}, Promise.resolve());
|
||||
} catch (error) {
|
||||
console.log('--- favorites api addFavoritesByIds catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.addFavoritesByIds.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ export class FavoritesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.favoritesApi.listFavorites(this.getUsername());
|
||||
} catch (error) {
|
||||
console.log('--- favorites api getFavorites catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.getFavorites.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -102,7 +102,7 @@ export class FavoritesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.favoritesApi.getFavorite('-me-', nodeId);
|
||||
} catch (error) {
|
||||
console.log('--- favorites api getFavoriteById catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.getFavoriteById.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -111,7 +111,7 @@ export class FavoritesApi extends RepoApi {
|
||||
try {
|
||||
return JSON.stringify((await this.getFavorites()).list.entries).includes(nodeId);
|
||||
} catch (error) {
|
||||
console.log('--- favorites api isFavorite catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.isFavorite.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -127,10 +127,9 @@ export class FavoritesApi extends RepoApi {
|
||||
return Promise.resolve(isFavorite);
|
||||
}
|
||||
};
|
||||
|
||||
return await Utils.retryCall(favorite);
|
||||
} catch (error) {
|
||||
console.log('--- favorites api isFavoriteWithRetry catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.isFavoriteWithRetry.name}`, error);
|
||||
}
|
||||
return isFavorite;
|
||||
}
|
||||
@@ -140,7 +139,7 @@ export class FavoritesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.favoritesApi.deleteFavorite('-me-', nodeId);
|
||||
} catch (error) {
|
||||
console.log('--- favorites api removeFavoriteById catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.removeFavoriteById.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +150,7 @@ export class FavoritesApi extends RepoApi {
|
||||
await this.removeFavoriteById(current);
|
||||
}, Promise.resolve());
|
||||
} catch (error) {
|
||||
console.log('--- favorites api removeFavoritesByIds catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.removeFavoritesByIds.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,10 +164,9 @@ export class FavoritesApi extends RepoApi {
|
||||
return Promise.resolve(totalItems);
|
||||
}
|
||||
};
|
||||
|
||||
return await Utils.retryCall(favoriteFiles);
|
||||
} catch (error) {
|
||||
console.log('favorites api waitForApi catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.waitForApi.name}`, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@
|
||||
import { RepoApi } from '../repo-api';
|
||||
import { NodeBodyCreate } from './node-body-create';
|
||||
import { NodeContentTree, flattenNodeContentTree } from './node-content-tree';
|
||||
import { NodesApi as AdfNodeApi, NodeBodyLock} from '@alfresco/js-api';
|
||||
import { NodesApi as AdfNodeApi, NodeBodyLock, NodeEntry, NodeChildAssociationPaging } from '@alfresco/js-api';
|
||||
import { Utils } from '../../../../utilities/utils';
|
||||
|
||||
export class NodesApi extends RepoApi {
|
||||
@@ -36,150 +36,150 @@ export class NodesApi extends RepoApi {
|
||||
super(username, password);
|
||||
}
|
||||
|
||||
async getNodeByPath(relativePath: string = '/') {
|
||||
async getNodeByPath(relativePath: string = '/'): Promise<NodeEntry> {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.getNode('-my-', { relativePath });
|
||||
} catch (error) {
|
||||
console.log('--- nodes api getNodeByPath catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.getNodeByPath.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async getNodeById(id: string) {
|
||||
async getNodeById(id: string): Promise<NodeEntry> {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.getNode(id);
|
||||
const node = await this.nodesApi.getNode(id);
|
||||
return node;
|
||||
} catch (error) {
|
||||
console.log('--- nodes api getNodeById catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.getNodeById.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async getNodeIdFromParent(name: string, parentId: string) {
|
||||
async getNodeIdFromParent(name: string, parentId: string): Promise<string> {
|
||||
try {
|
||||
const children = (await this.getNodeChildren(parentId)).list.entries;
|
||||
return children.find(elem => elem.entry.name === name).entry.id;
|
||||
return children.find(elem => elem.entry.name === name).entry.id || '';
|
||||
} catch (error) {
|
||||
console.log('--- nodes api getNodeIdFromParent catch error: ', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async getNodeDescription(name: string, parentId: string) {
|
||||
try {
|
||||
const children = (await this.getNodeChildren(parentId)).list.entries;
|
||||
return children.find(elem => elem.entry.name === name).entry.properties['cm:description'];
|
||||
} catch (error) {
|
||||
console.log('--- nodes api getNodeDescription catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.getNodeIdFromParent.name}`, error);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
async getNodeProperty(nodeId: string, property: string) {
|
||||
async getNodeDescription(name: string, parentId: string): Promise<string> {
|
||||
try {
|
||||
const children = (await this.getNodeChildren(parentId)).list.entries;
|
||||
return children.find(elem => elem.entry.name === name).entry.properties['cm:description'] || '';
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.getNodeDescription.name}`, error);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
async getNodeProperty(nodeId: string, property: string): Promise<any> {
|
||||
try {
|
||||
const node = await this.getNodeById(nodeId);
|
||||
if (node.entry.properties) {
|
||||
return node.entry.properties[property];
|
||||
}
|
||||
return (node.entry.properties && node.entry.properties[property]) || '';
|
||||
} catch (error) {
|
||||
console.log('--- nodes api getNodeProperty catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.getNodeProperty.name}`, error);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
async getFileVersionType(nodeId: string) {
|
||||
async getFileVersionType(nodeId: string): Promise<string> {
|
||||
try {
|
||||
const prop = await this.getNodeProperty(nodeId, 'cm:versionType');
|
||||
if ( prop ) {
|
||||
return prop;
|
||||
}
|
||||
return prop || '';
|
||||
} catch (error) {
|
||||
console.log('--- nodes api getFileVersionType catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.getFileVersionType.name}`, error);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
async getFileVersionLabel(nodeId: string) {
|
||||
async getFileVersionLabel(nodeId: string): Promise<string> {
|
||||
try {
|
||||
const prop = await this.getNodeProperty(nodeId, 'cm:versionLabel');
|
||||
if ( prop ) {
|
||||
return prop;
|
||||
}
|
||||
return prop || '';
|
||||
} catch (error) {
|
||||
console.log('--- nodes api getFileVersionLabel catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.getFileVersionLabel.name}`, error);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
async getSharedId(nodeId: string) {
|
||||
async getSharedId(nodeId: string): Promise<string> {
|
||||
try {
|
||||
return await this.getNodeProperty(nodeId, 'qshare:sharedId');
|
||||
const sharedId = await this.getNodeProperty(nodeId, 'qshare:sharedId');
|
||||
return sharedId || '';
|
||||
} catch (error) {
|
||||
console.log('--- nodes api getSharedId catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.getSharedId.name}`, error);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
async getSharedExpiryDate(nodeId: string) {
|
||||
async getSharedExpiryDate(nodeId: string): Promise<string> {
|
||||
try {
|
||||
return await this.getNodeProperty(nodeId, 'qshare:expiryDate');
|
||||
const expiryDate = await this.getNodeProperty(nodeId, 'qshare:expiryDate');
|
||||
return expiryDate || '';
|
||||
} catch (error) {
|
||||
console.log('--- nodes api getSharedExpiryDate catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.getSharedExpiryDate.name}`, error);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
async isFileShared(nodeId: string) {
|
||||
async isFileShared(nodeId: string): Promise<boolean> {
|
||||
try {
|
||||
return (await this.getSharedId(nodeId)) !== '';
|
||||
const sharedId = await this.getSharedId(nodeId);
|
||||
return sharedId !== '';
|
||||
} catch (error) {
|
||||
console.log('--- nodes api isFileShared catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.isFileShared.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async deleteNodeById(id: string, permanent: boolean = true) {
|
||||
async deleteNodeById(id: string, permanent: boolean = true): Promise<void> {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.deleteNode(id, { permanent });
|
||||
await this.nodesApi.deleteNode(id, { permanent });
|
||||
} catch (error) {
|
||||
console.log('--- nodes api deleteNodeById catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.deleteNodeById.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async deleteNodeByPath(path: string, permanent: boolean = true) {
|
||||
async deleteNodeByPath(path: string, permanent: boolean = true): Promise<void> {
|
||||
try {
|
||||
const id = (await this.getNodeByPath(path)).entry.id;
|
||||
return await this.deleteNodeById(id, permanent);
|
||||
await this.deleteNodeById(id, permanent);
|
||||
} catch (error) {
|
||||
console.log('--- nodes api deleteNodeByPath catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.deleteNodeByPath.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async deleteNodes(names: string[], relativePath: string = '', permanent: boolean = true) {
|
||||
async deleteNodes(names: string[], relativePath: string = '', permanent: boolean = true): Promise<void> {
|
||||
try {
|
||||
return await names.reduce(async (previous, current) => {
|
||||
await names.reduce(async (previous, current) => {
|
||||
await previous;
|
||||
const req = await this.deleteNodeByPath(`${relativePath}/${current}`, permanent);
|
||||
return req;
|
||||
}, Promise.resolve());
|
||||
} catch (error) {
|
||||
console.log('--- nodes api deleteNodes catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.deleteNodes.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async deleteNodesById(ids: string[], permanent: boolean = true) {
|
||||
async deleteNodesById(ids: string[], permanent: boolean = true): Promise<void> {
|
||||
try {
|
||||
return await ids.reduce(async (previous, current) => {
|
||||
await ids.reduce(async (previous, current) => {
|
||||
await previous;
|
||||
const req = await this.deleteNodeById(current, permanent);
|
||||
return req;
|
||||
}, Promise.resolve());
|
||||
} catch (error) {
|
||||
console.log('--- nodes api deleteNodesById catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.deleteNodesById.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async getNodeChildren(nodeId: string) {
|
||||
async getNodeChildren(nodeId: string): Promise<NodeChildAssociationPaging> {
|
||||
try {
|
||||
const opts = {
|
||||
include: [ 'properties' ]
|
||||
@@ -187,22 +187,22 @@ export class NodesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.listNodeChildren(nodeId, opts);
|
||||
} catch (error) {
|
||||
console.log('--- nodes api getNodeChildren catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.getNodeChildren.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async deleteNodeChildren(parentId: string) {
|
||||
async deleteNodeChildren(parentId: string): Promise<void> {
|
||||
try {
|
||||
const listEntries = (await this.getNodeChildren(parentId)).list.entries;
|
||||
const nodeIds = listEntries.map(entries => entries.entry.id);
|
||||
return await this.deleteNodesById(nodeIds);
|
||||
await this.deleteNodesById(nodeIds);
|
||||
} catch (error) {
|
||||
console.log('--- nodes api deleteNodeChildren catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.deleteNodeChildren.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async createImageNode(name: string, parentId: string = '-my-', title: string = '', description: string = '') {
|
||||
async createImageNode(name: string, parentId: string = '-my-', title: string = '', description: string = ''): Promise<any> {
|
||||
const imageProps = {
|
||||
'exif:pixelXDimension': 1000,
|
||||
'exif:pixelYDimension': 1200
|
||||
@@ -210,11 +210,11 @@ export class NodesApi extends RepoApi {
|
||||
try {
|
||||
return await this.createNode('cm:content', name, parentId, title, description, imageProps);
|
||||
} catch (error) {
|
||||
console.log('--- nodes api createImageNode catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.createImageNode.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async createNode(nodeType: string, name: string, parentId: string = '-my-', title: string = '', description: string = '', imageProps: any = null, author: string = '', majorVersion: boolean = true) {
|
||||
async createNode(nodeType: string, name: string, parentId: string = '-my-', title: string = '', description: string = '', imageProps: any = null, author: string = '', majorVersion: boolean = true): Promise<any> {
|
||||
const nodeBody = {
|
||||
name,
|
||||
nodeType,
|
||||
@@ -232,99 +232,99 @@ export class NodesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.createNode(parentId, nodeBody, { majorVersion });
|
||||
} catch (error) {
|
||||
console.log('--- nodes api createNode catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.createNode.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async createFile(name: string, parentId: string = '-my-', title: string = '', description: string = '', author: string = '', majorVersion: boolean = true) {
|
||||
async createFile(name: string, parentId: string = '-my-', title: string = '', description: string = '', author: string = '', majorVersion: boolean = true): Promise<any> {
|
||||
try {
|
||||
return await this.createNode('cm:content', name, parentId, title, description, null, author, majorVersion);
|
||||
} catch (error) {
|
||||
console.log('--- nodes api createFile catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.createFile.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async createImage(name: string, parentId: string = '-my-', title: string = '', description: string = '') {
|
||||
async createImage(name: string, parentId: string = '-my-', title: string = '', description: string = ''): Promise<any> {
|
||||
try {
|
||||
return await this.createImageNode(name, parentId, title, description);
|
||||
} catch (error) {
|
||||
console.log('--- nodes api createImage catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.createImage.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async createFolder(name: string, parentId: string = '-my-', title: string = '', description: string = '', author: string = '') {
|
||||
async createFolder(name: string, parentId: string = '-my-', title: string = '', description: string = '', author: string = ''): Promise<any> {
|
||||
try {
|
||||
return await this.createNode('cm:folder', name, parentId, title, description, null, author);
|
||||
} catch (error) {
|
||||
console.log('--- nodes api createFolder catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.createFolder.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async createChildren(data: NodeBodyCreate[]) {
|
||||
async createChildren(data: NodeBodyCreate[]): Promise<any> {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.createNode('-my-', <any>data);
|
||||
} catch (error) {
|
||||
console.log('--- nodes api createChildren catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.createChildren.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async createContent(content: NodeContentTree, relativePath: string = '/') {
|
||||
async createContent(content: NodeContentTree, relativePath: string = '/'): Promise<any> {
|
||||
try {
|
||||
return await this.createChildren(flattenNodeContentTree(content, relativePath));
|
||||
} catch (error) {
|
||||
console.log('--- nodes api createContent catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.createContent.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async createFolders(names: string[], relativePath: string = '/') {
|
||||
async createFolders(names: string[], relativePath: string = '/'): Promise<any> {
|
||||
try {
|
||||
return await this.createContent({ folders: names }, relativePath);
|
||||
} catch (error) {
|
||||
console.log('--- nodes api createFolders catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.createFolders.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async createFiles(names: string[], relativePath: string = '/') {
|
||||
async createFiles(names: string[], relativePath: string = '/'): Promise<any> {
|
||||
try {
|
||||
return await this.createContent({ files: names }, relativePath);
|
||||
} catch (error) {
|
||||
console.log('--- nodes api createFiles catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.createFiles.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
// node content
|
||||
async getNodeContent(nodeId: string) {
|
||||
async getNodeContent(nodeId: string): Promise<any> {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.getNodeContent(nodeId);
|
||||
} catch (error) {
|
||||
console.log('--- nodes api getNodeContent catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.getNodeContent.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async editNodeContent(nodeId: string, content: string) {
|
||||
async editNodeContent(nodeId: string, content: string): Promise<NodeEntry|null> {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.updateNodeContent(nodeId, content);
|
||||
} catch (error) {
|
||||
console.log('--- nodes api editNodeContent catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.editNodeContent.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async renameNode(nodeId: string, newName: string) {
|
||||
async renameNode(nodeId: string, newName: string): Promise<NodeEntry|null> {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return this.nodesApi.updateNode(nodeId, { name: newName });
|
||||
} catch (error) {
|
||||
console.log('--- nodes api renameNode catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.renameNode.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// node permissions
|
||||
async setGranularPermission(nodeId: string, inheritPermissions: boolean = false, username: string, role: string) {
|
||||
async setGranularPermission(nodeId: string, inheritPermissions: boolean = false, username: string, role: string): Promise<NodeEntry|null> {
|
||||
const data = {
|
||||
permissions: {
|
||||
isInheritanceEnabled: inheritPermissions,
|
||||
@@ -341,23 +341,13 @@ export class NodesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.updateNode(nodeId, data);
|
||||
} catch (error) {
|
||||
console.log('--- nodes api setGranularPermission catch error: ', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async getNodePermissions(nodeId: string) {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.getNode(nodeId, { include: ['permissions'] });
|
||||
} catch (error) {
|
||||
console.log('--- nodes api getNodePermissions catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.setGranularPermission.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// lock node
|
||||
async lockFile(nodeId: string, lockType: string = 'ALLOW_OWNER_CHANGES') {
|
||||
async lockFile(nodeId: string, lockType: string = 'ALLOW_OWNER_CHANGES'): Promise<NodeEntry|null> {
|
||||
const data = <NodeBodyLock>{
|
||||
type: lockType
|
||||
};
|
||||
@@ -366,52 +356,56 @@ export class NodesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.lockNode(nodeId, data );
|
||||
} catch (error) {
|
||||
console.log('--- nodes api lockFile catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.lockFile.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async unlockFile(nodeId: string) {
|
||||
async unlockFile(nodeId: string): Promise<NodeEntry|null> {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.unlockNode(nodeId);
|
||||
} catch (error) {
|
||||
console.log('--- nodes api unlockFile catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.unlockFile.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async getLockType(nodeId: string) {
|
||||
async getLockType(nodeId: string): Promise<any> {
|
||||
try {
|
||||
return await this.getNodeProperty(nodeId, 'cm:lockType');
|
||||
const lockType = await this.getNodeProperty(nodeId, 'cm:lockType');
|
||||
return lockType || '';
|
||||
} catch (error) {
|
||||
console.log('--- nodes api getLockType catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.getLockType.name}`, error);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
async getLockOwner(nodeId: string) {
|
||||
async getLockOwner(nodeId: string): Promise<any> {
|
||||
try {
|
||||
return await this.getNodeProperty(nodeId, 'cm:lockOwner');
|
||||
const lockOwner = await this.getNodeProperty(nodeId, 'cm:lockOwner');
|
||||
return lockOwner || '';
|
||||
} catch (error) {
|
||||
console.log('--- nodes api getLockOwner catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.getLockOwner.name}`, error);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
async isFileLockedWrite(nodeId: string) {
|
||||
async isFileLockedWrite(nodeId: string): Promise<boolean> {
|
||||
try {
|
||||
return (await this.getLockType(nodeId)) === 'WRITE_LOCK';
|
||||
} catch (error) {
|
||||
console.log('--- nodes api isFileLockedWrite catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.isFileLockedWrite.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async isFileLockedWriteWithRetry(nodeId: string, expect: boolean) {
|
||||
async isFileLockedWriteWithRetry(nodeId: string, expect: boolean): Promise<boolean> {
|
||||
const data = {
|
||||
expect: expect,
|
||||
retry: 5
|
||||
};
|
||||
let isLocked;
|
||||
let isLocked: boolean;
|
||||
try {
|
||||
const locked = async () => {
|
||||
isLocked = (await this.getLockType(nodeId)) === 'WRITE_LOCK';
|
||||
@@ -421,19 +415,19 @@ export class NodesApi extends RepoApi {
|
||||
return Promise.resolve(isLocked);
|
||||
}
|
||||
}
|
||||
return await Utils.retryCall(locked, data.retry);
|
||||
await Utils.retryCall(locked, data.retry);
|
||||
} catch (error) {
|
||||
console.log('--- nodes api isFileLockedWriteWithRetry catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.isFileLockedWriteWithRetry.name}`, error);
|
||||
}
|
||||
return isLocked;
|
||||
}
|
||||
|
||||
async isFileLockedByName(fileName: string, parentId: string) {
|
||||
async isFileLockedByName(fileName: string, parentId: string): Promise<boolean> {
|
||||
try {
|
||||
const id = await this.getNodeIdFromParent(fileName, parentId);
|
||||
return await this.isFileLockedWrite(id);
|
||||
} catch (error) {
|
||||
console.log('--- nodes api isFileLockedByName catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.isFileLockedByName.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -30,7 +30,7 @@ import { PeopleApi as AdfPeopleApi} from '@alfresco/js-api';
|
||||
export class PeopleApi extends RepoApi {
|
||||
peopleApi = new AdfPeopleApi(this.alfrescoJsApi);
|
||||
|
||||
constructor(username?, password?) {
|
||||
constructor(username?: string, password?: string) {
|
||||
super(username, password);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ export class PeopleApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.peopleApi.createPerson(person);
|
||||
} catch (error) {
|
||||
console.log('--- people api createUser catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.createUser.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ export class PeopleApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.peopleApi.getPerson(username);
|
||||
} catch (error) {
|
||||
console.log('--- people api getUser catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.getUser.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,7 @@ export class PeopleApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return this.peopleApi.updatePerson(username, userDetails);
|
||||
} catch (error) {
|
||||
console.log('--- people api updateUser catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.updateUser.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,7 @@ export class PeopleApi extends RepoApi {
|
||||
try {
|
||||
return await this.updateUser(username, { enabled: false });
|
||||
} catch (error) {
|
||||
console.log('--- people api disableUser catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.disableUser.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,7 @@ export class PeopleApi extends RepoApi {
|
||||
try {
|
||||
return await this.updateUser(username, { password: newPassword });
|
||||
} catch (error) {
|
||||
console.log('--- people api changePassword catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.changePassword.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -44,7 +44,7 @@ export class QueriesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return this.queriesApi.findSites(searchTerm, data);
|
||||
} catch (error) {
|
||||
console.log('--- queries api findSites catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.findSites.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -59,12 +59,12 @@ export class QueriesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return this.queriesApi.findNodes(searchTerm, data);
|
||||
} catch (error) {
|
||||
console.log('--- queries api findNodes catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.findNodes.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async waitForSites(searchTerm: string, data: any) {
|
||||
async waitForSites(searchTerm: string, data: { expect: number }) {
|
||||
try {
|
||||
const sites = async () => {
|
||||
const totalItems = (await this.findSites(searchTerm)).list.pagination.totalItems;
|
||||
@@ -77,7 +77,7 @@ export class QueriesApi extends RepoApi {
|
||||
|
||||
return await Utils.retryCall(sites);
|
||||
} catch (error) {
|
||||
console.log('--- queries api waitForSites catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.waitForSites.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ export class QueriesApi extends RepoApi {
|
||||
|
||||
return await Utils.retryCall(nodes);
|
||||
} catch (error) {
|
||||
console.log('--- queries api waitForFilesAndFolders catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.waitForFilesAndFolders.name}`, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -48,4 +48,12 @@ export abstract class RepoApi {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
protected handleError(message: string, response: any) {
|
||||
console.log(`\n--- ${message} error :`);
|
||||
console.log('\t>>> Status: ', response.status);
|
||||
console.log('\t>>> Text: ', response.response.text);
|
||||
console.log('\t>>> Method: ', response.response.error.method);
|
||||
console.log('\t>>> Path: ', response.response.error.path);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -51,7 +51,7 @@ export class SearchApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return this.searchApi.search(data);
|
||||
} catch (error) {
|
||||
console.log('--- search api queryRecentFiles catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.queryRecentFiles.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ export class SearchApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return this.searchApi.search(data);
|
||||
} catch (error) {
|
||||
console.log('--- search api queryNodesNames catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.queryNodesNames.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,7 @@ export class SearchApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return this.searchApi.search(data);
|
||||
} catch (error) {
|
||||
console.log('--- search api queryNodesExactNames catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.queryNodesExactNames.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ export class SearchApi extends RepoApi {
|
||||
|
||||
return await Utils.retryCall(recentFiles);
|
||||
} catch (error) {
|
||||
console.log('--- search api waitForApi catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.waitForApi.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ export class SearchApi extends RepoApi {
|
||||
|
||||
return await Utils.retryCall(nodes);
|
||||
} catch (error) {
|
||||
console.log('--- search api waitForNodes catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.waitForNodes.name}`, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -43,7 +43,7 @@ export class SharedLinksApi extends RepoApi {
|
||||
};
|
||||
return await this.sharedlinksApi.createSharedLink(data);
|
||||
} catch (error) {
|
||||
console.log('---- shareFileById error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.shareFileById.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,7 @@ export class SharedLinksApi extends RepoApi {
|
||||
return await this.shareFileById(current);
|
||||
}, Promise.resolve());
|
||||
} catch (error) {
|
||||
console.log('--- shared links api shareFilesByIds catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.shareFilesByIds.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ export class SharedLinksApi extends RepoApi {
|
||||
const found = sharedLinks.find(sharedLink => sharedLink.entry.name === name);
|
||||
return (found || { entry: { id: null } }).entry.id;
|
||||
} catch (error) {
|
||||
console.log('--- shared links api getSharedIdOfNode catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.getSharedIdOfNode.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -75,7 +75,7 @@ export class SharedLinksApi extends RepoApi {
|
||||
const id = await this.getSharedIdOfNode(name);
|
||||
return await this.sharedlinksApi.deleteSharedLink(id);
|
||||
} catch (error) {
|
||||
console.log('--- shared links api unshareFile catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.unshareFile.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ export class SharedLinksApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.sharedlinksApi.listSharedLinks();
|
||||
} catch (error) {
|
||||
console.log('--- shared links api getSharedLinks catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.getSharedLinks.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -102,7 +102,7 @@ export class SharedLinksApi extends RepoApi {
|
||||
|
||||
return await Utils.retryCall(sharedFiles);
|
||||
} catch (error) {
|
||||
console.log('--- shared links api waitForApi catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.waitForApi.name}`, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -41,7 +41,7 @@ export class SitesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.sitesApi.getSite(siteId);
|
||||
} catch (error) {
|
||||
console.log('--- sites api getSite catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.getSite.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ export class SitesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.sitesApi.listSiteMembershipsForPerson(this.getUsername());
|
||||
} catch (error) {
|
||||
console.log('--- sites api getSites catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.getSites.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@ export class SitesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return (await this.sitesApi.listSiteContainers(siteId)).list.entries[0].entry.id;
|
||||
} catch (error) {
|
||||
console.log('--- sites api getDocLibId catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.getDocLibId.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ export class SitesApi extends RepoApi {
|
||||
const site = await this.getSite(siteId);
|
||||
return site.entry.visibility;
|
||||
} catch (error) {
|
||||
console.log('--- sites api getVisibility catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.getVisibility.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -81,7 +81,7 @@ export class SitesApi extends RepoApi {
|
||||
const site = await this.getSite(siteId);
|
||||
return site.entry.description;
|
||||
} catch (error) {
|
||||
console.log('--- sites api getDescription catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.getDescription.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,7 @@ export class SitesApi extends RepoApi {
|
||||
const site = await this.getSite(siteId);
|
||||
return site.entry.title;
|
||||
} catch (error) {
|
||||
console.log('--- sites api getTitle catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.getTitle.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -108,7 +108,7 @@ export class SitesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.sitesApi.createSite(site);
|
||||
} catch (error) {
|
||||
console.log('--- sites api createSite catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.createSite.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -120,7 +120,7 @@ export class SitesApi extends RepoApi {
|
||||
return await this.createSite(current, visibility);
|
||||
}, Promise.resolve());
|
||||
} catch (error) {
|
||||
console.log('--- sites api createSites catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.createSites.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ export class SitesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.sitesApi.deleteSite(siteId, { permanent });
|
||||
} catch (error) {
|
||||
console.log('--- sites api deleteSite catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.deleteSite.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ export class SitesApi extends RepoApi {
|
||||
return await this.deleteSite(current, permanent);
|
||||
}, Promise.resolve());
|
||||
} catch (error) {
|
||||
console.log('--- sites api deleteSites catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.deleteSites.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ export class SitesApi extends RepoApi {
|
||||
return await this.deleteSite(current, permanent);
|
||||
}, Promise.resolve());
|
||||
} catch (error) {
|
||||
console.log('--- sites api deleteAllUserSites catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.deleteAllUserSites.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ export class SitesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.sitesApi.updateSiteMembership(siteId, userId, siteRole);
|
||||
} catch (error) {
|
||||
console.log('--- sites api updateSiteMember catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.updateSiteMember.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -181,7 +181,7 @@ export class SitesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.sitesApi.createSiteMembership(siteId, memberBody);
|
||||
} catch (error) {
|
||||
console.log('--- sites api addSiteMember catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.addSiteMember.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -191,7 +191,7 @@ export class SitesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.sitesApi.deleteSiteMembership(siteId, userId);
|
||||
} catch (error) {
|
||||
console.log('--- sites api deleteSiteMember catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.deleteSiteMember.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ export class SitesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.sitesApi.createSiteMembershipRequestForPerson('-me-', body);
|
||||
} catch (error) {
|
||||
console.log('--- sites api requestToJoin catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.requestToJoin.name}`, error);
|
||||
return null;
|
||||
};
|
||||
}
|
||||
@@ -215,7 +215,7 @@ export class SitesApi extends RepoApi {
|
||||
const requests = (await this.sitesApi.getSiteMembershipRequests('-me-')).list.entries.map(e => e.entry.id);
|
||||
return requests.includes(siteId);
|
||||
} catch (error) {
|
||||
console.log('--- sites api hasMembershipRequest catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.hasMembershipRequest.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -233,7 +233,7 @@ export class SitesApi extends RepoApi {
|
||||
|
||||
return await Utils.retryCall(sites);
|
||||
} catch (error) {
|
||||
console.log('sites api waitForApi catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.waitForApi.name}`, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@ export class TrashcanApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.trashcanApi.deleteDeletedNode(id);
|
||||
} catch (error) {
|
||||
console.log('--- trashcan api permanentlyDelete catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.permanentlyDelete.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ export class TrashcanApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.trashcanApi.restoreDeletedNode(id);
|
||||
} catch (error) {
|
||||
console.log('--- trashcan api restore catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.restore.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@ export class TrashcanApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.trashcanApi.listDeletedNodes(opts);
|
||||
} catch (error) {
|
||||
console.log('--- trashcan api getDeletedNodes catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.getDeletedNodes.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -75,7 +75,7 @@ export class TrashcanApi extends RepoApi {
|
||||
return await this.permanentlyDelete(current);
|
||||
}, Promise.resolve());
|
||||
} catch (error) {
|
||||
console.log('--- trashcan api emptyTrash catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.emptyTrash.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ export class TrashcanApi extends RepoApi {
|
||||
|
||||
return await Utils.retryCall(deletedFiles);
|
||||
} catch (error) {
|
||||
console.log('--- trashcan api waitForApi catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.waitForApi.name}`, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -47,7 +47,7 @@ export class UploadApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.upload.uploadFile(file, '', parentFolderId, null, opts);
|
||||
} catch (error) {
|
||||
console.log('--- upload api uploadFile catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.uploadFile.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ export class UploadApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.upload.uploadFile(file, '', parentFolderId, null, opts);
|
||||
} catch (error) {
|
||||
console.log('--- upload api uploadFileWithRename catch error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.uploadFileWithRename.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user