Revision 41279
trunk/org.gvsig.desktop/pom.xml | ||
---|---|---|
1916 | 1916 |
|
1917 | 1917 |
def log; |
1918 | 1918 |
|
1919 |
private String user;
|
|
1920 |
private String password;
|
|
1921 |
private Object sardine;
|
|
1919 |
private String user;
|
|
1920 |
private String password;
|
|
1921 |
private Object sardine;
|
|
1922 | 1922 |
|
1923 | 1923 |
public WebDAVClient(log) { |
1924 | 1924 |
this.log = log; |
1925 | 1925 |
} |
1926 | 1926 |
|
1927 |
public void login(String user, String password) {
|
|
1928 |
log.info("[WEBDAV] login as '"+user+"'.");
|
|
1929 |
def SardineFactory
|
|
1930 |
try {
|
|
1931 |
SardineFactory = "com.github.sardine.SardineFactory" as Class
|
|
1932 |
} catch (Exception ex) {
|
|
1933 |
log.error("[WEBDAV] can't get SardineFactory.",ex);
|
|
1934 |
}
|
|
1935 |
this.user = user;
|
|
1936 |
this.password = password;
|
|
1937 |
this.sardine = SardineFactory.begin(this.user,this.password);
|
|
1938 |
}
|
|
1927 |
public void login(String user, String password) {
|
|
1928 |
log.info("[WEBDAV] login as '"+user+"'.");
|
|
1929 |
def SardineFactory
|
|
1930 |
try {
|
|
1931 |
SardineFactory = "com.github.sardine.SardineFactory" as Class
|
|
1932 |
} catch (Exception ex) {
|
|
1933 |
log.error("[WEBDAV] can't get SardineFactory.",ex);
|
|
1934 |
}
|
|
1935 |
this.user = user;
|
|
1936 |
this.password = password;
|
|
1937 |
this.sardine = SardineFactory.begin(this.user,this.password);
|
|
1938 |
}
|
|
1939 | 1939 |
|
1940 |
public void login() {
|
|
1941 |
log.info("[WEBDAV] login as guest");
|
|
1942 |
this.sardine = SardineFactory.begin();
|
|
1943 |
}
|
|
1940 |
public void login() {
|
|
1941 |
log.info("[WEBDAV] login as guest");
|
|
1942 |
this.sardine = SardineFactory.begin();
|
|
1943 |
}
|
|
1944 | 1944 |
|
1945 |
public boolean exists(String url) throws Exception {
|
|
1946 |
return sardine.exists(url);
|
|
1947 |
}
|
|
1945 |
public boolean exists(String url) throws Exception {
|
|
1946 |
return sardine.exists(url);
|
|
1947 |
}
|
|
1948 | 1948 |
|
1949 |
public void makedirs(String url) throws Exception { |
|
1950 |
log.info("[WEBDAV] makedirs '"+url+"'."); |
|
1951 |
URL u = new URL(url); |
|
1952 |
String[] x = u.getPath().split("/"); |
|
1953 |
String path = ""; |
|
1954 |
for( int i=1; i<x.length; i++ ) { path = path + "/" + x[i]; URL t = new URL(u,path); mkdir(t.toString()); } } public void mkdir(String url) throws Exception { |
|
1955 |
if( ! exists(url) ) { |
|
1956 |
log.info("[WEBDAV] mkdir '"+url+"'."); |
|
1957 |
sardine.createDirectory(url); |
|
1958 |
} |
|
1959 |
} |
|
1949 |
public void makedirs(String url) throws Exception { |
|
1950 |
log.info("[WEBDAV] makedirs '"+url+"'."); |
|
1951 |
URL u = new URL(url); |
|
1952 |
String[] x = u.getPath().split("/"); |
|
1953 |
String path = ""; |
|
1954 |
for( int i=1; i<x.length; i++ ) { |
|
1955 |
path = path + "/" + x[i]; |
|
1956 |
URL t = new URL(u,path); |
|
1957 |
mkdir(t.toString()); |
|
1958 |
} |
|
1959 |
} |
|
1960 |
|
|
1961 |
public void mkdir(String url) throws Exception { |
|
1962 |
if( ! exists(url) ) { |
|
1963 |
log.info("[WEBDAV] mkdir '"+url+"'."); |
|
1964 |
sardine.createDirectory(url); |
|
1965 |
} |
|
1966 |
} |
|
1960 | 1967 |
|
1961 |
public void put(String source, String target) throws Exception {
|
|
1962 |
log.info("[WEBDAV] put '" + source + "' to '" + target + "'...");
|
|
1963 |
InputStream fis = new FileInputStream(new File(source));
|
|
1964 |
sardine.put(target, fis);
|
|
1965 |
log.info("[WEBDAV] put ok.");
|
|
1966 |
}
|
|
1968 |
public void put(String source, String target) throws Exception {
|
|
1969 |
log.info("[WEBDAV] put '" + source + "' to '" + target + "'...");
|
|
1970 |
InputStream fis = new FileInputStream(new File(source));
|
|
1971 |
sardine.put(target, fis);
|
|
1972 |
log.info("[WEBDAV] put ok.");
|
|
1973 |
}
|
|
1967 | 1974 |
|
1968 |
public List list(String url) throws Exception {
|
|
1969 |
List resources = sardine.list(url);
|
|
1970 |
return resources;
|
|
1971 |
}
|
|
1975 |
public List list(String url) throws Exception {
|
|
1976 |
List resources = sardine.list(url);
|
|
1977 |
return resources;
|
|
1978 |
}
|
|
1972 | 1979 |
} |
1973 | 1980 |
|
1974 | 1981 |
|
1975 | 1982 |
if( project.properties["deploy-package"] != null ) { |
1976 |
if( project.properties["gvsig.install.plugin.package"]=="true" ) {
|
|
1977 |
poolURL = project.properties["gvsig.package.info.poolURL"];
|
|
1978 |
if( poolURL[-1] != "/" ) {
|
|
1979 |
poolURL = poolURL + "/";
|
|
1980 |
}
|
|
1981 |
targetPath = poolURL + project.properties["gvsig.package.info.code"];
|
|
1982 |
log.info("Deploy plugin package to '"+targetPath+"'.");
|
|
1983 |
if( project.properties["gvsig.install.plugin.package"]=="true" ) {
|
|
1984 |
poolURL = project.properties["gvsig.package.info.poolURL"];
|
|
1985 |
if( poolURL[-1] != "/" ) {
|
|
1986 |
poolURL = poolURL + "/";
|
|
1987 |
}
|
|
1988 |
targetPath = poolURL + project.properties["gvsig.package.info.code"];
|
|
1989 |
log.info("Deploy plugin package to '"+targetPath+"'.");
|
|
1983 | 1990 |
|
1984 |
pkgname = "gvSIG-desktop-" + |
|
1985 |
project.properties["gvsig.package.info.gvSIGVersion"] + "-" + |
|
1986 |
project.properties["gvsig.package.info.code"] + "-" + |
|
1987 |
project.properties["gvsig.package.info.version"] + "-" + |
|
1988 |
project.properties["buildNumber"] + "-" + |
|
1989 |
project.properties["gvsig.package.info.state"] + "-" + |
|
1990 |
project.properties["gvsig.package.info.operatingSystem"] + "-" + |
|
1991 |
project.properties["gvsig.package.info.architecture"] + "-" + |
|
1992 |
project.properties["gvsig.package.info.javaVM"]; |
|
1993 |
|
|
1994 |
source = project.basedir.getAbsolutePath() + "/target/" + pkgname |
|
1995 |
targetPath = poolURL + project.properties["gvsig.package.info.code"] |
|
1991 |
pkgname = "gvSIG-desktop-" + |
|
1992 |
project.properties["gvsig.package.info.gvSIGVersion"] + "-" + |
|
1993 |
project.properties["gvsig.package.info.code"] + "-" + |
|
1994 |
project.properties["gvsig.package.info.version"] + "-" + |
|
1995 |
project.properties["buildNumber"] + "-" + |
|
1996 |
project.properties["gvsig.package.info.state"] + "-" + |
|
1997 |
project.properties["gvsig.package.info.operatingSystem"] + "-" + |
|
1998 |
project.properties["gvsig.package.info.architecture"] + "-" + |
|
1999 |
project.properties["gvsig.package.info.javaVM"]; |
|
1996 | 2000 |
|
1997 |
log.info("Creating addon-request.txt in target folder"); |
|
1998 |
new File(project.basedir.getAbsolutePath() + "/target/addon-request.txt").withWriter { out -> |
|
1999 |
out.println(); |
|
2000 |
out.println(pkgname); |
|
2001 |
out.println(); |
|
2002 |
out.println(targetPath+"/" + pkgname + ".gvspki"); |
|
2003 |
out.println(); |
|
2004 |
} |
|
2001 |
source = project.basedir.getAbsolutePath() + "/target/" + pkgname |
|
2002 |
targetPath = poolURL + project.properties["gvsig.package.info.code"] |
|
2005 | 2003 |
|
2006 |
if( project.properties["user"] == null ) { |
|
2007 |
print("Enter user name: "); |
|
2008 |
user = System.console().readLine().toString() |
|
2009 |
if( user != "" ) { |
|
2010 |
project.properties.setProperty("user",user); |
|
2011 |
} |
|
2012 |
} |
|
2004 |
log.info("Creating addon-request.txt in target folder"); |
|
2005 |
new File(project.basedir.getAbsolutePath() + "/target/addon-request.txt").withWriter { out -> |
|
2006 |
out.println(); |
|
2007 |
out.println(pkgname); |
|
2008 |
out.println(); |
|
2009 |
out.println(targetPath+"/" + pkgname + ".gvspki"); |
|
2010 |
out.println(); |
|
2011 |
} |
|
2012 |
|
|
2013 |
if( project.properties["user"] == null ) { |
|
2014 |
print("Enter user name: "); |
|
2015 |
user = System.console().readLine().toString() |
|
2016 |
if( user != "" ) { |
|
2017 |
project.properties.setProperty("user",user); |
|
2018 |
} |
|
2019 |
} |
|
2013 | 2020 |
if( project.properties["password"] == null ) { |
2014 |
print("Enter password for user '" + project.properties["user"] + "': ");
|
|
2015 |
password = System.console().readPassword().toString()
|
|
2016 |
if( password != "" ) {
|
|
2017 |
project.properties.setProperty("password",password);
|
|
2018 |
}
|
|
2019 |
}
|
|
2020 |
WebDAVClient session = new WebDAVClient(log);
|
|
2021 |
if( project.properties["user"] == null || project.properties["password"] == null ) {
|
|
2022 |
log.info("[WEBDAV] creating non authenticated session.");
|
|
2023 |
log.info("[WEBDAV] Use -Duser=USER -Dpassword=PASSWORD to create a authenticated session.");
|
|
2024 |
session.login();
|
|
2025 |
} else {
|
|
2026 |
session.login(project.properties["user"], project.properties["password"]);
|
|
2027 |
}
|
|
2028 |
session.makedirs(targetPath);
|
|
2029 |
session.put(source + ".gvspkg.zip", targetPath+"/"+pkgname+ ".gvspkg");
|
|
2030 |
session.put(source + ".gvspki", targetPath+"/"+pkgname+ ".gvspki");
|
|
2021 |
print("Enter password for user '" + project.properties["user"] + "': ");
|
|
2022 |
password = System.console().readPassword().toString()
|
|
2023 |
if( password != "" ) {
|
|
2024 |
project.properties.setProperty("password",password);
|
|
2025 |
}
|
|
2026 |
}
|
|
2027 |
WebDAVClient session = new WebDAVClient(log);
|
|
2028 |
if( project.properties["user"] == null || project.properties["password"] == null ) {
|
|
2029 |
log.info("[WEBDAV] creating non authenticated session.");
|
|
2030 |
log.info("[WEBDAV] Use -Duser=USER -Dpassword=PASSWORD to create a authenticated session.");
|
|
2031 |
session.login();
|
|
2032 |
} else {
|
|
2033 |
session.login(project.properties["user"], project.properties["password"]);
|
|
2034 |
}
|
|
2035 |
session.makedirs(targetPath);
|
|
2036 |
session.put(source + ".gvspkg.zip", targetPath+"/"+pkgname+ ".gvspkg");
|
|
2037 |
session.put(source + ".gvspki", targetPath+"/"+pkgname+ ".gvspki");
|
|
2031 | 2038 |
|
2032 |
} else {
|
|
2033 |
log.info("Skip plugin package deploy. It not be installed by default.");
|
|
2034 |
}
|
|
2039 |
} else {
|
|
2040 |
log.info("Skip plugin package deploy. It not be installed by default.");
|
|
2041 |
}
|
|
2035 | 2042 |
} else { |
2036 |
log.info("Skip plugin package deploy. Use the flags -Ddeploy-package -Duser=USER -Dpassword=PASSWORD to deploy it.");
|
|
2043 |
log.info("Skip plugin package deploy. Use the flags -Ddeploy-package -Duser=USER -Dpassword=PASSWORD to deploy it.");
|
|
2037 | 2044 |
} |
2038 | 2045 |
|
2039 | 2046 |
]]></source> |
... | ... | |
2507 | 2514 |
<gvsig.install.plugin.package>true</gvsig.install.plugin.package> |
2508 | 2515 |
|
2509 | 2516 |
<!-- External project versions --> |
2510 |
<gvsig.tools.version>3.0.19</gvsig.tools.version>
|
|
2517 |
<gvsig.tools.version>3.0.20-SNAPSHOT</gvsig.tools.version>
|
|
2511 | 2518 |
<gvsig.about.version>1.0.0</gvsig.about.version> |
2512 | 2519 |
<gvsig.proj.version>1.0.1</gvsig.proj.version> |
2513 | 2520 |
<gvsig.projection.api.version>2.0.15</gvsig.projection.api.version> |
Also available in: Unified diff