Package com.esri.gpt.framework.collection

Examples of com.esri.gpt.framework.collection.StringAttributeMap


      // initialize
      int numDeleted = 0;
      int numUpdated = 0;
      this.context = RequestContext.extract(null);
      this.startMillis = System.currentTimeMillis();
      StringAttributeMap catParams = this.context.getCatalogConfiguration().getParameters();
     
      // initialize index
      this.context.getObjectMap().put("lucene.useRemoteWriter",false);
      this.adapter = new LuceneIndexAdapter(context);
      if (this.adapter == null) {
        LOGGER.severe("A valid CatalogIndexAdapter cound not be initialized.");
      }
      this.adapter.touch(); // ensures that a proper directory structure exists
      if (this.checkInterrupted()) return;
      if (!this.adapter.getUsingSingleWriter()) {
        backgroundLock = this.adapter.obtainBackgroundLock();
      }
      this.searcher = this.adapter.newSearcher();
      this.reader = this.searcher.getIndexReader();
      if (this.checkInterrupted()) return;
     
      if (this.adapter.getUsingSingleWriter()) {
        this.writer = this.adapter.newWriter();
        this.adapter.setAutoCommitSingleWriter(false);
      }
     
      // initialize database
      ManagedConnection mc = this.context.getConnectionBroker().returnConnection("");
      this.con = mc.getJdbcConnection();
      this.mutator = mc.getClobMutator();
      this.resourceTable =  this.context.getCatalogConfiguration().getResourceTableName();
      this.resourceDataTable =  this.context.getCatalogConfiguration().getResourceDataTableName();
     
      // count current documents within the index and database
      CountInfo countInfo = new CountInfo();
      countInfo.numIndexedDocs = this.reader.numDocs();
      this.countDatabaseDocs(countInfo);
      if (this.checkInterrupted()) return;
      this.countIndexableDocs(countInfo);
      if (this.checkInterrupted()) return;
     
      // purge the index if required
      if (countInfo.numIndexableDocs == 0) {
        if (countInfo.numIndexedDocs > 0) {
          String p = Val.chkStr(catParams.getValue(
              "lucene.synchronizer.allowFullIndexPurge"));
          boolean bAllowFullIndexPurge = p.equalsIgnoreCase("true");
          if (bAllowFullIndexPurge) {
            numDeleted = countInfo.numIndexedDocs;
            this.closeAll();
View Full Code Here


}
 
private int getMaxAttempts() {
  ApplicationContext appCtx = ApplicationContext.getInstance();
  ApplicationConfiguration appCfg = appCtx.getConfiguration();
  StringAttributeMap parameters = appCfg.getCatalogConfiguration().getParameters();
  return Val.chkInt(parameters.getValue("webharvester.maxAttempts"),DEFAULT_MAX_ATTEMPTS);
}
View Full Code Here

   */
  private void initialize(HttpServletRequest request, RequestContext context) {

    String sTmp;
    int nTmp = 0;
    StringAttributeMap params = context.getCatalogConfiguration().getParameters();
   
    Enumeration<String> paramNames = request.getParameterNames();
    if (paramNames != null) {
      while (paramNames.hasMoreElements()) {
        String paramName = Val.chkStr(paramNames.nextElement());
        if (paramName.equalsIgnoreCase("start")) {
          this.hadStart = true;
        } else if (paramName.equalsIgnoreCase("max")) {
          this.hadMax = true;
        } else if (paramName.equalsIgnoreCase("f")) {
          sTmp = Val.chkStr(this.request.getParameter(paramName));
          if (sTmp.toLowerCase().startsWith("sitemap.")) {
            this.subFormat = Val.chkStr(sTmp.substring(8));
          }
        }
      }
    }
   
    String baseContextPath = RequestContext.resolveBaseContextPath(request);
    this.baseUrl = baseContextPath;
   
    sTmp = Val.chkStr(params.getValue("sitemap.baseUrl"));
    if (sTmp.length() > 0) {
      this.baseUrl = sTmp;
    } else {
      this.baseUrl += "/sitemap";
    }
    if (this.baseUrl.endsWith("&")) {
      this.baseUrl = this.baseUrl.substring(0,this.baseUrl.length() - 1);
    }
    if (this.baseUrl.endsWith("?")) {
      this.baseUrl = this.baseUrl.substring(0,this.baseUrl.length() - 1);
    }
   
    if ((this.subFormat != null) && (this.subFormat.length() > 0)) {
      sTmp = Val.chkStr(params.getValue("sitemap.documentUrlPattern."+this.subFormat));
      if (sTmp.length() == 0) {
        sTmp = Val.chkStr(params.getValue("sitemap.documentUrlPattern"));
      }
    } else {
      sTmp = Val.chkStr(params.getValue("sitemap.documentUrlPattern"));
    }
    if (sTmp.length() > 0) this.documentUrlPattern = sTmp;
    if (!this.documentUrlPattern.startsWith("http")) {
      if (!this.documentUrlPattern.startsWith("/")) {
        this.documentUrlPattern = "/"+this.documentUrlPattern;
      }
      this.documentUrlPattern = baseContextPath+this.documentUrlPattern;
    }
   
    nTmp = Val.chkInt(params.getValue("sitemap.urlsPerIndexFile"),0);
    if ((nTmp > 0) && (nTmp < 1000)) this.urlsPerIndexFile = nTmp;
   
    nTmp = Val.chkInt(params.getValue("sitemap.urlsPerSitemapFile"),0);
    if ((nTmp > 0) && (nTmp <= 50000)) this.urlsPerSitemapFile = nTmp;
    if (!this.hadStart && !this.hadMax) {
      this.query.getFilter().setMaxRecords(this.urlsPerSitemapFile);
    }
   
    sTmp = Val.chkStr(params.getValue("sitemap.namespaceUri"));
    if (sTmp.length() > 0) this.namespaceUri = sTmp;
   
    sTmp = Val.chkStr(params.getValue("sitemap.changefreq"));
    if (sTmp.length() > 0) this.changefreq = sTmp;
   
    sTmp = Val.chkStr(params.getValue("sitemap.priority"));
    if (sTmp.length() > 0) this.priority = sTmp;
   
    // error check
    String errPfx = "gpt.xml: gptConfig/catalog/parameter/";
    if (this.documentUrlPattern.indexOf("{0}") == -1) {
View Full Code Here

    // establish the connection
    ManagedConnection mc = returnConnection();
    Connection con = mc.getJdbcConnection();
   
    // determine if the database is case sensitive
    StringAttributeMap params = getRequestContext().getCatalogConfiguration().getParameters();
    String s = Val.chkStr(params.getValue("database.isCaseSensitive"));
    boolean isDbCaseSensitive = !s.equalsIgnoreCase("false");
   
    s = Val.chkStr(params.getValue("catalog.enableEditForAllPubMethods"));
    this.enableEditForAllPubMethods = s.equalsIgnoreCase("true");
   
    // determine if collections are being used
    List<String[]> collections = null;
    CollectionDao colDao = new CollectionDao(getRequestContext());
View Full Code Here

  /**
   * Gets source.
   * @return source
   */
  public AgpSource getSource() {
    StringAttributeMap attrs = getAttributeMap();

    AgpSource source = new AgpSource();
    AgpConnection con1 = new AgpConnection();
    HostContextPair pair = HostContextPair.makeHostContextPair(getSourceHost());
    con1.setHost(pair.getHost());
    con1.setWebContext(pair.getContext());
    con1.setTokenCriteria(new AgpTokenCriteria());
    con1.getTokenCriteria().setCredentials(new AgpCredentials(
            attrs.getValue("src-u"), attrs.getValue("src-p")));
    con1.getTokenCriteria().setReferer(getReferrer());
    source.setConnection(con1);
    AgpSearchCriteria searchCriteria = new AgpSearchCriteria();
    searchCriteria.setSortField("title");
    searchCriteria.setQ(attrs.getValue("src-q"));
    searchCriteria.setDeepTotal(Long.valueOf(attrs.getValue("src-m")));
    source.setSearchCriteria(searchCriteria);

    return source;
  }
View Full Code Here

  /**
   * Gets destination.
   * @return destination
   */
  public AgpDestination getDestination() {
    StringAttributeMap attrs = getAttributeMap();
   
    AgpDestination destination = new AgpDestination();
    AgpConnection con2 = new AgpConnection();
    HostContextPair pair = HostContextPair.makeHostContextPair(getDestinationHost());
    con2.setHost(pair.getHost());
    con2.setWebContext(pair.getContext());
    con2.setTokenCriteria(new AgpTokenCriteria());
    con2.getTokenCriteria().setCredentials(new AgpCredentials(
            attrs.getValue("dest-u"), attrs.getValue("dest-p")));
    con2.getTokenCriteria().setReferer(getReferrer());
    destination.setConnection(con2);
    destination.setDestinationOwner(attrs.getValue("dest-o"));
    destination.setDestinationFolderID(attrs.getValue("dest-f"));

    return destination;
  }
View Full Code Here

            ""+isRunning,"UTF-8","text/plain; charset=UTF-8");
        return;
      }
     
      context.getObjectMap().put("lucene.useRemoteWriter",false);
      StringAttributeMap params = context.getCatalogConfiguration().getParameters();
      String param = Val.chkStr(params.getValue("lucene.useSingleSearcher"));
      boolean useSingleWriter = param.equalsIgnoreCase("true");
      param = Val.chkStr(params.getValue("lucene.useLocalWriter"));
      boolean bUseLocalWriter = !param.equalsIgnoreCase("false");
     
      param = Val.chkStr(params.getValue("lucene.useRemoteWriter"));
      boolean useRemoteWriter = param.equalsIgnoreCase("true");
      String remoteWriterUrl = Val.chkStr(params.getValue("lucene.remoteWriterUrl"));

      boolean bOk = true;
      if (!useSingleWriter || !bUseLocalWriter) {
        bOk = false;
        String s = "Inconsistent configuration parameters,"+
          " lucene.useSingleWriter lucene.useLocalWriter";
        LOGGER.severe(s);
        response.sendError(500,"Inconsistent configuration parameters on server.");
      }
     
      if (bOk) {
        String sIds = Val.chkStr(request.getParameter("ids"));
        String[] ids = sIds.split(",");
       
        if (action.equalsIgnoreCase("delete")) {
          this.executeDelete(request,response,context,ids);
       
        } else if (action.equalsIgnoreCase("publish")) {
          this.executePublish(request,response,context,ids);
         
        } else if (action.equalsIgnoreCase("runSynchronizer")) {
          StringAttributeMap syncParams = new StringAttributeMap();
          //syncParams.set("feedbackSeconds","30");
          LuceneIndexSynchronizer lis = new LuceneIndexSynchronizer(syncParams);
          lis.syncronize();
         
        } else if (action.equalsIgnoreCase("touch")) {
View Full Code Here

  public static ValidatorFactory getInstance() {
    if (instance==null) {
      LOGGER.fine("Creating singleton instance of protcol validator factory...");
      ApplicationContext appCtx = ApplicationContext.getInstance();
      ApplicationConfiguration appCfg = appCtx.getConfiguration();
      StringAttributeMap parameters = appCfg.getCatalogConfiguration().getParameters();
      String validatorFactoryClassName = Val.chkStr(parameters.getValue("webharvester.validatorFactory.class"));
      if (!validatorFactoryClassName.isEmpty()) {
        try {
          Class validatorFactoryClass = Class.forName(validatorFactoryClassName);
          instance = (ValidatorFactory)validatorFactoryClass.newInstance();
        } catch (Exception ex) {
View Full Code Here

  /**
   * Sets attributes.
   * @param attributes attributes
   */
  public void setAttributes(StringAttributeMap attributes) {
    this.attributes = attributes != null ? attributes : new StringAttributeMap();
  }
View Full Code Here

  @Override
  public void buildStatistics() throws Exception {
    try {
      String[] restUriParts = statRequestCtx.getRestUriParts();
      HttpServletResponse response = statRequestCtx.getResponse();
      StringAttributeMap params = statRequestCtx.getStatQueryParams();
      writer.begin(response);
      sb.append("{");
      addSpaces(1);
      sb.append("\"harvester\": {");
      addSpaces(2);
      String metrics = Val.chkStr(params.getValue("metrics"));
      String dimensions = Val.chkStr(params.getValue("dimensions"));
      String uuids = Val.chkStr(params.getValue("uuids"));
      String startDate = Val.chkStr(params.getValue("start-date"));
      String endDate = Val.chkStr(params.getValue("end-date"));
      boolean hasDatabaseInfo = false;
      boolean hasConfigInfo = false;
      if (metrics.contains(StatisticsMetrics.CONFIG.toString()
          .toLowerCase())) {
        collectEnvironmentInfo();
View Full Code Here

TOP

Related Classes of com.esri.gpt.framework.collection.StringAttributeMap

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.