Exemple #1
0
 /**
  * Generate tab descriptors from an dictionary of property values.
  *
  * @param dict the properties to use
  * @return An array of the new tab descriptors
  */
 public static NSArray<TabDescriptor> tabsFromDictionary(
     NSDictionary<String, NSDictionary<String, Object>> dict) {
   NSMutableArray<TabDescriptor> tabs = new NSMutableArray<TabDescriptor>();
   for (String label : dict.keySet()) {
     NSDictionary<String, Object> settings = dict.get(label);
     String pageName = (String) settings.objectForKey("pageName");
     int accessLevel =
         ERXValueUtilities.intValueWithDefault(settings.objectForKey("accessLevel"), 0);
     int priority = ERXValueUtilities.intValueWithDefault(settings.objectForKey("priority"), 0);
     boolean wantsStart =
         ERXValueUtilities.booleanValueWithDefault(settings.objectForKey("wantsStart"), false);
     @SuppressWarnings("unchecked")
     NSDictionary<String, NSDictionary<String, Object>> children =
         (NSDictionary<String, NSDictionary<String, Object>>) settings.objectForKey("children");
     String overridingLabel = (String) settings.objectForKey("label");
     if (overridingLabel != null) {
       label = overridingLabel;
     }
     @SuppressWarnings("unchecked")
     NSDictionary<String, Object> tabConfig =
         (NSDictionary<String, Object>) settings.objectForKey("config");
     tabs.addObject(
         new TabDescriptor(
             pageName,
             label,
             accessLevel,
             priority,
             wantsStart,
             (children == null) ? null : tabsFromDictionary(children),
             (String) settings.objectForKey("id"),
             tabConfig));
   }
   return tabs;
 }
  /**
   * Action used for turning EOAdaptorDebugging output on or off.<br>
   * <br>
   * Synopsis:<br>
   * pw=<i>aPassword</i> <br>
   * Form Values:<br>
   * <strong>pw</strong> password to be checked against the system property <code>
   * er.extensions.ERXEOAdaptorDebuggingPassword</code>.<br>
   * <strong>debug</strong> flag signaling whether to turn EOAdaptorDebugging on or off (defaults to
   * off). The value should be one of:
   *
   * <ul>
   *   <li>on
   *   <li>true
   *   <li>1
   *   <li>y
   *   <li>yes
   *   <li>off
   *   <li>false
   *   <li>0
   *   <li>n
   *   <li>no
   *       <ul>
   *         <br>
   *         Note: this action must be invoked against a specific instance (the instance number must
   *         be in the request URL).
   *
   * @return a page showing what action was taken (with regard to EOAdaptorDebugging), if any.
   */
  public WOActionResults eoAdaptorDebuggingAction() {
    if (canPerformActionWithPasswordKey("er.extensions.ERXEOAdaptorDebuggingPassword")) {
      ERXStringHolder result = pageWithName(ERXStringHolder.class);
      result.setEscapeHTML(false);
      String message;
      boolean currentState = ERXExtensions.adaptorLogging();
      int instance = request().applicationNumber();
      if (instance == -1) {
        log.info("EOAdaptorDebuggingAction requested without a specific instance.");
        message =
            "<p>You must invoke this action on a <em>specific</em> instance.</p>"
                + "<p>Your url should look like: <code>.../WebObjects/1/wa/...</code>, where '1' would be the first instance of the target application.</p>";
      } else {
        String debugParam = request().stringFormValueForKey("debug");
        log.debug("EOAdaptorDebuggingAction requested with 'debug' param:" + debugParam);
        if (debugParam == null || debugParam.trim().length() == 0) {
          message =
              "<p>EOAdaptorDebugging is currently <strong>"
                  + (currentState ? "ON" : "OFF")
                  + "</strong> for instance <strong>"
                  + instance
                  + "</strong>.</p>";
          message +=
              "<p>To change the setting, provide the 'debug' parameter to this action, e.g.: <code>...eoAdaptorDebugging?debug=on&pw=secret</code></p>";
        } else {
          if (debugParam.trim().equalsIgnoreCase("on")) {
            debugParam = "true";
          } else if (debugParam.trim().equalsIgnoreCase("off")) {
            debugParam = "false";
          }

          boolean desiredState = ERXValueUtilities.booleanValueWithDefault(debugParam, false);
          log.debug(
              "EOAdaptorDebuggingAction requested 'debug' state change to: '"
                  + desiredState
                  + "' for instance: "
                  + instance
                  + ".");
          if (currentState != desiredState) {
            ERXExtensions.setAdaptorLogging(desiredState);
            message =
                "<p>Turned EOAdaptorDebugging <strong>"
                    + (desiredState ? "ON" : "OFF")
                    + "</strong> for instance <strong>"
                    + instance
                    + "</strong>.</p>";
          } else {
            message = "<p>EOAdaptorDebugging setting <strong>not changed</strong>.</p>";
          }
        }
      }

      message +=
          "<p><em>Please be mindful of using EOAdaptorDebugging as it may have a large impact on application performance.</em></p>";
      result.setValue(message);
      return result;
    }

    return forbiddenResponse();
  }
 /**
  * Boolean used to hide/show the confirmation dialog's remove button.
  *
  * <p>The remove button show only be displayed if the reverse relationship for the related eo is
  * not mandatory and isEntityRemoveable returns true.
  */
 public Boolean showRemoveButton() {
   if (_showRemoveButton == null) {
     boolean isRemoveable =
         ERXValueUtilities.booleanValueWithDefault(
             d2wContext().valueForKey("isEntityRemoveable"), false);
     EODataSource ds = dataSource();
     if (ds != null && ds instanceof EODetailDataSource) {
       EODetailDataSource dds = (EODetailDataSource) ds;
       EOEnterpriseObject masterObj = (EOEnterpriseObject) dds.masterObject();
       EOEntity masterEntity = ERXEOAccessUtilities.entityForEo(masterObj);
       EORelationship relationship = masterEntity.relationshipNamed(dds.detailKey());
       EORelationship reverseRelationship = relationship.inverseRelationship();
       if (isRemoveable) {
         if (reverseRelationship == null) {
           _showRemoveButton = Boolean.TRUE;
         } else {
           _showRemoveButton = !reverseRelationship.isMandatory();
         }
       } else {
         _showRemoveButton = Boolean.FALSE;
       }
     } else {
       _showRemoveButton = Boolean.valueOf(isRemoveable);
     }
   }
   return _showRemoveButton;
 }
Exemple #4
0
 /**
  * Utility to get the boolean value of a binding or a default value if none is supplied. Handles
  * non-boolean bindings Numbers, NSArray, String, NSKeyValueCoding.
  *
  * @param name name of the binding
  * @param defaultValue value to return if unbound
  * @return value for binding or defaultValue value if unbound
  */
 public boolean booleanValueForBinding(String name, boolean defaultValue) {
   boolean value = defaultValue;
   if (hasBinding(name)) {
     Object boundValue = valueForBinding(name);
     value = ERXValueUtilities.booleanValue(boundValue);
   }
   return value;
 }
 /**
  * Boolean used to hide/show the confirmation dialog's delete button
  *
  * <p>The delete button is only shown if isEntityDeletable returns true
  */
 public Boolean showDeleteButton() {
   if (_showDeleteButton == null) {
     _showDeleteButton =
         new Boolean(
             canDelete() && ERXValueUtilities.booleanValue(valueForBinding("isEntityDeletable")));
   }
   return _showDeleteButton;
 }
 public boolean isMandatory() {
   return ERXValueUtilities.booleanValue(subContext().valueForKey("isMandatory"));
 }
 /**
  * Look up an object by id number. Assumes the editing context is appropriately locked.
  *
  * @param ec The editing context to use
  * @param id The id to look up
  * @return The object, or null if no such id exists
  */
 public static UserMessageSubscription forId(EOEditingContext ec, String id) {
   return forId(ec, er.extensions.foundation.ERXValueUtilities.intValue(id));
 }
Exemple #8
0
  /**
   * <div class="ja"> ドメイン又は ip リストを全件表示するドメイン又は ip リストに変換します
   *
   * <p>例: www.ksroom.com はそのままで戻る 1.2.3.4 はそのままで戻る 1.2.3.4-6 は (1.2.3.4, 1.2.3.5, 1.2.3.6) として戻る
   *
   * @param data - NSArray&lt;String&gt; ドメイン又は ip リスト
   * @return 全件のドメイン又は ip リスト </div>
   */
  public static NSArray<String> fullDomainIpList(NSArray<String> data) {
    NSMutableArray<String> results = new NSMutableArray<String>(data.count());
    for (String string : data) {
      if (ERXStringUtilities.stringIsNullOrEmpty(string)) {
        continue;
      }

      // 文字で始まるドメイン
      char firstLetter = string.charAt(0);
      if (!StringUtils.isNumeric("" + firstLetter)) {
        results.addObject(string);

        // IP を調査し追加すること
        InetAddress addr;
        try {
          addr = InetAddress.getByName(string);
          if (addr != null) results.addObject(addr.getHostAddress());
        } catch (UnknownHostException e) {
          e.printStackTrace();
        }
        continue;
      }

      // 数字で始まる普通のドメイン又は、IPアドレス
      if (!string.contains("-")) {
        results.addObject(string);
        continue;
      }

      // 数字で始まる又は - を持つドメイン
      NSArray<String> bubuns = NSArray.componentsSeparatedByString(string, "-");
      if (bubuns.count() != 2) {
        // 複数の "-" がある
        results.addObject(string);
        continue;
      }

      String startIP = ERXTcpIp.inet4IpAddressTo3digitFromat(bubuns.objectAtIndex(0));

      // 正しい IP ?
      if (ERXStringUtilities.stringIsNullOrEmpty(startIP)) {
        results.addObject(string);
        continue;
      }

      // IP 追加処理
      long endIp = ERXValueUtilities.longValue(bubuns.objectAtIndex(1));

      StringTokenizer tempStringTokenizer = new StringTokenizer(startIP, ".");
      long countToken = tempStringTokenizer.countTokens();
      if (countToken == 4) { // 4 digit時処理
        try {
          long ip1 = Long.parseLong(tempStringTokenizer.nextToken());
          long ip2 = Long.parseLong(tempStringTokenizer.nextToken());
          long ip3 = Long.parseLong(tempStringTokenizer.nextToken());
          long ip4 = Long.parseLong(tempStringTokenizer.nextToken());

          for (long i = ip4; i <= endIp; i++) {
            String ipStr = "" + ip1 + _DOT + ip2 + _DOT + ip3 + _DOT + i;
            results.addObject(ipStr);
          }
        } catch (Exception e) {

        }
      }
    }
    return results.immutableClone();
  }