Copyright ©
Mindbreeze GmbH, A-4020 Linz, .
All rights reserved. All hardware and software names used are registered trade names and/or registered trademarks of the respective manufacturers.
These documents are highly confidential. No rights to our software or our professional services, or results of our professional services, or other protected rights can be based on the handing over and presentation of these documents.
Distribution, publication or duplication is not permitted.
The term ‘user‘ is used in a gender-neutral sense throughout the document.
For building and deploying the examples from this document, the following third party Software is needed:
Java SE Development Kit: Version 1.8 or newer
Eclipse IDE for Java Developers
If you are using Microsoft Windows: install the Mindbreeze SDK by executing MesSDKSetup.exe
Linux or OSX: extract the mes-devel-<version>.zip to a folder of your choice and add the SDK/bin folder from the archive to your Path variable.
The Mindbreeze Software Development Toolkit contains a tool for generating Mindbreeze Plugin Projects called mesjavaplugin.bat in case of Microsoft Windows installations and mesjavaplugin.sh for Unix-based systems. The tool can be used for generating the following Mindbreeze extension types:
datasource: crawler, context and authorization plugin for a given data source
filter: filter plugin for a given data type
postfilter: post filter transformation plugin
itemtransformer: item transformation plugin
Called without parameter the mesjavaplugin tool displays its usage with examples:
The <name> parameter is the name of the plugin. The project will be generated in a folder with the name of this parameter lowercased in the current path.
The <base package> parameter is the java package where the source files will be generated.
Please follow these steps to generate and deploy a post filter transformation plugin for editing or adding custom metadata:
Create the plugin project:
mesjavaplugin.sh postfilter MetadataProcessor com.mycompany
Navigate to the metadataprocessor folder in your current path.
Import the newly created project into your Eclipse IDE:
After successfully importing the Project you will find a stub implementation of the plugin in the MetadataProcessorPostFilter.java file:
Note that the name of the Java file is <name>PostFilter.java where <name> is the plugin name parameter from the previous step.
Extend the source code to fit for your needs. For example an implementation that would add a metadata to the document named “meta” with a string value of : “value” would be the following:
private void processRequest(FilterAndIndexRequest.Builder request) {
// Clone the request
Metadata.Builder metadataBuilder = request.getContentBuilder().getMetadataBuilder();
NamedValue.Builder namedValueBuilder = NamedValue.newBuilder();
namedValueBuilder.setName("meta");
namedValueBuilder.addValue(ValueHelper.newBuilder("value"));
metadataBuilder.addMetadatum(namedValueBuilder)
}
Build the plugin archive by executing the script build.bat on Windows Systems or build.sh on Unix in the project directory. If the process is successful, an archive with the name <name>-postfilter.zip should be produced. <name> is here again the plugin name parameter specified.
The plugin is ready to be installed with the Mindbreeze Configuration Interface:
After successful installation the plugin can be activated for any Filter service:
Please follow these steps to generate an item transformer plugin for editing or adding custom metadata:
Create the plugin project:
mesjavaplugin.sh itemtransformer MetadataProcessor com.mycompany
Navigate to the metadataprocessor folder in your current path.
Import the newly created project into your Eclipse IDE (As in the previous example).
After successfully importing the Project you will find a stub implementation of the plugin in the MetadataProcessorItemTransformerService.java file:
Extend the code according to your needs. An example that again adds a metadata named “meta” with the value “value” is the following:
private void processItem(Item.Builder itemBuilder) {
itemBuilder.addProperty(
NamedValue.newBuilder()
.setName("meta")
.addValue(ValueHelper.newBuilder("value"))
);
}
Build the plugin archive by executing the script build.bat on Windows Systems or build.sh on Unix in the project directory. If the process is successful, an archive with the name <name>-postfilter.zip should be produced. <name> is here again the plugin name parameter specified.
The plugin is ready to be installed with the Mindbreeze Configuration Interface:
After a successful installation the Plugin is available for all Index Services.
As you could see in both examples, it is possible to define properties for the installed Plugins from the configuration interface by adding custom plugin properties.
These configuration properties are accessible in the plugin source code from the properties map:
Map<String, List<String>> properties = null;
The init method that is retrieving the configuration properties is called automatically if the plugin implements the com.mindbreeze.enterprisesearch.mesapi.Initializable interface.
The previous example of an itemtransformer plugin now setting a metadata value to a configuration parameter named “meta” looks like:
private void processItem(Item.Builder itemBuilder) {
if (properties != null && properties.containsKey("meta")) {
List<String> values = properties.get("meta");
if (values != null && !values.isEmpty()) {
String value = values.get(0);
if (value != null) {
itemBuilder.addProperty(
NamedValue.newBuilder()
.setName("meta")
.addValue(ValueHelper.newBuilder(value))
);
}
}
}
}
The plugins.xml Plugin Descriptor describes the Plugins available in the archive. The main outline is as follows:
version
plugins
Plugin
id
kind
extension
code
if kind is CODE
properties
for predefined properties that are passed to the Plugin
config_options
<config_option>
<Group>
<label>
<LangString>
<lang>en</lang>
<value>Base Configuration</value>
</LangString>
</label>
<level>DEFAULT_LEVEL</level>
<option>
<Option>
<name>meta</name>
<input>TEXT</input>
<hint>The value that is added as the meta property.</hint>
<label>
<LangString>
<lang>en</lang>
<value>meta property value</value>
</LangString>
</label>
<option />
</Option>
</option>
</Group>
</config_option>