Example usage for org.apache.commons.logging Log isErrorEnabled

List of usage examples for org.apache.commons.logging Log isErrorEnabled

Introduction

In this page you can find the example usage for org.apache.commons.logging Log isErrorEnabled.

Prototype

boolean isErrorEnabled();

Source Link

Document

Is error logging currently enabled?

Usage

From source file:org.eclipse.smila.search.templates.NodeTransformerType.java

/**
 * Parse configuration and return according IRMType.
 * //w ww . j  a v  a  2  s.  c  o  m
 * @param configurationElement
 *          Configuration element.
 * @param ordinal
 *          Ordinal.
 * @return NodeTransformerType.
 */
public static NodeTransformerType parseType(IConfigurationElement configurationElement, int ordinal) {

    if (!configurationElement.getName().equals(TAG_NODE_TRANSFORMER)) {
        return null;
    }

    final Log log = LogFactory.getLog(NodeTransformerType.class);

    try {
        return new NodeTransformerType(configurationElement, ordinal);
    } catch (final Exception e) {
        if (log.isErrorEnabled()) {
            String name = configurationElement.getAttribute(ATT_NAME);
            if (name == null) {
                name = "[missing attribute name]";
            }
            final String msg = "Failed to load StrategyType named " + name + " in "
                    + configurationElement.getDeclaringExtension().getNamespaceIdentifier();
            log.error(msg, e);
        }
        return null;
    }
}

From source file:org.eclipse.smila.search.utils.advsearch.AdvSearchAccess.java

public static AdvSearchAccess getInstance() {
    final Log log = LogFactory.getLog(AdvSearchAccess.class);
    AdvSearchAccess[] types;// ww w . ja  v  a 2 s .c o m
    try {
        types = getTypes();
        if (types.length != 1) {
            if (log.isWarnEnabled()) {
                log.warn("invalid index structure access count [" + types.length + "]");
            }
            return null;
        }
        return types[0];
    } catch (final AdvSearchException e) {
        if (log.isErrorEnabled()) {
            log.error(e);
        }
        return null;
    }
}

From source file:org.eclipse.smila.search.utils.advsearch.AdvSearchAccess.java

/**
 * Get all available IRM types./*from w ww.j a v a2 s .  c  o  m*/
 * 
 * @return IRM types.
 */
public static AdvSearchAccess[] getTypes() throws AdvSearchException {

    if (s_cachedAdvSearchAccess != null) {
        return s_cachedAdvSearchAccess;
    }

    final Log log = LogFactory.getLog(AdvSearchAccess.class);

    final List<AdvSearchAccess> found = new ArrayList<AdvSearchAccess>();
    // TODO: Check why the next line is needed.
    // found.add(UNKNOWN);
    final IExtension[] extensions = Platform.getExtensionRegistry()
            .getExtensionPoint(EXTENSION_POINT_NAME_ADV_SEARCH_ACCESS).getExtensions();
    for (int i = 0; i < extensions.length; i++) {
        final IExtension extension = extensions[i];
        final IConfigurationElement[] configElements = extension.getConfigurationElements();

        for (int j = 0; j < configElements.length; j++) {
            final IConfigurationElement configurationElement = configElements[j];
            final String typeName = parseType(configurationElement, found.size());

            AdvSearchAccess clazz = null;
            try {
                final Object obj = configurationElement.createExecutableExtension("Clazz");
                clazz = (AdvSearchAccess) obj;
            } catch (final Exception exception) {
                if (log.isErrorEnabled()) {
                    if (configurationElement != null) {
                        log.error("Failed to instantiate adv. search access");
                    } else {
                        log.error("Unknown!");
                    }
                }
                throw new AdvSearchException("unable to load adv. search access", exception);
            }

            if (clazz != null) {
                found.add(clazz);
            }
        }
    }

    s_cachedAdvSearchAccess = found.toArray(new AdvSearchAccess[0]);
    return s_cachedAdvSearchAccess;
}

From source file:org.eclipse.smila.search.utils.advsearch.AdvSearchAccess.java

/**
 * Parse configuration and return according IRMType.
 * //from  w w  w .  j av a2  s .  c  o m
 * @param configurationElement
 *          Configuration element.
 * @param ordinal
 *          Ordinal.
 * @return Type name.
 */
public static String parseType(IConfigurationElement configurationElement, int ordinal) {

    final Log log = LogFactory.getLog(AdvSearchAccess.class);

    if (!configurationElement.getName().equals("SearchAdvAccess")) {
        return null;
    }

    try {
        String name = configurationElement.getAttribute("Clazz");
        if (name == null) {
            name = "[missing attribute name]";
        }
        return name;
    } catch (final Exception e) {
        if (log.isErrorEnabled()) {
            String name = configurationElement.getAttribute("Clazz");
            if (name == null) {
                name = "[missing attribute name]";
            }
            final String msg = "Failed to load adv. search type named " + name + " in "
                    + configurationElement.getDeclaringExtension().getNamespaceIdentifier();
            log.error(msg, e);
        }
        return null;
    }
}

From source file:org.eclipse.smila.search.utils.indexstructure.IndexStructureAccess.java

public static IndexStructureAccess getInstance() {

    final Log log = LogFactory.getLog(IndexStructureAccess.class);

    IndexStructureAccess[] types;/*from  www . ja  v a2 s .  com*/
    try {
        types = getTypes();
        if (types.length != 1) {
            if (log.isWarnEnabled()) {
                log.warn("invalid index structure access count [" + types.length + "]");
            }
            return null;
        }
        return types[0];
    } catch (final ISException e) {
        if (log.isErrorEnabled()) {
            log.error(e);
        }
        return null;
    }
}

From source file:org.eclipse.smila.search.utils.indexstructure.IndexStructureAccess.java

/**
 * Get all available IRM types./* ww  w  .java  2s.c  o m*/
 * 
 * @return IRM types.
 * @throws ISException
 *           -
 */
public static IndexStructureAccess[] getTypes() throws ISException {

    if (s_cachedIndexStructureAccess != null) {
        return s_cachedIndexStructureAccess;
    }

    final Log log = LogFactory.getLog(IndexStructureAccess.class);

    final List<IndexStructureAccess> found = new ArrayList<IndexStructureAccess>();
    // TODO: Check why the next line is needed.
    // found.add(UNKNOWN);
    final IExtension[] extensions = Platform.getExtensionRegistry()
            .getExtensionPoint(EXTENSION_POINT_NAME_INDEX_STRUCTURE_ACCESS).getExtensions();
    for (int i = 0; i < extensions.length; i++) {
        final IExtension extension = extensions[i];
        final IConfigurationElement[] configElements = extension.getConfigurationElements();

        for (int j = 0; j < configElements.length; j++) {
            final IConfigurationElement configurationElement = configElements[j];
            final String typeName = parseType(configurationElement, found.size());

            IndexStructureAccess clazz = null;
            try {
                final Object obj = configurationElement.createExecutableExtension("Clazz");
                clazz = (IndexStructureAccess) obj;
            } catch (final Exception exception) {
                if (log.isErrorEnabled()) {
                    if (configurationElement != null) {
                        log.error("Failed to instantiate index structure access");
                    } else {
                        log.error("Unknown!");
                    }
                }
                throw new ISException("unable to load index structure access", exception);
            }

            if (clazz != null) {
                found.add(clazz);
            }
        }
    }

    s_cachedIndexStructureAccess = found.toArray(new IndexStructureAccess[0]);
    return s_cachedIndexStructureAccess;
}

From source file:org.eclipse.smila.search.utils.indexstructure.IndexStructureAccess.java

/**
 * Parse configuration and return according IRMType.
 * /*  w w  w. j  a va 2s.  c o m*/
 * @param configurationElement
 *          Configuration element.
 * @param ordinal
 *          Ordinal.
 * @return Type name.
 */
public static String parseType(IConfigurationElement configurationElement, int ordinal) {

    if (!configurationElement.getName().equals("IndexStructureAccess")) {
        return null;
    }

    final Log log = LogFactory.getLog(IndexStructureAccess.class);

    try {
        String name = configurationElement.getAttribute("Clazz");
        if (name == null) {
            name = "[missing attribute name]";
        }
        return name;
    } catch (final Exception e) {
        if (log.isErrorEnabled()) {
            String name = configurationElement.getAttribute("Clazz");
            if (name == null) {
                name = "[missing attribute name]";
            }
            final String msg = "Failed to load StrategyType named " + name + " in "
                    + configurationElement.getDeclaringExtension().getNamespaceIdentifier();
            log.error(msg, e);
        }
        return null;
    }
}

From source file:org.eclipse.smila.search.utils.param.def.DParameterDefinition.java

public static void main(String[] arg) {
    final Log log = LogFactory.getLog(DParameterDefinition.class);
    try {/*w ww. ja  v a2  s.  co  m*/
        final org.w3c.dom.Document d = XMLUtils
                .parse(new java.io.File("d:/anyfinder/af-engine-sdk/xml/param-testcase.xml"), true);
        final DParameterDefinition pset = DParameterDefinitionCodec.decode(d.getDocumentElement());

        final org.w3c.dom.Document d2 = XMLUtils.getDocument("top");
        final org.w3c.dom.Element e = d2.getDocumentElement();
        final org.w3c.dom.Element pelement = DParameterDefinitionCodec.encode(pset, e);

        XMLUtils.stream(pelement, false, "UTF-8", System.err);
    } catch (final Exception e) {
        if (log.isErrorEnabled()) {
            log.error(e);
        }
    }
}

From source file:org.eclipse.smila.search.utils.param.ParameterSet.java

public static void main(String[] arg) {
    final Log log = LogFactory.getLog(ParameterSet.class);
    try {/*from  ww  w  .j a va2 s  .  c  o  m*/

        // DParameterSet einlesen
        org.w3c.dom.Document d = XMLUtils
                .parse(new java.io.File("d:/anyfinder/af-engine-sdk/xml/param-testcase.xml"), true);
        final DParameterSet pset = DParameterSetCodec.decode(d.getDocumentElement());

        org.w3c.dom.Document d2 = XMLUtils.getDocument("top");
        org.w3c.dom.Element e = d2.getDocumentElement();
        org.w3c.dom.Element pelement = DParameterSetCodec.encode(pset, e);

        XMLUtils.stream(pelement, false, "UTF-8", System.err);

        // DParameterDefinition einlesen
        d = XMLUtils.parse(new java.io.File("d:/anyfinder/af-engine-sdk/xml/paramdef-testcase.xml"), true);
        final DParameterDefinition pdef = DParameterDefinitionCodec.decode(d.getDocumentElement());

        d2 = XMLUtils.getDocument("top");
        e = d2.getDocumentElement();
        pelement = DParameterDefinitionCodec.encode(pdef, e);

        XMLUtils.stream(pelement, false, "UTF-8", System.err);

        // ParameterSet erzeugen
        final ParameterSet ps = new ParameterSet(pset, pdef);

        final Enumeration en = ps.getParameterNames();
        for (; en.hasMoreElements();) {
            final String pname = (String) en.nextElement();
            final String ptype = ps.getParameterType(pname);
            Object value = ps.getParameter(pname);
            if (ptype.indexOf("List") >= 0) {
                String newValue = "";

                for (int i = 0; true; i++) {
                    try {
                        newValue += Array.get(value, i);
                        Array.get(value, i + 1);
                        newValue += ", ";
                    } catch (final ArrayIndexOutOfBoundsException iae) {
                        break;
                    }
                }
                value = newValue;
            }
            if (log.isInfoEnabled()) {
                log.info(pname + "(" + ptype + "):\t" + value);
            }
        }
    } catch (final Exception e) {
        if (log.isErrorEnabled()) {
            log.error(e);
        }
    }
}

From source file:org.eclipse.smila.search.utils.search.SearchAccess.java

public static SearchAccess getInstance() {

    final Log log = LogFactory.getLog(SearchAccess.class);

    SearchAccess[] types;/*ww w  .  j  a v a  2 s.c  om*/
    try {
        types = getTypes();
        if (types.length != 1) {
            if (log.isWarnEnabled()) {
                log.warn("invalid index structure access count [" + types.length + "]");
            }
            return null;
        }
        return types[0];
    } catch (final DSearchException e) {
        if (log.isErrorEnabled()) {
            log.error(e);
        }
        return null;
    }
}