use of com.evolveum.midpoint.repo.api.RepositoryServiceFactoryException in project midpoint by Evolveum.
the class TestSqlRepositoryFactory method updateConfigurationFromFile.
private void updateConfigurationFromFile(Configuration configuration, String filePath) throws RepositoryServiceFactoryException {
Properties properties = new Properties();
try {
File file = new File(filePath);
LOGGER.debug("Config file absolute path '{}'.", new Object[] { file.getAbsolutePath() });
if (!file.exists() || !file.isFile() || !file.canRead()) {
throw new RepositoryServiceFactoryException("Config file '" + filePath + "' doesn't exist or can't be read.");
}
Reader reader = new InputStreamReader(new FileInputStream(file), "utf-8");
properties.load(reader);
} catch (RepositoryServiceFactoryException ex) {
throw ex;
} catch (Exception ex) {
throw new RepositoryServiceFactoryException(ex.getMessage(), ex);
}
//override loaded configuration based on properties file...
updateConfigurationFromProperties(configuration, properties);
}
use of com.evolveum.midpoint.repo.api.RepositoryServiceFactoryException in project midpoint by Evolveum.
the class SqlRepositoryFactory method checkPort.
private void checkPort(int port) throws RepositoryServiceFactoryException {
if (port >= 65635 || port < 0) {
throw new RepositoryServiceFactoryException("Port must be in range 0-65634, not '" + port + "'.");
}
ServerSocket ss = null;
try {
ss = new ServerSocket(port);
ss.setReuseAddress(true);
} catch (BindException e) {
throw new RepositoryServiceFactoryException("Configured port (" + port + ") for H2 already in use.", e);
} catch (IOException e) {
LOGGER.error("Reported IO error, while binding ServerSocket to port " + port + " used to test availability " + "of port for H2 Server", e);
} finally {
try {
if (ss != null) {
ss.close();
}
} catch (IOException ex) {
LOGGER.error("Reported IO error, while closing ServerSocket used to test availability " + "of port for H2 Server", ex);
}
}
}
use of com.evolveum.midpoint.repo.api.RepositoryServiceFactoryException in project midpoint by Evolveum.
the class RepositoryFactory method getRepositoryService.
public synchronized RepositoryService getRepositoryService() {
if (repositoryService == null) {
try {
LOGGER.debug("Creating repository service using factory {}", factory);
repositoryService = factory.getRepositoryService();
} catch (RepositoryServiceFactoryException | RuntimeException ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Failed to get repository service from factory " + factory, ex);
throw new SystemException("Failed to get repository service from factory " + factory, ex);
} catch (Error ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Failed to get repository service from factory " + factory, ex);
throw ex;
}
}
return repositoryService;
}
use of com.evolveum.midpoint.repo.api.RepositoryServiceFactoryException in project midpoint by Evolveum.
the class TestSqlRepositoryConfigurationFactory method updateConfigurationFromFile.
private void updateConfigurationFromFile(Configuration configuration, String filePath) throws RepositoryServiceFactoryException {
Properties properties = new Properties();
try {
File file = new File(filePath);
LOGGER.debug("Config file absolute path '{}'.", file.getAbsolutePath());
if (!file.exists() || !file.isFile() || !file.canRead()) {
throw new RepositoryServiceFactoryException("Config file '" + filePath + "' doesn't exist or can't be read.");
}
Reader reader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8);
properties.load(reader);
} catch (RepositoryServiceFactoryException ex) {
throw ex;
} catch (Exception ex) {
throw new RepositoryServiceFactoryException(ex.getMessage(), ex);
}
// override loaded configuration based on properties file...
updateConfigurationFromProperties(configuration, properties);
}
use of com.evolveum.midpoint.repo.api.RepositoryServiceFactoryException in project midpoint by Evolveum.
the class SqlEmbeddedRepository method checkPort.
private void checkPort(int port) throws RepositoryServiceFactoryException {
if (port >= 65635 || port < 0) {
throw new RepositoryServiceFactoryException("Port must be in range 0-65634, not '" + port + "'.");
}
ServerSocket ss = null;
try {
ss = new ServerSocket(port);
ss.setReuseAddress(true);
} catch (BindException e) {
throw new RepositoryServiceFactoryException("Configured port (" + port + ") for H2 already in use.", e);
} catch (IOException e) {
LOGGER.error("Reported IO error, while binding ServerSocket to port " + port + " used to test availability " + "of port for H2 Server", e);
} finally {
try {
if (ss != null) {
ss.close();
}
} catch (IOException ex) {
LOGGER.error("Reported IO error, while closing ServerSocket used to test availability " + "of port for H2 Server", ex);
}
}
}
Aggregations