Search in sources :

Example 36 with OConfigurationException

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;
}
Also used : OConfigurationException(com.orientechnologies.orient.core.exception.OConfigurationException) RESULT(com.orientechnologies.orient.core.hook.ORecordHook.RESULT) ProxyObject(javassist.util.proxy.ProxyObject) OConfigurationException(com.orientechnologies.orient.core.exception.OConfigurationException) OException(com.orientechnologies.common.exception.OException) OTransactionException(com.orientechnologies.orient.core.exception.OTransactionException) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 37 with OConfigurationException

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);
            }
        }
}
Also used : OConfigurationException(com.orientechnologies.orient.core.exception.OConfigurationException) Method(java.lang.reflect.Method) OException(com.orientechnologies.common.exception.OException) InvocationTargetException(java.lang.reflect.InvocationTargetException) OConfigurationException(com.orientechnologies.orient.core.exception.OConfigurationException) OTransactionException(com.orientechnologies.orient.core.exception.OTransactionException) OSerializationException(com.orientechnologies.orient.core.exception.OSerializationException)

Example 38 with OConfigurationException

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);
    }
}
Also used : OConfigurationException(com.orientechnologies.orient.core.exception.OConfigurationException) TrustManagerFactory(javax.net.ssl.TrustManagerFactory) SSLContext(javax.net.ssl.SSLContext) KeyStore(java.security.KeyStore) FileInputStream(java.io.FileInputStream) OConfigurationException(com.orientechnologies.orient.core.exception.OConfigurationException) IOException(java.io.IOException) OException(com.orientechnologies.common.exception.OException) KeyManagerFactory(javax.net.ssl.KeyManagerFactory)

Example 39 with OConfigurationException

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;
    }
}
Also used : OConfigurationException(com.orientechnologies.orient.core.exception.OConfigurationException) IOException(java.io.IOException) ParseException(java.text.ParseException) File(java.io.File) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 40 with OConfigurationException

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);
    }
}
Also used : OConfigurationException(com.orientechnologies.orient.core.exception.OConfigurationException) OServerParameterConfiguration(com.orientechnologies.orient.server.config.OServerParameterConfiguration) OConfigurationException(com.orientechnologies.orient.core.exception.OConfigurationException) OException(com.orientechnologies.common.exception.OException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Aggregations

OConfigurationException (com.orientechnologies.orient.core.exception.OConfigurationException)43 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)16 IOException (java.io.IOException)12 OException (com.orientechnologies.common.exception.OException)9 File (java.io.File)8 OIOException (com.orientechnologies.common.io.OIOException)5 OServerParameterConfiguration (com.orientechnologies.orient.server.config.OServerParameterConfiguration)5 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)4 ConsoleCommand (com.orientechnologies.common.console.annotation.ConsoleCommand)3 OSystemException (com.orientechnologies.common.exception.OSystemException)3 ODatabaseException (com.orientechnologies.orient.core.exception.ODatabaseException)3 ORetryQueryException (com.orientechnologies.orient.core.exception.ORetryQueryException)3 OTransactionException (com.orientechnologies.orient.core.exception.OTransactionException)3 OSerializationException (com.orientechnologies.orient.core.exception.OSerializationException)2 ORecordId (com.orientechnologies.orient.core.id.ORecordId)2 OStorage (com.orientechnologies.orient.core.storage.OStorage)2 OETLProcessHaltedException (com.orientechnologies.orient.etl.OETLProcessHaltedException)2 OServerConfigurationManager (com.orientechnologies.orient.server.config.OServerConfigurationManager)2 OServerNetworkListener (com.orientechnologies.orient.server.network.OServerNetworkListener)2 KeyStore (java.security.KeyStore)2