@Activate
  protected final void activate(final Map<String, String> properties) throws Exception {
    this.transformName = PropertiesUtil.toString(properties.get(PROP_NAME), DEFAULT_TRANSFORM_NAME);

    log.info("Registering Named Image Transfomer: {}", this.transformName);

    final Map<String, String> map =
        OsgiPropertyUtil.toMap(
            PropertiesUtil.toStringArray(properties.get(PROP_TRANSFORMS), new String[] {}),
            ":",
            true,
            null);

    for (final Map.Entry<String, String> entry : map.entrySet()) {
      final String[] params = StringUtils.split(entry.getValue(), "&");
      final Map<String, String> values = OsgiPropertyUtil.toMap(params, "=", true, null);

      log.debug("ImageTransform params for [ {} ] ~> {}", entry.getKey(), values);

      // Order matters so use a LinkedHashMap
      this.transforms.put(entry.getKey(), TypeUtil.toValueMap(values));
    }

    log.info("Named Images Transforms: {}", this.transforms.size());
    for (final Map.Entry<String, ValueMap> entry : this.transforms.entrySet()) {
      log.info("{} ~> {}", entry.getKey(), entry.getValue());
    }
  }
 @Activate
 private void activate(ComponentContext componentContext) {
   Dictionary config = componentContext.getProperties();
   requestThreadLocal =
       PropertiesUtil.toBoolean(
           config.get(PARAM_REQUEST_THREAD_LOCAL), PARAM_REQUEST_THREAD_LOCAL_DEFAULT);
 }
 protected final void unbindTagDataConverter(
     final TagDataConverter service, final Map<Object, Object> props) {
   final String type = PropertiesUtil.toString(props.get(TagDataConverter.PROP_NAME), null);
   if (type != null) {
     this.tagDataConverters.remove(type);
   }
 }
 protected final void unbindImageTransformers(
     final ImageTransformer service, final Map<Object, Object> props) {
   final String type = PropertiesUtil.toString(props.get(ImageTransformer.PROP_TYPE), null);
   if (type != null) {
     imageTransformers.remove(type);
   }
 }
 /** OSGi clue code to evict RefreshSfOptionSet instances from 'optionSets' */
 protected final void unbindOptionSets(
     final RefreshSfOptionSet service, final Map<Object, Object> props) {
   final String name = PropertiesUtil.toString(props.get(RefreshSfOptionSetImpl.PROP_NAME), null);
   if (name != null) {
     optionSets.remove(name);
   }
 }
 @Activate
 protected void activate(ComponentContext context) {
   this.propOpt =
       PropertiesUtil.toString(
           context.getProperties().get(PROPERTY_OPTIMIZATION), DEFAULT_OPTIMIZATION);
   this.optimization = ClosureOptimizationLevel.fromString(this.propOpt);
 }
 @SuppressWarnings("rawtypes")
 @Activate
 protected void activate(ComponentContext context) {
   Dictionary props = context.getProperties();
   noUserRedirectLocationFormat =
       PropertiesUtil.toString(
           props.get(NO_USER_REDIRECT_LOCATION_FORMAT), DEFAULT_NO_USER_REDIRECT_FORMAT);
   registrationPath = PropertiesUtil.toString(props.get(REGISTRATION_PATH), "/system/trustedauth");
   defaultDestination = PropertiesUtil.toString(props.get(DEFAULT_DESTINATION), "/dev");
   try {
     httpService.registerServlet(registrationPath, this, null, null);
     LOGGER.info("Registered {} at {} ", this, registrationPath);
   } catch (ServletException e) {
     LOGGER.error(e.getMessage(), e);
   } catch (NamespaceException e) {
     LOGGER.error(e.getMessage(), e);
   }
 }
 @Override
 protected void doActivate(ComponentContext context) throws Exception {
   Dictionary<?, ?> properties = context.getProperties();
   maxage = PropertiesUtil.toLong(properties.get(PROP_MAX_AGE), -1);
   if (maxage < 0) {
     throw new ConfigurationException(
         PROP_MAX_AGE, "Max Age must be specified and greater than 0.");
   }
 }
 @Activate
 public void activate(Map<String, Object> properties) {
   defaultHandler = new DefaultSparseHandler();
   topics =
       PropertiesUtil.toStringArray(properties.get(PROP_TOPICS), StoreListener.DEFAULT_TOPICS);
   for (String topic : topics) {
     contentIndexer.addImmediateHandler(topic, this);
     contentIndexer.addHandler(topic, this);
   }
 }
 private Map<String, Object> getLegacyProperties() {
   Map<String, Object> map = new HashMap<String, Object>();
   map.put(LaunchLiveActionBase.PROP_RANK, props.get(LaunchLiveActionBase.PROP_RANK));
   map.put(
       LaunchLiveActionBase.PROP_PROPS,
       PropertiesUtil.toStringArray(props.get(LaunchLiveActionBase.PROP_PROPS)));
   map.put(LaunchLiveActionBase.PROP_PARAMETER, props.get(LaunchLiveActionBase.PROP_PARAMETER));
   map.put(LaunchLiveActionBase.PROP_TITLE, props.get(LaunchLiveActionBase.PROP_TITLE));
   map.put(LaunchLiveActionBase.ACTION_TYPE, props.get(LaunchLiveActionBase.ACTION_TYPE));
   return map;
 }
  @Activate
  protected final void activate(Map<String, Object> config) throws RepositoryException {
    if (!capabilityHelper.isOak()) {
      log.info("Cowardly refusing to create indexes on non-Oak instance.");
      return;
    }

    final String ensureDefinitionsPath =
        PropertiesUtil.toString(
            config.get(PROP_ENSURE_DEFINITIONS_PATH), DEFAULT_ENSURE_DEFINITIONS_PATH);

    final String oakIndexesPath =
        PropertiesUtil.toString(config.get(PROP_OAK_INDEXES_PATH), DEFAULT_OAK_INDEXES_PATH);

    log.info("Ensuring Oak Indexes [ {} ~> {} ]", ensureDefinitionsPath, oakIndexesPath);

    if (StringUtils.isBlank(ensureDefinitionsPath)) {
      throw new IllegalArgumentException(
          "OSGi Configuration Property `"
              + PROP_ENSURE_DEFINITIONS_PATH
              + "` "
              + "cannot be blank.");
    } else if (StringUtils.isBlank(oakIndexesPath)) {
      throw new IllegalArgumentException(
          "OSGi Configuration Property `" + PROP_OAK_INDEXES_PATH + "` " + "cannot be blank.");
    }

    // Start the indexing process asynchronously, so the activate won't get blocked
    // by rebuilding a synchronous index

    EnsureOakIndexJobHandler sih =
        new EnsureOakIndexJobHandler(this, oakIndexesPath, ensureDefinitionsPath);
    ScheduleOptions options = scheduler.NOW();
    String name =
        String.format(
            "Ensure index %s => %s", new Object[] {oakIndexesPath, ensureDefinitionsPath});
    options.name(name);
    options.canRunConcurrently(false);
    scheduler.schedule(sih, options);
    log.info("Job scheduled to update the index");
  }
  @Activate
  @Modified
  protected void activate(ComponentContext context) {

    props = context.getProperties();

    // build configuration of the excluded items

    final String[] pageProperties =
        PropertiesUtil.toStringArray(
            context.getProperties().get(PARAMETER_EXCLUDED_PROPERTIES), EMPTY_CONFIG);

    final String[] paragraphItems =
        PropertiesUtil.toStringArray(
            context.getProperties().get(PARAMETER_EXCLUDED_PARAGRAPH_ITEMS), EMPTY_CONFIG);

    final String[] nodeTypes =
        PropertiesUtil.toStringArray(
            context.getProperties().get(PARAMETER_EXCLUDED_NODE_TYPES), EMPTY_CONFIG);

    final List<String> reservedProperties =
        Arrays.asList(
            PropertiesUtil.toStringArray(
                context.getProperties().get(PARAMETER_RESERVED_PROPERTIES), EMPTY_CONFIG));

    final Set<String> excludedPageProperties = new HashSet<String>(Arrays.asList(pageProperties));
    excludedPageProperties.addAll(reservedProperties);

    final Set<String> excludedParagraphItems = new HashSet<String>(Arrays.asList(paragraphItems));
    excludedParagraphItems.addAll(reservedProperties);

    final Set<String> excludedNodeTypes = new HashSet<String>(Arrays.asList(nodeTypes));

    exclusionConfig =
        new LaunchExclusionConfig(
            excludedPageProperties, excludedParagraphItems, excludedNodeTypes);
  }
  /**
   * Get the value of an OSGi configuration boolean property for a given PID.
   *
   * @param pid The PID of the OSGi component to retrieve
   * @param property The property of the config to retrieve
   * @param value The value to assign the provided property
   * @return The property value
   */
  public boolean getBooleanProperty(
      final String pid, final String property, final boolean defaultValue) {
    try {
      Configuration conf = configAdmin.getConfiguration(pid);

      @SuppressWarnings("unchecked")
      Dictionary<String, Object> props = conf.getProperties();

      if (props != null) {
        return PropertiesUtil.toBoolean(props.get(property), defaultValue);
      }
    } catch (IOException e) {
      LOGGER.error("Could not get property", e);
    }

    return defaultValue;
  }
  /**
   * Get the value of an OSGi configuration long property for a given PID.
   *
   * @param pid The PID of the OSGi component to retrieve
   * @param property The property of the config to retrieve
   * @param value The value to assign the provided property
   * @return The property value
   */
  public Long getLongProperty(final String pid, final String property, final Long defaultValue) {
    long placeholder = -1L;
    long defaultTemp = defaultValue != null ? defaultValue : placeholder;

    try {
      Configuration conf = configAdmin.getConfiguration(pid);

      @SuppressWarnings("unchecked")
      Dictionary<String, Object> props = conf.getProperties();

      if (props != null) {
        long result = PropertiesUtil.toLong(props.get(property), defaultTemp);

        return result == placeholder ? null : result;
      }
    } catch (IOException e) {
      LOGGER.error("Could not get property", e);
    }

    return defaultValue;
  }
 @Activate
 public void activate(Map<String, ?> config) throws Exception {
   queueName = PropertiesUtil.toString(config.get(QUEUE_NAME), "");
 }
  @SuppressWarnings("rawtypes")
  protected void activate(ComponentContext context) {
    Dictionary props = context.getProperties();
    usingSession = PropertiesUtil.toBoolean(props.get(USE_SESSION), false);
    secureCookie = PropertiesUtil.toBoolean(props.get(SECURE_COOKIE), false);
    ttl = PropertiesUtil.toLong(props.get(TTL), 1200000);
    trustedAuthCookieName = PropertiesUtil.toString(props.get(COOKIE_NAME), "");
    sharedSecret =
        PropertiesUtil.toString(
            props.get(SERVER_TOKEN_SHARED_SECRET), "default-setting-change-before-use");
    trustedTokenEnabled = PropertiesUtil.toBoolean(props.get(SERVER_TOKEN_ENABLED), true);
    debugCookies = PropertiesUtil.toBoolean(props.get(DEBUG_COOKIES), false);
    tokenStore.setDebugCookies(debugCookies);
    String safeHostsAddr = PropertiesUtil.toString(props.get(SERVER_TOKEN_SAFE_HOSTS_ADDR), "");
    safeHostAddrSet.clear();
    if (safeHostsAddr != null) {
      for (String address : StringUtils.split(safeHostsAddr, ';')) {
        safeHostAddrSet.add(address);
      }
    }
    String trustedProxyServerAddr =
        PropertiesUtil.toString(props.get(TRUSTED_PROXY_SERVER_ADDR), "");
    trustedProxyServerAddrSet.clear();
    if (trustedProxyServerAddr != null) {
      for (String address : StringUtils.split(trustedProxyServerAddr, ';')) {
        trustedProxyServerAddrSet.add(address);
      }
    }
    String wrappers = PropertiesUtil.toString(props.get(SERVER_TOKEN_SAFE_WRAPPERS), "");
    if (wrappers == null || wrappers.length() == 0) {
      wrappers = DEFAULT_WRAPPERS;
    }
    safeWrappers = StringUtils.split(wrappers, ";");

    String tokenFile = PropertiesUtil.toString(props.get(TOKEN_FILE_NAME), "");
    String serverId = clusterTrackingService.getCurrentServerId();
    tokenStore.doInit(cacheManager, tokenFile, serverId, ttl);

    trustedHeaderName = PropertiesUtil.toString(props.get(TRUSTED_HEADER_NAME), "");
    trustedParameterName = PropertiesUtil.toString(props.get(TRUSTED_PARAMETER_NAME), "");
  }
 /** OSGi clue code to inject RefreshSfClient instances into 'clients' */
 protected final void bindClients(final RefreshSfClient service, final Map<Object, Object> props) {
   final String name = PropertiesUtil.toString(props.get(RefreshSfClientImpl.PROP_NAME), null);
   if (name != null) {
     clients.put(name, service);
   }
 }
 @Activate
 protected void activate(Map<String, Object> config) throws ServletException, NamespaceException {
   message = PropertiesUtil.toString(config.get(PROP_MESSAGE), "no message");
   path = PropertiesUtil.toString(config.get(PROP_PATH), "no path");
   register();
 }
 @Activate
 protected void activate(ComponentContext componentContext) {
   Dictionary properties = componentContext.getProperties();
   priority = PropertiesUtil.toInteger(properties.get(PRIORITY), DEFAULT_PRIORITY);
 }
 private void configure(final Map<String, Object> config) {
   myParameter = PropertiesUtil.toString(config.get(MY_PARAMETER), null);
   logger.debug("configure: myParameter='{}''", myParameter);
 }