コード例 #1
0
ファイル: Index.java プロジェクト: sexybiggetje/aktie
  public CObj getIdentHasFile(String comid, String uid, String wdig, String pdig) {
    BooleanQuery bq = new BooleanQuery();
    Term typterm = new Term(CObj.PARAM_TYPE, CObj.HASFILE);
    bq.add(new TermQuery(typterm), BooleanClause.Occur.MUST);

    Term comterm = new Term(CObj.docString(CObj.COMMUNITYID), comid);
    bq.add(new TermQuery(comterm), BooleanClause.Occur.MUST);

    Term wdigterm = new Term(CObj.docString(CObj.FILEDIGEST), wdig);
    bq.add(new TermQuery(wdigterm), BooleanClause.Occur.MUST);

    Term pdigterm = new Term(CObj.docString(CObj.FRAGDIGEST), pdig);
    bq.add(new TermQuery(pdigterm), BooleanClause.Occur.MUST);

    Term cidterm = new Term(CObj.docString(CObj.CREATOR), uid);
    bq.add(new TermQuery(cidterm), BooleanClause.Occur.MUST);

    Term shterm = new Term(CObj.docString(CObj.STILLHASFILE), "true");
    bq.add(new TermQuery(shterm), BooleanClause.Occur.MUST);

    CObj r = null;
    CObjList cl = search(bq, Integer.MAX_VALUE);

    if (cl.size() > 0) {
      try {
        r = cl.get(0);
      } catch (IOException e) {
        e.printStackTrace();
      }
    }

    cl.close();
    return r;
  }
コード例 #2
0
ファイル: Index.java プロジェクト: sexybiggetje/aktie
  public CObj getSubscriptionUnsub(String comid, String memid) {
    BooleanQuery bq = new BooleanQuery();
    Term typterm = new Term(CObj.PARAM_TYPE, CObj.SUBSCRIPTION);
    bq.add(new TermQuery(typterm), BooleanClause.Occur.MUST);

    Term cidterm = new Term(CObj.docString(CObj.COMMUNITYID), comid);
    bq.add(new TermQuery(cidterm), BooleanClause.Occur.MUST);

    Term midterm = new Term(CObj.docString(CObj.CREATOR), memid);
    bq.add(new TermQuery(midterm), BooleanClause.Occur.MUST);

    CObj r = null;
    CObjList l = search(bq, 1);

    if (l.size() > 0) {
      try {
        r = l.get(0);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    l.close();
    return r;
  }
コード例 #3
0
ファイル: Index.java プロジェクト: sexybiggetje/aktie
  public CObjList searchFiles(String comid, String share, String qstr, Sort srt) {
    BooleanQuery query = new BooleanQuery();

    Term pstterm = new Term(CObj.PARAM_TYPE, CObj.FILE);
    query.add(new TermQuery(pstterm), BooleanClause.Occur.MUST);

    Term comterm = new Term(CObj.docString(CObj.COMMUNITYID), comid);
    query.add(new TermQuery(comterm), BooleanClause.Occur.MUST);

    NumericRangeQuery<Long> nq =
        NumericRangeQuery.newLongRange(
            CObj.docNumber(CObj.NUMBER_HAS), 0L, Long.MAX_VALUE, false, true);
    query.add(nq, BooleanClause.Occur.MUST);

    if (share != null) {
      Term shareterm = new Term(CObj.docString(CObj.SHARE_NAME), share);
      query.add(new TermQuery(shareterm), BooleanClause.Occur.MUST);
    }

    Matcher m = Pattern.compile("\\S+").matcher(qstr);

    if (m.find()) {
      StringBuilder sb = new StringBuilder();
      sb.append(CObj.docStringText(CObj.NAME));
      sb.append(":\"");
      sb.append(qstr);
      sb.append("\"");
      return search(query, sb.toString(), Integer.MAX_VALUE, srt);
    } else {
      return search(query, Integer.MAX_VALUE, srt);
    }
  }
コード例 #4
0
ファイル: Index.java プロジェクト: sexybiggetje/aktie
  public CObj getFragment(String comid, String wdig, String ddig, String dig) {
    BooleanQuery bq = new BooleanQuery();
    Term typterm = new Term(CObj.PARAM_TYPE, CObj.FRAGMENT);
    bq.add(new TermQuery(typterm), BooleanClause.Occur.MUST);

    Term ct = new Term(CObj.docString(CObj.COMMUNITYID), comid);
    bq.add(new TermQuery(ct), BooleanClause.Occur.MUST);

    Term wdt = new Term(CObj.docString(CObj.FILEDIGEST), wdig);
    bq.add(new TermQuery(wdt), BooleanClause.Occur.MUST);

    Term tddt = new Term(CObj.docString(CObj.FRAGDIGEST), ddig);
    bq.add(new TermQuery(tddt), BooleanClause.Occur.MUST);

    Term ddt = new Term(CObj.docString(CObj.FRAGDIG), dig);
    bq.add(new TermQuery(ddt), BooleanClause.Occur.MUST);

    Term shf = new Term(CObj.docPrivate(CObj.COMPLETE), "true");
    bq.add(new TermQuery(shf), BooleanClause.Occur.MUST);

    CObj r = null;
    CObjList cl = search(bq, Integer.MAX_VALUE);

    if (cl.size() > 0) {
      try {
        r = cl.get(0);
      } catch (IOException e) {
        e.printStackTrace();
      }
    }

    cl.close();
    return r;
  }
コード例 #5
0
ファイル: Index.java プロジェクト: sexybiggetje/aktie
  public CObjList getSubscriptions(String comid, Sort s) {
    BooleanQuery bq = new BooleanQuery();
    Term typterm = new Term(CObj.PARAM_TYPE, CObj.SUBSCRIPTION);
    bq.add(new TermQuery(typterm), BooleanClause.Occur.MUST);

    Term comterm = new Term(CObj.docString(CObj.COMMUNITYID), comid);
    bq.add(new TermQuery(comterm), BooleanClause.Occur.MUST);

    Term subterm = new Term(CObj.docString(CObj.SUBSCRIBED), "true");
    bq.add(new TermQuery(subterm), BooleanClause.Occur.MUST);

    return search(bq, Integer.MAX_VALUE, s);
  }
コード例 #6
0
ファイル: Index.java プロジェクト: sexybiggetje/aktie
  public CObjList getMemberSubscriptions(String memid) {
    BooleanQuery bq = new BooleanQuery();
    Term typterm = new Term(CObj.PARAM_TYPE, CObj.SUBSCRIPTION);
    bq.add(new TermQuery(typterm), BooleanClause.Occur.MUST);

    Term comterm = new Term(CObj.docString(CObj.CREATOR), memid);
    bq.add(new TermQuery(comterm), BooleanClause.Occur.MUST);

    Term subterm = new Term(CObj.docString(CObj.SUBSCRIBED), "true");
    bq.add(new TermQuery(subterm), BooleanClause.Occur.MUST);

    return search(bq, Integer.MAX_VALUE);
  }
コード例 #7
0
ファイル: Index.java プロジェクト: sexybiggetje/aktie
  public CObjList searchPosts(String comid, String qstr, Sort srt) {
    BooleanQuery query = new BooleanQuery();

    Term pstterm = new Term(CObj.PARAM_TYPE, CObj.POST);
    query.add(new TermQuery(pstterm), BooleanClause.Occur.MUST);

    Term comterm = new Term(CObj.docString(CObj.COMMUNITYID), comid);
    query.add(new TermQuery(comterm), BooleanClause.Occur.MUST);

    Matcher m = Pattern.compile("\\S+").matcher(qstr);

    if (m.find()) {
      StringBuilder sb = new StringBuilder();
      sb.append(CObj.docStringText(CObj.SUBJECT));
      sb.append(":\"");
      sb.append(qstr);
      sb.append("\" OR ");
      sb.append(CObj.docText(CObj.BODY));
      sb.append(":\"");
      sb.append(qstr);
      sb.append("\" OR ");
      sb.append(CObj.docStringText(CObj.NAME));
      sb.append(":\"");
      sb.append(qstr);
      sb.append("\"");
      return search(query, sb.toString(), Integer.MAX_VALUE, srt);
    } else {
      return search(query, Integer.MAX_VALUE, srt);
    }
  }
コード例 #8
0
ファイル: Index.java プロジェクト: sexybiggetje/aktie
  // Could be based on creator and sequence number, but
  // not enough to worry about.  Just send all.
  public CObjList getIdentityPrivateCommunities(String creator) {
    BooleanQuery bq = new BooleanQuery();
    Term typterm = new Term(CObj.PARAM_TYPE, CObj.COMMUNITY);
    bq.add(new TermQuery(typterm), BooleanClause.Occur.MUST);

    Term memterm = new Term(CObj.docString(CObj.CREATOR), creator);
    bq.add(new TermQuery(memterm), BooleanClause.Occur.MUST);

    Term scopeterm = new Term(CObj.docString(CObj.SCOPE), CObj.SCOPE_PRIVATE);
    bq.add(new TermQuery(scopeterm), BooleanClause.Occur.MUST);

    Term mineterm = new Term(CObj.docPrivate(CObj.MINE), "true");
    bq.add(new TermQuery(mineterm), BooleanClause.Occur.MUST);

    return search(bq, Integer.MAX_VALUE);
  }
コード例 #9
0
ファイル: Index.java プロジェクト: sexybiggetje/aktie
  public CObjList getFragments(String wdig, String pdig) {
    BooleanQuery bq = new BooleanQuery();
    Term typterm = new Term(CObj.PARAM_TYPE, CObj.FRAGMENT);
    bq.add(new TermQuery(typterm), BooleanClause.Occur.MUST);

    Term dig = new Term(CObj.docString(CObj.FILEDIGEST), wdig);
    bq.add(new TermQuery(dig), BooleanClause.Occur.MUST);

    Term ddig = new Term(CObj.docString(CObj.FRAGDIGEST), pdig);
    bq.add(new TermQuery(ddig), BooleanClause.Occur.MUST);

    SortField field = new SortField(CObj.docNumber(CObj.FRAGOFFSET), SortField.Type.LONG);
    Sort sort = new Sort(field);

    return search(bq, Integer.MAX_VALUE, sort);
  }
コード例 #10
0
ファイル: Index.java プロジェクト: sexybiggetje/aktie
  public CObjList getHasFiles(String comid, String memid, long first, long last) {
    BooleanQuery bq = new BooleanQuery();
    Term typterm = new Term(CObj.PARAM_TYPE, CObj.HASFILE);
    bq.add(new TermQuery(typterm), BooleanClause.Occur.MUST);

    Term comterm = new Term(CObj.docString(CObj.COMMUNITYID), comid);
    bq.add(new TermQuery(comterm), BooleanClause.Occur.MUST);

    Term memterm = new Term(CObj.docString(CObj.CREATOR), memid);
    bq.add(new TermQuery(memterm), BooleanClause.Occur.MUST);

    NumericRangeQuery<Long> nq =
        NumericRangeQuery.newLongRange(CObj.docNumber(CObj.SEQNUM), first, last, true, true);
    bq.add(nq, BooleanClause.Occur.MUST);

    return search(bq, Integer.MAX_VALUE);
  }
コード例 #11
0
ファイル: Index.java プロジェクト: sexybiggetje/aktie
  public CObjList getLocalHasFiles(String comid, String memid, String localfile) {
    BooleanQuery bq = new BooleanQuery();
    Term typterm = new Term(CObj.PARAM_TYPE, CObj.HASFILE);
    bq.add(new TermQuery(typterm), BooleanClause.Occur.MUST);

    Term comterm = new Term(CObj.docString(CObj.COMMUNITYID), comid);
    bq.add(new TermQuery(comterm), BooleanClause.Occur.MUST);

    Term memterm = new Term(CObj.docString(CObj.CREATOR), memid);
    bq.add(new TermQuery(memterm), BooleanClause.Occur.MUST);

    Term lfterm = new Term(CObj.docPrivate(CObj.LOCALFILE), localfile);
    bq.add(new TermQuery(lfterm), BooleanClause.Occur.MUST);

    Term shterm = new Term(CObj.docString(CObj.STILLHASFILE), "true");
    bq.add(new TermQuery(shterm), BooleanClause.Occur.MUST);

    return search(bq, Integer.MAX_VALUE);
  }
コード例 #12
0
ファイル: Index.java プロジェクト: sexybiggetje/aktie
  public CObjList getMyHasFiles(String wdig, String pdig) {
    BooleanQuery bq = new BooleanQuery();
    Term typterm = new Term(CObj.PARAM_TYPE, CObj.HASFILE);
    bq.add(new TermQuery(typterm), BooleanClause.Occur.MUST);

    Term wdigterm = new Term(CObj.docString(CObj.FILEDIGEST), wdig);
    bq.add(new TermQuery(wdigterm), BooleanClause.Occur.MUST);

    Term pdigterm = new Term(CObj.docString(CObj.FRAGDIGEST), pdig);
    bq.add(new TermQuery(pdigterm), BooleanClause.Occur.MUST);

    Term shterm = new Term(CObj.docString(CObj.STILLHASFILE), "true");
    bq.add(new TermQuery(shterm), BooleanClause.Occur.MUST);

    Term myterm = new Term(CObj.docPrivate(CObj.MINE), "true");
    bq.add(new TermQuery(myterm), BooleanClause.Occur.MUST);

    return search(bq, Integer.MAX_VALUE);
  }
コード例 #13
0
ファイル: Index.java プロジェクト: sexybiggetje/aktie
  public CObjList getFragments(String digs) {
    BooleanQuery bq = new BooleanQuery();
    Term typterm = new Term(CObj.PARAM_TYPE, CObj.FRAGMENT);
    bq.add(new TermQuery(typterm), BooleanClause.Occur.MUST);

    Term dig = new Term(CObj.docString(CObj.FRAGDIG), digs);
    bq.add(new TermQuery(dig), BooleanClause.Occur.MUST);

    return search(bq, Integer.MAX_VALUE);
  }
コード例 #14
0
ファイル: Index.java プロジェクト: sexybiggetje/aktie
  public CObjList getFragmentsToReset(String comid, String wdig, String fdig) {
    BooleanQuery bq = new BooleanQuery();
    Term typterm = new Term(CObj.PARAM_TYPE, CObj.FRAGMENT);
    bq.add(new TermQuery(typterm), BooleanClause.Occur.MUST);

    Term comterm = new Term(CObj.docString(CObj.COMMUNITYID), comid);
    bq.add(new TermQuery(comterm), BooleanClause.Occur.MUST);

    Term wterm = new Term(CObj.docString(CObj.FILEDIGEST), wdig);
    bq.add(new TermQuery(wterm), BooleanClause.Occur.MUST);

    Term fterm = new Term(CObj.docString(CObj.FRAGDIGEST), fdig);
    bq.add(new TermQuery(fterm), BooleanClause.Occur.MUST);

    Term cpltterm = new Term(CObj.docPrivate(CObj.COMPLETE), "req");
    bq.add(new TermQuery(cpltterm), BooleanClause.Occur.MUST);

    return search(bq, Integer.MAX_VALUE);
  }
コード例 #15
0
ファイル: Index.java プロジェクト: sexybiggetje/aktie
  public CObjList getPublicCommunities() {
    BooleanQuery bq = new BooleanQuery();
    Term typterm = new Term(CObj.PARAM_TYPE, CObj.COMMUNITY);
    bq.add(new TermQuery(typterm), BooleanClause.Occur.MUST);

    Term pubterm = new Term(CObj.docString(CObj.SCOPE), CObj.SCOPE_PUBLIC);
    bq.add(new TermQuery(pubterm), BooleanClause.Occur.MUST);

    return search(bq, Integer.MAX_VALUE);
  }
コード例 #16
0
ファイル: Index.java プロジェクト: sexybiggetje/aktie
  public CObjList getMySubscriptions() {
    BooleanQuery bq = new BooleanQuery();
    Term typterm = new Term(CObj.PARAM_TYPE, CObj.SUBSCRIPTION);
    bq.add(new TermQuery(typterm), BooleanClause.Occur.MUST);

    Term subterm = new Term(CObj.docString(CObj.SUBSCRIBED), "true");
    bq.add(new TermQuery(subterm), BooleanClause.Occur.MUST);

    Term mustterm = new Term(CObj.docPrivate(CObj.MINE), "true");
    bq.add(new TermQuery(mustterm), BooleanClause.Occur.MUST);

    return search(bq, Integer.MAX_VALUE);
  }
コード例 #17
0
ファイル: Index.java プロジェクト: sexybiggetje/aktie
  public CObjList getMyMemberships(Sort s) {
    BooleanQuery bq = new BooleanQuery();
    Term typterm = new Term(CObj.PARAM_TYPE, CObj.COMMUNITY);
    bq.add(new TermQuery(typterm), BooleanClause.Occur.MUST);

    Term mineterm = new Term(CObj.docPrivate(CObj.MINE), "true");
    bq.add(new TermQuery(mineterm), BooleanClause.Occur.MUST);

    Term privterm = new Term(CObj.docString(CObj.SCOPE), CObj.SCOPE_PRIVATE);
    bq.add(new TermQuery(privterm), BooleanClause.Occur.MUST);

    return search(bq, Integer.MAX_VALUE, s);
  }
コード例 #18
0
ファイル: Index.java プロジェクト: sexybiggetje/aktie
  // Could be based on creator and sequence number, but
  // not enough to worry about.  Just send all.
  public CObjList getCommunities(String creator, long first, long last) {
    BooleanQuery bq = new BooleanQuery();
    Term typterm = new Term(CObj.PARAM_TYPE, CObj.COMMUNITY);
    bq.add(new TermQuery(typterm), BooleanClause.Occur.MUST);

    Term memterm = new Term(CObj.docString(CObj.CREATOR), creator);
    bq.add(new TermQuery(memterm), BooleanClause.Occur.MUST);

    NumericRangeQuery<Long> nq =
        NumericRangeQuery.newLongRange(CObj.docNumber(CObj.SEQNUM), first, last, true, true);
    bq.add(nq, BooleanClause.Occur.MUST);

    return search(bq, Integer.MAX_VALUE);
  }
コード例 #19
0
ファイル: Index.java プロジェクト: sexybiggetje/aktie
  public CObjList searchSemiPrivateCommunities(String squery, Sort s) {
    BooleanQuery bq = new BooleanQuery();
    Term typterm = new Term(CObj.PARAM_TYPE, CObj.COMMUNITY);
    bq.add(new TermQuery(typterm), BooleanClause.Occur.MUST);

    Term mineterm = new Term(CObj.docPrivate(CObj.MINE), "false");
    bq.add(new TermQuery(mineterm), BooleanClause.Occur.MUST);

    Term privterm = new Term(CObj.docString(CObj.SCOPE), CObj.SCOPE_PRIVATE);
    bq.add(new TermQuery(privterm), BooleanClause.Occur.MUST);

    Term pnterm = new Term(CObj.docString(CObj.NAME_IS_PUBLIC), "true");
    bq.add(new TermQuery(pnterm), BooleanClause.Occur.MUST);

    if (squery != null) {
      Matcher m = Pattern.compile("\\S+").matcher(squery);

      if (m.find()) {
        StringBuilder sb = new StringBuilder();
        sb.append(CObj.docStringText(CObj.NAME));
        sb.append(":\"");
        sb.append(squery);
        sb.append("\" OR ");
        sb.append(CObj.docStringText(CObj.DESCRIPTION));
        sb.append(":\"");
        sb.append(squery);
        sb.append("\" OR ");
        sb.append(CObj.docStringText(CObj.CREATOR_NAME));
        sb.append(":\"");
        sb.append(squery);
        sb.append("\"");
        return search(bq, sb.toString(), Integer.MAX_VALUE);
      }
    }

    return search(bq, Integer.MAX_VALUE, s);
  }
コード例 #20
0
ファイル: Index.java プロジェクト: sexybiggetje/aktie
  public CObjList searchSubscribable(
      String squery, String memid, boolean prv, boolean pub, Sort s) {
    if (!prv && !pub) {
      prv = true;
      pub = true;
    }

    BooleanQuery combined = new BooleanQuery();
    combined.setMinimumNumberShouldMatch(1);

    Term comterm = new Term(CObj.PARAM_TYPE, CObj.COMMUNITY);
    combined.add(new TermQuery(comterm), BooleanClause.Occur.MUST);

    if (pub) {

      Term pubterm = new Term(CObj.docString(CObj.SCOPE), CObj.SCOPE_PUBLIC);
      combined.add(new TermQuery(pubterm), BooleanClause.Occur.SHOULD);
    }

    if (prv && memid != null) {

      Term pubterm2 = new Term(CObj.docPrivate(memid), "true");
      combined.add(new TermQuery(pubterm2), BooleanClause.Occur.SHOULD);
    }

    if (squery != null) {
      Matcher m = Pattern.compile("\\S+").matcher(squery);

      if (m.find()) {
        StringBuilder sb = new StringBuilder();
        sb.append(CObj.docPrivateText(CObj.NAME));
        sb.append(":\"");
        sb.append(squery);
        sb.append("\" OR ");
        sb.append(CObj.docPrivateText(CObj.DESCRIPTION));
        sb.append(":\"");
        sb.append(squery);
        sb.append("\"");
        return search(combined, sb.toString(), Integer.MAX_VALUE, s);
      }
    }

    return search(combined, Integer.MAX_VALUE, s);
  }