Exemplo n.º 1
0
 private static void addCols(Locale locale, Element parent) {
   Element bodyMinuta = parent.addElement(XML_COLS_TEXT);
   bodyMinuta
       .addElement(XML_COL_LOWER_TEXT)
       .add(
           DocumentHelper.createCDATA(
               RBUtil.getInstance(locale).getProperty(I18N_BOOKUSE_ORIGINDOCS_COL1)));
   bodyMinuta
       .addElement(XML_COL_LOWER_TEXT)
       .add(
           DocumentHelper.createCDATA(
               RBUtil.getInstance(locale).getProperty(I18N_BOOKUSE_ORIGINDOCS_COL2)));
 }
Exemplo n.º 2
0
  /**
   * *****************************************************************************************************************
   * Public methods
   * ****************************************************************************************************************
   */
  public static Document createXMLOrigDocFdr(
      List list, int type, int canAdd, int canDel, AxSf axsf, Locale locale, boolean bad) {
    shortFormatter =
        new SimpleDateFormat(RBUtil.getInstance(locale).getProperty(I18N_DATE_SHORTFORMAT));

    Document document = DocumentHelper.createDocument();

    Element root = document.addElement(XML_ORIGDOCS_TEXT);

    addLibro(type, canAdd, canDel, root);

    int fld8Type = 0;
    if (axsf.getFld8() != null && axsf.getFld8().getScrTypeadm() != null) {
      fld8Type = axsf.getFld8().getScrTypeadm().getId().intValue();
      if (fld8Type != 1) {
        fld8Type = 0;
      }
    }

    String id = "0";
    if (axsf.getFld8() != null) {
      id = axsf.getFld8().getId().toString();
    }
    addRegistro(id, fld8Type, root);
    addCols(locale, root);

    Element docs = root.addElement(XML_DOCS_TEXT);
    if (bad) {
      SaveOrigDocDataDocInput saveOrigDocDataDocInput = null;
      for (Iterator it = list.iterator(); it.hasNext(); ) {
        saveOrigDocDataDocInput = (SaveOrigDocDataDocInput) it.next();
        addDocsBad(saveOrigDocDataDocInput, locale, docs);
      }
    } else {
      ScrRegorigdoc scr = null;
      for (Iterator it = list.iterator(); it.hasNext(); ) {
        scr = (ScrRegorigdoc) it.next();
        addDocs(scr, locale, docs);
      }
    }

    return document;
  }
Exemplo n.º 3
0
  private void doWork(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    response.setDateHeader("Expires", 0);
    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("Pragma", "no-cache");
    response.setContentType("text/html; charset=UTF-8");

    // identificador de archivo de usuario.
    Integer archiveId = RequestUtils.parseRequestParameterAsInteger(request, "ArchiveId");
    // Identificador de carpeta.
    Integer folderId = RequestUtils.parseRequestParameterAsInteger(request, "FolderId");
    // Obtenemos la sesión asociada al usuario.
    HttpSession session = request.getSession();
    // Texto del idioma. Ej: EU_
    String idioma = (String) session.getAttribute(Keys.J_IDIOMA);
    // Número del idioma. Ej: 10
    Long numIdioma = (Long) session.getAttribute(Keys.J_NUM_IDIOMA);
    // Formulario o no.
    Boolean form = (Boolean) session.getAttribute(Keys.J_OPENFOLDER_FORM);
    // Obtenemos el objeto de configuración del servidor de aplicaciones y el identificador
    // de sesión para este usuario en el servidor de aplicaciones.
    UseCaseConf useCaseConf = (UseCaseConf) session.getAttribute(J_USECASECONF);
    // response.getWriter().write(ACTIVATE_TREE_1);
    // response.getWriter().write("LISTA DE DISTRIBUCION");
    PrintWriter writer = response.getWriter();
    try {
      Document xmlDocument =
          bookUseCase.getDtrFdrResults(useCaseConf, archiveId, folderId.intValue());

      String xslPath =
          ContextUtil.getRealPath(session.getServletContext(), XSL_DTRLISTFDR_RELATIVE_PATH);
      StreamSource s =
          new StreamSource(
              new InputStreamReader(new BufferedInputStream(new FileInputStream(xslPath))));
      Templates cachedXSLT = factory.newTemplates(s);
      Transformer transformer = cachedXSLT.newTransformer();
      DocumentSource source = new DocumentSource(xmlDocument);

      StreamResult result = new StreamResult(writer);
      transformer.transform(source, result);

    } catch (ValidationException e) {
      _logger.fatal("Error de validacion", e);
      writer.write(ACTIVATE_TREE_1);
      ResponseUtils.generateJavaScriptLog(
          writer,
          RBUtil.getInstance(useCaseConf.getLocale())
              .getProperty(Keys.I18N_EXCEPTION_VALIDATIONEXCEPTION));
    } catch (BookException e) {
      _logger.fatal("Error en el libro", e);
      writer.write(ACTIVATE_TREE_1);
      ResponseUtils.generateJavaScriptError(writer, e);
    } catch (SessionException e) {
      _logger.fatal("Error en la sesion", e);
      ResponseUtils.generateJavaScriptLogSessionExpiredDtrfdr(
          writer, e.getMessage(), idioma, numIdioma);
      // ResponseUtils.generateJavaScriptError(response, e);
    } catch (TransformerConfigurationException e) {
      _logger.fatal("Error en la distribucion", e);
      writer.write(ACTIVATE_TREE_1);
      ResponseUtils.generateJavaScriptLog(
          writer,
          RBUtil.getInstance(useCaseConf.getLocale())
              .getProperty(Keys.I18N_ISICRESSRV_ERR_CREATING_DTR_OBJ));
    } catch (TransformerFactoryConfigurationError e) {
      _logger.fatal("Error en la distribucion", e);
      writer.write(ACTIVATE_TREE_1);
      ResponseUtils.generateJavaScriptLog(
          writer,
          RBUtil.getInstance(useCaseConf.getLocale())
              .getProperty(Keys.I18N_ISICRESSRV_ERR_CREATING_DTR_OBJ));
    } catch (TransformerException e) {
      _logger.fatal("Error en la distribucion", e);
      writer.write(ACTIVATE_TREE_1);
      ResponseUtils.generateJavaScriptLog(
          writer,
          RBUtil.getInstance(useCaseConf.getLocale())
              .getProperty(Keys.I18N_ISICRESSRV_ERR_CREATING_DTR_OBJ));
    } catch (Exception e) {
      _logger.fatal("Error en la distribucion", e);
      writer.write(ACTIVATE_TREE_1);
      ResponseUtils.generateJavaScriptLog(
          writer,
          RBUtil.getInstance(useCaseConf.getLocale())
              .getProperty(Keys.I18N_ISICRESSRV_ERR_CREATING_DTR_OBJ));
    }
  }
Exemplo n.º 4
0
  private void doWork(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    response.setDateHeader("Expires", 0);
    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("Pragma", "no-cache");
    response.setContentType("text/html; charset=UTF-8");

    PrintWriter writer = response.getWriter();

    // Obtenemos la sesión asociada al usuario.
    HttpSession session = request.getSession();
    // Texto del idioma. Ej: EU_
    String idioma = (String) session.getAttribute(Keys.J_IDIOMA);
    // Número del idioma. Ej: 10
    Long numIdioma = (Long) session.getAttribute(Keys.J_NUM_IDIOMA);
    // Obtenemos el objeto de configuración del servidor de aplicaciones y el identificador
    // de sesión para este usuario en el servidor de aplicaciones.
    UseCaseConf useCaseConf = (UseCaseConf) session.getAttribute(J_USECASECONF);

    String method = request.getParameter("method");

    try {

      if (method.equals("loadDatos")) {
        saveOrdenation(session, request);
        saveSearchConditions(session, request);
        loadDatos(request, response, session);
      } else {
        if (method.equals("search")) {
          saveOrdenation(session, request);
          doSearch(request, response, session, useCaseConf, writer);
        } else {

          if (method.equals("showResults")) {
            showResults(session, response);
          } else {
            saveOrdenation(session, request);
            deleteRow(request, response, session);
          }
        }
      }
    } catch (RemoteException e) {
      _logger.fatal("Error de comunicaciones", e);
      writer.write(ACTIVATE_SEVERAL);
      ResponseUtils.generateJavaScriptLog(
          writer,
          RBUtil.getInstance(useCaseConf.getLocale())
              .getProperty(Keys.I18N_EXCEPTION_REMOTEEXCEPTION));
    } catch (SecurityException e) {
      _logger.fatal("Error de seguridad", e);
      writer.write(ACTIVATE_SEVERAL);
      ResponseUtils.generateJavaScriptError(writer, e, useCaseConf.getLocale());
    } catch (ValidationException e) {
      _logger.fatal("Error de validacion", e);
      e.printStackTrace(System.err);
      writer.write(ACTIVATE_SEVERAL);
      ResponseUtils.generateJavaScriptLog(
          writer,
          RBUtil.getInstance(useCaseConf.getLocale())
              .getProperty(Keys.I18N_EXCEPTION_VALIDATIONEXCEPTION));
    } catch (BookException e) {
      _logger.fatal("Error en el libro", e);
      writer.write(ACTIVATE_SEVERAL);
      ResponseUtils.generateJavaScriptError(writer, e);
    } catch (AttributesException e) {
      _logger.fatal("Error en los atributos", e);
      writer.write(ACTIVATE_SEVERAL);
      ResponseUtils.generateJavaScriptError(writer, e, useCaseConf.getLocale());
    } catch (SessionException e) {
      _logger.fatal("Error en la sesion", e);
      writer.write(ACTIVATE_SEVERAL);
      ResponseUtils.generateJavaScriptErrorSessionExpired(writer, e, idioma, numIdioma);
      // ResponseUtils.generateJavaScriptError(writer, e);
    } catch (Exception e) {
      _logger.fatal("Error al cargar la lista", e);
      writer.write(ACTIVATE_SEVERAL);
      ResponseUtils.generateJavaScriptLog(
          writer,
          RBUtil.getInstance(useCaseConf.getLocale())
              .getProperty(Keys.I18N_ISICRESSRV_ERR_CREATING_FDRQRY_OBJ));
    }
  }
Exemplo n.º 5
0
  private void doSearch(
      HttpServletRequest request,
      HttpServletResponse response,
      HttpSession session,
      UseCaseConf useCaseConf,
      PrintWriter writer)
      throws ValidationException, SessionException, BookException, AttributesException,
          SecurityException, ParseException, FileNotFoundException,
          TransformerConfigurationException, TransformerException, Exception {

    QuerySearchAvanced querySearchAvanced = saveSearchConditions(session, request);

    Document xmlDocument = null;
    List badCtrls = null;
    Integer bookID = (Integer) session.getAttribute(Keys.J_BOOK);

    Map rowMap = RowQuerySearchAdvanced.transformToMap(querySearchAvanced);

    // Validar los campos de búsqueda según el formato de cada uno
    badCtrls = bookUseCase.validateAdvancedQueryParams(useCaseConf, bookID, rowMap);

    // Si todos los campos están correctamente rellenados
    if (badCtrls.isEmpty()) {

      xmlDocument = doSearch(useCaseConf, bookID, rowMap, querySearchAvanced.getOrder());

      if (xmlDocument != null) {
        // Almacenamos el xml con los resultados en sesión
        session.setAttribute("queryResults", xmlDocument);

        String script =
            "<script language=javascript>top.g_TreeFunc=true;top.Main.Workspace.EnabledTool();"
                + "window.open(top.g_URL + \"/vldSearchOperator.jsp?method=showResults&SessionPId="
                + session.getId()
                + "\", \"TableData\",\"location=no\",true);</script>";

        response.getWriter().write(script);

      } else {

        writer.write(
            "<HTML><HEAD><script type=text/javascript language=javascript src=\"./scripts/tbltext.js\"></script>");

        ResponseUtils.generateJavaScriptLog(
            writer,
            RBUtil.getInstance(useCaseConf.getLocale())
                .getProperty(Keys.I18N_EXCEPTION_BOOK_HAS_NO_FOLDERS));
        writer.write(ACTIVATE_SEVERAL_ADVSEARCH);

        writer.write("</HEAD><BODY tabIndex=-1></BODY></HTML>");
      }
    } else {
      FieldSearchAvanced[] fieldList = querySearchAvanced.getFieldSearchAvanced();
      boolean[] invalidValues = querySearchAvanced.getHasInvalidValue();
      for (int i = 0; i < fieldList.length; i++) {
        FieldSearchAvanced field = fieldList[i];
        if (field != null) {
          if (badCtrls.contains(new Integer(field.getRowId()))) {
            invalidValues[i] = true;
          } else {
            invalidValues[i] = false;
          }
        }
      }
      // Actualizamos el valor en sesión de los campos de búsqueda para que aparezcan los no
      // validados
      session.setAttribute("valoresConsulta", querySearchAvanced);

      writer.write(
          "<HTML><HEAD><script type=text/javascript language=javascript src=\"./scripts/tbltext.js\"></script>");

      ResponseUtils.generateJavaScriptLog(
          writer,
          RBUtil.getInstance(useCaseConf.getLocale())
              .getProperty(Keys.I18N_ISICRESSRV_QRY_ABORT_CAUSE_INVALID_TEXT));

      writer.write(ACTIVATE_SEVERAL_ADVSEARCH);

      writer.write("</HEAD><BODY tabIndex=-1></BODY></HTML>");
    }
  }
Exemplo n.º 6
0
  private void doWork(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    response.setDateHeader("Expires", 0);
    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("Pragma", "no-cache");
    response.setContentType("text/html; charset=UTF-8");

    // Tipo de usuarios (1 departamento; 2 Grupo; 3 Ususario).
    Integer userType =
        RequestUtils.parseRequestParameterAsInteger(request, "oSelectUsersType", new Integer(0));
    // Identificador de usuario.
    Integer userId =
        RequestUtils.parseRequestParameterAsInteger(
            request, "oSelectDeptGroupUser", new Integer(0));
    // Cadena con el id de usuario al que se distribuye y su mensaje asociado.
    String messageForUser = RequestUtils.parseRequestParameterAsString(request, "oMensaje");
    // Registros seleccionados de la lista.
    String ids = RequestUtils.parseRequestParameterAsString(request, "List");
    // Obtenemos la sesión asociada al usuario.
    HttpSession session = request.getSession();
    // Recuperamos el id de libro
    Integer bookID = (Integer) session.getAttribute(Keys.J_BOOK);
    // Texto del idioma. Ej: EU_
    String idioma = (String) session.getAttribute(Keys.J_IDIOMA);
    // Número del idioma. Ej: 10
    Long numIdioma = (Long) session.getAttribute(Keys.J_NUM_IDIOMA);
    // Obtenemos el objeto de configuración del servidor de aplicaciones y
    // el identificador
    // de sesión para este usuario en el servidor de aplicaciones.
    UseCaseConf useCaseConf = (UseCaseConf) session.getAttribute(J_USECASECONF);
    PrintWriter writer = response.getWriter();
    String resp = null;
    try {
      List listIdsRegister = parseList(ids);
      if (_logger.isDebugEnabled()) {
        for (Iterator it = listIdsRegister.iterator(); it.hasNext(); ) {
          _logger.debug("===================> listIdsRegister " + it.next());
        }
        _logger.debug("===================> messageForUser " + messageForUser);
        _logger.debug("===================> userType " + userType);
        _logger.debug("===================> userId " + userId);
      }
      resp =
          distributionUseCase.createDistribution(
              useCaseConf, bookID, listIdsRegister, userType, userId, messageForUser);
      if (_logger.isDebugEnabled()) {
        _logger.debug("===================> resp " + resp);
      }
      Map resps = parseResp(resp);
      String respNoDistributed = null;
      String respDistributed = null;
      if (resps.containsKey("ND")) {
        respNoDistributed = (String) resps.get("ND");
        respNoDistributed = respNoDistributed.substring(0, respNoDistributed.length() - 1);
      }
      if (resps.containsKey("SD")) {
        respDistributed = (String) resps.get("SD");
      }
      ResponseUtils.generateJavaScriptLogDtrDist(
          writer,
          respNoDistributed,
          respDistributed,
          RBUtil.getInstance(useCaseConf.getLocale()).getProperty(Keys.I18N_DTREX_CREATE_SATISFY));
    } catch (ValidationException e) {
      _logger.fatal("Error de validacion", e);
      ResponseUtils.generateJavaScriptLog(
          writer,
          RBUtil.getInstance(useCaseConf.getLocale())
              .getProperty(Keys.I18N_EXCEPTION_VALIDATIONEXCEPTION));
    } catch (DistributionException e) {
      _logger.fatal("Error en la distribucion", e);
      ResponseUtils.generateJavaScriptError(writer, e);
    } catch (BookException e) {
      _logger.fatal("Error en el libro", e);
      ResponseUtils.generateJavaScriptError(writer, e);
    } catch (EventException e) {
      _logger.fatal("Error en el evento", e);
      ResponseUtils.generateJavaScriptError(writer, e);
    } catch (SessionException e) {
      _logger.fatal("Error en la sesion", e);
      ResponseUtils.generateJavaScriptErrorSessionExpired(writer, e, idioma, numIdioma);
    } catch (Exception e) {
      _logger.fatal("Error en distribucion", e);
      ResponseUtils.generateJavaScriptLog(
          writer,
          RBUtil.getInstance(useCaseConf.getLocale())
              .getProperty(Keys.I18N_ISICRESSRV_ERR_CREATING_DTR_OBJ));
    }
  }