/*
 * This file is part of the DITA Open Toolkit project.
 * See the accompanying license.txt file for applicable licenses.
 */

/*
 * (c) Copyright IBM Corp. 2005, 2006 All Rights Reserved.
 */
package org.dita.dost.util;

import static org.dita.dost.util.Constants.*;

import java.io.File;
import java.util.HashMap;

import org.apache.xml.resolver.Catalog;
import org.apache.xml.resolver.CatalogManager;
import org.apache.xml.resolver.tools.CatalogResolver;
import org.dita.dost.log.DITAOTJavaLogger;

/**
 * General catalog file resolving utilities.
 * @version 1.0 2005-4-11
 * @author Zhang, Yuan Peng
 */

public final class CatalogUtils {
    /**logger to log informations.*/
    private static DITAOTJavaLogger logger = new DITAOTJavaLogger();
    /**apache catalogResolver.*/
    private static CatalogResolver catalogResolver = null;
    /**
     * Instances should NOT be constructed in standard programming.
     */
    private CatalogUtils() {
        // leave blank as designed
    }

    /**
     * Get CatalogResolver.
     * @return CatalogResolver
     */
    public static synchronized CatalogResolver getCatalogResolver() {
        if (catalogResolver == null) {
            final CatalogManager manager = new CatalogManager();
            manager.setIgnoreMissingProperties(true);
            manager.setUseStaticCatalog(false); // We'll use a private catalog.
            manager.setPreferPublic(true);

            //manager.setVerbosity(10);
            catalogResolver = new CatalogResolver(manager);

            final File catalogFilePath = new File(Configuration.pluginResourceDirs.get("org.dita.base"), FILE_NAME_CATALOG);

            final Catalog catalog = catalogResolver.getCatalog();
            try {
                catalog.parseCatalog(catalogFilePath.toURI().toURL());
            } catch (final Exception e) {
                logger.logError(e.getMessage(), e) ;
            }
        }

        return catalogResolver;
    }
}


@@ -289,74 +289,8 @@
 le;%0A
-import java.util.HashMap;%0A%0Aimport org.apache.xml.resolver.Catalog;
 %0Aimp
@@ -390,51 +390,8 @@
 ver;
-%0Aimport org.dita.dost.log.DITAOTJavaLogger;
 %0A%0A/*
@@ -534,113 +534,8 @@
 s %7B%0A
-    /**logger to log informations.*/%0A    private static DITAOTJavaLogger logger = new DITAOTJavaLogger();
 %0A   
@@ -1208,110 +1208,8 @@
 e);%0A
-%0A            //manager.setVerbosity(10);%0A            catalogResolver = new CatalogResolver(manager);%0A%0A
     
@@ -1329,17 +1329,16 @@
 TALOG);%0A
-%0A
         
@@ -1345,49 +1345,17 @@
     
-final Catalog catalog = catalogResolver.g
+manager.s
 etCa
@@ -1363,66 +1363,13 @@
 alog
-();%0A            try %7B%0A                catalog.parseCatalog
+Files
 (cat
@@ -1395,11 +1395,14 @@
 ).to
-URL
+String
 ());
@@ -1418,104 +1418,95 @@
     
-%7D catch (final Exception e) %7B%0A                logger.logError(e.getMessage(), e) ;%0A            %7D
+//manager.setVerbosity(10);%0A            catalogResolver = new CatalogResolver(manager);
 %0A   

Refactor catalog manager initialization