Revision 1459
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.136/org.gvsig.scripting.app/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
|
|
3 |
<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"> |
|
4 |
<modelVersion>4.0.0</modelVersion> |
|
5 |
<artifactId>org.gvsig.scripting.app</artifactId> |
|
6 |
<packaging>pom</packaging> |
|
7 |
<name>${project.artifactId}</name> |
|
8 |
<parent> |
|
9 |
<groupId>org.gvsig</groupId> |
|
10 |
<artifactId>org.gvsig.scripting</artifactId> |
|
11 |
<version>2.3.136</version> |
|
12 |
</parent> |
|
13 |
|
|
14 |
<modules> |
|
15 |
<module>org.gvsig.scripting.app.mainplugin</module> |
|
16 |
</modules> |
|
17 |
</project> |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.136/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/buildNumber.properties | ||
---|---|---|
1 |
#Wed Jun 30 20:15:12 CEST 2021 |
|
2 |
buildNumber=216 |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.136/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>gvsig-plugin-package</id> |
|
3 |
<formats> |
|
4 |
<format>zip</format> |
|
5 |
</formats> |
|
6 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
7 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
8 |
<files> |
|
9 |
<file> |
|
10 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
11 |
<outputDirectory>lib</outputDirectory> |
|
12 |
</file> |
|
13 |
<file> |
|
14 |
<source>target/package.info</source> |
|
15 |
</file> |
|
16 |
</files> |
|
17 |
|
|
18 |
<fileSets> |
|
19 |
<fileSet> |
|
20 |
<directory>src/main/resources-plugin</directory> |
|
21 |
<outputDirectory>.</outputDirectory> |
|
22 |
</fileSet> |
|
23 |
<fileSet> |
|
24 |
<directory>target/abeille</directory> |
|
25 |
<outputDirectory>.</outputDirectory> |
|
26 |
</fileSet> |
|
27 |
</fileSets> |
|
28 |
|
|
29 |
<dependencySets> |
|
30 |
|
|
31 |
<dependencySet> |
|
32 |
<useProjectArtifact>false</useProjectArtifact> |
|
33 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
34 |
<outputDirectory>lib</outputDirectory> |
|
35 |
<includes> |
|
36 |
<!-- |
|
37 |
Plugin libraries |
|
38 |
--> |
|
39 |
<include>org.ini4j:ini4j</include> |
|
40 |
<include>net.sourceforge.thinlet:thinlet</include> |
|
41 |
<include>org.gvsig:org.gvsig.scripting.thing</include> |
|
42 |
<include>org.gvsig:org.gvsig.scripting.lib.api</include> |
|
43 |
<include>org.gvsig:org.gvsig.scripting.swing.api</include> |
|
44 |
<include>org.gvsig:org.gvsig.scripting.lib.impl</include> |
|
45 |
<include>org.gvsig:org.gvsig.scripting.swing.impl</include> |
|
46 |
<include>org.apache.tika:tika-core</include> |
|
47 |
|
|
48 |
<!-- |
|
49 |
Utility libraries |
|
50 |
--> |
|
51 |
<!-- JOpenDocument --> |
|
52 |
<include>org.jopendocument:jOpenDocument</include> |
|
53 |
|
|
54 |
<!-- CSSBox webbrowser --> |
|
55 |
<include>net.sf.cssbox:cssbox</include> |
|
56 |
<include>net.sf.cssbox:swingbox</include> |
|
57 |
<include>net.sf.cssbox:jstyleparser</include> |
|
58 |
<include>net.sourceforge.nekohtml:nekohtml</include> |
|
59 |
<include>org.antlr:antlr-runtime</include> |
|
60 |
|
|
61 |
<!-- |
|
62 |
Script engines libraries |
|
63 |
--> |
|
64 |
|
|
65 |
<include>org.codehaus.groovy:groovy-all</include> |
|
66 |
|
|
67 |
<!-- |
|
68 |
<include>org.renjin:renjin-script-engine:jar:jar-with-dependencies</include> |
|
69 |
--> |
|
70 |
|
|
71 |
<include>org.python:${jython.artifactId}</include> |
|
72 |
<include>com.github.tbekolay.jnumeric:jnumeric</include> |
|
73 |
|
|
74 |
</includes> |
|
75 |
</dependencySet> |
|
76 |
|
|
77 |
<dependencySet> |
|
78 |
<useProjectArtifact>false</useProjectArtifact> |
|
79 |
<useTransitiveDependencies>true</useTransitiveDependencies> |
|
80 |
<outputDirectory>lib</outputDirectory> |
|
81 |
<includes> |
|
82 |
<!-- |
|
83 |
JGit support runtime libraries |
|
84 |
--> |
|
85 |
<include>org.eclipse.jgit:org.eclipse.jgit</include> |
|
86 |
<include>com.jcraft:jsch</include> |
|
87 |
<include>com.googlecode.javaewah:JavaEWAH</include> |
|
88 |
<include>org.apache.httpcomponents:httpclient</include> |
|
89 |
<include>org.apache.httpcomponents:httpcore</include> |
|
90 |
</includes> |
|
91 |
</dependencySet> |
|
92 |
|
|
93 |
<dependencySet> |
|
94 |
<useProjectArtifact>false</useProjectArtifact> |
|
95 |
<useTransitiveDependencies>true</useTransitiveDependencies> |
|
96 |
<outputDirectory>lib</outputDirectory> |
|
97 |
<includes> |
|
98 |
<!-- |
|
99 |
ICEPDF support runtime libraries |
|
100 |
--> |
|
101 |
<include>org.icepdf.os:icepdf-viewer</include> |
|
102 |
<include>org.icepdf.os:icepdf-core</include> |
|
103 |
</includes> |
|
104 |
</dependencySet> |
|
105 |
|
|
106 |
<dependencySet> |
|
107 |
<useProjectArtifact>false</useProjectArtifact> |
|
108 |
<useTransitiveDependencies>true</useTransitiveDependencies> |
|
109 |
<outputDirectory>lib</outputDirectory> |
|
110 |
<includes> |
|
111 |
<!-- |
|
112 |
java-diff-utils libraries |
|
113 |
https://github.com/java-diff-utils/java-diff-utils |
|
114 |
--> |
|
115 |
<include>com.sksamuel.diff:diff</include> |
|
116 |
|
|
117 |
</includes> |
|
118 |
</dependencySet> |
|
119 |
|
|
120 |
<dependencySet> |
|
121 |
<useProjectArtifact>false</useProjectArtifact> |
|
122 |
<useTransitiveDependencies>true</useTransitiveDependencies> |
|
123 |
<outputDirectory>lib</outputDirectory> |
|
124 |
<includes> |
|
125 |
<!-- |
|
126 |
flexmark-java, Markdown support libraries |
|
127 |
--> |
|
128 |
<include>com.vladsch.flexmark:flexmark-all</include> |
|
129 |
<include>com.vladsch.flexmark:flexmark</include> |
|
130 |
<include>com.vladsch.flexmark:flexmark-ext-abbreviation</include> |
|
131 |
<include>com.vladsch.flexmark:flexmark-util</include> |
|
132 |
<include>com.vladsch.flexmark:flexmark-ext-admonition</include> |
|
133 |
<include>com.vladsch.flexmark:flexmark-ext-anchorlink</include> |
|
134 |
<include>com.vladsch.flexmark:flexmark-ext-aside</include> |
|
135 |
<include>com.vladsch.flexmark:flexmark-ext-attributes</include> |
|
136 |
<include>com.vladsch.flexmark:flexmark-ext-autolink</include> |
|
137 |
<include>org.nibor.autolink:autolink</include> |
|
138 |
<include>com.vladsch.flexmark:flexmark-ext-definition</include> |
|
139 |
<include>com.vladsch.flexmark:flexmark-ext-emoji</include> |
|
140 |
<include>com.vladsch.flexmark:flexmark-ext-enumerated-reference</include> |
|
141 |
<include>com.vladsch.flexmark:flexmark-ext-escaped-character</include> |
|
142 |
<include>com.vladsch.flexmark:flexmark-ext-footnotes</include> |
|
143 |
<include>com.vladsch.flexmark:flexmark-ext-gfm-issues</include> |
|
144 |
<include>com.vladsch.flexmark:flexmark-ext-gfm-strikethrough</include> |
|
145 |
<include>com.vladsch.flexmark:flexmark-ext-gfm-tasklist</include> |
|
146 |
<include>com.vladsch.flexmark:flexmark-ext-gfm-users</include> |
|
147 |
<include>com.vladsch.flexmark:flexmark-ext-gitlab</include> |
|
148 |
<include>com.vladsch.flexmark:flexmark-ext-jekyll-front-matter</include> |
|
149 |
<include>com.vladsch.flexmark:flexmark-ext-jekyll-tag</include> |
|
150 |
<include>com.vladsch.flexmark:flexmark-ext-media-tags</include> |
|
151 |
<include>com.vladsch.flexmark:flexmark-ext-macros</include> |
|
152 |
<include>com.vladsch.flexmark:flexmark-ext-ins</include> |
|
153 |
<include>com.vladsch.flexmark:flexmark-ext-xwiki-macros</include> |
|
154 |
<include>com.vladsch.flexmark:flexmark-ext-superscript</include> |
|
155 |
<include>com.vladsch.flexmark:flexmark-ext-tables</include> |
|
156 |
<include>com.vladsch.flexmark:flexmark-ext-toc</include> |
|
157 |
<include>com.vladsch.flexmark:flexmark-ext-typographic</include> |
|
158 |
<include>com.vladsch.flexmark:flexmark-ext-wikilink</include> |
|
159 |
<include>com.vladsch.flexmark:flexmark-ext-yaml-front-matter</include> |
|
160 |
<include>com.vladsch.flexmark:flexmark-ext-youtube-embedded</include> |
|
161 |
<include>com.vladsch.flexmark:flexmark-html2md-converter</include> |
|
162 |
<include>org.jsoup:jsoup</include> |
|
163 |
<include>com.vladsch.flexmark:flexmark-jira-converter</include> |
|
164 |
<include>com.vladsch.flexmark:flexmark-pdf-converter</include> |
|
165 |
<include>com.openhtmltopdf:openhtmltopdf-core</include> |
|
166 |
<include>com.openhtmltopdf:openhtmltopdf-pdfbox</include> |
|
167 |
<include>org.apache.pdfbox:xmpbox</include> |
|
168 |
<include>de.rototor.pdfbox:graphics2d</include> |
|
169 |
<include>com.openhtmltopdf:openhtmltopdf-rtl-support</include> |
|
170 |
<include>com.ibm.icu:icu4j</include> |
|
171 |
<include>com.openhtmltopdf:openhtmltopdf-jsoup-dom-converter</include> |
|
172 |
<include>com.vladsch.flexmark:flexmark-profile-pegdown</include> |
|
173 |
<include>com.vladsch.flexmark:flexmark-util-ast</include> |
|
174 |
<include>org.jetbrains:annotations</include> |
|
175 |
<include>com.vladsch.flexmark:flexmark-util-builder</include> |
|
176 |
<include>com.vladsch.flexmark:flexmark-util-collection</include> |
|
177 |
<include>com.vladsch.flexmark:flexmark-util-data</include> |
|
178 |
<include>com.vladsch.flexmark:flexmark-util-dependency</include> |
|
179 |
<include>com.vladsch.flexmark:flexmark-util-format</include> |
|
180 |
<include>com.vladsch.flexmark:flexmark-util-html</include> |
|
181 |
<include>com.vladsch.flexmark:flexmark-util-misc</include> |
|
182 |
<include>com.vladsch.flexmark:flexmark-util-options</include> |
|
183 |
<include>com.vladsch.flexmark:flexmark-util-sequence</include> |
|
184 |
<include>com.vladsch.flexmark:flexmark-util-visitor</include> |
|
185 |
<include>com.vladsch.flexmark:flexmark-youtrack-converter</include> |
|
186 |
<include>org.apache.pdfbox:pdfbox</include> |
|
187 |
<include>org.apache.pdfbox:fontbox</include> |
|
188 |
<include>commons-logging:commons-logging</include> |
|
189 |
</includes> |
|
190 |
</dependencySet> |
|
191 |
|
|
192 |
</dependencySets> |
|
193 |
|
|
194 |
</assembly> |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.136/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/java/org/gvsig/scripting/app/InstallCert.java | ||
---|---|---|
1 |
package org.gvsig.scripting.app; |
|
2 |
|
|
3 |
/* |
|
4 |
* Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. |
|
5 |
* |
|
6 |
* Redistribution and use in source and binary forms, with or without |
|
7 |
* modification, are permitted provided that the following conditions |
|
8 |
* are met: |
|
9 |
* |
|
10 |
* - Redistributions of source code must retain the above copyright |
|
11 |
* notice, this list of conditions and the following disclaimer. |
|
12 |
* |
|
13 |
* - Redistributions in binary form must reproduce the above copyright |
|
14 |
* notice, this list of conditions and the following disclaimer in the |
|
15 |
* documentation and/or other materials provided with the distribution. |
|
16 |
* |
|
17 |
* - Neither the name of Sun Microsystems nor the names of its |
|
18 |
* contributors may be used to endorse or promote products derived |
|
19 |
* from this software without specific prior written permission. |
|
20 |
* |
|
21 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS |
|
22 |
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
|
23 |
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
24 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
|
25 |
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|
26 |
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
27 |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
|
28 |
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
|
29 |
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
30 |
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
|
31 |
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
32 |
*/ |
|
33 |
/** |
|
34 |
* Originally from: |
|
35 |
* http://blogs.sun.com/andreas/resource/InstallCert.java |
|
36 |
* Use: |
|
37 |
* java InstallCert hostname |
|
38 |
* Example: |
|
39 |
*% java InstallCert ecc.fedora.redhat.com |
|
40 |
*/ |
|
41 |
|
|
42 |
import java.io.BufferedReader; |
|
43 |
import java.io.File; |
|
44 |
import java.io.FileInputStream; |
|
45 |
import java.io.FileOutputStream; |
|
46 |
import java.io.InputStream; |
|
47 |
import java.io.InputStreamReader; |
|
48 |
import java.io.OutputStream; |
|
49 |
import java.security.KeyStore; |
|
50 |
import java.security.MessageDigest; |
|
51 |
import java.security.cert.CertificateException; |
|
52 |
import java.security.cert.X509Certificate; |
|
53 |
|
|
54 |
import javax.net.ssl.SSLContext; |
|
55 |
import javax.net.ssl.SSLException; |
|
56 |
import javax.net.ssl.SSLSocket; |
|
57 |
import javax.net.ssl.SSLSocketFactory; |
|
58 |
import javax.net.ssl.TrustManager; |
|
59 |
import javax.net.ssl.TrustManagerFactory; |
|
60 |
import javax.net.ssl.X509TrustManager; |
|
61 |
|
|
62 |
/** |
|
63 |
* Class used to add the server's certificate to the KeyStore |
|
64 |
* with your trusted certificates. |
|
65 |
* |
|
66 |
* NOTE: modified to install the certificate always into the main cacerts |
|
67 |
* keystore. |
|
68 |
*/ |
|
69 |
public class InstallCert { |
|
70 |
|
|
71 |
public static void install(String host, Integer port, String passphrase) throws Exception { |
|
72 |
if( passphrase==null ) { |
|
73 |
passphrase = "changeit"; |
|
74 |
} |
|
75 |
if( port == null || port <1) { |
|
76 |
port = 443; |
|
77 |
} |
|
78 |
main( |
|
79 |
new String[] { |
|
80 |
host +":"+port, |
|
81 |
passphrase |
|
82 |
} |
|
83 |
); |
|
84 |
} |
|
85 |
|
|
86 |
public static void main(String[] args) throws Exception { |
|
87 |
String host; |
|
88 |
int port; |
|
89 |
char[] passphrase; |
|
90 |
if ((args.length == 1) || (args.length == 2)) { |
|
91 |
String[] c = args[0].split(":"); |
|
92 |
host = c[0]; |
|
93 |
port = (c.length == 1) ? 443 : Integer.parseInt(c[1]); |
|
94 |
String p = (args.length == 1) ? "changeit" : args[1]; |
|
95 |
passphrase = p.toCharArray(); |
|
96 |
} else { |
|
97 |
System.out.println("Usage: java InstallCert [:port] [passphrase]"); |
|
98 |
return; |
|
99 |
} |
|
100 |
|
|
101 |
File file = null; |
|
102 |
// File file = new File("jssecacerts"); |
|
103 |
// if (file.isFile() == false) { |
|
104 |
char SEP = File.separatorChar; |
|
105 |
File dir = |
|
106 |
new File(System.getProperty("java.home") + SEP + "lib" + SEP |
|
107 |
+ "security"); |
|
108 |
// file = new File(dir, "jssecacerts"); |
|
109 |
// if (file.isFile() == false) { |
|
110 |
file = new File(dir, "cacerts"); |
|
111 |
|
|
112 |
if (!file.canWrite()) { |
|
113 |
System.err |
|
114 |
.println("Unable to write in the file " |
|
115 |
+ file |
|
116 |
+ ".\nRun InstallCert as an administrator or a user with " |
|
117 |
+ "privileges to write in the cacerts file"); |
|
118 |
|
|
119 |
System.exit(-1); |
|
120 |
} |
|
121 |
// } |
|
122 |
// } |
|
123 |
System.out.println("Loading KeyStore " + file + "..."); |
|
124 |
InputStream in = new FileInputStream(file); |
|
125 |
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType()); |
|
126 |
ks.load(in, passphrase); |
|
127 |
in.close(); |
|
128 |
|
|
129 |
SSLContext context = SSLContext.getInstance("TLS"); |
|
130 |
TrustManagerFactory tmf = |
|
131 |
TrustManagerFactory.getInstance(TrustManagerFactory |
|
132 |
.getDefaultAlgorithm()); |
|
133 |
tmf.init(ks); |
|
134 |
X509TrustManager defaultTrustManager = |
|
135 |
(X509TrustManager) tmf.getTrustManagers()[0]; |
|
136 |
SavingTrustManager tm = new SavingTrustManager(defaultTrustManager); |
|
137 |
context.init(null, new TrustManager[] { tm }, null); |
|
138 |
SSLSocketFactory factory = context.getSocketFactory(); |
|
139 |
|
|
140 |
System.out |
|
141 |
.println("Opening connection to " + host + ":" + port + "..."); |
|
142 |
SSLSocket socket = (SSLSocket) factory.createSocket(host, port); |
|
143 |
socket.setSoTimeout(10000); |
|
144 |
try { |
|
145 |
System.out.println("Starting SSL handshake..."); |
|
146 |
socket.startHandshake(); |
|
147 |
socket.close(); |
|
148 |
System.out.println(); |
|
149 |
System.out.println("No errors, certificate is already trusted"); |
|
150 |
} catch (SSLException e) { |
|
151 |
System.out.println(); |
|
152 |
e.printStackTrace(System.out); |
|
153 |
} |
|
154 |
|
|
155 |
X509Certificate[] chain = tm.chain; |
|
156 |
if (chain == null) { |
|
157 |
System.out.println("Could not obtain server certificate chain"); |
|
158 |
return; |
|
159 |
} |
|
160 |
|
|
161 |
BufferedReader reader = |
|
162 |
new BufferedReader(new InputStreamReader(System.in)); |
|
163 |
|
|
164 |
System.out.println(); |
|
165 |
System.out.println("Server sent " + chain.length + " certificate(s):"); |
|
166 |
System.out.println(); |
|
167 |
MessageDigest sha1 = MessageDigest.getInstance("SHA1"); |
|
168 |
MessageDigest md5 = MessageDigest.getInstance("MD5"); |
|
169 |
for (int i = 0; i < chain.length; i++) { |
|
170 |
X509Certificate cert = chain[i]; |
|
171 |
System.out.println(" " + (i + 1) + " Subject " |
|
172 |
+ cert.getSubjectDN()); |
|
173 |
System.out.println(" Issuer " + cert.getIssuerDN()); |
|
174 |
sha1.update(cert.getEncoded()); |
|
175 |
System.out.println(" sha1 " + toHexString(sha1.digest())); |
|
176 |
md5.update(cert.getEncoded()); |
|
177 |
System.out.println(" md5 " + toHexString(md5.digest())); |
|
178 |
System.out.println(); |
|
179 |
} |
|
180 |
|
|
181 |
// int k=0; |
|
182 |
// System.out |
|
183 |
// .println("Enter certificate to add to trusted keystore or 'q' to quit: [1]"); |
|
184 |
// String line = reader.readLine().trim(); |
|
185 |
// try { |
|
186 |
// k = (line.length() == 0) ? 0 : Integer.parseInt(line) - 1; |
|
187 |
// } catch (NumberFormatException e) { |
|
188 |
// System.out.println("KeyStore not changed"); |
|
189 |
// return; |
|
190 |
// } |
|
191 |
|
|
192 |
for( int k=0; k<chain.length; k++ ) { |
|
193 |
X509Certificate cert = chain[k]; |
|
194 |
String alias = host + "-" + (k + 1); |
|
195 |
ks.setCertificateEntry(alias, cert); |
|
196 |
|
|
197 |
// OutputStream out = new FileOutputStream("jssecacerts"); |
|
198 |
OutputStream out = new FileOutputStream(file); |
|
199 |
ks.store(out, passphrase); |
|
200 |
out.close(); |
|
201 |
|
|
202 |
System.out.println(); |
|
203 |
System.out.println(cert); |
|
204 |
System.out.println(); |
|
205 |
System.out |
|
206 |
.println("Added certificate to keystore '" + |
|
207 |
file + "' using alias '" + alias + "'"); |
|
208 |
} |
|
209 |
} |
|
210 |
|
|
211 |
private static final char[] HEXDIGITS = "0123456789abcdef".toCharArray(); |
|
212 |
|
|
213 |
private static String toHexString(byte[] bytes) { |
|
214 |
StringBuilder sb = new StringBuilder(bytes.length * 3); |
|
215 |
for (int b : bytes) { |
|
216 |
b &= 0xff; |
|
217 |
sb.append(HEXDIGITS[b >> 4]); |
|
218 |
sb.append(HEXDIGITS[b & 15]); |
|
219 |
sb.append(' '); |
|
220 |
} |
|
221 |
return sb.toString(); |
|
222 |
} |
|
223 |
|
|
224 |
private static class SavingTrustManager implements X509TrustManager { |
|
225 |
|
|
226 |
private final X509TrustManager tm; |
|
227 |
private X509Certificate[] chain; |
|
228 |
|
|
229 |
SavingTrustManager(X509TrustManager tm) { |
|
230 |
this.tm = tm; |
|
231 |
} |
|
232 |
|
|
233 |
public X509Certificate[] getAcceptedIssuers() { |
|
234 |
throw new UnsupportedOperationException(); |
|
235 |
} |
|
236 |
|
|
237 |
public void checkClientTrusted(X509Certificate[] chain, String authType) |
|
238 |
throws CertificateException { |
|
239 |
throw new UnsupportedOperationException(); |
|
240 |
} |
|
241 |
|
|
242 |
public void checkServerTrusted(X509Certificate[] chain, String authType) |
|
243 |
throws CertificateException { |
|
244 |
this.chain = chain; |
|
245 |
tm.checkServerTrusted(chain, authType); |
|
246 |
} |
|
247 |
} |
|
248 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.136/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/java/org/gvsig/scripting/app/extension/DataFoldersRecoverPanel.java | ||
---|---|---|
1 |
package org.gvsig.scripting.app.extension; |
|
2 |
|
|
3 |
import java.awt.Dimension; |
|
4 |
import java.util.ArrayList; |
|
5 |
import java.util.List; |
|
6 |
import javax.swing.DefaultListModel; |
|
7 |
import javax.swing.ListSelectionModel; |
|
8 |
import javax.swing.event.ListSelectionEvent; |
|
9 |
import javax.swing.event.ListSelectionListener; |
|
10 |
import org.gvsig.scripting.DataFolderFound; |
|
11 |
import org.gvsig.tools.swing.api.JListWithCheckbox; |
|
12 |
import org.gvsig.tools.swing.api.ListElement; |
|
13 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
14 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
|
15 |
|
|
16 |
/** |
|
17 |
* |
|
18 |
* @author jjdelcerro |
|
19 |
*/ |
|
20 |
public class DataFoldersRecoverPanel extends DataFoldersRecoverPanelView { |
|
21 |
|
|
22 |
private final List<DataFolderFound> dataFoldersFound; |
|
23 |
private JListWithCheckbox lstCheckedDataFolders; |
|
24 |
|
|
25 |
public DataFoldersRecoverPanel(List<DataFolderFound> dataFoldersFound) { |
|
26 |
this.dataFoldersFound = dataFoldersFound; |
|
27 |
this.initComponents(); |
|
28 |
} |
|
29 |
|
|
30 |
private void initComponents() { |
|
31 |
ToolsSwingManager manager = ToolsSwingLocator.getToolsSwingManager(); |
|
32 |
this.lstCheckedDataFolders = manager.createJListWithCheckbox(lstDataFolders); |
|
33 |
DefaultListModel model = new DefaultListModel(); |
|
34 |
for (DataFolderFound dataFolderFound : dataFoldersFound) { |
|
35 |
if( dataFolderFound.getApplicationFolder()==null ) { |
|
36 |
continue; |
|
37 |
} |
|
38 |
model.addElement( |
|
39 |
new ListElement<>( |
|
40 |
dataFolderFound.getApplicationName() + " ("+dataFolderFound.getDataFolderId()+")", |
|
41 |
dataFolderFound |
|
42 |
) |
|
43 |
); |
|
44 |
} |
|
45 |
this.lstDataFolders.setModel(model); |
|
46 |
this.lstDataFolders.addListSelectionListener(new ListSelectionListener() { |
|
47 |
@Override |
|
48 |
public void valueChanged(ListSelectionEvent e) { |
|
49 |
if( e.getValueIsAdjusting() ) { |
|
50 |
return; |
|
51 |
} |
|
52 |
updateInterfaceData(); |
|
53 |
} |
|
54 |
}); |
|
55 |
|
|
56 |
this.setPreferredSize(new Dimension(500, 420)); |
|
57 |
} |
|
58 |
|
|
59 |
private void updateInterfaceData() { |
|
60 |
DataFolderFound dataFolder = (DataFolderFound) ListElement.getSelected(this.lstDataFolders); |
|
61 |
if (dataFolder == null) { |
|
62 |
return; |
|
63 |
} |
|
64 |
this.txtApplication.setText(dataFolder.getApplicationName()); |
|
65 |
this.txtPreferencias.setText(dataFolder.getDataFolderId()); |
|
66 |
this.txtPath.setText(dataFolder.getApplicationFolder().getUserPath()); |
|
67 |
String path = dataFolder.getOldDataFolder().getAbsolutePath(); |
|
68 |
this.txtOldFolder.setText(path); |
|
69 |
this.txtOldFolder.setCaretPosition(path.length()); |
|
70 |
} |
|
71 |
|
|
72 |
public List<DataFolderFound> getSelectedDataFolders() { |
|
73 |
List<DataFolderFound> r = new ArrayList<>(); |
|
74 |
ListSelectionModel checkedModel = this.lstCheckedDataFolders.getCheckedModel(); |
|
75 |
for (int i = 0; i < dataFoldersFound.size(); i++) { |
|
76 |
if (checkedModel.isSelectedIndex(i)) { |
|
77 |
r.add(dataFoldersFound.get(i)); |
|
78 |
} |
|
79 |
} |
|
80 |
return r; |
|
81 |
} |
|
82 |
|
|
83 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.136/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/java/org/gvsig/scripting/app/extension/ScriptingExtension.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.scripting.app.extension; |
|
23 |
|
|
24 |
import java.io.File; |
|
25 |
import java.io.InputStream; |
|
26 |
import java.net.MalformedURLException; |
|
27 |
import java.net.URL; |
|
28 |
import java.util.List; |
|
29 |
import org.apache.commons.io.IOUtils; |
|
30 |
import org.apache.commons.lang3.StringUtils; |
|
31 |
|
|
32 |
import org.gvsig.andami.IconThemeHelper; |
|
33 |
import org.gvsig.andami.PluginServices; |
|
34 |
import org.gvsig.andami.PluginsLocator; |
|
35 |
import org.gvsig.andami.PluginsManager; |
|
36 |
import org.gvsig.andami.plugins.Extension; |
|
37 |
import org.gvsig.andami.plugins.PluginClassLoader; |
|
38 |
import org.gvsig.scripting.ScriptingLocator; |
|
39 |
import org.gvsig.scripting.ScriptingManager; |
|
40 |
import org.gvsig.scripting.swing.api.ScriptingSwingLocator; |
|
41 |
import org.gvsig.scripting.swing.api.ScriptingUIManager; |
|
42 |
import org.gvsig.tools.dynobject.DynObject; |
|
43 |
import org.gvsig.tools.swing.impl.windowmanager.DefaultWindowManager; |
|
44 |
import org.slf4j.Logger; |
|
45 |
import org.slf4j.LoggerFactory; |
|
46 |
import org.gvsig.tools.script.Script; |
|
47 |
import org.gvsig.tools.util.Invocable; |
|
48 |
|
|
49 |
@SuppressWarnings("UseSpecificCatch") |
|
50 |
public class ScriptingExtension extends Extension { |
|
51 |
|
|
52 |
@SuppressWarnings("FieldNameHidesFieldInSuperclass") |
|
53 |
private static final Logger LOGGER = LoggerFactory.getLogger(ScriptingExtension.class); |
|
54 |
|
|
55 |
private ScriptingUtils utils; |
|
56 |
|
|
57 |
@Deprecated |
|
58 |
public static void log(String message) { |
|
59 |
ScriptingUtils.log(ScriptingUtils.INFO, message, null); |
|
60 |
} |
|
61 |
|
|
62 |
@Deprecated |
|
63 |
public static void log(int level, String message) { |
|
64 |
ScriptingUtils.log(level, message, null); |
|
65 |
} |
|
66 |
|
|
67 |
@Deprecated |
|
68 |
public static void log(int level, String message, Throwable th) { |
|
69 |
ScriptingUtils.log(level, message, th); |
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
public void initialize() { |
|
74 |
IconThemeHelper.registerIcon("action", "tools-scripting-launcher", this); |
|
75 |
IconThemeHelper.registerIcon("action", "tools-scripting-composer", this); |
|
76 |
IconThemeHelper.registerIcon("action", "tools-scripting-console-jython", this); |
|
77 |
|
|
78 |
PluginsManager pluginManager = PluginsLocator.getManager(); |
|
79 |
this.utils = new ScriptingUtils(); |
|
80 |
|
|
81 |
this.utils.initializaPaths( |
|
82 |
pluginManager.getPluginsFolders(), |
|
83 |
pluginManager.getInstallFolder(), |
|
84 |
this.getPlugin().getPluginHomeFolder(), |
|
85 |
pluginManager.getApplicationVersion().format(ScriptsInstallerInitializer.VERSION_FORMAT) |
|
86 |
); |
|
87 |
|
|
88 |
Thread th = new Thread(new Runnable() { |
|
89 |
@Override |
|
90 |
public void run() { |
|
91 |
preloadPythonEngine(); |
|
92 |
} |
|
93 |
}, "ScriptEnginesInitializer"); |
|
94 |
th.start(); |
|
95 |
try { |
|
96 |
th.join(1000); // force change to other thread |
|
97 |
} catch (InterruptedException ex) { |
|
98 |
// Ignore. |
|
99 |
} |
|
100 |
} |
|
101 |
|
|
102 |
public ScriptingUtils getScriptingUtils() { |
|
103 |
return this.utils; |
|
104 |
} |
|
105 |
|
|
106 |
@Override |
|
107 |
public void execute(String actionCommand) { |
|
108 |
this.execute(actionCommand, null); |
|
109 |
} |
|
110 |
|
|
111 |
@Override |
|
112 |
public void execute(String command, Object[] args) { |
|
113 |
|
|
114 |
|
|
115 |
if( "tools-scripting-launcher".equalsIgnoreCase(command) ) { |
|
116 |
utils.runLauncher(); |
|
117 |
|
|
118 |
} else if( "tools-scripting-composer".equalsIgnoreCase(command) ) { |
|
119 |
utils.runComposer(); |
|
120 |
|
|
121 |
} else { |
|
122 |
utils.runScript(command, args); |
|
123 |
} |
|
124 |
} |
|
125 |
|
|
126 |
private void preloadPythonEngine() { |
|
127 |
ScriptingManager manager = (ScriptingManager) ScriptingLocator.getManager(); |
|
128 |
synchronized (manager) { |
|
129 |
String respath = "/scripting/langs/python/preload.py"; |
|
130 |
InputStream res = this.getClass().getResourceAsStream(respath); |
|
131 |
if( res != null ) { |
|
132 |
LOGGER.info("Scan for script engines"); |
|
133 |
List<String> lines; |
|
134 |
try { |
|
135 |
lines = IOUtils.readLines(res); |
|
136 |
String code = StringUtils.join(lines, "\n"); |
|
137 |
LOGGER.info("Preload python script engine"); |
|
138 |
Script script = manager.createScript( |
|
139 |
"preload", |
|
140 |
code, |
|
141 |
ScriptingManager.PYTHON_LANGUAGE_NAME |
|
142 |
); |
|
143 |
LOGGER.info("Preload python modules"); |
|
144 |
script.invokeFunction("main", null); |
|
145 |
|
|
146 |
} catch (Exception ex) { |
|
147 |
LOGGER.warn("Can't run preload script for python.", ex); |
|
148 |
} |
|
149 |
LOGGER.info("Preload of script engines finished"); |
|
150 |
} |
|
151 |
} |
|
152 |
} |
|
153 |
|
|
154 |
|
|
155 |
@Override |
|
156 |
public void postInitialize() { |
|
157 |
super.postInitialize(); |
|
158 |
|
|
159 |
PluginsManager pluginManager = PluginsLocator.getManager(); |
|
160 |
|
|
161 |
pluginManager.addStartupTask( |
|
162 |
"ExecuteAutorunScripts", |
|
163 |
utils.getAutorunScriptsOnStartup(pluginManager.getPluginsFolders()), |
|
164 |
false, |
|
165 |
200 |
|
166 |
); |
|
167 |
pluginManager.addStartupTask( |
|
168 |
"PostProcessArguments", |
|
169 |
new PostProcessArguments(), |
|
170 |
false, |
|
171 |
199 |
|
172 |
); |
|
173 |
|
|
174 |
|
|
175 |
Invocable initializer = new ScriptsInstallerInitializer(); |
|
176 |
initializer.call(this.getPlugin().getPluginName()); |
|
177 |
} |
|
178 |
|
|
179 |
@Override |
|
180 |
public boolean isEnabled() { |
|
181 |
return true; |
|
182 |
} |
|
183 |
|
|
184 |
@Override |
|
185 |
public boolean isVisible() { |
|
186 |
return true; |
|
187 |
} |
|
188 |
|
|
189 |
public static void add_classpath(URL url) { |
|
190 |
if( url==null ) { |
|
191 |
LOGGER.warn("Can't add to the plugin classloader a null URL."); |
|
192 |
return; |
|
193 |
} |
|
194 |
try { |
|
195 |
PluginsManager manager = PluginsLocator.getManager(); |
|
196 |
PluginServices thePlugin = manager.getPlugin(ScriptingExtension.class); |
|
197 |
PluginClassLoader loader = thePlugin.getClassLoader(); |
|
198 |
loader.addURL(url); |
|
199 |
} catch(Throwable th) { |
|
200 |
LOGGER.warn("Can't add the url '"+url.toString()+"' to the plugin classloader.",th); |
|
201 |
} |
|
202 |
} |
|
203 |
|
|
204 |
public static void add_classpath(File path) { |
|
205 |
if( path==null ) { |
|
206 |
LOGGER.warn("Can't create a url from a null file."); |
|
207 |
return; |
|
208 |
} |
|
209 |
try { |
|
210 |
URL url = path.toURI().toURL(); |
|
211 |
add_classpath(url); |
|
212 |
} catch (MalformedURLException ex) { |
|
213 |
LOGGER.warn("Can't create a url from the path '"+path+"'.", ex); |
|
214 |
} |
|
215 |
} |
|
216 |
|
|
217 |
public static void add_classpath(String path) { |
|
218 |
if( path==null ) { |
|
219 |
LOGGER.warn("Can't create a url from a null path."); |
|
220 |
return; |
|
221 |
} |
|
222 |
File f = new File(path); |
|
223 |
add_classpath(f); |
|
224 |
} |
|
225 |
|
|
226 |
@Override |
|
227 |
public PluginServices getPlugin() { |
|
228 |
PluginServices thePlugin = super.getPlugin(); |
|
229 |
if (thePlugin == null) { |
|
230 |
thePlugin = PluginsLocator.getManager().getPlugin(ScriptingExtension.class); |
|
231 |
this.setPlugin(thePlugin); |
|
232 |
} |
|
233 |
return thePlugin; |
|
234 |
} |
|
235 |
|
|
236 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.136/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/java/org/gvsig/scripting/app/extension/ScriptingUtils.java | ||
---|---|---|
1 |
package org.gvsig.scripting.app.extension; |
|
2 |
|
|
3 |
import java.awt.event.ActionEvent; |
|
4 |
import java.awt.event.ActionListener; |
|
5 |
import java.io.File; |
|
6 |
import java.io.IOException; |
|
7 |
import java.nio.file.FileVisitOption; |
|
8 |
import static java.nio.file.FileVisitOption.FOLLOW_LINKS; |
|
9 |
import java.nio.file.FileVisitResult; |
|
10 |
import java.nio.file.Files; |
|
11 |
import java.nio.file.Path; |
|
12 |
import java.nio.file.Paths; |
|
13 |
import java.nio.file.SimpleFileVisitor; |
|
14 |
import java.nio.file.attribute.BasicFileAttributes; |
|
15 |
import java.text.MessageFormat; |
|
16 |
import java.util.ArrayList; |
|
17 |
import java.util.Arrays; |
|
18 |
import java.util.Collections; |
|
19 |
import java.util.Comparator; |
|
20 |
import java.util.EnumSet; |
|
21 |
import java.util.List; |
|
22 |
import java.util.function.Predicate; |
|
23 |
import javax.swing.JOptionPane; |
|
24 |
import javax.swing.SwingUtilities; |
|
25 |
import org.apache.commons.io.FileUtils; |
|
26 |
import org.apache.commons.io.FilenameUtils; |
|
27 |
import org.apache.commons.io.IOCase; |
|
28 |
import org.apache.commons.lang3.BooleanUtils; |
|
29 |
import org.apache.commons.lang3.StringUtils; |
|
30 |
import org.gvsig.andami.PluginServices; |
|
31 |
import org.gvsig.andami.PluginsLocator; |
|
32 |
import org.gvsig.andami.PluginsManager; |
|
33 |
import org.gvsig.scripting.DataFolderFound; |
|
34 |
import org.gvsig.scripting.ScriptingBaseScript; |
|
35 |
import org.gvsig.scripting.ScriptingFolder; |
|
36 |
import org.gvsig.scripting.ScriptingLocator; |
|
37 |
import org.gvsig.scripting.ScriptingManager; |
|
38 |
import org.gvsig.scripting.ScriptingScript; |
|
39 |
import org.gvsig.scripting.ScriptingUnit; |
|
40 |
import org.gvsig.scripting.app.extension.messagewait.MessageWait; |
|
41 |
import org.gvsig.scripting.swing.api.JScriptingComposer; |
|
42 |
import org.gvsig.scripting.swing.api.ScriptingSwingLocator; |
|
43 |
import org.gvsig.scripting.swing.api.ScriptingUIManager; |
|
44 |
import static org.gvsig.scripting.swing.api.ScriptingUIManager.SCRIPT_COMPOSER_AUTORUN; |
|
45 |
import org.gvsig.tools.ToolsLocator; |
|
46 |
import org.gvsig.tools.dynobject.DynObject; |
|
47 |
import org.gvsig.tools.exception.BaseException; |
|
48 |
import org.gvsig.tools.i18n.I18nManager; |
|
49 |
import org.gvsig.tools.packageutils.PackageManager; |
|
50 |
import org.gvsig.tools.packageutils.Version; |
|
51 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
52 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
|
53 |
import org.gvsig.tools.swing.api.windowmanager.Dialog; |
|
54 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
55 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2; |
|
56 |
import org.gvsig.tools.swing.impl.windowmanager.DefaultWindowManager; |
|
57 |
import org.gvsig.tools.task.SimpleTaskStatus; |
|
58 |
import org.gvsig.tools.visitor.VisitCanceledException; |
|
59 |
import org.gvsig.tools.visitor.Visitor; |
|
60 |
import org.slf4j.Logger; |
|
61 |
import org.slf4j.LoggerFactory; |
|
62 |
import org.gvsig.tools.util.FolderSet; |
|
63 |
import org.gvsig.tools.util.impl.DefaultFolderSet; |
|
64 |
/** |
|
65 |
* |
|
66 |
* @author jjdelcerro |
|
67 |
*/ |
|
68 |
@SuppressWarnings("UseSpecificCatch") |
|
69 |
public class ScriptingUtils { |
|
70 |
|
|
71 |
public static final String SKIP_AUTORUNS = "skipAutoruns"; |
|
72 |
|
|
73 |
private static final Logger LOGGER = LoggerFactory.getLogger(ScriptingExtension.class); |
|
74 |
|
|
75 |
private boolean executingAutorunScripts = false; |
|
76 |
private static boolean composer_initialized = false; |
|
77 |
private final MessageWait message; |
|
78 |
|
|
79 |
/* |
|
80 |
* la funcion log y las constantes estan pensadas para usarlas desde los scripts. |
|
81 |
*/ |
|
82 |
public static final int INFO = 0; |
|
83 |
public static final int TRACE = 1; |
|
84 |
public static final int WARN = 2; |
|
85 |
public static final int ERROR = 3; |
|
86 |
|
|
87 |
public static void log(String message) { |
|
88 |
log(INFO, message, null); |
|
89 |
} |
|
90 |
|
|
91 |
public static void log(int level, String message) { |
|
92 |
log(level, message, null); |
|
93 |
} |
|
94 |
|
|
95 |
public static void log(int level, String message, Throwable th) { |
|
96 |
switch( level ) { |
|
97 |
case TRACE: |
|
98 |
LOGGER.trace(message, th); |
|
99 |
break; |
|
100 |
case ERROR: |
|
101 |
LOGGER.error(message, th); |
|
102 |
break; |
|
103 |
case WARN: |
|
104 |
LOGGER.warn(message, th); |
|
105 |
break; |
|
106 |
default: |
|
107 |
case INFO: |
|
108 |
LOGGER.info(message, th); |
|
109 |
break; |
|
110 |
} |
|
111 |
} |
|
112 |
private String appversion; |
|
113 |
private File pluginHomeFolder; |
|
114 |
|
|
115 |
public ScriptingUtils() { |
|
116 |
message = new MessageWait(); |
|
117 |
} |
|
118 |
|
|
119 |
public static File getScriptsHomeFolder(File pluginHomeFolder, String appversion) { |
|
120 |
File scriptsHomeFolder; |
|
121 |
File f = FileUtils.getFile(pluginHomeFolder, "scripts-folder.txt"); |
|
122 |
if( f.exists() ) { |
|
123 |
try { |
|
124 |
List<String> lines = FileUtils.readLines(f); |
|
125 |
for( String line : lines ) { |
|
126 |
line = line.trim(); |
|
127 |
if( !line.startsWith("#") ) { |
|
128 |
scriptsHomeFolder = new File(line); |
|
129 |
if( !scriptsHomeFolder.isAbsolute() ) { |
|
130 |
scriptsHomeFolder = new File(pluginHomeFolder, line); |
|
131 |
} |
|
132 |
scriptsHomeFolder = new File( |
|
133 |
FilenameUtils.normalizeNoEndSeparator( |
|
134 |
scriptsHomeFolder.getAbsolutePath(), |
|
135 |
true |
|
136 |
) |
|
137 |
); |
|
138 |
if( scriptsHomeFolder.exists() ) { |
|
139 |
return scriptsHomeFolder; |
|
140 |
} |
|
141 |
} |
|
142 |
} |
|
143 |
} catch (IOException ex) { |
|
144 |
} |
|
145 |
} else { |
|
146 |
try { |
|
147 |
FileUtils.touch(f); |
|
148 |
} catch (IOException ex) { |
|
149 |
} |
|
150 |
} |
|
151 |
scriptsHomeFolder = FileUtils.getFile(pluginHomeFolder, appversion) ; |
|
152 |
return scriptsHomeFolder; |
|
153 |
} |
|
154 |
|
|
155 |
public void initializaPaths(List<File> pluginsFolder, File installFolder, File pluginHoneFolder, String appversion) { |
|
156 |
|
|
157 |
this.appversion = appversion; |
|
158 |
this.pluginHomeFolder = pluginHoneFolder; |
|
159 |
ScriptingManager manager = ScriptingLocator.getManager(); |
|
160 |
manager.setHomeFolder(getScriptsHomeFolder(pluginHoneFolder, appversion)); |
|
161 |
|
|
162 |
ScriptingFolder folder = manager.createLink( |
|
163 |
"Common", |
|
164 |
manager.getUserFolder(), |
|
165 |
"../../scripts" |
|
166 |
); |
|
167 |
folder.setProperty(ScriptingUtils.SKIP_AUTORUNS, BooleanUtils.toStringTrueFalse(true)); |
|
168 |
folder.save(); |
|
169 |
// manager.createLink( |
|
170 |
// "Previous version", |
|
171 |
// manager.getUserFolder(), |
|
172 |
// "../../../org.gvsig.scripting.app.extension/scripts" |
|
173 |
// ); |
|
174 |
|
|
175 |
List<File> pluginsFolders = new ArrayList<>(); |
|
176 |
for( File f : pluginsFolder ) { |
|
177 |
pluginsFolders.addAll(Arrays.asList(f.listFiles())); |
|
178 |
} |
|
179 |
|
|
180 |
for( File pluginFolder : pluginsFolders ) { |
|
181 |
File scriptsFolder = new File(pluginFolder, "scripting/scripts"); |
|
182 |
if( scriptsFolder.exists() ) { |
|
183 |
manager.registerSystemFolder(pluginFolder.getName(), scriptsFolder); |
|
184 |
} |
|
185 |
File libFolder = new File(pluginFolder, "scripting/lib"); |
|
186 |
if( libFolder.exists() ) { |
|
187 |
manager.addLibFolder(libFolder); |
|
188 |
} |
|
189 |
} |
|
190 |
manager.setPackagesFolder(installFolder); |
|
191 |
|
|
192 |
File localAddonRepositoryFolder = new File(manager.getRootUserFolder(), "addons"); |
|
193 |
if( !localAddonRepositoryFolder.exists() ) { |
|
194 |
try { |
|
195 |
FileUtils.forceMkdir(localAddonRepositoryFolder); |
|
196 |
} catch (IOException ex) { |
|
197 |
LOGGER.info("Can't create addons folder in '" + localAddonRepositoryFolder.getAbsolutePath() + "'.", ex); |
|
198 |
} |
|
199 |
} |
|
200 |
File initAddonFile = new File(localAddonRepositoryFolder, "__init__.py"); |
|
201 |
if( !initAddonFile.exists() ) { |
|
202 |
try { |
|
203 |
FileUtils.touch(initAddonFile); |
|
204 |
} catch (IOException ex) { |
|
205 |
LOGGER.info("Can't create addons __init__ file in '" + localAddonRepositoryFolder.getAbsolutePath() + "'.", ex); |
|
206 |
} |
|
207 |
} |
|
208 |
} |
|
209 |
|
|
210 |
|
|
211 |
public void runScript(String name, Object[] args) { |
|
212 |
if( StringUtils.isBlank(name) ) { |
|
213 |
return; |
|
214 |
} |
|
215 |
ScriptingUIManager uimanager = ScriptingSwingLocator.getUIManager(); |
|
216 |
WindowManager winmanager = ToolsSwingLocator.getWindowManager(); |
|
217 |
ScriptingBaseScript script = uimanager.getManager().getScript(name); |
|
218 |
if( script != null ) { |
|
219 |
script.run(args); |
|
220 |
} else { |
|
221 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
222 |
dialogs.messageDialog( |
|
223 |
"Can't locate script '" + name + "'.", |
|
224 |
"ScriptLaunch", |
|
225 |
JOptionPane.OK_OPTION |
|
226 |
); |
|
227 |
} |
|
228 |
} |
|
229 |
|
|
230 |
public void runLauncher() { |
|
231 |
ScriptingUIManager uimanager = ScriptingSwingLocator.getUIManager(); |
|
232 |
WindowManager winmanager = ToolsSwingLocator.getWindowManager(); |
|
233 |
winmanager.showWindow(uimanager.createLauncher().asJComponent(), uimanager.getTranslation("Scripting_Launcher"), WindowManager.MODE.TOOL); |
|
234 |
} |
|
235 |
|
|
236 |
public void runComposer() { |
|
237 |
PluginsManager pluginsManager = PluginsLocator.getPluginsManager(); |
|
238 |
PluginServices plugin = pluginsManager.getPlugin(ScriptingExtension.class); |
|
239 |
if( plugin!=null ) { |
|
240 |
DynObject preferences = plugin.getPluginProperties(); |
|
241 |
if( preferences!=null ) { |
|
242 |
Boolean composerUseHisWindowManager = (Boolean) preferences.getDynValue("ComposerUseHisWindowManager"); |
|
243 |
if( composerUseHisWindowManager!=null && composerUseHisWindowManager ) { |
|
244 |
DefaultWindowManager winmanager = new DefaultWindowManager(); |
|
245 |
ScriptingUIManager uimanager = ScriptingSwingLocator.getUIManager(); |
|
246 |
uimanager.setWindowManager(winmanager); |
|
247 |
} |
|
248 |
} |
|
249 |
} |
|
250 |
|
|
251 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
252 |
message.showMessage( |
|
253 |
i18n.getTranslation("_notice"), |
|
254 |
i18n.getTranslation("_Initializing_the_scripting_plugin_Xhorizontal_ellipsisX") + "\n" |
|
255 |
+ i18n.getTranslation("_Waiting_to_terminate"), |
|
256 |
new MessageWait.WaitingCondition() { |
|
257 |
private Thread th = null; |
|
258 |
|
|
259 |
@Override |
|
260 |
public boolean stopWaiting() { |
|
261 |
if (executingAutorunScripts) { |
|
262 |
return false; |
|
263 |
} |
|
264 |
if (composer_initialized) { |
|
265 |
return true; |
|
266 |
} |
|
267 |
if (th == null) { |
|
268 |
th = new Thread(new ExecuteScriptsFromScriptingFolders(null, "scautorun", SCRIPT_COMPOSER_AUTORUN), "StartupScriptingComposer"); |
|
269 |
th.start(); |
|
270 |
} |
|
271 |
return false; |
|
272 |
} |
|
273 |
}, |
|
274 |
new Runnable() { |
|
275 |
@Override |
|
276 |
public void run() { |
|
277 |
showScriptingComposer(); |
|
278 |
} |
|
279 |
} |
|
280 |
); |
|
281 |
|
|
282 |
} |
|
283 |
|
|
284 |
public Runnable getAutorunScriptsOnStartup(List<File> pluginsFolders) { |
|
285 |
return new ExecuteAutorunScriptsOnStartup(pluginsFolders); |
|
286 |
} |
|
287 |
|
|
288 |
private void showScriptingComposer() { |
|
289 |
ScriptingUIManager uimanager = ScriptingSwingLocator.getUIManager(); |
|
290 |
JScriptingComposer composer = uimanager.createComposer(); |
|
291 |
uimanager.showWindow( |
|
292 |
composer.asJComponent(), |
|
293 |
uimanager.getTranslation("Scripting_Composer") |
|
294 |
); |
|
295 |
} |
|
296 |
|
|
297 |
private class ExecuteScriptsFromScriptingFolders extends AbstractExecuteScripts { |
|
298 |
|
|
299 |
public ExecuteScriptsFromScriptingFolders(List<File> pluginsFolders, String title, String patternName) { |
|
300 |
super(pluginsFolders, title, patternName); |
|
301 |
} |
|
302 |
|
|
303 |
@Override |
|
304 |
public void run() { |
|
305 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
306 |
SimpleTaskStatus status = ToolsLocator.getTaskStatusManager().createDefaultSimpleTaskStatus("Scripts startup"); |
|
307 |
status.setIndeterminate(); |
|
308 |
status.setAutoremove(true); |
|
309 |
status.add(); |
|
310 |
final I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
311 |
try { |
|
312 |
LOGGER.info("Searching "+title+" scripts..."); |
|
313 |
dialogs.message( |
|
314 |
i18nManager.getTranslation("_Searching_autorun_scripts_Xhorizontal_ellipsisX"), |
|
315 |
JOptionPane.INFORMATION_MESSAGE |
|
316 |
); |
|
317 |
ScriptingManager manager = ScriptingLocator.getManager(); |
|
318 |
final List<ScriptingScript> scripts = new ArrayList<>(); |
|
319 |
|
|
320 |
Visitor visitor = new Visitor() { |
|
321 |
@Override |
|
322 |
public void visit(Object o) throws VisitCanceledException, BaseException { |
|
323 |
ScriptingUnit unit = (ScriptingUnit) o; |
|
324 |
if( unit instanceof ScriptingScript && |
|
325 |
FilenameUtils.wildcardMatch(unit.getName(), patternName, IOCase.INSENSITIVE) ) { |
|
326 |
ScriptingScript script = (ScriptingScript) unit; |
|
327 |
if( script.isEnabled() ) { |
|
328 |
scripts.add(script); |
|
329 |
} else { |
|
330 |
LOGGER.info("Skip "+title+" script '" + script.getFile().getAbsolutePath() + "'."); |
|
331 |
} |
|
332 |
} |
|
333 |
} |
|
334 |
}; |
|
335 |
Predicate<ScriptingUnit> includeFilter = new Predicate<ScriptingUnit>() { |
|
336 |
@Override |
|
337 |
public boolean test(ScriptingUnit unit) { |
|
338 |
if( unit instanceof ScriptingFolder ) { |
|
339 |
return !BooleanUtils.toBoolean(unit.getProperty(SKIP_AUTORUNS)); |
|
340 |
} |
|
341 |
return false; |
|
342 |
} |
|
343 |
}; |
|
344 |
manager.getSystemFolder().accept(visitor, includeFilter); |
|
345 |
manager.getUserFolder().accept(visitor, includeFilter); |
|
346 |
sortScripts(scripts); |
|
347 |
executeScripts(scripts, status); |
|
348 |
} catch(Throwable th) { |
|
349 |
|
|
350 |
} finally { |
|
351 |
composer_initialized = true; |
|
352 |
LOGGER.info("Running "+title+" scripts terminated."); |
|
353 |
dialogs.message("", JOptionPane.INFORMATION_MESSAGE); |
|
354 |
status.terminate(); |
|
355 |
} |
|
356 |
} |
|
357 |
} |
|
358 |
|
|
359 |
public class ExecuteAutorunScriptsOnStartup implements Runnable { |
|
360 |
|
|
361 |
private final List<File> pluginsFolders; |
|
362 |
|
|
363 |
public ExecuteAutorunScriptsOnStartup(List<File> pluginsFolders) { |
|
364 |
this.pluginsFolders = pluginsFolders; |
|
365 |
} |
|
366 |
|
|
367 |
@Override |
|
368 |
public void run() { |
|
369 |
Runnable process = new ExecuteScriptsFromFilesystem( |
|
370 |
this.pluginsFolders, |
|
371 |
"autorun", |
|
372 |
"autorun.inf" |
|
373 |
); |
|
374 |
process.run(); |
|
375 |
} |
|
376 |
} |
|
377 |
|
|
378 |
private abstract class AbstractExecuteScripts implements Runnable { |
|
379 |
|
|
380 |
protected String patternName; |
|
381 |
protected String title; |
|
382 |
private final List<File> pluginsFolders; |
|
383 |
|
|
384 |
public AbstractExecuteScripts(List<File> pluginsFolders, String title, String patternName) { |
|
385 |
if( pluginsFolders==null ) { |
|
386 |
this.pluginsFolders = Collections.EMPTY_LIST; |
|
387 |
} else { |
|
388 |
this.pluginsFolders = pluginsFolders; |
|
389 |
} |
|
390 |
this.patternName = patternName; |
|
391 |
this.title = title; |
|
392 |
} |
|
393 |
|
|
394 |
protected List<File> getPluginsFolders() { |
|
395 |
return this.pluginsFolders; |
|
396 |
} |
|
397 |
|
|
398 |
private String getScriptOrderKey(ScriptingBaseScript o) { |
|
399 |
int groupOrder = 500; |
|
400 |
String groupName = "default"; |
|
401 |
int scriptOrder = 500; |
|
402 |
String s = o.getProperty("autorun.group.order"); |
|
403 |
if (s != null) { |
|
404 |
try { |
|
405 |
groupOrder = Integer.parseInt(s); |
|
406 |
} catch (Exception ex) { |
|
407 |
// Do nothing. |
|
408 |
} |
|
409 |
} |
|
410 |
s = o.getProperty("autorun.group.name"); |
|
411 |
if (s != null) { |
|
412 |
groupName = s; |
|
413 |
} |
|
414 |
s = o.getProperty("autorun.order"); |
|
415 |
if (s != null) { |
|
416 |
try { |
|
417 |
scriptOrder = Integer.parseInt(s); |
|
418 |
} catch (Exception ex) { |
|
419 |
// Do nothing. |
|
420 |
} |
|
421 |
} |
|
422 |
String key = MessageFormat.format( |
|
423 |
"{0,number,000000}.{1}.{2,number,000000}", |
|
424 |
groupOrder, |
|
425 |
groupName, |
|
426 |
scriptOrder |
|
427 |
); |
|
428 |
return key; |
|
429 |
} |
|
430 |
|
|
431 |
protected void sortScripts(List<ScriptingScript> scripts) { |
|
432 |
Collections.sort(scripts, new Comparator<ScriptingBaseScript>() { |
|
433 |
|
|
434 |
@Override |
|
435 |
public int compare(ScriptingBaseScript o1, ScriptingBaseScript o2) { |
|
436 |
return getScriptOrderKey(o2).compareToIgnoreCase(getScriptOrderKey(o1)); |
|
437 |
} |
|
438 |
}); |
|
439 |
} |
|
440 |
|
|
441 |
protected void executeScripts(List<ScriptingScript> scripts, SimpleTaskStatus status) { |
|
442 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
443 |
final I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
444 |
if (scripts != null && !scripts.isEmpty()) { |
|
445 |
if (status != null) { |
|
446 |
status.setRangeOfValues(0, scripts.size()); |
|
447 |
} |
|
448 |
int n = 0; |
|
449 |
for (ScriptingBaseScript script : scripts) { |
|
450 |
if (status != null) { |
|
451 |
status.setCurValue(n++); |
|
452 |
} |
|
453 |
try { |
|
454 |
LOGGER.info("running " + title + " script '" + script.getFile().getAbsolutePath() + "' (" + getScriptOrderKey(script) + ", " + script.getIsolationGroup() + ")."); |
|
455 |
dialogs.message( |
|
456 |
i18nManager.getTranslation( |
|
457 |
"_Starting_XnameX", |
|
458 |
new String[]{ |
|
459 |
script.getFile().getParentFile().getName()} |
|
460 |
), |
|
461 |
JOptionPane.INFORMATION_MESSAGE |
|
462 |
); |
|
463 |
} catch (Exception ex) { |
|
464 |
// Ignore it |
|
465 |
} |
|
466 |
try { |
|
467 |
// Hacemos un reload por si un sript deshabilito a otro. |
|
468 |
script.reload(); |
|
469 |
if( script.isEnabled() ) { |
|
470 |
script.run(); |
|
471 |
} else { |
|
472 |
LOGGER.info("Skip " + title + " script '" + script.getFile().getAbsolutePath() + "' (" + getScriptOrderKey(script) + ", " + script.getIsolationGroup() + ")."); |
|
473 |
} |
|
474 |
} catch (Exception ex) { |
|
475 |
LOGGER.warn("Can't execute " + title + " from '" + script.getFile().getAbsolutePath() + "'.", ex); |
|
476 |
} |
|
477 |
} |
|
478 |
} |
|
479 |
|
|
480 |
} |
|
481 |
} |
|
482 |
|
|
483 |
private class ExecuteScriptsFromFilesystem extends AbstractExecuteScripts { |
|
484 |
|
|
485 |
public ExecuteScriptsFromFilesystem(List<File> pluginsFolder, String title, String patternName) { |
|
486 |
super(pluginsFolder, title, patternName); |
|
487 |
} |
|
488 |
|
|
489 |
@Override |
|
490 |
public void run() { |
|
491 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
492 |
executingAutorunScripts = true; |
|
493 |
try { |
|
494 |
final ScriptingManager manager = ScriptingLocator.getManager(); |
|
495 |
manager.loadEngines(); |
|
496 |
|
|
497 |
// final PluginsManager pluginManager = PluginsLocator.getManager(); |
|
498 |
final I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
499 |
|
|
500 |
final List<ScriptingScript> scripts = new ArrayList<>(); |
|
501 |
|
|
502 |
List<File> pluginsFolders = new ArrayList<>(); |
|
503 |
for (File pluginsFolders2 : this.getPluginsFolders()) { |
|
504 |
for (File pluginFolder : pluginsFolders2.listFiles()) { |
|
505 |
File f = FileUtils.getFile(pluginFolder, "scripting", "scripts"); |
|
506 |
if (f.exists()) { |
|
507 |
pluginsFolders.add(f); |
|
508 |
} |
|
509 |
} |
|
510 |
} |
|
511 |
|
|
512 |
dialogs.message( |
|
513 |
i18nManager.getTranslation("_Searching_autorun_scripts_Xhorizontal_ellipsisX"), |
|
514 |
JOptionPane.INFORMATION_MESSAGE |
|
515 |
); |
|
516 |
|
|
517 |
SimpleFileVisitor<Path> visitor = new SimpleFileVisitor<Path>() { |
|
518 |
@Override |
|
519 |
public FileVisitResult visitFile(Path path, BasicFileAttributes bfa) throws IOException { |
|
520 |
File file = path.toFile(); |
|
521 |
if (FilenameUtils.wildcardMatch(file.getName(), patternName, IOCase.INSENSITIVE)) { |
|
522 |
if (file.exists()) { |
|
523 |
ScriptingScript script = (ScriptingScript) manager.getScript(file); |
|
524 |
if (script.isEnabled()) { |
|
525 |
scripts.add(script); |
|
526 |
} else { |
|
527 |
LOGGER.info("Skip " + title + " script '" + file.getAbsolutePath() + "'."); |
|
528 |
} |
|
529 |
} |
|
530 |
} |
|
531 |
return FileVisitResult.CONTINUE; |
|
532 |
} |
|
533 |
}; |
|
534 |
try { |
|
535 |
EnumSet<FileVisitOption> opts = EnumSet.of(FOLLOW_LINKS); |
|
536 |
for (File pluginFolder : pluginsFolders) { |
|
537 |
Files.walkFileTree(Paths.get(pluginFolder.toURI()), opts, Integer.MAX_VALUE, visitor); |
|
538 |
} |
|
539 |
Files.walkFileTree(Paths.get(manager.getRootUserFolder().toURI()), opts, Integer.MAX_VALUE, visitor); |
|
540 |
List<ScriptingFolder> folders = manager.getAlternativeUserFolders(); |
|
541 |
for (ScriptingFolder folder : folders) { |
|
542 |
Files.walkFileTree(Paths.get(folder.getFile().toURI()), opts, Integer.MAX_VALUE, visitor); |
|
543 |
} |
|
544 |
} catch (Exception ex) { |
|
545 |
LOGGER.warn("Can't execute " + title + " in home.", ex); |
|
546 |
} |
|
547 |
sortScripts(scripts); |
|
548 |
executeScripts(scripts, null); |
|
549 |
|
|
550 |
} finally { |
|
551 |
LOGGER.info("Running " + title + " scripts terminated."); |
|
552 |
dialogs.message("", JOptionPane.INFORMATION_MESSAGE); |
|
553 |
executingAutorunScripts = false; |
|
554 |
} |
|
555 |
checkDataFoldersVersions(); |
|
556 |
} |
|
557 |
|
|
558 |
} |
|
559 |
|
|
560 |
private void checkDataFoldersVersions() { |
|
561 |
final ScriptingManager manager = ScriptingLocator.getManager(); |
|
562 |
PackageManager versionFactory = ToolsLocator.getPackageManager(); |
|
563 |
Version currentVersion = versionFactory.createVersion(this.appversion); |
|
564 |
FolderSet folders = new DefaultFolderSet(); |
|
565 |
folders.add(this.pluginHomeFolder); |
|
566 |
final List<DataFolderFound> dataFoldersFound = manager.searchOldVersions(currentVersion, folders); |
|
567 |
if( dataFoldersFound == null || dataFoldersFound.isEmpty() ) { |
|
568 |
return; |
|
569 |
} |
|
570 |
Runnable askUser = new Runnable() { |
|
571 |
@Override |
|
572 |
public void run() { |
|
573 |
WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
|
574 |
final DataFoldersRecoverPanel panel = new DataFoldersRecoverPanel(dataFoldersFound); |
|
575 |
final Dialog dialog = winManager.createDialog( |
|
576 |
panel, |
|
577 |
"Recuperacion de preferencias", |
|
578 |
null, |
|
579 |
WindowManager_v2.BUTTONS_OK_CANCEL |
|
580 |
); |
|
581 |
dialog.addActionListener(new ActionListener() { |
|
582 |
@Override |
|
583 |
public void actionPerformed(ActionEvent e) { |
|
584 |
if (dialog.getAction() == WindowManager_v2.BUTTON_OK) { |
|
585 |
List<DataFolderFound> toRestore = panel.getSelectedDataFolders(); |
|
586 |
for (DataFolderFound dataFolderFound : dataFoldersFound) { |
|
587 |
if (toRestore.contains(dataFolderFound)) { |
|
588 |
dataFolderFound.restore(); |
|
589 |
} else { |
|
590 |
dataFolderFound.leave(); |
|
591 |
} |
|
592 |
} |
|
593 |
} |
|
594 |
} |
|
595 |
}); |
|
596 |
dialog.show(WindowManager.MODE.WINDOW); |
|
597 |
} |
|
598 |
}; |
|
599 |
if( SwingUtilities.isEventDispatchThread() ) { |
|
600 |
askUser.run(); |
|
601 |
} else { |
|
602 |
SwingUtilities.invokeLater(askUser); |
|
603 |
} |
|
604 |
} |
|
605 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.136/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/java/org/gvsig/scripting/app/extension/ScriptingMain.java | ||
---|---|---|
1 |
package org.gvsig.scripting.app.extension; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.net.URL; |
|
5 |
import java.util.ArrayList; |
|
6 |
import java.util.HashMap; |
|
7 |
import java.util.List; |
|
8 |
import java.util.Map; |
|
9 |
import javax.swing.UIManager; |
|
10 |
import org.apache.commons.cli.CommandLine; |
|
11 |
import org.apache.commons.cli.CommandLineParser; |
|
12 |
import org.apache.commons.cli.Options; |
|
13 |
import org.apache.commons.cli.PosixParser; |
|
14 |
import org.apache.commons.io.FileUtils; |
|
15 |
import org.gvsig.about.AboutLocator; |
|
16 |
import org.gvsig.about.AboutManager; |
|
17 |
import org.gvsig.scripting.ScriptingManager; |
|
18 |
import org.gvsig.scripting.swing.api.ScriptingSwingLocator; |
|
19 |
import org.gvsig.scripting.swing.api.ScriptingUIManager; |
|
20 |
import org.gvsig.tools.ToolsLocator; |
|
21 |
import org.gvsig.tools.exception.BaseException; |
|
22 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
23 |
import org.gvsig.tools.packageutils.PackageInfo; |
|
24 |
import org.gvsig.tools.packageutils.PackageManager; |
|
25 |
import org.gvsig.tools.packageutils.Version; |
|
26 |
|
|
27 |
/** |
|
28 |
* |
|
29 |
* @author jjdelcerro |
|
30 |
*/ |
|
31 |
public class ScriptingMain { |
|
32 |
|
|
33 |
private File applicationFolder = null; |
|
34 |
private Version applicacionVersion = null; |
|
35 |
private List<File> pluginsFolder = null; |
|
36 |
private File applicationHomeFolder; |
|
37 |
private File installFolder; |
|
38 |
private int applicacionBuildNumber; |
|
39 |
|
|
40 |
private ScriptingUtils utils; |
|
41 |
|
|
42 |
public static void main(String args[]) throws Exception { |
|
43 |
ScriptingMain main = new ScriptingMain(); |
|
44 |
main.doMain(args); |
|
45 |
} |
|
46 |
|
|
47 |
public File getApplicationFolder() { |
|
48 |
if (applicationFolder == null) { |
|
49 |
applicationFolder = new File(System.getProperty("user.dir")); |
|
50 |
} |
|
51 |
return applicationFolder; |
|
52 |
} |
|
53 |
|
|
54 |
public File getApplicationHomeFolder() { |
|
55 |
if (applicationHomeFolder == null) { |
|
56 |
applicationHomeFolder = new File(System.getProperty("user.home")); |
|
57 |
} |
|
58 |
return applicationHomeFolder; |
|
59 |
} |
|
60 |
|
|
61 |
public File getInstallFolder() { |
|
62 |
if (installFolder == null) { |
|
63 |
installFolder = FileUtils.getFile(getApplicationFolder(), "install"); |
|
64 |
} |
|
65 |
return this.installFolder; |
Also available in: Unified diff