Skip to content

Commit

Permalink
Merge pull request #722 from wolfgangmm/develop
Browse files Browse the repository at this point in the history
Installer and version change for release 3.0RC1
  • Loading branch information
adamretter committed Jul 7, 2015
2 parents 3508729 + 1ff5131 commit e4d2a2b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 103 deletions.
4 changes: 2 additions & 2 deletions build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#
# $Id$
project.name = eXist-db
project.version = 2.3dev
project.version.numeric = 2.3.0
project.version = 3.0.RC1
project.version.numeric = 3.0.0
project.source = develop
project.codename = Berlin

Expand Down
104 changes: 3 additions & 101 deletions src/org/exist/installer/Setup.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,133 +58,35 @@ public static void main(String[] args) {
System.err.println("No password specified. Admin password will be empty.");
return;
}
// int offset = 0;
String passwd = null;
if (args[0].startsWith("pass:")) {
passwd = args[0].substring(5);
// offset = 1;
}
System.setProperty(AutoDeploymentTrigger.AUTODEPLOY_PROPERTY, "off");
// final XQueryService query = initDb(passwd);
// if (query != null) {
// try {
// installApps(query, args, offset);
// } catch (EXistException e) {
// System.err.println("An error occurred while installing apps: " + e.getMessage());
// }
// }
initDb(passwd);
shutdown(passwd);
}

private static void installApps(XQueryService query, String[] args, int offset) throws EXistException {
final File home = getExistHome();
final ExistRepository repository = getRepository(home);

final List<String> uris = new ArrayList<String>();
for (int i = offset; i < args.length; i++) {
final String name = args[i];
try {
final File xar = findApp(home, name);
if (xar != null) {
System.out.println("Installing app package " + xar.getName());
final UserInteractionStrategy interact = new BatchUserInteraction();
final Package pkg = repository.getParentRepo().installPackage(xar, true, interact);
final String pkgName = pkg.getName();
uris.add(pkgName);
} else {
System.err.println("App package not found: " + name + ". Skipping it.");
}
} catch (final PackageException e) {
System.err.println("Failed to install application package " + name + ": " + e.getMessage());
}
}

System.out.println("\n=== Starting the installation process for each application... ===");
System.out.println("\nPLEASE DO NOT ABORT\n");

final String prolog =
"import module namespace repo=\"http://exist-db.org/xquery/repo\" " +
"at \"java:org.exist.xquery.modules.expathrepo.ExpathPackageModule\";\n";
for (final String uri : uris) {
final StringBuilder xquery = new StringBuilder(prolog);
xquery.append(" repo:deploy(\"" + uri + "\")");
System.out.print("Installing app package: " + uri + "... ");
try {
query.query(xquery.toString());
} catch (final XMLDBException e) {
e.printStackTrace();
System.err.println("An error occurred while deploying application: " + uri +
". You can install it later using the package repository.");
}
System.out.println("DONE.");
}

System.out.println("=== App installation completed. ===");
}

private static File getExistHome() throws EXistException {
return BrokerPool.getInstance().getConfiguration().getExistHome();
}

private static File findApp(File home, String app) {
final File apps = new File(home, "apps");
System.out.println("Apps directory: " + apps.getAbsolutePath());
if (apps.canRead() && apps.isDirectory()) {
final File[] files = apps.listFiles();
for (final File file : files) {
if (file.getName().startsWith(app))
{return file;}
}
}
return null;
}

private static ExistRepository getRepository(File home) throws EXistException {
try {
if (home != null){
final File repo_dir = new File(home, "webapp/WEB-INF/expathrepo");
// ensure the dir exists
repo_dir.mkdir();
final FileSystemStorage storage = new FileSystemStorage(repo_dir);
return new ExistRepository(storage);
}else{
final File repo_dir = new File(System.getProperty("java.io.tmpdir") + "/expathrepo");
// ensure the dir exists
repo_dir.mkdir();
final FileSystemStorage storage = new FileSystemStorage(repo_dir);
return new ExistRepository(storage);
}
}
catch ( final PackageException ex ) {
// problem with pkg-repo.jar throwing exception
throw new EXistException("Problem setting expath repository", ex);
}
}

private static XQueryService initDb(String adminPass) {
private static void initDb(String adminPass) {
System.out.println("--- Starting embedded database instance ---");
try {
final Class<?> cl = Class.forName(DRIVER);
final Database database = (Database) cl.newInstance();
database.setProperty("create-database", "true");
DatabaseManager.registerDatabase(database);
Collection root = DatabaseManager.getCollection(URI, "admin", null);
final Collection root = DatabaseManager.getCollection(URI, "admin", null);
if (adminPass != null) {
final UserManagementService service =
(UserManagementService) root.getService("UserManagementService", "1.0");
final Account admin = service.getAccount("admin");
admin.setPassword(adminPass);
System.out.println("Setting admin user password...");
service.updateAccount(admin);
root = DatabaseManager.getCollection(URI, "admin", adminPass);
}
final XQueryService query = (XQueryService) root.getService("XQueryService", "1.0");
return query;
} catch (final Exception e) {
System.err.println("Caught an exception while initializing db: " + e.getMessage());
e.printStackTrace();
}
return null;
}

private static void shutdown(String adminPass) {
Expand Down

0 comments on commit e4d2a2b

Please sign in to comment.