Пример #1
0
  /** 空行をskipして読めること。 その際に、データ部の改行による空行を除かないこと。 */
  @Test
  public void read_skip_emptyline() throws Throwable {
    // ## Arrange ##
    final Reader r = getResourceAsReader("-11", "tsv");

    final MapCsvLayout<String> layout = new MapCsvLayout<String>();
    layout.setLineReaderHandler(new SkipEmptyLineReadEditor());

    // ## Act ##
    final RecordReader<Map<String, String>> csvReader = layout.build().openReader(r);

    // ## Assert ##
    final Map<String, String> bean = CollectionsUtil.newHashMap();
    assertEquals(true, csvReader.hasNext());
    csvReader.read(bean);
    logger.debug(bean.toString());
    assertEquals("あ1", bean.get("aaa"));
    assertEquals("い1", bean.get("bbb"));
    assertEquals("う1", bean.get("ccc"));

    assertEquals(true, csvReader.hasNext());
    csvReader.read(bean);
    logger.debug(bean.toString());
    assertEquals("あ2", bean.get("aaa"));
    assertEquals("い\r\n\r\n\r\n2", bean.get("bbb"));
    assertEquals("う2", bean.get("ccc"));

    assertEquals(false, csvReader.hasNext());
    csvReader.close();
  }
 /** Notification that the invariants have broken, triggers an error. */
 private void invariantsBroken(Object key, Object value) {
   String mapBefore = _map.toString();
   String setBefore = _sortedSet.toString();
   String mapSizeBefore = "" + _map.size();
   String setSizeBefore = "" + _sortedSet.size();
   stabilize();
   String mapAfter = _map.toString();
   String setAfter = _sortedSet.toString();
   String mapSizeAfter = "" + _map.size();
   String setSizeAfter = "" + _sortedSet.size();
   Assert.silent(
       false,
       "key: "
           + key
           + ", value: "
           + value
           + "\nbefore stabilization: "
           + "\nsize of map: "
           + mapSizeBefore
           + ", set: "
           + setSizeBefore
           + "\nmap: "
           + mapBefore
           + "\nset: "
           + setBefore
           + "\nafter stabilization: "
           + "\nsize of map "
           + mapSizeAfter
           + ", set: "
           + setSizeAfter
           + "\nmap: "
           + mapAfter
           + "\nset: "
           + setAfter);
 }
Пример #3
0
  static void assertReadSmallColumns(
      final RecordReader<Map<String, String>> csvReader, final Map<String, String> bean)
      throws IOException {

    assertEquals(true, csvReader.hasNext());
    csvReader.read(bean);
    logger.debug(bean.toString());
    assertEquals("あ1", bean.get("aaa"));
    assertEquals(null, bean.get("bbb"));
    assertEquals("う1", bean.get("ccc"));

    assertEquals(true, csvReader.hasNext());
    // ファイルにbbbは無いため、nullで上書きされること
    bean.put("aaa", "zz1");
    bean.put("bbb", "zz2");
    bean.put("ccc", "zz3");
    csvReader.read(bean);
    logger.debug(bean.toString());
    assertEquals("あ2", bean.get("aaa"));
    assertEquals(null, bean.get("bbb"));
    assertEquals("う2", bean.get("ccc"));

    assertEquals(false, csvReader.hasNext());
    csvReader.close();
  }
Пример #4
0
  private static <T> T lookupMBean(
      final Map<String, String> props,
      final Class<T> type,
      final Predicate<T> tester,
      final long timeout) {
    long until = System.currentTimeMillis() + timeout;
    do
      try {
        final T bean = Mbeans.lookup(jdbcJmxDomain, props, type);
        tester.apply(bean);
        return bean;
      } catch (UndeclaredThrowableException e) {
        if (Exceptions.isCausedBy(e, InstanceNotFoundException.class)) {
          if (System.currentTimeMillis() < until) {
            try {
              TimeUnit.SECONDS.sleep(5);
            } catch (InterruptedException e1) {
              Thread.interrupted();
              break;
            }
            LOG.debug("Waiting for MBean " + type.getSimpleName() + "/" + props);
            continue;
          }
          throw new NoSuchElementException(type.getSimpleName() + " " + props.toString());
        } else {
          throw Exceptions.toUndeclared(e);
        }
      }
    while (System.currentTimeMillis() < until);

    throw new NoSuchElementException(type.getSimpleName() + " " + props.toString());
  }
Пример #5
0
  public static void assertRead1(
      final RecordReader<Map<String, String>> csvReader, final Map<String, String> bean)
      throws IOException {

    assertEquals(0, csvReader.getRecordNumber());
    assertEquals(true, csvReader.hasNext());
    assertEquals(0, csvReader.getRecordNumber());
    csvReader.read(bean);
    logger.debug(bean.toString());
    assertEquals(1, csvReader.getRecordNumber());
    assertEquals("あ1", bean.get("aaa"));
    assertEquals("い1", bean.get("bbb"));
    assertEquals("う1", bean.get("ccc"));

    assertEquals(true, csvReader.hasNext());
    csvReader.read(bean);
    logger.debug(bean.toString());
    assertEquals(2, csvReader.getRecordNumber());
    assertEquals("あ2", bean.get("aaa"));
    assertEquals("い2", bean.get("bbb"));
    assertEquals("う2", bean.get("ccc"));

    assertEquals(true, csvReader.hasNext());
    csvReader.read(bean);
    logger.debug(bean.toString());
    assertEquals(3, csvReader.getRecordNumber());
    assertEquals("あ3", bean.get("aaa"));
    assertEquals("い3", bean.get("bbb"));
    assertEquals("う3", bean.get("ccc"));

    assertEquals(false, csvReader.hasNext());
    assertEquals(3, csvReader.getRecordNumber());
    csvReader.close();
  }
Пример #6
0
 public String toString() {
   return String.format(
       "CFPropDefs(%s, compaction: %s, compression: %s)",
       properties.toString(),
       compactionStrategyOptions.toString(),
       compressionParameters.toString());
 }
Пример #7
0
  static void assertReadEmptyRow2(final RecordReader<Map<String, String>> csvReader)
      throws IOException {

    {
      assertEquals(true, csvReader.hasNext());
      final Map<String, String> bean = csvReader.read();
      logger.debug(bean.toString());
      assertEquals("あ1", bean.get("aaa"));
      assertEquals("い1", bean.get("bbb"));
      assertEquals("う1", bean.get("ccc"));
    }

    {
      assertEquals(true, csvReader.hasNext());
      final Map<String, String> bean = csvReader.read();
      logger.debug(bean.toString());
      assertEquals(null, bean.get("aaa"));
      assertEquals(null, bean.get("bbb"));
      assertEquals(null, bean.get("ccc"));
    }

    {
      assertEquals(true, csvReader.hasNext());
      final Map<String, String> bean = csvReader.read();
      logger.debug(bean.toString());
      assertEquals("あ3", bean.get("aaa"));
      assertEquals("い3", bean.get("bbb"));
      assertEquals("う3", bean.get("ccc"));
    }

    assertEquals(false, csvReader.hasNext());
    csvReader.close();
  }
Пример #8
0
 public void testConstrainedMapLegal() {
   Map<String, Integer> map = Maps.newLinkedHashMap();
   Map<String, Integer> constrained = MapConstraints.constrainedMap(map, TEST_CONSTRAINT);
   map.put(TEST_KEY, TEST_VALUE);
   constrained.put("foo", 1);
   map.putAll(ImmutableMap.of("bar", 2));
   constrained.putAll(ImmutableMap.of("baz", 3));
   assertTrue(map.equals(constrained));
   assertTrue(constrained.equals(map));
   assertEquals(map.entrySet(), constrained.entrySet());
   assertEquals(map.keySet(), constrained.keySet());
   assertEquals(HashMultiset.create(map.values()), HashMultiset.create(constrained.values()));
   assertFalse(map.values() instanceof Serializable);
   assertEquals(map.toString(), constrained.toString());
   assertEquals(map.hashCode(), constrained.hashCode());
   ASSERT
       .that(map.entrySet())
       .has()
       .allOf(
           Maps.immutableEntry(TEST_KEY, TEST_VALUE),
           Maps.immutableEntry("foo", 1),
           Maps.immutableEntry("bar", 2),
           Maps.immutableEntry("baz", 3))
       .inOrder();
 }
Пример #9
0
 public String toStringShort() {
   StringBuilder sb = new StringBuilder();
   sb.append(
       String.format("character counts: %s\n", characterOccurrences.toString())); // $NON-NLS-1$
   sb.append(String.format("doublet counts: %s\n", doubletOccurrences.toString())); // $NON-NLS-1$
   sb.append(String.format("triplet counts: %s", tripletOccurrences.toString())); // $NON-NLS-1$
   return sb.toString();
 }
Пример #10
0
  /**
   * Tests Map.toString(). Since the format of the string returned by the toString() method is not
   * defined in the Map interface, there is no common way to test the results of the toString()
   * method. Thereforce, it is encouraged that Map implementations override this test with one that
   * checks the format matches any format defined in its API. This default implementation just
   * verifies that the toString() method does not return null.
   */
  public void testMapToString() {
    resetEmpty();
    assertTrue("Empty map toString() should not return null", map.toString() != null);
    verify();

    resetFull();
    assertTrue("Empty map toString() should not return null", map.toString() != null);
    verify();
  }
  @Test
  public void mappedServersTest() {

    Map<Integer, String> servers = new HashMap<>();
    servers.put(0, "server0");
    servers.put(1, "server1");

    HashFunction md5 = Hashing.md5();
    List<PartitionEntry> triggers = generateTriggers(3, 1000);

    Map<Integer, String> newPartition;
    Map<Integer, String> oldPartition;

    print("initial - test 2 servers " + servers.toString());
    newPartition = new HashMap<>();
    for (PartitionEntry trigger : triggers) {
      newPartition.put(
          trigger.hashCode(),
          servers.get(Hashing.consistentHash(md5.hashInt(trigger.hashCode()), 2)));
    }

    for (int buckets = 3; buckets < 10; buckets++) {

      servers.put(buckets - 1, "server" + (buckets - 1));
      print("test " + buckets + " servers " + servers.toString());

      oldPartition = newPartition;
      newPartition = new HashMap<>();
      for (PartitionEntry trigger : triggers) {
        newPartition.put(
            trigger.hashCode(),
            servers.get(Hashing.consistentHash(md5.hashInt(trigger.hashCode()), buckets)));
      }

      int changes = comparePartitions(oldPartition, newPartition);
      print(
          "Changes from "
              + (buckets - 1)
              + "  to "
              + buckets
              + " servers: "
              + changes
              + " of "
              + oldPartition.size());
      print("" + (((float) changes / (float) oldPartition.size()) * 100) + " % moved");
      print(
          "K("
              + oldPartition.size()
              + ")/n("
              + buckets
              + "): "
              + ((float) oldPartition.size() / (float) buckets));
    }
  }
Пример #12
0
 @Override
 public String toString() {
   return Objects.toStringHelper(this)
       .add("startDate", startDate)
       .add("endDate", endDate)
       .add("startOffset", startOffset)
       .add("endOffset", endOffset)
       .add("sourcePartitionOffsetStart", sourcePartitionOffsetStart.toString())
       .add("sourcePartitionOffsetEnd", sourcePartitionOffsetEnd.toString())
       .toString();
 }
  public static void main(String[] args) {

    /** 参数初始化 在java main 方式运行时必须每次都执行加载 如果是在web应用开发里,这个方写在可使用监听的方式写入缓存,无须在这出现 */
    SDKConfig.getConfig().loadPropertiesFromSrc(); // 从classpath加载acp_sdk.properties文件

    /** 组装请求报文 */
    Map<String, String> data = new HashMap<String, String>();
    // 版本号
    data.put("version", "5.0.0");
    // 字符集编码 默认"UTF-8"
    data.put("encoding", "UTF-8");
    // 签名方法 01 RSA
    data.put("signMethod", "01");
    // 交易类型
    data.put("txnType", "32");
    // 交易子类型
    data.put("txnSubType", "00");
    // 业务类型
    data.put("bizType", "000201");
    // 渠道类型,07-PC,08-手机
    data.put("channelType", "08");
    // 前台通知地址 ,控件接入方式无作用
    data.put("frontUrl", "http://localhost:8080/ACPTest/acp_front_url.do");
    // 后台通知地址
    data.put("backUrl", "http://222.222.222.222:8080/ACPTest/acp_back_url.do");
    // 接入类型,商户接入填0 0- 商户 , 1: 收单, 2:平台商户
    data.put("accessType", "0");
    // 商户号码,请改成自己的商户号
    data.put("merId", "888888888888888");
    // 原预授权的queryId,可以从查询接口或者通知接口中获取
    data.put("origQryId", "201502282020185545888");
    // 商户订单号,8-40位数字字母,重新产生,不同于原交易
    data.put("orderId", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()));
    // 订单发送时间,取系统时间
    data.put("txnTime", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()));
    // 交易金额,撤销时需和原预授权一致
    data.put("txnAmt", "1");
    // 交易币种
    data.put("currencyCode", "156");
    // 请求方保留域,透传字段,查询、通知、对账文件中均会原样出现
    // data.put("reqReserved", "透传信息");

    data = signData(data);

    // 交易请求url 从配置文件读取
    String url = SDKConfig.getConfig().getBackRequestUrl();

    Map<String, String> resmap = submitUrl(data, url);

    System.out.println("请求报文=[" + data.toString() + "]");
    System.out.println("应答报文=[" + resmap.toString() + "]");
  }
Пример #14
0
  /** Asserts that two maps are equal. */
  public static void assertEquals(Map<?, ?> actual, Map<?, ?> expected) {
    if (actual == expected) {
      return;
    }

    if (actual == null || expected == null) {
      log.error(message(null, expected.toString(), actual.toString()));
      if (haultonfailure) fail("Maps not equal: expected: " + expected + " and actual: " + actual);
      else {
        if (map == null) {
          map = new LinkedHashMap<String, String>();
        }
        map.put(
            "Maps not equal: "
                + SEPARATOR
                + UtilityMethods.getRandomNumber()
                + System.currentTimeMillis(),
            actual + SEPARATOR + expected);
      }
    }

    if (actual.size() != expected.size()) {
      if (haultonfailure)
        fail("Maps do not have the same size:" + actual.size() + " != " + expected.size());
      else {
        if (map == null) {
          map = new LinkedHashMap<String, String>();
        }
        map.put(
            "Maps do not have the same size: "
                + SEPARATOR
                + UtilityMethods.getRandomNumber()
                + System.currentTimeMillis(),
            actual + SEPARATOR + expected);
      }
    }

    Set<?> entrySet = actual.entrySet();
    for (Iterator<?> iterator = entrySet.iterator(); iterator.hasNext(); ) {
      Map.Entry<?, ?> entry = (Map.Entry<?, ?>) iterator.next();
      Object key = entry.getKey();
      Object value = entry.getValue();
      Object expectedValue = expected.get(key);
      assertEquals(
          value,
          expectedValue,
          "Maps do not match for key:" + key + " actual:" + value + " expected:" + expectedValue);
    }
  }
Пример #15
0
  /** 1つのRecordInOutインスタンスから複数のCsvReaderをopenしたとき、 それぞれのReaderでの処理が影響しないこと。 */
  @Test
  public void openMultiReader() throws Throwable {
    // ## Arrange ##
    final MapCsvLayout<String> layout = new MapCsvLayout<String>();

    // ## Act ##
    final RecordReader<Map<String, String>> csvReader1 =
        layout.build().openReader(getResourceAsReader("-6", "tsv"));

    final Map<String, String> bean1 = CollectionsUtil.newHashMap();
    final Map<String, String> bean2 = CollectionsUtil.newHashMap();

    // ## Assert ##
    csvReader1.read(bean1);
    logger.debug(bean1.toString());
    assertEquals(4, bean1.size());
    assertEquals("あ1", bean1.get("aaa"));
    assertEquals("い1", bean1.get("bbb"));
    assertEquals("う1", bean1.get("ccc"));
    assertEquals("え1", bean1.get("ddd"));

    final RecordReader<Map<String, String>> csvReader2 =
        layout.build().openReader(getResourceAsReader("-4", "tsv"));
    csvReader2.read(bean2);
    assertEquals(3, bean2.size());
    logger.debug(bean2.toString());
    assertEquals("あ1", bean2.get("aaa"));
    assertEquals("い1", bean2.get("bbb"));
    assertEquals(" ", bean2.get("ccc"));

    csvReader1.read(bean1);
    logger.debug(bean1.toString());
    assertEquals(4, bean1.size());
    assertEquals("あ2", bean1.get("aaa"));
    assertEquals("い2", bean1.get("bbb"));
    assertEquals("う2", bean1.get("ccc"));
    assertEquals("え2", bean1.get("ddd"));

    csvReader2.read(bean2);
    logger.debug(bean2.toString());
    assertEquals(3, bean2.size());
    assertEquals(null, bean2.get("aaa"));
    assertEquals("い2", bean2.get("bbb"));
    assertEquals(null, bean2.get("ccc"));

    csvReader1.close();
    csvReader2.close();
  }
 @Override
 public String toString() {
   return "cluster: "
       + (this.cluster == null ? "" : this.cluster)
       + "summaryMap: "
       + summaryMap.toString();
 }
  @SuppressWarnings({"UnnecessaryBoxing", "UnnecessaryUnboxing"})
  protected void assertAllDataRemoved() {
    if (!createSchema()) {
      return; // no tables were created...
    }
    if (!Boolean.getBoolean(VALIDATE_DATA_CLEANUP)) {
      return;
    }

    Session tmpSession = sessionFactory.openSession();
    try {
      List list = tmpSession.createQuery("select o from java.lang.Object o").list();

      Map<String, Integer> items = new HashMap<String, Integer>();
      if (!list.isEmpty()) {
        for (Object element : list) {
          Integer l = items.get(tmpSession.getEntityName(element));
          if (l == null) {
            l = 0;
          }
          l = l + 1;
          items.put(tmpSession.getEntityName(element), l);
          System.out.println("Data left: " + element);
        }
        fail("Data is left in the database: " + items.toString());
      }
    } finally {
      try {
        tmpSession.close();
      } catch (Throwable t) {
        // intentionally empty
      }
    }
  }
Пример #18
0
  public static void main(String[] args)
      throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
    Company com = new Company();

    com.setName("");
    com.getName();

    // simple
    BeanUtils.setProperty(com, "name", "Jack");
    BeanUtils.getProperty(com, "name");

    // indexed
    BeanUtils.setProperty(com, "product[1]", "NOTES SERVER");
    BeanUtils.getProperty(com, "product[1]");

    // mapped
    HashMap am = new HashMap();
    am.put("1", "10010");
    am.put("2", "10010");
    BeanUtils.setProperty(com, "telephone", am);
    BeanUtils.getProperty(com, "telephone(2)");

    // combined
    BeanUtils.getProperty(com, "employee[1].name");

    // copyProperty
    Company com2 = new Company();
    BeanUtils.copyProperties(com2, com);

    // converter
    BeanUtils.setProperty(com, "date", new Date());

    BeanUtils.setProperty(com, "date", "2013-10-01");

    ConvertUtils.register(
        new Converter() {

          public <T> T convert(Class<T> type, Object value) {
            // TODO Auto-generated method stub
            return null;
          }
        },
        Date.class);

    // DynamicBean
    LazyDynaMap dynaBean = new LazyDynaMap();

    dynaBean.set("foo", "bar");
    dynaBean.set("customer", "title", "Rose");
    dynaBean.set("address", 0, "address1");
    System.out.println(dynaBean.get("address", 0));
    Map map = dynaBean.getMap();
    System.out.println(map.toString());

    // returnNull
    dynaBean.setReturnNull(true);

    // Restricted
    dynaBean.setRestricted(true);
  }
Пример #19
0
 public static Map<String, String> getSearchRecipesOptions(String query, int page) {
   Map<String, String> options = new HashMap<>();
   options.put("q", query);
   options.put("page", String.valueOf(page));
   Log.d("food2fork", "query Search - " + options.toString());
   return options;
 }
Пример #20
0
 private Map<String, Object> getID3Tags(String filename) {
   debug("Getting the properties.");
   Map<String, Object> props = new HashMap<String, Object>();
   try {
     MpegAudioFileReader reader = new MpegAudioFileReader(this);
     // InputStream stream = createInput(filename);
     InputStream stream = new FileInputStream(filename);
     AudioFileFormat baseFileFormat = reader.getAudioFileFormat(stream, stream.available());
     stream.close();
     if (baseFileFormat instanceof TAudioFileFormat) {
       TAudioFileFormat fileFormat = (TAudioFileFormat) baseFileFormat;
       props = fileFormat.properties();
       if (props.size() == 0) {
         error("No file properties available for " + filename + ".");
       } else {
         debug("File properties: " + props.toString());
       }
     }
   } catch (UnsupportedAudioFileException e) {
     error("Couldn't get the file format for " + filename + ": " + e.getMessage());
   } catch (IOException e) {
     error("Couldn't access " + filename + ": " + e.getMessage());
   }
   return props;
 }
  public Subject krb5PasswordLogin(String password) {
    String loginModuleName = "krb5UsernamePasswordLogin";

    LOG.info(
        "Attempting kerberos authentication of user: "******" using username and password mechanism");

    // Set the domain to realm and the kdc
    // System.setProperty("java.security.krb5.realm", "JTLAN.CO.UK");
    // System.setProperty("java.security.krb5.kdc", "jtserver.jtlan.co.uk");
    // System.setProperty("java.security.krb5.conf",
    // "/home/turnerj/git/servlet-security-filter/KerberosSecurityFilter/src/main/resources/krb5.conf");

    // Form jaasOptions map
    Map<String, String> jaasOptions = new HashMap<String, String>();
    jaasOptions.put("useKeyTab", "false");
    jaasOptions.put("storeKey", "false");
    jaasOptions.put("doNotPrompt", "false");
    jaasOptions.put("refreshKrb5Config", "false");
    jaasOptions.put("clearPass", "true");
    jaasOptions.put("useTicketCache", "false");
    LOG.debug("Dynamic jaas configuration used:" + jaasOptions.toString());

    // Create dynamic jaas config
    DynamicJaasConfiguration contextConfig = new DynamicJaasConfiguration();
    contextConfig.addAppConfigEntry(
        loginModuleName,
        "com.sun.security.auth.module.Krb5LoginModule",
        AppConfigurationEntry.LoginModuleControlFlag.REQUIRED,
        jaasOptions);

    try {
      /*
       * Create login context using dynamic config
       * The "krb5UsernamePasswordLogin" needs to correspond to a configuration in the jaas config.
       */
      LoginContext loginCtx =
          new LoginContext(
              loginModuleName,
              null,
              new LoginUsernamePasswordHandler(clientPrincipal, password),
              contextConfig);
      loginCtx.login();
      Subject clientSubject = loginCtx.getSubject();
      String loggedInUser = principalNameFromSubject(clientSubject);
      LOG.info(
          "SUCCESSFUL LOGIN for user: "******" using username and password mechanism.");
      return clientSubject;
    } catch (LoginException le) {
      le.printStackTrace();
      // Failed logins are not an application error so the following line is at info level.
      LOG.info(
          "LOGIN FAILED for user: "******" using username and password mechanism. Reason: "
              + le.toString());
      return null;
    }
  }
  public void test() {
    String text =
        new StringBuilder()
            .append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
            .append(
                "<DescribeRegionsResponse xmlns=\"http://ec2.amazonaws.com/doc/2010-06-15/\"><requestId>0a5a6b4d-c0d7-4531-9ba9-bbc0b94d2007</requestId><regionInfo><item><regionName>is-1</regionName><regionEndpoint>api.greenqloud.com</regionEndpoint></item></regionInfo></DescribeRegionsResponse>\n")
            .toString();

    Map<String, URI> expected = expected();

    DescribeRegionsResponseHandler handler =
        injector.getInstance(DescribeRegionsResponseHandler.class);
    Map<String, URI> result = factory.create(handler).parse(text);

    assertEquals(result.toString(), expected.toString());
  }
Пример #23
0
 public final String toString() {
   if (l == null) {
     StringBuilder localStringBuilder = new StringBuilder();
     localStringBuilder.append("[");
     localStringBuilder.append(getClass().getSimpleName());
     localStringBuilder.append(": appBundleId=");
     localStringBuilder.append(a);
     localStringBuilder.append(", executionId=");
     localStringBuilder.append(b);
     localStringBuilder.append(", installationId=");
     localStringBuilder.append(c);
     localStringBuilder.append(", androidId=");
     localStringBuilder.append(d);
     localStringBuilder.append(", osVersion=");
     localStringBuilder.append(e);
     localStringBuilder.append(", deviceModel=");
     localStringBuilder.append(f);
     localStringBuilder.append(", appVersionCode=");
     localStringBuilder.append(g);
     localStringBuilder.append(", appVersionName=");
     localStringBuilder.append(h);
     localStringBuilder.append(", timestamp=");
     localStringBuilder.append(i);
     localStringBuilder.append(", type=");
     localStringBuilder.append(j);
     localStringBuilder.append(", details=");
     localStringBuilder.append(k.toString());
     localStringBuilder.append("]");
     l = localStringBuilder.toString();
   }
   return l;
 }
Пример #24
0
  @RequestNeedParam({"messageid"})
  @RequestMapping(
      value = "/detailMessage",
      method = {RequestMethod.POST})
  @ResponseBody
  public ResponseBean detailMessage(String request) {
    requestBean = gson.fromJson(request, RequestBean.class);
    // 进行校验
    if (requestBean.checkMac()) {
      LOG.info("校验成功....");
      // 真正的业务逻辑
      try {
        content = requestBean.getContent();
        Message message = gson.fromJson(content.toString(), Message.class);
        CommonUtils.decriptObject(
            message, requestBean.getHead().getImei(), requestBean.getHead().getImsi());
        message = messageService.detailAndSetreadMessage(message);
        responseBean.setContent(message);
      } catch (Exception e) {
        LOG.error("业务执行异常...." + e.getMessage());
        responseBean.getMsg().setCode("0001");
        responseBean.getMsg().setDesc(Constant.CODE_0001);
        return responseBean;
      }
      LOG.info("业务执行成功,设置返回报文状态为成功...");
      responseBean.getMsg().setCode("0000");
      responseBean.getMsg().setDesc(Constant.CODE_0000);
      responseBean.setMac(requestBean.getHead().getSerial());
    }

    return responseBean;
  }
  /**
   * Dynamic streaming play method.
   *
   * <p>The following properties are supported on the play options:
   *
   * <pre>
   * streamName: String. The name of the stream to play or the new stream to switch to.
   * oldStreamName: String. The name of the initial stream that needs to be switched out. This is not needed and ignored
   * when play2 is used for just playing the stream and not switching to a new stream.
   * start: Number. The start time of the new stream to play, just as supported by the existing play API. and it has the
   * same defaults. This is ignored when the method is called for switching (in other words, the transition
   * is either NetStreamPlayTransition.SWITCH or NetStreamPlayTransitions.SWAP)
   * len: Number. The duration of the playback, just as supported by the existing play API and has the same defaults.
   * transition: String. The transition mode for the playback command. It could be one of the following:
   * NetStreamPlayTransitions.RESET
   * NetStreamPlayTransitions.APPEND
   * NetStreamPlayTransitions.SWITCH
   * NetStreamPlayTransitions.SWAP
   * </pre>
   *
   * NetStreamPlayTransitions:
   *
   * <pre>
   * APPEND : String = "append" - Adds the stream to a playlist and begins playback with the first stream.
   * APPEND_AND_WAIT : String = "appendAndWait" - Builds a playlist without starting to play it from the first stream.
   * RESET : String = "reset" - Clears any previous play calls and plays the specified stream immediately.
   * RESUME : String = "resume" - Requests data from the new connection starting from the point at which the previous connection ended.
   * STOP : String = "stop" - Stops playing the streams in a playlist.
   * SWAP : String = "swap" - Replaces a content stream with a different content stream and maintains the rest of the playlist.
   * SWITCH : String = "switch" - Switches from playing one stream to another stream, typically with streams of the same content.
   * </pre>
   *
   * @see <a
   *     href="http://www.adobe.com/devnet/flashmediaserver/articles/dynstream_actionscript.html">ActionScript
   *     guide to dynamic streaming</a>
   * @see <a
   *     href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/NetStreamPlayTransitions.html">NetStreamPlayTransitions</a>
   */
  public void play2(int streamId, Map<String, ?> playOptions) {
    log.debug("play2 options: {}", playOptions.toString());
    /* { streamName=streams/new.flv,
       oldStreamName=streams/old.flv,
    start=0, len=-1,
    offset=12.195,
    transition=switch } */
    // get the transition type
    String transition = (String) playOptions.get("transition");
    if (conn != null) {
      if ("NetStreamPlayTransitions.STOP".equals(transition)) {
        PendingCall pendingCall = new PendingCall("play", new Object[] {Boolean.FALSE});
        conn.invoke(pendingCall, getChannelForStreamId(streamId));
      } else if ("NetStreamPlayTransitions.RESET".equals(transition)) {
        // just reset the currently playing stream

      } else {
        Object[] params = new Object[6];
        params[0] = playOptions.get("streamName").toString();
        Object o = playOptions.get("start");
        params[1] = o instanceof Integer ? (Integer) o : Integer.valueOf((String) o);
        o = playOptions.get("len");
        params[2] = o instanceof Integer ? (Integer) o : Integer.valueOf((String) o);
        // new parameters for playback
        params[3] = transition;
        params[4] = playOptions.get("offset");
        params[5] = playOptions.get("oldStreamName");
        // do call
        PendingCall pendingCall = new PendingCall("play2", params);
        conn.invoke(pendingCall, getChannelForStreamId(streamId));
      }
    } else {
      log.info("Connection was null ?");
    }
  }
Пример #26
0
 public static Map<String, String> getRecipesOptions(String requester, int page) {
   Map<String, String> options = new HashMap<>();
   options.put("sort", getSortByForRequesterFragment(requester));
   options.put("page", String.valueOf(page));
   Log.d("food2fork", "query - " + options.toString());
   return options;
 }
Пример #27
0
 /**
  * Set policy bundle.
  *
  * @param code - Operation code.
  */
 public void setPolicyBundle(String code) {
   try {
     resultBuilder.build(code, new JSONObject(bundleParams.toString()));
   } catch (JSONException e) {
     Log.e(TAG, "Invalid JSON format." + e);
   }
 }
Пример #28
0
 @Override
 public String toString() {
   StringBuilder result = new StringBuilder();
   String NEW_LINE = System.getProperty("line.separator");
   result.append(this.getClass().getName() + " Object {" + NEW_LINE);
   result.append(" consumerKey: " + _consumerKey + NEW_LINE);
   result.append(" consumerSecret: " + _consumerSecret + NEW_LINE);
   result.append(" signatureMethod: " + _signatureMethod + NEW_LINE);
   result.append(" transportName: " + _transportName + NEW_LINE);
   result.append(" id: " + id + NEW_LINE);
   result.append(" providerImplClass: " + providerImplClass + NEW_LINE);
   result.append(" customPermissions: " + customPermissions + NEW_LINE);
   result.append(" requestTokenUrl: " + requestTokenUrl + NEW_LINE);
   result.append(" authenticationUrl: " + authenticationUrl + NEW_LINE);
   result.append(" accessTokenUrl: " + accessTokenUrl + NEW_LINE);
   result.append(" registeredPlugins: " + registeredPlugins + NEW_LINE);
   result.append(" pluginsScopes: " + pluginsScopes + NEW_LINE);
   result.append(" saveRawResponse: " + saveRawResponse + NEW_LINE);
   if (customProperties != null) {
     result.append(" customProperties: " + customProperties.toString() + NEW_LINE);
   } else {
     result.append(" customProperties: null" + NEW_LINE);
   }
   result.append("}");
   return result.toString();
 }
Пример #29
0
 @RequestMapping(value = "PosterLoginServlet", produces = "application/json;charset=UTF-8")
 @ResponseBody
 public String PosterLogin(HttpServletRequest req) {
   String infor = req.getParameter("sendInfor");
   String postername = "";
   String password = "";
   System.out.println(infor);
   JSONObject json;
   try {
     json = new JSONObject(infor);
     postername = json.getString("postername");
     password = json.getString("password");
   } catch (JSONException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   Map<String, Object> posterinfo = new HashMap<String, Object>();
   posterinfo = us.PosterLogin(postername, password);
   if (posterinfo != null && !posterinfo.toString().equals("[]")) {
     JSONObject jsonres = new JSONObject(posterinfo);
     System.out.println(jsonres.toString());
     return encodeUTF_8.encodeStr(jsonres.toString());
   } else {
     return "Failed to Login!";
   }
 }
Пример #30
0
  @Override
  public String toString() {

    return "instance of MassPayItem class with the values: "
        + "nvpRequest: "
        + nvpRequest.toString();
  }