コード例 #1
0
  public static void sendCommandInstancesToWotaskds(
      String command, NSArray instanceArray, NSArray wotaskdArray, WOTaskdHandler collector) {
    if (instanceArray.count() > 0 && wotaskdArray.count() > 0) {
      int instanceCount = instanceArray.count();

      NSMutableDictionary monitorRequest = new NSMutableDictionary(1);
      NSMutableArray commandWotaskd = new NSMutableArray(instanceArray.count() + 1);

      commandWotaskd.addObject(command);

      for (int i = 0; i < instanceCount; i++) {
        MInstance anInst = (MInstance) instanceArray.objectAtIndex(i);
        commandWotaskd.addObject(
            new NSDictionary(
                new Object[] {
                  anInst.applicationName(), anInst.id(), anInst.hostName(), anInst.port()
                },
                commandInstanceKeys));
      }
      monitorRequest.takeValueForKey(commandWotaskd, "commandWotaskd");

      WOResponse[] responses = collector.sendRequest(monitorRequest, wotaskdArray, false);
      NSDictionary[] responseDicts = collector.generateResponseDictionaries(responses);
      if (NSLog.debugLoggingAllowedForLevelAndGroups(
          NSLog.DebugLevelDetailed, NSLog.DebugGroupDeployment)) {
        NSLog.debug.appendln(
            "OUT: "
                + NSPropertyListSerialization.stringFromPropertyList(monitorRequest)
                + "\n\nIN: "
                + NSPropertyListSerialization.stringFromPropertyList(new NSArray(responseDicts)));
      }
      collector.getCommandErrors(responseDicts);
    }
  }
コード例 #2
0
 /**
  * Constructs the form values dictionary by first calling the method <code>
  * encodeEnterpriseObjectsPrimaryKeyForUrl</code> and then using the results of that to construct
  * the dictionary.
  *
  * @param eos array of enterprise objects to be encoded in the url
  * @param separator to be used to separate entity names
  * @param encrypt flag to determine if the primary key of the objects should be encrypted.
  * @return dictionary containing all of the key value pairs where the keys denote the entity names
  *     and the values denote the possibly encrypted primary keys.
  */
 public static NSDictionary dictionaryOfFormValuesForEnterpriseObjects(
     NSArray eos, String separator, boolean encrypt) {
   String base = encodeEnterpriseObjectsPrimaryKeyForUrl(eos, separator, encrypt);
   NSArray elements = NSArray.componentsSeparatedByString(base, "&");
   return (NSDictionary)
       NSPropertyListSerialization.propertyListFromString(
           "{" + elements.componentsJoinedByString(";") + ";}");
 }
コード例 #3
0
ファイル: TabDescriptor.java プロジェクト: kylelaker/web-cat
 /**
  * Generate tab descriptors from a property list description.
  *
  * @param data the raw bytes from the property list
  * @return An array of the new tab descriptors
  */
 public static NSArray<TabDescriptor> tabsFromPropertyList(NSData data) {
   @SuppressWarnings("unchecked")
   NSDictionary<String, NSDictionary<String, Object>> dict =
       (NSDictionary<String, NSDictionary<String, Object>>)
           NSPropertyListSerialization.propertyListFromData(data, "UTF-8");
   log.debug("tabFromPropertyList(): dict = " + dict);
   return tabsFromDictionary(dict);
 }
コード例 #4
0
ファイル: _MySQLPlugIn.java プロジェクト: pgrbnsn/wonder
 protected void writeJDBCInfo(NSDictionary<String, Object> jdbcInfo) {
   try {
     String jdbcInfoS = NSPropertyListSerialization.stringFromPropertyList(jdbcInfo);
     FileOutputStream fos = new FileOutputStream("/tmp/JDBCInfo.plist");
     fos.write(jdbcInfoS.getBytes());
     fos.close();
   } catch (Exception e) {
     throw new IllegalStateException("problem writing JDBCInfo.plist", e);
   }
 }
コード例 #5
0
  protected static String encode(NSArray rules) {
    if (rules != null) {
      EOKeyValueArchiver archiver = new EOKeyValueArchiver();

      archiver.encodeObject(rules, RuleModel.RULES_KEY);

      return NSPropertyListSerialization.stringFromPropertyList(
          transformDictionary(archiver.dictionary(), RuleModelUtilities.compressionLookup()));
    } else {
      return null;
    }
  }
コード例 #6
0
  protected static NSArray decode(String string) {
    if (string != null) {
      NSDictionary dictionary = NSPropertyListSerialization.dictionaryForString(string);
      EOKeyValueUnarchiver unarchiver =
          new EOKeyValueUnarchiver(
              transformDictionary(dictionary, RuleModelUtilities.expansionLookup()));
      NSArray rules = (NSArray) unarchiver.decodeObjectForKey(RuleModel.RULES_KEY);

      unarchiver.finishInitializationOfObjects();

      return rules;
    } else {
      return null;
    }
  }
コード例 #7
0
ファイル: DB2PlugIn.java プロジェクト: BhavinGitHub/wonder
  /**
   * This is usually extracted from the the database using JDBC, but this is really inconvenient for
   * users who are trying to generate SQL at some. A specific version of the data has been written
   * into the property list of the framework and this can be used as a hard-coded equivalent.
   */
  public NSDictionary jdbcInfo() {
    // you can swap this code out to write the property list out in order
    // to get a fresh copy of the JDBCInfo.plist.
    //    try {
    //      String jdbcInfoS = NSPropertyListSerialization.stringFromPropertyList(super.jdbcInfo());
    //      FileOutputStream fos = new FileOutputStream("/tmp/JDBCInfo.plist");
    //      fos.write(jdbcInfoS.getBytes());
    //      fos.close();
    //    }
    //    catch(Exception e) {
    //      throw new IllegalStateException("problem writing JDBCInfo.plist",e);
    //    }

    NSDictionary jdbcInfo;
    // have a look at the JDBC connection URL to see if the flag has been set to
    // specify that the hard-coded jdbcInfo information should be used.
    if (shouldUseBundledJdbcInfo()) {
      if (NSLog.debugLoggingAllowedForLevel(NSLog.DebugLevelDetailed)) {
        NSLog.debug.appendln(
            "Loading jdbcInfo from JDBCInfo.plist as opposed to using the JDBCPlugIn default implementation.");
      }

      InputStream jdbcInfoStream =
          NSBundle.bundleForClass(getClass()).inputStreamForResourcePath("JDBCInfo.plist");
      if (jdbcInfoStream == null) {
        throw new IllegalStateException("Unable to find 'JDBCInfo.plist' in this plugin jar.");
      }

      try {
        jdbcInfo =
            (NSDictionary)
                NSPropertyListSerialization.propertyListFromData(
                    new NSData(jdbcInfoStream, 2048), "US-ASCII");
      } catch (IOException e) {
        throw new RuntimeException("Failed to load 'JDBCInfo.plist' from this plugin jar.", e);
      } finally {
        try {
          jdbcInfoStream.close();
        } catch (IOException e) {
        }
      }
    } else {
      jdbcInfo = super.jdbcInfo();
    }
    return jdbcInfo;
  }
コード例 #8
0
ファイル: UploadAnchor.java プロジェクト: baywind/reusables
  public NSDictionary preferences() {
    NSDictionary result = (NSDictionary) valueForBinding("prefsDict");
    if (result == null) {
      java.io.InputStream inputStream =
          application()
              .resourceManager()
              .inputStreamForResourceNamed(
                  (String) valueForBinding("prefsFile"),
                  (String) valueForBinding("framework"),
                  null);

      // read in the data, log exceptions
      try {
        NSData prefsData = new NSData(inputStream, inputStream.available());
        result = (NSDictionary) NSPropertyListSerialization.propertyListFromData(prefsData, "UTF8");
        inputStream.close();
      } catch (Exception exception) {
        NSLog.out.appendln("UploadAnchor:  failed to read preferences file" + exception);
      }
    }
    return result;
  }
コード例 #9
0
ファイル: RuleEditor.java プロジェクト: hypeastrum/wonder
 public String objectAsString(Rule o) {
   EOKeyValueArchiver eokeyvaluearchiver = new EOKeyValueArchiver();
   o.encodeWithKeyValueArchiver(eokeyvaluearchiver);
   return NSPropertyListSerialization.stringFromPropertyList(eokeyvaluearchiver.dictionary());
 }
コード例 #10
0
ファイル: _MySQLPlugIn.java プロジェクト: pgrbnsn/wonder
  @Override
  @SuppressWarnings({"unchecked", "rawtypes"})
  public NSDictionary<String, Object> jdbcInfo() {

    NSDictionary<String, Object> jdbcInfo;
    // have a look at the JDBC connection URL to see if the flag has been set to
    // specify that the hard-coded jdbcInfo information should be used.
    if (shouldUseBundledJdbcInfo()) {
      if (NSLog.debugLoggingAllowedForLevel(NSLog.DebugLevelDetailed)) {
        NSLog.debug.appendln(
            "Loading jdbcInfo from JDBCInfo.plist as opposed to using the JDBCPlugIn default implementation.");
      }

      InputStream jdbcInfoStream =
          NSBundle.bundleForClass(getClass()).inputStreamForResourcePath("JDBCInfo.plist");
      if (jdbcInfoStream == null) {
        throw new IllegalStateException("Unable to find 'JDBCInfo.plist' in this plugin jar.");
      }

      try {
        jdbcInfo =
            (NSDictionary<String, Object>)
                NSPropertyListSerialization.propertyListFromData(
                    new NSData(jdbcInfoStream, 2048), "US-ASCII");
      } catch (IOException e) {
        throw new RuntimeException("Failed to load 'JDBCInfo.plist' from this plugin jar.", e);
      }

    } else {

      NSMutableDictionary<String, Object> mutableInfo = super.jdbcInfo().mutableClone();
      NSMutableDictionary<String, NSDictionary> typeInfo =
          ((NSDictionary<String, NSDictionary>) mutableInfo.objectForKey("typeInfo"))
              .mutableClone();
      NSDictionary textTypeInfo = typeInfo.objectForKey("TEXT");
      if (textTypeInfo != null) {
        Object rawCreateParams = textTypeInfo.objectForKey("createParams");
        if (!rawCreateParams.equals("1")) {
          NSMutableDictionary newRawTypeInfo = textTypeInfo.mutableClone();
          newRawTypeInfo.setObjectForKey("1", "createParams");
          typeInfo.setObjectForKey(newRawTypeInfo, "RAW");
        }
      }
      JDBCPlugIn._takeValueForKeyPath(typeInfo, "0", "BLOB", "createParams");
      JDBCPlugIn._takeValueForKeyPath(typeInfo, "0", "LONGBLOB", "createParams");
      JDBCPlugIn._takeValueForKeyPath(typeInfo, "0", "MEDIUMBLOB", "createParams");
      JDBCPlugIn._takeValueForKeyPath(typeInfo, "0", "TINYBLOB", "createParams");
      mutableInfo.setObjectForKey(typeInfo, "typeInfo");

      NSLog.debug.appendln(
          new StringBuilder("fetched MySQL (")
              .append(databaseProductName())
              .append(") JDBC Info = ")
              .append(mutableInfo)
              .toString());

      // Write a fresh copy of JDBCInfo.plist to /tmp
      // writeJDBCInfo(mutableInfo);

      jdbcInfo = mutableInfo.immutableClone();
    }
    return jdbcInfo;
  }
コード例 #11
0
 /**
  * Creates an NSDictionary from a resource associated with a given bundle that is in property list
  * format.
  *
  * @param name name of the file or resource.
  * @param bundle NSBundle to which the resource belongs.
  * @return NSDictionary de-serialized from the property list.
  */
 @SuppressWarnings("unchecked")
 public static NSDictionary dictionaryFromPropertyList(String name, NSBundle bundle) {
   String string = ERXStringUtilities.stringFromResource(name, "plist", bundle);
   return (NSDictionary<?, ?>) NSPropertyListSerialization.propertyListFromString(string);
 }