use of com.orientechnologies.orient.core.exception.OConfigurationException in project orientdb by orientechnologies.
the class ODatabasePojoAbstract method getUserObjectByRecord.
public T getUserObjectByRecord(final OIdentifiable iRecord, final String iFetchPlan, final boolean iCreate) {
if (!(iRecord instanceof ODocument))
return null;
// PASS FOR rid2Records MAP BECAUSE IDENTITY COULD BE CHANGED IF WAS NEW AND IN TX
ODocument record = rid2Records.get(iRecord.getIdentity());
if (record == null)
record = (ODocument) iRecord;
Object pojo = records2Objects.get(record);
if (pojo == null && iCreate) {
checkOpeness();
try {
if (iRecord.getRecord().getInternalStatus() == ORecordElement.STATUS.NOT_LOADED)
record = (ODocument) record.load();
pojo = newInstance(record.getClassName());
registerUserObject(pojo, record);
stream2pojo(record, pojo, iFetchPlan);
} catch (Exception e) {
throw OException.wrapException(new OConfigurationException("Cannot retrieve pojo from record " + record), e);
}
}
return (T) pojo;
}
use of com.orientechnologies.orient.core.exception.OConfigurationException in project orientdb by orientechnologies.
the class OObjectEntitySerializer method invokeCallback.
protected static void invokeCallback(final Class<?> iClass, final Object iPojo, final ODocument iDocument, final Class<?> iAnnotation) {
final List<Method> methods = getCallbackMethods(iAnnotation, iClass);
if (methods != null && !methods.isEmpty())
for (Method m : methods) {
try {
if (m.getParameterTypes().length > 0)
m.invoke(iPojo, iDocument);
else
m.invoke(iPojo);
} catch (Exception e) {
throw OException.wrapException(new OConfigurationException("Error on executing user callback '" + m.getName() + "' annotated with '" + iAnnotation.getSimpleName() + "'"), e);
}
}
}
use of com.orientechnologies.orient.core.exception.OConfigurationException in project orientdb by orientechnologies.
the class OServerSSLSocketFactory method getSSLContext.
protected SSLContext getSSLContext() {
try {
SSLContext context = SSLContext.getInstance("TLS");
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
KeyStore keyStore = KeyStore.getInstance(keyStoreType);
char[] keyStorePass = keyStorePassword.toCharArray();
keyStore.load(new FileInputStream(keyStoreFile), keyStorePass);
kmf.init(keyStore, keyStorePass);
TrustManagerFactory tmf = null;
if (trustStoreFile != null) {
tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
KeyStore trustStore = KeyStore.getInstance(trustStoreType);
char[] trustStorePass = trustStorePassword.toCharArray();
trustStore.load(new FileInputStream(trustStoreFile), trustStorePass);
tmf.init(trustStore);
}
context.init(kmf.getKeyManagers(), (tmf == null ? null : tmf.getTrustManagers()), null);
return context;
} catch (Exception e) {
throw OException.wrapException(new OConfigurationException("Failed to create SSL context"), e);
}
}
use of com.orientechnologies.orient.core.exception.OConfigurationException in project orientdb by orientechnologies.
the class OAutomaticBackup method configure.
private void configure() {
final File f = new File(OSystemVariableResolver.resolveSystemVariables(configFile));
if (f.exists()) {
// READ THE FILE
try {
final String configurationContent = OIOUtils.readFileAsString(f);
configuration = new ODocument().fromJSON(configurationContent);
} catch (IOException e) {
throw OException.wrapException(new OConfigurationException("Cannot load Automatic Backup configuration file '" + configFile + "'. Automatic Backup will be disabled"), e);
}
} else {
// AUTO CONVERT XML CONFIGURATION (<v2.2) TO JSON FILE
try {
f.getParentFile().mkdirs();
f.createNewFile();
OIOUtils.writeFile(f, configuration.toJSON("prettyPrint"));
OLogManager.instance().info(this, "Automatic Backup: migrated configuration to file '%s'", f);
} catch (IOException e) {
throw OException.wrapException(new OConfigurationException("Cannot create Automatic Backup configuration file '" + configFile + "'. Automatic Backup will be disabled"), e);
}
}
// PARSE THE JSON FILE
for (String settingName : configuration.fieldNames()) {
final Object settingValue = configuration.field(settingName);
final String settingValueAsString = settingValue != null ? settingValue.toString() : null;
if (settingName.equalsIgnoreCase("enabled")) {
if (!(Boolean) settingValue)
// DISABLE IT
return;
} else if (settingName.equalsIgnoreCase("delay"))
delay = OIOUtils.getTimeAsMillisecs(settingValue);
else if (settingName.equalsIgnoreCase("firstTime")) {
try {
firstTime = OIOUtils.getTodayWithTime(settingValueAsString);
if (firstTime.before(new Date())) {
Calendar cal = Calendar.getInstance();
cal.setTime(firstTime);
cal.add(Calendar.DAY_OF_MONTH, 1);
firstTime = cal.getTime();
}
} catch (ParseException e) {
throw OException.wrapException(new OConfigurationException("Parameter 'firstTime' has invalid format, expected: HH:mm:ss"), e);
}
} else if (settingName.equalsIgnoreCase("targetDirectory"))
targetDirectory = settingValueAsString;
else if (settingName.equalsIgnoreCase("dbInclude")) {
String[] included = getDbsList(settingName, settingValueAsString);
for (String db : included) includeDatabases.add(db);
} else if (settingName.equalsIgnoreCase("dbExclude") && settingValueAsString.trim().length() > 0) {
String[] excluded = getDbsList(settingName, settingValueAsString);
for (String db : excluded) excludeDatabases.add(db);
} else if (settingName.equalsIgnoreCase("targetFileName"))
targetFileName = settingValueAsString;
else if (settingName.equalsIgnoreCase("bufferSize"))
bufferSize = (Integer) settingValue;
else if (settingName.equalsIgnoreCase("compressionLevel"))
compressionLevel = (Integer) settingValue;
else if (settingName.equalsIgnoreCase("mode"))
mode = MODE.valueOf(settingValueAsString.toUpperCase());
else if (settingName.equalsIgnoreCase("exportOptions"))
exportOptions = settingValueAsString;
}
}
use of com.orientechnologies.orient.core.exception.OConfigurationException in project orientdb by orientechnologies.
the class OJMXPlugin method config.
@Override
public void config(final OServer oServer, final OServerParameterConfiguration[] iParams) {
for (OServerParameterConfiguration param : iParams) {
if (param.name.equalsIgnoreCase("enabled")) {
if (!Boolean.parseBoolean(param.value))
// DISABLE IT
return;
} else if (param.name.equalsIgnoreCase("profilerManaged"))
profilerManaged = Boolean.parseBoolean(param.value);
}
OLogManager.instance().info(this, "JMX plugin installed and active: profilerManaged=%s", profilerManaged);
final MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
try {
if (profilerManaged) {
// REGISTER THE PROFILER
onProfiler = new ObjectName("com.orientechnologies.common.profiler:type=OProfilerMXBean");
if (mBeanServer.isRegistered(onProfiler))
mBeanServer.unregisterMBean(onProfiler);
mBeanServer.registerMBean(Orient.instance().getProfiler(), onProfiler);
}
} catch (Exception e) {
throw OException.wrapException(new OConfigurationException("Cannot initialize JMX server"), e);
}
}
Aggregations