Change appDir handling:
* If appDir is not defined in apps.properties, use the last file repository as appdir (used to be the first one) * If appDir is defined, add it to the end of the repository list if it isn't explicitly listed as repository. * If appDir is defined in apps.properties, use it for the app.dir JS variable. * Never automatically create an app's file repositories.
This commit is contained in:
parent
fa3ddd8a68
commit
326f30a88b
2 changed files with 27 additions and 31 deletions
|
@ -180,7 +180,7 @@ public final class Application implements IPathElement, Runnable {
|
||||||
*/
|
*/
|
||||||
public Application(String name, Repository[] repositories, File dbDir)
|
public Application(String name, Repository[] repositories, File dbDir)
|
||||||
throws RemoteException, IllegalArgumentException {
|
throws RemoteException, IllegalArgumentException {
|
||||||
this(name, null, repositories, dbDir);
|
this(name, null, repositories, null, dbDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -189,14 +189,15 @@ public final class Application implements IPathElement, Runnable {
|
||||||
*/
|
*/
|
||||||
public Application(String name, Server server)
|
public Application(String name, Server server)
|
||||||
throws RemoteException, IllegalArgumentException {
|
throws RemoteException, IllegalArgumentException {
|
||||||
this(name, server, new Repository[0], null);
|
this(name, server, new Repository[0], null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build an application with the given name, server instance, sources and
|
* Build an application with the given name, server instance, sources and
|
||||||
* db directory.
|
* db directory.
|
||||||
*/
|
*/
|
||||||
public Application(String name, Server server, Repository[] repositories, File customDbDir)
|
public Application(String name, Server server, Repository[] repositories,
|
||||||
|
File customAppDir, File customDbDir)
|
||||||
throws RemoteException, IllegalArgumentException {
|
throws RemoteException, IllegalArgumentException {
|
||||||
if ((name == null) || (name.trim().length() == 0)) {
|
if ((name == null) || (name.trim().length() == 0)) {
|
||||||
throw new IllegalArgumentException("Invalid application name: " + name);
|
throw new IllegalArgumentException("Invalid application name: " + name);
|
||||||
|
@ -212,6 +213,7 @@ public final class Application implements IPathElement, Runnable {
|
||||||
this.repositories.addAll(Arrays.asList(repositories));
|
this.repositories.addAll(Arrays.asList(repositories));
|
||||||
resourceComparator = new ResourceComparator(this);
|
resourceComparator = new ResourceComparator(this);
|
||||||
|
|
||||||
|
appDir = customAppDir;
|
||||||
dbDir = customDbDir;
|
dbDir = customDbDir;
|
||||||
|
|
||||||
// system-wide properties, default to null
|
// system-wide properties, default to null
|
||||||
|
@ -239,10 +241,12 @@ public final class Application implements IPathElement, Runnable {
|
||||||
dbDir.mkdirs();
|
dbDir.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<repositories.length; i++) {
|
if (appDir == null) {
|
||||||
if (repositories[i] instanceof FileRepository) {
|
for (int i=repositories.length-1; i>=0; i--) {
|
||||||
appDir = new File(repositories[i].getName());
|
if (repositories[i] instanceof FileRepository) {
|
||||||
break;
|
appDir = new File(repositories[i].getName());
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -333,18 +333,17 @@ public class ApplicationManager implements XmlRpcHandler {
|
||||||
|
|
||||||
// read and configure app repositories
|
// read and configure app repositories
|
||||||
ArrayList repositoryList = new ArrayList();
|
ArrayList repositoryList = new ArrayList();
|
||||||
|
Class[] parameters = { String.class };
|
||||||
for (int i = 0; true; i++) {
|
for (int i = 0; true; i++) {
|
||||||
Class[] parameters = { String.class };
|
String repositoryArgs = props.getProperty(name + ".repository." + i);
|
||||||
|
|
||||||
String[] repositoryArgs = { props.getProperty(name + ".repository." + i) };
|
if (repositoryArgs != null) {
|
||||||
|
|
||||||
if (repositoryArgs[0] != null) {
|
|
||||||
// lookup repository implementation
|
// lookup repository implementation
|
||||||
String repositoryImpl = props.getProperty(name + ".repository." + i +
|
String repositoryImpl = props.getProperty(name + ".repository." + i +
|
||||||
".implementation");
|
".implementation");
|
||||||
if (repositoryImpl == null) {
|
if (repositoryImpl == null) {
|
||||||
// implementation not set manually, have to guess it
|
// implementation not set manually, have to guess it
|
||||||
if (repositoryArgs[0].endsWith(".zip")) {
|
if (repositoryArgs.endsWith(".zip")) {
|
||||||
repositoryImpl = "helma.framework.repository.ZipRepository";
|
repositoryImpl = "helma.framework.repository.ZipRepository";
|
||||||
} else {
|
} else {
|
||||||
repositoryImpl = "helma.framework.repository.FileRepository";
|
repositoryImpl = "helma.framework.repository.FileRepository";
|
||||||
|
@ -355,10 +354,10 @@ public class ApplicationManager implements XmlRpcHandler {
|
||||||
try {
|
try {
|
||||||
newRepository = (Repository) Class.forName(repositoryImpl)
|
newRepository = (Repository) Class.forName(repositoryImpl)
|
||||||
.getConstructor(parameters)
|
.getConstructor(parameters)
|
||||||
.newInstance((Object[]) repositoryArgs);
|
.newInstance(new Object[] { repositoryArgs });
|
||||||
repositoryList.add(newRepository);
|
repositoryList.add(newRepository);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("Adding repository " + repositoryArgs[0] + " failed. " +
|
System.out.println("Adding repository " + repositoryArgs + " failed. " +
|
||||||
"Will not use that repository. Check your initArgs!");
|
"Will not use that repository. Check your initArgs!");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -369,24 +368,17 @@ public class ApplicationManager implements XmlRpcHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (repositoryList.size() > 0) {
|
if (appDir != null) {
|
||||||
repositories = new Repository[repositoryList.size()];
|
FileRepository appRep = new FileRepository(appDir);
|
||||||
repositoryList.toArray(repositories);
|
if (!repositoryList.contains(appRep)) {
|
||||||
} else {
|
repositoryList.add(appRep);
|
||||||
repositories = new Repository[1];
|
|
||||||
if (appDir != null) {
|
|
||||||
repositories[0] = new FileRepository(appDir);
|
|
||||||
} else {
|
|
||||||
repositories[0] = new FileRepository(new File(server.getAppsHome(), appName));
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
if (!repositories[0].exists()) {
|
|
||||||
repositories[0].create();
|
|
||||||
}
|
|
||||||
} catch (Exception swallow) {
|
|
||||||
// couldn't create repository
|
|
||||||
}
|
}
|
||||||
|
} else if (repositoryList.isEmpty()) {
|
||||||
|
repositoryList.add(new FileRepository(
|
||||||
|
new File(server.getAppsHome(), appName)));
|
||||||
}
|
}
|
||||||
|
repositories = new Repository[repositoryList.size()];
|
||||||
|
repositoryList.toArray(repositories);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -395,7 +387,7 @@ public class ApplicationManager implements XmlRpcHandler {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// create the application instance
|
// create the application instance
|
||||||
app = new Application(appName, server, repositories, dbDir);
|
app = new Application(appName, server, repositories, appDir, dbDir);
|
||||||
|
|
||||||
// register ourselves
|
// register ourselves
|
||||||
descriptors.put(appName, this);
|
descriptors.put(appName, this);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue