Ejemplo n.º 1
0
 public FileInfo getFileInfo(String uriString)
     throws SearchLibException, UnsupportedEncodingException, URISyntaxException {
   AbstractSearchRequest searchRequest =
       (AbstractSearchRequest) dbClient.getNewRequest(SearchTemplate.fileInfo.name());
   StringBuilder sb = new StringBuilder();
   FileItemFieldEnum.INSTANCE.uri.addQuery(sb, uriString, true);
   searchRequest.setQueryString(sb.toString());
   searchRequest.setStart(0);
   searchRequest.setRows(1);
   AbstractResultSearch<?> result = (AbstractResultSearch<?>) dbClient.request(searchRequest);
   if (result.getNumFound() == 0) return null;
   return new FileInfo(result.getDocument(0));
 }
Ejemplo n.º 2
0
 public void getFileInfoList(URI parentDirectory, Map<String, FileInfo> indexFileMap)
     throws SearchLibException, UnsupportedEncodingException, URISyntaxException {
   AbstractSearchRequest searchRequest =
       (AbstractSearchRequest) dbClient.getNewRequest(SearchTemplate.fileInfo.name());
   StringBuilder sb = new StringBuilder();
   String parentUriString = parentDirectory.toASCIIString();
   FileItemFieldEnum.INSTANCE.directory.addQuery(sb, parentUriString, true);
   searchRequest.setQueryString(sb.toString());
   searchRequest.setStart(0);
   searchRequest.setRows(Integer.MAX_VALUE);
   AbstractResultSearch<?> result = (AbstractResultSearch<?>) dbClient.request(searchRequest);
   int l = result.getNumFound();
   for (int i = 0; i < l; i++) {
     FileInfo fileInfo = new FileInfo(result.getDocument(i));
     indexFileMap.put(fileInfo.getUri(), fileInfo);
   }
 }
Ejemplo n.º 3
0
 public long getFileList(
     AbstractSearchRequest searchRequest, long start, long rows, List<FileItem> list)
     throws SearchLibException {
   searchRequest.reset();
   searchRequest.setStart((int) start);
   searchRequest.setRows((int) rows);
   try {
     AbstractResultSearch<?> result = (AbstractResultSearch<?>) dbClient.request(searchRequest);
     if (list != null) for (ResultDocument doc : result) list.add(getNewFileItem(doc));
     return result.getNumFound();
   } catch (RuntimeException e) {
     throw new SearchLibException(e);
   } catch (UnsupportedEncodingException e) {
     throw new SearchLibException(e);
   } catch (URISyntaxException e) {
     throw new SearchLibException(e);
   }
 }
Ejemplo n.º 4
0
  public long getFiles(
      AbstractSearchRequest searchRequest,
      ItemField orderBy,
      boolean orderAsc,
      long start,
      long rows,
      List<FileItem> list)
      throws SearchLibException {
    searchRequest.setStart((int) start);
    searchRequest.setRows((int) rows);
    try {
      if (orderBy != null) orderBy.addSort(searchRequest, !orderAsc);
      AbstractResultSearch<?> result = (AbstractResultSearch<?>) dbClient.request(searchRequest);
      if (list != null) for (ResultDocument doc : result) list.add(getNewFileItem(doc));
      return result.getNumFound();

    } catch (IOException e) {
      throw new SearchLibException(e);
    } catch (RuntimeException e) {
      throw new SearchLibException(e);
    } catch (URISyntaxException e) {
      throw new SearchLibException(e);
    }
  }