constructor(private injector: Injector, private cookieService: Cookie2Service, private httpHelperService: HttpHelperService) {}
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
- let authReq = req.clone({ headers: req.headers.set(this.cookieService.getUserIdSuffix(), this.cookieService.getUserId())
- .set('Content-Type', 'application/json; charset=UTF-8')
- .set(this.cookieService.getUserIdSuffix(), this.cookieService.getUserId())
- .set(this.cookieService.getUserIdSuffix(), this.cookieService.getUserId())
- });
+ let authReq: HttpRequest<any>;
+ if (req.body instanceof FormData) {
+ authReq = req.clone({ headers: req.headers.set(this.cookieService.getUserIdSuffix(), this.cookieService.getUserId())
+ .set(this.cookieService.getUserIdSuffix(), this.cookieService.getUserId())
+ .set(this.cookieService.getUserIdSuffix(), this.cookieService.getUserId())
+ });
+ } else {
+ authReq = req.clone({ headers: req.headers.set(this.cookieService.getUserIdSuffix(), this.cookieService.getUserId())
+ .set('Content-Type', 'application/json; charset=UTF-8')
+ .set(this.cookieService.getUserIdSuffix(), this.cookieService.getUserId())
+ .set(this.cookieService.getUserIdSuffix(), this.cookieService.getUserId())
+ });
+ }
const uuidValue = this.httpHelperService.getUuidValue(authReq.url);
if (uuidValue !== '') {
this.isLoading = true;
switch (artifactType) {
case (ArtifactType.TOSCA.TOSCA_CSAR):
- this.Notification.error({
- message: "Feature not implemented yet",
- title: "Error"
+ this.componentService.putServiceToscaModel(this.componentId, this.componentType, file).subscribe((response)=> {
+ this.Notification.success({
+ message: "Service " + response.name + " has been updated",
+ title: "Success"
+ });
+ this.isLoading = false;
+ }, () => {
+ this.isLoading = false;
});
- this.isLoading = false;
break;
case (ArtifactType.TOSCA.TOSCA_TEMPLATE):
this.componentService.putServiceToscaTemplate(this.componentId, this.componentType, file).subscribe((response)=> {
return this.http.put<any>(this.baseUrl + this.getServerTypeUrl(componentType) + componentId + '/toscaTemplate', file)
}
+ putServiceToscaModel(componentId: string, componentType: string, file) {
+ let uploadData:FormData = new FormData();
+ uploadData.append('upload', file);
+ return this.http.put<any>(this.baseUrl + this.getServerTypeUrl(componentType) + componentId + '/toscaModel', uploadData);
+ }
+
getFullComponent(componentType: string, uniqueId: string): Observable<Component> {
return this.http.get<Component>(this.baseUrl + this.getServerTypeUrl(componentType) + uniqueId);
}