upgrade to latest JS-API and ADF (#896)

* improved update script and latest ADF libs

* upgrade to latest js-api and ADF

* upgrade tests

* update viewer code

* use @alfresco/js-api

* update to latest adf

* fix deprecation issues

* update viewer

* fix copy/move dialog

* change expect

* fix remove site from favorites

* fix unit test

* update adf version

* use ADF upload dialog
This commit is contained in:
Denys Vuika
2019-01-22 14:10:48 +00:00
committed by GitHub
parent afa6de5687
commit f0a3f6f630
82 changed files with 360 additions and 1214 deletions

View File

@@ -26,8 +26,11 @@
import { RepoApi } from '../repo-api';
import { RepoClient } from './../../repo-client';
import { Utils } from '../../../../utilities/utils';
import { FavoritesApi as AdfFavoritesApi, SitesApi as AdfSiteApi } from '@alfresco/js-api';
export class FavoritesApi extends RepoApi {
favoritesApi = new AdfFavoritesApi(this.alfrescoJsApi);
sitesApi = new AdfSiteApi(this.alfrescoJsApi);
constructor(username?, password?) {
super(username, password);
@@ -42,7 +45,7 @@ export class FavoritesApi extends RepoApi {
}
}
};
return await this.alfrescoJsApi.core.favoritesApi.addFavorite('-me-', data);
return await this.favoritesApi.createFavorite('-me-', data);
}
async addFavoriteById(nodeType: 'file' | 'folder' | 'site', id: string) {
@@ -50,7 +53,7 @@ export class FavoritesApi extends RepoApi {
await this.apiAuth();
if ( nodeType === 'site' ) {
guid = (await this.alfrescoJsApi.core.sitesApi.getSite(id)).entry.guid;
guid = (await this.sitesApi.getSite(id)).entry.guid;
} else {
guid = id;
}
@@ -62,7 +65,7 @@ export class FavoritesApi extends RepoApi {
}
};
try {
return await this.alfrescoJsApi.core.favoritesApi.addFavorite('-me-', data);
return await this.favoritesApi.createFavorite('-me-', data);
} catch (error) {
// console.log('--- add favorite by id catch ');
}
@@ -77,12 +80,12 @@ export class FavoritesApi extends RepoApi {
async getFavorites() {
await this.apiAuth();
return await this.alfrescoJsApi.core.favoritesApi.getFavorites(this.getUsername());
return await this.favoritesApi.listFavorites(this.getUsername());
}
async getFavoriteById(nodeId: string) {
await this.apiAuth();
return await this.alfrescoJsApi.core.favoritesApi.getFavorite('-me-', nodeId);
return await this.favoritesApi.getFavorite('-me-', nodeId);
}
async isFavorite(nodeId: string) {
@@ -111,7 +114,7 @@ export class FavoritesApi extends RepoApi {
async removeFavoriteById(nodeId: string) {
await this.apiAuth();
try {
return await this.alfrescoJsApi.core.peopleApi.removeFavoriteSite('-me-', nodeId);
return await this.favoritesApi.deleteSiteFavorite('-me-', nodeId);
} catch (error) {
// console.log('--- remove favorite by id catch ');
}
@@ -139,6 +142,5 @@ export class FavoritesApi extends RepoApi {
} catch (error) {
console.log('-----> catch favorites: ', error);
}
}
}

View File

@@ -23,27 +23,26 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { NodeBodyLock } from 'alfresco-js-api-node';
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';
export class NodesApi extends RepoApi {
nodesApi = new AdfNodeApi(this.alfrescoJsApi);
constructor(username?, password?) {
super(username, password);
}
// nodes
async getNodeByPath(relativePath: string = '/') {
await this.apiAuth();
return await this.alfrescoJsApi.core.nodesApi.getNode('-my-', { relativePath });
return await this.nodesApi.getNode('-my-', { relativePath });
}
async getNodeById(id: string) {
await this.apiAuth();
return await this.alfrescoJsApi.core.nodesApi.getNode(id);
return await this.nodesApi.getNode(id);
}
async getNodeDescription(name: string, parentId: string) {
@@ -75,7 +74,7 @@ export class NodesApi extends RepoApi {
async deleteNodeById(id: string, permanent: boolean = true) {
await this.apiAuth();
try {
return await this.alfrescoJsApi.core.nodesApi.deleteNode(id, { permanent });
return await this.nodesApi.deleteNode(id, { permanent });
} catch (error) {
console.log('------ deleteNodeById failed ');
}
@@ -100,14 +99,12 @@ export class NodesApi extends RepoApi {
}, Promise.resolve());
}
// children
async getNodeChildren(nodeId: string) {
const opts = {
include: [ 'properties' ]
};
await this.apiAuth();
return await this.alfrescoJsApi.core.nodesApi.getNodeChildren(nodeId, opts);
return await this.nodesApi.listNodeChildren(nodeId, opts);
}
async deleteNodeChildren(parentId: string) {
@@ -138,7 +135,7 @@ export class NodesApi extends RepoApi {
}
await this.apiAuth();
return await this.alfrescoJsApi.core.nodesApi.addNode(parentId, nodeBody);
return await this.nodesApi.createNode(parentId, nodeBody);
}
async createFile(name: string, parentId: string = '-my-', title: string = '', description: string = '') {
@@ -155,7 +152,7 @@ export class NodesApi extends RepoApi {
async createChildren(data: NodeBodyCreate[]): Promise<any> {
await this.apiAuth();
return await this.alfrescoJsApi.core.nodesApi.addNode('-my-', data);
return await this.nodesApi.createNode('-my-', <any>data);
}
async createContent(content: NodeContentTree, relativePath: string = '/') {
@@ -173,17 +170,17 @@ export class NodesApi extends RepoApi {
// node content
async getNodeContent(nodeId: string) {
await this.apiAuth();
return await this.alfrescoJsApi.core.nodesApi.getNodeContent(nodeId);
return await this.nodesApi.getNodeContent(nodeId);
}
async editNodeContent(nodeId: string, content: string) {
await this.apiAuth();
return await this.alfrescoJsApi.core.nodesApi.updateNodeContent(nodeId, content);
return await this.nodesApi.updateNodeContent(nodeId, content);
}
async renameNode(nodeId: string, newName: string) {
await this.apiAuth();
return this.alfrescoJsApi.core.nodesApi.updateNode(nodeId, { name: newName });
return this.nodesApi.updateNode(nodeId, { name: newName });
}
// node permissions
@@ -201,12 +198,12 @@ export class NodesApi extends RepoApi {
};
await this.apiAuth();
return await this.alfrescoJsApi.core.nodesApi.updateNode(nodeId, data);
return await this.nodesApi.updateNode(nodeId, data);
}
async getNodePermissions(nodeId: string) {
await this.apiAuth();
return await this.alfrescoJsApi.core.nodesApi.getNode(nodeId, { include: ['permissions'] });
return await this.nodesApi.getNode(nodeId, { include: ['permissions'] });
}
// lock node
@@ -215,11 +212,11 @@ export class NodesApi extends RepoApi {
type: lockType
};
await this.apiAuth();
return await this.alfrescoJsApi.core.nodesApi.lockNode(nodeId, data );
return await this.nodesApi.lockNode(nodeId, data );
}
async unlockFile(nodeId: string) {
await this.apiAuth();
return await this.alfrescoJsApi.core.nodesApi.unlockNode(nodeId);
return await this.nodesApi.unlockNode(nodeId);
}
}

View File

@@ -25,8 +25,10 @@
import { PersonModel, Person } from './people-api-models';
import { RepoApi } from '../repo-api';
import { PeopleApi as AdfPeopleApi} from '@alfresco/js-api';
export class PeopleApi extends RepoApi {
peopleApi = new AdfPeopleApi(this.alfrescoJsApi);
constructor(username?, password?) {
super(username, password);
@@ -35,17 +37,17 @@ export class PeopleApi extends RepoApi {
async createUser(user: PersonModel) {
const person = new Person(user);
await this.apiAuth();
return await this.alfrescoJsApi.core.peopleApi.addPerson(person);
return await this.peopleApi.createPerson(person);
}
async getUser(username: string) {
await this.apiAuth();
return await this.alfrescoJsApi.core.peopleApi.getPerson(username);
return await this.peopleApi.getPerson(username);
}
async updateUser(username: string, userDetails?: PersonModel) {
await this.apiAuth();
return this.alfrescoJsApi.core.peopleApi.updatePerson(username, userDetails);
return this.peopleApi.updatePerson(username, userDetails);
}
async disableUser(username: string) {

View File

@@ -25,8 +25,10 @@
import { RepoApi } from '../repo-api';
import { Utils } from '../../../../utilities/utils';
import { QueriesApi as AdfQueriesApi } from '@alfresco/js-api';
export class QueriesApi extends RepoApi {
queriesApi = new AdfQueriesApi(this.alfrescoJsApi);
constructor(username?, password?) {
super(username, password);
@@ -39,7 +41,7 @@ export class QueriesApi extends RepoApi {
};
await this.apiAuth();
return this.alfrescoJsApi.core.queriesApi.findSites(searchTerm, data);
return this.queriesApi.findSites(searchTerm, data);
}
async findNodes(searchTerm: string) {

View File

@@ -23,21 +23,22 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import * as AlfrescoApi from 'alfresco-js-api-node';
import { AlfrescoApi } from '@alfresco/js-api';
import { REPO_API_HOST } from '../../../configs';
import { RepoClientAuth } from '../repo-client-models';
export abstract class RepoApi {
alfrescoJsApi = new AlfrescoApi({
provider: 'ECM',
hostEcm: REPO_API_HOST
});
alfrescoJsApi = new AlfrescoApi();
constructor(
private username: string = RepoClientAuth.DEFAULT_USERNAME,
private password: string = RepoClientAuth.DEFAULT_PASSWORD
) {}
) {
this.alfrescoJsApi.setConfig({
provider: 'ECM',
hostEcm: REPO_API_HOST
});
}
apiAuth() {
return this.alfrescoJsApi.login(this.username, this.password);

View File

@@ -25,8 +25,10 @@
import { RepoApi } from '../repo-api';
import { Utils } from '../../../../utilities/utils';
import { SearchApi as AdfSearchApi } from '@alfresco/js-api';
export class SearchApi extends RepoApi {
searchApi = new AdfSearchApi(this.alfrescoJsApi);
constructor(username?, password?) {
super(username, password);
@@ -46,7 +48,7 @@ export class SearchApi extends RepoApi {
};
await this.apiAuth();
return this.alfrescoJsApi.search.searchApi.search(data);
return this.searchApi.search(data);
}
async queryNodesNames(searchTerm: string) {
@@ -61,7 +63,7 @@ export class SearchApi extends RepoApi {
};
await this.apiAuth();
return this.alfrescoJsApi.search.searchApi.search(data);
return this.searchApi.search(data);
}
async queryNodesExactNames(searchTerm: string) {
@@ -76,7 +78,7 @@ export class SearchApi extends RepoApi {
};
await this.apiAuth();
return this.alfrescoJsApi.search.searchApi.search(data);
return this.searchApi.search(data);
}
async waitForApi(username, data) {

View File

@@ -25,8 +25,10 @@
import { RepoApi } from '../repo-api';
import { Utils } from '../../../../utilities/utils';
import { SharedlinksApi as AdfSharedlinksApi } from '@alfresco/js-api';
export class SharedLinksApi extends RepoApi {
sharedlinksApi = new AdfSharedlinksApi(this.alfrescoJsApi);
constructor(username?, password?) {
super(username, password);
@@ -39,7 +41,7 @@ export class SharedLinksApi extends RepoApi {
nodeId: id,
expiresAt: expireDate
};
return await this.alfrescoJsApi.core.sharedlinksApi.addSharedLink(data);
return await this.sharedlinksApi.createSharedLink(data);
} catch (error) {
console.log('---- shareFileById error: ', error);
}
@@ -60,12 +62,12 @@ export class SharedLinksApi extends RepoApi {
async unshareFile(name: string) {
const id = await this.getSharedIdOfNode(name);
return await this.alfrescoJsApi.core.sharedlinksApi.deleteSharedLink(id);
return await this.sharedlinksApi.deleteSharedLink(id);
}
async getSharedLinks() {
await this.apiAuth();
return await this.alfrescoJsApi.core.sharedlinksApi.findSharedLinks();
return await this.sharedlinksApi.listSharedLinks();
}
async waitForApi(data) {

View File

@@ -24,11 +24,13 @@
*/
import { RepoApi } from '../repo-api';
import { SiteBody, SiteMemberRoleBody, SiteMemberBody } from 'alfresco-js-api-node';
import { SiteBody, SiteMemberRoleBody, SiteMemberBody } from '@alfresco/js-api';
import { SITE_VISIBILITY } from '../../../../configs';
import { Utils } from '../../../../utilities/utils';
import { SitesApi as AdfSiteApi } from '@alfresco/js-api';
export class SitesApi extends RepoApi {
sitesApi = new AdfSiteApi(this.alfrescoJsApi);
constructor(username?, password?) {
super(username, password);
@@ -36,17 +38,17 @@ export class SitesApi extends RepoApi {
async getSite(siteId: string) {
await this.apiAuth();
return await this.alfrescoJsApi.core.sitesApi.getSite(siteId);
return await this.sitesApi.getSite(siteId);
}
async getSites() {
await this.apiAuth();
return await this.alfrescoJsApi.core.peopleApi.getSiteMembership(this.getUsername());
return await this.sitesApi.listSiteMembershipsForPerson(this.getUsername());
}
async getDocLibId(siteId: string) {
await this.apiAuth();
return (await this.alfrescoJsApi.core.sitesApi.getSiteContainers(siteId)).list.entries[0].entry.id;
return (await this.sitesApi.listSiteContainers(siteId)).list.entries[0].entry.id;
}
async getVisibility(siteId: string) {
@@ -73,7 +75,7 @@ export class SitesApi extends RepoApi {
};
await this.apiAuth();
return await this.alfrescoJsApi.core.sitesApi.createSite(site);
return await this.sitesApi.createSite(site);
}
async createSites(titles: string[], visibility?: string) {
@@ -85,7 +87,7 @@ export class SitesApi extends RepoApi {
async deleteSite(siteId: string, permanent: boolean = true) {
await this.apiAuth();
return await this.alfrescoJsApi.core.sitesApi.deleteSite(siteId, { permanent });
return await this.sitesApi.deleteSite(siteId, { permanent });
}
async deleteSites(siteIds: string[], permanent: boolean = true) {
@@ -110,7 +112,7 @@ export class SitesApi extends RepoApi {
};
await this.apiAuth();
return await this.alfrescoJsApi.core.sitesApi.updateSiteMember(siteId, userId, siteRole);
return await this.sitesApi.updateSiteMembership(siteId, userId, siteRole);
}
async addSiteMember(siteId: string, userId: string, role: string) {
@@ -120,12 +122,12 @@ export class SitesApi extends RepoApi {
};
await this.apiAuth();
return await this.alfrescoJsApi.core.sitesApi.addSiteMember(siteId, memberBody);
return await this.sitesApi.createSiteMembership(siteId, memberBody);
}
async deleteSiteMember(siteId: string, userId: string) {
await this.apiAuth();
return await this.alfrescoJsApi.core.sitesApi.removeSiteMember(siteId, userId);
return await this.sitesApi.deleteSiteMembership(siteId, userId);
}
async requestToJoin(siteId: string) {
@@ -134,7 +136,7 @@ export class SitesApi extends RepoApi {
};
await this.apiAuth();
try {
return await this.alfrescoJsApi.core.peopleApi.addSiteMembershipRequest('-me-', body);
return await this.sitesApi.createSiteMembershipRequestForPerson('-me-', body);
} catch (error) {
console.log('====== requestToJoin catch ', error);
};
@@ -142,7 +144,7 @@ export class SitesApi extends RepoApi {
async hasMembershipRequest(siteId: string) {
await this.apiAuth();
const requests = (await this.alfrescoJsApi.core.peopleApi.getSiteMembershipRequests('-me-')).list.entries.map(e => e.entry.id);
const requests = (await this.sitesApi.getSiteMembershipRequests('-me-')).list.entries.map(e => e.entry.id);
return requests.includes(siteId);
}

View File

@@ -25,8 +25,10 @@
import { RepoApi } from '../repo-api';
import { Utils } from '../../../../utilities/utils';
import { TrashcanApi as AdfTrashcanApi} from '@alfresco/js-api';
export class TrashcanApi extends RepoApi {
trashcanApi = new AdfTrashcanApi(this.alfrescoJsApi);
constructor(username?, password?) {
super(username, password);
@@ -34,12 +36,12 @@ export class TrashcanApi extends RepoApi {
async permanentlyDelete(id: string) {
await this.apiAuth();
return await this.alfrescoJsApi.core.nodesApi.purgeDeletedNode(id);
return await this.trashcanApi.deleteDeletedNode(id);
}
async restore(id: string) {
await this.apiAuth();
return await this.alfrescoJsApi.core.nodesApi.restoreNode(id);
return await this.trashcanApi.restoreDeletedNode(id);
}
async getDeletedNodes() {
@@ -47,7 +49,7 @@ export class TrashcanApi extends RepoApi {
maxItems: 1000
};
await this.apiAuth();
return await this.alfrescoJsApi.core.nodesApi.getDeletedNodes(opts);
return await this.trashcanApi.listDeletedNodes(opts);
}
async emptyTrash() {

View File

@@ -25,10 +25,12 @@
import { RepoApi } from '../repo-api';
import { E2E_ROOT_PATH } from '../../../../configs';
import { UploadApi as AdfUploadApi } from '@alfresco/js-api';
const fs = require('fs');
export class UploadApi extends RepoApi {
upload = new AdfUploadApi(this.alfrescoJsApi);
constructor(username?, password?) {
super(username, password);
@@ -42,7 +44,7 @@ export class UploadApi extends RepoApi {
};
await this.apiAuth();
return await this.alfrescoJsApi.upload.uploadFile(file, '', parentFolderId, null, opts);
return await this.upload.uploadFile(file, '', parentFolderId, null, opts);
}
async uploadFileWithRename(fileName: string, parentFolderId: string = '-my-', newName: string) {
@@ -53,7 +55,7 @@ export class UploadApi extends RepoApi {
};
await this.apiAuth();
return await this.alfrescoJsApi.upload.uploadFile(file, '', parentFolderId, null, opts);
return await this.upload.uploadFile(file, '', parentFolderId, null, opts);
}
}