Create a Search Plug-in Component

A search plug-in component is needed to carry out the following tasks:

Create the queries required by the external search service

An OpenSearch service is initially accessed by sending an HTTP GET request to its descriptor URI. The returned descriptor is a document that describes the service's search query format. The search plug-in component converts user search queries into the format described in the returned descriptor.

Convert returned search results

The search results are returned in an Atom feed. The search plug-in converts them to model objects that can be manipulated by Content Studio.

Provide suitable behavior for result items

The result items need to be displayed in the search result area along with other search results, and it should be possible for users to manipulate them in the same ways as other result items (where appropriate). The search plug-in can therefore be used to provide the result items with suitable icons, context menu options and suitable behavior for click, drag and drop events.

To create a search plug-in component, you need to implement the interface com.escenic.studio.search.SearchPlugin. For example:

package com.example.studio;

import com.escenic.domain.OpenSearchSyndEntryReference;
import com.escenic.model.search.Query;
import com.escenic.studio.SearchMenuAction;
import com.escenic.studio.search.SearchPlugin;
import com.escenic.studio.search.SearchResultEntryModel;

import com.sun.syndication.feed.synd.SyndEntry;

import java.net.URI;
import java.util.Collections;
import java.util.List;

public class ExampleSearchPlugin implements SearchPlugin<SearchResultEntryModel> {
  @Override
  public boolean supports(final List<SearchResultEntryModel> pReferences) {
    boolean shouldSupport = false;
    //TODO:: support check
    return shouldSupport;
  }

  @Override
  public List<SearchMenuAction> getContextMenuActions(final List<SearchResultEntryModel> pReferences) {
    SearchMenuAction action = new SearchMenuAction() {
      @Override
      public String getActionKey() {
        return "action.createSelected";
      }

      @Override
      public void actionPerformed(final List<OpenSearchSyndEntryReference> pReferences) {
        //TODO:: handle the click event on the menu
      }
    };

    return Collections.singletonList(action);
  }

  @Override
  public SearchMenuAction getClickAction(final List<SearchResultEntryModel> pReferences) {
    return new SearchMenuAction() {
      @Override
      public String getActionKey() {
        return "action.openClicked";
      }

      @Override
      public void actionPerformed(final List<OpenSearchSyndEntryReference> pReferences) {
        //TODO: handle the click event
      }
    };
  }

  @Override
  public SearchResultEntryModel getContentReferenceFromEntry(final SyndEntry pEntry) {
    SearchResultEntryModel model = null;
    //TODO:: implementation logic for the conversion
    return model;
  }

  @Override
  public URI createURIFromTemplate(final String pTemplate, final Query pQuery, final int pPage, final int pPageSize) {
    URI searchURI = null;
    //TODO:: The template expansion logic
    return searchURI;
  }
}

To register your implementation as a Content Studio plug-in component you must:

  1. Create a .properties file for the class you have created and add it to your Content Studio configuration layer (see Content Studio Configuration Layer). For the example class above you would probably add a file called studio-configuration-root/com/example/studio/ExampleSearchPlugin.properties. The file must at least contain the following line (plus any property settings your component requires):

    $class=com.example.studio.ExampleSearchPlugin
  2. Edit the file studio-configuration-root/com/escenic/studio/search/SearchPluginManager.properties in your Content Studio configuration layer. If the file does not already exist in your Content Studio configuration layer, then create it. Add an entry like this:

    plugin.search-plugin-name=/com/example/studio/ExampleSearchPlugin

    where search-plugin-name is the name you want to use to identify your component.