| .. | .. |
|---|
| 32 | 32 | @Path("/test") |
|---|
| 33 | 33 | public class LicenseServices { |
|---|
| 34 | 34 | |
|---|
| 35 | | - // private LicenseHelper licenseHelper = InjectorFactory.getInjector().getInstance(LicenseHelper.class); |
|---|
| 36 | | - private static final Logger LOG = LogManager.getLogger(LicenseServices.class); |
|---|
| 35 | + private static final Logger LOG = LogManager.getLogger(LicenseServices.class); |
|---|
| 37 | 36 | |
|---|
| 38 | | - private static final int DEFAULT_LICENSE_EXPIRATION = 365; |
|---|
| 39 | | - private static final String LICENSE_STRING = "CurisIntegrity Config Server v{0}.{1}"; |
|---|
| 37 | + private static final int DEFAULT_LICENSE_EXPIRATION = 365; |
|---|
| 38 | + private static final String LICENSE_STRING = "CurisIntegrity Config Server v{0}.{1}"; |
|---|
| 40 | 39 | |
|---|
| 41 | | - @com.google.inject.Inject |
|---|
| 42 | | - @Named("base-uri") |
|---|
| 43 | | - private URI uri; |
|---|
| 40 | + @com.google.inject.Inject |
|---|
| 41 | + @Named("base-uri") |
|---|
| 42 | + private URI uri; |
|---|
| 44 | 43 | |
|---|
| 45 | | - public LicenseServices() { |
|---|
| 44 | + public LicenseServices() { |
|---|
| 46 | 45 | |
|---|
| 47 | | - } |
|---|
| 46 | + } |
|---|
| 48 | 47 | |
|---|
| 49 | | - /** |
|---|
| 50 | | - * |
|---|
| 51 | | - * @return the server version in format majorVersion.minorVersion |
|---|
| 52 | | - */ |
|---|
| 53 | | - @GET |
|---|
| 54 | | - @Produces( |
|---|
| 55 | | - { MediaType.TEXT_HTML }) |
|---|
| 56 | | - public Response index() { |
|---|
| 57 | | - try { |
|---|
| 58 | | - String index = IOUtils.toString(this.getClass().getResourceAsStream("/static/index.html")); |
|---|
| 59 | | - return Response.ok().entity(index).build(); |
|---|
| 60 | | - } catch (IOException e) { |
|---|
| 61 | | - LOG.error("Error getting index.html", e); |
|---|
| 62 | | - } |
|---|
| 63 | | - return Response.ok().entity(MessageFormat.format(LICENSE_STRING, 0, 1)).build(); |
|---|
| 64 | | - } |
|---|
| 48 | + /** |
|---|
| 49 | + * |
|---|
| 50 | + * @return the server version in format majorVersion.minorVersion |
|---|
| 51 | + */ |
|---|
| 52 | + @GET |
|---|
| 53 | + @Produces({ MediaType.TEXT_HTML }) |
|---|
| 54 | + public Response index() { |
|---|
| 55 | + try { |
|---|
| 56 | + String index = IOUtils.toString(this.getClass().getResourceAsStream("/static/index.html")); |
|---|
| 57 | + return Response.ok().entity(index).build(); |
|---|
| 58 | + } catch (IOException e) { |
|---|
| 59 | + LOG.error("Error getting index.html", e); |
|---|
| 60 | + } |
|---|
| 61 | + return Response.ok().entity(MessageFormat.format(LICENSE_STRING, 0, 1)).build(); |
|---|
| 62 | + } |
|---|
| 65 | 63 | |
|---|
| 66 | | - @GET |
|---|
| 67 | | - @Path("/dummy") |
|---|
| 68 | | - @Produces( |
|---|
| 69 | | - { MediaType.TEXT_PLAIN }) |
|---|
| 70 | | - public Response dummy(@Context HttpServletRequest request) { |
|---|
| 71 | | - LOG.info("Request: " + request.getPathInfo()); |
|---|
| 72 | | - return Response.ok().entity((uri == null)).build(); |
|---|
| 73 | | - } |
|---|
| 64 | + @GET |
|---|
| 65 | + @Path("/dummy") |
|---|
| 66 | + @Produces({ MediaType.TEXT_PLAIN }) |
|---|
| 67 | + public Response dummy(@Context HttpServletRequest request) { |
|---|
| 68 | + LOG.info("Request: " + request.getPathInfo()); |
|---|
| 69 | + return Response.ok().entity((uri == null)).build(); |
|---|
| 70 | + } |
|---|
| 74 | 71 | |
|---|
| 75 | | - /** |
|---|
| 76 | | - * @return the version of the three entities that can be synchronized (Users, DataSet and Settings) |
|---|
| 77 | | - */ |
|---|
| 78 | | - @POST |
|---|
| 79 | | - @Path("/upload1") |
|---|
| 80 | | - @Consumes(MediaType.MULTIPART_FORM_DATA) |
|---|
| 81 | | - @Produces( |
|---|
| 82 | | - { MediaType.APPLICATION_JSON }) |
|---|
| 83 | | - public Response testFile1(@MultipartForm FileUploadForm mfdi) { |
|---|
| 84 | | - LOG.info("FORM: texto: {}, file: {}", mfdi.getTexto(), new String(mfdi.getFile())); |
|---|
| 85 | | - return Response.ok("OK").build(); |
|---|
| 86 | | - } |
|---|
| 72 | + /** |
|---|
| 73 | + * @return the version of the three entities that can be synchronized |
|---|
| 74 | + * (Users, DataSet and Settings) |
|---|
| 75 | + */ |
|---|
| 76 | + @POST |
|---|
| 77 | + @Path("/upload1") |
|---|
| 78 | + @Consumes(MediaType.MULTIPART_FORM_DATA) |
|---|
| 79 | + @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 80 | + public Response testFile1(@MultipartForm FileUploadForm mfdi) { |
|---|
| 81 | + LOG.info("FORM: texto: {}, file: {}", mfdi.getTexto(), new String(mfdi.getFile())); |
|---|
| 82 | + return Response.ok("OK").build(); |
|---|
| 83 | + } |
|---|
| 87 | 84 | |
|---|
| 88 | | - @GET |
|---|
| 89 | | - @Path("/current/{license}") |
|---|
| 90 | | - @Produces( |
|---|
| 91 | | - { MediaType.APPLICATION_JSON }) |
|---|
| 92 | | - public ServiceResponse<ServerConfigVersions> testFile(@PathParam("license") String license, @DefaultValue("-1") @QueryParam("minorVersion") int minorVersion, @DefaultValue("-1") @QueryParam("majorVersion") int majorVersion) { |
|---|
| 85 | + @GET |
|---|
| 86 | + @Path("/current/{license}") |
|---|
| 87 | + @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 88 | + public ServiceResponse<ServerConfigVersions> testFile(@PathParam("license") String license, |
|---|
| 89 | + @DefaultValue("-1") @QueryParam("minorVersion") int minorVersion, @DefaultValue("-1") @QueryParam("majorVersion") int majorVersion) { |
|---|
| 93 | 90 | |
|---|
| 94 | | - LOG.info("Called 'current' service with license: {}", license); |
|---|
| 95 | | - ServiceResponse<ServerConfigVersions> response = new ServiceResponse<ServerConfigVersions>(); |
|---|
| 91 | + LOG.info("Called 'current' service with license: {}", license); |
|---|
| 92 | + ServiceResponse<ServerConfigVersions> response = new ServiceResponse<ServerConfigVersions>(); |
|---|
| 96 | 93 | |
|---|
| 97 | | - return response; |
|---|
| 98 | | - } |
|---|
| 94 | + return response; |
|---|
| 95 | + } |
|---|
| 99 | 96 | |
|---|
| 100 | | - public static class FileUploadForm { |
|---|
| 97 | + public static class FileUploadForm { |
|---|
| 101 | 98 | |
|---|
| 102 | | - @FormParam("file1") |
|---|
| 103 | | - @PartType("application/octet-stream") |
|---|
| 104 | | - private byte[] file; |
|---|
| 99 | + @FormParam("file1") |
|---|
| 100 | + @PartType("application/octet-stream") |
|---|
| 101 | + private byte[] file; |
|---|
| 105 | 102 | |
|---|
| 106 | | - @FormParam("texto1") |
|---|
| 107 | | - @PartType("text/plain") |
|---|
| 108 | | - private String texto; |
|---|
| 103 | + @FormParam("texto1") |
|---|
| 104 | + @PartType("text/plain") |
|---|
| 105 | + private String texto; |
|---|
| 109 | 106 | |
|---|
| 110 | | - public FileUploadForm() { |
|---|
| 111 | | - } |
|---|
| 107 | + public FileUploadForm() {} |
|---|
| 112 | 108 | |
|---|
| 113 | | - public byte[] getFile() { |
|---|
| 114 | | - return file; |
|---|
| 115 | | - } |
|---|
| 109 | + public byte[] getFile() { |
|---|
| 110 | + return file; |
|---|
| 111 | + } |
|---|
| 116 | 112 | |
|---|
| 117 | | - public void setFile(byte[] file) { |
|---|
| 118 | | - this.file = file; |
|---|
| 119 | | - } |
|---|
| 113 | + public void setFile(byte[] file) { |
|---|
| 114 | + this.file = file; |
|---|
| 115 | + } |
|---|
| 120 | 116 | |
|---|
| 121 | | - public void setTexto(final String texto) { |
|---|
| 122 | | - this.texto = texto; |
|---|
| 123 | | - } |
|---|
| 117 | + public void setTexto(final String texto) { |
|---|
| 118 | + this.texto = texto; |
|---|
| 119 | + } |
|---|
| 124 | 120 | |
|---|
| 125 | | - public String getTexto() { |
|---|
| 126 | | - return texto; |
|---|
| 127 | | - } |
|---|
| 121 | + public String getTexto() { |
|---|
| 122 | + return texto; |
|---|
| 123 | + } |
|---|
| 128 | 124 | |
|---|
| 129 | | - } |
|---|
| 125 | + } |
|---|
| 130 | 126 | } |
|---|