Search in sources :

Example 1 with OServerCommandGetStaticContent

use of com.orientechnologies.orient.server.network.protocol.http.command.get.OServerCommandGetStaticContent 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)

Aggregations

OCallable (com.orientechnologies.common.util.OCallable)1 OConfigurationException (com.orientechnologies.orient.core.exception.OConfigurationException)1 OServerNetworkListener (com.orientechnologies.orient.server.network.OServerNetworkListener)1 OServerCommandGetStaticContent (com.orientechnologies.orient.server.network.protocol.http.command.get.OServerCommandGetStaticContent)1 URL (java.net.URL)1