[DEBUG] Some corrections for upload

This commit is contained in:
Edouard DUPIN 2022-04-08 21:31:37 +02:00
parent edcac1a386
commit 15c3b5f71e
5 changed files with 50 additions and 39 deletions

View File

@ -257,7 +257,7 @@ public class NodeInterface {
ex.printStackTrace(); ex.printStackTrace();
throw new SQLException("Creating node failed, no ID obtained (2)."); throw new SQLException("Creating node failed, no ID obtained (2).");
} }
ps.execute(); //ps.execute();
} catch (SQLException ex) { } catch (SQLException ex) {
ex.printStackTrace(); ex.printStackTrace();
} }

View File

@ -14,6 +14,9 @@ import javax.annotation.security.PermitAll;
import javax.ws.rs.*; import javax.ws.rs.*;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
import javax.ws.rs.core.Response.Status;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.sql.*; import java.sql.*;
@ -288,11 +291,16 @@ public class VideoResource {
System.out.println(" - season: " + season); System.out.println(" - season: " + season);
System.out.println(" - episode: " + episode); System.out.println(" - episode: " + episode);
System.out.println(" - title: " + title); System.out.println(" - title: " + title);
System.out.println(" - typeId: " + typeId); System.out.println(" - type: " + typeId);
System.out.println(" - fileInputStream: " + fileInputStream); System.out.println(" - fileInputStream: " + fileInputStream);
System.out.println(" - fileMetaData: " + fileMetaData); System.out.println(" - fileMetaData: " + fileMetaData);
System.out.flush(); System.out.flush();
if (typeId == null) {
return Response.status(406).
entity("Missong Input 'type'").
type("text/plain").
build();
}
long tmpUID = DataResource.getTmpDataId(); long tmpUID = DataResource.getTmpDataId();
String sha512 = DataResource.saveTemporaryFile(fileInputStream, tmpUID); String sha512 = DataResource.saveTemporaryFile(fileInputStream, tmpUID);
@ -413,10 +421,13 @@ public class VideoResource {
MediaSmall creation = get(uniqueSQLID); MediaSmall creation = get(uniqueSQLID);
return Response.ok(creation).build(); return Response.ok(creation).build();
} catch (Exception ex) { } catch (Exception ex) {
System.out.println("Cat ann unexpected error ... "); System.out.println("Catch an unexpected error ... " + ex.getMessage());
ex.printStackTrace(); ex.printStackTrace();
return Response.status(417).
entity("Back-end error : " + ex.getMessage()).
type("text/plain").
build();
} }
return Response.serverError().build();
} }
@POST @POST
@Path("{id}/add_cover") @Path("{id}/add_cover")

View File

@ -33,11 +33,11 @@
</table> </table>
</div> </div>
<div *ngIf="this.parsedElement.length != 0" class="title"> <div *ngIf="this.parsedElement.length !== 0" class="title">
Meta-data: Meta-data:
</div> </div>
<div class="clear"><br/></div> <div class="clear"><br/></div>
<div *ngIf="this.parsedElement.length != 0" class="fill-all"> <div *ngIf="this.parsedElement.length !== 0" class="fill-all">
<div class="request_raw_table"> <div class="request_raw_table">
<table> <table>
<colgroup> <colgroup>
@ -49,9 +49,9 @@
<tr> <tr>
<td class="left-colomn">Type:</td> <td class="left-colomn">Type:</td>
<td class="right-colomn"> <td class="right-colomn">
<select [ngModel]="type_id" <select [ngModel]="typeId"
(ngModelChange)="onChangeType($event)" (ngModelChange)="onChangeType($event)"
[class.error]="type_id == null"> [class.error]="typeId === undefined">
<option *ngFor="let element of listType" [ngValue]="element.value">{{element.label}}</option> <option *ngFor="let element of listType" [ngValue]="element.value">{{element.label}}</option>
</select> </select>
</td> </td>
@ -61,7 +61,7 @@
<td class="right-colomn"> <td class="right-colomn">
<input type="text" <input type="text"
placeholder="Universe of the Media" placeholder="Universe of the Media"
[value]="global_universe" [value]="globalUniverse"
(input)="onUniverse($event.target.value)" (input)="onUniverse($event.target.value)"
/> />
</td> </td>
@ -71,7 +71,7 @@
<td class="right-colomn"> <td class="right-colomn">
<input type="text" <input type="text"
placeholder="Series of the Media" placeholder="Series of the Media"
[value]="global_series" [value]="globalSeries"
(input)="onSeries($event.target.value)" (input)="onSeries($event.target.value)"
/> />
</td> </td>
@ -79,7 +79,7 @@
<tr> <tr>
<td class="left-colomn"></td> <td class="left-colomn"></td>
<td class="right-colomn"> <td class="right-colomn">
<select [ngModel]="series_id" <select [ngModel]="seriesId"
(ngModelChange)="onChangeSeries($event)"> (ngModelChange)="onChangeSeries($event)">
<option *ngFor="let element of listSeries" [ngValue]="element.value">{{element.label}}</option> <option *ngFor="let element of listSeries" [ngValue]="element.value">{{element.label}}</option>
</select> </select>
@ -98,7 +98,7 @@
<input type="number" <input type="number"
pattern="[0-9]{0-4}" pattern="[0-9]{0-4}"
placeholder="season of the Media" placeholder="season of the Media"
[value]="global_season" [value]="globalSeason"
(input)="onSeason($event.target.value)" (input)="onSeason($event.target.value)"
/> />
</td> </td>
@ -128,7 +128,7 @@
placeholder="e?" placeholder="e?"
[value]="data.episode" [value]="data.episode"
(input)="onEpisode(data, $event.target.value)" (input)="onEpisode(data, $event.target.value)"
[class.error]="data.episodeDetected == true" [class.error]="data.episodeDetected === true"
/> />
</td> </td>
<td class="right-colomn" > <td class="right-colomn" >
@ -136,9 +136,9 @@
placeholder="Name of the Media" placeholder="Name of the Media"
[value]="data.title" [value]="data.title"
(input)="onTitle(data, $event.target.value)" (input)="onTitle(data, $event.target.value)"
[class.error]="data.title == ''" [class.error]="data.title === ''"
/> />
<span *ngIf="data.nameDetected == true" class="error"> <span *ngIf="data.nameDetected === true" class="error">
^^^This title already exist !!! ^^^This title already exist !!!
</span> </span>
</td> </td>
@ -164,7 +164,7 @@
</button> </button>
</div> </div>
<div class="clear"></div> <div class="clear"></div>
<div class="request_raw_table" *ngIf="this.listFileInBdd != null"> <div class="request_raw_table" *ngIf="this.listFileInBdd !== undefined">
<table> <table>
<colgroup> <colgroup>
<col style="width:10%"> <col style="width:10%">
@ -179,14 +179,14 @@
</thead> </thead>
<tbody> <tbody>
<tr *ngFor="let data of this.listFileInBdd"> <tr *ngFor="let data of this.listFileInBdd">
<td class="left-colomn" [class.error]="data.episodeDetected == true">{{data.episode}}</td> <td class="left-colomn" [class.error]="data.episodeDetected === true">{{data.episode}}</td>
<td class="right-colomn" [class.error]="data.nameDetected == true">{{data.name}}</td> <td class="right-colomn" [class.error]="data.nameDetected === true">{{data.name}}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
</div> </div>
<div *ngIf="this.parsedElement.length != 0" class="fill-all"> <div *ngIf="this.parsedElement.length !== 0" class="fill-all">
<div class="request_raw_table"> <div class="request_raw_table">
<table> <table>
<colgroup> <colgroup>

View File

@ -58,7 +58,7 @@ export class UploadScene implements OnInit {
selectedFiles: FileList; selectedFiles: FileList;
typeId: number = null; typeId: number = null;
seriesId: number = null; seriesId: number = null;
saisonId: number = null;v saisonId: number = null;
needSend: boolean = false; needSend: boolean = false;
// list of all files already registered in the bdd to compare with the curent list of files. // list of all files already registered in the bdd to compare with the curent list of files.
@ -391,10 +391,10 @@ export class UploadScene implements OnInit {
iii--; iii--;
} }
} }
console.log(`check : ${JSON.stringify(this.parsedElement[0])}`)
this.globalUniverse = this.parsedElement[0].universe; this.globalUniverse = this.parsedElement[0].universe ?? '';
this.globalSeries = this.parsedElement[0].series; this.globalSeries = this.parsedElement[0].series ?? '';
this.globalSeason = this.parsedElement[0].season; this.globalSeason = this.parsedElement[0].season ?? null;
this.updateNeedSend(); this.updateNeedSend();
this.seriesId = null; this.seriesId = null;

View File

@ -55,25 +55,25 @@ export class VideoService {
} }
uploadFile(file:File, uploadFile(file:File,
universe:string, universe?:string,
series:string, series?:string,
seriesId:number, seriesId?:number,
season:number, season?:number,
episode:number, episode?:number,
title:string, title?:string,
typeId:number, typeId?:number,
progress:any = null) { progress:any = null) {
const formData = new FormData(); const formData = new FormData();
formData.append('file_name', file.name); formData.append('file_name', file.name);
// set the file at hte begining it will permit to abort the transmission // set the file at hte begining it will permit to abort the transmission
formData.append('file', file); formData.append('file', file?? null);
formData.append('universe', universe); formData.append('universe', universe?? null);
if(seriesId !== null) { if(seriesId !== null) {
formData.append('seriesId', seriesId.toString()); formData.append('series', seriesId.toString());
} else { } else {
formData.append('seriesId', null); formData.append('series', null);
} }
formData.append('series', series); formData.append('series', series?? null);
if(season !== null) { if(season !== null) {
formData.append('season', season.toString()); formData.append('season', season.toString());
} else { } else {
@ -85,7 +85,7 @@ export class VideoService {
} else { } else {
formData.append('episode', null); formData.append('episode', null);
} }
formData.append('title', title); formData.append('title', title?? null);
if(typeId !== null) { if(typeId !== null) {
formData.append('typeId', typeId.toString()); formData.append('typeId', typeId.toString());