Revision 7513 branches/v10/frameworks/_fwAndami/src/com/iver/andami/Launcher.java

View differences:

Launcher.java
64 64
import java.net.MalformedURLException;
65 65
import java.net.URL;
66 66
import java.net.URLConnection;
67
import java.security.AllPermission;
68
import java.security.CodeSource;
69
import java.security.PermissionCollection;
70
import java.security.Permissions;
71
import java.security.Policy;
67 72
import java.util.ArrayList;
68 73
import java.util.Comparator;
69 74
import java.util.Date;
......
211 216
		// de plugin services para quien lo quiera usar (por ejemplo, para
212 217
		// cargar un proyecto por l?nea de comandos)
213 218
		PluginServices.setArguments(args);
214
		
219

  
215 220
		configureLocales(args);
216
		
221

  
217 222
		//Se pone el lookAndFeel
218 223
		try {
219 224
			String lookAndFeel = getAndamiConfig().getLookAndFeel();
......
224 229
			logger.warn(Messages.getString("Launcher.look_and_feel"), e);
225 230
		}
226 231

  
232

  
233
		// Solucionamos el problema de permisos que se produc?a con Java Web Start con este c?digo.
234
		// System.setSecurityManager(null);
235
	     Policy.setPolicy(new Policy() {
236
	     public PermissionCollection getPermissions(CodeSource codesource) {
237
	              Permissions perms = new Permissions();
238
	              perms.add(new AllPermission());
239
	              return (perms);
240
	     }
241
	     public void
242
		 	refresh() {}
243
	     });
244

  
245

  
227 246
		// Mostrar la ventana de inicio
228 247
		splashWindow = new SplashWindow(null);
229 248

  
......
1449 1468

  
1450 1469
					if (lastMiliSeconds.longValue() == miliSecondsInWeb.longValue()) {
1451 1470
						System.out.println("No hay nueva actualizaci?n");
1471
                        logger.debug("No hay nueva actualizaci?n -> Return");
1472
                        logger.debug("timeStampWeb= " + miliSecondsInWeb);
1473
                        logger.debug("timeStampLocal= " + lastMiliSeconds);
1452 1474

  
1453 1475
						return;
1454 1476
					}
......
1460 1482
						timeFile.getAbsolutePath());
1461 1483
				}
1462 1484

  
1463
				InputStream stream = connection.getInputStream();
1464
				File temp = File.createTempFile("gvsig", ".zip");
1465
				temp.deleteOnExit();
1485
				InputStream stream = url.openStream();
1486
                File temp = File.createTempFile("gvsig", ".zip");
1466 1487

  
1467
				FileOutputStream file = new FileOutputStream(temp);
1468
				BufferedInputStream in = new BufferedInputStream(stream);
1469
				BufferedOutputStream out = new BufferedOutputStream(file);
1488
                logger.debug(temp.getAbsolutePath());
1470 1489

  
1471
				int i;
1472
				int pct;
1473
				int desde;
1474
				int hasta;
1490
                temp.deleteOnExit();
1491
                FileOutputStream file = new FileOutputStream(temp);
1475 1492

  
1476
				hasta = connection.getContentLength() / 1024;
1477
				desde = 0;
1493
                byte[] lt_read = new byte[1];
1478 1494

  
1479
				while ((i = in.read()) != -1) {
1480
					pct = ((desde / 1024) * 100) / hasta;
1495
                while (stream.read(lt_read) > 0)
1496
                  file.write(lt_read);
1481 1497

  
1482
					if (((desde % 10240) == 0) && (pct > 10) &&
1483
							((pct % 10) == 0)) {
1484
						SplashWindow.process(pct,
1485
							(desde / 1024) + "Kb de " + hasta +
1486
							"Kb descargados...");
1487
					}
1498
                stream.close();
1499
                stream = null;
1500
                file.close();
1501
                file = null;
1488 1502

  
1489
					out.write(i);
1490
					desde++;
1491
				}
1503
                System.gc();
1492 1504

  
1493
				out.flush();
1494
				out.close();
1495
				in.close();
1496

  
1505
                logger.debug("Ha creado el fichero ZIP");
1497 1506
				//Se extrae el zip
1498 1507
				SplashWindow.process(5, "Extensiones descargadas.");
1499 1508

  
......
1906 1915
	 * provided language code (which may be an ISO 839-2/T
1907 1916
	 * three-characters-long code or an ISO 839-1 two-characters-long
1908 1917
	 * code).
1909
	 * 
1918
	 *
1910 1919
	 * If the provided parameter is already two characters long, it
1911 1920
	 * returns the parameter without any modification.
1912
	 * 
1921
	 *
1913 1922
	 * @param langCode A language code representing either
1914 1923
	 *  an ISO 839-2/T language code or an ISO 839-1 code.
1915 1924
	 * @return A two-characters-long code specifying
......
1948 1957
		}
1949 1958
		return "es";
1950 1959
	}
1951
	
1960

  
1952 1961
	/**
1953 1962
	 * Configures the locales (languages and local resources) to be used
1954 1963
	 * by the application.
1955
	 * 
1964
	 *
1956 1965
	 * First it tries to get the locale from the command line parameters,
1957 1966
	 * then the andami-config file is checked.
1958
	 * 
1967
	 *
1959 1968
	 * The locale name is normalized to get a two characters language code
1960 1969
	 * as defined by ISO-639-1 (although ISO-639-2/T three characters codes
1961 1970
	 * are also accepted from the command line or the configuration file).
1962
	 * 
1971
	 *
1963 1972
	 * Finally, the gvsig-i18n library and the default locales for Java and
1964 1973
	 * Swing are configured.
1965 1974
	 *

Also available in: Unified diff