mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
Sync latest development (#147)
* fix navigation docs issues * update documentation (#142) * update documentation changed start command used a tags for links nested inside table and p tags, because Github did not render them correctly * set link to navigation on side-nav.md * [ACA-1061] update project version (#145) [ACA-1061] update project version * move e2e to a separate repo * fix "view" button (toolbar)
This commit is contained in:
@@ -1,86 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { promise } from 'protractor';
|
||||
import { RepoApi } from '../repo-api';
|
||||
import { NodesApi } from '../nodes/nodes-api';
|
||||
import { RepoClient } from './../../repo-client';
|
||||
|
||||
export class FavoritesApi extends RepoApi {
|
||||
|
||||
addFavorite(api: RepoClient, nodeType: string, name: string): Promise<any> {
|
||||
return api.nodes.getNodeByPath(name)
|
||||
.then((response) => {
|
||||
const { id } = response.data.entry;
|
||||
return ([{
|
||||
target: {
|
||||
[nodeType]: {
|
||||
guid: id
|
||||
}
|
||||
}
|
||||
}]);
|
||||
})
|
||||
.then((data) => {
|
||||
return this.post(`/people/-me-/favorites`, { data });
|
||||
})
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
||||
addFavoriteById(nodeType: string, id: string): Promise<any> {
|
||||
const data = [{
|
||||
target: {
|
||||
[nodeType]: {
|
||||
guid: id
|
||||
}
|
||||
}
|
||||
}];
|
||||
return this.post(`/people/-me-/favorites`, { data })
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
||||
addFavoritesByIds(nodeType: string, ids: string[]): Promise<any[]> {
|
||||
return ids.reduce((previous, current) => (
|
||||
previous.then(() => this.addFavoriteById(nodeType, current))
|
||||
), Promise.resolve());
|
||||
}
|
||||
|
||||
getFavorite(api: RepoClient, name: string): Promise<any> {
|
||||
return api.nodes.getNodeByPath(name)
|
||||
.then((response) => {
|
||||
const { id } = response.data.entry;
|
||||
return this.get(`/people/-me-/favorites/${id}`);
|
||||
})
|
||||
.catch((response) => Promise.resolve(response));
|
||||
}
|
||||
|
||||
removeFavorite(api: RepoClient, nodeType: string, name: string): Promise<any> {
|
||||
return api.nodes.getNodeByPath(name)
|
||||
.then((response) => {
|
||||
const { id } = response.data.entry;
|
||||
return this.delete(`/people/-me-/favorites/${id}`);
|
||||
})
|
||||
.catch(this.handleError);
|
||||
}
|
||||
}
|
@@ -1,38 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export const NODE_TYPE_FILE = 'cm:content';
|
||||
export const NODE_TYPE_FOLDER = 'cm:folder';
|
||||
export const NODE_TITLE = 'cm:title';
|
||||
export const NODE_DESCRIPTION = 'cm:description';
|
||||
|
||||
export class NodeBodyCreate {
|
||||
constructor(
|
||||
public name: string,
|
||||
public nodeType: string,
|
||||
public relativePath: string = '/',
|
||||
public properties?: any[]
|
||||
) {}
|
||||
}
|
@@ -1,85 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { NodeBodyCreate, NODE_TYPE_FILE, NODE_TYPE_FOLDER, NODE_TITLE, NODE_DESCRIPTION } from './node-body-create';
|
||||
|
||||
export interface NodeContentTree {
|
||||
name?: string;
|
||||
files?: string[];
|
||||
folders?: (string|NodeContentTree)[];
|
||||
title?: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export function flattenNodeContentTree(content: NodeContentTree, relativePath: string = '/'): NodeBodyCreate[] {
|
||||
const { name, files, folders, title, description } = content;
|
||||
let data: NodeBodyCreate[] = [];
|
||||
let properties: any;
|
||||
|
||||
properties = {
|
||||
[NODE_TITLE]: title,
|
||||
[NODE_DESCRIPTION]: description
|
||||
};
|
||||
|
||||
if (name) {
|
||||
data = data.concat([{
|
||||
nodeType: NODE_TYPE_FOLDER,
|
||||
name,
|
||||
relativePath,
|
||||
properties
|
||||
}]);
|
||||
|
||||
relativePath = (relativePath === '/')
|
||||
? `/${name}`
|
||||
: `${relativePath}/${name}`;
|
||||
}
|
||||
|
||||
if (folders) {
|
||||
const foldersData: NodeBodyCreate[] = folders
|
||||
.map((folder: (string|NodeContentTree)): NodeBodyCreate[] => {
|
||||
const folderData: NodeContentTree = (typeof folder === 'string')
|
||||
? { name: folder }
|
||||
: folder;
|
||||
|
||||
return flattenNodeContentTree(folderData, relativePath);
|
||||
})
|
||||
.reduce((nodesData: NodeBodyCreate[], folderData: NodeBodyCreate[]) => nodesData.concat(folderData), []);
|
||||
|
||||
data = data.concat(foldersData);
|
||||
}
|
||||
|
||||
if (files) {
|
||||
const filesData: NodeBodyCreate[] = files
|
||||
.map((filename: string): NodeBodyCreate => ({
|
||||
nodeType: NODE_TYPE_FILE,
|
||||
name: filename,
|
||||
relativePath
|
||||
}));
|
||||
|
||||
data = data.concat(filesData);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
@@ -1,104 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { RepoApi } from '../repo-api';
|
||||
import { NodeBodyCreate, NODE_TYPE_FILE, NODE_TYPE_FOLDER } from './node-body-create';
|
||||
import { NodeContentTree, flattenNodeContentTree } from './node-content-tree';
|
||||
|
||||
export class NodesApi extends RepoApi {
|
||||
// nodes
|
||||
getNodeByPath(relativePath: string = '/'): Promise<any> {
|
||||
return this
|
||||
.get(`/nodes/-my-`, { parameters: { relativePath } })
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
||||
getNodeById(id: string): Promise<any> {
|
||||
return this
|
||||
.get(`/nodes/${id}`)
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
||||
getNodeDescription(name: string): Promise<string> {
|
||||
return this.getNodeByPath(name)
|
||||
.then(response => response.data.entry.properties['cm:description'])
|
||||
.catch(() => Promise.resolve(''));
|
||||
}
|
||||
|
||||
deleteNodeById(id: string, permanent: boolean = true): Promise<any> {
|
||||
return this
|
||||
.delete(`/nodes/${id}?permanent=${permanent}`)
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
||||
deleteNodeByPath(path: string, permanent: boolean = true): Promise<any> {
|
||||
return this
|
||||
.getNodeByPath(path)
|
||||
.then((response: any): string => response.data.entry.id)
|
||||
.then((id: string): any => this.deleteNodeById(id, permanent))
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
||||
deleteNodes(names: string[], relativePath: string = '', permanent: boolean = true): Promise<any[]> {
|
||||
return names.reduce((previous, current) => (
|
||||
previous.then(() => this.deleteNodeByPath(`${relativePath}/${current}`, permanent))
|
||||
), Promise.resolve());
|
||||
}
|
||||
|
||||
deleteNodesById(ids: string[], permanent: boolean = true): Promise<any[]> {
|
||||
return ids.reduce((previous, current) => (
|
||||
previous.then(() => this.deleteNodeById(current, permanent))
|
||||
), Promise.resolve());
|
||||
}
|
||||
|
||||
// children
|
||||
getNodeChildren(nodeId: string): Promise<any> {
|
||||
return this
|
||||
.get(`/nodes/${nodeId}/children`)
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
||||
createChildren(data: NodeBodyCreate[]): Promise<any> {
|
||||
return this
|
||||
.post(`/nodes/-my-/children`, { data })
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
||||
createContent(content: NodeContentTree, relativePath: string = '/'): Promise<any> {
|
||||
return this.createChildren(flattenNodeContentTree(content, relativePath));
|
||||
}
|
||||
|
||||
createNodeWithProperties(name: string, title?: string, description?: string, relativePath: string = '/'): Promise<any> {
|
||||
return this.createContent({ name, title, description }, relativePath);
|
||||
}
|
||||
|
||||
createFolders(names: string[], relativePath: string = '/'): Promise<any> {
|
||||
return this.createContent({ folders: names }, relativePath);
|
||||
}
|
||||
|
||||
createFiles(names: string[], relativePath: string = '/'): Promise<any> {
|
||||
return this.createContent({ files: names }, relativePath);
|
||||
}
|
||||
}
|
@@ -1,43 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export class Person {
|
||||
id?: string;
|
||||
password?: string;
|
||||
firstName?: string;
|
||||
lastName?: string;
|
||||
email?: string;
|
||||
properties?: any;
|
||||
|
||||
constructor(username: string, password: string, details: Person) {
|
||||
this.id = username;
|
||||
this.password = password || username;
|
||||
this.firstName = username;
|
||||
this.lastName = username;
|
||||
this.email = `${username}@alfresco.com`;
|
||||
|
||||
Object.assign(this, details);
|
||||
}
|
||||
}
|
@@ -1,60 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { RepoApi } from '../repo-api';
|
||||
import { Person } from './people-api-models';
|
||||
|
||||
export class PeopleApi extends RepoApi {
|
||||
getUser(username: string) {
|
||||
return this
|
||||
.get(`/people/${username}`)
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
||||
updateUser(username: string, details?: Person): Promise<any> {
|
||||
if (details.id) {
|
||||
delete details.id;
|
||||
}
|
||||
|
||||
return this
|
||||
.put(`/people/${username}`, { data: details })
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
||||
createUser(username: string, password?: string, details?: Person): Promise<any> {
|
||||
const person: Person = new Person(username, password, details);
|
||||
const onSuccess = (response) => response;
|
||||
const onError = (response) => {
|
||||
return (response.statusCode === 409)
|
||||
? Promise.resolve(this.updateUser(username, person))
|
||||
: Promise.reject(response);
|
||||
};
|
||||
|
||||
return this
|
||||
.post(`/people`, { data: person })
|
||||
.then(onSuccess, onError)
|
||||
.catch(this.handleError);
|
||||
}
|
||||
}
|
@@ -1,71 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { RestClient, RestClientArgs, RestClientResponse } from '../../rest-client/rest-client';
|
||||
import { RepoClientAuth, RepoClientConfig } from '../repo-client-models';
|
||||
|
||||
export abstract class RepoApi {
|
||||
private client: RestClient;
|
||||
private defaults: RepoClientConfig = new RepoClientConfig();
|
||||
|
||||
constructor(
|
||||
auth: RepoClientAuth = new RepoClientAuth(),
|
||||
private config?: RepoClientConfig
|
||||
) {
|
||||
const { username, password } = auth;
|
||||
|
||||
this.client = new RestClient(username, password);
|
||||
}
|
||||
|
||||
private createEndpointUri(endpoint: string): string {
|
||||
const { defaults, config } = this;
|
||||
const { host, tenant } = Object.assign(defaults, config);
|
||||
|
||||
return `${host}/alfresco/api/${tenant}/public/alfresco/versions/1${endpoint}`;
|
||||
}
|
||||
|
||||
protected handleError(response: RestClientResponse) {
|
||||
const { request: { method, path, data }, data: error } = response;
|
||||
|
||||
console.log(`ERROR on ${method}\n${path}\n${data}`);
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
protected get(endpoint: string, args: RestClientArgs = {}) {
|
||||
return this.client.get(this.createEndpointUri(endpoint), args);
|
||||
}
|
||||
|
||||
protected post(endpoint: string, args: RestClientArgs = {}) {
|
||||
return this.client.post(this.createEndpointUri(endpoint), args);
|
||||
}
|
||||
|
||||
protected put(endpoint: string, args: RestClientArgs = {}) {
|
||||
return this.client.put(this.createEndpointUri(endpoint), args);
|
||||
}
|
||||
|
||||
protected delete(endpoint: string, args: RestClientArgs = {}) {
|
||||
return this.client.delete(this.createEndpointUri(endpoint), args);
|
||||
}
|
||||
}
|
@@ -1,50 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { RepoApi } from '../repo-api';
|
||||
import { NodesApi } from '../nodes/nodes-api';
|
||||
import { RepoClient } from './../../repo-client';
|
||||
|
||||
export class SharedLinksApi extends RepoApi {
|
||||
|
||||
shareFileById(id: string): Promise<any> {
|
||||
const data = [{ nodeId: id }];
|
||||
|
||||
return this.post(`/shared-links`, { data })
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
||||
shareFilesByIds(ids: string[]): Promise<any[]> {
|
||||
return ids.reduce((previous, current) => (
|
||||
previous.then(() => this.shareFileById(current))
|
||||
), Promise.resolve());
|
||||
}
|
||||
|
||||
getSharedLinks(): Promise<any> {
|
||||
return this.get(`/shared-links`)
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
||||
}
|
@@ -1,42 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { SITE_VISIBILITY } from '../../../../configs';
|
||||
|
||||
export class Site {
|
||||
title?: string;
|
||||
visibility?: string = SITE_VISIBILITY.PUBLIC;
|
||||
id?: string;
|
||||
description?: string;
|
||||
|
||||
constructor(title: string, visibility: string, details: Site) {
|
||||
this.title = title;
|
||||
this.visibility = visibility;
|
||||
this.id = title;
|
||||
this.description = `${title} description`;
|
||||
|
||||
Object.assign(this, details);
|
||||
}
|
||||
}
|
@@ -1,111 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { RepoApi } from '../repo-api';
|
||||
import { Site } from './sites-api-models';
|
||||
|
||||
export class SitesApi extends RepoApi {
|
||||
getSite(id: string) {
|
||||
return this
|
||||
.get(`/sites/${id}`)
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
||||
updateSite(id: string, details?: Site): Promise<any> {
|
||||
if (details.id) {
|
||||
delete details.id;
|
||||
}
|
||||
|
||||
return this
|
||||
.put(`/sites/${id}`, { data: details })
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
||||
createOrUpdateSite(title: string, visibility: string, details?: Site): Promise<any> {
|
||||
const site: Site = new Site(title, visibility, details);
|
||||
const onSuccess = (response) => response;
|
||||
const onError = (response) => {
|
||||
return (response.statusCode === 409)
|
||||
? Promise.resolve(this.updateSite(site.id, site))
|
||||
: Promise.reject(response);
|
||||
};
|
||||
|
||||
return this
|
||||
.post(`/sites`, { data: site })
|
||||
.then(onSuccess, onError)
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
||||
createSite(title: string, visibility: string, details?: Site): Promise<any> {
|
||||
const site: Site = new Site(title, visibility, details);
|
||||
return this
|
||||
.post(`/sites`, { data: site })
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
||||
createSites(titles: string[], visibility: string): Promise<any[]> {
|
||||
return titles.reduce((previous, current) => (
|
||||
previous.then(() => this.createSite(current, visibility))
|
||||
), Promise.resolve());
|
||||
}
|
||||
|
||||
deleteSite(id: string, permanent: boolean = true): Promise<any> {
|
||||
return this
|
||||
.delete(`/sites/${id}?permanent=${permanent}`)
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
||||
deleteSites(ids: string[], permanent: boolean = true): Promise<any[]> {
|
||||
return ids.reduce((previous, current) => (
|
||||
previous.then(() => this.deleteSite(current))
|
||||
), Promise.resolve());
|
||||
}
|
||||
|
||||
updateSiteMember(siteId: string, userId: string, role: string): Promise<any> {
|
||||
return this
|
||||
.put(`/sites/${siteId}/members/${userId}`, { data: { role } })
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
||||
addSiteMember(siteId: string, userId: string, role: string): Promise<any> {
|
||||
const onSuccess = (response) => response;
|
||||
const onError = (response) => {
|
||||
return (response.statusCode === 409)
|
||||
? Promise.resolve(this.updateSiteMember(siteId, userId, role))
|
||||
: Promise.reject(response);
|
||||
};
|
||||
|
||||
return this
|
||||
.post(`/sites/${siteId}/members`, { data: { role, id: userId } })
|
||||
.then(onSuccess, onError)
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
||||
deleteSiteMember(siteId: string, userId: string): Promise<any> {
|
||||
return this
|
||||
.delete(`/sites/${siteId}/members/${userId}`)
|
||||
.catch(this.handleError);
|
||||
}
|
||||
}
|
@@ -1,54 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { RepoApi } from '../repo-api';
|
||||
|
||||
export class TrashcanApi extends RepoApi {
|
||||
permanentlyDelete(id: string): Promise<any> {
|
||||
return this
|
||||
.delete(`/deleted-nodes/${id}`)
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
||||
getDeletedNodes(): Promise<any> {
|
||||
return this
|
||||
.get(`/deleted-nodes?maxItems=1000`)
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
||||
emptyTrash(): Promise<any> {
|
||||
return this.getDeletedNodes()
|
||||
.then(resp => {
|
||||
return resp.data.list.entries.map(entries => entries.entry.id);
|
||||
})
|
||||
.then(ids => {
|
||||
return ids.reduce((previous, current) => (
|
||||
previous.then(() => this.permanentlyDelete(current))
|
||||
), Promise.resolve());
|
||||
})
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
||||
}
|
@@ -1,46 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {
|
||||
ADMIN_USERNAME,
|
||||
ADMIN_PASSWORD,
|
||||
REPO_API_HOST,
|
||||
REPO_API_TENANT
|
||||
} from '../../configs';
|
||||
|
||||
export class RepoClientAuth {
|
||||
static DEFAULT_USERNAME: string = ADMIN_USERNAME;
|
||||
static DEFAULT_PASSWORD: string = ADMIN_PASSWORD;
|
||||
|
||||
constructor(
|
||||
public username: string = RepoClientAuth.DEFAULT_USERNAME,
|
||||
public password: string = RepoClientAuth.DEFAULT_PASSWORD
|
||||
) {}
|
||||
}
|
||||
|
||||
export class RepoClientConfig {
|
||||
host?: string = REPO_API_HOST;
|
||||
tenant?: string = REPO_API_TENANT;
|
||||
}
|
@@ -1,57 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { RepoClientAuth, RepoClientConfig } from './repo-client-models';
|
||||
|
||||
import { PeopleApi } from './apis/people/people-api';
|
||||
import { NodesApi } from './apis/nodes/nodes-api';
|
||||
import { SitesApi } from './apis/sites/sites-api';
|
||||
import { FavoritesApi } from './apis/favorites/favorites-api';
|
||||
import { SharedLinksApi } from './apis/shared-links/shared-links-api';
|
||||
import { TrashcanApi } from './apis/trashcan/trashcan-api';
|
||||
|
||||
export class RepoClient {
|
||||
public people: PeopleApi = new PeopleApi(this.auth, this.config);
|
||||
public nodes: NodesApi = new NodesApi(this.auth, this.config);
|
||||
public sites: SitesApi = new SitesApi(this.auth, this.config);
|
||||
public favorites: FavoritesApi = new FavoritesApi(this.auth, this.config);
|
||||
public shared: SharedLinksApi = new SharedLinksApi(this.auth, this.config);
|
||||
public trashcan: TrashcanApi = new TrashcanApi(this.auth, this.config);
|
||||
|
||||
constructor(
|
||||
private username: string = RepoClientAuth.DEFAULT_USERNAME,
|
||||
private password: string = RepoClientAuth.DEFAULT_PASSWORD,
|
||||
private config?: RepoClientConfig
|
||||
) {}
|
||||
|
||||
private get auth(): RepoClientAuth {
|
||||
const { username, password } = this;
|
||||
return { username, password };
|
||||
}
|
||||
}
|
||||
|
||||
export * from './apis/nodes/node-body-create';
|
||||
export * from './apis/nodes/node-content-tree';
|
||||
export * from './apis/nodes/nodes-api';
|
@@ -1,79 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
const chalk = require('chalk');
|
||||
/* tslint:enable */
|
||||
|
||||
export const log = {
|
||||
i: 0,
|
||||
|
||||
get indentation(): string {
|
||||
return new Array(this.i).fill(' ').join('');
|
||||
},
|
||||
|
||||
indent() {
|
||||
this.i++;
|
||||
return this;
|
||||
},
|
||||
|
||||
dedent() {
|
||||
this.i--;
|
||||
return this;
|
||||
},
|
||||
|
||||
log(message: string = '', options: any = { ignoreIndentation: false }) {
|
||||
const indentation = (!options.ignoreIndentation)
|
||||
? this.indentation
|
||||
: '';
|
||||
|
||||
console.log(`${indentation}${message}`);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
blank() {
|
||||
return this.log();
|
||||
},
|
||||
|
||||
info(message: string = '', options: any = { bold: false, title: false }) {
|
||||
const { bold } = options;
|
||||
const style = (bold ? chalk.bold : chalk).gray;
|
||||
|
||||
return this.log(style(message), options);
|
||||
},
|
||||
|
||||
success(message: string = '', options: any = { bold: false }) {
|
||||
const style = options.bold ? chalk.bold.green : chalk.green;
|
||||
|
||||
return this.log(style(message), options);
|
||||
},
|
||||
|
||||
error(message: string = '', options: any = { bold: false }) {
|
||||
const style = options.bold ? chalk.bold.red : chalk.red;
|
||||
|
||||
return this.log(style(message), options);
|
||||
}
|
||||
};
|
@@ -1,90 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { log } from './console-logger';
|
||||
|
||||
const errors = [];
|
||||
|
||||
export const consoleReporter = {
|
||||
jasmineStarted(suiteInfo) {
|
||||
log.blank().info(
|
||||
`Running ${suiteInfo.totalSpecsDefined} tests`,
|
||||
{ bold: true, title: true }
|
||||
).blank();
|
||||
},
|
||||
|
||||
suiteStarted(suite) {
|
||||
log.info(suite.description).indent();
|
||||
},
|
||||
|
||||
specDone: (spec) => {
|
||||
const {
|
||||
status,
|
||||
description,
|
||||
failedExpectations
|
||||
} = spec;
|
||||
|
||||
if (status === 'passed') {
|
||||
log.success(`∙ ${description}`);
|
||||
}
|
||||
|
||||
if (status === 'failed') {
|
||||
log.error(`✕ ${description}`, { bold: true });
|
||||
|
||||
errors.push(spec);
|
||||
|
||||
failedExpectations.forEach((failed) => {
|
||||
log.error(` ${failed.message}`);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
suiteDone: (result) => {
|
||||
log.dedent();
|
||||
},
|
||||
|
||||
jasmineDone: (result) => {
|
||||
if (!!errors.length) {
|
||||
log .blank()
|
||||
.blank()
|
||||
.info(`${errors.length} failing tests`, { bold: true, title: true });
|
||||
|
||||
errors.forEach(error => {
|
||||
log .blank()
|
||||
.error(`✕ ${error.fullName}`, { bold: true });
|
||||
|
||||
error.failedExpectations.forEach(failed => {
|
||||
log .info(`${failed.message}`)
|
||||
.blank()
|
||||
.error(`${failed.stack}`);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
log.success(`All tests passed!`, { bold: true });
|
||||
}
|
||||
|
||||
log.blank().blank();
|
||||
}
|
||||
};
|
@@ -1,63 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
interface RequestConfig {
|
||||
timeout?: number;
|
||||
noDelay?: boolean;
|
||||
keepAlive?: boolean;
|
||||
keepAliveDelay?: number;
|
||||
}
|
||||
|
||||
interface ResponseConfig {
|
||||
timeout?: number;
|
||||
}
|
||||
|
||||
interface ResponseRequest {
|
||||
method: string;
|
||||
path: string;
|
||||
data: string;
|
||||
}
|
||||
|
||||
export interface NodeRestClient {
|
||||
get(uri: string, callback: Function): Function;
|
||||
post(uri: string, callback: Function): Function;
|
||||
put(uri: string, callback: Function): Function;
|
||||
delete(uri: string, callback: Function): Function;
|
||||
}
|
||||
|
||||
export interface RestClientArgs {
|
||||
data?: any;
|
||||
parameters?: any;
|
||||
headers?: any;
|
||||
requestConfig?: RequestConfig;
|
||||
responseConfig?: ResponseConfig;
|
||||
}
|
||||
|
||||
export interface RestClientResponse {
|
||||
request: ResponseRequest;
|
||||
data: any;
|
||||
statusMessage: string;
|
||||
statusCode: number;
|
||||
}
|
@@ -1,89 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Client } from 'node-rest-client';
|
||||
import { NodeRestClient, RestClientArgs, RestClientResponse } from './rest-client-models';
|
||||
|
||||
export * from './rest-client-models';
|
||||
|
||||
export class RestClient {
|
||||
private static DEFAULT_HEADERS = {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
};
|
||||
|
||||
private client: NodeRestClient;
|
||||
|
||||
constructor(user: string, password: string) {
|
||||
this.client = <NodeRestClient>(new Client({ user, password }));
|
||||
}
|
||||
|
||||
get(uri: string, args: RestClientArgs = {}): Promise<RestClientResponse> {
|
||||
return this.promisify('get', uri, args);
|
||||
}
|
||||
|
||||
post(uri: string, args: RestClientArgs = {}): Promise<RestClientResponse> {
|
||||
return this.promisify('post', uri, args);
|
||||
}
|
||||
|
||||
put(uri: string, args: RestClientArgs = {}): Promise<RestClientResponse> {
|
||||
return this.promisify('put', uri, args);
|
||||
}
|
||||
|
||||
delete(uri: string, args: RestClientArgs = {}): Promise<RestClientResponse> {
|
||||
return this.promisify('delete', uri, args);
|
||||
}
|
||||
|
||||
private createArgs(args: RestClientArgs = {}): RestClientArgs {
|
||||
const data = JSON.stringify(args.data);
|
||||
|
||||
return Object.assign({}, RestClient.DEFAULT_HEADERS, args, { data });
|
||||
}
|
||||
|
||||
private promisify(fnName: string, uri: string, args: RestClientArgs): Promise<RestClientResponse> {
|
||||
const fn: Function = this.client[fnName];
|
||||
const fnArgs = [ encodeURI(uri), this.createArgs(args) ];
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const fnCallback = (data, rawResponse) => {
|
||||
const {
|
||||
statusCode, statusMessage,
|
||||
req: { method, path }
|
||||
} = rawResponse;
|
||||
|
||||
const response: RestClientResponse = {
|
||||
data, statusCode, statusMessage,
|
||||
request: { method, path, data: args.data }
|
||||
};
|
||||
|
||||
(response.statusCode >= 400)
|
||||
? reject(response)
|
||||
: resolve(response);
|
||||
};
|
||||
|
||||
fn(...fnArgs, fnCallback);
|
||||
});
|
||||
}
|
||||
}
|
@@ -1,44 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { browser, promise } from 'protractor';
|
||||
|
||||
export class Utils {
|
||||
// generate a random value
|
||||
static random(): string {
|
||||
return Math.random().toString(36).substring(3, 10);
|
||||
}
|
||||
|
||||
// local storage
|
||||
static clearLocalStorage(): promise.Promise<any> {
|
||||
return browser.executeScript('window.localStorage.clear();');
|
||||
}
|
||||
|
||||
// session storage
|
||||
static clearSessionStorage(): promise.Promise<any> {
|
||||
return browser.executeScript('window.sessionStorage.clear();');
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user