package au.org.ands.vocabs.toolkit.provider.importer;
import java.lang.invoke.MethodHandles;
import java.util.Collection;
import java.util.HashMap;
import java.util.Properties;

import org.openrdf.repository.RepositoryException;
import org.openrdf.repository.config.RepositoryConfigException;
import org.openrdf.repository.manager.RepositoryInfo;
import org.openrdf.repository.manager.RepositoryManager;
import org.openrdf.repository.manager.RepositoryProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import au.org.ands.vocabs.toolkit.tasks.TaskInfo;
import au.org.ands.vocabs.toolkit.utils.ToolkitProperties;

/** Abstract class representing importer providers. */
public class SesameProvider extends ImporterProvider {

     /** Logger for this class. */
    private final Logger logger = LoggerFactory.getLogger(
            MethodHandles.lookup().lookupClass());

    /** Access to the Toolkit properties. */
    protected static final Properties PROPS = ToolkitProperties.getProperties();

    /** URL to access the Sesame server. */
    private String sesameServer =
            PROPS.getProperty("SesameImporter.serverUrl");


    /** Return information about the provider.
     * @return The information.
     */
    @Override
    public final Collection<?> getInfo() {
        RepositoryManager manager = null;
        try {
            manager = RepositoryProvider.getRepositoryManager(sesameServer);
            Collection<RepositoryInfo> infos =
                    manager.getAllRepositoryInfos(true);
            return infos;
        } catch (RepositoryConfigException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (RepositoryException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return null;
    }

    /** Do an import. Update the message parameter with the result
     * of the import.
     * @param taskInfo The TaskInfo object describing the entire task.
     * @param results HashMap representing the result of the harvest.
     * @return True, iff the import succeeded.
     */
    @Override
    public final boolean doImport(final TaskInfo taskInfo,
            final HashMap<String, String> results) {
        return true;
    }

}

@@ -1145,16 +1145,1476 @@
 Url%22);%0A%0A
+    /** Force loading of HttpClientUtils, so that shutdown works%0A     * properly. Revisit this when using a later version of Tomcat,%0A     * as the problem may be caused by a defect in Tomcat.%0A     * For now (Tomcat 7.0.61), without this, you get an error%0A     * on Tomcat shutdown:%0A     * Exception in thread %22RepositoryProvider-shutdownHook%22%0A     *  java.lang.NoClassDefFoundError:%0A     *   org/apache/http/client/utils/HttpClientUtils%0A     *    at org.openrdf.http.client.SesameClientImpl.shutDown(%0A     *    SesameClientImpl.java:102)%0A     * at org.openrdf.repository.manager.RemoteRepositoryManager.shutDown(%0A     *    RemoteRepositoryManager.java:156)%0A     * at org.openrdf.repository.manager.%0A     *   RepositoryProvider$SynchronizedManager.shutDown(%0A     *     RepositoryProvider.java:68)%0A     * at org.openrdf.repository.manager.RepositoryProvider$1.run(%0A     *   RepositoryProvider.java:81)%0A     * Caused by: java.lang.ClassNotFoundException:%0A     *    org.apache.http.client.utils.HttpClientUtils%0A     *  at org.apache.catalina.loader.WebappClassLoader.loadClass(%0A     *     WebappClassLoader.java:1720)%0A     *  at org.apache.catalina.loader.WebappClassLoader.loadClass(%0A     *     WebappClassLoader.java:1571)%0A     *  ... 4 more%0A     *%0A     */%0A    @SuppressWarnings(%22unused%22)%0A    private static final Class%3Corg.apache.http.client.utils.HttpClientUtils%3E%0A        HTTPCLIENTUTILS_CLASS =%0A            org.apache.http.client.utils.HttpClientUtils.class;%0A
 %0A    /**

Fix problem with Tomcat shutdown after having used Sesame