/*
 * Copyright 2014 Gabriel Harris-Rouquette
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http:www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.afterkraft.kraftrpg.storage;

import com.afterkraft.kraftrpg.KraftRPGPlugin;
import com.afterkraft.kraftrpg.api.ExternalProviderRegistration;
import com.afterkraft.kraftrpg.api.Manager;
import com.afterkraft.kraftrpg.api.storage.StorageBackend;
import com.afterkraft.kraftrpg.api.storage.StorageFrontend;

public class RPGStorageManager implements Manager {
    private final KraftRPGPlugin plugin;
    private StorageFrontend storage;

    public RPGStorageManager(KraftRPGPlugin plugin) {
        this.plugin = plugin;
    }

    @Override
    public void initialize() {
        String configuredBackend = plugin.getProperties().getStorageType();
        StorageBackend backend = ExternalProviderRegistration.getStorageBackendMap().get(configuredBackend);
        if (backend == null) {
            plugin.getLogger().severe("ERROR - You specified the '" + configuredBackend + "' storage type, but that storage type is not available.");
            StringBuilder sb = new StringBuilder("Available storage types are:");
            for (String str : ExternalProviderRegistration.getStorageBackendMap().keySet()) {
                sb.append(" ").append(str);
            }
            plugin.getLogger().severe(sb.toString());
            plugin.cancelEnable();
            return;
        }

        boolean error;
        try {
            error = !backend.initialize();
        } catch (Throwable e) {
            error = true;
            e.printStackTrace();
        }
        if (error) {
            plugin.getLogger().severe("The storage backend '" + configuredBackend + "' threw an exception during startup.");
            plugin.cancelEnable();
            return;
        }

        storage = ExternalProviderRegistration.getStorageFrontendOverride().construct(plugin, backend);
    }

    public StorageFrontend getStorage() {
        return storage;
    }

    @Override
    public void shutdown() {
        storage.shutdown();
    }
}

@@ -1909,31 +1909,8 @@
  %7D%0A%0A
-        boolean error;%0A
     
@@ -1935,17 +1935,8 @@
     
-error = !
 back
@@ -2002,84 +2002,27 @@
    e
-rror = true;%0A            e.printStackTrace();%0A        %7D%0A        if (error) %7B
+.printStackTrace();
 %0A   

Simplify initialize() call