- remove some awaits

- add try catch
- small refactoring
This commit is contained in:
Adina Parpalita
2019-10-17 17:31:29 +03:00
parent 9fd47d3186
commit 227e05e3f9
39 changed files with 1243 additions and 905 deletions

View File

@@ -28,33 +28,58 @@ import { RepoApi } from '../repo-api';
import { PeopleApi as AdfPeopleApi} from '@alfresco/js-api';
export class PeopleApi extends RepoApi {
peopleApi = new AdfPeopleApi(this.alfrescoJsApi);
peopleApi = new AdfPeopleApi(this.alfrescoJsApi);
constructor(username?, password?) {
super(username, password);
}
constructor(username?, password?) {
super(username, password);
}
async createUser(user: PersonModel) {
const person = new Person(user);
await this.apiAuth();
return await this.peopleApi.createPerson(person);
async createUser(user: PersonModel) {
try {
const person = new Person(user);
await this.apiAuth();
return await this.peopleApi.createPerson(person);
} catch (error) {
console.log('--- people api createUser catch error: ', error);
return null;
}
}
async getUser(username: string) {
await this.apiAuth();
return await this.peopleApi.getPerson(username);
async getUser(username: string) {
try {
await this.apiAuth();
return await this.peopleApi.getPerson(username);
} catch (error) {
console.log('--- people api getUser catch error: ', error);
return null;
}
}
async updateUser(username: string, userDetails?: PersonModel) {
await this.apiAuth();
return this.peopleApi.updatePerson(username, userDetails);
async updateUser(username: string, userDetails?: PersonModel) {
try {
await this.apiAuth();
return this.peopleApi.updatePerson(username, userDetails);
} catch (error) {
console.log('--- people api updateUser catch error: ', error);
return null;
}
}
async disableUser(username: string) {
return await this.updateUser(username, { enabled: false });
async disableUser(username: string) {
try {
return await this.updateUser(username, { enabled: false });
} catch (error) {
console.log('--- people api disableUser catch error: ', error);
return null;
}
}
async changePassword(username: string, newPassword: string) {
return await this.updateUser(username, { password: newPassword });
async changePassword(username: string, newPassword: string) {
try {
return await this.updateUser(username, { password: newPassword });
} catch (error) {
console.log('--- people api changePassword catch error: ', error);
return null;
}
}
}