Package com.esri.gpt.catalog.lucene

Examples of com.esri.gpt.catalog.lucene.LuceneIndexAdapter


      throws CorruptIndexException, IOException {
    if (this.searcher != null) {
      return this.searcher;
    } else {
      if (this.baseAdapter == null) {
        this.baseAdapter = new LuceneIndexAdapter(context);
      }
      this.searcher = this.baseAdapter.newSearcher();
      return this.searcher;
    }
  }
View Full Code Here


    throws CorruptIndexException, IOException {
    if (this.searcher != null) {
      return this.searcher;
    } else {
      if (this.baseAdapter == null) {
        this.baseAdapter = new LuceneIndexAdapter(context.getRequestContext());
      }
      this.searcher = this.baseAdapter.newSearcher();
      return this.searcher;
    }
  }
View Full Code Here

    AuthenticationStatus auth = rContext.getUser().getAuthenticationStatus();
    boolean bAdmin = auth.getAuthenticatedRoles().hasRole("gptAdministrator");
    if (!bAdmin) {     
      MetadataAcl acl = new MetadataAcl(rContext);
      if (!acl.isPolicyUnrestricted()) {
        LuceneIndexAdapter adapter = new LuceneIndexAdapter(rContext);
        String[] resourceAcls = adapter.queryAcls(resourceId);
        if ((resourceAcls != null) && (resourceAcls.length > 0)) {
         
          String[] userAcls = acl.makeUserAcl();
          if ((userAcls != null) && (userAcls.length > 0)) {
            for (String resourcePrincipal: resourceAcls) {
              for (String userPrincipal: userAcls) {
                if (resourcePrincipal.equalsIgnoreCase(userPrincipal)) {
                  return;
                }
              }
            }
          }
          throw new AsnInsufficientPrivilegeException();
         
        }
      }
    }
   
    // ensure the existence of a local resource id
    if (!context.getOperation().getAuthPolicy().getAllowNonLocalResourceIds()) {
      LuceneIndexAdapter adapter = new LuceneIndexAdapter(rContext);
      Timestamp ts = adapter.queryModifiedDate(resourceId);
      if (ts == null) {
        throw new CatalogIndexException("Invalid resource id: "+resourceId);
      }
    }
     
View Full Code Here

  protected void loadLuceneMeta(RequestContext context, List<IFeedRecords.FieldMeta> fields) throws CatalogIndexException {
    if (!isLuceneMetaAllowed()) {
      return;
    }

    LuceneIndexAdapter indexAdapter = new LuceneIndexAdapter(context);
    IndexSearcher searcher = null;
    try {
      searcher = indexAdapter.newSearcher();
      IndexReader indexReader = searcher.getIndexReader();
      for (String fieldName : indexReader.getFieldNames(IndexReader.FieldOption.ALL)) {
        fields.add(new IFeedRecords.FieldMeta(IFeedRecord.STD_COLLECTION_INDEX + "." + fieldName, "esriFieldTypeString", fieldName));
      }
    } catch (Exception e) {
      String sMsg = "Error accessing index:\n " + Val.chkStr(e.getMessage());
      throw new CatalogIndexException(sMsg, e);
    } finally {
      indexAdapter.closeSearcher(searcher);
    }
  }
View Full Code Here

   * @return the analyzer
   */
  public Analyzer newAnalyzer(AsnContext context) {
    RequestContext rc = null;
    try {
      LuceneIndexAdapter adapter = null;
      if ((context != null) && (context.getRequestContext() != null)) {
        adapter = new LuceneIndexAdapter(context.getRequestContext());
      } else {
        rc = RequestContext.extract(null);
        adapter = new LuceneIndexAdapter(rc);
      }
      return adapter.newAnalyzer();
    } finally {
      if (rc != null) rc.getConnectionBroker().closeAll();
    }
  }
View Full Code Here

    } else {
      response.setContentType("text/plain");
    }
   
    PrintWriter writer = response.getWriter();
    LuceneIndexAdapter adapter = null;
    IndexSearcher searcher = null;
    try {
      String field = this.getParameterValue(request,"field");
      String term = this.getParameterValue(request,"term");
      String sortBy = this.getParameterValue(request,"sortBy");
      String pathInfo = "";
      if (request.getPathInfo() != null) {
        pathInfo = Val.chkStr(request.getPathInfo().toLowerCase());
        if (pathInfo.startsWith("/")) pathInfo = pathInfo.substring(1);
        if (pathInfo.endsWith("/")) pathInfo = pathInfo.substring(0,(pathInfo.length() - 1));
        //System.err.println(pathInfo);
      }
     
      adapter = new LuceneIndexAdapter(context);  
      searcher = adapter.newSearcher();
      IndexReader reader = searcher.getIndexReader();
      StatsRequest statsRequest = new StatsRequest(context);
      statsRequest.setResponseWriter(writer);
      statsRequest.prepare(reader);
      statsRequest.setSortBy(sortBy);
      statsRequest.setResponseFormat(responseFormat);
     
      if (field.length() > 0) {
        int maxRecs = Val.chkInt(this.getParameterValue(request,"max"),-2);
        if (maxRecs == -2) {
          maxRecs = Val.chkInt(this.getParameterValue(request,"maxrecords"),-1);
        }
        int minFreq = Val.chkInt(this.getParameterValue(request,"minFrequency"),-1);
        int maxFreq = Val.chkInt(this.getParameterValue(request,"maxFrequency"),-1);
        SingleFieldStats stats = new SingleFieldStats(field,maxRecs,minFreq,maxFreq);
        stats.collectStats(statsRequest,reader);
//      } else if (term.length() > 0) {
//        SingleTermStats stats = new SingleTermStats(term);
//        stats.collectStats(statsRequest,reader);  
//      } else if (pathInfo.equals("terms")){
//        GlobalTermStats stats = new GlobalTermStats();
//        stats.collectStats(statsRequest,reader); 
      } else {
        //GlobalFieldStats stats = new GlobalFieldStats();
        SummaryStats stats = new SummaryStats();
        stats.collectStats(statsRequest,reader)
      }
   
   // } catch (Exception ex) {

    //  response.setContentType("text/plain;charset=UTF-8");
     // writer.println("Error getting metadata: " + ex.getMessage());
     // LogUtil.getLogger().log(Level.SEVERE, "Error getting metadata", ex);

    } finally {
      try {
        writer.flush();
      } catch (Exception ef) {};
      try {
        if ((adapter != null) && (searcher != null)) {
          adapter.closeSearcher(searcher);
        }
      } catch (Exception ef) {};
    }
   
  }
View Full Code Here

      }
     
      // obtain the background thread lock,
      // sleep for 10 minutes if busy then try again
      rContext = RequestContext.extract(null);
      LuceneIndexAdapter adapter = new LuceneIndexAdapter(rContext);
      adapter.touch(); // ensures that a proper directory structure exists
      try {
        backgroundLock = adapter.obtainBackgroundLock();
      } catch (LockObtainFailedException lofe) {
        if (Thread.currentThread().isInterrupted()) return;
        try {
          Thread.sleep(10 * 1000);
        } catch (InterruptedException e) {
          throw new IOException(e.toString());
        }
        if (Thread.currentThread().isInterrupted()) return;
        backgroundLock = adapter.obtainBackgroundLock();
      }
      if (Thread.currentThread().isInterrupted()) return;
     
      // process services on the ArcGIS server
      StringBuilder sbSummary = new StringBuilder();
View Full Code Here

TOP

Related Classes of com.esri.gpt.catalog.lucene.LuceneIndexAdapter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.