Revision 1225
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.186/README.txt | ||
---|---|---|
1 |
=============== |
|
2 |
gvSIG Educa |
|
3 |
=============== |
|
4 |
|
|
5 |
--------------------- |
|
6 |
Portable View |
|
7 |
--------------------- |
|
8 |
|
|
9 |
Description |
|
10 |
============== |
|
11 |
|
|
12 |
This folder contains the sources of the Portable View functionality. |
|
13 |
|
|
14 |
Requirements |
|
15 |
============== |
|
16 |
|
|
17 |
* Maven 2.6 or higher |
|
18 |
|
|
19 |
* Java JDK 1.5 or higher |
|
20 |
|
|
21 |
For eclipse |
|
22 |
------------- |
|
23 |
|
|
24 |
See `developer guide at gvSIG.org <http://www.gvsig.org/plone/projects/gvsig-desktop/docs/devel/gvsig-devel-guide/2-1-0/introduccion>`_ and the file ``REAME-ECLIPSE.txt`` |
|
25 |
|
|
26 |
|
|
27 |
Contents |
|
28 |
========== |
|
29 |
|
|
30 |
org.gvsig.educa.portableview.lib |
|
31 |
--------------------------------- |
|
32 |
|
|
33 |
Functionality sources. This project just contain the main process and the logic without any dependency with User Interface. |
|
34 |
|
|
35 |
org.gvsig.educa.portableview.swing |
|
36 |
------------------------------------- |
|
37 |
|
|
38 |
User Interface components to access a manage the application services. |
|
39 |
|
|
40 |
org.gvsig.educa.portableview.main |
|
41 |
----------------------------------- |
|
42 |
|
|
43 |
Little test application which allow run the main functionality of application. |
|
44 |
|
|
45 |
See `Execute little test application`_ to know how run it. |
|
46 |
|
|
47 |
pom.xml |
|
48 |
--------- |
|
49 |
|
|
50 |
Maven project definition file |
|
51 |
|
|
52 |
README.rst |
|
53 |
-------------- |
|
54 |
|
|
55 |
This file (in reStructureText format, for more info this format look at `gvSIG portal <https://gvsig.org/web/projects/gvsig-desktop/docs/devel/guia-para-documentar/el-formato-restructuredtext>`_ or at `docUtils reference <http://docutils.sourceforge.net/rst.html>`_) |
|
56 |
|
|
57 |
|
|
58 |
Compilation |
|
59 |
================ |
|
60 |
|
|
61 |
From shell |
|
62 |
------------ |
|
63 |
|
|
64 |
Execute this command:: |
|
65 |
|
|
66 |
org.gvsig.educa.portableview$ mvn clean install |
|
67 |
|
|
68 |
|
|
69 |
From eclipse |
|
70 |
-------------- |
|
71 |
|
|
72 |
See `work in a proyect of the developer guide at gvSIG.org <https://gvsig.org/web/projects/gvsig-desktop/docs/devel/gvsig-devel-guide/2.0.0/trabajar-con-un-proyecto>`_ |
|
73 |
|
|
74 |
In some project, could be better use ``mvn eclipse:clean eclipse:eclipse`` than import project as a *Maven project*. Maven plugin of eclipse does not set classpath correctly in some project. |
|
75 |
|
|
76 |
|
|
77 |
Packing |
|
78 |
======== |
|
79 |
|
|
80 |
This functionality has no stand-alone packing process. |
|
81 |
|
|
82 |
Version |
|
83 |
--------------- |
|
84 |
|
|
85 |
To changes version number just set in in ``project/version`` tag of *pom.xml* in this folder. Sub-projects will inherit it. |
|
86 |
|
|
87 |
Version polity is the standard in project. Changes in version number: |
|
88 |
|
|
89 |
* third number: Bug fixes and minors improvements. API must have no changes from previous version. |
|
90 |
* second number: Bug fixes and mayor improvements. API can have minor changes. Previously deprecated classes could be removed. No architectural changes. |
|
91 |
* first number: Mayor changes. |
|
92 |
|
|
93 |
Create a tag |
|
94 |
------------------ |
|
95 |
|
|
96 |
TODO: use *maven release* plugin |
|
97 |
|
|
98 |
Use svn copy command to copy version in server. Process could be like this: |
|
99 |
|
|
100 |
|
|
101 |
#. Check that there ins no changes in workspace:: |
|
102 |
|
|
103 |
svn up ; svn status |
|
104 |
|
|
105 |
#. Check that project compiles and passes all test. |
|
106 |
|
|
107 |
mvn clean install |
|
108 |
|
|
109 |
#. Update *pom.xml* to set version of tag (usually removing *-SNAPSHOT*) |
|
110 |
#. create tag folder on server:: |
|
111 |
|
|
112 |
svn mkdir -m "Create {version} tag folder" https://devel.gvsig.org/svn/gvsig-educa/org.gvsig.educa.portablewview/tags/{version} |
|
113 |
|
|
114 |
#. Copy current workcopy to tag folder:: |
|
115 |
|
|
116 |
svn copy -m "Create {version} tag" * https://devel.gvsig.org/svn/gvsig-educa/org.gvsig.educa.portablewview/tags/{version} |
|
117 |
|
|
118 |
#. Update *pom.xml* to next version |
|
119 |
#. Commit *pom.xml* changes:: |
|
120 |
|
|
121 |
svn commit -m "Set new version {version}-SNAPSHOT" pom.xml |
|
122 |
|
|
123 |
|
|
124 |
i18n |
|
125 |
====== |
|
126 |
|
|
127 |
The files for internationalization can be found in this folders: |
|
128 |
|
|
129 |
+ *org.gvsig.educa.portablewview.app.viewer/src/main/resources-plugin* |
|
130 |
+ *org.gvsig.educa.portablewview.app.editor/src/main/resources-plugin* |
|
131 |
|
|
132 |
The internationalization of this application is based on standard java resource bundle mechanism. So, to add a new language just add the file with the language code to every related folder. |
|
133 |
|
|
134 |
Execute little test application |
|
135 |
================================= |
|
136 |
|
|
137 |
From shell |
|
138 |
------------ |
|
139 |
|
|
140 |
After compile the application, execute this command:: |
|
141 |
|
|
142 |
org.gvsig.educa.portablewview$ cd org.gvsig.educa.thematicmap.main |
|
143 |
org.gvsig.educa.portablewview/org.gvsig.educa.portablewview.main$ mvn exec:java |
|
144 |
|
|
145 |
Form eclipse |
|
146 |
------------------ |
|
147 |
|
|
148 |
Select ``org.gvsig.educa.portableview.main`` project in *Project tree* using *Java perspective*, click with right mouse button and select ``Run as.../Java application``. Select ``Main`` class for project. |
|
149 |
|
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.186/org.gvsig.educa.portableview.lib/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
3 |
|
|
4 |
<modelVersion>4.0.0</modelVersion> |
|
5 |
<artifactId>org.gvsig.educa.portableview.lib</artifactId> |
|
6 |
<packaging>pom</packaging> |
|
7 |
<name>org.gvsig.educa.portableview.lib</name> |
|
8 |
<parent> |
|
9 |
<groupId>org.gvsig</groupId> |
|
10 |
<artifactId>org.gvsig.educa.portableview</artifactId> |
|
11 |
<version>1.0.186</version> |
|
12 |
</parent> |
|
13 |
<modules> |
|
14 |
<module>org.gvsig.educa.portableview.lib.api</module> |
|
15 |
<module>org.gvsig.educa.portableview.lib.impl</module> |
|
16 |
<module>org.gvsig.educa.portableview.lib.prov.installer</module> |
|
17 |
</modules> |
|
18 |
</project> |
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.186/org.gvsig.educa.portableview.lib/org.gvsig.educa.portableview.lib.impl/src/test/resources/README.txt | ||
---|---|---|
1 |
==== |
|
2 |
gvSIG. Desktop Geographic Information System. |
|
3 |
|
|
4 |
Copyright (C) 2007-2012 gvSIG Association. |
|
5 |
|
|
6 |
This program is free software; you can redistribute it and/or |
|
7 |
modify it under the terms of the GNU General Public License |
|
8 |
as published by the Free Software Foundation; either version 2 |
|
9 |
of the License, or (at your option) any later version. |
|
10 |
|
|
11 |
This program is distributed in the hope that it will be useful, |
|
12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
GNU General Public License for more details. |
|
15 |
|
|
16 |
You should have received a copy of the GNU General Public License |
|
17 |
along with this program; if not, write to the Free Software |
|
18 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
MA 02110-1301, USA. |
|
20 |
|
|
21 |
For any additional information, do not hesitate to contact us |
|
22 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
==== |
|
24 |
|
|
25 |
Put into this folder the resources needed by your test classes. |
|
26 |
|
|
27 |
This folder is added to the Tests classpath, so you can load any resources |
|
28 |
through the ClassLoader. |
|
29 |
|
|
30 |
By default, in this folder you can find an example of log4j configuration, |
|
31 |
prepared to log messages through the console, so logging works when you |
|
32 |
run your tests classes. |
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.186/org.gvsig.educa.portableview.lib/org.gvsig.educa.portableview.lib.impl/src/test/resources/log4j.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1" ?> |
|
2 |
<!-- |
|
3 |
|
|
4 |
gvSIG. Desktop Geographic Information System. |
|
5 |
|
|
6 |
Copyright (C) 2007-2012 gvSIG Association. |
|
7 |
|
|
8 |
This program is free software; you can redistribute it and/or |
|
9 |
modify it under the terms of the GNU General Public License |
|
10 |
as published by the Free Software Foundation; either version 2 |
|
11 |
of the License, or (at your option) any later version. |
|
12 |
|
|
13 |
This program is distributed in the hope that it will be useful, |
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
GNU General Public License for more details. |
|
17 |
|
|
18 |
You should have received a copy of the GNU General Public License |
|
19 |
along with this program; if not, write to the Free Software |
|
20 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
MA 02110-1301, USA. |
|
22 |
|
|
23 |
For any additional information, do not hesitate to contact us |
|
24 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
25 |
|
|
26 |
--> |
|
27 |
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> |
|
28 |
|
|
29 |
<!-- |
|
30 |
Log4J configuration file for unit tests execution. |
|
31 |
--> |
|
32 |
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> |
|
33 |
|
|
34 |
<!-- Appender configuration to show logging messages through the console --> |
|
35 |
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> |
|
36 |
<layout class="org.apache.log4j.PatternLayout"> |
|
37 |
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n %m%n" /> |
|
38 |
</layout> |
|
39 |
</appender> |
|
40 |
|
|
41 |
<!-- |
|
42 |
Activate logging messages of DEBUG level of higher only for the |
|
43 |
org.gvsig.tools packages. |
|
44 |
You can put full classes names or packages instead, to configure |
|
45 |
logging for all the classes and subpackages of the package. |
|
46 |
--> |
|
47 |
<category name="org.gvsig.tools"> |
|
48 |
<priority value="DEBUG" /> |
|
49 |
</category> |
|
50 |
<category name="org.gvsig.educa.portableview"> |
|
51 |
<priority value="DEBUG" /> |
|
52 |
</category> |
|
53 |
|
|
54 |
<!-- |
|
55 |
By default, show only logging messages of INFO level or higher, |
|
56 |
through the previously configured CONSOLE appender. |
|
57 |
--> |
|
58 |
<root> |
|
59 |
<priority value="DEBUG" /> |
|
60 |
<appender-ref ref="CONSOLE" /> |
|
61 |
</root> |
|
62 |
</log4j:configuration> |
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.186/org.gvsig.educa.portableview.lib/org.gvsig.educa.portableview.lib.impl/src/main/resources/org/gvsig/educa/portableview/impl/i18n/text_pt_BR.properties | ||
---|---|---|
1 |
#text_pt_br.properties |
|
2 |
_CantLoadContextException=Problemas ao carregar o arquivo de MapContext |
|
3 |
_CompilationException=Problemas ao compilar mapa tem\u00E1tico |
|
4 |
_InvalidInstalledPortableViewException=Formato inv\u00E1lido para um PortableView instalado |
|
5 |
_InvalidPortableViewFormatException=Formato inv\u00E1lido para um arquivo de PortableView |
|
6 |
buildNumber=Vers\u00E3o de compila\u00E7\u00E3o |
|
7 |
cleaning_work_folder=Apagando o diret\u00F3rio de trabalho |
|
8 |
compilation_not_valid=Compila\u00E7\u00E3o inv\u00E1lida |
|
9 |
compiling_portable_view=Compilando mapa tem\u00E1tico |
|
10 |
coping_all_layers_files=Copiando todos os arquivos relacionados \u00E0s camadas |
|
11 |
creating_work_folder=Criando diret\u00F3rio de trabalho |
|
12 |
creationTimestamp=Data de cria\u00E7\u00E3o |
|
13 |
generating_base_name=Gerando nome b\u00E1sico para o arquivo |
|
14 |
generating_target_file=Gerando arquivo do mapa tem\u00E1tico |
|
15 |
generating_target_filename=Gerando nome do arquivo para o mapa tem\u00E1tico |
|
16 |
id=Identificador |
|
17 |
missing_id_value=Informar o identificador |
|
18 |
missing_name_value=Informar o nome |
|
19 |
name=Nome |
|
20 |
preparing_new_map_context=Preparando novo esquema de mapa |
|
21 |
Portable_View=Mapa tem\u00E1tico |
|
22 |
Portable_View_Compilation=Compila\u00E7\u00E3o do mapa tem\u00E1tico |
|
23 |
portable_view_description=Descri\u00E7\u00E3o do mapa tem\u00E1tico |
|
24 |
portable_view_id=Identificador do mapa tem\u00E1tico |
|
25 |
portable_view_information=Informa\u00E7\u00E3o do mapa tem\u00E1tico |
|
26 |
portable_view_layers=Camadas do mapa tem\u00E1tico |
|
27 |
portable_view_name=Nome do mapa tem\u00E1tico |
|
28 |
portable_view_validation=Valida\u00E7\u00E3o do mapa tem\u00E1tico |
|
29 |
portable_view_version=Vers\u00E3o do mapa tem\u00E1tico |
|
30 |
updateing_compilation_info=Atualizando dados da compila\u00E7\u00E3o |
|
31 |
version=Vers\u00E3o |
|
32 |
writing_graphics_layer=Salvando a camada de gr\u00E1ficos |
|
33 |
writing_map_information_data=Salvando informa\u00E7\u00F5es sobre o mapa tem\u00E1tico |
|
34 |
writing_mapcontext_definition=Salvando o esquema do mapa tem\u00E1tico |
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.186/org.gvsig.educa.portableview.lib/org.gvsig.educa.portableview.lib.impl/src/main/resources/org/gvsig/educa/portableview/impl/i18n/text_ru.properties | ||
---|---|---|
1 |
#text_ru.properties |
|
2 |
_CantLoadContextException=\u041E\u0448\u0438\u0431\u043A\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043A\u0438 \u0444\u0430\u0439\u043B\u0430 MapContext [%(mapContextPath)] \u0434\u043B\u044F \u0444\u0430\u0439\u043B\u0430 PortableView [%(mapPath)]\: %(info) |
|
3 |
_CompilationException=\u041F\u0440\u043E\u0438\u0437\u043E\u0448\u043B\u0430 \u043E\u0448\u0438\u0431\u043A\u0430 \u0432\u043E \u0432\u0440\u0435\u043C\u044F \u043A\u043E\u043C\u043F\u0438\u043B\u044F\u0446\u0438\u0438 \u0422\u0435\u043C\u0430\u0442\u0438\u0447\u0435\u0441\u043A\u043E\u0439 \u043A\u0430\u0440\u0442\u044B [%(portableViewId)]\: %(info) |
|
4 |
_InvalidInstalledPortableViewException=\u0423\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D\u043D\u0430\u044F \u0422\u0435\u043C\u0430\u0442\u0438\u0447\u0435\u0441\u043A\u0430\u044F \u043A\u0430\u0440\u0442\u0430 \u0438\u043C\u0435\u0435\u0442 \u043D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442 [%(filePath)]\: %(info) |
|
5 |
_InvalidPortableViewFormatException=\u0424\u0430\u0439\u043B PortableView \u0438\u043C\u0435\u0435\u0442 \u043D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442 [%(filePath)]\: %(info) |
|
6 |
buildNumber=\u041D\u043E\u043C\u0435\u0440 \u0441\u0431\u043E\u0440\u043A\u0438 |
|
7 |
cleaning_work_folder=\u041E\u0447\u0438\u0441\u0442\u043A\u0430 \u0440\u0430\u0431\u043E\u0447\u0435\u0433\u043E \u043A\u0430\u0442\u0430\u043B\u043E\u0433\u0430 |
|
8 |
compilation_not_valid=\u041A\u043E\u043C\u043F\u0438\u043B\u044F\u0446\u0438\u044F \u043D\u0435 \u0432\u044B\u043F\u043E\u043B\u043D\u0435\u043D\u0430 |
|
9 |
compiling_portable_view=\u0412\u044B\u043F\u043E\u043B\u043D\u044F\u0435\u0442\u0441\u044F \u043A\u043E\u043C\u043F\u0438\u043B\u044F\u0446\u0438\u044F \u0422\u0435\u043C\u0430\u0442\u0438\u0447\u0435\u0441\u043A\u043E\u0439 \u043A\u0430\u0440\u0442\u044B |
|
10 |
coping_all_layers_files=\u041A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435 \u0432\u0441\u0435\u0445 \u0444\u0430\u0439\u043B\u043E\u0432 \u0441\u043B\u043E\u0435\u0432 |
|
11 |
creating_work_folder=\u0421\u043E\u0437\u0434\u0430\u043D\u0438\u0435 \u0440\u0430\u0431\u043E\u0447\u0435\u0439 \u043F\u0430\u043F\u043A\u0438 |
|
12 |
creationTimestamp=\u0414\u0430\u0442\u0430 \u0441\u043E\u0437\u0434\u0430\u043D\u0438\u044F |
|
13 |
generating_base_name=\u0421\u043E\u0437\u0434\u0430\u043D\u0438\u0435 \u0431\u0430\u0437\u043E\u0432\u043E\u0433\u043E \u0438\u043C\u0435\u043D\u0438 \u0444\u0430\u0439\u043B\u0430 |
|
14 |
generating_target_file=\u0421\u043E\u0437\u0434\u0430\u043D\u0438\u0435 \u0444\u0430\u0439\u043B\u0430 \u0422\u0435\u043C\u0430\u0442\u0438\u0447\u0435\u0441\u043A\u043E\u0439 \u043A\u0430\u0440\u0442\u044B |
|
15 |
generating_target_filename=\u0421\u043E\u0437\u0434\u0430\u043D\u0438\u0435 \u0438\u043C\u0435\u043D\u0438 \u0444\u0430\u0439\u043B\u0430 \u0422\u0435\u043C\u0430\u0442\u0438\u0447\u0435\u0441\u043A\u043E\u0439 \u043A\u0430\u0440\u0442\u044B |
|
16 |
id=\u0418\u0434\u0435\u043D\u0442\u0438\u0444\u0438\u043A\u0430\u0442\u043E\u0440 |
|
17 |
missing_id_value=\u041E\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0438\u0434\u0435\u043D\u0442\u0438\u0444\u0438\u043A\u0430\u0442\u043E\u0440\u0430 |
|
18 |
missing_name_value=\u041E\u0442\u0441\u0442\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0438\u043C\u0435\u043D\u0438 |
|
19 |
name=\u0418\u043C\u044F |
|
20 |
preparing_new_map_context=\u041F\u043E\u0434\u0433\u043E\u0442\u043E\u0432\u043A\u0430 \u043D\u043E\u0432\u043E\u0439 \u0441\u0445\u0435\u043C\u044B \u0434\u043B\u044F \u043A\u0430\u0440\u0442\u044B |
|
21 |
Portable_View=\u0422\u0435\u043C\u0430\u0442\u0438\u0447\u0435\u0441\u043A\u0430\u044F \u043A\u0430\u0440\u0442\u0430 |
|
22 |
Portable_View_Compilation=\u041A\u043E\u043C\u043F\u0438\u043B\u044F\u0446\u0438\u044F \u0422\u0435\u043C\u0430\u0442\u0438\u0447\u0435\u0441\u043A\u043E\u0439 \u043A\u0430\u0440\u0442\u044B |
|
23 |
portable_view_description=\u041E\u043F\u0438\u0441\u0430\u043D\u0438\u0435 |
|
24 |
portable_view_id=\u0418\u0434\u0435\u043D\u0442\u0438\u0444\u0438\u043A\u0430\u0442\u043E\u0440 |
|
25 |
portable_view_information=\u0418\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u044F |
|
26 |
portable_view_layers=\u0421\u043B\u043E\u0438 \u0422\u0435\u043C\u0430\u0442\u0438\u0447\u0435\u0441\u043A\u043E\u0439 \u043A\u0430\u0440\u0442\u044B |
|
27 |
portable_view_name=\u0418\u043C\u044F |
|
28 |
portable_view_validation=\u041F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 \u0422\u0435\u043C\u0430\u0442\u0438\u0447\u0435\u0441\u043A\u043E\u0439 \u043A\u0430\u0440\u0442\u044B |
|
29 |
portable_view_version=\u0412\u0435\u0440\u0441\u0438\u044F |
|
30 |
updateing_compilation_info=\u041E\u0431\u043D\u043E\u0432\u043B\u0435\u043D\u0438\u0435 \u0438\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u0438 \u043A\u043E\u043C\u043F\u0438\u043B\u044F\u0446\u0438\u0438 |
|
31 |
version=\u0412\u0435\u0440\u0441\u0438\u044F |
|
32 |
writing_graphics_layer=\u0421\u043E\u0437\u0440\u0430\u043D\u0435\u043D\u0438\u0435 \u0441\u043B\u043E\u044F \u0433\u0440\u0430\u0444\u0438\u043A\u0438 |
|
33 |
writing_map_information_data=\u0421\u043E\u0445\u0440\u0430\u043D\u0435\u043D\u0438\u0435 \u0438\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u0438 \u0422\u0435\u043C\u0430\u0442\u0438\u0447\u0435\u0441\u043A\u043E\u0439 \u043A\u0430\u0440\u0442\u044B |
|
34 |
writing_mapcontext_definition=\u0421\u043E\u0437\u0440\u0430\u043D\u0435\u043D\u0438\u0435 \u0441\u0445\u0435\u043C\u044B \u043A\u0430\u0440\u0442\u044B |
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.186/org.gvsig.educa.portableview.lib/org.gvsig.educa.portableview.lib.impl/src/main/resources/org/gvsig/educa/portableview/impl/i18n/text_es.properties | ||
---|---|---|
1 |
#text_es.properties |
|
2 |
_CantLoadContextException=Problemas cargando el fichero de MapContext [%(mapContextPath)] del PortableView [%(mapPath)]\: %(info) |
|
3 |
_CompilationException=Se ha encontrado un problema al compilar la vista portable [%(portableViewId)]\: %(info) |
|
4 |
_InvalidInstalledPortableViewException=Formato inv\u00E1lido para el PortableView instalado [%(filePath)]\: %(info) |
|
5 |
_InvalidPortableViewFormatException=Formato inv\u00E1lido para fichero de PortableView [%(filePath)]\: %(info) |
|
6 |
buildNumber=Versi\u00F3n de compilaci\u00F3n |
|
7 |
cleaning_work_folder=Limpiando el directorio de trabajo |
|
8 |
compilation_not_valid=Compilaci\u00F3n no v\u00E1lida |
|
9 |
compiling_portable_view=Compilando vista portable |
|
10 |
coping_all_layers_files=Copiando todos los ficheros relacionados con las capas |
|
11 |
creating_work_folder=Creando el directorio de trabajo |
|
12 |
creationTimestamp=Fecha de creaci\u00F3n |
|
13 |
generating_base_name=Generando el nombre base para el fichero |
|
14 |
generating_target_file=Generando el fichero de la vista portable |
|
15 |
generating_target_filename=Generando nombre de fichero para la vista portable |
|
16 |
id=Identificador |
|
17 |
missing_id_value=Falta valor para el identificador |
|
18 |
missing_name_value=Falta valor para el nombre |
|
19 |
name=Nombre |
|
20 |
preparing_new_map_context=Preparando el nuevo esquema de mapa |
|
21 |
Portable_View=Vista portable |
|
22 |
Portable_View_Compilation=Compilaci\u00F3n de la vista portable |
|
23 |
portable_view_description=Descripci\u00F3n |
|
24 |
portable_view_id=Identificador |
|
25 |
portable_view_information=Informaci\u00F3n de la vista portable |
|
26 |
portable_view_layers=Capas de la vista portable |
|
27 |
portable_view_name=Nombre |
|
28 |
portable_view_validation=Validaci\u00F3n de la vista portable |
|
29 |
portable_view_version=Versi\u00F3n |
|
30 |
updateing_compilation_info=Actualizando datos de la compilaci\u00F3n |
|
31 |
version=Versi\u00F3n |
|
32 |
writing_graphics_layer=Guardando la capa de gr\u00E1ficos |
|
33 |
writing_map_information_data=Guardando informaci\u00F3n sobre la vista portable |
|
34 |
writing_mapcontext_definition=Guardando el esquema del mapa |
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.186/org.gvsig.educa.portableview.lib/org.gvsig.educa.portableview.lib.impl/src/main/resources/org/gvsig/educa/portableview/impl/i18n/text_de.properties | ||
---|---|---|
1 |
#text_de.properties |
|
2 |
_CantLoadContextException=Problem beim Laden der MapContext Datei [%(mapContextPath)] der Thematischen Karte [%(mapPath)]\: %(info) |
|
3 |
_CompilationException=Problem beim Kompilieren der Thematischen Karte |
|
4 |
_InvalidInstalledPortableViewException=Ung\u00FCltiges Format einer installierten Thematischen Karte\: [%(filePath)]\: %(info) |
|
5 |
_InvalidPortableViewFormatException=Ung\u00FCltiges Format einer Mapdatei zur Thematischen Karte\: [%(filePath)]\: %(info) |
|
6 |
buildNumber=Build-Version |
|
7 |
cleaning_work_folder=Arbeitsverzeichnis leeren |
|
8 |
compilation_not_valid=Kompilierung ung\u00FCltig |
|
9 |
compiling_portable_view=Thematische Karte kompilieren |
|
10 |
coping_all_layers_files=Alle zu Layern geh\u00F6renden Dateien kopieren |
|
11 |
creating_work_folder=Arbeitsverzeichnis erstellen |
|
12 |
creationTimestamp=Zeitstempel |
|
13 |
generating_base_name=Basis-Dateiname erstellen |
|
14 |
generating_target_file=Mapfile f\u00FCr Thematische Karte erstellen |
|
15 |
generating_target_filename=Name des Mapfiles der Thematischen Karte |
|
16 |
id=Id |
|
17 |
missing_id_value=Fehlende ID |
|
18 |
missing_name_value=Fehlende Bezeichnung |
|
19 |
name=Name |
|
20 |
preparing_new_map_context=Neuen Map Context vorbereiten |
|
21 |
Portable_View=Thematische Karte |
|
22 |
Portable_View_Compilation=Kompilierung der Thematischen Karte |
|
23 |
portable_view_description=Beschreibung |
|
24 |
portable_view_id=ID |
|
25 |
portable_view_information=Information |
|
26 |
portable_view_layers=Ebenen der Thematischen Karte |
|
27 |
portable_view_name=Name |
|
28 |
portable_view_validation=Validierung der Thematischen Karte |
|
29 |
portable_view_version=Version |
|
30 |
updateing_compilation_info=Kompilierungsinformationen aktualisieren |
|
31 |
version=Version |
|
32 |
writing_graphics_layer=Graphik-Layer schreiben |
|
33 |
writing_map_information_data=Informationen zur Thematischen Karte schreiben |
|
34 |
writing_mapcontext_definition=Map schema schreiben |
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.186/org.gvsig.educa.portableview.lib/org.gvsig.educa.portableview.lib.impl/src/main/resources/org/gvsig/educa/portableview/impl/i18n/text_it.properties | ||
---|---|---|
1 |
#text_it.properties |
|
2 |
_CantLoadContextException=Problemi nel caricamento del file di MapContext [%(mapContextPath)] del file di mappa tematica [%(mapPath)]\: %(info) |
|
3 |
_CompilationException=Problema nella compilazione della mappa tematica [%(portableViewId)]\: %(info) |
|
4 |
_InvalidInstalledPortableViewException=Formato non valido della mappa tematica installata [%(filePath)]\: %(info) |
|
5 |
_InvalidPortableViewFormatException=Formato non valido del file di mappa tematica [%(filePath)]\: %(info) |
|
6 |
buildNumber=Versione di compilazione |
|
7 |
cleaning_work_folder=Pulizia della cartella di lavoro |
|
8 |
compilation_not_valid=Compilazione non valida |
|
9 |
compiling_portable_view=Compilazione della mappa tematica |
|
10 |
coping_all_layers_files=Copia di tutti i file relativi ai layer |
|
11 |
creating_work_folder=Creazione della cartella di lavoro |
|
12 |
creationTimestamp=Data di creazione |
|
13 |
generating_base_name=Generazione del nome base per il file |
|
14 |
generating_target_file=Generazione del file della mappa tematica |
|
15 |
generating_target_filename=Generazione del nome del file di mappa tematica |
|
16 |
id=Identificatore |
|
17 |
missing_id_value=Identificatore mancante |
|
18 |
missing_name_value=Nome mancante |
|
19 |
name=Nome |
|
20 |
preparing_new_map_context=Preparazione di un nuovo schema di mappa |
|
21 |
Portable_View=Mappa tematica |
|
22 |
Portable_View_Compilation=Compilazione di una mappa tematica |
|
23 |
portable_view_description=Descrizione |
|
24 |
portable_view_id=Identificatore |
|
25 |
portable_view_information=Informazioni |
|
26 |
portable_view_layers=Layer della mappa tematica |
|
27 |
portable_view_name=Nome |
|
28 |
portable_view_validation=Validazione di mappa tematica |
|
29 |
portable_view_version=Versione |
|
30 |
updateing_compilation_info=Aggiornamento delle informazioni di compilazione |
|
31 |
version=Versione |
|
32 |
writing_graphics_layer=Salvataggio layer di grafici |
|
33 |
writing_map_information_data=Salvataggio delle informazioni della mappa tematica |
|
34 |
writing_mapcontext_definition=Salvataggio dello schema di mappa |
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.186/org.gvsig.educa.portableview.lib/org.gvsig.educa.portableview.lib.impl/src/main/resources/org/gvsig/educa/portableview/impl/i18n/text.properties | ||
---|---|---|
1 |
#text.properties |
|
2 |
_CantLoadContextException=Problemas cargando el fichero de MapContext [%(mapContextPath)] del PortableView [%(mapPath)]\: %(info) |
|
3 |
_CompilationException=Se ha encontrado un problema al compilar la vista portable [%(portableViewId)]\: %(info) |
|
4 |
_InvalidInstalledPortableViewException=Formato inv\u00E1lido para PortableView instalado [%(filePath)]\: %(info) |
|
5 |
_InvalidProtableViewFormatException=Formato inv\u00E1lido para fichero de PortableView [%(filePath)]\: %(info) |
|
6 |
buildNumber=Versi\u00F3n de compilaci\u00F3n |
|
7 |
cleaning_work_folder=Limpiando el directorio de trabajo |
|
8 |
compilation_not_valid=Compilaci\u00F3n no v\u00E1lida |
|
9 |
compiling_portable_view=Compilando vista portable |
|
10 |
coping_all_layers_files=Copiando todos los ficheros relacionados con las capas |
|
11 |
creating_work_folder=Creando el directorio de trabajo |
|
12 |
creationTimestamp=Fecha de creaci\u00F3n |
|
13 |
generating_base_name=Generando el nombre base para el fichero |
|
14 |
generating_target_file=Generando el fichero de la vista portable |
|
15 |
generating_target_filename=Generando nombre de fichero para la vista portable |
|
16 |
id=Identificador |
|
17 |
missing_id_value=Falta valor para el identificador |
|
18 |
missing_name_value=Falta valor para el nombre |
|
19 |
name=Nombre |
|
20 |
preparing_new_map_context=Preparando el nuevo esquema de mapa |
|
21 |
Portable_View=Vista portable |
|
22 |
Portable_View_Compilation=Compilaci\u00F3n de la vista portable |
|
23 |
portable_view_description=Descripci\u00F3n |
|
24 |
portable_view_id=Identificador |
|
25 |
portable_view_information=Informaci\u00F3n de la vista portable |
|
26 |
portable_view_layers=Capas de la vista portable |
|
27 |
portable_view_name=Nombre |
|
28 |
portable_view_validation=Validaci\u00F3n de la vista portable |
|
29 |
portable_view_version=Versi\u00F3n |
|
30 |
updateing_compilation_info=Actualizando datos de la compilaci\u00F3n |
|
31 |
version=Versi\u00F3n |
|
32 |
writing_graphics_layer=Guardando la capa de gr\u00E1ficos |
|
33 |
writing_map_information_data=Guardando informaci\u00F3n sobre la vista portable |
|
34 |
writing_mapcontext_definition=Guardando el esquema del mapa |
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.186/org.gvsig.educa.portableview.lib/org.gvsig.educa.portableview.lib.impl/src/main/resources/org/gvsig/educa/portableview/impl/i18n/text_en.properties | ||
---|---|---|
1 |
#text_en.properties |
|
2 |
_CantLoadContextException=Problem loading MapContext file [%(mapContextPath)] of a PortableView file [%(mapPath)]\: %(info) |
|
3 |
_CompilationException=Problem found compiling Portable view [%(portableViewId)]\: %(info) |
|
4 |
_InvalidInstalledPortableViewException=Invalid format of an installed PortableView [%(filePath)]\: %(info) |
|
5 |
_InvalidPortableViewFormatException=Invalid format of a PortableView file [%(filePath)]\: %(info) |
|
6 |
buildNumber=Build Number |
|
7 |
cleaning_work_folder=Cleaning work folder |
|
8 |
compilation_not_valid=Compilation not valid |
|
9 |
compiling_portable_view=Compiling Portable View |
|
10 |
coping_all_layers_files=Copying all files related to layers |
|
11 |
creating_work_folder=Creating work folder |
|
12 |
creationTimestamp=Creation date |
|
13 |
generating_base_name=Generating base file name |
|
14 |
generating_target_file=Generating Portable View file |
|
15 |
generating_target_filename=Generating Portable View file name |
|
16 |
id=Identifier |
|
17 |
missing_id_value=Missing identifier |
|
18 |
missing_name_value=Missing name |
|
19 |
name=Name |
|
20 |
preparing_new_map_context=Preparen new map schema |
|
21 |
Portable_View=Portable View |
|
22 |
Portable_View_Compilation=Portable view compilation |
|
23 |
portable_view_description=Description |
|
24 |
portable_view_id=Identifier |
|
25 |
portable_view_information=Information |
|
26 |
portable_view_layers=Portable View Layers |
|
27 |
portable_view_name=Name |
|
28 |
portable_view_validation=Portable View Validation |
|
29 |
portable_view_version=Version |
|
30 |
updateing_compilation_info=Updating compilation information |
|
31 |
version=Version |
|
32 |
writing_graphics_layer=Writing Graphics Layer |
|
33 |
writing_map_information_data=Writing Portable View information data |
|
34 |
writing_mapcontext_definition=Writing map schema |
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.186/org.gvsig.educa.portableview.lib/org.gvsig.educa.portableview.lib.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.educa.portableview.impl.PortableViewDefaultImplLibrary |
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.186/org.gvsig.educa.portableview.lib/org.gvsig.educa.portableview.lib.impl/src/main/java/org/gvsig/educa/portableview/impl/map/DefaultPortableView.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.educa.portableview.impl.map; |
|
23 |
|
|
24 |
import java.io.File; |
|
25 |
import java.io.IOException; |
|
26 |
|
|
27 |
import org.slf4j.Logger; |
|
28 |
import org.slf4j.LoggerFactory; |
|
29 |
import org.gvsig.educa.portableview.impl.MapResoucesManager; |
|
30 |
import org.gvsig.educa.portableview.map.CantLoadContextException; |
|
31 |
import org.gvsig.educa.portableview.map.InvalidPortableViewFormatException; |
|
32 |
import org.gvsig.educa.portableview.map.PortableView; |
|
33 |
import org.gvsig.educa.portableview.map.PortableViewInformation; |
|
34 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
35 |
import org.gvsig.tools.ToolsLocator; |
|
36 |
import org.gvsig.tools.dispose.DisposableManager; |
|
37 |
|
|
38 |
/** |
|
39 |
* <p> |
|
40 |
* Default {@link PortableView} implementation |
|
41 |
* </p> |
|
42 |
* <p> |
|
43 |
* Delegates open/close operation on the {@link MapResoucesManager} |
|
44 |
* </p> |
|
45 |
* |
|
46 |
* @author gvSIG Team |
|
47 |
* @version $Id$ |
|
48 |
* |
|
49 |
*/ |
|
50 |
public class DefaultPortableView implements PortableView { |
|
51 |
|
|
52 |
private static final Logger LOG = LoggerFactory |
|
53 |
.getLogger(DefaultPortableView.class); |
|
54 |
|
|
55 |
private final DisposableManager disposableManager; |
|
56 |
private final File file; |
|
57 |
private final PortableViewInformation info; |
|
58 |
private final MapResoucesManager resourceManager; |
|
59 |
private MapContext mapContext; |
|
60 |
|
|
61 |
public DefaultPortableView(File file, PortableViewInformation info, |
|
62 |
MapResoucesManager resourceManager) { |
|
63 |
this.file = file; |
|
64 |
this.info = info; |
|
65 |
this.resourceManager = resourceManager; |
|
66 |
disposableManager = ToolsLocator.getDisposableManager(); |
|
67 |
disposableManager.bind(this); |
|
68 |
resourceManager.addResource(this); |
|
69 |
} |
|
70 |
|
|
71 |
/** {@inheridDoc} */ |
|
72 |
public PortableViewInformation getInformation() { |
|
73 |
return info; |
|
74 |
} |
|
75 |
|
|
76 |
/** |
|
77 |
* Returns source map file |
|
78 |
* |
|
79 |
* @return |
|
80 |
*/ |
|
81 |
public File getSourceFile() { |
|
82 |
return file; |
|
83 |
} |
|
84 |
|
|
85 |
/** {@inheridDoc} */ |
|
86 |
public void open() throws IOException, InvalidPortableViewFormatException, |
|
87 |
CantLoadContextException { |
|
88 |
if (isOpen()) { |
|
89 |
throw new IllegalStateException("Map is already opened"); |
|
90 |
} |
|
91 |
mapContext = resourceManager.openMap(this); |
|
92 |
} |
|
93 |
|
|
94 |
/** {@inheridDoc} */ |
|
95 |
public boolean isOpen() { |
|
96 |
return resourceManager.isOpen(this); |
|
97 |
} |
|
98 |
|
|
99 |
/** {@inheridDoc} */ |
|
100 |
public void close() throws IOException { |
|
101 |
if (!isOpen()) { |
|
102 |
// Nothing to do |
|
103 |
return; |
|
104 |
} |
|
105 |
resourceManager.closeMap(this); |
|
106 |
mapContext.dispose(); |
|
107 |
mapContext = null; |
|
108 |
} |
|
109 |
|
|
110 |
/** {@inheridDoc} */ |
|
111 |
public MapContext getMapContext() { |
|
112 |
if (!isOpen()) { |
|
113 |
throw new IllegalStateException("Map not open"); |
|
114 |
} |
|
115 |
return mapContext; |
|
116 |
} |
|
117 |
|
|
118 |
/** {@inheridDoc} */ |
|
119 |
public String getSourceFilePath() { |
|
120 |
return file.getAbsolutePath(); |
|
121 |
} |
|
122 |
|
|
123 |
public void dispose() { |
|
124 |
disposableManager.release(this); |
|
125 |
try { |
|
126 |
close(); |
|
127 |
} catch (IOException e) { |
|
128 |
LOG.warn("Problem dispossing PortableView", e); |
|
129 |
} |
|
130 |
|
|
131 |
} |
|
132 |
} |
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.186/org.gvsig.educa.portableview.lib/org.gvsig.educa.portableview.lib.impl/src/main/java/org/gvsig/educa/portableview/impl/map/PortableViewLoader.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.educa.portableview.impl.map; |
|
23 |
|
|
24 |
import java.io.File; |
|
25 |
import java.io.IOException; |
|
26 |
import java.io.InputStream; |
|
27 |
import java.util.Enumeration; |
|
28 |
import java.util.zip.ZipEntry; |
|
29 |
import java.util.zip.ZipException; |
|
30 |
import java.util.zip.ZipFile; |
|
31 |
|
|
32 |
import org.slf4j.Logger; |
|
33 |
import org.slf4j.LoggerFactory; |
|
34 |
import org.gvsig.educa.portableview.PortableViewFileServices; |
|
35 |
import org.gvsig.educa.portableview.PortableViewLocator; |
|
36 |
import org.gvsig.educa.portableview.impl.util.FileUtils; |
|
37 |
import org.gvsig.educa.portableview.impl.util.IOUtils; |
|
38 |
import org.gvsig.educa.portableview.map.CantLoadContextException; |
|
39 |
import org.gvsig.educa.portableview.map.InvalidInstalledPortableViewException; |
|
40 |
import org.gvsig.educa.portableview.map.InvalidPortableViewFormatException; |
|
41 |
import org.gvsig.educa.portableview.map.PortableViewInformation; |
|
42 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
43 |
import org.gvsig.installer.lib.api.InstallerLocator; |
|
44 |
import org.gvsig.installer.lib.api.InstallerManager; |
|
45 |
import org.gvsig.installer.lib.api.PackageInfo; |
|
46 |
import org.gvsig.installer.lib.api.PackageInfoReader; |
|
47 |
import org.gvsig.tools.ToolsLocator; |
|
48 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
49 |
import org.gvsig.tools.persistence.PersistentState; |
|
50 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
51 |
|
|
52 |
/** |
|
53 |
* Utility class which contain methods to load data from a PortableView file |
|
54 |
* |
|
55 |
* @author gvSIG Team |
|
56 |
* @version $Id$ |
|
57 |
* |
|
58 |
*/ |
|
59 |
public class PortableViewLoader { |
|
60 |
|
|
61 |
@SuppressWarnings("unused") |
|
62 |
private static final Logger LOG = LoggerFactory |
|
63 |
.getLogger(PortableViewLoader.class); |
|
64 |
|
|
65 |
private final InstallerManager installerManager; |
|
66 |
|
|
67 |
private final PackageInfoReader packageInfoReader; |
|
68 |
|
|
69 |
private final PortableViewFileServices fileServices; |
|
70 |
|
|
71 |
/** |
|
72 |
* |
|
73 |
*/ |
|
74 |
public PortableViewLoader() { |
|
75 |
installerManager = InstallerLocator.getInstallerManager(); |
|
76 |
packageInfoReader = installerManager.getDefaultPackageInfoReader(); |
|
77 |
fileServices = PortableViewLocator.getFileServices(); |
|
78 |
} |
|
79 |
|
|
80 |
/** |
|
81 |
* Loads the mapContext definition form the deploy folder of a portable view |
|
82 |
* |
|
83 |
* @param mapFile |
|
84 |
* portable view file name (for problems messages) |
|
85 |
* @param deployFolder |
|
86 |
* portable view deploy folder |
|
87 |
* @return |
|
88 |
* @throws InvalidPortableViewFormatException |
|
89 |
* @throws CantLoadContextException |
|
90 |
*/ |
|
91 |
public MapContext loadMapContextFromMapDeployFolder(File mapFile, |
|
92 |
File deployFolder) throws InvalidPortableViewFormatException, |
|
93 |
CantLoadContextException { |
|
94 |
|
|
95 |
// Prepares file path |
|
96 |
File mapContextFile = |
|
97 |
new File(deployFolder, "mapContext/mapContext.xml"); |
|
98 |
|
|
99 |
// Check if file exists |
|
100 |
if (!mapContextFile.exists()) { |
|
101 |
throw new InvalidPortableViewFormatException(mapFile, |
|
102 |
"Missing mapContext/mapContext.xml file in deployed map: " |
|
103 |
.concat(mapContextFile.getAbsolutePath())); |
|
104 |
} |
|
105 |
if (!mapContextFile.isFile()) { |
|
106 |
throw new InvalidPortableViewFormatException(mapFile, |
|
107 |
"mapContext/mapContext.xml file in deployed map is not a file: " |
|
108 |
.concat(mapContextFile.getAbsolutePath())); |
|
109 |
} |
|
110 |
|
|
111 |
// Load map context |
|
112 |
MapContext mapContext; |
|
113 |
try { |
|
114 |
|
|
115 |
mapContext = |
|
116 |
fileServices.loadMapContext(mapContextFile, deployFolder); |
|
117 |
|
|
118 |
if (mapContext == null) { |
|
119 |
throw new CantLoadContextException(mapFile, mapContextFile, |
|
120 |
"mapContext not loaded", null); |
|
121 |
} |
|
122 |
|
|
123 |
return mapContext; |
|
124 |
} catch (Exception e) { |
|
125 |
throw new CantLoadContextException(mapFile, mapContextFile, e); |
|
126 |
} |
|
127 |
} |
|
128 |
|
|
129 |
/** |
|
130 |
* Gets information from a portableViewFile without uncompress it |
|
131 |
* |
|
132 |
* @param portableViewfile |
|
133 |
* @return |
|
134 |
* @throws InvalidPortableViewFormatException |
|
135 |
*/ |
|
136 |
public PortableViewInformation getInformationFromMapFile(File portableViewfile) |
|
137 |
throws InvalidPortableViewFormatException { |
|
138 |
|
|
139 |
PersistenceManager persistenceManager = |
|
140 |
ToolsLocator.getPersistenceManager(); |
|
141 |
|
|
142 |
// Try to open file |
|
143 |
ZipFile zipFile; |
|
144 |
try { |
|
145 |
zipFile = new ZipFile(portableViewfile); |
|
146 |
} catch (ZipException e1) { |
|
147 |
throw new InvalidPortableViewFormatException(portableViewfile, |
|
148 |
"Zip format problem", e1); |
|
149 |
} catch (IOException e1) { |
|
150 |
throw new InvalidPortableViewFormatException(portableViewfile, e1); |
|
151 |
} |
|
152 |
|
|
153 |
PersistentState pState = null; |
|
154 |
try { |
|
155 |
// gets zip file entries |
|
156 |
Enumeration<? extends ZipEntry> entries = zipFile.entries(); |
|
157 |
ZipEntry entry; |
|
158 |
|
|
159 |
// look for MapInfo entry |
|
160 |
while (entries.hasMoreElements()) { |
|
161 |
entry = entries.nextElement(); |
|
162 |
if (!entry.getName().equals("MapInfo.xml")) { |
|
163 |
continue; |
|
164 |
} |
|
165 |
|
|
166 |
// Check it's a file |
|
167 |
if (entry.isDirectory()) { |
|
168 |
throw new InvalidPortableViewFormatException( |
|
169 |
portableViewfile, "MapInfo.xml is a directory"); |
|
170 |
} |
|
171 |
|
|
172 |
// Load file into a persistence state |
|
173 |
InputStream is = null; |
|
174 |
try { |
|
175 |
try { |
|
176 |
is = zipFile.getInputStream(entry); |
|
177 |
pState = persistenceManager.loadState(is); |
|
178 |
} catch (IOException e) { |
|
179 |
throw new InvalidPortableViewFormatException( |
|
180 |
portableViewfile, "problem opening MapInfo.xml", e); |
|
181 |
} catch (PersistenceException e) { |
|
182 |
throw new InvalidPortableViewFormatException( |
|
183 |
portableViewfile, "problem loading MapInfo.xml", e); |
|
184 |
} |
|
185 |
} finally { |
|
186 |
IOUtils.closeQuietly(is); |
|
187 |
} |
|
188 |
} |
|
189 |
|
|
190 |
} finally { |
|
191 |
// Close zip file |
|
192 |
IOUtils.closeQuietly(zipFile); |
|
193 |
} |
|
194 |
|
|
195 |
// If MapInfo file not found |
|
196 |
if (pState == null) { |
|
197 |
throw new IllegalArgumentException("Missing MapInfo.xml"); |
|
198 |
} |
|
199 |
|
|
200 |
// Load data form persistence state |
|
201 |
DefaultPortableViewInformation info = |
|
202 |
new DefaultPortableViewInformation(); |
|
203 |
try { |
|
204 |
info.loadFromState(pState); |
|
205 |
} catch (PersistenceException e) { |
|
206 |
throw new IllegalArgumentException("Invalid MapInfo.xml format", e); |
|
207 |
} |
|
208 |
return info; |
|
209 |
|
|
210 |
} |
|
211 |
|
|
212 |
public PackageInfo getPackageInfoFromInstalledPortableView(File folder) |
|
213 |
throws InvalidInstalledPortableViewException { |
|
214 |
// Check for package.info file |
|
215 |
File packageInfoFile = new File(folder, "package.info"); |
|
216 |
if (!FileUtils.isReadableFile(packageInfoFile)) { |
|
217 |
return null; |
|
218 |
} |
|
219 |
|
|
220 |
PackageInfo packageInfo = installerManager.createPackageInfo(); |
|
221 |
InputStream in = null; |
|
222 |
try { |
|
223 |
in = FileUtils.openInputStream(packageInfoFile); |
|
224 |
packageInfoReader.read(packageInfo, in); |
|
225 |
} catch (Exception ex) { |
|
226 |
throw new InvalidInstalledPortableViewException(folder, ex); |
|
227 |
} finally { |
|
228 |
IOUtils.closeQuietly(in); |
|
229 |
} |
|
230 |
return packageInfo; |
|
231 |
} |
|
232 |
} |
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.186/org.gvsig.educa.portableview.lib/org.gvsig.educa.portableview.lib.impl/src/main/java/org/gvsig/educa/portableview/impl/map/DefaultPortableViewInformation.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.educa.portableview.impl.map; |
|
23 |
|
|
24 |
import java.text.DateFormat; |
|
25 |
import java.text.ParseException; |
|
26 |
import java.util.Date; |
|
27 |
|
|
28 |
import org.cresques.cts.IProjection; |
|
29 |
import org.gvsig.educa.portableview.map.PortableViewInformation; |
|
30 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
31 |
import org.gvsig.tools.ToolsLocator; |
|
32 |
import org.gvsig.tools.dataTypes.DataTypes; |
|
33 |
import org.gvsig.tools.dynobject.DynObject; |
|
34 |
import org.gvsig.tools.dynobject.DynObjectManager; |
|
35 |
import org.gvsig.tools.dynobject.DynStruct; |
|
36 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
37 |
import org.gvsig.tools.persistence.Persistent; |
|
38 |
import org.gvsig.tools.persistence.PersistentState; |
|
39 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
40 |
|
|
41 |
/** |
|
42 |
* Default implementation of {@link PortableViewInformation} |
|
43 |
* |
|
44 |
* @author gvSIG Team |
|
45 |
* @version $Id$ |
|
46 |
* |
|
47 |
*/ |
|
48 |
public class DefaultPortableViewInformation implements PortableViewInformation, |
|
49 |
Persistent { |
|
50 |
|
|
51 |
public static DynStruct dynDefinition; |
|
52 |
|
|
53 |
private String id; |
|
54 |
private String name; |
|
55 |
private String description; |
|
56 |
private int version; |
|
57 |
private int buildNumber; |
|
58 |
private Date creationTimestamp; |
|
59 |
private Envelope envelope; |
|
60 |
private IProjection crs; |
|
61 |
|
|
62 |
/** {@inheridDoc} */ |
|
63 |
public String getId() { |
|
64 |
return id; |
|
65 |
} |
|
66 |
|
|
67 |
/** {@inheridDoc} */ |
|
68 |
public String getName() { |
|
69 |
return name; |
|
70 |
} |
|
71 |
|
|
72 |
/** {@inheridDoc} */ |
|
73 |
public String getDescription() { |
|
74 |
return description; |
|
75 |
} |
|
76 |
|
|
77 |
/** {@inheridDoc} */ |
|
78 |
public int getVersion() { |
|
79 |
return version; |
|
80 |
} |
|
81 |
|
|
82 |
/** {@inheridDoc} */ |
|
83 |
public int getBuildNumber() { |
|
84 |
return buildNumber; |
|
85 |
} |
|
86 |
|
|
87 |
/** {@inheridDoc} */ |
|
88 |
public Date getCreationTimestamp() { |
|
89 |
return creationTimestamp; |
|
90 |
} |
|
91 |
|
|
92 |
/** {@inheridDoc} */ |
|
93 |
public Envelope getFullEnvelope() { |
|
94 |
if (envelope == null) { |
|
95 |
return null; |
|
96 |
} |
|
97 |
try { |
|
98 |
return (Envelope) envelope.clone(); |
|
99 |
} catch (CloneNotSupportedException e) { |
|
100 |
throw new IllegalStateException(e); |
|
101 |
} |
|
102 |
} |
|
103 |
|
|
104 |
/** {@inheridDoc} */ |
|
105 |
public IProjection getCRS() { |
|
106 |
return crs; |
|
107 |
} |
|
108 |
|
|
109 |
/** {@inheridDoc} */ |
|
110 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
111 |
state.set("id", id); |
|
112 |
state.set("name", name); |
|
113 |
state.set("description", description); |
|
114 |
state.set("version", version); |
|
115 |
state.set("buildNumber", buildNumber); |
|
116 |
state.set("creationTimestamp", creationTimestamp); |
|
117 |
state.set("envelope", envelope); |
|
118 |
state.set("crs", crs); |
|
119 |
} |
|
120 |
|
|
121 |
/** {@inheridDoc} */ |
|
122 |
public DynObject getDynObject() { |
|
123 |
DynObjectManager manager = ToolsLocator.getDynObjectManager(); |
|
124 |
DynObject obj = manager.createDynObject(dynDefinition); |
|
125 |
obj.setDynValue("id", id); |
|
126 |
obj.setDynValue("name", name); |
|
127 |
obj.setDynValue("description", description); |
|
128 |
obj.setDynValue("version", version); |
|
129 |
obj.setDynValue("buildNumber", buildNumber); |
|
130 |
obj.setDynValue("creationTimestamp", creationTimestamp); |
|
131 |
obj.setDynValue("envelope", envelope); |
|
132 |
obj.setDynValue("crs", crs); |
|
133 |
|
|
134 |
return obj; |
|
135 |
} |
|
136 |
|
|
137 |
/** {@inheridDoc} */ |
|
138 |
public void loadFromState(PersistentState state) |
|
139 |
throws PersistenceException { |
|
140 |
id = state.getString("id"); |
|
141 |
name = state.getString("name"); |
|
142 |
description = state.getString("description"); |
|
143 |
version = state.getInt("version"); |
|
144 |
buildNumber = state.getInt("buildNumber"); |
|
145 |
creationTimestamp = state.getDate("creationTimestamp"); |
|
146 |
envelope = (Envelope) state.get("envelope"); |
|
147 |
crs = (IProjection) state.get("crs"); |
|
148 |
} |
|
149 |
|
|
150 |
protected void setId(String id) { |
|
151 |
this.id = id; |
|
152 |
} |
|
153 |
|
|
154 |
protected void setName(String name) { |
|
155 |
this.name = name; |
|
156 |
} |
|
157 |
|
|
158 |
protected void setDescription(String description) { |
|
159 |
this.description = description; |
|
160 |
} |
|
161 |
|
|
162 |
protected void setVersion(int version) { |
|
163 |
this.version = version; |
|
164 |
} |
|
165 |
|
|
166 |
protected void setBuildNumber(int buildNumber) { |
|
167 |
this.buildNumber = buildNumber; |
|
168 |
} |
|
169 |
|
|
170 |
protected void setCreationTimestamp(Date creationTimestamp) { |
|
171 |
this.creationTimestamp = creationTimestamp; |
|
172 |
} |
|
173 |
|
|
174 |
protected void setFullEnvelope(Envelope envelope) { |
|
175 |
try { |
|
176 |
this.envelope = (Envelope) envelope.clone(); |
|
177 |
} catch (CloneNotSupportedException e) { |
|
178 |
throw new IllegalArgumentException(e); |
|
179 |
} |
|
180 |
} |
|
181 |
|
|
182 |
protected void setCrs(IProjection crs) { |
|
183 |
this.crs = crs; |
|
184 |
} |
|
185 |
|
|
186 |
public DynStruct getDynDefinition() { |
|
187 |
return dynDefinition; |
|
188 |
} |
|
189 |
|
|
190 |
/** |
|
191 |
* Utility method to register {@link PortableViewInformation} definition in |
|
192 |
* the {@link PersistenceManager} |
|
193 |
*/ |
|
194 |
public static void registerPersistent() { |
|
195 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
196 |
DynStruct definition = |
|
197 |
manager.addDefinition(DefaultPortableViewInformation.class, |
|
198 |
PortableViewInformation.DYN_DEFINITION_NAME, |
|
199 |
"Portable View information", null, null); |
|
200 |
|
|
201 |
definition.addDynFieldString("id").setMandatory(true); |
|
202 |
definition.addDynFieldString("name").setMandatory(true); |
|
203 |
definition.addDynFieldString("description").setMandatory(true); |
|
204 |
definition.addDynFieldInt("version").setMandatory(true); |
|
205 |
definition.addDynFieldInt("buildNumber").setMandatory(true); |
|
206 |
definition.addDynFieldDate("creationTimestamp").setMandatory(true); |
|
207 |
definition.addDynFieldObject("envelope") |
|
208 |
.setClassOfValue(Envelope.class).setMandatory(true); |
|
209 |
definition.addDynFieldObject("crs").setClassOfValue(IProjection.class) |
|
210 |
.setMandatory(true); |
|
211 |
|
|
212 |
dynDefinition = definition; |
|
213 |
|
|
214 |
} |
|
215 |
|
|
216 |
} |
org.gvsig.educa.portableview/tags/org.gvsig.educa.portableview-1.0.186/org.gvsig.educa.portableview.lib/org.gvsig.educa.portableview.lib.impl/src/main/java/org/gvsig/educa/portableview/impl/util/FileUtils.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.educa.portableview.impl.util; |
|
23 |
|
|
24 |
import java.io.File; |
|
25 |
import java.io.IOException; |
|
26 |
import java.io.InputStream; |
|
27 |
import java.io.OutputStream; |
|
28 |
import java.util.Collection; |
|
29 |
import java.util.Enumeration; |
|
30 |
import java.util.zip.ZipEntry; |
|
31 |
import java.util.zip.ZipException; |
|
32 |
import java.util.zip.ZipFile; |
|
33 |
import java.util.zip.ZipOutputStream; |
|
34 |
|
|
35 |
import org.apache.commons.io.DirectoryWalker; |
|
36 |
import org.apache.commons.lang3.StringUtils; |
|
37 |
import org.slf4j.Logger; |
|
38 |
import org.slf4j.LoggerFactory; |
|
39 |
|
|
40 |
/** |
|
41 |
* <p> |
|
42 |
* File utilities. Extends the provides by <i>apache-common-IO</i> |
|
43 |
* </p> |
|
44 |
* |
|
45 |
* @author gvSIG Team |
|
46 |
* @version $Id$ |
|
47 |
* |
|
48 |
*/ |
|
49 |
public abstract class FileUtils extends org.apache.commons.io.FileUtils { |
|
50 |
|
|
51 |
private static final Logger LOG = LoggerFactory.getLogger(FileUtils.class); |
|
52 |
|
|
53 |
public static final boolean UNIXLIKE_FILESYSTEM = File.separatorChar == '/'; |
|
54 |
|
|
55 |
/** |
|
56 |
* <p> |
|
57 |
* Unzip a file into a folder |
|
58 |
* </p> |
|
59 |
* |
|
60 |
* @param zipFile |
|
61 |
* @param outputFloder |
|
62 |
* must exists. WARNING: <b>Contents will be removed before |
|
63 |
* unzip</b> |
|
64 |
* @throws IOException |
|
65 |
* @throws ZipException |
|
66 |
* @throws IllegalArgumentException |
|
67 |
* if zipFile is not a file or outputFloder doesn't exists or is |
|
68 |
* read-only |
|
69 |
*/ |
|
70 |
public static void unzipFile(File zipFile, File outputFloder) |
|
71 |
throws ZipException, IOException { |
|
72 |
|
|
73 |
if (LOG.isDebugEnabled()) { |
|
74 |
LOG.debug( |
|
75 |
"Unzip {} --> {}", |
|
76 |
new Object[] { zipFile.getAbsolutePath(), |
|
77 |
outputFloder.getAbsolutePath() }); |
|
78 |
} |
|
79 |
|
|
80 |
// basic checks input file |
|
81 |
if (!zipFile.exists()) { |
|
82 |
throw new IllegalArgumentException("File '".concat( |
|
83 |
zipFile.getAbsolutePath()).concat("' no exists")); |
|
84 |
} |
|
85 |
if (!zipFile.isFile()) { |
|
86 |
throw new IllegalArgumentException("'".concat( |
|
87 |
zipFile.getAbsolutePath()).concat("' is not a file")); |
|
88 |
} |
|
89 |
if (!zipFile.canRead()) { |
|
90 |
throw new IllegalArgumentException("File '".concat( |
|
91 |
zipFile.getAbsolutePath()).concat("' can not be readed")); |
|
92 |
} |
|
93 |
|
|
94 |
// basic checks output file |
|
95 |
if (!outputFloder.exists()) { |
|
96 |
throw new IllegalArgumentException("Folder '".concat( |
|
97 |
outputFloder.getAbsolutePath()).concat("' not exists.")); |
|
98 |
} |
|
99 |
if (!outputFloder.isDirectory()) { |
|
100 |
throw new IllegalArgumentException("'".concat( |
|
101 |
outputFloder.getAbsolutePath()) |
|
102 |
.concat("' is not a folder.")); |
|
103 |
} |
|
104 |
if (!outputFloder.canWrite()) { |
|
105 |
throw new IllegalArgumentException("Can't write on'".concat( |
|
106 |
outputFloder.getAbsolutePath()).concat("' folder.")); |
|
107 |
} |
|
108 |
|
|
109 |
if (LOG.isTraceEnabled()) { |
|
110 |
LOG.trace("cleaning directory {}", outputFloder.getAbsolutePath()); |
|
111 |
} |
|
112 |
|
|
113 |
cleanDirectory(outputFloder); |
|
114 |
|
|
115 |
// Extract file |
|
116 |
ZipFile openedZipFile = null; |
|
117 |
try { |
|
118 |
openedZipFile = new ZipFile(zipFile); |
|
119 |
Enumeration<? extends ZipEntry> entries = openedZipFile.entries(); |
|
120 |
ZipEntry entry; |
|
121 |
File targetFile; |
|
122 |
// iterate over entries |
|
123 |
while (entries.hasMoreElements()) { |
|
124 |
entry = entries.nextElement(); |
|
125 |
|
|
126 |
// compound target path |
|
127 |
targetFile = new File(outputFloder, entry.getName()); |
|
128 |
|
|
129 |
if (entry.isDirectory()) { |
|
130 |
// Create folder |
|
131 |
if (LOG.isTraceEnabled()) { |
|
132 |
LOG.trace("creating folder {}", |
|
133 |
targetFile.getAbsolutePath()); |
|
134 |
} |
|
135 |
|
|
136 |
if (!targetFile.mkdirs()) { |
|
137 |
throw new IOException("Can't create '".concat( |
|
138 |
targetFile.getAbsolutePath()).concat( |
|
139 |
"' folder.")); |
|
140 |
} |
|
141 |
} else { |
|
142 |
// extract file from zip |
|
143 |
if (LOG.isTraceEnabled()) { |
|
144 |
LOG.trace("extracting file {}", |
|
145 |
targetFile.getAbsolutePath()); |
|
146 |
} |
|
147 |
extractZipEntry(openedZipFile, entry, targetFile); |
|
148 |
} |
|
149 |
} |
|
150 |
|
|
151 |
} finally { |
|
152 |
IOUtils.closeQuietly(openedZipFile); |
|
153 |
} |
|
154 |
} |
|
155 |
|
|
156 |
/** |
|
157 |
* Extract a zipEntry into a file |
|
158 |
* |
|
159 |
* @param zipFile |
|
160 |
* @param entry |
|
161 |
* @param target |
|
162 |
* (if exists will be overwrite) |
|
163 |
* @throws IOException |
|
164 |
*/ |
|
165 |
private static void extractZipEntry(ZipFile zipFile, ZipEntry entry, |
|
166 |
File target) throws IOException { |
|
167 |
InputStream is = null; |
|
168 |
OutputStream os = null; |
|
169 |
try { |
|
170 |
is = zipFile.getInputStream(entry); |
|
171 |
os = openOutputStream(target); |
|
172 |
IOUtils.copy(is, os); |
|
173 |
} finally { |
|
174 |
IOUtils.closeQuietly(is); |
|
175 |
IOUtils.closeQuietly(os); |
|
176 |
} |
|
177 |
} |
|
178 |
|
|
179 |
/** |
|
180 |
* <p> |
|
181 |
* Create a zip file which will contains all contents of a folder |
|
182 |
* </p> |
|
183 |
* <p> |
|
184 |
* Files will be use relative path to <code>rootFolder</code> |
|
185 |
* </p> |
|
186 |
* |
|
187 |
* @param rootFolder |
|
188 |
* rootFolder (must be an existing folder) |
|
189 |
* @param targetFile |
|
190 |
* final file (must not exists) |
|
191 |
* @throws IOException |
|
192 |
* @throws IllegalArgumentException |
|
193 |
* if there are any problem in parameters |
|
194 |
*/ |
|
195 |
public static void zipFolder(File rootFolder, File targetFile) |
|
196 |
throws IOException { |
|
197 |
if (LOG.isDebugEnabled()) { |
|
198 |
LOG.debug( |
|
199 |
"zip {} --> {}", |
|
200 |
new Object[] { rootFolder.getAbsolutePath(), |
|
201 |
targetFile.getAbsolutePath() }); |
|
202 |
} |
|
203 |
|
|
204 |
if (!isReadableFolder(rootFolder)) { |
|
205 |
throw new IllegalArgumentException("Invalid folder"); |
|
206 |
} |
|
207 |
if (targetFile.exists()) { |
|
208 |
throw new IllegalArgumentException("Target file already exists"); |
|
209 |
} |
|
210 |
if (!isWritableFolder(targetFile.getParentFile())) { |
|
211 |
throw new IllegalArgumentException("Can't write in target folder"); |
|
212 |
} |
|
213 |
RelativePathFolderZipper zipper = new RelativePathFolderZipper( |
|
214 |
rootFolder, targetFile); |
|
215 |
|
|
216 |
zipper.zip(); |
|
217 |
|
|
218 |
} |
|
219 |
|
|
220 |
/** |
|
221 |
* Informs if <code>folder</code> is a writable folder( exists & isDir & |
|
222 |
* canWrite) |
|
223 |
* |
|
224 |
* @param folder |
|
225 |
* @return |
|
226 |
*/ |
|
227 |
public static boolean isWritableFolder(File folder) { |
|
228 |
return folder.exists() && folder.isDirectory() && folder.canWrite(); |
|
229 |
} |
|
230 |
|
|
231 |
/** |
|
232 |
* Informs if <code>folder</code> is a readable folder( exists & isDir & |
|
233 |
* canRead) |
|
234 |
* |
|
235 |
* @param folder |
|
236 |
* @return |
|
237 |
*/ |
|
238 |
public static boolean isReadableFolder(File folder) { |
|
239 |
return folder.exists() && folder.isDirectory() && folder.canRead(); |
Also available in: Unified diff