Package com.google.enterprise.connector.instantiator

Examples of com.google.enterprise.connector.instantiator.Instantiator


   * @return a ImportExportConnectorList
   */
  @VisibleForTesting
  static final ImportExportConnectorList getConnectors() {
    ImportExportConnectorList connectors = new ImportExportConnectorList();
    Instantiator instantiator = Context.getInstance().getInstantiator();
    for (String connectorName : instantiator.getConnectorNames()) {
      try {
        Configuration configuration =
            instantiator.getConnectorConfiguration(connectorName);
        if (configuration != null) {
          Schedule schedule = instantiator.getConnectorSchedule(connectorName);
          connectors.add(new LegacyImportExportConnector(
              connectorName, configuration, schedule, null));
        }
      } catch (ConnectorNotFoundException e) {
        // This shouldn't happen.
View Full Code Here


   *        which are not included in {@code connectors} if and only if
   *        {@code noremove} is {@code false}.
   */
  static final void setConnectors(ImportExportConnectorList connectors,
      boolean noRemove) {
    Instantiator instantiator = Context.getInstance().getInstantiator();
    Set<String> previousConnectorNames =
        new HashSet<String>(instantiator.getConnectorNames());

    for (ImportExportConnector connector : connectors) {
      String name = connector.getName();
      try {
        // Store the Configuration.
        boolean update = previousConnectorNames.contains(name);
        Configuration configuration = connector.getConfiguration();
        ConfigureResponse configureResponse =
            instantiator.setConnectorConfiguration(name, configuration,
                                                   Locale.ENGLISH, update);
        if (configureResponse != null) {
          LOGGER.warning("setConnectorConfiguration(name=" + name + "\"): "
                         + configureResponse.getMessage());
          continue;
        }

        // Store the Schedule.
        instantiator.setConnectorSchedule(name, connector.getSchedule());

        previousConnectorNames.remove(name);
      } catch (ConnectorNotFoundException e) {
        // This shouldn't happen.
        LOGGER.warning("Connector " + name + " not found!");
      } catch (ConnectorExistsException e) {
        // This shouldn't happen.
        LOGGER.warning("Connector " + name + " already exists!");
      } catch (ConnectorTypeNotFoundException e) {
        LOGGER.warning("Connector Type " + connector.getTypeName()
                       + " not found!");
      } catch (InstantiatorException e) {
        LOGGER.log(Level.WARNING, "Failed to create connector " + name + ": ",
                   e);
      }
    }

    // Remove previous connectors which no longer exist.
    if (!noRemove) {
      for (String name : previousConnectorNames) {
        try {
          instantiator.removeConnector(name);
        } catch (InstantiatorException e) {
          LOGGER.log(Level.WARNING, "Failed to remove connector " + name + ": ",
                     e);
        }
      }
View Full Code Here

TOP

Related Classes of com.google.enterprise.connector.instantiator.Instantiator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.