/**
  * Activate this component. Open the session and register event listeners.
  *
  * @param context The component context
  */
 protected void activate(final ComponentContext context) {
   reverseReplicate =
       OsgiUtil.toBoolean(
           context.getProperties().get(PROPERTY_REVERSE_REPLICATE), DEFAULT_REVERSE_REPLICATE);
   fieldWhitelist = OsgiUtil.toStringArray(context.getProperties().get(PROPERTY_FIELD_WHITELIST));
   attachmentTypeBlacklist =
       OsgiUtil.toStringArray(context.getProperties().get(PROPERTY_ATTACHMENT_TYPE_BLACKLIST));
 }
예제 #2
0
  @Activate
  protected void activate(final BundleContext bundleContext, final Map<String, ?> config) {
    final String davRoot = OsgiUtil.toString(config.get(PROP_DAV_ROOT), DEFAULT_DAV_ROOT);
    final boolean createAbsoluteUri =
        OsgiUtil.toBoolean(config.get(PROP_CREATE_ABSOLUTE_URI), DEFAULT_CREATE_ABSOLUTE_URI);

    final AuthHttpContext context = new AuthHttpContext(davRoot);
    context.setAuthenticationSupport(authSupport);

    // prepare DavEx servlet config
    final Dictionary<String, String> initProps = new Hashtable<String, String>();

    // prefix to the servlet
    initProps.put(INIT_PARAM_RESOURCE_PATH_PREFIX, davRoot);

    // create absolute URIs (or absolute paths)
    initProps.put(INIT_PARAM_CREATE_ABSOLUTE_URI, Boolean.toString(createAbsoluteUri));

    // disable CSRF checks for now (should be handled by Sling)
    initProps.put(INIT_PARAM_CSRF_PROTECTION, CSRFUtil.DISABLED);

    // register and handle registration failure
    try {
      this.httpService.registerServlet(davRoot, this, initProps, context);
      this.servletAlias = davRoot;

      java.util.Properties dummyServiceProperties = new java.util.Properties();
      dummyServiceProperties.put(Constants.SERVICE_VENDOR, config.get(Constants.SERVICE_VENDOR));
      dummyServiceProperties.put(
          Constants.SERVICE_DESCRIPTION, "Helper for " + config.get(Constants.SERVICE_DESCRIPTION));
      dummyServiceProperties.put(PAR_AUTH_REQ, "-" + davRoot);
      this.dummyService =
          bundleContext.registerService("java.lang.Object", new Object(), dummyServiceProperties);
    } catch (Exception e) {
      log.error("activate: Failed registering DavEx Servlet at " + davRoot, e);
    }
  }
  protected void activate(ComponentContext ctx) {
    @SuppressWarnings("rawtypes")
    Dictionary props = ctx.getProperties();

    Integer _maxRetries = OsgiUtil.toInteger(props.get(MAX_RETRIES), -1);
    if (_maxRetries > -1) {
      if (diff(maxRetries, _maxRetries)) {
        maxRetries = _maxRetries;
      }
    } else {
      LOGGER.error("Maximum times to retry messages not set.");
    }

    Integer _retryInterval = OsgiUtil.toInteger(props.get(RETRY_INTERVAL), -1);
    if (_retryInterval > -1) {
      if (diff(_retryInterval, retryInterval)) {
        retryInterval = _retryInterval;
      }
    } else {
      LOGGER.error("SMTP retry interval not set.");
    }

    if (maxRetries * retryInterval < 4320 /* minutes in 3 days */) {
      LOGGER.warn("SMTP retry window is very short.");
    }

    Integer _smtpPort = OsgiUtil.toInteger(props.get(SMTP_PORT), -1);
    boolean validPort = _smtpPort != null && _smtpPort >= 0 && _smtpPort <= 65535;
    if (validPort) {
      if (diff(smtpPort, _smtpPort)) {
        smtpPort = _smtpPort;
      }
    } else {
      LOGGER.error("Invalid port set for SMTP");
    }

    String _smtpServer = OsgiUtil.toString(props.get(SMTP_SERVER), "");
    boolean smtpServerEmpty = _smtpServer == null || _smtpServer.trim().length() == 0;
    if (!smtpServerEmpty) {
      if (diff(smtpServer, _smtpServer)) {
        smtpServer = _smtpServer;
      }
    } else {
      LOGGER.error("No SMTP server set");
    }

    try {
      connection = connFactoryService.getDefaultConnectionFactory().createConnection();
      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
      Queue dest = session.createQueue(QUEUE_NAME);
      MessageConsumer consumer = session.createConsumer(dest);
      consumer.setMessageListener(this);
      connection.start();
    } catch (JMSException e) {
      LOGGER.error(e.getMessage(), e);
      if (connection != null) {
        try {
          connection.close();
        } catch (JMSException e1) {
        }
      }
    }
  }
예제 #4
0
 @Activate
 protected void activate(Map<?, ?> props) {
   defaultMaxResults = OsgiUtil.toInteger(props.get(DEFAULT_MAX_RESULTS), defaultMaxResults);
   slowQueryThreshold = OsgiUtil.toLong(props.get(SLOW_QUERY_TIME), 10L);
   verySlowQueryThreshold = OsgiUtil.toLong(props.get(VERY_SLOW_QUERY_TIME), 100L);
 }
예제 #5
0
 @Activate
 @Modified
 protected void activate(Map<?, ?> props) {
   groupHome = OsgiUtil.toString(props.get(GROUP_HOME_RES), DEFAULT_GROUP_HOME);
   userHome = OsgiUtil.toString(props.get(USER_HOME_RES), DEFAULT_USER_HOME);
 }