-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Search: component revision fixes; configuration error handling; versi…
…oning for ILIAS major versions
- Loading branch information
1 parent
0d90eb9
commit 128fd05
Showing
6 changed files
with
71 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
*/ | ||
|
@@ -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()); | ||
|
@@ -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) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters