[DEV] updat to the new model (READY)

This commit is contained in:
Edouard DUPIN 2024-01-18 23:34:43 +01:00
parent 3ea26e3f78
commit 7ce71f91d5
10 changed files with 128 additions and 128 deletions

View File

@ -24,7 +24,7 @@ public class WebLauncherLocal extends WebLauncher {
if (true) {
// for local test:
ConfigBaseVariable.apiAdress = "http://0.0.0.0:15080/karso/api/";
ConfigBaseVariable.dbPort = "3307";
ConfigBaseVariable.dbPort = "3906";
// create a unique key for test ==> not retrieve the token every load...
ConfigVariable.uuid_for_key_generation = "lkjlkjlkjlmkjqmwlsdkjqfsdlkf88QJSDMLQKSndmLQKZNERMAL";
//ConfigBaseVariable.dbType = "sqlite";

View File

@ -25,8 +25,8 @@ import jakarta.annotation.security.RolesAllowed;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.PATCH;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
@ -135,7 +135,7 @@ public class ApplicationResource {
return DataAccess.get(Application.class, id);
}
@PUT
@PATCH
@Path("{id}")
@RolesAllowed("ADMIN")
@Consumes(MediaType.APPLICATION_JSON)
@ -192,7 +192,7 @@ public class ApplicationResource {
}
public record AddUserData(
long userId) {};
long userId) {}
// TODO : review the function to correct admin only access...
@POST

View File

@ -18,8 +18,8 @@ import jakarta.annotation.security.RolesAllowed;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.PATCH;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
@ -137,7 +137,7 @@ public class RightResource {
return DataAccess.get(Right.class, id);
}
@PUT
@PATCH
@Path("{id}")
@RolesAllowed("ADMIN")
@Consumes(MediaType.APPLICATION_JSON)

View File

@ -17,7 +17,7 @@ import jakarta.annotation.security.PermitAll;
import jakarta.annotation.security.RolesAllowed;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.PATCH;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
@ -67,18 +67,18 @@ public class SystemConfigResource {
if (set == null) {
throw new NotFoundException("Value does not exist");
}
if (set.type.equals("BOOLEAN")) {
if ("BOOLEAN".equals(set.type)) {
final boolean availlable = "true".equalsIgnoreCase(set.value);
return Response.status(200).entity("{ \"value\":" + availlable + "}").build();
}
if (set.type.equals("NUMBER")) {
if ("NUMBER".equals(set.type)) {
final double value = Double.parseDouble(set.value);
return Response.status(200).entity("{ \"value\":" + value + "}").build();
}
return Response.status(200).entity("{ \"value\":\"" + set.value + "\"}").build();
}
@PUT
@PATCH
@Path("key/{key}")
@RolesAllowed(value = { "ADMIN" })
@Consumes(MediaType.APPLICATION_JSON)

View File

@ -36,8 +36,8 @@ import jakarta.annotation.security.RolesAllowed;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.NotFoundException;
import jakarta.ws.rs.PATCH;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
@ -100,7 +100,7 @@ public class UserResource {
return RightResource.getUserRight(userId, applicationId);
}
@PUT
@PATCH
@Path("{userId}/application/{applicationId}/rights")
@RolesAllowed("ADMIN")
public Map<String, Object> patchApplicationRight(@Context final SecurityContext sc, @PathParam("userId") final long userId, @PathParam("applicationId") final long applicationId,

View File

@ -77,8 +77,8 @@ public class TestUnAuthorizedAPI {
api.get(String.class, urlOffset);
} else if ("POST".equals(type)) {
api.post(String.class, urlOffset, data);
} else if ("PUT".equals(type)) {
api.put(String.class, urlOffset, data);
} else if ("PATCH".equals(type)) {
api.patch(String.class, urlOffset, data);
} else if ("DELETE".equals(type)) {
api.delete(String.class, urlOffset);
}
@ -106,8 +106,8 @@ public class TestUnAuthorizedAPI {
api.get(String.class, urlOffset);
} else if ("POST".equals(type)) {
api.post(String.class, urlOffset, data);
} else if ("PUT".equals(type)) {
api.put(String.class, urlOffset, data);
} else if ("PATCH".equals(type)) {
api.patch(String.class, urlOffset, data);
} else if ("DELETE".equals(type)) {
api.delete(String.class, urlOffset);
}
@ -127,11 +127,11 @@ public class TestUnAuthorizedAPI {
// /application/
checkFail("GET", "application/", 401);
checkFail("POST", "application/", 401, "{}");
checkFail("PUT", "application/", 405, "{}"); // does not exist
checkFail("PATCH", "application/", 405, "{}"); // does not exist
checkFail("DELETE", "application/", 405); // does not exist
// /application/{id}
checkFail("GET", "application/0", 401);
checkFail("PUT", "application/0", 401, "{}");
checkFail("PATCH", "application/0", 401, "{}");
checkFail("POST", "application/0", 405, "{}");
checkFail("DELETE", "application/0", 401);
// /application/{id}/*
@ -159,13 +159,13 @@ public class TestUnAuthorizedAPI {
checkFail("GET", "right", 401);
checkFail("POST", "right", 401, "{}");
checkFail("GET", "right/0", 401);
checkFail("PUT", "right/0", 401, "{}");
checkFail("PATCH", "right/0", 401, "{}");
checkFail("DELETE", "right/0", 401);
// /system_config
checkWork("GET", "system_config/is_sign_up_availlable");
checkFail("GET", "system_config/key/skjdfhkjsdhfkjsh", 401);
checkFail("PUT", "system_config/key/skjdfhkjsdhfkjsh", 401, "{}");
checkFail("PATCH", "system_config/key/skjdfhkjsdhfkjsh", 401, "{}");
// /users
checkFail("GET", "users", 401);

View File

@ -382,7 +382,7 @@ export class AdminUserService {
.requestJson({
server: 'karso',
endPoint: `users/${userId}/application/${applicationId}/rights`,
requestType: HTTPRequestModel.PUT,
requestType: HTTPRequestModel.PATCH,
accept: HTTPMimeType.JSON,
contentType: HTTPMimeType.JSON,
body: dataUpdate

View File

@ -286,7 +286,7 @@ export class ApplicationService {
.requestJson({
server: 'karso',
endPoint: `application/${id}`,
requestType: HTTPRequestModel.PUT,
requestType: HTTPRequestModel.PATCH,
accept: HTTPMimeType.JSON,
contentType: HTTPMimeType.JSON,
body: updateState,

View File

@ -13,7 +13,7 @@ class MultipleRequest {
failResponse = undefined;
data = {};
constructor(private resolve: any, private reject: any, private countRequest: number) {}
constructor(private resolve: any, private reject: any, private countRequest: number) { }
add(key: string, value: any): void {
this.requestDone += 1;
this.data[key] = value;
@ -44,7 +44,7 @@ class MultipleRequest {
@Injectable()
export class SettingsService {
constructor(private http: HttpWrapperService) {}
constructor(private http: HttpWrapperService) { }
/**
* Get a generic setting (Key value)
* @returns a promise of the data value
@ -76,7 +76,7 @@ export class SettingsService {
this.http
.requestJson({
endPoint: `system_config/key/${key}`,
requestType: HTTPRequestModel.PUT,
requestType: HTTPRequestModel.PATCH,
accept: HTTPMimeType.JSON,
contentType: HTTPMimeType.JSON,
body: {

@ -1 +1 @@
Subproject commit 9fc25b4feaeba509ff39f70b24d97be47f4b30e1
Subproject commit 0496753211a09aacb11436567d513b3586bbaabb