[DEV] update version
This commit is contained in:
parent
4b20edc04d
commit
0383be3ada
@ -20,12 +20,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>kangaroo-and-rabbit</groupId>
|
<groupId>kangaroo-and-rabbit</groupId>
|
||||||
<artifactId>archidata</artifactId>
|
<artifactId>archidata</artifactId>
|
||||||
<version>0.4.0</version>
|
<version>0.5.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-simple</artifactId>
|
<artifactId>slf4j-simple</artifactId>
|
||||||
<version>2.0.7</version>
|
<version>2.0.9</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--
|
<!--
|
||||||
************************************************************
|
************************************************************
|
||||||
@ -35,13 +35,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit-jupiter-api</artifactId>
|
<artifactId>junit-jupiter-api</artifactId>
|
||||||
<version>5.10.0</version>
|
<version>5.10.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit-jupiter-engine</artifactId>
|
<artifactId>junit-jupiter-engine</artifactId>
|
||||||
<version>5.10.0</version>
|
<version>5.10.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package org.kar.karideo.api;
|
package org.kar.karideo.api;
|
||||||
|
|
||||||
import org.kar.archidata.exception.FailException;
|
import org.kar.archidata.exception.FailException;
|
||||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
import org.kar.archidata.util.ConfigBaseVariable;
|
||||||
import org.kar.archidata.tools.JWTWrapper;
|
import org.kar.archidata.util.JWTWrapper;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -17,10 +17,10 @@ import jakarta.ws.rs.core.Response;
|
|||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public class HealthCheck {
|
public class HealthCheck {
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(HealthCheck.class);
|
static final Logger LOGGER = LoggerFactory.getLogger(HealthCheck.class);
|
||||||
|
|
||||||
public record HealthResult(
|
public record HealthResult(
|
||||||
String value) {};
|
String value) {};
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@PermitAll
|
@PermitAll
|
||||||
public HealthResult getHealth() throws FailException {
|
public HealthResult getHealth() throws FailException {
|
||||||
|
@ -9,7 +9,7 @@ import org.kar.archidata.dataAccess.DataAccess;
|
|||||||
import org.kar.archidata.dataAccess.QueryAnd;
|
import org.kar.archidata.dataAccess.QueryAnd;
|
||||||
import org.kar.archidata.dataAccess.QueryCondition;
|
import org.kar.archidata.dataAccess.QueryCondition;
|
||||||
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
||||||
import org.kar.archidata.tools.DataTools;
|
import org.kar.archidata.util.DataTools;
|
||||||
import org.kar.karideo.model.Season;
|
import org.kar.karideo.model.Season;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -30,20 +30,20 @@ import jakarta.ws.rs.core.Response;
|
|||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public class SeasonResource {
|
public class SeasonResource {
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(SeasonResource.class);
|
static final Logger LOGGER = LoggerFactory.getLogger(SeasonResource.class);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public static Season getWithId(@PathParam("id") final Long id) throws Exception {
|
public static Season getWithId(@PathParam("id") final Long id) throws Exception {
|
||||||
return DataAccess.get(Season.class, id);
|
return DataAccess.get(Season.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public List<Season> get() throws Exception {
|
public List<Season> get() throws Exception {
|
||||||
return DataAccess.gets(Season.class);
|
return DataAccess.gets(Season.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
@ -51,18 +51,18 @@ public class SeasonResource {
|
|||||||
public Season get(@PathParam("id") final Long id) throws Exception {
|
public Season get(@PathParam("id") final Long id) throws Exception {
|
||||||
return DataAccess.get(Season.class, id);
|
return DataAccess.get(Season.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* =============================================================================
|
/* =============================================================================
|
||||||
* ADMIN SECTION:
|
* ADMIN SECTION:
|
||||||
* ============================================================================= */
|
* ============================================================================= */
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Season put(final String jsonRequest) throws Exception {
|
public Season put(final String jsonRequest) throws Exception {
|
||||||
return DataAccess.insertWithJson(Season.class, jsonRequest);
|
return DataAccess.insertWithJson(Season.class, jsonRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@ -71,7 +71,7 @@ public class SeasonResource {
|
|||||||
DataAccess.updateWithJson(Season.class, id, jsonRequest);
|
DataAccess.updateWithJson(Season.class, id, jsonRequest);
|
||||||
return DataAccess.get(Season.class, id);
|
return DataAccess.get(Season.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@ -79,7 +79,7 @@ public class SeasonResource {
|
|||||||
DataAccess.delete(Season.class, id);
|
DataAccess.delete(Season.class, id);
|
||||||
return Response.ok().build();
|
return Response.ok().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/add_cover")
|
@Path("{id}/add_cover")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@ -88,7 +88,7 @@ public class SeasonResource {
|
|||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
||||||
return DataTools.uploadCover(Season.class, id, fileName, fileInputStream, fileMetaData);
|
return DataTools.uploadCover(Season.class, id, fileName, fileInputStream, fileMetaData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}/rm_cover/{coverId}")
|
@Path("{id}/rm_cover/{coverId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@ -96,7 +96,7 @@ public class SeasonResource {
|
|||||||
AddOnManyToMany.removeLink(Season.class, id, "cover", coverId);
|
AddOnManyToMany.removeLink(Season.class, id, "cover", coverId);
|
||||||
return Response.ok(DataAccess.get(Season.class, id)).build();
|
return Response.ok(DataAccess.get(Season.class, id)).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Season getOrCreate(final String name, final Long seriesId) {
|
public static Season getOrCreate(final String name, final Long seriesId) {
|
||||||
try {
|
try {
|
||||||
Season out = DataAccess.getWhere(Season.class, new QueryAnd(new QueryCondition("name", "=", name), new QueryCondition("parentId", "=", seriesId)));
|
Season out = DataAccess.getWhere(Season.class, new QueryAnd(new QueryCondition("name", "=", name), new QueryCondition("parentId", "=", seriesId)));
|
||||||
@ -113,5 +113,5 @@ public class SeasonResource {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import org.kar.archidata.dataAccess.DataAccess;
|
|||||||
import org.kar.archidata.dataAccess.QueryAnd;
|
import org.kar.archidata.dataAccess.QueryAnd;
|
||||||
import org.kar.archidata.dataAccess.QueryCondition;
|
import org.kar.archidata.dataAccess.QueryCondition;
|
||||||
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
||||||
import org.kar.archidata.tools.DataTools;
|
import org.kar.archidata.util.DataTools;
|
||||||
import org.kar.karideo.model.Series;
|
import org.kar.karideo.model.Series;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -30,20 +30,20 @@ import jakarta.ws.rs.core.Response;
|
|||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public class SeriesResource {
|
public class SeriesResource {
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(SeriesResource.class);
|
static final Logger LOGGER = LoggerFactory.getLogger(SeriesResource.class);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public static Series getWithId(@PathParam("id") final Long id) throws Exception {
|
public static Series getWithId(@PathParam("id") final Long id) throws Exception {
|
||||||
return DataAccess.get(Series.class, id);
|
return DataAccess.get(Series.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public List<Series> get() throws Exception {
|
public List<Series> get() throws Exception {
|
||||||
return DataAccess.gets(Series.class);
|
return DataAccess.gets(Series.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
@ -51,18 +51,18 @@ public class SeriesResource {
|
|||||||
public Series get(@PathParam("id") final Long id) throws Exception {
|
public Series get(@PathParam("id") final Long id) throws Exception {
|
||||||
return DataAccess.get(Series.class, id);
|
return DataAccess.get(Series.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* =============================================================================
|
/* =============================================================================
|
||||||
* ADMIN SECTION:
|
* ADMIN SECTION:
|
||||||
* ============================================================================= */
|
* ============================================================================= */
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Series put(final String jsonRequest) throws Exception {
|
public Series put(final String jsonRequest) throws Exception {
|
||||||
return DataAccess.insertWithJson(Series.class, jsonRequest);
|
return DataAccess.insertWithJson(Series.class, jsonRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@ -71,7 +71,7 @@ public class SeriesResource {
|
|||||||
DataAccess.updateWithJson(Series.class, id, jsonRequest);
|
DataAccess.updateWithJson(Series.class, id, jsonRequest);
|
||||||
return DataAccess.get(Series.class, id);
|
return DataAccess.get(Series.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@ -79,7 +79,7 @@ public class SeriesResource {
|
|||||||
DataAccess.delete(Series.class, id);
|
DataAccess.delete(Series.class, id);
|
||||||
return Response.ok().build();
|
return Response.ok().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/add_cover")
|
@Path("{id}/add_cover")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@ -88,7 +88,7 @@ public class SeriesResource {
|
|||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
||||||
return DataTools.uploadCover(Series.class, id, fileName, fileInputStream, fileMetaData);
|
return DataTools.uploadCover(Series.class, id, fileName, fileInputStream, fileMetaData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}/rm_cover/{coverId}")
|
@Path("{id}/rm_cover/{coverId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@ -96,7 +96,7 @@ public class SeriesResource {
|
|||||||
AddOnManyToMany.removeLink(Series.class, id, "cover", coverId);
|
AddOnManyToMany.removeLink(Series.class, id, "cover", coverId);
|
||||||
return Response.ok(DataAccess.get(Series.class, id)).build();
|
return Response.ok(DataAccess.get(Series.class, id)).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Series getOrCreate(final String name, final Long typeId) {
|
public static Series getOrCreate(final String name, final Long typeId) {
|
||||||
try {
|
try {
|
||||||
Series out = DataAccess.getWhere(Series.class, new QueryAnd(new QueryCondition("name", "=", name), new QueryCondition("parentId", "=", typeId)));
|
Series out = DataAccess.getWhere(Series.class, new QueryAnd(new QueryCondition("name", "=", name), new QueryCondition("parentId", "=", typeId)));
|
||||||
@ -113,5 +113,5 @@ public class SeriesResource {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import org.glassfish.jersey.media.multipart.FormDataParam;
|
|||||||
import org.kar.archidata.dataAccess.DataAccess;
|
import org.kar.archidata.dataAccess.DataAccess;
|
||||||
import org.kar.archidata.dataAccess.QueryCondition;
|
import org.kar.archidata.dataAccess.QueryCondition;
|
||||||
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
||||||
import org.kar.archidata.tools.DataTools;
|
import org.kar.archidata.util.DataTools;
|
||||||
import org.kar.karideo.model.Type;
|
import org.kar.karideo.model.Type;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -29,20 +29,20 @@ import jakarta.ws.rs.core.Response;
|
|||||||
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
||||||
public class TypeResource {
|
public class TypeResource {
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(TypeResource.class);
|
static final Logger LOGGER = LoggerFactory.getLogger(TypeResource.class);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public static Type getWithId(@PathParam("id") final Long id) throws Exception {
|
public static Type getWithId(@PathParam("id") final Long id) throws Exception {
|
||||||
return DataAccess.get(Type.class, id);
|
return DataAccess.get(Type.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public List<Type> get() throws Exception {
|
public List<Type> get() throws Exception {
|
||||||
return DataAccess.gets(Type.class);
|
return DataAccess.gets(Type.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
@ -50,22 +50,22 @@ public class TypeResource {
|
|||||||
public Type get(@PathParam("id") final Long id) throws Exception {
|
public Type get(@PathParam("id") final Long id) throws Exception {
|
||||||
return DataAccess.get(Type.class, id);
|
return DataAccess.get(Type.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Type getId(final Long id) throws Exception {
|
public static Type getId(final Long id) throws Exception {
|
||||||
return DataAccess.get(Type.class, id);
|
return DataAccess.get(Type.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* =============================================================================
|
/* =============================================================================
|
||||||
* ADMIN SECTION:
|
* ADMIN SECTION:
|
||||||
* ============================================================================= */
|
* ============================================================================= */
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Type put(final String jsonRequest) throws Exception {
|
public Type put(final String jsonRequest) throws Exception {
|
||||||
return DataAccess.insertWithJson(Type.class, jsonRequest);
|
return DataAccess.insertWithJson(Type.class, jsonRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@ -74,7 +74,7 @@ public class TypeResource {
|
|||||||
DataAccess.updateWithJson(Type.class, id, jsonRequest);
|
DataAccess.updateWithJson(Type.class, id, jsonRequest);
|
||||||
return DataAccess.get(Type.class, id);
|
return DataAccess.get(Type.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@ -82,7 +82,7 @@ public class TypeResource {
|
|||||||
DataAccess.delete(Type.class, id);
|
DataAccess.delete(Type.class, id);
|
||||||
return Response.ok().build();
|
return Response.ok().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/add_cover")
|
@Path("{id}/add_cover")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@ -91,7 +91,7 @@ public class TypeResource {
|
|||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
||||||
return DataTools.uploadCover(Type.class, id, fileName, fileInputStream, fileMetaData);
|
return DataTools.uploadCover(Type.class, id, fileName, fileInputStream, fileMetaData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}/rm_cover/{coverId}")
|
@Path("{id}/rm_cover/{coverId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@ -99,7 +99,7 @@ public class TypeResource {
|
|||||||
AddOnManyToMany.removeLink(Type.class, id, "cover", coverId);
|
AddOnManyToMany.removeLink(Type.class, id, "cover", coverId);
|
||||||
return Response.ok(DataAccess.get(Type.class, id)).build();
|
return Response.ok(DataAccess.get(Type.class, id)).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Type getOrCreate(final String name) {
|
public static Type getOrCreate(final String name) {
|
||||||
try {
|
try {
|
||||||
Type out = DataAccess.getWhere(Type.class, new QueryCondition("name", "=", name));
|
Type out = DataAccess.getWhere(Type.class, new QueryCondition("name", "=", name));
|
||||||
@ -115,5 +115,5 @@ public class TypeResource {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
|||||||
import org.kar.archidata.exception.FailException;
|
import org.kar.archidata.exception.FailException;
|
||||||
import org.kar.archidata.exception.InputException;
|
import org.kar.archidata.exception.InputException;
|
||||||
import org.kar.archidata.model.Data;
|
import org.kar.archidata.model.Data;
|
||||||
import org.kar.archidata.tools.DataTools;
|
import org.kar.archidata.util.DataTools;
|
||||||
import org.kar.karideo.model.Media;
|
import org.kar.karideo.model.Media;
|
||||||
import org.kar.karideo.model.Season;
|
import org.kar.karideo.model.Season;
|
||||||
import org.kar.karideo.model.Series;
|
import org.kar.karideo.model.Series;
|
||||||
@ -37,20 +37,20 @@ import jakarta.ws.rs.core.Response;
|
|||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public class VideoResource {
|
public class VideoResource {
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(VideoResource.class);
|
static final Logger LOGGER = LoggerFactory.getLogger(VideoResource.class);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public List<Media> get() throws Exception {
|
public List<Media> get() throws Exception {
|
||||||
return DataAccess.gets(Media.class);
|
return DataAccess.gets(Media.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public Media get(@PathParam("id") final Long id) throws Exception {
|
public Media get(@PathParam("id") final Long id) throws Exception {
|
||||||
return DataAccess.get(Media.class, id);
|
return DataAccess.get(Media.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@ -60,7 +60,7 @@ public class VideoResource {
|
|||||||
DataAccess.updateWithJson(Media.class, id, jsonRequest);
|
DataAccess.updateWithJson(Media.class, id, jsonRequest);
|
||||||
return DataAccess.get(Media.class, id);
|
return DataAccess.get(Media.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String multipartCorrection(final String data) {
|
private String multipartCorrection(final String data) {
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -73,7 +73,7 @@ public class VideoResource {
|
|||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("/upload/")
|
@Path("/upload/")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@ -91,7 +91,7 @@ public class VideoResource {
|
|||||||
episode = multipartCorrection(episode);
|
episode = multipartCorrection(episode);
|
||||||
title = multipartCorrection(title);
|
title = multipartCorrection(title);
|
||||||
typeId = multipartCorrection(typeId);
|
typeId = multipartCorrection(typeId);
|
||||||
|
|
||||||
//public NodeSmall uploadFile(final FormDataMultiPart form) {
|
//public NodeSmall uploadFile(final FormDataMultiPart form) {
|
||||||
System.out.println("Upload media file: " + fileMetaData);
|
System.out.println("Upload media file: " + fileMetaData);
|
||||||
System.out.println(" - fileName: " + fileName);
|
System.out.println(" - fileName: " + fileName);
|
||||||
@ -107,7 +107,7 @@ public class VideoResource {
|
|||||||
if (typeId == null) {
|
if (typeId == null) {
|
||||||
throw new InputException("typeId", "TypiId is not specified");
|
throw new InputException("typeId", "TypiId is not specified");
|
||||||
}
|
}
|
||||||
|
|
||||||
final long tmpUID = DataResource.getTmpDataId();
|
final long tmpUID = DataResource.getTmpDataId();
|
||||||
final String sha512 = DataResource.saveTemporaryFile(fileInputStream, tmpUID);
|
final String sha512 = DataResource.saveTemporaryFile(fileInputStream, tmpUID);
|
||||||
Data data = DataResource.getWithSha512(sha512);
|
Data data = DataResource.getWithSha512(sha512);
|
||||||
@ -145,7 +145,7 @@ public class VideoResource {
|
|||||||
if (series != null) {
|
if (series != null) {
|
||||||
seriesNode = SeriesResource.getOrCreate(series, typeNode.id);
|
seriesNode = SeriesResource.getOrCreate(series, typeNode.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(" ==> " + seriesNode);
|
System.out.println(" ==> " + seriesNode);
|
||||||
System.out.println("Find seasonNode");
|
System.out.println("Find seasonNode");
|
||||||
// get uid of season:
|
// get uid of season:
|
||||||
@ -157,10 +157,10 @@ public class VideoResource {
|
|||||||
if (season != null) {
|
if (season != null) {
|
||||||
seasonNode = SeasonResource.getOrCreate(season, seriesNode.id);
|
seasonNode = SeasonResource.getOrCreate(season, seriesNode.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(" ==> " + seasonNode);
|
System.out.println(" ==> " + seasonNode);
|
||||||
System.out.println("add media");
|
System.out.println("add media");
|
||||||
|
|
||||||
final long uniqueSQLID = -1;
|
final long uniqueSQLID = -1;
|
||||||
try {
|
try {
|
||||||
final Media media = new Media();
|
final Media media = new Media();
|
||||||
@ -195,7 +195,7 @@ public class VideoResource {
|
|||||||
throw new FailException("Catch Exception ==> check server logs");
|
throw new FailException("Catch Exception ==> check server logs");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/add_cover")
|
@Path("{id}/add_cover")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@ -204,7 +204,7 @@ public class VideoResource {
|
|||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
||||||
return DataTools.uploadCover(Media.class, id, fileName, fileInputStream, fileMetaData);
|
return DataTools.uploadCover(Media.class, id, fileName, fileInputStream, fileMetaData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}/rm_cover/{coverId}")
|
@Path("{id}/rm_cover/{coverId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@ -212,7 +212,7 @@ public class VideoResource {
|
|||||||
AddOnManyToMany.removeLink(Media.class, id, "cover", coverId);
|
AddOnManyToMany.removeLink(Media.class, id, "cover", coverId);
|
||||||
return Response.ok(DataAccess.get(Media.class, id)).build();
|
return Response.ok(DataAccess.get(Media.class, id)).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
|
@ -5,7 +5,6 @@ import java.util.Map;
|
|||||||
import org.kar.archidata.tools.JWTWrapper;
|
import org.kar.archidata.tools.JWTWrapper;
|
||||||
|
|
||||||
public class Common {
|
public class Common {
|
||||||
static String userToken = JWTWrapper.createJwtTestToken(16512, "test_user_login", "KarAuth", "karideo", Map.of("USER", Boolean.TRUE));
|
static String USER_TOKEN = JWTWrapper.createJwtTestToken(16512, "test_user_login", "KarAuth", "karideo", Map.of("karideo", Map.of("USER", Boolean.TRUE)));
|
||||||
static String adminToken = JWTWrapper.createJwtTestToken(16512, "test_admin_login", "KarAuth", "karideo", Map.of("USER", Boolean.TRUE, "ADMIN", Boolean.TRUE));
|
static String ADMIN_TOKEN = JWTWrapper.createJwtTestToken(16512, "test_admin_login", "KarAuth", "karideo", Map.of("karideo", Map.of("USER", Boolean.TRUE, "ADMIN", Boolean.TRUE)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user