public String javascriptUrl() {
    String uri;

    if (ERXProperties.booleanForKeyWithDefault("er.jquerymobile.javascript.use.odn", true)) {
      uri = ERXProperties.stringForKey("er.jquerymobile.javascript.odn.location");
    } else {
      uri = ERXProperties.stringForKey("er.jquerymobile.javascript.local.location");
    }
    return ERXHyperlinkResource.urlForHyperlinkResource(context(), uri);
  }
 public String getMessageOfTheDay() {
   String message =
       (_messageOfTheDay == null)
           ? ERXProperties.stringForKey("decor.messageOfTheDay")
           : _messageOfTheDay;
   return message;
 }
  private static void StaticInitializer() {
    LOG.info("[-STATIC-] APPLICATION");

    ERXProperties.setOperatorForKey(
        new StartsWithOperator(ERXProperties.stringForKey("os.arch")),
        "arch"); // 'x86', 'x86_64', ...
    ERXProperties.setOperatorForKey(
        new StartsWithOperator(ERXProperties.stringForKey("os.name")),
        "osname"); // 'Windows XP', 'Mac OS X', ...
    ERXProperties.setOperatorForKey(
        new StartsWithOperator(ERXProperties.stringForKey("os.version")),
        "osvers"); // '5.1', '10.8.2', ...

    ERXProperties.setOperatorForKey(
        new StartsWithOperator(ERXProperties.stringForKey("user.name")), "user");
    ERXProperties.setOperatorForKey(
        new StartsWithOperator(
            ERXProperties.stringForKey("catalina.home") == null ? "apache" : "tomcat"),
        "envo");

    // ------------------------------------------------------------------------------------------------
    LOG.info("[-STATIC-] APPLICATION - SET UP NOTIFICATION OBSERVERS");
    Observer observer = new Observer();
    _retainer = new NSArray<Observer>(observer);

    NSNotificationCenter.defaultCenter()
        .addObserver(
            observer,
            new NSSelector<Object>("appWillLaunch", new Class[] {NSNotification.class}),
            com.webobjects.appserver.WOApplication.ApplicationWillFinishLaunchingNotification,
            null);

    NSNotificationCenter.defaultCenter()
        .addObserver(
            observer,
            new NSSelector<Object>("appDidLaunch", new Class[] {NSNotification.class}),
            com.webobjects.appserver.WOApplication.ApplicationDidFinishLaunchingNotification,
            null);

    NSNotificationCenter.defaultCenter()
        .addOmniscientObserver(
            observer,
            new NSSelector<Object>("allNotifications", new Class[] {NSNotification.class}));

    // ------------------------------------------------------------------------------------------------
    LOG.info("[-STATIC-] APPLICATION - CLASSPATH CHECK");
    NSArray<String> classPathComponents =
        NSArray.componentsSeparatedByString(
            ERXProperties.stringForKey("java.class.path"),
            ERXProperties.stringForKey("path.separator"));
    for (String classPathComponent : classPathComponents) { // enumerate the class path ...
      try { // ... can each library be found
        if ((new File(classPathComponent)).isFile())
          LOG.trace("classpath [jar] {}", classPathComponent);
        else LOG.trace("classpath [bin] {}", classPathComponent);
      } catch (Exception x) {
        LOG.error("{} Exception validating classpath", classPathComponent, x);
      }
    }
  }
  public Application() {
    super();

    PachySanity.adjustEnvironment();

    if (isFirstTime()) {

      PachySanity.showEnvironment();

    } else {

      if (ERXProperties.booleanForKeyWithDefault("pachy.CreateEnvironment", false)) {
        PachySanity.createEnvironment();
      }

      if (ERXProperties.booleanForKeyWithDefault("pachy.ShowEnvironment", true)) {
        PachySanity.showEnvironment();
      }

      PachySanity.testEnvironment();

      if (ERXProperties.booleanForKey("pachy.exitAfterInitialize")) {
        LOG.info("[APPLICATION] EXIT AFTER INITIALIZING [pachy.exitAfterInitialize == true]");
        System.exit(0);
        /* ############################################# MIGHT STOP HERE (pachy.exitAfterInitialize) #### */
      }
    }

    er.extensions.ERXExtensions.setAdaptorLogging(
        ERXProperties.booleanForKeyWithDefault("pachy.optionEnableAdaptorLog", false));

    /*------------------------------------------------------------------------------------------------*
     *  ... add the metadata database to the objectStores (why does EOModel not do this?)
     *------------------------------------------------------------------------------------------------*/
    try {
      CXObjectStoreCoordinator.getDefaultCoordinator()
          .addObjectStore(
              "org.pachyderm.assetdb", ERXProperties.stringForKey("dbConnectURLGLOBAL"));
      LOG.info("org.pachyderm.assetdb registered.");
    } catch (Exception x) {
      LOG.error("org.pachyderm.assetdb not registered.", x);
    }

    /*------------------------------------------------------------------------------------------------*
     *  add the English and French locales to the locale array ...
     *------------------------------------------------------------------------------------------------*/
    locales = new NSMutableArray<Locale>();
    locales.addObject(Locale.ENGLISH);
    locales.addObject(Locale.FRENCH);

    /*------------------------------------------------------------------------------------------------*
     *  loading this class, causes "UTRuntimeProvider" to scan for UTI definitions which can take
     *  a long time (~10 seconds on a good day).  Rather than have the first unfortunate user incur
     *  that penalty unpredictably, we get it over with now, before anyone logs in ...
     *------------------------------------------------------------------------------------------------*/
    UTType.loadThisClassNow();
  }
 private String documentRoot() {
   if (_documentRoot == null) {
     _documentRoot = ERXProperties.stringForKey("WODocumentRoot");
     if (_documentRoot == null) {
       NSBundle bundle = NSBundle.bundleForName("JavaWebObjects");
       NSDictionary dict =
           ERXDictionaryUtilities.dictionaryFromPropertyList("WebServerConfig", bundle);
       _documentRoot = (String) dict.objectForKey("DocumentRoot");
     }
   }
   return _documentRoot;
 }
Exemple #6
0
  public void takeValuesFromRequest(WORequest request, WOContext context) {
    if (context._wasFormSubmitted()) {
      super.takeValuesFromRequest(request, context);

      String apiKey = ERXProperties.stringForKey("er.captcha.akismet.apiKey");
      String url =
          ERXProperties.stringForKeyWithDefault(
              "er.captcha.akismet.url", "http://" + request._serverName());
      Akismet api = new Akismet(apiKey, url);
      if (ERXApplication.isDevelopmentModeSafe()) {
        if (!api.verifyAPIKey()) {
          throw new RuntimeException(
              "The API key you provided is invalid. Please set a valid api key in the property 'er.captcha.akismet.apiKey'.");
        }
      }

      String ipAddress = stringValueForBinding("remoteAddress", request._remoteAddress());
      String userAgent = stringValueForBinding("userAgent", request.headerForKey("user-agent"));
      String referrer = stringValueForBinding("referrer", request.headerForKey("referer"));
      String permalink = stringValueForBinding("permalink");
      String commentType = stringValueForBinding("commentType");
      String author = stringValueForBinding("author");
      String authorEmail = stringValueForBinding("authorEmail");
      String authorURL = stringValueForBinding("authorURL");
      String content = stringValueForBinding("content");
      Map other = null;

      boolean isSpam =
          api.commentCheck(
              ipAddress,
              userAgent,
              referrer,
              permalink,
              commentType,
              author,
              authorEmail,
              authorURL,
              content,
              other);
      if (isSpam) {
        validationFailedWithException(
            new NSValidation.ValidationException("Spam check failed."),
            this,
            ERXSimpleSpamCheck.SPAM_CHECK_KEY);
        setValueForBinding(Boolean.FALSE, "valid");
      } else {
        setValueForBinding(Boolean.TRUE, "valid");
      }
    }
  }
Exemple #7
0
 /**
  * Sets the default EOEntity class to com.webobjects.eoaccess.ERXEntity. You can provide your own
  * via the property <code>er.extensions.ERXModel.defaultEOEntityClassName</code> however your
  * class must be in the same package unless you plan on re-implementing eof itself.
  *
  * @see com.webobjects.eoaccess.EOModel#_addEntityWithPropertyList(java.lang.Object)
  */
 @Override
 public Object _addEntityWithPropertyList(Object propertyList)
     throws InstantiationException, IllegalAccessException {
   NSMutableDictionary<String, Object> list =
       ((NSDictionary<String, Object>) propertyList).mutableClone();
   if (list.objectForKey("entityClass") == null) {
     String eoEntityClassName =
         ERXProperties.stringForKey("er.extensions.ERXModel.defaultEOEntityClassName");
     if (eoEntityClassName == null) {
       eoEntityClassName = ERXEntity.class.getName();
     }
     list.setObjectForKey(eoEntityClassName, "entityClass");
   }
   return super._addEntityWithPropertyList(list);
 }
Exemple #8
0
  /**
   * <span class="en"> Predicate used to validate email well-formness.
   *
   * @return true if the email is valid
   * @param email the email String value to validate
   * @return a <code>boolean</code> value </span>
   *     <p><span class="ja"> メールが正しいかどうかを検証します。
   * @param email - 検証するメール値
   * @return メールが有効であれば true が戻ります。 </span>
   */
  public synchronized boolean isValidEmail(String email) {
    if (_pattern == null) {
      String patternString = ERXProperties.stringForKey("er.javamail.emailPattern");
      if (patternString == null || patternString.trim().length() == 0) {
        patternString = EMAIL_VALIDATION_PATTERN;
      }

      try {
        _pattern = Pattern.compile(patternString);
      } catch (PatternSyntaxException e) {
        throw new RuntimeException(
            "The compilation of the email pattern '" + patternString + "' failed.", e);
      }
    }
    if (email != null) {
      return _pattern.matcher(email).matches();
    }
    return false;
  }
Exemple #9
0
  protected void setupSmtpProperties(Properties properties, String contextString) {
    String contextSuffix = contextString == null ? "" : ("." + contextString);

    // Smtp host
    String smtpProtocol = smtpProtocolForContext(contextString);

    String smtpHost =
        ERXProperties.stringForKeyWithDefault(
            "er.javamail.smtpHost" + contextSuffix,
            ERXProperties.stringForKey("er.javamail.smtpHost"));
    if ((smtpHost == null) || (smtpHost.length() == 0)) {
      // Try to fail back to default java config
      smtpHost = ERXProperties.stringForKey("mail." + smtpProtocol + ".host");

      if ((smtpHost == null) || (smtpHost.length() == 0)) {
        // use the standard WO host
        smtpHost = ERXProperties.stringForKey("WOSMTPHost");
        if ((smtpHost == null) || (smtpHost.length() == 0)) {
          throw new RuntimeException(
              "ERJavaMail: You must specify a SMTP host for outgoing mail with the property 'er.javamail.smtpHost'");
        }
        // ... and then maybe actually do what the docs say this method is supposed to do
        properties.setProperty("mail." + smtpProtocol + ".host", smtpHost);
        properties.setProperty("er.javamail.smtpHost", smtpHost);
      } else {
        properties.setProperty("er.javamail.smtpHost", smtpHost);
      }
    } else {
      properties.setProperty("mail." + smtpProtocol + ".host", smtpHost);
    }
    log.debug("er.javamail.smtpHost: " + smtpHost);

    String port =
        ERXProperties.stringForKeyWithDefault(
            "er.javamail.smtpPort" + contextSuffix,
            ERXProperties.stringForKey("er.javamail.smtpPort"));
    if (port != null && port.length() > 0) {
      properties.setProperty("mail." + smtpProtocol + ".port", port);
      log.debug("ERJavaMail will use smtp port: " + port);
    }

    boolean smtpAuth =
        ERXProperties.booleanForKeyWithDefault(
            "er.javamail.smtpAuth" + contextSuffix,
            ERXProperties.booleanForKey("er.javamail.smtpAuth"));
    log.debug("ERJavaMail will use authenticated SMTP connections.");
    if (smtpAuth) {
      properties.setProperty("mail." + smtpProtocol + ".auth", String.valueOf(smtpAuth));
      String user =
          ERXProperties.stringForKeyWithDefault(
              "er.javamail.smtpUser" + contextSuffix,
              ERXProperties.stringForKey("er.javamail.smtpUser"));
      if (user == null || user.length() == 0) {
        throw new RuntimeException(
            "You specified er.javamail.smtpAuth=true, but you didn't specify an er.javamail.smtpUser to use as the login name.");
      }
      properties.setProperty("mail." + smtpProtocol + ".user", user);
      String password =
          ERXProperties.stringForKeyWithDefault(
              "er.javamail.smtpPassword" + contextSuffix,
              ERXProperties.stringForKey("er.javamail.smtpPassword"));
      if (password == null || password.length() == 0) {
        log.warn(
            "You specified er.javamail.smtpAuth=true, but you didn't set er.javamail.smtpPassword for the "
                + user
                + " mail user.");
      }
      if (password != null) {
        properties.setProperty("mail." + smtpProtocol + ".password", password);
      }
    }
    if ("smtps".equals(smtpProtocol)) {
      properties.setProperty("mail.smtps.socketFactory.fallback", "false");
    }
  }
Exemple #10
0
 public boolean _isAdditionalForeignSupportedDevelopmentPlatform() {
   String osName = ERXProperties.stringForKey("os.name");
   return (osName != null && osName.equals("Linux"));
 }
Exemple #11
0
 public String getProperty(String key) {
   return ERXProperties.stringForKey(key);
 }
Exemple #12
0
 public String creditText() {
   return ERXProperties.stringForKey("decor.creditText");
 }