Search in sources :

Example 11 with OConfigurationException

use of com.orientechnologies.orient.core.exception.OConfigurationException in project orientdb by orientechnologies.

the class OServerPluginManager method registerStaticDirectory.

protected void registerStaticDirectory(final OServerPluginInfo iPluginData) {
    Object pluginWWW = iPluginData.getParameter("www");
    if (pluginWWW == null)
        pluginWWW = iPluginData.getName();
    final OServerNetworkListener httpListener = server.getListenerByProtocol(ONetworkProtocolHttpAbstract.class);
    if (httpListener == null)
        throw new OConfigurationException("HTTP listener not registered while installing Static Content command");
    final OServerCommandGetStaticContent command = (OServerCommandGetStaticContent) httpListener.getCommand(OServerCommandGetStaticContent.class);
    if (command != null) {
        final URL wwwURL = iPluginData.getClassLoader().findResource("www/");
        final OCallable<Object, String> callback;
        if (wwwURL != null)
            callback = createStaticLinkCallback(iPluginData, wwwURL);
        else
            // LET TO THE COMMAND TO CONTROL IT
            callback = new OCallable<Object, String>() {

                @Override
                public Object call(final String iArgument) {
                    return iPluginData.getInstance().getContent(iArgument);
                }
            };
        command.registerVirtualFolder(pluginWWW.toString(), callback);
    }
}
Also used : OConfigurationException(com.orientechnologies.orient.core.exception.OConfigurationException) OCallable(com.orientechnologies.common.util.OCallable) OServerCommandGetStaticContent(com.orientechnologies.orient.server.network.protocol.http.command.get.OServerCommandGetStaticContent) OServerNetworkListener(com.orientechnologies.orient.server.network.OServerNetworkListener) URL(java.net.URL)

Example 12 with OConfigurationException

use of com.orientechnologies.orient.core.exception.OConfigurationException in project orientdb by orientechnologies.

the class OConsoleDatabaseApp method dropServerUser.

@SuppressWarnings("unchecked")
@ConsoleCommand(description = "Drop a server user. For more information look at http://orientdb.com/docs/last/Security.html#orientdb-server-security", onlineHelp = "Console-Command-Drop-Server-User")
public void dropServerUser(@ConsoleParameter(name = "user-name", description = "User name") String iServerUserName) {
    if (iServerUserName == null || iServerUserName.length() == 0)
        throw new IllegalArgumentException("User name null or empty");
    final File serverCfgFile = new File("../config/orientdb-server-config.xml");
    if (!serverCfgFile.exists())
        throw new OConfigurationException("Cannot access to file " + serverCfgFile);
    try {
        final OServerConfigurationManager serverCfg = new OServerConfigurationManager(serverCfgFile);
        if (!serverCfg.existsUser(iServerUserName)) {
            error("\nServer user '%s' not found in configuration", iServerUserName);
            return;
        }
        serverCfg.dropUser(iServerUserName);
        serverCfg.saveConfiguration();
        message("\nServer user '%s' dropped correctly", iServerUserName);
    } catch (Exception e) {
        error("\nError on loading %s file: %s", serverCfgFile, e.toString());
    }
}
Also used : OConfigurationException(com.orientechnologies.orient.core.exception.OConfigurationException) OServerConfigurationManager(com.orientechnologies.orient.server.config.OServerConfigurationManager) OSystemException(com.orientechnologies.common.exception.OSystemException) OConfigurationException(com.orientechnologies.orient.core.exception.OConfigurationException) ORetryQueryException(com.orientechnologies.orient.core.exception.ORetryQueryException) OIOException(com.orientechnologies.common.io.OIOException) ODatabaseException(com.orientechnologies.orient.core.exception.ODatabaseException) ConsoleCommand(com.orientechnologies.common.console.annotation.ConsoleCommand)

Example 13 with OConfigurationException

use of com.orientechnologies.orient.core.exception.OConfigurationException in project orientdb by orientechnologies.

the class OConsoleDatabaseApp method listServerUsers.

@SuppressWarnings("unchecked")
@ConsoleCommand(description = "Display all the server user names. For more information look at http://orientdb.com/docs/last/Security.html#orientdb-server-security", onlineHelp = "Console-Command-List-Server-User")
public void listServerUsers() {
    final File serverCfgFile = new File("../config/orientdb-server-config.xml");
    if (!serverCfgFile.exists())
        throw new OConfigurationException("Cannot access to file " + serverCfgFile);
    try {
        final OServerConfigurationManager serverCfg = new OServerConfigurationManager(serverCfgFile);
        message("\nSERVER USERS\n");
        final Set<OServerUserConfiguration> users = serverCfg.getUsers();
        if (users.isEmpty())
            message("\nNo users found");
        else
            for (OServerUserConfiguration u : users) {
                message("\n- '%s', permissions: %s", u.name, u.resources);
            }
    } catch (Exception e) {
        error("\nError on loading %s file: %s", serverCfgFile, e.toString());
    }
}
Also used : OConfigurationException(com.orientechnologies.orient.core.exception.OConfigurationException) OServerUserConfiguration(com.orientechnologies.orient.server.config.OServerUserConfiguration) OServerConfigurationManager(com.orientechnologies.orient.server.config.OServerConfigurationManager) OSystemException(com.orientechnologies.common.exception.OSystemException) OConfigurationException(com.orientechnologies.orient.core.exception.OConfigurationException) ORetryQueryException(com.orientechnologies.orient.core.exception.ORetryQueryException) OIOException(com.orientechnologies.common.io.OIOException) ODatabaseException(com.orientechnologies.orient.core.exception.ODatabaseException) ConsoleCommand(com.orientechnologies.common.console.annotation.ConsoleCommand)

Example 14 with OConfigurationException

use of com.orientechnologies.orient.core.exception.OConfigurationException in project orientdb by orientechnologies.

the class ODistributedAbstractPlugin method config.

@SuppressWarnings("unchecked")
@Override
public void config(OServer oServer, OServerParameterConfiguration[] iParams) {
    serverInstance = oServer;
    oServer.setVariable("ODistributedAbstractPlugin", this);
    for (OServerParameterConfiguration param : iParams) {
        if (param.name.equalsIgnoreCase("enabled")) {
            if (!Boolean.parseBoolean(OSystemVariableResolver.resolveSystemVariables(param.value))) {
                // DISABLE IT
                enabled = false;
                return;
            }
        } else if (param.name.equalsIgnoreCase("nodeName")) {
            nodeName = param.value;
            if (nodeName.contains("."))
                throw new OConfigurationException("Illegal node name '" + nodeName + "'. '.' is not allowed in node name");
        } else if (param.name.startsWith(PAR_DEF_DISTRIB_DB_CONFIG)) {
            setDefaultDatabaseConfigFile(param.value);
        }
    }
    if (serverInstance.getUser("replicator") == null)
        // DROP THE REPLICATOR USER. THIS USER WAS NEEDED BEFORE 2.2, BUT IT'S NOT REQUIRED ANYMORE
        OLogManager.instance().config(this, "Found 'replicator' user. Starting from OrientDB v2.2 this internal user is no needed anymore. Removing it...");
    try {
        serverInstance.dropUser("replicator");
    } catch (IOException e) {
        throw OException.wrapException(new OConfigurationException("Error on deleting 'replicator' user"), e);
    }
}
Also used : OConfigurationException(com.orientechnologies.orient.core.exception.OConfigurationException) OServerParameterConfiguration(com.orientechnologies.orient.server.config.OServerParameterConfiguration) OIOException(com.orientechnologies.common.io.OIOException)

Example 15 with OConfigurationException

use of com.orientechnologies.orient.core.exception.OConfigurationException in project orientdb by orientechnologies.

the class OServerSSLSocketFactory method config.

@Override
public void config(String name, final OServerParameterConfiguration[] iParameters) {
    super.config(name, iParameters);
    for (OServerParameterConfiguration param : iParameters) {
        if (param.name.equalsIgnoreCase(PARAM_NETWORK_SSL_CLIENT_AUTH)) {
            clientAuth = Boolean.parseBoolean(param.value);
        } else if (param.name.equalsIgnoreCase(PARAM_NETWORK_SSL_KEYSTORE)) {
            keyStorePath = param.value;
        } else if (param.name.equalsIgnoreCase(PARAM_NETWORK_SSL_KEYSTORE_PASSWORD)) {
            keyStorePassword = param.value;
        } else if (param.name.equalsIgnoreCase(PARAM_NETWORK_SSL_KEYSTORE_TYPE)) {
            keyStoreType = param.value;
        } else if (param.name.equalsIgnoreCase(PARAM_NETWORK_SSL_TRUSTSTORE)) {
            trustStorePath = param.value;
        } else if (param.name.equalsIgnoreCase(PARAM_NETWORK_SSL_TRUSTSTORE_PASSWORD)) {
            trustStorePassword = param.value;
        } else if (param.name.equalsIgnoreCase(PARAM_NETWORK_SSL_TRUSTSTORE_TYPE)) {
            trustStoreType = param.value;
        }
    }
    if (keyStorePath == null) {
        throw new OConfigurationException("Missing parameter " + PARAM_NETWORK_SSL_KEYSTORE);
    } else if (keyStorePassword == null) {
        throw new OConfigurationException("Missing parameter " + PARAM_NETWORK_SSL_KEYSTORE_PASSWORD);
    }
    keyStoreFile = new File(keyStorePath);
    if (!keyStoreFile.isAbsolute()) {
        keyStoreFile = new File(OSystemVariableResolver.resolveSystemVariables("${ORIENTDB_HOME}"), keyStorePath);
    }
    if (trustStorePath != null) {
        trustStoreFile = new File(trustStorePath);
        if (!trustStoreFile.isAbsolute()) {
            trustStoreFile = new File(OSystemVariableResolver.resolveSystemVariables("${ORIENTDB_HOME}"), trustStorePath);
        }
    }
}
Also used : OConfigurationException(com.orientechnologies.orient.core.exception.OConfigurationException) OServerParameterConfiguration(com.orientechnologies.orient.server.config.OServerParameterConfiguration) File(java.io.File)

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