コード例 #1
0
  public void init(ServletConfig servletConfig) throws ServletException {
    super.init(servletConfig);

    fileUpload = new DiskFileUpload();
    fileUpload.setHeaderEncoding("UTF-8");
    fileUpload.setSizeMax(verticalProperties.getMultiPartRequestMaxSize());
    fileUpload.setSizeThreshold(64000);

    // Parameters for the mail sent to users when generating a new password:
    SMTP_HOST = verticalProperties.getMailSmtpHost();
    if (SMTP_HOST == null) {
      SMTP_HOST = "mail.enonic.com";
    }
  }
コード例 #2
0
  /**
   * Parses the input stream and partitions the parsed items into a set of form fields and a set of
   * file items.
   *
   * @param request The multipart request wrapper.
   * @param servletContext Our ServletContext object
   * @return multipart processed request
   * @throws HdivMultipartException if an unrecoverable error occurs.
   */
  public HttpServletRequest handleMultipartRequest(
      RequestWrapper request, ServletContext servletContext) throws HdivMultipartException {

    DiskFileUpload upload = new DiskFileUpload();

    upload.setHeaderEncoding(request.getCharacterEncoding());
    // Set the maximum size before a FileUploadException will be thrown.
    upload.setSizeMax(getSizeMax());
    // Set the maximum size that will be stored in memory.
    upload.setSizeThreshold((int) getSizeThreshold());
    // Set the the location for saving data on disk.
    upload.setRepositoryPath(getRepositoryPath(servletContext));

    List<FileItem> items = null;
    try {
      items = upload.parseRequest(request);

    } catch (DiskFileUpload.SizeLimitExceededException e) {
      if (log.isErrorEnabled()) {
        log.error("Size limit exceeded exception");
      }
      // Special handling for uploads that are too big.
      throw new HdivMultipartException(e);

    } catch (FileUploadException e) {
      if (log.isErrorEnabled()) {
        log.error("Failed to parse multipart request", e);
      }
      throw new HdivMultipartException(e);
    }

    // Process the uploaded items
    Iterator<FileItem> iter = items.iterator();
    while (iter.hasNext()) {
      FileItem item = iter.next();

      if (item.isFormField()) {
        this.addTextParameter(request, item);
      } else {
        this.addFileParameter(request, item);
      }
    }
    return request;
  }
コード例 #3
0
  /**
   * Process the blog entries
   *
   * @param httpServletRequest Request
   * @param httpServletResponse Response
   * @param user {@link org.blojsom.blog.BlogUser} instance
   * @param context Context
   * @param entries Blog entries retrieved for the particular request
   * @return Modified set of blog entries
   * @throws BlojsomPluginException If there is an error processing the blog entries
   */
  public BlogEntry[] process(
      HttpServletRequest httpServletRequest,
      HttpServletResponse httpServletResponse,
      BlogUser user,
      Map context,
      BlogEntry[] entries)
      throws BlojsomPluginException {
    if (!authenticateUser(httpServletRequest, httpServletResponse, context, user)) {
      httpServletRequest.setAttribute(PAGE_PARAM, ADMIN_LOGIN_PAGE);

      return entries;
    }

    String username = getUsernameFromSession(httpServletRequest, user.getBlog());
    if (!checkPermission(user, null, username, FILE_UPLOAD_PERMISSION)) {
      httpServletRequest.setAttribute(PAGE_PARAM, ADMIN_ADMINISTRATION_PAGE);
      addOperationResultMessage(context, "You are not allowed to upload files");

      return entries;
    }

    File resourceDirectory =
        new File(
            _blojsomConfiguration.getInstallationDirectory()
                + _resourcesDirectory
                + user.getId()
                + "/");

    String action = BlojsomUtils.getRequestValue(ACTION_PARAM, httpServletRequest);
    if (BlojsomUtils.checkNullOrBlank(action)) {
      _logger.debug("User did not request edit action");

      httpServletRequest.setAttribute(PAGE_PARAM, ADMIN_ADMINISTRATION_PAGE);
    } else if (PAGE_ACTION.equals(action)) {
      _logger.debug("User requested file upload page");

      httpServletRequest.setAttribute(PAGE_PARAM, FILE_UPLOAD_PAGE);
    } else if (UPLOAD_FILE_ACTION.equals(action)) {
      _logger.debug("User requested file upload action");

      // Create a new disk file upload and set its parameters
      DiskFileUpload diskFileUpload = new DiskFileUpload();
      diskFileUpload.setRepositoryPath(_temporaryDirectory);
      diskFileUpload.setSizeThreshold(_maximumMemorySize);
      diskFileUpload.setSizeMax(_maximumUploadSize);

      try {
        List items = diskFileUpload.parseRequest(httpServletRequest);
        Iterator itemsIterator = items.iterator();
        while (itemsIterator.hasNext()) {
          FileItem item = (FileItem) itemsIterator.next();

          // Check for the file upload form item
          if (!item.isFormField()) {
            String itemNameWithoutPath = BlojsomUtils.getFilenameFromPath(item.getName());

            _logger.debug(
                "Found file item: " + itemNameWithoutPath + " of type: " + item.getContentType());

            // Is it one of the accepted file types?
            String fileType = item.getContentType();
            boolean isAcceptedFileType = _acceptedFileTypes.containsKey(fileType);

            String extension = BlojsomUtils.getFileExtension(itemNameWithoutPath);
            boolean isAcceptedFileExtension = true;
            for (int i = 0; i < _invalidFileExtensions.length; i++) {
              String invalidFileExtension = _invalidFileExtensions[i];
              if (itemNameWithoutPath.indexOf(invalidFileExtension) != -1) {
                isAcceptedFileExtension = false;
                break;
              }
            }

            // If so, upload the file to the resources directory
            if (isAcceptedFileType && isAcceptedFileExtension) {
              if (!resourceDirectory.exists()) {
                if (!resourceDirectory.mkdirs()) {
                  _logger.error(
                      "Unable to create resource directory for user: "******"Unable to create resource directory");
                  return entries;
                }
              }

              File resourceFile =
                  new File(
                      _blojsomConfiguration.getInstallationDirectory()
                          + _resourcesDirectory
                          + user.getId()
                          + "/"
                          + itemNameWithoutPath);
              try {
                item.write(resourceFile);
              } catch (Exception e) {
                _logger.error(e);
                addOperationResultMessage(
                    context, "Unknown error in file upload: " + e.getMessage());
              }

              String resourceURL =
                  user.getBlog().getBlogBaseURL()
                      + _blojsomConfiguration.getResourceDirectory()
                      + user.getId()
                      + "/"
                      + item.getName();

              _logger.debug("Successfully uploaded resource file: " + resourceFile.toString());
              addOperationResultMessage(
                  context,
                  "Successfully upload resource file: "
                      + item.getName()
                      + ". <p></p>Here is a link to <a href=\""
                      + resourceURL
                      + "\">"
                      + item.getName()
                      + "</a>. Right-click and copy the link to the resource to use in a blog entry.");
            } else {
              if (!isAcceptedFileExtension) {
                _logger.error("Upload file does not have an accepted extension: " + extension);
                addOperationResultMessage(
                    context, "Upload file does not have an accepted extension: " + extension);
              } else {
                _logger.error(
                    "Upload file is not an accepted type: "
                        + item.getName()
                        + " of type: "
                        + item.getContentType());
                addOperationResultMessage(
                    context,
                    "Upload file is not an accepted type: "
                        + item.getName()
                        + " of type: "
                        + item.getContentType());
              }
            }
          }
        }
      } catch (FileUploadException e) {
        _logger.error(e);
        addOperationResultMessage(context, "Unknown error in file upload: " + e.getMessage());
      }

      httpServletRequest.setAttribute(PAGE_PARAM, FILE_UPLOAD_PAGE);
    } else if (DELETE_UPLOAD_FILES.equals(action)) {
      String[] filesToDelete = httpServletRequest.getParameterValues(FILE_TO_DELETE);
      if (filesToDelete != null && filesToDelete.length > 0) {
        File deletedFile;
        for (int i = 0; i < filesToDelete.length; i++) {
          String fileToDelete = filesToDelete[i];
          deletedFile = new File(resourceDirectory, fileToDelete);
          if (!deletedFile.delete()) {
            _logger.debug("Unable to delete resource file: " + deletedFile.toString());
          }
        }

        addOperationResultMessage(
            context, "Deleted " + filesToDelete.length + " file(s) from resources directory");
      }

      httpServletRequest.setAttribute(PAGE_PARAM, FILE_UPLOAD_PAGE);
    }

    // Create a list of files in the user's resource directory
    Map resourceFilesMap = null;
    if (resourceDirectory.exists()) {
      File[] resourceFiles = resourceDirectory.listFiles();

      if (resourceFiles != null) {
        resourceFilesMap = new HashMap(resourceFiles.length);
        for (int i = 0; i < resourceFiles.length; i++) {
          File resourceFile = resourceFiles[i];
          resourceFilesMap.put(resourceFile.getName(), resourceFile.getName());
        }
      }
    } else {
      resourceFilesMap = new HashMap();
    }

    resourceFilesMap = new TreeMap(resourceFilesMap);
    context.put(PLUGIN_ADMIN_FILE_UPLOAD_FILES, resourceFilesMap);

    return entries;
  }
コード例 #4
0
  @Override
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {
    super.doPost(request);
    logger.debug("Inicio.");

    PrintWriter out = response.getWriter();

    try {

      CResultadoOperacion resultadoOperacion;

      JAASUserPrincipal jassUserPrincipal = (JAASUserPrincipal) request.getUserPrincipal();
      PasarelaAdmcar.listaSesiones =
          (ListaSesiones)
              SessionsContextShared.getContextShared()
                  .getSharedAttribute(this.getServletContext(), "UserSessions");
      Sesion userSession = PasarelaAdmcar.listaSesiones.getSesion(jassUserPrincipal.getName());

      Principal userPrincipal = userSession.getUserPrincipal();
      Enumeration userPerms = userSession.getRoleGroup().members();

      /* - antes de MultipartPostMethod -
      String stream = request.getParameter("mensajeXML");
         logger.info("stream="+stream);
         */

      /* MultipartPostMethod */
      String stream = null;
      /** Recogemos los nuevos ficheros annadidos */
      Hashtable fileUploads = new Hashtable();
      // Create a new file upload handler
      DiskFileUpload upload = new DiskFileUpload();

      /** Set upload parameters */
      upload.setSizeThreshold(CConstantesComando.MaxMemorySize);
      upload.setSizeMax(CConstantesComando.MaxRequestSize);
      /*
      String yourTempDirectory= "anexos" + File.separator;
      upload.setRepositoryPath(yourTempDirectory);
      */

      // Parse the request
      try {
        //               request.setCharacterEncoding("ISO-8859-1");
        List items = upload.parseRequest(request);

        // Process the uploaded items
        Iterator iter = items.iterator();
        String sMunicipio = "";
        while (iter.hasNext()) {
          FileItem item = (FileItem) iter.next();

          String fieldName = item.getFieldName();
          if (item.isFormField()) {
            if (fieldName.equalsIgnoreCase("mensajeXML")) {
              stream = item.getString("ISO-8859-1");
              logger.info("MENSAJE XML:" + item.getString("ISO-8859-1"));
              System.out.println(
                  "CServletLicencias.doPost mensajeXML=" + item.getString("ISO-8859-1"));
            } else if (fieldName.equalsIgnoreCase(
                com.geopista.protocol.net.EnviarSeguro.idMunicipio)) {
              sMunicipio = item.getString("ISO-8859-1");
              userSession.setIdMunicipio(sMunicipio);
            }
          } else {
            CAnexo anexo = new CAnexo();
            /** Debido a que el nombre del fichero puede contener acentos. */
            fieldName = URLDecoder.decode(fieldName, "ISO-8859-1");
            anexo.setFileName(fieldName);
            anexo.setContent(item.get());
            fileUploads.put(fieldName, anexo);
          }
        }

      } catch (FileUploadBase.SizeLimitExceededException ex) {
        String respuesta =
            buildResponse(
                new CResultadoOperacion(false, "FileUploadBase.SizeLimitExceededException"));
        out.print(respuesta);
        out.flush();
        out.close();
        logger.warn("************************* FileUploadBase.SizeLimitExceededException");
        return;
      }

      // **********************************************************
      // ** Chequeamos
      // ******************************************************
      if ((stream == null) || (stream.trim().equals(""))) {
        String respuesta = buildResponse(new CResultadoOperacion(false, "stream es null"));
        out.print(respuesta);
        out.flush();
        out.close();
        logger.warn("stream null or empty. stream: " + stream);
        return;
      }

      StringReader sw = new StringReader(stream);
      logger.info("sw=" + sw.toString());

      CEnvioOperacion envioOperacion =
          (com.geopista.protocol.CEnvioOperacion)
              Unmarshaller.unmarshal(com.geopista.protocol.CEnvioOperacion.class, sw);
      logger.debug("envioOperacion.getComando(): " + envioOperacion.getComando());

      // CResultadoOperacion resultadoOperacion;
      String numExpediente;
      CSolicitudLicencia solicitudLicencia;
      CExpedienteLicencia expedienteLicencia;
      Hashtable hash;
      Vector vector = new Vector();

      switch (envioOperacion.getComando()) {
        case CConstantesComando.CMD_LICENCIAS_CREAR_EXPEDIENTE:
          solicitudLicencia = envioOperacion.getSolicitudLicencia();
          expedienteLicencia = envioOperacion.getExpedienteLicencia();

          /** inicio */
          /*
           * Cargamos en una hash los nombres de los anexos de la solicitud (marcados como annadidos, borrados, sin marcar).
           * El contenido de los marcados como annadidos, so se encuentra en el xml, sino en la hash fileUploads.
           */

          /* ANEXOS de solicitud. En la creacion no hay mejora de datos ni alegacion.
           * No tienen contenido.
           * Nos interesara recoger el estado (annadido, borrado) y el tipo de anexo.
           */
          /* SOLICITUD **/
          solicitudLicencia.setAnexos(
              actualizarAnexosUploaded(solicitudLicencia.getAnexos(), fileUploads));

          resultadoOperacion =
              COperacionesDatabaseLicencias.crearExpedienteLicencias(
                  solicitudLicencia,
                  expedienteLicencia,
                  userPrincipal,
                  userSession.getIdMunicipio());
          break;

        case CConstantesComando.CMD_LICENCIAS_MODIFICAR_EXPEDIENTE:
          solicitudLicencia = envioOperacion.getSolicitudLicencia();
          expedienteLicencia = envioOperacion.getExpedienteLicencia();

          /** inicio */
          /*
           * Cargamos en una hash los nombres de los anexos de la solicitud (marcados como annadidos, borrados, sin marcar).
           * El contenido de los marcados como annadidos, so se encuentra en el xml, sino en la hash fileUploads.
           */

          /*
           * No tienen contenido.
           * Nos interesara recoger el estado (annadido, borrado) y el tipo de anexo.
           */
          /** ANEXOS SOLICITUD */
          solicitudLicencia.setAnexos(
              actualizarAnexosUploaded(solicitudLicencia.getAnexos(), fileUploads));

          /* ANEXOS MEJORA DE DATOS */
          Vector vMejoras = solicitudLicencia.getMejoras();
          Vector vM = new Vector();
          if (vMejoras != null) {
            for (Enumeration e = vMejoras.elements(); e.hasMoreElements(); ) {
              Mejora mejora = (Mejora) e.nextElement();
              mejora.setAnexos(actualizarAnexosUploaded(mejora.getAnexos(), fileUploads));
              vM.add(mejora);
            }
            solicitudLicencia.setMejoras(vM);
          }

          /* ANEXOS ALEGACION */
          Alegacion alegacion = expedienteLicencia.getAlegacion();
          if (alegacion != null) {
            alegacion.setAnexos(actualizarAnexosUploaded(alegacion.getAnexos(), fileUploads));
            expedienteLicencia.setAlegacion(alegacion);
          }

          resultadoOperacion =
              COperacionesDatabaseLicencias.modificarExpedienteLicencias(
                  solicitudLicencia,
                  expedienteLicencia,
                  userPrincipal,
                  userSession.getIdMunicipio());
          break;

        case CConstantesComando.CMD_LICENCIAS_GET_TIPOS_LICENCIA:
          resultadoOperacion = new CResultadoOperacion(true, "");
          resultadoOperacion.setVector(COperacionesDatabaseLicencias.getTiposLicencia());
          break;

        case CConstantesComando.CMD_LICENCIAS_GET_TIPOS_OBRA:
          resultadoOperacion = new CResultadoOperacion(true, "");
          resultadoOperacion.setVector(COperacionesDatabaseLicencias.getTiposObra());
          break;

        case CConstantesComando.CMD_LICENCIAS_GET_TIPOS_ANEXO:
          resultadoOperacion = new CResultadoOperacion(true, "");
          resultadoOperacion.setVector(COperacionesDatabaseLicencias.getTiposAnexo());
          break;

        case CConstantesComando.CMD_LICENCIAS_GET_ESTADOS_DISPONIBLES:
          resultadoOperacion = new CResultadoOperacion(true, "");
          expedienteLicencia = (CExpedienteLicencia) envioOperacion.getParametro();
          int idTipoLicencia =
              new Integer(expedienteLicencia.getTipoLicenciaDescripcion()).intValue();
          resultadoOperacion.setVector(
              COperacionesDatabaseLicencias.getEstadosDisponibles(
                  expedienteLicencia, idTipoLicencia));
          break;

        case CConstantesComando.CMD_LICENCIAS_GET_ESTADOS_PERMITIDOS:
          resultadoOperacion = new CResultadoOperacion(true, "");
          expedienteLicencia = (CExpedienteLicencia) envioOperacion.getParametro();
          idTipoLicencia = new Integer(expedienteLicencia.getTipoLicenciaDescripcion()).intValue();
          resultadoOperacion.setVector(
              COperacionesDatabaseLicencias.getEstadosPermitidos(
                  expedienteLicencia, userPerms, idTipoLicencia));
          break;

        case CConstantesComando.CMD_LICENCIAS_GET_ESTADOS:
          resultadoOperacion = new CResultadoOperacion(true, "");
          Vector tiposLicencia = (Vector) envioOperacion.getTiposLicencia();
          resultadoOperacion.setVector(COperacionesDatabaseLicencias.getEstados(tiposLicencia));
          break;

        case CConstantesComando.CMD_LICENCIAS_GET_VIAS_NOTIFICACION:
          resultadoOperacion = new CResultadoOperacion(true, "");
          resultadoOperacion.setVector(COperacionesDatabaseLicencias.getViasNotificacion());
          break;

        case CConstantesComando.CMD_LICENCIAS_GET_SOLICITUD_LICENCIA:
          resultadoOperacion = new CResultadoOperacion(true, "");
          numExpediente = (String) envioOperacion.getParametro();
          String locale = (String) envioOperacion.getParametro2();
          tiposLicencia = (Vector) envioOperacion.getTiposLicencia();
          resultadoOperacion =
              COperacionesDatabaseLicencias.getExpedienteLicencia(
                  numExpediente, userSession.getIdMunicipio(), locale, tiposLicencia);
          break;

        case CConstantesComando.CMD_LICENCIAS_GET_SOLICITUDES_LICENCIA:
          resultadoOperacion = new CResultadoOperacion(true, "");
          locale = (String) envioOperacion.getParametro2();
          tiposLicencia = (Vector) envioOperacion.getTiposLicencia();
          resultadoOperacion =
              COperacionesDatabaseLicencias.getSolicitudesLicencia(locale, tiposLicencia);
          break;

        case CConstantesComando.CMD_LICENCIAS_GET_SEARCHED_EXPEDIENTES:
          resultadoOperacion = new CResultadoOperacion(true, "");
          hash = envioOperacion.getHashtable();
          resultadoOperacion.setVector(
              COperacionesDatabaseLicencias.getSearchedExpedientes(
                  hash,
                  userPerms,
                  userSession.getIdMunicipio(),
                  envioOperacion.getTiposLicencia()));
          break;

        case CConstantesComando.CMD_LICENCIAS_GET_SEARCHED_EXPEDIENTES_PLANOS:
          resultadoOperacion = new CResultadoOperacion(true, "");
          hash = envioOperacion.getHashtable();
          resultadoOperacion.setExpedientes(
              COperacionesDatabaseLicencias.getSearchedExpedientesPlanos(
                  hash, userSession.getIdMunicipio(), envioOperacion.getTiposLicencia()));
          resultadoOperacion.setVector(
              COperacionesDatabaseLicencias.getSearchedReferenciasPlanos(
                  hash, userSession.getIdMunicipio(), envioOperacion.getTiposLicencia()));

          break;
        case CConstantesComando.CMD_LICENCIAS_GET_SEARCHED_REFERENCIAS_CATASTRALES:
          resultadoOperacion = new CResultadoOperacion(true, "");
          hash = envioOperacion.getHashtable();
          resultadoOperacion.setVector(
              COperacionesDatabaseLicencias.getSearchedReferenciasCatastrales(
                  hash, userSession.getIdMunicipio()));
          break;

        case CConstantesComando.CMD_LICENCIAS_GET_SEARCHED_ADDRESSES:
          resultadoOperacion = new CResultadoOperacion(true, "");
          hash = envioOperacion.getHashtable();
          resultadoOperacion.setVector(
              COperacionesDatabaseLicencias.getSearchedAddresses(
                  hash, userSession.getIdMunicipio()));
          break;

        case CConstantesComando.CMD_LICENCIAS_GET_SEARCHED_ADDRESSES_BY_NUMPOLICIA:
          resultadoOperacion = new CResultadoOperacion(true, "");
          hash = envioOperacion.getHashtable();
          resultadoOperacion.setVector(
              COperacionesDatabaseLicencias.getSearchedAddressesByNumPolicia(
                  hash, userSession.getIdMunicipio()));
          break;

        case CConstantesComando.CMD_LICENCIAS_GET_SEARCHED_PERSONAS:
          resultadoOperacion = new CResultadoOperacion(true, "");
          hash = envioOperacion.getHashtable();
          resultadoOperacion.setVector(
              COperacionesDatabaseLicencias.getSearchedPersonas(
                  hash, userSession.getIdMunicipio()));
          break;

        case CConstantesComando.CMD_LICENCIAS_GET_TIPOS_FINALIZACION:
          resultadoOperacion = new CResultadoOperacion(true, "");
          resultadoOperacion.setVector(COperacionesDatabaseLicencias.getTiposFinalizacion());
          break;

        case CConstantesComando.CMD_LICENCIAS_GET_TIPOS_TRAMITACION:
          resultadoOperacion = new CResultadoOperacion(true, "");
          resultadoOperacion.setVector(COperacionesDatabaseLicencias.getTiposTramitacion());
          break;

        case CConstantesComando.CMD_LICENCIAS_GET_TIPOS_NOTIFICACION:
          resultadoOperacion = new CResultadoOperacion(true, "");
          resultadoOperacion.setVector(COperacionesDatabaseLicencias.getTiposNotificacion());
          break;

        case CConstantesComando.CMD_LICENCIAS_GET_ESTADOS_NOTIFICACION:
          resultadoOperacion = new CResultadoOperacion(true, "");
          resultadoOperacion.setVector(COperacionesDatabaseLicencias.getEstadosNotificacion());
          break;

        case CConstantesComando.CMD_LICENCIAS_GET_ESTADOS_RESOLUCION:
          resultadoOperacion = new CResultadoOperacion(true, "");
          resultadoOperacion.setVector(COperacionesDatabaseLicencias.getEstadosResolucion());
          break;

        case CConstantesComando.CMD_LICENCIAS_GET_NOTIFICACIONES:
          resultadoOperacion = new CResultadoOperacion(true, "");
          hash = envioOperacion.getHashtable();
          resultadoOperacion.setVector(COperacionesDatabaseLicencias.getNotificaciones(hash));
          break;

        case CConstantesComando.CMD_LICENCIAS_GET_PARCELARIO:
          resultadoOperacion = new CResultadoOperacion(true, "");
          hash = envioOperacion.getHashtable();
          resultadoOperacion.setVector(
              COperacionesDatabaseLicencias.getParcelario(hash, userSession.getIdMunicipio()));
          break;

        case CConstantesComando.CMD_LICENCIAS_GET_SOLICITUDES_EXPEDIENTES_INFORME:
          hash = envioOperacion.getHashtable();
          resultadoOperacion =
              COperacionesDatabaseLicencias.getSolicitudesExpedientesInforme(
                  hash, userSession.getIdMunicipio(), envioOperacion.getTiposLicencia());
          break;

        case CConstantesComando.CMD_LICENCIAS_GET_PLANTILLAS:
          String aplicacion = (String) envioOperacion.getParametro();
          vector = COperacionesDatabaseLicencias.getPlantillas(aplicacion);
          resultadoOperacion = new CResultadoOperacion(true, "");
          resultadoOperacion.setVector(vector);
          break;

        case CConstantesComando.CMD_LICENCIAS_GET_NOTIFICACIONES_MENU:
          hash = envioOperacion.getHashtable();
          vector =
              COperacionesDatabaseLicencias.getNotificacionesMenu(
                  hash, userSession.getIdMunicipio(), envioOperacion.getTiposLicencia());
          resultadoOperacion = new CResultadoOperacion(true, "");
          resultadoOperacion.setVector(vector);
          break;

        case CConstantesComando.CMD_LICENCIAS_GET_EVENTOS:
          hash = envioOperacion.getHashtable();
          locale = (String) envioOperacion.getParametro();
          resultadoOperacion =
              COperacionesDatabaseLicencias.getEventos(
                  hash, userSession.getIdMunicipio(), envioOperacion.getTiposLicencia(), locale);
          break;
        case CConstantesComando.CMD_LICENCIAS_GET_ULTIMOS_EVENTOS:
          hash = envioOperacion.getHashtable();
          locale = (String) envioOperacion.getParametro();
          resultadoOperacion =
              COperacionesDatabaseLicencias.getUltimosEventos(
                  hash, userSession.getIdMunicipio(), envioOperacion.getTiposLicencia(), locale);
          break;
        case CConstantesComando.CMD_LICENCIAS_GET_EVENTOS_SIN_REVISAR:
          hash = envioOperacion.getHashtable();
          locale = (String) envioOperacion.getParametro();
          resultadoOperacion =
              COperacionesDatabaseLicencias.getEventosSinRevisar(
                  hash, userSession.getIdMunicipio(), envioOperacion.getTiposLicencia(), locale);
          break;
        case CConstantesComando.CMD_LICENCIAS_GET_HISTORICO:
          hash = envioOperacion.getHashtable();
          locale = (String) envioOperacion.getParametro();
          resultadoOperacion =
              COperacionesDatabaseLicencias.getHistorico(
                  hash, userSession.getIdMunicipio(), envioOperacion.getTiposLicencia(), locale);
          break;
        case CConstantesComando.CMD_LICENCIAS_GET_HISTORICO_EXPEDIENTE:
          hash = envioOperacion.getHashtable();
          locale = (String) envioOperacion.getParametro();
          resultadoOperacion =
              COperacionesDatabaseLicencias.getHistorico(
                  hash, userSession.getIdMunicipio(), envioOperacion.getTiposLicencia(), locale);
          break;
        case CConstantesComando.CMD_LICENCIAS_GET_NOTIFICACIONES_PENDIENTES:
          hash = envioOperacion.getHashtable();
          vector =
              COperacionesDatabaseLicencias.getNotificacionesPendientes(
                  userSession.getIdMunicipio(), envioOperacion.getTiposLicencia());
          resultadoOperacion = new CResultadoOperacion(true, "");
          resultadoOperacion.setVector(vector);
          break;
        case CConstantesComando.CMD_LICENCIAS_GET_EVENTOS_PENDIENTES:
          resultadoOperacion =
              COperacionesDatabaseLicencias.getEventosPendientes(
                  userSession.getIdMunicipio(),
                  userPerms,
                  envioOperacion.getTiposLicencia(),
                  (String) envioOperacion.getParametro());
          break;
        case CConstantesComando.CMD_LICENCIAS_BLOQUEAR_EXPEDIENTE:
          boolean bloquear = ((Boolean) envioOperacion.getParametro()).booleanValue();
          numExpediente = envioOperacion.getExpedienteLicencia().getNumExpediente();
          resultadoOperacion =
              COperacionesDatabaseLicencias.bloquearExpediente(numExpediente, bloquear);
          break;
        case CConstantesComando.CMD_INSERTAR_INFORME:
          resultadoOperacion =
              COperacionesDatabaseLicencias.insertarInforme(
                  (Informe) envioOperacion.getParametro(), fileUploads);
          break;
        case CConstantesComando.CMD_LICENCIAS_ACTUALIZAR_IDSIGEM:
          expedienteLicencia = envioOperacion.getExpedienteLicencia();
          resultadoOperacion = COperacionesDatabaseLicencias.actualizarIdSigem(expedienteLicencia);
          break;
        case CConstantesComando.CMD_LICENCIAS_OBTENER_IDSIGEM:
          expedienteLicencia = envioOperacion.getExpedienteLicencia();
          resultadoOperacion = COperacionesDatabaseLicencias.obtenerIdSigem(expedienteLicencia);
          break;
        case CConstantesComando.CMD_LICENCIAS_ACTUALIZAR_ESTADOSIGEM:
          expedienteLicencia = envioOperacion.getExpedienteLicencia();
          resultadoOperacion =
              COperacionesDatabaseLicencias.checkExpedientePublicado(
                  expedienteLicencia, userSession.getIdMunicipio());
          break;
        case CConstantesComando.CMD_LICENCIAS_PUBLICAR_EXPEDEINTE_SIGEM:
          expedienteLicencia = envioOperacion.getExpedienteLicencia();
          solicitudLicencia = envioOperacion.getSolicitudLicencia();
          resultadoOperacion =
              COperacionesDatabaseLicencias.publicarExpedienteSigem(
                  expedienteLicencia, solicitudLicencia, userSession.getIdMunicipio());
          break;

        case CConstantesComando.CMD_LICENCIAS_ANEXO_ALFRESCO:
          resultadoOperacion =
              COperacionesDatabaseLicencias.anexoAlfresco(
                  envioOperacion.getSolicitudLicencia().getIdSolicitud(),
                  envioOperacion.getSolicitudLicencia().getAnexos(),
                  userPrincipal);
          break;

        case CConstantesComando.CMD_LICENCIAS_ANEXO_GETID:
          resultadoOperacion =
              COperacionesDatabaseLicencias.getAnexoId(
                  (String) envioOperacion.getParametro(), (Long) envioOperacion.getParametro2());
          break;

        default:
          logger.warn(
              "Comand not found. envioOperacion.getComando(): " + envioOperacion.getComando());
          resultadoOperacion = new CResultadoOperacion(false, "Command not found");
      }

      String respuesta = buildResponse(resultadoOperacion);
      out.print(respuesta);
      out.flush();
      out.close();

    } catch (Exception ex) {
      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
      ex.printStackTrace(pw);
      logger.error("Exception: " + sw.toString());
    }
  }