Package com.esri.gpt.framework.context

Examples of com.esri.gpt.framework.context.RequestContext


        this.autoSelector = new AutoSelector(cfg.getAutoSelectFrequency()) {

          @Override
          protected void onSelect(HrRecord resource) {
            if (ProtocolInvoker.getUpdateContent(resource.getProtocol())) {
              RequestContext context = RequestContext.extract(null);
              try {
                submit(context, resource, null, resource.getLastSyncDate()==null || HarvestPolicy.getInstance().getForceFullHarvest(resource)? null: resource.getLastSyncDate());
              } finally {
                context.onExecutionPhaseCompleted();
              }
            }
          }
        };
        Thread thread = new Thread(autoSelector, "Auto-selector");
View Full Code Here


  /**
   * Recovers records.
   */
  private void resetRunning() {
    RequestContext context = RequestContext.extract(null);
    try {
      HjResetRunningRequest recover = new HjResetRunningRequest(context);
      recover.execute();
      if (taskQueue!=null) {
        taskQueue.notifyChange();
      }
    } catch (SQLException ex) {
      LOGGER.log(Level.SEVERE, "[SYNCHRONIZER] Error recovering from the previous failout", ex);
    } finally {
      context.onExecutionPhaseCompleted();
    }
  }
View Full Code Here

      record.getResourceLinks().add(link);
    }

    String url = "";
    try {
      RequestContext rContext = context;
      ServletRequest sRequest = rContext.getServletRequest();
      if (sRequest instanceof HttpServletRequest) {
        HttpServletRequest hSRequest = (HttpServletRequest) sRequest;
        String path = Val.chkStr(hSRequest.getPathInfo()).toLowerCase();
        if (path.contains("catalog/search/search.page")
                || path.contains("catalog/main/home.page")) {
View Full Code Here

*           the SQL exception
*/
protected Connection getConnection() throws SearchException, SQLException {

  SearchConfig.getConfiguredInstance();
  RequestContext requestContext = this.getRequestContext();
  if (requestContext == null) {
    throw new SearchException("Could not get a request context so as "
        + " to make a" + " connection to the repository.");
  }

  ConnectionBroker connectionBroker = requestContext.getConnectionBroker();
  if (connectionBroker == null) {
    throw new SearchException("Could not get a Connection Broker so as"
        + " to make a" + " connection to the repository.");
  }

View Full Code Here

public RequestContext getRequestContext() {
  if(super.getRequestContext() != null) {
    return super.getRequestContext();
  }
  FacesContextBroker broker = new FacesContextBroker();
  RequestContext requestContext = broker.extractRequestContext();
  return requestContext;
}
View Full Code Here

*/
public String getDownloadView() {

  try {
    // start view preparation phase
    RequestContext context = onPrepareViewStarted();
    HttpServletRequest request =
      new FacesContextBroker().extractHttpServletRequest();

    // get donwload config
    DownloadConfiguration cfg =
      com.esri.gpt.framework.context.RequestContext.extract(request).
      getApplicationConfiguration().getDownloadDataConfiguration();

    // get user email address
    setUserEmail(getParameterByKey(request, KEY_EMAIL));
    if (getUserEmail().length() == 0) {
      User user = context.getUser();
      setUserEmail(user != null ? user.getProfile().getEmailAddress() : "");
    }

    // get map service url
    setMapServiceUrl(getParameterByKey(request, KEY_MAPSERVICEURL));
View Full Code Here

  /**
   * Run the synchronization process.
   */
  public void run() {
    LOGGER.info("AGSSynchronizer run started...");
    RequestContext rContext = null;
    Lock backgroundLock = null;
    long tStartMillis = System.currentTimeMillis();
    try {
     
      // initialize
      String restUrl = "";
      String soapUrl = "";
      PublicationRecord template = new PublicationRecord();
      if (this.parameters != null) {
        restUrl = Val.chkStr(this.parameters.getValue("restUrl"));
        soapUrl = Val.chkStr(this.parameters.getValue("soapUrl"));
        template.setAutoApprove(
            Val.chkStr(this.parameters.getValue("autoApprove")).equalsIgnoreCase("true"));
        template.setUpdateOnlyIfXmlHasChanged(
            Val.chkStr(this.parameters.getValue("updateOnlyIfXmlHasChanged")).equalsIgnoreCase("true"));
      }
      if (restUrl.length() == 0) {
        LOGGER.log(Level.SEVERE,"AGSSynchronizer run aborted: the restUrl parameter was empty.");
        return;
      }
      if (soapUrl.length() == 0) {
        LOGGER.log(Level.SEVERE,"AGSSynchronizer run aborted: the soapUrl parameter was empty.");
        return;
      }
     
      // 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();
      Publisher publisher = Publisher.makeSystemAdministrator(rContext);
      HttpClientRequest httpClient = HttpClientRequest.newRequest();
     
      ProcessingContext pContext = new ProcessingContext(rContext,publisher,httpClient,template,false);
      AGSProcessor ags = new AGSProcessor(pContext);
      ags.getTarget().setRestUrl(restUrl);
      ags.getTarget().setSoapUrl(soapUrl);
      ags.getTarget().setTargetUrl(restUrl);
      ags.getTarget().setTargetType(AGSTarget.TargetType.ROOT);
      if (!Thread.currentThread().isInterrupted()) {
        ags.process();
      }
      sbSummary.append("\n numCreated=").append(pContext.getNumberCreated());
      sbSummary.append(", numReplaced=").append(pContext.getNumberReplaced());
      sbSummary.append(", numUnchanged=").append(pContext.getNumberUnchanged());
      sbSummary.append(", numDeleted=").append(pContext.getNumberDeleted());
      sbSummary.append(", numFailed=").append(pContext.getNumberFailed());
           
      // log a summary message
      double dSec = (System.currentTimeMillis() - tStartMillis) / 1000.0;
      StringBuilder msg = new StringBuilder();
      msg.append("AGSSynchronizer run completed.");
      msg.append("\n restUrl=").append(restUrl);
      msg.append("\n soapUrl=").append(soapUrl);
      msg.append(sbSummary.toString());
      msg.append("\n wasInterrupted=").append(Thread.currentThread().isInterrupted());
      msg.append(", runtime: ");
      msg.append(Math.round(dSec / 60.0 * 100.0) / 100.0).append(" minutes");
      if (dSec <= 600) {
        msg.append(", ").append(Math.round(dSec * 100.0) / 100.0).append(" seconds");
      }
      LOGGER.info(msg.toString());
     
    } catch (ImsServiceException e) {
      LOGGER.log(Level.SEVERE,"Deletion error.",e);
    } catch (CatalogIndexException e) {
      LOGGER.log(Level.SEVERE,"Catalog index error.",e);
    } catch (SQLException e) {
      LOGGER.log(Level.SEVERE,"Database error.",e);
    } catch (Exception e) {
      LOGGER.log(Level.SEVERE,"Unknown error.",e);
     
    } finally {
      if (backgroundLock != null) {
        try {
          backgroundLock.release();
        } catch (Throwable t) {
          LOGGER.log(Level.WARNING,"Error releasing lock.",t);
        }
      }
      if (rContext != null) {
        rContext.onExecutionPhaseCompleted();
      }
      if (Thread.currentThread().isInterrupted()) {
        LOGGER.info("AGSSynchronizer run was interrupted.");
      }
    }
View Full Code Here

 
  try {

    // Extracting getRecordByID and GetRecordsUrl associated with uuid in
    // session
    RequestContext reqContext = this.getRequestContext();
    if(reqContext == null) {
      throw new NullPointerException("RequestContext in search engine is null")
    }
    String sessionKeyPrfx = this.getClass().getCanonicalName() + ":uuid:"
        + uuid;
    String sessionGetMetadataKey = sessionKeyPrfx + ":GetMetadataRecord:url";
    String sessionGetRecordsKey = sessionKeyPrfx + ":GetRecords:url";
    String sessionProfileId = sessionKeyPrfx + ":profileId";
    String sessionCapabUrl = sessionKeyPrfx + ":capabilities:url";
    String sessionCapObject = sessionKeyPrfx + ":capabilities:object";
   
    Object objCapObject = reqContext.extractFromSession(sessionCapObject);
    if(objCapObject instanceof CswCatalogCapabilities) {
      this.setCapabilities((CswCatalogCapabilities)objCapObject);
    }
    Object objGetMetadataUrl = reqContext.extractFromSession(
        sessionGetMetadataKey);
    Object objGetRecordsUrl = reqContext.extractFromSession(
        sessionGetRecordsKey);
    Object objProfileId = reqContext.extractFromSession(
        sessionProfileId);
    Object objGetCapabUrl = reqContext.extractFromSession(
        sessionCapabUrl);
   
    if (objGetMetadataUrl == null
        || "".equals(objGetMetadataUrl.toString().trim())
        || objGetRecordsUrl == null
        || "".equals(objGetRecordsUrl.toString().trim())
        || objProfileId == null
        || "".equals(objProfileId.toString().trim())
        || objGetCapabUrl == null
        || "".equals(objGetCapabUrl.toString().trim())) {
      doCapabilities = true;
    } else {
      this.setGetRecordsUrl(objGetRecordsUrl.toString());
      this.setGetMetadataRecordUrl(objGetMetadataUrl.toString());
      this.setProfileId(objProfileId.toString());
      this.setGetCapabiltiesUrl(objGetCapabUrl.toString());
    }
   
    // Checking the db to check if profile and url are still the same
    GptRepository repos = new GptRepository();
   
    try {
      if (record == null) {

        record = repos.readHarvestRecord(uuid, this.getRequestContext());

      }
      Protocol harvestProtocol = record.getProtocol();
      if (harvestProtocol instanceof HarvestProtocolCsw) {
        HarvestProtocolCsw harvestProtocolCsw = (HarvestProtocolCsw) harvestProtocol;
        if (!this.getProfileId().equals(harvestProtocolCsw.getProfile())
            || !this.getGetCapabiltiesUrl().equals(record.getHostUrl())) {
          doCapabilities = true;
          this.setProfileId(harvestProtocolCsw.getProfile());
          this.setGetCapabiltiesUrl(record.getHostUrl());
        }

      } else {
        throw new SearchException("repository id " + uuid + " is not expected"
            + " CSW protocol");
      }
    } catch (SearchException e) {
      // T.M. accomodates gpt.xml values
      String url = Val.chkStr(this.getFactoryAttributes().get("url"));
      String profileId = Val.chkStr(this.getFactoryAttributes()
          .get("profileid"));
      if(!"".equals(url) && !"".equals(profileId)) {
        doCapabilities = true;
        this.setProfileId(profileId);
        this.setGetCapabiltiesUrl(url);
      } else {
        throw e;
      }
    }
    // Do the capabilities if requested
    if (doCapabilities) {
      super.init();
      // Add info to session
      reqContext.addToSession(sessionGetMetadataKey,
          this.getGetMetadataRecordUrl());
      reqContext.addToSession(sessionGetRecordsKey, this.getGetRecordsUrl());
      reqContext.addToSession(sessionCapabUrl, this.getGetCapabiltiesUrl());
      reqContext.addToSession(sessionProfileId, this.getProfileId());
      reqContext.addToSession(sessionCapObject, this.getCapabilities());
    }
  } catch (Throwable e) {
    throw new SearchException("Error while getting items from repository "
        + " with id of " + uuid + e.getMessage(), e);
  }
View Full Code Here

* @throws AbortProcessingException if processing should be aborted
*/
public void processLogout(ActionEvent event)
  throws AbortProcessingException {
  try {
    RequestContext context = onExecutionPhaseStarted();
    invalidateSession(context);
  } catch (AbortProcessingException e) {
    throw(e);
  } catch (Throwable t) {
    handleException(t);
View Full Code Here

* This method is intended for use from a JSP page only.
* @return the active user profile attributes
*/
public UserAttributeMap getActiveUserAttributes() {
  if (_activeUserAttributes == null) {
    RequestContext rc = extractRequestContext();
    User user = rc.getUser();
    if (user.getAuthenticationStatus().getWasAuthenticated()) {
      _activeUserAttributes = new UserAttributeMap(user.getProfile());
     
      // attempt to reload the user's profile
      IdentityAdapter idAdapter = rc.newIdentityAdapter();
      User userUpdate = new User();
      userUpdate.setKey(user.getKey());
      userUpdate.setLocalID(user.getLocalID());
      userUpdate.setDistinguishedName(user.getDistinguishedName());
      userUpdate.setProfile(_activeUserAttributes);
View Full Code Here

TOP

Related Classes of com.esri.gpt.framework.context.RequestContext

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.