List of usage examples for org.apache.commons.logging Log error
void error(Object message);
From source file:org.eclipse.smila.search.datadictionary.DataDictionaryAccess.java
/** * DataDicitonaryAccess.//from w ww . j a va 2 s . com * * @return - an access object. */ public static DataDictionaryAccess getInstance() { final Log log = LogFactory.getLog(DataDictionaryAccess.class); DataDictionaryAccess[] types; try { types = getTypes(); if (types.length != 1) { if (log.isWarnEnabled()) { log.warn("invalid data dictionary access count [" + types.length + "]"); } return null; } return types[0]; } catch (final DataDictionaryException e) { if (log.isErrorEnabled()) { log.error(e); } return null; } }
From source file:org.eclipse.smila.search.datadictionary.DataDictionaryAccess.java
/** * Get all available IRM types./*from ww w . j a va2s . c o m*/ * * @return IRM types. * @throws DataDictionaryException * DataDictionaryException. */ public static DataDictionaryAccess[] getTypes() throws DataDictionaryException { if (s_cachedDataDictionaryAccess != null) { return s_cachedDataDictionaryAccess; } final Log log = LogFactory.getLog(DataDictionaryAccess.class); final List<DataDictionaryAccess> found = new ArrayList<DataDictionaryAccess>(); // TODO: Check why the next line is needed. // found.add(UNKNOWN); final IExtension[] extensions = Platform.getExtensionRegistry() .getExtensionPoint(EXTENSION_POINT_NAME_DATA_DICTIONARY_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]; DataDictionaryAccess clazz = null; try { final Object obj = configurationElement.createExecutableExtension("Clazz"); clazz = (DataDictionaryAccess) obj; } catch (final Exception exception) { if (log.isErrorEnabled()) { if (configurationElement != null) { log.error("Failed to instantiate data dictionary access"); } else { log.error("Unknown!"); } } throw new DataDictionaryException("unable to load data dictionary access", exception); } if (clazz != null) { found.add(clazz); } } } s_cachedDataDictionaryAccess = found.toArray(new DataDictionaryAccess[0]); return s_cachedDataDictionaryAccess; }
From source file:org.eclipse.smila.search.EIFActivator.java
public synchronized static void registerSchemas() { if (schemasInitialized) { return;/*w w w . j ava2 s.c o m*/ } final Log log = LogFactory.getLog(EIFActivator.class); try { final String[] schemas = { "ParameterDescriptions.xsd", "ParameterSet.xsd", "ParameterDefinition.xsd", "ErrorMessage.xsd", "AnyFinderSearchDateFieldParameter.xsd", "AnyFinderSearchNumberFieldParameter.xsd", "AnyFinderSearchTextFieldParameter.xsd", "AnyFinderEngineData.xsd", "SearchParameterObjects.xsd", "DataDictionaryConfiguration.xsd", "DataDictionaryConnection.xsd", "IndexStructure.xsd", "Queue.xsd", "RapidDeployerAdvancedSearchTemplateFields.xsd", "RapidDeployerIndexStructure.xsd", "RecordTransformationDefinition.xsd", "RecordTransformationProcess.xsd", "RecordTransformationSet.xsd", "SimpleTypeDefs.xsd", "AnyFinderAdvancedSearch.xsd", "AnyFinderDataDictionary.xsd", "AnyFinderSearch.xsd", "FieldTemplates.xsd", "SearchTemplates.xsd", "AnyFinderFieldRequest.xsd", "HighlightingTransformerRegistry.xsd", "NodeTransformerRegistry.xsd", "TransformerRegistry.xsd" }; XMLUtils.clearGrammarCache(); // read all schemas in defined order for (final String schema : schemas) { XMLUtils.loadSchema("../xml/" + schema, EIFActivator.s_bundleContext); } schemasInitialized = true; } catch (final Exception exception) { if (log.isErrorEnabled()) { log.error(exception); } } }
From source file:org.eclipse.smila.search.index.IndexConnection.java
/** * This method extends a given search query with all possible configurable attributes. Additionally checks this method * wether there are any conflicts with the index structure or the query constraints. * /*from w w w . jav a 2 s . c o m*/ * @param dQuery * - * @throws IndexException * - */ public void validateQuery(final DQuery dQuery) throws IndexException { final Log log = LogFactory.getLog(getClass()); final Hashtable<Integer, DField> queryFields = new Hashtable<Integer, DField>(); final DConfiguration dConfig = _index.getConfiguration(); // 1. check fields of query against index. // 2. apply configuration settings Enumeration fields = dQuery.getFields(); while (fields.hasMoreElements()) { final DField field = (DField) fields.nextElement(); if (!_index.getIndexStructure().hasField(field.getFieldNo())) { throw new IndexException( "field in search query does not exist in index [" + field.getFieldNo() + "]"); } // checks whether types of search field and index field are compatible. // for checking, the type taken from the index field's default configuration will be used, // because there we already have simple search types, whereas in the index structure, // different types may be used (e. g. Date may be represented by Number) if (!dConfig.getDefaultConfig().getField(field.getFieldNo()).getFieldConfig().getType() .equals(field.getType())) { throw new IndexException("field type in search query does not match field type in index [" + field.getFieldNo() + "]"); } // get default whole parameterization DFieldConfig fc = null; // check for named config if (field.getParameterDescriptor() != null) { DNamedConfig nc = null; if (!dConfig.hasNamedConfig(field.getParameterDescriptor())) { log.error("unable to locate named config for index [" + dQuery.getIndexName() + ";" + field.getParameterDescriptor() + "]"); } else { nc = dConfig.getNamedConfig(field.getParameterDescriptor()); if (nc != null) { // check for field type specifig named config fc = nc.getFieldConfig(field); if (fc == null) { log.error("unable to locate named config for index [" + dQuery.getIndexName() + ";" + field.getParameterDescriptor() + ";" + field.getType() + "]"); } } } } final DFieldConfig defaultfc = dConfig.getDefaultConfig().getField(field.getFieldNo()).getFieldConfig(); // set default config applyFieldConfig(field, fc, defaultfc); queryFields.put(new Integer(field.getFieldNo()), field); } // 3. check query constraints for simple search. final DQueryConstraints queryConstraints = dConfig.getQueryConstraints(); if (queryConstraints != null) { for (int i = 0; i < queryConstraints.getFieldConstraintsLength(); i++) { final DFieldConstraints dFieldConstraints = queryConstraints.getFieldConstraints(i); final String occurrence = dFieldConstraints.getOccurrence(); if (occurrence.equals("required")) { if (!queryFields.containsKey(new Integer(dFieldConstraints.getFieldNo()))) { throw new IndexException( "query constraint requires field [" + dFieldConstraints.getFieldNo() + "]"); } } else if (occurrence.equals("prohibited")) { if (queryFields.containsKey(new Integer(dFieldConstraints.getFieldNo()))) { throw new IndexException( "query constraint prohibits field [" + dFieldConstraints.getFieldNo() + "]"); } } // check further query constraints final DField field = queryFields.get(new Integer(dFieldConstraints.getFieldNo())); if (field == null) { continue; } if (dFieldConstraints.getFieldTemplateCount() > 0) { boolean matchConstraint = false; final String[] fieldTemplates = dFieldConstraints.getFieldTemplates(); final String fieldTemplate = field.getFieldTemplate() != null ? field.getFieldTemplate().trim() : ""; for (final String fieldTemplate2 : fieldTemplates) { if (fieldTemplate2.equals(fieldTemplate)) { matchConstraint = true; break; } } if (!matchConstraint) { throw new IndexException("query field does not match field template constraint [" + field.getFieldNo() + "]"); } } if (dFieldConstraints.getNodeTransformerCount() > 0) { boolean matchConstraint = false; final String[] nodeTransformers = dFieldConstraints.getNodeTransformers(); final String nodeTransformerName = field.getNodeTransformer() != null ? field.getNodeTransformer().getName() : ""; for (final String nodeTransformer : nodeTransformers) { if (nodeTransformer.equals(nodeTransformerName)) { matchConstraint = true; break; } } if (!matchConstraint) { throw new IndexException("query field does not match node transformer constraint [" + field.getFieldNo() + "]"); } } if (dFieldConstraints.getConstraintCount() > 0) { boolean matchConstraint = false; final String[] constraints = dFieldConstraints.getConstraints(); final String constraint = field.getConstraint() != null ? field.getConstraint() : ""; for (final String constraint2 : constraints) { if (constraint2.equals(constraint)) { matchConstraint = true; break; } } if (!matchConstraint) { throw new IndexException( "query field does not match constraint constraint [" + field.getFieldNo() + "]"); } } } } // apply field valiadtion and transformation fields = dQuery.getFields(); while (fields.hasMoreElements()) { final DField field = (DField) fields.nextElement(); if (field instanceof DTextField) { encodeTextField((DTextField) field); } } }
From source file:org.eclipse.smila.search.plugin.PluginFactory.java
public static Plugin getPlugin() { synchronized (s_object) { final Log log = LogFactory.getLog(PluginFactory.class); if (s_plugin == null) { try { initialize();/*w ww .jav a2 s .com*/ } catch (final PluginException exception) { if (log.isErrorEnabled()) { log.error(exception); } } } return s_plugin; } }
From source file:org.eclipse.smila.search.plugin.PluginFactory.java
public static Plugin getInstance() { // TODO: implement correctly final Log log = LogFactory.getLog(PluginFactory.class); Plugin[] types;// w w w .j ava 2 s . co m try { types = getTypes(); if (types.length != 1) { if (log.isWarnEnabled()) { log.warn("invalid plugin count [" + types.length + "]"); } return null; } return types[0]; } catch (final PluginException e) { if (log.isErrorEnabled()) { log.error(e); } return null; } }
From source file:org.eclipse.smila.search.plugin.PluginFactory.java
/** * Get all available IRM types./*from ww w.ja va 2s . c om*/ * * @return IRM types. * @throws PluginException - */ public static Plugin[] getTypes() throws PluginException { final Log log = LogFactory.getLog(PluginFactory.class); final List<Plugin> found = new ArrayList<Plugin>(); // TODO: Check why the next line is needed. // found.add(UNKNOWN); final IExtension[] extensions = Platform.getExtensionRegistry() .getExtensionPoint(EXTENSION_POINT_NAME_PLUGIN).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()); Plugin clazz = null; try { final Object obj = configurationElement.createExecutableExtension("Clazz"); clazz = (Plugin) obj; } catch (final Exception exception) { if (log.isErrorEnabled()) { if (configurationElement != null) { log.error("Failed to instantiate plugin"); } else { log.error("Unknown!"); } } throw new PluginException("unable to load plugin", exception); } if (clazz != null) { found.add(clazz); } } } return found.toArray(new Plugin[0]); }
From source file:org.eclipse.smila.search.templates.NodeTransformerRegistryController.java
/** * @return DNodeTransformerRegistry//w w w . java 2s.co m */ public static DNodeTransformerRegistry getNodeTransformer() { final Log log = LogFactory.getLog(NodeTransformerRegistryController.class); final Hashtable<String, NodeTransformerType> nodeTransformers = NodeTransformerType.getTypes(); final DNodeTransformerRegistry registry = new DNodeTransformerRegistry(); for (final NodeTransformerType nodeTransformerType : nodeTransformers.values()) { final DNodeTransformer nt = new DNodeTransformer(); nt.setClassName(nodeTransformerType.getClass().getName()); nt.setDescription(nodeTransformerType.getName()); nt.setName(nodeTransformerType.getName()); try { nt.setParameterDefinition(nodeTransformerType.getParameterDefinition()); } catch (final NodeTransformerException exception) { if (log.isErrorEnabled()) { log.error(exception); } } registry.addNodeTransformer(nt); } return registry; }
From source file:org.eclipse.smila.search.templates.NodeTransformerType.java
/** * Load a IRM reference.// w w w. ja v a 2 s . c o m * * @return IRM. * @throws NodeTransformerException * Unable to load IRM. */ public NodeTransformer loadNodeTransformer() throws NodeTransformerException { if (_nodeTransformer != null) { return _nodeTransformer; } final Log log = LogFactory.getLog(NodeTransformerType.class); try { final Object obj = _configurationElement.createExecutableExtension(ATT_CLASS_NAME); _nodeTransformer = (NodeTransformer) obj; return _nodeTransformer; } catch (final Exception exception) { if (log.isErrorEnabled()) { if (_configurationElement != null) { log.error(("Failed to instantiate node transformer: " + _configurationElement.getAttribute(ATT_CLASS_NAME) + " in uri: " + _name + " in plugin: " + _configurationElement.getDeclaringExtension().getNamespaceIdentifier())); } else { log.error("Unknown!"); } } throw new NodeTransformerException("unable to load node transformer", exception); } }
From source file:org.eclipse.smila.search.templates.TemplateRegistryController.java
/** * Resolves all search templates for a given index. * /* www . j a v a 2 s . c o m*/ * @param indexName * Index name. * @return Search templates. * @throws TemplateException * Unable to get search templates. */ public static DSearchTemplates getSearchTemplates(String indexName) throws TemplateException { final Log log = LogFactory.getLog(TemplateRegistryController.class); checkIndexExistance(indexName); synchronized (s_searchTemplates) { if (s_searchTemplates.containsKey(indexName)) { return s_searchTemplates.get(indexName); } else { DSearchTemplates templates = null; final File file = getSearchTemplateFile(indexName); // create dummy template if (!file.exists()) { templates = new DSearchTemplates(); templates.setIndexName(indexName); saveTemplateToDisk(templates); } else { // load template file try { final Document doc = XMLUtils.parse(file, new XMLUtilsConfig()); templates = DSearchTemplatesCodec.decode(doc.getDocumentElement()); } catch (final XMLUtilsException e) { log.error(e.getMessage()); throw new TemplateException("unable parse templates file [" + file.getName() + "]", e); } catch (final DSearchTemplatesException e) { log.error("unable to load templates file [" + file.getName() + "]", e); throw new TemplateException("unable decode templates file [" + file.getName() + "]", e); } } // register file s_searchTemplates.put(indexName, templates); return templates; } } }