コード例 #1
0
ファイル: PageImpl.java プロジェクト: flaviooo/rockframework
 public PageImpl(final int pageNumber, final int resultsPerPage) {
   super();
   Assert.greaterThan(pageNumber, 0, "pageNumber");
   Assert.greaterThan(resultsPerPage, 0, "resultsPerPage");
   this.pageNumber = pageNumber;
   this.resultsPerPage = resultsPerPage;
 }
コード例 #2
0
  public Collection<LDAPSearchResult> search(final LDAPFilter filter) {
    Assert.notNull(filter, "filter");
    try {
      if ((this.connectOnSearch) && (!this.isConnected())) {
        this.connect();
      }
      Assert.notNull(this.context, "context");
      SearchControls controls = new SearchControls();
      controls.setReturningAttributes(filter.getAttributes());
      controls.setCountLimit(filter.getLimit());
      controls.setTimeLimit(0);
      controls.setSearchScope(SearchControls.SUBTREE_SCOPE);

      NamingEnumeration<SearchResult> results =
          this.context.search(filter.getBaseName(), filter.getFilter(), controls);

      Collection<LDAPSearchResult> c = LDAPHelper.toCollection(results);

      if (this.connectOnSearch) {
        this.disconnect();
      }

      return c;
    } catch (NamingException e) {
      throw new LDAPException(e);
    }
  }
コード例 #3
0
ファイル: IOUtils.java プロジェクト: flaviooo/rockframework
  public static String toString(final Reader reader, final Charset charset) throws IOException {
    Assert.notNull(reader, "reader");
    Assert.notNull(charset, "charset");
    byte[] bytes = IOUtils.toByteArray(reader);

    String s = new String(bytes, charset);

    return s;
  }
コード例 #4
0
ファイル: IOUtils.java プロジェクト: flaviooo/rockframework
  public static String toString(final InputStream inputStream, final Charset charset)
      throws IOException {
    Assert.notNull(inputStream, "inputStream");
    Assert.notNull(charset, "charset");
    byte[] bytes = IOUtils.toByteArray(inputStream);

    String s = new String(bytes, charset);

    return s;
  }
コード例 #5
0
ファイル: IOUtils.java プロジェクト: flaviooo/rockframework
  public static void copy(final Reader reader, final Writer writer) throws IOException {
    Assert.notNull(reader, "reader");
    Assert.notNull(writer, "writer");

    int i = 0;
    char[] chars = new char[IOUtils.BUFFER_SIZE];
    do {
      i = reader.read(chars);
      if (i != -1) {
        writer.write(chars, 0, i);
      }
    } while (i != -1);
  }
コード例 #6
0
ファイル: IOUtils.java プロジェクト: flaviooo/rockframework
  public static void copy(final InputStream inputStream, final OutputStream outputStream)
      throws IOException {
    Assert.notNull(inputStream, "inputStream");
    Assert.notNull(outputStream, "outputStream");

    int i = 0;
    byte[] bytes = new byte[IOUtils.BUFFER_SIZE];
    do {
      i = inputStream.read(bytes);
      if (i != -1) {
        outputStream.write(bytes, 0, i);
      }
    } while (i != -1);
  }
コード例 #7
0
ファイル: IOUtils.java プロジェクト: flaviooo/rockframework
 public static InputStream gunzip(final InputStream inputStream) throws IOException {
   Assert.notNull(inputStream, "inputStream");
   GZIPInputStream gzipInputStream = new GZIPInputStream(inputStream);
   InputOutputStream inputOutputStream = new InputOutputStream();
   IOUtils.copy(gzipInputStream, inputOutputStream);
   return inputOutputStream.getInputStream();
 }
コード例 #8
0
ファイル: IOUtils.java プロジェクト: flaviooo/rockframework
  public static byte[] toByteArray(final InputStream inputStream) throws IOException {
    Assert.notNull(inputStream, "inputStream");

    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

    IOUtils.copy(inputStream, outputStream);

    return outputStream.toByteArray();
  }
コード例 #9
0
ファイル: IOUtils.java プロジェクト: flaviooo/rockframework
  public static byte[] toByteArray(final Reader reader) throws IOException {
    Assert.notNull(reader, "reader");

    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    Writer writer = new OutputStreamWriter(outputStream);

    IOUtils.copy(reader, writer);

    return outputStream.toByteArray();
  }
コード例 #10
0
 @Override
 public Cache get(final String id) {
   Assert.notEmpty(id, "id");
   for (Cache cache : this.caches) {
     if (((MemoryCacheImpl) cache).getId().equals(id)) {
       return cache;
     }
   }
   return null;
 }
コード例 #11
0
 @Override
 public Cache create(final String id) {
   Assert.notEmpty(id, "id");
   if (this.contains(id)) {
     throw new IllegalArgumentException("A cache with name " + id + " already exists");
   }
   Cache c = new MemoryCacheImpl(id);
   this.caches.add(c);
   return c;
 }
コード例 #12
0
ファイル: IOUtils.java プロジェクト: flaviooo/rockframework
  public static byte[] toByteArray(final File file) throws IOException {
    Assert.notNull(file, "file");

    FileInputStream inputStream = new FileInputStream(file);
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

    IOUtils.copy(inputStream, outputStream);

    inputStream.close();

    return outputStream.toByteArray();
  }
コード例 #13
0
 @Override
 public void remove(final String id) {
   Assert.notEmpty(id, "id");
   Iterator<Cache> iterator = this.caches.iterator();
   while (iterator.hasNext()) {
     Cache cache = iterator.next();
     if (((MemoryCacheImpl) cache).getId().equals(id)) {
       iterator.remove();
       break;
     }
   }
 }
コード例 #14
0
 @Override
 public boolean contains(final String id) {
   Assert.notEmpty(id, "id");
   boolean b = false;
   for (Cache cache : this.caches) {
     if (((MemoryCacheImpl) cache).getId().equals(id)) {
       b = true;
       break;
     }
   }
   return b;
 }
コード例 #15
0
ファイル: IOUtils.java プロジェクト: flaviooo/rockframework
 public static InputStream gunzip(final byte[] bytes) throws IOException {
   Assert.notNull(bytes, "bytes");
   return IOUtils.gunzip(new ByteArrayInputStream(bytes));
 }
コード例 #16
0
ファイル: IOUtils.java プロジェクト: flaviooo/rockframework
  public static Reader toReader(final InputStream inputStream) {
    Assert.notNull(inputStream, "inputStream");

    return new InputStreamReader(inputStream);
  }