Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package multimedia;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.PrintWriter;
- import java.io.RandomAccessFile;
- import java.io.UnsupportedEncodingException;
- import java.net.URLEncoder;
- import java.nio.channels.FileChannel;
- import java.nio.channels.FileLock;
- import java.nio.channels.OverlappingFileLockException;
- import java.util.List;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- import javax.servlet.ServletException;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import javax.xml.ws.WebServiceRef;
- import org.apache.commons.fileupload.FileItem;
- import org.apache.commons.fileupload.FileItemFactory;
- import org.apache.commons.fileupload.disk.DiskFileItemFactory;
- import org.apache.commons.fileupload.servlet.ServletFileUpload;
- import org.netbeans.j2ee.wsdl.bpelinvocador.wsdlbpelinvocador.WsdlbpelInvocador;
- //import org.netbeans.j2ee.wsdl.ejbadhierete.wsdladhierete.WsdladhiereteService;
- //import org.netbeans.j2ee.wsdl.ejbelabora.wsdlelabora.WsdlelaboraService;
- /**
- *
- * @author tomas
- */
- public class Multimedia extends HttpServlet {
- @WebServiceRef(wsdlLocation = "WEB-INF/wsdl/localhost_9080/wsdlbpelInvocadorService/wsdlbpelInvocador.wsdl")
- private WsdlbpelInvocador service;
- protected void processRequest(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- response.setContentType("text/html;charset=UTF-8");
- PrintWriter out = response.getWriter();
- try {
- String tit = "";
- String des = "";
- String cat = "";
- String tipo = "";
- String usuario = "";
- String opcion = "";
- String vidyouurl = "";
- String contexto="elabora";
- byte[] buffer = new byte[500 * 1024];
- byte[] archiveData = null;
- boolean uploaded = false;
- if (ServletFileUpload.isMultipartContent(request)) {//Es un formulario multipart
- // Create a factory for disk-based file items
- try {
- request.setCharacterEncoding("ISO-8859-1");
- //Es un formulario multipart
- // Create a factory for disk-based file items
- FileItemFactory factory = new DiskFileItemFactory();
- // Create a new file upload handler
- ServletFileUpload upload = new ServletFileUpload(factory);
- // Parse the request
- List<FileItem> items = upload.parseRequest(request);
- for (FileItem item : items) {
- if (item.isFormField()) {
- // Tratamos los parametros que vienen en el request
- String namePar = item.getFieldName();
- String valorPar = item.getString();
- if (namePar.equals("titulo")) {
- tit = valorPar;
- System.out.println("Valor Titulo"+tit);
- } else if (namePar.equals("descripcion")) {
- des = valorPar;
- System.out.println("Valor Descripcion"+des);
- } else if (namePar.equals("categoria")) {
- cat = valorPar;
- System.out.println("Valor categoria"+cat);
- } else if (namePar.equals("tipo")) {
- tipo = valorPar;
- System.out.println("Valor Tipo"+tipo);
- } else if (namePar.equals("usr")) {
- usuario = valorPar;
- System.out.println("Valor usr"+usuario);
- } else if (namePar.equals("radio-choice")) {
- opcion = valorPar;
- } else if (namePar.equals("vidyouurl")) {
- vidyouurl = valorPar;
- } else if (namePar.equals("contexto")) {
- contexto = valorPar;
- System.out.println("Valor contexto"+contexto);
- }
- } else {
- if (item.get().length > 0) {
- buffer = item.get();
- int readBytes = (int) item.getSize();
- if (readBytes <= 0) {
- out.write("<h2>Archivo no válido</h2>");
- } else {
- uploaded = true;
- }
- if (uploaded) {
- archiveData = new byte[readBytes];
- for (int i = 0; i < readBytes; i++) {
- archiveData[i] = buffer[i];
- }
- if (readBytes > 10) {
- //BufferedImage origImage = ImageIO.read(new ByteArrayInputStream(photoData));
- if (contexto.contentEquals("adhierete")) {
- System.out.println("Estoy dentro de Adhierete");
- if (tipo.contentEquals("imagen")) {
- /*try { // Call Web Service Operation
- org.netbeans.j2ee.wsdl.ejbadhierete.wsdladhierete.WsdladhieretePortType port = service_1.getWsdladhieretePort();
- // TODO initialize WS operation arguments here
- java.lang.String titulo = tit;
- java.lang.String descripcion = des;
- java.lang.String categoria = cat;
- // TODO process result here
- java.lang.String result = port.subirFoto(titulo, descripcion, categoria, usuario);
- FileOutputStream foto = new FileOutputStream(result);
- foto.write(archiveData);
- ImageUtils.Reescaler(result);
- foto.close();
- if(!result.contentEquals("No existe la categoria")&&!result.contentEquals("Error al subir foto"))
- result = "La imagen se ha subido correctamente al servidor. Pulse sobre el botón \"Volver\" para refrescar el contenido.";
- out.write("<h2>" + result + "</h2>");
- } catch (Exception ex) {
- out.write("<h2>Se ha producido un error al intentar subir la imagen al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.</h2>");
- }*/
- try { // Call Web Service Operation
- // TODO initialize WS operation arguments here
- java.lang.String dirWSDL = "http://localhost:8080/wsdladhiereteService/AdhiereteService";
- java.lang.String operacion = "subirFoto";
- java.lang.String titulo = tit;
- java.lang.String descripcion = des;
- java.lang.String categoria = cat;
- java.lang.String parVal = "#titulo="+titulo+"#descripcion="+descripcion+"#categoria="+categoria+"#usuario="+usuario;
- // TODO process result here
- java.lang.String result = invocacion(dirWSDL, operacion, parVal);
- FileOutputStream foto = new FileOutputStream(result);
- foto.write(archiveData);
- ImageUtils.Reescaler(result);
- foto.close();
- if(!result.contentEquals("No existe la categoria")&&!result.contentEquals("Error al subir foto"))
- result = "La imagen se ha subido correctamente al servidor. Pulse sobre el botón \"Volver\" para refrescar el contenido.";
- out.write("<h2>" + result + "</h2>");
- out.println("Result = "+result);
- } catch (Exception ex) {
- // TODO handle custom exceptions here
- out.write("<h2>Se ha producido un error al intentar subir la imagen al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.</h2>");
- ex.printStackTrace();
- }
- } else if (tipo.contentEquals("audio")) {
- /*try { // Call Web Service Operation
- org.netbeans.j2ee.wsdl.ejbadhierete.wsdladhierete.WsdladhieretePortType port = service_1.getWsdladhieretePort();
- // TODO initialize WS operation arguments here
- java.lang.String titulo = tit;
- java.lang.String descripcion = des;
- java.lang.String categoria = cat;
- // TODO process result here
- java.lang.String result = port.subirAudio(titulo, descripcion, categoria, usuario);
- FileOutputStream audio = new FileOutputStream(result);
- audio.write(archiveData);
- audio.close();
- if(!result.contentEquals("No existe la categoria")&&!result.contentEquals("Error al subir audio"))
- result = "El archivo de audio se ha subido correctamente al servidor. Pulse sobre el botón \"Volver\" para refrescar el contenido.";
- out.write("<h2>" + result + "</h2>");
- } catch (Exception ex) {
- out.write("<h2>Se ha producido un error al intentar subir el archivo de audio al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.</h2>");
- }*/
- try { // Call Web Service Operation
- // TODO initialize WS operation arguments here
- java.lang.String dirWSDL = "http://localhost:8080/wsdladhiereteService/AdhiereteService";
- java.lang.String operacion = "subirAudio";
- java.lang.String titulo = tit;
- java.lang.String descripcion = des;
- java.lang.String categoria = cat;
- java.lang.String parVal = "#titulo="+titulo+"#descripcion="+descripcion+"#categoria="+categoria+"#usuario="+usuario;
- // TODO process result here
- java.lang.String result = invocacion(dirWSDL, operacion, parVal);
- FileOutputStream audio = new FileOutputStream(result);
- audio.write(archiveData);
- audio.close();
- if(!result.contentEquals("No existe la categoria")&&!result.contentEquals("Error al subir audio"))
- result = "El archivo de audio se ha subido correctamente al servidor. Pulse sobre el botón \"Volver\" para refrescar el contenido.";
- out.write("<h2>" + result + "</h2>");
- out.println("Result = "+result);
- } catch (Exception ex) {
- // TODO handle custom exceptions here
- out.write("<h2>Se ha producido un error al intentar subir el archivo de audio al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.</h2>");
- ex.printStackTrace();
- }
- } else if (tipo.contentEquals("foto_usuario")) {
- /*try { // Call Web Service Operation
- org.netbeans.j2ee.wsdl.ejbadhierete.wsdladhierete.WsdladhieretePortType port = service_1.getWsdladhieretePort();
- // TODO initialize WS operation arguments here
- java.lang.String titulo = tit;
- java.lang.String descripcion = "foto_usuario";
- java.lang.String categoria = "foto_usuario";
- // TODO process result here
- java.lang.String result = port.subirFoto(titulo, descripcion, categoria, usuario);
- System.out.println("INVADERS "+ tit + " " + result);
- port.consultaBBDD("3", tit+"#foto#"+result.substring(0, result.indexOf("/home")));
- FileOutputStream foto = new FileOutputStream(result.substring(result.indexOf("/home")));
- foto.write(archiveData);
- ImageUtils.Reescaler(result.substring(result.indexOf("/home")));
- foto.close();
- System.out.println("INVADERS despues");
- if(!result.contentEquals("No existe la categoria")&&!result.contentEquals("Error al subir foto"))
- result = "La imagen se ha subido correctamente al servidor. Pulse sobre el botón \"Volver\" para refrescar el contenido.";
- out.write("<h2>" + result + "</h2>");
- } catch (Exception ex) {
- out.write("<h2>Se ha producido un error al intentar subir la imagen al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.</h2>");
- }*/
- try { // Call Web Service Operation
- // TODO initialize WS operation arguments here
- java.lang.String dirWSDL = "http://localhost:8080/wsdladhiereteService/AdhiereteService";
- java.lang.String operacion = "subirFoto";
- java.lang.String titulo = tit;
- java.lang.String descripcion = "foto_usuario";
- java.lang.String categoria = "foto_usuario";
- java.lang.String parVal = "#titulo="+titulo+"#descripcion="+descripcion+"#categoria="+categoria+"#usuario="+usuario;
- // TODO process result here
- java.lang.String result = invocacion(dirWSDL, operacion, parVal);
- System.out.println("INVADERS "+ tit + " " + result);
- invocacion(dirWSDL, "consultaBBDD", "#tipo=3#parametros="+tit+"(;;almohadilla;;)foto(;;almohadilla;;)"+result.substring(0, result.indexOf("/home")));
- //port.consultaBBDD("3", tit+"#foto#"+result.substring(0, result.indexOf("/home")));
- FileOutputStream foto = new FileOutputStream(result.substring(result.indexOf("/home")));
- foto.write(archiveData);
- ImageUtils.Reescaler(result.substring(result.indexOf("/home")));
- foto.close();
- System.out.println("INVADERS despues");
- if(!result.contentEquals("No existe la categoria")&&!result.contentEquals("Error al subir foto"))
- result = "La imagen se ha subido correctamente al servidor. Pulse sobre el botón \"Volver\" para refrescar el contenido.";
- out.write("<h2>" + result + "</h2>");
- out.println("Result = "+result);
- } catch (Exception ex) {
- // TODO handle custom exceptions here
- out.write("<h2>Se ha producido un error al intentar subir la imagen al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.</h2>");
- ex.printStackTrace();
- }
- }
- }else{
- if (tipo.contentEquals("imagen")) {
- /*try { // Call Web Service Operation
- org.netbeans.j2ee.wsdl.ejbelabora.wsdlelabora.WsdlelaboraPortType port = service.getWsdlelaboraPort();
- // TODO initialize WS operation arguments here
- java.lang.String titulo = tit;
- java.lang.String descripcion = des;
- java.lang.String categoria = cat;
- // TODO process result here
- java.lang.String result = port.subirFoto(titulo, descripcion, categoria, usuario);
- FileOutputStream foto = new FileOutputStream(result);
- foto.write(archiveData);
- ImageUtils.Reescaler(result);
- foto.close();
- if(!result.contentEquals("No existe la categoria")&&!result.contentEquals("Error al subir foto"))
- result = "La imagen se ha subido correctamente al servidor. Pulse sobre el botón \"Volver\" para refrescar el contenido.";
- out.write("<h2>" + result + "</h2>");
- } catch (Exception ex) {
- out.write("<h2>Se ha producido un error al intentar subir la imagen al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.</h2>");
- }*/
- try { // Call Web Service Operation
- // TODO initialize WS operation arguments here
- java.lang.String dirWSDL = "http://localhost:8080/wsdlelaboraService/ElaboraService";
- java.lang.String operacion = "subirFoto";
- java.lang.String titulo = tit;
- java.lang.String descripcion = des;
- java.lang.String categoria = cat;
- java.lang.String parVal = "#titulo="+titulo+"#descripcion="+descripcion+"#categoria="+categoria+"#usuario="+usuario;
- // TODO process result here
- java.lang.String result = invocacion(dirWSDL, operacion, parVal);
- FileOutputStream foto = new FileOutputStream(result);
- foto.write(archiveData);
- ImageUtils.Reescaler(result);
- foto.close();
- if(!result.contentEquals("No existe la categoria")&&!result.contentEquals("Error al subir foto"))
- result = "La imagen se ha subido correctamente al servidor. Pulse sobre el botón \"Volver\" para refrescar el contenido.";
- out.write("<h2>" + result + "</h2>");
- out.println("Result = "+result);
- } catch (Exception ex) {
- // TODO handle custom exceptions here
- out.write("<h2>Se ha producido un error al intentar subir la imagen al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.</h2>");
- ex.printStackTrace();
- }
- } else if (tipo.contentEquals("imagenMultimedia")){
- try { // Call Web Service Operation
- // TODO initialize WS operation arguments here
- java.lang.String dirWSDL = "http://localhost:8080/wsdlelaboraService/ElaboraService";
- java.lang.String operacion = "subirFoto";
- java.lang.String titulo = tit;
- java.lang.String descripcion = des;
- java.lang.String categoria = cat;
- java.lang.String parVal = "#titulo="+titulo+"#descripcion="+descripcion+"#categoria="+categoria+"#usuario="+usuario;
- // TODO process result here
- java.lang.String result = invocacion(dirWSDL, operacion, parVal);
- FileOutputStream foto = new FileOutputStream(result);
- foto.write(archiveData);
- ImageUtils.Reescaler(result);
- foto.close();
- if(!result.contentEquals("No existe la categoria")&&!result.contentEquals("Error al subir foto")){
- String res1[] = result.split("/");
- String idMul = res1[8];
- result = res1[8] + "#" + "La imagen se ha subido correctamente al servidor. Será redirigido a la página pricipal de multimedia.";
- }
- out.println(result);
- } catch (Exception ex) {
- out.write("Se ha producido un error al intentar subir la imagen al servidor. Será redirigido a la página pricipal de multimedia.");
- ex.printStackTrace();
- }
- } else if (tipo.contentEquals("audio")) {
- /*try { // Call Web Service Operation
- org.netbeans.j2ee.wsdl.ejbelabora.wsdlelabora.WsdlelaboraPortType port = service.getWsdlelaboraPort();
- // TODO initialize WS operation arguments here
- java.lang.String titulo = tit;
- java.lang.String descripcion = des;
- java.lang.String categoria = cat;
- // TODO process result here
- java.lang.String result = port.subirAudio(titulo, descripcion, categoria, usuario);
- FileOutputStream audio = new FileOutputStream(result);
- audio.write(archiveData);
- audio.close();
- if(!result.contentEquals("No existe la categoria")&&!result.contentEquals("Error al subir audio"))
- result = "El archivo de audio se ha subido correctamente al servidor. Pulse sobre el botón \"Volver\" para refrescar el contenido.";
- out.write("<h2>" + result + "</h2>");
- } catch (Exception ex) {
- out.write("<h2>Se ha producido un error al intentar subir el archivo de audio al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.</h2>");
- }*/
- try { // Call Web Service Operation
- // TODO initialize WS operation arguments here
- java.lang.String dirWSDL = "http://localhost:8080/wsdlelaboraService/ElaboraService";
- java.lang.String operacion = "subirAudio";
- java.lang.String titulo = tit;
- java.lang.String descripcion = des;
- java.lang.String categoria = cat;
- java.lang.String parVal = "#titulo="+titulo+"#descripcion="+descripcion+"#categoria="+categoria+"#usuario="+usuario;
- // TODO process result here
- java.lang.String result =invocacion(dirWSDL, operacion, parVal);
- FileOutputStream audio = new FileOutputStream(result);
- audio.write(archiveData);
- audio.close();
- if(!result.contentEquals("No existe la categoria")&&!result.contentEquals("Error al subir audio"))
- result = "El archivo de audio se ha subido correctamente al servidor. Pulse sobre el botón \"Volver\" para refrescar el contenido.";
- out.write("<h2>" + result + "</h2>");
- out.println("Result = "+result);
- } catch (Exception ex) {
- // TODO handle custom exceptions here
- out.write("<h2>Se ha producido un error al intentar subir el archivo de audio al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.</h2>");
- ex.printStackTrace();
- }
- } else if(tipo.contentEquals("audioMultimedia")){
- try { // Call Web Service Operation
- // TODO initialize WS operation arguments here
- java.lang.String dirWSDL = "http://localhost:8080/wsdlelaboraService/ElaboraService";
- java.lang.String operacion = "subirAudio";
- java.lang.String titulo = tit;
- java.lang.String descripcion = des;
- java.lang.String categoria = cat;
- java.lang.String parVal = "#titulo="+titulo+"#descripcion="+descripcion+"#categoria="+categoria+"#usuario="+usuario;
- // TODO process result here
- java.lang.String result = invocacion(dirWSDL, operacion, parVal);
- FileOutputStream audio = new FileOutputStream(result);
- audio.write(archiveData);
- audio.close();
- if(!result.contentEquals("No existe la categoria")&&!result.contentEquals("Error al subir el audio")){
- String res1[] = result.split("/");
- String idMul = res1[8];
- result = res1[8] + "#" + "El audio se ha subido correctamente al servidor. Será redirigido a la página pricipal de multimedia.";
- }
- out.println(result);
- } catch (Exception ex) {
- out.write("Se ha producido un error al intentar subir el audio al servidor. Será redirigido a la página pricipal de multimedia.");
- ex.printStackTrace();
- }
- } else if (tipo.contentEquals("foto_usuario")) {
- /*try { // Call Web Service Operation
- org.netbeans.j2ee.wsdl.ejbelabora.wsdlelabora.WsdlelaboraPortType port = service.getWsdlelaboraPort();
- // TODO initialize WS operation arguments here
- java.lang.String titulo = tit;
- java.lang.String descripcion = "foto_usuario";
- java.lang.String categoria = "foto_usuario";
- // TODO process result here
- java.lang.String result = port.subirFoto(titulo, descripcion, categoria, usuario);
- System.out.println("INVADERS "+ tit + " " + result);
- port.consultaBBDD("3", tit+"#foto#"+result.substring(0, result.indexOf("/home")));
- FileOutputStream foto = new FileOutputStream(result.substring(result.indexOf("/home")));
- foto.write(archiveData);
- ImageUtils.Reescaler(result.substring(result.indexOf("/home")));
- foto.close();
- System.out.println("INVADERS despues");
- if(!result.contentEquals("No existe la categoria")&&!result.contentEquals("Error al subir foto"))
- result = "La imagen se ha subido correctamente al servidor. Pulse sobre el botón \"Volver\" para refrescar el contenido.";
- out.write("<h2>" + result + "</h2>");
- } catch (Exception ex) {
- out.write("<h2>Se ha producido un error al intentar subir la imagen al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.</h2>");
- }*/
- try { // Call Web Service Operation
- // TODO initialize WS operation arguments here
- java.lang.String dirWSDL = "http://localhost:8080/wsdlelaboraService/ElaboraService";
- java.lang.String operacion = "subirFoto";
- java.lang.String titulo = tit;
- java.lang.String descripcion = "foto_usuario";
- java.lang.String categoria = "foto_usuario";
- java.lang.String parVal = "#titulo="+titulo+"#descripcion="+descripcion+"#categoria="+categoria+"#usuario="+usuario;
- // TODO process result here
- java.lang.String result = invocacion(dirWSDL, operacion, parVal);
- System.out.println("INVADERS "+ tit + " " + result);
- invocacion(dirWSDL, "consultaBBDD", "#tipo=3#parametros="+tit+"(;;almohadilla;;)foto(;;almohadilla;;)"+result.substring(0, result.indexOf("/home")));
- //port.consultaBBDD("3", tit+"#foto#"+result.substring(0, result.indexOf("/home")));
- FileOutputStream foto = new FileOutputStream(result.substring(result.indexOf("/home")));
- foto.write(archiveData);
- ImageUtils.Reescaler(result.substring(result.indexOf("/home")));
- foto.close();
- System.out.println("INVADERS despues");
- if(!result.contentEquals("No existe la categoria")&&!result.contentEquals("Error al subir foto"))
- result = "La imagen se ha subido correctamente al servidor. Pulse sobre el botón \"Volver\" para refrescar el contenido.";
- out.write("<h2>" + result + "</h2>");
- out.println("Result = "+result);
- } catch (Exception ex) {
- // TODO handle custom exceptions here
- out.write("<h2>Se ha producido un error al intentar subir la imagen al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.</h2>");
- ex.printStackTrace();
- }
- }else if (tipo.contentEquals("foto_grupo")) {
- /*try { // Call Web Service Operation
- org.netbeans.j2ee.wsdl.ejbelabora.wsdlelabora.WsdlelaboraPortType port = service.getWsdlelaboraPort();
- // TODO initialize WS operation arguments here
- java.lang.String titulo = tit;
- java.lang.String descripcion = "foto_usuario";
- java.lang.String categoria = "foto_usuario";
- // TODO process result here
- java.lang.String result = port.subirFoto(titulo, descripcion, categoria, usuario);
- System.out.println("INVADERS "+ tit + " " + result);
- port.consultaBBDD("3", tit+"#foto#"+result.substring(0, result.indexOf("/home")));
- FileOutputStream foto = new FileOutputStream(result.substring(result.indexOf("/home")));
- foto.write(archiveData);
- ImageUtils.Reescaler(result.substring(result.indexOf("/home")));
- foto.close();
- System.out.println("INVADERS despues");
- if(!result.contentEquals("No existe la categoria")&&!result.contentEquals("Error al subir foto"))
- result = "La imagen se ha subido correctamente al servidor. Pulse sobre el botón \"Volver\" para refrescar el contenido.";
- out.write("<h2>" + result + "</h2>");
- } catch (Exception ex) {
- out.write("<h2>Se ha producido un error al intentar subir la imagen al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.</h2>");
- }*/
- try { // Call Web Service Operation
- // TODO initialize WS operation arguments here
- java.lang.String dirWSDL = "http://localhost:8080/wsdlelaboraService/ElaboraService";
- java.lang.String operacion = "subirFoto";
- java.lang.String titulo = tit;
- tipo = "foto_usuario";
- java.lang.String descripcion = "foto_usuario";
- java.lang.String categoria = "foto_usuario";
- java.lang.String parVal = "#titulo=" + titulo + "#descripcion=" + descripcion + "#categoria=" + categoria + "#usuario=" + usuario;
- // TODO process result here
- java.lang.String result = invocacion(dirWSDL, operacion, parVal);
- System.out.println("result" + result);
- //invocacion(dirWSDL, "consultaBBDD", "#tipo=3#parametros=" + tit + "(;;almohadilla;;)foto(;;almohadilla;;)" + result.substring(0, result.indexOf("/home")));
- //port.consultaBBDD("3", tit+"#foto#"+result.substring(0, result.indexOf("/home")));
- FileOutputStream foto = new FileOutputStream(result.substring(result.indexOf("/home")));
- foto.write(archiveData);
- ImageUtils.Reescaler(result.substring(result.indexOf("/home")));
- foto.close();
- System.out.println("INVADERS despues");
- if (!result.contentEquals("No existe la categoria") && !result.contentEquals("Error al subir foto")) {
- // result = "La imagen se ha subido correctamente al servidor. Pulse sobre el botón \"Volver\" para refrescar el contenido.";
- String directorio=result.substring(result.indexOf("recursos"));
- String idFoto= result.substring(0, result.indexOf("/home"));
- result=idFoto+"#"+directorio;
- }
- out.write( result );
- // out.println("Result = " + result);
- } catch (Exception ex) {
- // TODO handle custom exceptions here
- out.write("<h2>Se ha producido un error al intentar subir la imagen al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.</h2>");
- ex.printStackTrace();
- }
- }else if (tipo.contentEquals("foto_cat")) {
- try { // Call Web Service Operation
- // TODO initialize WS operation arguments here
- java.lang.String dirWSDL = "http://localhost:8080/Comunicador/wsdlComunicadorService";
- java.lang.String operacion = "subirFoto";
- java.lang.String titulo = tit;
- tipo = "foto_cat";
- java.lang.String descripcion = "foto_usuario";
- java.lang.String categoria = "foto_usuario";
- java.lang.String parVal = "#titulo=" + titulo + "#descripcion=" + descripcion + "#categoria=" + "0" + "#usuario=" + usuario;
- // TODO process result here
- java.lang.String result = invocacion(dirWSDL, operacion, parVal);
- System.out.println("result" + result);
- //invocacion(dirWSDL, "consultaBBDD", "#tipo=3#parametros=" + tit + "(;;almohadilla;;)foto(;;almohadilla;;)" + result.substring(0, result.indexOf("/home")));
- //port.consultaBBDD("3", tit+"#foto#"+result.substring(0, result.indexOf("/home")));
- System.out.println("RUTAAAAAAAAAA :" + result.substring(result.indexOf("/home")));
- FileOutputStream foto = new FileOutputStream(result.substring(result.indexOf("/home")));
- foto.write(archiveData);
- ImageUtils.Reescaler(result.substring(result.indexOf("/home")));
- foto.close();
- System.out.println("INVADERS despues");
- if (!result.contentEquals("No existe la categoria") && !result.contentEquals("Error al subir foto")) {
- // result = "La imagen se ha subido correctamente al servidor. Pulse sobre el botón \"Volver\" para refrescar el contenido.";
- String directorio=result.substring(result.indexOf("recursos"));
- String idFoto= result.substring(0, result.indexOf("/home"));
- result=idFoto+"#"+directorio;
- }
- out.write( result );
- // out.println("Result = " + result);
- } catch (Exception ex) {
- // TODO handle custom exceptions here
- out.write("<h2>Se ha producido un error al intentar subir la imagen al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.</h2>");
- ex.printStackTrace();
- }
- }
- else if (tipo.contentEquals("foto_mensaje")) {
- try { // Call Web Service Operation
- // TODO initialize WS operation arguments here
- java.lang.String dirWSDL = "http://localhost:8080/Comunicador/wsdlComunicadorService";
- java.lang.String operacion = "subirFoto";
- java.lang.String titulo = tit;
- tipo = "foto_mensaje";
- java.lang.String descripcion = "foto_usuario";
- java.lang.String categoria = "foto_usuario";
- java.lang.String parVal = "#titulo=" + titulo + "#descripcion=" + descripcion + "#categoria=" + "0" + "#usuario=" + usuario;
- // TODO process result here
- java.lang.String result = invocacion(dirWSDL, operacion, parVal);
- System.out.println("result" + result);
- //invocacion(dirWSDL, "consultaBBDD", "#tipo=3#parametros=" + tit + "(;;almohadilla;;)foto(;;almohadilla;;)" + result.substring(0, result.indexOf("/home")));
- //port.consultaBBDD("3", tit+"#foto#"+result.substring(0, result.indexOf("/home")));
- System.out.println("RUTAAAAAAAAAA :" + result.substring(result.indexOf("/home")));
- FileOutputStream foto = new FileOutputStream(result.substring(result.indexOf("/home")));
- foto.write(archiveData);
- ImageUtils.Reescaler(result.substring(result.indexOf("/home")));
- foto.close();
- System.out.println("INVADERS despues");
- if (!result.contentEquals("No existe la categoria") && !result.contentEquals("Error al subir foto")) {
- // result = "La imagen se ha subido correctamente al servidor. Pulse sobre el botón \"Volver\" para refrescar el contenido.";
- String directorio=result.substring(result.indexOf("recursos"));
- String idFoto= result.substring(0, result.indexOf("/home"));
- result=idFoto+"#"+directorio;
- }
- out.write( result );
- // out.println("Result = " + result);
- } catch (Exception ex) {
- // TODO handle custom exceptions here
- out.write("<h2>Se ha producido un error al intentar subir la imagen al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.</h2>");
- ex.printStackTrace();
- }
- }
- }
- }
- }
- } else {
- out.write("<h2>Error al subir el archivo</h2>");
- }
- }
- }
- if (contexto.contentEquals("adhierete")) {
- System.out.println("Estoy dentro de Adhierete");
- if (tipo.contentEquals("video")){
- System.out.println("Estoy en video");
- if (opcion.contentEquals("vidyou")){
- System.out.println("Estoy en video youtube");
- /*try { // Call Web Service Operation
- org.netbeans.j2ee.wsdl.ejbadhierete.wsdladhierete.WsdladhieretePortType port = service_1.getWsdladhieretePort();
- // TODO initialize WS operation arguments here
- java.lang.String titulo = tit;
- java.lang.String descripcion = des;
- java.lang.String categoria = cat;
- java.lang.String localizacion = vidyouurl;
- // TODO process result here
- java.lang.String result = port.subirLinkYoutube(titulo, descripcion, categoria, localizacion, usuario);
- if(result.contentEquals("Correcto")){
- result = "El video se ha subido correctamente. Pulse sobre el botón \"Volver\" para refrescar el contenido.";
- } else {
- result = "Se ha producido un error al intentar subir el video al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.";
- }
- out.write("<h2>" + result + "</h2>");
- } catch (Exception ex) {
- out.write("<h2>Se ha producido un error al intentar subir el video al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.</h2>");
- }*/
- try { // Call Web Service Operation
- // TODO initialize WS operation arguments here
- java.lang.String titulo = tit;
- java.lang.String descripcion = des;
- java.lang.String categoria = cat;
- java.lang.String localizacionEncoder=URLEncoder.encode(vidyouurl, "UTF-8");
- java.lang.String localizacion = localizacionEncoder;
- java.lang.String dirWSDL = "http://localhost:8080/wsdladhiereteService/AdhiereteService";
- java.lang.String operacion = "subirLinkYoutube";
- java.lang.String parVal = "#titulo="+titulo+"#descripcion="+descripcion+"#categoria="+categoria+"#localizacion="+localizacion+"#usuario="+usuario;
- // TODO process result here
- java.lang.String result = invocacion(dirWSDL, operacion, parVal);
- //out.println("Result = "+result);
- if(result.contentEquals("Correcto")){
- result = "El video se ha subido correctamente. Pulse sobre el botón \"Volver\" para refrescar el contenido.";
- } else {
- result = "Se ha producido un error al intentar subir el video al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.";
- }
- out.write("<h2>" + result + "</h2>");
- } catch (Exception ex) {
- out.write("<h2>Se ha producido un error al intentar subir el video al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.</h2>");
- }
- } else if (opcion.contentEquals("vidprop")){
- /*try { // Call Web Service Operation
- org.netbeans.j2ee.wsdl.ejbadhierete.wsdladhierete.WsdladhieretePortType port = service_1.getWsdladhieretePort();
- // TODO initialize WS operation arguments here
- java.lang.String titulo = tit;
- java.lang.String descripcion = des;
- java.lang.String categoria = cat;
- // TODO process result here
- java.lang.String result = port.subirVideo(titulo, descripcion, categoria, usuario);
- if (result.contentEquals("Error")){
- result = "Se ha producido un error al intentar subir el video al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.";
- out.write("<h2>" + result + "</h2>");
- } else {
- out.write(result);
- }
- } catch (Exception ex) {
- out.write("<h2>Se ha producido un error al intentar subir el video al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.</h2>");
- }*/
- try { // Call Web Service Operation
- // TODO initialize WS operation arguments here
- java.lang.String titulo = tit;
- java.lang.String descripcion = des;
- java.lang.String categoria = cat;
- java.lang.String dirWSDL = "http://localhost:8080/wsdladhiereteService/AdhiereteService";
- java.lang.String operacion = "subirVideo";
- java.lang.String parVal = "#titulo="+titulo+"#descripcion="+descripcion+"#categoria="+categoria+"#usuario="+usuario;
- // TODO process result here
- java.lang.String result = invocacion(dirWSDL, operacion, parVal);
- //out.println("Result = "+result);
- if (result.contentEquals("Error")){
- result = "Se ha producido un error al intentar subir el video al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.";
- out.write("<h2>" + result + "</h2>");
- } else {
- out.write(result);
- }
- out.write("<h2>" + result + "</h2>");
- } catch (Exception ex) {
- out.write("<h2>Se ha producido un error al intentar subir el video al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.</h2>");
- }
- }
- }
- }else{
- if (tipo.contentEquals("video")){
- System.out.println("Estoy en video");
- if (opcion.contentEquals("vidyou")){
- System.out.println("Estoy en video youtube");
- /*try { // Call Web Service Operation
- org.netbeans.j2ee.wsdl.ejbelabora.wsdlelabora.WsdlelaboraPortType port = service.getWsdlelaboraPort();
- // TODO initialize WS operation arguments here
- java.lang.String titulo = tit;
- java.lang.String descripcion = des;
- java.lang.String categoria = cat;
- java.lang.String localizacion = vidyouurl;
- // TODO process result here
- java.lang.String result = port.subirLinkYoutube(titulo, descripcion, categoria, localizacion, usuario);
- if(result.contentEquals("Correcto")){
- result = "El video se ha subido correctamente. Pulse sobre el botón \"Volver\" para refrescar el contenido.";
- } else {
- result = "Se ha producido un error al intentar subir el video al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.";
- }
- out.write("<h2>" + result + "</h2>");
- } catch (Exception ex) {
- out.write("<h2>Se ha producido un error al intentar subir el video al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.</h2>");
- }*/
- try { // Call Web Service Operation
- // TODO initialize WS operation arguments here
- java.lang.String titulo = tit;
- java.lang.String descripcion = des;
- java.lang.String categoria = cat;
- java.lang.String localizacionEncoder=URLEncoder.encode(vidyouurl, "UTF-8");
- java.lang.String localizacion = localizacionEncoder;
- java.lang.String dirWSDL = "http://localhost:8080/wsdlelaboraService/ElaboraService";
- java.lang.String operacion = "subirLinkYoutube";
- java.lang.String parVal = "#titulo="+titulo+"#descripcion="+descripcion+"#categoria="+categoria+"#localizacion="+localizacion+"#usuario="+usuario;
- // TODO process result here
- java.lang.String result = invocacion(dirWSDL, operacion, parVal);
- //out.println("Result = "+result);
- if(result.contentEquals("Correcto")){
- result = "El video se ha subido correctamente. Pulse sobre el botón \"Volver\" para refrescar el contenido.";
- } else {
- result = "Se ha producido un error al intentar subir el video al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.";
- }
- out.write("<h2>" + result + "</h2>");
- } catch (Exception ex) {
- out.write("<h2>Se ha producido un error al intentar subir el video al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.</h2>");
- }
- } else if(opcion.contains("vidyouMultimedia")){
- try { // Call Web Service Operation
- // TODO initialize WS operation arguments here
- java.lang.String titulo = tit;
- java.lang.String descripcion = des;
- java.lang.String categoria = cat;
- java.lang.String localizacionEncoder=URLEncoder.encode(vidyouurl, "UTF-8");
- java.lang.String localizacion = localizacionEncoder;
- java.lang.String dirWSDL = "http://localhost:8080/wsdlelaboraService/ElaboraService";
- java.lang.String operacion = "subirLinkYoutube";
- java.lang.String parVal = "#titulo="+titulo+"#descripcion="+descripcion+"#categoria="+categoria+"#localizacion="+localizacion+"#usuario="+usuario;
- // TODO process result here
- java.lang.String result = invocacion(dirWSDL, operacion, parVal);
- if(!result.contentEquals("Error")){
- result = result + "# El video se ha subido correctamente. Pulse sobre el botón \"Volver\" para refrescar el contenido.";
- } else {
- result = "Se ha producido un error al intentar subir el video al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.";
- }
- out.write(result);
- } catch (Exception ex) {
- out.write("Se ha producido un error al intentar subir el video al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo");
- }
- } else if (opcion.contentEquals("vidprop")){
- /*try { // Call Web Service Operation
- org.netbeans.j2ee.wsdl.ejbelabora.wsdlelabora.WsdlelaboraPortType port = service.getWsdlelaboraPort();
- // TODO initialize WS operation arguments here
- java.lang.String titulo = tit;
- java.lang.String descripcion = des;
- java.lang.String categoria = cat;
- // TODO process result here
- java.lang.String result = port.subirVideo(titulo, descripcion, categoria, usuario);
- if (result.contentEquals("Error")){
- result = "Se ha producido un errelaboraor al intentar subir el video al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.";
- out.write("<h2>" + result + "</h2>");
- } else {
- out.write(result);
- }
- } catch (Exception ex) {
- out.write("<h2>Se ha producido un error al intentar subir el video al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.</h2>");
- }*/
- try { // Call Web Service Operation
- // TODO initialize WS operation arguments here
- java.lang.String titulo = tit;
- java.lang.String descripcion = des;
- java.lang.String categoria = cat;
- java.lang.String dirWSDL = "http://localhost:8080/wsdlelaboraService/ElaboraService";
- java.lang.String operacion = "subirVideo";
- java.lang.String parVal = "#titulo="+titulo+"#descripcion="+descripcion+"#categoria="+categoria+"#usuario="+usuario;
- // TODO process result here
- java.lang.String result =invocacion(dirWSDL, operacion, parVal);
- //out.println("Result = "+result);
- if (result.contentEquals("Error")){
- result = "Se ha producido un error al intentar subir el video al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.";
- out.write("<h2>" + result + "</h2>");
- } else {
- out.write(result);
- }
- out.write("<h2>" + result + "</h2>");
- } catch (Exception ex) {
- out.write("<h2>Se ha producido un error al intentar subir el video al servidor. Por favor, pulse sobre el botón \"Volver\" e inténtelo de nuevo.</h2>");
- }
- }
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- out.write("<h2>Error al subir el archivo</h2>");
- } finally {
- out.close();
- }
- }
- private org.fve.fachada.binding.configuracion.Sistema jaxbUnmarshalFromFileConfiguracion(java.io.File file) throws java.io.FileNotFoundException, javax.xml.bind.JAXBException, IOException {
- boolean ficheronobloqueado=true;
- boolean mostradomensajebloqueo=false;
- // Get a file channel for the file
- FileChannel channel = new RandomAccessFile(file, "rw").getChannel();
- // Use the file channel to create a lock on the file.
- FileLock lock=null;
- // This method blocks until it can retrieve the lock.
- //FileLock lock = channel.lock();
- // Try acquiring the lock without blocking. This method returns
- // null or throws an exception if the file is already locked.
- while(ficheronobloqueado){
- try {
- lock = channel.tryLock();
- ficheronobloqueado=false;
- //System.out.print("ATENCION MARCA BLOQUEO-------------BLOQUEO ESTABLECIDO");
- } catch (OverlappingFileLockException e) {
- if(mostradomensajebloqueo==false){
- //System.out.print("ATENCION MARCA BLOQUEO-------------FICHERO YA BLOQUEADO POR OTRO PROCESO");
- mostradomensajebloqueo=true;
- }
- }
- }
- org.fve.fachada.binding.configuracion.Sistema ret = null;
- java.io.InputStream is = null;
- try {
- javax.xml.bind.JAXBContext jaxbCtx = javax.xml.bind.JAXBContext.newInstance(org.fve.fachada.binding.configuracion.Sistema.class.getPackage().getName());
- javax.xml.bind.Unmarshaller unmarshaller = jaxbCtx.createUnmarshaller();
- is = new java.io.FileInputStream(file);
- ret = (org.fve.fachada.binding.configuracion.Sistema) unmarshaller.unmarshal(is);
- } finally {
- try {
- is.close();
- // Release the lock
- lock.release();
- //System.out.print("ATENCION MARCA BLOQUEO-------------BLOQUEADO ELIMINADO");
- // Close the file
- channel.close();
- ficheronobloqueado=true;
- } catch (Exception ex) {
- java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.SEVERE, null, ex);
- }
- }
- return ret;
- }
- // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
- /**
- * Handles the HTTP <code>GET</code> method.
- * @param request servlet request
- * @param response servlet response
- * @throws ServletException if a servlet-specific error occurs
- * @throws IOException if an I/O error occurs
- */
- @Override
- protected void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- processRequest(request, response);
- }
- /**
- * Handles the HTTP <code>POST</code> method.
- * @param request servlet request
- * @param response servlet response
- * @throws ServletException if a servlet-specific error occurs
- * @throws IOException if an I/O error occurs
- */
- @Override
- protected void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- processRequest(request, response);
- }
- /**
- * Returns a short description of the servlet.
- * @return a String containing servlet description
- */
- @Override
- public String getServletInfo() {
- return "Short description";
- }// </editor-fold>
- private String invocacion(java.lang.String dirWSDL, java.lang.String operacion, java.lang.String parVal) {
- org.netbeans.j2ee.wsdl.bpelinvocador.wsdlbpelinvocador.WsdlbpelInvocadorPortType port = service.getWsdlbpelInvocadorPort();
- return port.invocacion(dirWSDL, operacion, parVal);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement