protected static NSDictionary expansionLookup() {
    if (RuleModelUtilities.expansionLookup == null) {
      NSDictionary lookupDictionary = RuleModelUtilities.compressionLookup();
      Enumeration keys = lookupDictionary.keyEnumerator();
      NSMutableDictionary lookup = new NSMutableDictionary(lookupDictionary.count());

      while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        Object value = lookupDictionary.objectForKey(key);

        lookup.setObjectForKey(key, value);
      }

      // Direct To Web rule editor compatibility
      lookup.setObjectForKey(
          BooleanAssignment.class.getName(), "com.webobjects.directtoweb.BooleanAssignment");
      lookup.setObjectForKey(Rule.class.getName(), "com.webobjects.directtoweb.Rule");
      lookup.setObjectForKey(
          SimpleAssignment.class.getName(), "com.webobjects.directtoweb.Assignment");
      lookup.setObjectForKey(
          KeyValueAssignment.class.getName(), "com.webobjects.directtoweb.KeyValueAssignment");

      RuleModelUtilities.expansionLookup = lookup;
    }

    return RuleModelUtilities.expansionLookup;
  }
Пример #2
0
 /**
  * Returns a deep clone of the given dictionary. A deep clone will attempt to clone the keys and
  * values (deeply) of this dictionary as well as the dictionary itself.
  *
  * @param dict the dictionary to clone
  * @param onlyCollections if true, only collections in this dictionary will be cloned, not
  *     individual values
  * @return a deep clone of dict
  */
 public static <K, V> NSDictionary<K, V> deepClone(
     NSDictionary<K, V> dict, boolean onlyCollections) {
   NSMutableDictionary<K, V> clonedDict = null;
   if (dict != null) {
     clonedDict = dict.mutableClone();
     for (K key : dict.allKeys()) {
       V value = dict.objectForKey(key);
       K cloneKey = ERXUtilities.deepClone(key, onlyCollections);
       V cloneValue = ERXUtilities.deepClone(value, onlyCollections);
       if (cloneKey != key) {
         clonedDict.removeObjectForKey(key);
         if (cloneValue != null) {
           clonedDict.setObjectForKey(cloneValue, cloneKey);
         }
       } else if (cloneValue != null) {
         if (cloneValue != value) {
           clonedDict.setObjectForKey(cloneValue, cloneKey);
         }
       } else {
         clonedDict.removeObjectForKey(key);
       }
     }
   }
   return clonedDict;
 }
Пример #3
0
    public void prepareUpdateExpressionWithRow(NSDictionary row, EOQualifier qualifier) {
      EOAttribute attribute;
      Object value;
      for (Enumeration enumeration = row.keyEnumerator();
          enumeration.hasMoreElements();
          addUpdateListAttribute(attribute, value)) {
        String attributeName = (String) enumeration.nextElement();
        attribute = this.entity().anyAttributeNamed(attributeName);
        if (attribute == null)
          throw new IllegalStateException(
              "prepareUpdateExpressionWithRow: row argument contains key '"
                  + attributeName
                  + "' which does not have corresponding attribute on entity '"
                  + this.entity().name()
                  + "'");
        value = row.objectForKey(attributeName);
      }

      _whereClauseString =
          EOQualifierSQLGeneration.Support._sqlStringForSQLExpression(qualifier, this);
      String tableList = tableListWithRootEntity(_rootEntityForExpression());
      _statement =
          assembleUpdateStatementWithRow(
              row, qualifier, tableList, new String(_listString), _whereClauseString);
    }
  @Override
  public D2WContext subContext() {
    if (_context == null) {
      String s = hasBinding("_dynamicPage") ? (String) valueForBinding("_dynamicPage") : null;
      if (s != null) {
        _context = makeSubContextForDynamicPageNamed(s, session());
      } else {
        _context =
            makeSubContextForTaskAndEntity(
                task(), EOModelGroup.defaultGroup().entityNamed(entityName()), session());
      }
      String s1 = lookFromSettings();
      if (s1 != null) {
        _context.takeValueForInferrableKey(lookFromSettings(), D2WModel.LookKey);
      }
      _context.takeValueForKey(
          _context.task() + "CurrentObject",
          D2WComponent.keyForGenerationReplacementForVariableNamed("currentObject"));
    }
    NSDictionary nsdictionary = settings();
    if (nsdictionary != null) {
      String s2;
      for (Enumeration enumeration = nsdictionary.keyEnumerator();
          enumeration.hasMoreElements();
          _context.takeValueForInferrableKey(nsdictionary.valueForKey(s2), s2)) {
        s2 = (String) enumeration.nextElement();
      }
    }

    if (log.isDebugEnabled()) log.debug(hashCode() + ": context: " + _context);
    return _context;
  }
Пример #5
0
  @Override
  public HashMap getAverageSessionMemory() {
    NSMutableDictionary<String, Long> avg = new NSMutableDictionary<>();
    NSDictionary<String, Long> startMemory = null;
    NSMutableDictionary<String, Long> currentMemory = memoryUsage();
    try {
      startMemory = (NSDictionary<String, Long>) initMemoryField.get(this);
    } catch (Exception e) {
      // ignore
    }
    int sessionCount = activeSessions().size();

    Long totalSessionMemory = Long.valueOf(0L);
    Long averageSessionMemory = Long.valueOf(0L);
    if (startMemory != null && sessionCount > 0) {
      totalSessionMemory =
          Long.valueOf(
              startMemory.get("Free Memory").longValue()
                  - currentMemory.get("Free Memory").longValue());
      averageSessionMemory = Long.valueOf(totalSessionMemory.longValue() / sessionCount);
    }
    avg.setObjectForKey(totalSessionMemory, "Total Memory");
    avg.setObjectForKey(averageSessionMemory, "Per Session");

    return avg.hashMap();
  }
Пример #6
0
  protected NSMutableArray getQueryErrors(NSDictionary[] responseDicts) {
    NSMutableArray errorArray = new NSMutableArray();

    for (int i = 0; i < responseDicts.length; i++) {
      if (responseDicts[i] != null) {
        NSDictionary responseDict = responseDicts[i];
        getGlobalErrorFromResponse(responseDict, errorArray);

        NSArray commandWotaskdResponse =
            (NSArray) responseDict.valueForKey("commandWotaskdResponse");
        if ((commandWotaskdResponse != null) && (commandWotaskdResponse.count() > 0)) {
          int count = commandWotaskdResponse.count();
          for (int j = 1; j < count; j++) {
            NSDictionary aDict = (NSDictionary) commandWotaskdResponse.objectAtIndex(j);
            String errorMessage = (String) aDict.valueForKey("errorMessage");
            if (errorMessage != null) {
              errorArray.addObject(errorMessage);
              if (j == 0) break; // the command produced an error,
              // parsing didn't finish
            }
          }
        }
      }
    }
    if (NSLog.debugLoggingAllowedForLevelAndGroups(
        NSLog.DebugLevelDetailed, NSLog.DebugGroupDeployment))
      NSLog.debug.appendln("##### getQueryErrors: " + errorArray);
    mySession().addObjectsFromArrayIfAbsentToErrorMessageArray(errorArray);
    return errorArray;
  }
Пример #7
0
 private String defaultValue() {
   if (!inAppend || item1 == null) return null;
   Object dflt = indexItem.valueForKey("defaultValue");
   if (dflt == null) return null;
   if (dflt.equals("ASSUME")) {
     String str1 = value1();
     NSArray list = (NSArray) indexItem.valueForKey("external");
     int best = 0;
     String result = null;
     for (int i = 0; i < list.count(); i++) {
       Object value2 = list.objectAtIndex(i);
       String str2;
       if (value2 instanceof NSKeyValueCoding) {
         str2 = (String) ((NSKeyValueCoding) value2).valueForKey("title");
         value2 = (String) ((NSKeyValueCoding) value2).valueForKey("value");
       } else {
         str2 = value2.toString();
       }
       int cor = Various.correlation(str1, str2);
       if (cor > best && cor > Math.min(str1.length(), str2.length()) / 2) {
         result = value2.toString();
         best = cor;
       }
     }
     return result;
   }
   return (String) DisplayAny.ValueReader.evaluateValue(dflt, item1, this);
 }
Пример #8
0
  @Override
  public NSArray getRequestHandlerPathForRequest(WORequest request) {
    NSMutableArray<Object> requestHandlerPath = new NSMutableArray<Object>();

    try {
      String path = request._uriDecomposed().requestHandlerPath();

      ERXRoute matchingRoute =
          setupRequestWithRouteForMethodAndPath(request, request.method(), path);
      if (matchingRoute != null) {
        @SuppressWarnings("unchecked")
        NSDictionary<ERXRoute.Key, String> keys =
            (NSDictionary<ERXRoute.Key, String>)
                request.userInfo().objectForKey(ERXRouteRequestHandler.KeysKey);
        String controller = keys.objectForKey(ERXRoute.ControllerKey);
        String actionName = keys.objectForKey(ERXRoute.ActionKey);
        requestHandlerPath.addObject(controller);
        requestHandlerPath.addObject(actionName);
      } else {
        requestHandlerPath.addObject(
            ERXProperties.stringForKeyWithDefault(
                "ERXRest.missingControllerName", "ERXMissingRouteController"));
        requestHandlerPath.addObject("missing");
        // throw new FileNotFoundException("There is no controller for the route '" + path + "'.");
      }

    } catch (Throwable t) {
      throw new RuntimeException("Failed to process the requested route.", t);
    }

    return requestHandlerPath;
  }
 /**
  * Decodes the encoded entity name.
  *
  * @param encodedName the encode name.
  * @return decoded entity name.
  */
 public static String entityNameDecode(String encodedName) {
   String entityName = encodedName;
   NSDictionary entityNames = encodedEntityNames();
   synchronized (entityNames) {
     entityName = (String) entityNames.objectForKey(encodedName);
   }
   return entityName;
 }
Пример #10
0
 public WOActionResults exportZPU() {
   StringBuilder buf = new StringBuilder("journal");
   buf.append(currMonth.valueForKey("year"));
   int month = ((Integer) currMonth.valueForKey("month")).intValue();
   month++;
   if (month < 10) buf.append('0');
   buf.append(month);
   return exportJournalZPU(journalZPU, context(), buf.toString());
 }
Пример #11
0
  /**
   * Creates an immutable dictionary containing all of the keys and objects from two dictionaries.
   *
   * @param dict1 the first dictionary
   * @param dict2 the second dictionary
   * @return immutbale dictionary containing the union of the two dictionaries.
   */
  public static <K, V> NSDictionary<K, V> dictionaryWithDictionaryAndDictionary(
      NSDictionary<? extends K, ? extends V> dict1, NSDictionary<? extends K, ? extends V> dict2) {
    if (dict1 == null || dict1.allKeys().count() == 0) return (NSDictionary<K, V>) dict2;
    if (dict2 == null || dict2.allKeys().count() == 0) return (NSDictionary<K, V>) dict1;

    NSMutableDictionary<K, V> result = new NSMutableDictionary<K, V>(dict2);
    result.addEntriesFromDictionary(dict1);
    return new NSDictionary<K, V>(result);
  }
 /**
  * This method encodes the entity name of the enterprise object by searching in the default model
  * group whether it can find the key EncodedEntityNameKey in the user info dictionary.
  *
  * @param eo the enterprise object
  * @return the encoded entity name defaulting to the given eo's entityName
  */
 public static String entityNameEncode(EOEnterpriseObject eo) {
   // Get the EncodedEntityName of the object
   // Default to eo's entityName
   String encodedEntityName = eo.entityName();
   EOEntity entity = EOModelGroup.defaultGroup().entityNamed(eo.entityName());
   NSDictionary userInfo = entity.userInfo();
   if (userInfo != null && userInfo.objectForKey(EncodedEntityNameKey) != null)
     encodedEntityName = (String) userInfo.objectForKey(EncodedEntityNameKey);
   return encodedEntityName;
 }
Пример #13
0
 public ERD2WExtendedRule(EOKeyValueUnarchiver eokeyvalueunarchiver) {
   super(
       eokeyvalueunarchiver.decodeIntForKey("author"),
       ((EOQualifier) eokeyvalueunarchiver.decodeObjectForKey("lhs")),
       ((Assignment) eokeyvalueunarchiver.decodeObjectForKey("rhs")));
   NSDictionary dict = (NSDictionary) eokeyvalueunarchiver.decodeObjectForKey("userInfo");
   setAuthor(eokeyvalueunarchiver.decodeIntForKey("author"));
   assignmentClassName = (String) eokeyvalueunarchiver.decodeObjectForKey("assignmentClassName");
   if (dict != null) setMutableUserInfo(dict.mutableClone());
 }
Пример #14
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;
 }
Пример #15
0
  /**
   * Returns an EOAttribute with all of its fields filled in based on the properties of this
   * ERXMigrationColumn. The attribute is attached to the given entity.
   *
   * @param entity the entity to add the attribute to
   * @return an EOAttribute with all of its fields filled in
   */
  @SuppressWarnings("unchecked")
  public EOAttribute _newAttribute(EOEntity entity) {
    EOAdaptor eoAdaptor = _table.database().adaptor();
    // MS: Hack to make Memory adaptor migrations "work"
    if (!(eoAdaptor instanceof JDBCAdaptor)) {
      EOAttribute nonJdbcAttribute = new EOAttribute();
      nonJdbcAttribute.setName(_name);
      nonJdbcAttribute.setColumnName(_name);
      nonJdbcAttribute.setExternalType("nonJdbcAttribute");
      entity.addAttribute(nonJdbcAttribute);
      return nonJdbcAttribute;
    }

    JDBCAdaptor adaptor = (JDBCAdaptor) _table.database().adaptor();
    ERXSQLHelper sqlHelper = ERXSQLHelper.newSQLHelper(adaptor);
    String externalType = sqlHelper.externalTypeForJDBCType(adaptor, _jdbcType);
    if (externalType == null) {
      externalType = "IF_YOU_ARE_SEEING_THIS_SOMETHING_WENT_WRONG_WITH_EXTERNAL_TYPES";
    }
    EOAttribute attribute =
        adaptor.createAttribute(
            _name, _name, _jdbcType, externalType, _precision, _scale, _allowsNull ? 1 : 0);
    if (_width > 0) {
      attribute.setWidth(_width);
    }
    if (_defaultValue != null) {
      NSDictionary userInfo = attribute.userInfo();
      NSMutableDictionary mutableUserInfo;
      if (userInfo == null) {
        mutableUserInfo = new NSMutableDictionary();
      } else {
        mutableUserInfo = userInfo.mutableClone();
      }
      mutableUserInfo.setObjectForKey(_defaultValue, "default");
      attribute.setUserInfo(mutableUserInfo);
    }

    if (_overrideValueType != null) {
      if (ERXMigrationColumn.NULL_VALUE_TYPE.equals(_overrideValueType)) {
        attribute.setValueType(null);
      } else {
        attribute.setValueType(_overrideValueType);
      }
      if (sqlHelper.reassignExternalTypeForValueTypeOverride(attribute)) {
        adaptor.assignExternalTypeForAttribute(attribute);
      }
    }

    if (_overrideExternalType != null) {
      attribute.setExternalType(_overrideExternalType);
    }

    entity.addAttribute(attribute);
    return attribute;
  }
Пример #16
0
  /**
   * Overrides the parent implementation to provide a more efficient mechanism for generating
   * primary keys, while generating the primary key support on the fly.
   *
   * @param count the batch size
   * @param entity the entity requesting primary keys
   * @param channel open JDBCChannel
   * @return NSArray of NSDictionary where each dictionary corresponds to a unique primary key value
   */
  public NSArray newPrimaryKeys(int count, EOEntity entity, JDBCChannel channel) {
    if (isPrimaryKeyGenerationNotSupported(entity)) {
      return null;
    }

    EOAttribute attribute = (EOAttribute) entity.primaryKeyAttributes().lastObject();
    String attrName = attribute.name();
    boolean isIntType = "i".equals(attribute.valueType());

    NSMutableArray results = new NSMutableArray(count);
    String sequenceName = sequenceNameForEntity(entity);
    DB2Expression expression = new DB2Expression(entity);

    boolean succeeded = false;
    for (int tries = 0; !succeeded && tries < 2; tries++) {
      while (results.count() < count) {
        try {
          StringBuffer sql = new StringBuffer();
          sql.append("SELECT ");
          sql.append("next value for " + sequenceName + " AS KEY");
          sql.append(" from sysibm.sysdummy1");
          expression.setStatement(sql.toString());
          channel.evaluateExpression(expression);
          try {
            NSDictionary row;
            while ((row = channel.fetchRow()) != null) {
              Enumeration pksEnum = row.allValues().objectEnumerator();
              while (pksEnum.hasMoreElements()) {
                Number pkObj = (Number) pksEnum.nextElement();
                Number pk;
                if (isIntType) {
                  pk = Integer.valueOf(pkObj.intValue());
                } else {
                  pk = Long.valueOf(pkObj.longValue());
                }
                results.addObject(new NSDictionary(pk, attrName));
              }
            }
          } finally {
            channel.cancelFetch();
          }
          succeeded = true;
        } catch (JDBCAdaptorException ex) {
          throw ex;
        }
      }
    }

    if (results.count() != count) {
      throw new IllegalStateException(
          "Unable to generate primary keys from the sequence for " + entity + ".");
    }

    return results;
  }
 // FIXME: Should check for NSKeyValueCoding.NullValue
 public Object fireNow(D2WContext c) {
   Object result = null;
   String keyPath;
   String resultKey;
   NSDictionary conditionAssignment = (NSDictionary) this.value();
   keyPath = (String) conditionAssignment.valueForKey("nonNullKeyPath");
   resultKey = c.valueForKeyPath(keyPath) == null ? "falseValue" : "trueValue";
   result = conditionAssignment.objectForKey(resultKey);
   if (log.isDebugEnabled()) log.debug("ResultKey:  " + resultKey + " = " + result);
   return result;
 }
Пример #18
0
 public static <K, V> NSDictionary<K, V> removeNullValues(NSDictionary<K, V> dict) {
   NSMutableDictionary<K, V> d = new NSMutableDictionary<K, V>();
   for (Enumeration<K> e = dict.keyEnumerator(); e.hasMoreElements(); ) {
     K key = e.nextElement();
     V o = dict.objectForKey(key);
     if (!(o instanceof NSKeyValueCoding.Null)) {
       d.setObjectForKey(o, key);
     }
   }
   return d;
 }
Пример #19
0
  /**
   * @param d dictionary to sort keys from
   * @return keys from d sorted by ascending value they are mapped to
   */
  public static <T> NSArray<T> keysSortedByValueAscending(final NSDictionary<T, ?> d) {
    NSArray<T> result = null;

    if (d != null && d.count() > 0) {
      final NSArray<T> keys = d.allKeys();
      result =
          ERXArrayUtilities.sortedArrayUsingComparator(keys, new NSDictionaryKeyValueComparator(d));
    }

    return result != null ? result : NSArray.EmptyArray;
  }
Пример #20
0
 @Override
 public NSDictionary statistics() {
   NSDictionary stats = super.statistics();
   NSMutableDictionary fixed = stats.mutableClone();
   for (Enumeration enumerator = stats.keyEnumerator(); enumerator.hasMoreElements(); ) {
     Object key = enumerator.nextElement();
     Object value = stats.objectForKey(key);
     fixed.setObjectForKey(fix(value), key);
   }
   stats = fixed;
   return stats;
 }
 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;
 }
Пример #22
0
  // if you're keys are not all strings, this method will throw.
  public static NSArray<String> stringKeysSortedAscending(final NSDictionary<String, ?> d) {
    NSArray<String> result = null;

    if (d != null && d.count() > 0) {
      final NSArray<String> keys = d.allKeys();
      result =
          ERXArrayUtilities.sortedArrayUsingComparator(
              keys, NSComparator.AscendingStringComparator);
    }

    return result != null ? result : NSArray.EmptyArray;
  }
  protected static NSDictionary transformDictionary(NSDictionary dictionary, NSDictionary lookup) {
    NSMutableDictionary transformedDictionary = new NSMutableDictionary(dictionary.count());
    Enumeration keys = dictionary.keyEnumerator();

    while (keys.hasMoreElements()) {
      Object key = keys.nextElement();
      Object value = dictionary.objectForKey(key);

      transformedDictionary.setObjectForKey(RuleModelUtilities.transform(value, lookup), key);
    }

    return transformedDictionary;
  }
 public String selectAnneeEnCours(NSDictionary bindings) {
   String id = (String) bindings.valueForKey("indivId");
   if (id == null) {
     id = (String) bindings.valueForKey("numero");
   }
   String select = "SELECT rp.an_univ||rp.prd_univ as PERIODE, ";
   select += "rp.libelle, rp.prd_session, rp.an_civ as ANNEE ";
   String from = "FROM gerry.param_prd pp, gerry.ref_periode rp ";
   String where =
       "WHERE pp.an_univ||pp.prd_univ = rp.an_univ||rp.prd_univ AND pp.par_prd_type='DEF'";
   String sql = select + from + where;
   return sql;
 }
Пример #25
0
 protected void _addUpdateResponseToErrorArray(
     NSDictionary updateTypeResponse, String responseKey, NSMutableArray errorArray) {
   NSArray aResponse = (NSArray) updateTypeResponse.valueForKey(responseKey);
   if (aResponse != null) {
     for (Enumeration e = aResponse.objectEnumerator(); e.hasMoreElements(); ) {
       NSDictionary aDict = (NSDictionary) e.nextElement();
       String errorMessage = (String) aDict.valueForKey("errorMessage");
       if (errorMessage != null) {
         errorArray.addObject(errorMessage);
       }
     }
   }
 }
Пример #26
0
  public MTAjaxTabbedPanel(String name, NSDictionary associations, WOElement template) {
    super(name, associations, template);
    content = template;
    id = (WOAssociation) associations.objectForKey("id");
    busyDiv = (WOAssociation) associations.objectForKey("busyDiv");
    onLoad = (WOAssociation) associations.objectForKey("onLoad");
    onSelect = (WOAssociation) associations.objectForKey("onSelect");
    findTabs((WODynamicGroup) template);

    if (id == null) {
      throw new RuntimeException("id binding is required");
    }
  }
Пример #27
0
 /**
  * Removes an array of keys from a dictionary and returns the result.
  *
  * @param d dictionary to be pruned
  * @param a array of keys to be pruned
  * @return pruned dictionary
  */
 public static <K, V> NSDictionary<K, V> dictionaryByRemovingFromDictionaryKeysInArray(
     NSDictionary<K, V> d, NSArray<K> a) {
   NSMutableDictionary<K, V> result = new NSMutableDictionary<K, V>();
   if (d != null && a != null) {
     for (Enumeration<K> e = d.allKeys().objectEnumerator(); e.hasMoreElements(); ) {
       K key = e.nextElement();
       if (!a.containsObject(key)) {
         result.setObjectForKey(d.objectForKey(key), key);
       }
     }
   }
   return result.immutableClone();
 }
Пример #28
0
  /**
   * Sets up a route controller based on a request userInfo that came from routeForMethodAndPath.
   *
   * @param controller the controller to setup
   * @param userInfo the request userInfo
   */
  public void setupRouteControllerFromUserInfo(
      ERXRouteController controller, NSDictionary<String, Object> userInfo) {
    controller._setRequestHandler(this);

    if (userInfo != null) {
      ERXRoute route = (ERXRoute) userInfo.objectForKey(ERXRouteRequestHandler.RouteKey);
      controller._setRoute(route);
      @SuppressWarnings("unchecked")
      NSDictionary<ERXRoute.Key, String> keys =
          (NSDictionary<ERXRoute.Key, String>)
              userInfo.objectForKey(ERXRouteRequestHandler.KeysKey);
      controller._setRouteKeys(keys);
    }
  }
Пример #29
0
 /**
  * V�rifie que le WebService poss?de les op�rations requises � l'utilisation de ce client.
  *
  * @throws Exception
  */
 private void checkWSRequirements() throws Exception {
   NSDictionary dic = wsClient.operationsDictionaryForService(wsName);
   for (int i = 0; i < requiredOperations().length; i++) {
     String string = requiredOperations()[i];
     if (dic.valueForKey(string) == null) {
       throw new Exception(
           "L'operation "
               + string
               + " n'est pas d�finie pour le WebService "
               + wsName
               + ". Votre classe d'invocation ne peut pas h�riter de ZWSInvocator.");
     }
   }
 }
Пример #30
0
  /* ******** Error Handling ********* */
  public NSMutableArray getUpdateErrors(
      NSDictionary[] responseDicts,
      String updateType,
      boolean hasHosts,
      boolean hasApplications,
      boolean hasInstances,
      boolean hasSite) {
    NSMutableArray errorArray = new NSMutableArray();

    boolean clearOverwrite = false;
    if ((updateType.equals("overwrite")) || (updateType.equals("clear"))) clearOverwrite = true;

    for (int i = 0; i < responseDicts.length; i++) {
      if (responseDicts[i] != null) {
        NSDictionary responseDict = responseDicts[i];
        getGlobalErrorFromResponse(responseDict, errorArray);

        NSDictionary updateWotaskdResponseDict =
            (NSDictionary) responseDict.valueForKey("updateWotaskdResponse");

        if (updateWotaskdResponseDict != null) {
          NSDictionary updateTypeResponse =
              (NSDictionary) updateWotaskdResponseDict.valueForKey(updateType);
          if (updateTypeResponse != null) {
            if (clearOverwrite) {
              String errorMessage = (String) updateTypeResponse.valueForKey("errorMessage");
              if (errorMessage != null) {
                errorArray.addObject(errorMessage);
              }
            } else {
              if (hasSite) {
                NSDictionary aDict = (NSDictionary) updateTypeResponse.valueForKey("site");
                String errorMessage = (String) aDict.valueForKey("errorMessage");
                if (errorMessage != null) {
                  errorArray.addObject(errorMessage);
                }
              }
              if (hasHosts)
                _addUpdateResponseToErrorArray(updateTypeResponse, "hostArray", errorArray);
              if (hasApplications)
                _addUpdateResponseToErrorArray(updateTypeResponse, "applicationArray", errorArray);
              if (hasInstances)
                _addUpdateResponseToErrorArray(updateTypeResponse, "instanceArray", errorArray);
            }
          }
        }
      }
    }
    if (NSLog.debugLoggingAllowedForLevelAndGroups(
        NSLog.DebugLevelDetailed, NSLog.DebugGroupDeployment))
      NSLog.debug.appendln("##### getUpdateErrors: " + errorArray);
    mySession().addObjectsFromArrayIfAbsentToErrorMessageArray(errorArray);
    return errorArray;
  }