Skip to content

Commit

Permalink
Search: component revision fixes; configuration error handling; versi…
Browse files Browse the repository at this point in the history
…oning for ILIAS major versions
  • Loading branch information
smeyer-ilias committed Jan 17, 2025
1 parent 0d90eb9 commit 128fd05
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 50 deletions.
2 changes: 1 addition & 1 deletion components/ILIAS/WebServices/RPC/lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.ilias.ilserver</groupId>
<artifactId>ilServer</artifactId>
<version>9.0.2</version>
<version>10.0.1</version>
<build>
<finalName>ilServer</finalName>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,12 @@ private boolean startServer() {
logger.debug("Start parsing");
parser = new CommonsIniFileParser();
logger.debug("Parser created");
parser.parseSettings(arguments[0], true);
try {
parser.parseSettings(arguments[0], true);
} catch (ConfigurationException e) {
System.err.println(e.getMessage());
System.exit(1);
}
logger.debug("Parser parsed");
settings = ServerSettings.getInstance();
client = initRpcClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public boolean indexObjects(String clientKey, Vector<Integer> objIds) {
client = ClientSettings.getInstance(LocalSettings.getClientKey());
server = ServerSettings.getInstance();

properties = ObjectDefinitionReader.getInstance(client.getAbsolutePath());
properties = ObjectDefinitionReader.getInstance(client);
parser = new ObjectDefinitionParser(properties.getObjectPropertyFiles());
parser.parse();

Expand Down Expand Up @@ -170,11 +170,10 @@ public boolean index(String clientKey, boolean incremental) {
IndexHolder.deleteIndex();
}

properties = ObjectDefinitionReader.getInstance(client.getAbsolutePath());
properties = ObjectDefinitionReader.getInstance(client);
parser = new ObjectDefinitionParser(properties.getObjectPropertyFiles());
parser.parse();

//controller = CommandController.getInstance();
controller = new CommandController();
if(incremental) {
controller.initRefresh();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,72 +27,48 @@
import java.util.HashMap;
import java.util.Vector;

import de.ilias.services.settings.ClientSettings;
import org.apache.logging.log4j.LogManager;

import de.ilias.services.settings.ConfigurationException;
import org.apache.logging.log4j.Logger;

/**
*
*
* @author Stefan Meyer <[email protected]>
* @version $Id$
*/
public class ObjectDefinitionReader {


private static final Logger logger = LogManager.getLogger(ObjectDefinitionReader.class);
private static final HashMap<File, ObjectDefinitionReader> instances = new HashMap<File, ObjectDefinitionReader>();

public static final String objectPropertyName = "LuceneObjectDefinition.xml";
public static final String pluginPath = "Customizing/global/plugins";

public static final String componentPath = "components";

private final Vector<File> objectPropertyFiles = new Vector<File>();


File absolutePath;
ClientSettings clientSettings;

/**
* Singleton constructor
* @throws ConfigurationException
*/
private ObjectDefinitionReader(File absolutePath) throws ConfigurationException {
this.absolutePath = absolutePath;
private ObjectDefinitionReader(ClientSettings settings) throws ConfigurationException {
this.clientSettings = settings;
this.absolutePath = settings.getAbsolutePath();
read();
}

/**
*
* @param absolutePath
* @return
* @throws ConfigurationException
*/
public static ObjectDefinitionReader getInstance(File absolutePath) throws ConfigurationException {

if(instances.containsKey(absolutePath)) {
logger.debug("Using cached properties.");
return instances.get(absolutePath);

public static ObjectDefinitionReader getInstance(ClientSettings settings) throws ConfigurationException {
if (instances.containsKey(settings.getAbsolutePath())) {
return instances.get(settings.getAbsolutePath());
}
instances.put(absolutePath, new ObjectDefinitionReader(absolutePath));
return instances.get(absolutePath);
instances.put(settings.getAbsolutePath(), new ObjectDefinitionReader(settings));
return instances.get(settings.getAbsolutePath());
}

/**
* @return the absolutePath
*/
public File getAbsolutePath() {
return absolutePath;
return clientSettings.getAbsolutePath();
}


/**
* @param absolutePath the absolutePath to set
*/
public void setAbsolutePath(File absolutePath) {
this.absolutePath = absolutePath;
}

/**
* @return the objectPropertyFiles
*/
Expand All @@ -110,7 +86,19 @@ private void read() throws ConfigurationException {
if(!absolutePath.isDirectory()) {
throw new ConfigurationException("Absolute path required. Path: " + absolutePath.getAbsolutePath());
}

traverseByVersion();
}

private void traverseByVersion() {
if (clientSettings.getIliasMajorVersion() == 0 || clientSettings.getIliasMajorVersion() >= 10) {
traverseByVersion10();
} else {
traverseByVersion8();
}
}

private void traverseByVersion8() {

// Traverse through Modules
File start = new File(absolutePath.getAbsoluteFile() + System.getProperty("file.separator") + "Modules");
logger.debug("Start path is : " + start.getAbsoluteFile());
Expand All @@ -126,11 +114,14 @@ private void read() throws ConfigurationException {
logger.debug("Start path is : " + plugin.getAbsoluteFile());
traverse(plugin);
}

private void traverseByVersion10() {
// Traverse through Plugins
File plugin = new File(absolutePath.getAbsoluteFile() + System.getProperty("file.separator") + ObjectDefinitionReader.componentPath);
logger.debug("Start path is : " + plugin.getAbsoluteFile());
traverse(plugin);
}

/**
*
* @param dir
*/
private void traverse(File dir) {

if(dir == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class ClientSettings {
private String client;
private String nic;
private File iliasIniFile;
private int iliasMajorVersion;
private File dataDirectory;
private File clientIniFile;
private File absolutePath;
Expand All @@ -61,6 +62,7 @@ public ClientSettings(String client, String nic) {

this.client = client;
this.nic = nic;
this.iliasMajorVersion = 0;
}

public static synchronized ClientSettings getInstance(String client, String nic) throws ConfigurationException {
Expand Down Expand Up @@ -143,6 +145,14 @@ public void setNic(String nic) {
public File getIliasIniFile() {
return iliasIniFile;
}

public void setIliasMajorVersion(int majorVersion) {
this.iliasMajorVersion = majorVersion;
}

public int getIliasMajorVersion() {
return iliasMajorVersion;
}

/**
* @return the dataDirectory
Expand Down Expand Up @@ -192,8 +202,6 @@ public File getClientIniFile() {
return clientIniFile;
}

/**
*/
public void setClientIniFile(String clientIniPath) throws ConfigurationException {

this.clientIniFile = new File(clientIniPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ public void parseSettings(String path, boolean parseClientSettings) throws Confi
else
nic = "0";
clientSettings = ClientSettings.getInstance(client, nic);
if(sectionConfig.containsKey("IliasMajorVersion")) {
int majorVersion = 0;
try {
majorVersion = Integer.parseInt(getConfig(ini, section, "IliasMajorVersion", true));
clientSettings.setIliasMajorVersion(majorVersion);
this.logger.info("Using major version: {}", majorVersion);
} catch (NumberFormatException e) {
this.logger.error("Invalid IliasMajorVersion given: {}", getConfig(ini, section, "IliasMajorVersion", true));
throw new ConfigurationException("Parsing ilServer.ini failed with message: invalid IliasMajorVersion given: " + getConfig(ini, section, "IliasMajorVersion", true));
}
}
if(sectionConfig.containsKey("IliasIniPath")) {
clientSettings.setIliasIniFile(getConfig(ini, section, "IliasIniPath", false));
// Now parse the ilias.ini file
Expand Down Expand Up @@ -147,6 +158,13 @@ private void parseClientData(ClientSettings clientSettings) throws Configuration
String dataName = getConfig(ini, "clients", "path", true);
String iniFileName = getConfig(ini, "clients", "inifile", true);

if (
clientSettings.getIliasMajorVersion() >= 10 && dataName.indexOf("public") != 0
) {
logger.warn("Replaced datadir {} => {}", dataName, "public/" + dataName);
dataName = "public/" + dataName;
}

clientSettings.setClientIniFile(clientSettings.getAbsolutePath().getCanonicalPath() +
System.getProperty("file.separator") +
dataName + System.getProperty("file.separator") +
Expand Down

0 comments on commit 128fd05

Please sign in to comment.