From 2fd6ff883fa6ee5ece773c69fce66f3cd03c86a5 Mon Sep 17 00:00:00 2001
From: Roberto Sánchez <roberto.sanchez@curisit.net>
Date: Wed, 22 Jan 2014 11:26:50 +0000
Subject: [PATCH] #396 feature - Refactoring JavaScript resources, relocating third party libraries from own libs

---
 securis/src/main/java/net/curisit/securis/services/LicenseServices.java |   89 ++++++++++++++++++++++++--------------------
 1 files changed, 48 insertions(+), 41 deletions(-)

diff --git a/securis/src/main/java/net/curisit/securis/services/LicenseServices.java b/securis/src/main/java/net/curisit/securis/services/LicenseServices.java
index bbf1a0d..f4d6a08 100644
--- a/securis/src/main/java/net/curisit/securis/services/LicenseServices.java
+++ b/securis/src/main/java/net/curisit/securis/services/LicenseServices.java
@@ -6,8 +6,11 @@
 
 import javax.inject.Named;
 import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
 import javax.ws.rs.DefaultValue;
+import javax.ws.rs.FormParam;
 import javax.ws.rs.GET;
+import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
@@ -20,11 +23,13 @@
 import net.curisit.integrity.beans.ServiceResponse;
 
 import org.apache.commons.io.IOUtils;
+import org.jboss.resteasy.annotations.providers.multipart.MultipartForm;
+import org.jboss.resteasy.annotations.providers.multipart.PartType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 // The Java class will be hosted at the URI path "/myresource"
-@Path("/license")
+@Path("/test")
 public class LicenseServices {
 
 	// private LicenseHelper licenseHelper = InjectorFactory.getInjector().getInstance(LicenseHelper.class);
@@ -38,6 +43,7 @@
 	private URI uri;
 
 	public LicenseServices() {
+
 	}
 
 	/**
@@ -70,55 +76,56 @@
 	/**
 	 * @return the version of the three entities that can be synchronized (Users, DataSet and Settings)
 	 */
+	@POST
+	@Path("/upload1")
+	@Consumes(MediaType.MULTIPART_FORM_DATA)
+	@Produces(
+		{ MediaType.APPLICATION_JSON })
+	public Response testFile1(@MultipartForm FileUploadForm mfdi) {
+		log.info("FORM: texto: {}, file: {}", mfdi.getTexto(), new String(mfdi.getFile()));
+		return Response.ok("OK").build();
+	}
+
 	@GET
 	@Path("/current/{license}")
 	@Produces(
 		{ MediaType.APPLICATION_JSON })
-	public ServiceResponse<ServerConfigVersions> status(@PathParam("license") String license, @DefaultValue("-1") @QueryParam("minorVersion") int minorVersion, @DefaultValue("-1") @QueryParam("majorVersion") int majorVersion) {
+	public ServiceResponse<ServerConfigVersions> testFile(@PathParam("license") String license, @DefaultValue("-1") @QueryParam("minorVersion") int minorVersion, @DefaultValue("-1") @QueryParam("majorVersion") int majorVersion) {
 
 		log.info("Called 'current' service with license: {}", license);
 		ServiceResponse<ServerConfigVersions> response = new ServiceResponse<ServerConfigVersions>();
 
 		return response;
 	}
-	//
-	// private <T> ServiceResponse<T> buildErrorResponse(ServiceResponse<T> response, String msgErrorCode) {
-	// response.setSuccess(false);
-	// response.setErrorMessage(localManager.getString(msgErrorCode));
-	// response.setErrorMessageCode(msgErrorCode);
-	// return response;
-	// }
-	//
-	// private Date calculateCaducation() {
-	// Integer licenseExpiration = systemParams.getParamAsInt(SystemParams.Keys.CONFIG_SERVER_LICENSE_EXPIRATION);
-	// if (licenseExpiration == null)
-	// licenseExpiration = DEFAULT_LICENSE_EXPIRATION;
-	// return Utils.addDays(new Date(), licenseExpiration);
-	// }
-	//
-	// private boolean validateLicense(String license) {
-	// BasicApplication ba = basicApplicationDao.findByLicense(license);
-	// return (ba != null);
-	// }
-	//
-	// private boolean validateVersion(int minorVersion, int majorVersion) {
-	// return (versionManager.getMajorVersion() == majorVersion);
-	// }
-	//
-	// private BasicApplication findBasicApp(String license) {
-	// BasicApplication ba = basicApplicationDao.findByLicense(license);
-	// return ba;
-	// }
-	//
-	// private License generateLicense() {
-	// // TODO complete all field of the license
-	// License license = new License();
-	// license.setCustomerCode(systemParams.getParam(SystemParams.Keys.CONFIG_COMMON_CUSTOMER_CODE));
-	// license.setCSCode(systemParams.getParam(SystemParams.Keys.CONFIG_COMMON_CS_CODE));
-	// license.setCRCLogo("00000000");
-	// license.setExpirationDate(calculateCaducation());
-	// license.setInstallCode(codeGenerator.generateInstalationNumber());
-	// return license;
-	// }
 
+	public static class FileUploadForm {
+
+		@FormParam("file1")
+		@PartType("application/octet-stream")
+		private byte[] file;
+
+		@FormParam("texto1")
+		@PartType("text/plain")
+		private String texto;
+
+		public FileUploadForm() {
+		}
+
+		public byte[] getFile() {
+			return file;
+		}
+
+		public void setFile(byte[] file) {
+			this.file = file;
+		}
+
+		public void setTexto(final String texto) {
+			this.texto = texto;
+		}
+
+		public String getTexto() {
+			return texto;
+		}
+
+	}
 }

--
Gitblit v1.3.2