Example #1
0
  public static GeopistaMap getMapISO88591(String FileName) throws Exception {
    File file = new File(FileName);
    String basePath = file.getParent();
    GeopistaMap sourceMap = null;
    try {

      InputStream is = new FileInputStream(file);

      String stringReader = FileUtil.parseISO88591(is);

      XML2Java converter = new XML2Java();
      converter.addCustomConverter(
          Date.class, GeopistaMapCustomConverter.getMapDateCustomConverter());

      sourceMap = (GeopistaMap) converter.read(stringReader, com.geopista.model.GeopistaMap.class);
      sourceMap.setBasePath(basePath);
    } catch (Exception e) {
      if (logger.isDebugEnabled()) {
        logger.debug(
            "getMap(String) - El fichero "
                + FileName
                + "no se puede leer. "
                + e.getLocalizedMessage());
      }
      throw e;
    }

    return sourceMap;
  }
Example #2
0
  public static GeopistaMap getResumeMap(String FileName) throws Exception {

    File file = new File(FileName);
    String basePath = file.getParent();
    String name = file.getName();

    String upperName = name.toUpperCase();
    String[] lstName = upperName.split(".DXF");
    upperName = lstName[0];
    GeopistaMap sourceMap = new GeopistaMap();

    sourceMap.setBasePath(basePath);
    sourceMap.setDescription(upperName);

    sourceMap.setName(name);

    return sourceMap;
  }
Example #3
0
  public static void main(String args[]) throws Exception {
    StringWriter stringWriter = new StringWriter();
    GeopistaMap map = new GeopistaMap();
    map.setName("Prueba");
    map.setExtracted(true);
    map.setTimeStamp(new Date());
    try {
      Java2XML converter = new Java2XML();
      converter.addCustomConverter(
          Date.class, GeopistaMapCustomConverter.getMapDateCustomConverter());

      converter.write(map, "GEOPISTAMap", stringWriter);
    } finally {
      stringWriter.flush();
    }
    if (logger.isDebugEnabled()) {
      logger.debug("main(String)" + stringWriter.toString());
    }
  }
  private void btnEliminar_actionPerformed(ActionEvent e) {

    GeopistaMap selectMap = (GeopistaMap) lstListaMapas.getSelectedValue();

    if (selectMap != null) {

      int deleteMapConfirm =
          JOptionPane.showConfirmDialog(
              aplicacion.getMainFrame(),
              aplicacion.getI18nString("GeopistaListaMapasPanel.ConfimarBorradoMapa")
                  + " "
                  + selectMap.getName()
                  + "?",
              aplicacion.getI18nString("GeopistaListaMapasPanel.BorrarMapa"),
              JOptionPane.YES_NO_OPTION);
      if (deleteMapConfirm != 0) return;

      String mapDeleteSelected = selectMap.getBasePath();

      if (!selectMap.isSystemMap()) {
        File dirBaseMake = new File(mapDeleteSelected);

        File[] deleteFiles = dirBaseMake.listFiles();
        if (deleteFiles != null) {
          for (int n = 0; n < deleteFiles.length; n++) {
            try {
              File actualDeleteFile = deleteFiles[n];
              boolean borrado = actualDeleteFile.delete();
              if (!borrado)
                throw new IOException(
                    aplicacion.getI18nString("GeopistaListaMapasPanel.ElMapaInicioErrorBorrado")
                        + " "
                        + selectMap.getName()
                        + " "
                        + aplicacion.getI18nString("GeopistaListaMapasPanel.NoBorrado"));

              if (dirBaseMake != null) {
                borrado = dirBaseMake.delete();
              }

            } catch (Exception e1) {
              JOptionPane.showMessageDialog(aplicacion.getMainFrame(), e1.getMessage());
            }
          }
        }

      } else {
        if (selectMap.getIdEntidad() == 0) {
          deleteMapConfirm =
              JOptionPane.showConfirmDialog(
                  aplicacion.getMainFrame(),
                  aplicacion.getI18nString("GeopistaListaMapasPanel.ConfimarBorradoMapaEntidad0")
                      + " "
                      + selectMap.getName()
                      + "?",
                  aplicacion.getI18nString("GeopistaListaMapasPanel.BorrarMapa"),
                  JOptionPane.YES_NO_OPTION);
          if (deleteMapConfirm != 0) return;
        }

        String sUrlPrefix;
        // ------NUEVO------>
        if (SSOAuthManager.isSSOActive())
          sUrlPrefix = aplicacion.getString(SSOConstants.SSO_SERVER_URL);
        else sUrlPrefix = aplicacion.getString("geopista.conexion.servidor");
        // ----FIN NUEVO---->
        AdministradorCartografiaClient administradorCartografiaClient =
            new AdministradorCartografiaClient(sUrlPrefix + "/AdministradorCartografiaServlet");
        try {
          if (!aplicacion.isLogged()) {
            aplicacion.setProfile("Geopista");
            aplicacion.login();
          }

          if (aplicacion.isLogged()) {
            administradorCartografiaClient.deleteMap(selectMap, Locale.getDefault().toString());

          } else {
            return;
          }
        } catch (Exception e1) {

          Throwable deleteError = e1.getCause();
          if (deleteError instanceof PermissionException) {
            JOptionPane.showMessageDialog(
                aplicacion.getMainFrame(),
                aplicacion.getI18nString("GeopistaListaMapasPanel.NoPermisosBorrarMapa"));
          }
          if (deleteError instanceof SystemMapException) {
            JOptionPane.showMessageDialog(
                aplicacion.getMainFrame(),
                aplicacion.getI18nString("GeopistaListaMapasPanel.MapaDeSistemaNoBorrar"));
          }
          if (deleteError instanceof SQLException) {
            JOptionPane.showMessageDialog(
                aplicacion.getMainFrame(),
                aplicacion.getI18nString("GeopistaListaMapasPanel.MapaNoSePuedeBorrarPublicado"));
          }
          if (deleteError instanceof PublishedMapException) {
            JOptionPane.showMessageDialog(
                aplicacion.getMainFrame(),
                aplicacion.getI18nString("GeopistaListaMapasPanel.MapaNoSePuedeBorrarPublicado"));
          }
          return;
        }
      }
      listModel.removeElement(selectMap);
    }
  }