protected Item loadItem(File file) throws AccessControlException {
Configuration config = getItemConfiguration(file);
String fileName = file.getName();
String id = fileName.substring(0, fileName.length() - getSuffix().length());
Item item = (Item) items.get(id);
String klass = getItemClass(config);
if (item == null) {
try {
item = (Item) Class.forName(klass).newInstance();
} catch (Exception e) {
String errorMsg =
"Exception when trying to instanciate: "
+ klass
+ " with exception: "
+ e.fillInStackTrace();
// an exception occured when trying to instanciate
// a user.
log.error(errorMsg);
throw new AccessControlException(errorMsg, e);
}
item.setConfigurationDirectory(configurationDirectory);
}
try {
item.configure(config);
} catch (ConfigurationException e) {
String errorMsg = "Exception when trying to configure: " + klass;
throw new AccessControlException(errorMsg, e);
}
return item;