mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4590] - Mark StartTaskCloudService as deprecated (#4936)
* [ADF-4590] - Make StartTaskCloud deprecated * [ADF-4590] - lint * fix build errors * remove unnecesarry file
This commit is contained in:
committed by
Eugenio Romano
parent
8d2229cf99
commit
601f975485
@@ -23,5 +23,6 @@ export * from './task-form/public-api';
|
|||||||
export * from './directives/public-api';
|
export * from './directives/public-api';
|
||||||
|
|
||||||
export * from './services/task-cloud.service';
|
export * from './services/task-cloud.service';
|
||||||
|
export * from './services/start-task-cloud.service';
|
||||||
|
|
||||||
export * from './task-cloud.module';
|
export * from './task-cloud.module';
|
||||||
|
@@ -0,0 +1,75 @@
|
|||||||
|
/*!
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Alfresco Software, Ltd.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { AlfrescoApiService, AppConfigService, LogService } from '@alfresco/adf-core';
|
||||||
|
import { Observable, from, throwError } from 'rxjs';
|
||||||
|
import { map, catchError } from 'rxjs/operators';
|
||||||
|
import { StartTaskCloudRequestModel } from '../start-task/models/start-task-cloud-request.model';
|
||||||
|
import { TaskDetailsCloudModel, StartTaskCloudResponseModel } from '../start-task/models/task-details-cloud.model';
|
||||||
|
import { BaseCloudService } from '../../services/base-cloud.service';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class StartTaskCloudService extends BaseCloudService {
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private apiService: AlfrescoApiService,
|
||||||
|
private appConfigService: AppConfigService,
|
||||||
|
private logService: LogService
|
||||||
|
) { super(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated in 3.5.0, use TaskCloudService instead.
|
||||||
|
* Creates a new standalone task.
|
||||||
|
* @param taskDetails Details of the task to create
|
||||||
|
* @returns Details of the newly created task
|
||||||
|
*/
|
||||||
|
createNewTask(taskDetails: TaskDetailsCloudModel): Observable<TaskDetailsCloudModel> {
|
||||||
|
const queryUrl = this.buildCreateTaskUrl(taskDetails.appName);
|
||||||
|
const bodyParam = JSON.stringify(this.buildRequestBody(taskDetails));
|
||||||
|
const pathParams = {}, queryParams = {}, headerParams = {},
|
||||||
|
formParams = {}, contentTypes = ['application/json'], accepts = ['application/json'];
|
||||||
|
|
||||||
|
return from(
|
||||||
|
this.apiService
|
||||||
|
.getInstance()
|
||||||
|
.oauth2Auth.callCustomApi(
|
||||||
|
queryUrl, 'POST', pathParams, queryParams,
|
||||||
|
headerParams, formParams, bodyParam,
|
||||||
|
contentTypes, accepts, null, null)
|
||||||
|
).pipe(
|
||||||
|
map((response: StartTaskCloudResponseModel) => {
|
||||||
|
return new TaskDetailsCloudModel(response.entry);
|
||||||
|
}),
|
||||||
|
catchError((err) => this.handleError(err))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private buildCreateTaskUrl(appName: string): any {
|
||||||
|
this.contextRoot = this.appConfigService.get('bpmHost');
|
||||||
|
return `${this.getBasePath(appName)}/rb/v1/tasks`;
|
||||||
|
}
|
||||||
|
|
||||||
|
private buildRequestBody(taskDetails: any) {
|
||||||
|
return new StartTaskCloudRequestModel(taskDetails);
|
||||||
|
}
|
||||||
|
|
||||||
|
private handleError(error: any) {
|
||||||
|
this.logService.error(error);
|
||||||
|
return throwError(error || 'Server error');
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user