Package com.esri.gpt.server.csw.provider.components

Examples of com.esri.gpt.server.csw.provider.components.RequestHandler


   
    // process the request
    LOGGER.fine("Executing CSW provider request....");
    String cswResponse = "";
    String mimeType = "application/xml";
    RequestHandler handler = null;
    OperationResponse opResponse = null;
    try {
      String cswRequest = readInputCharacters(request);
      LOGGER.finer("cswRequest:\n"+cswRequest);
      handler = this.makeRequestHandler(request,response,context);
      if (cswRequest.length() > 0) {
        opResponse = handler.handleXML(cswRequest);
      } else {
        opResponse = handler.handleGet(request);
      }
      if (opResponse != null) {
        cswResponse = Val.chkStr(opResponse.getResponseXml());
        String fmt = Val.chkStr(opResponse.getOutputFormat());
        if (fmt.equalsIgnoreCase("text/xml")) {
          mimeType = "text/xml";
        }
      }
    } catch (Exception e) {
      OperationContext opContext = null;
      if (handler != null) {
        opContext = handler.getOperationContext();
      }
      cswResponse = handleException(opContext,e);
    }
   
    // write the response
View Full Code Here


   */
  protected RequestHandler makeRequestHandler(HttpServletRequest request,
                                              HttpServletResponse response,
                                              RequestContext context) {
    IProviderFactory factory = new ProviderFactory();
    RequestHandler handler = factory.makeRequestHandler(
        request,context,this.cswSubContextPath,this.resourceFilePrefix);
    if (handler != null) {
      handler.getOperationContext().getServiceProperties().setAllowTransactions(this.allowTransactions);
    }
    return handler;
  }
View Full Code Here

  protected String readFullXml(HttpServletRequest request,
                               HttpServletResponse response,
                               RequestContext context,
                               String id)
    throws Exception {
    RequestHandler handler = this.makeRequestHandler(request,response,context);
    OperationContext opContext = handler.getOperationContext();
    IProviderFactory factory = opContext.getProviderFactory();
    IOriginalXmlProvider oxp = factory.makeOriginalXmlProvider(opContext);
    if (oxp == null) {
      String msg = "The getxml parameter is not supported.";
      String locator = "getxml";
View Full Code Here

    // send the GetRecordsById request
    try {
      GetRecordsGenerator generator = new GetRecordsGenerator(this.getRequestContext());
      String cswRequest = generator.generateCswByIdRequest(uuid);
     
      RequestHandler handler = ProviderFactory.newHandler(this.getRequestContext());
      OperationResponse resp = handler.handleXML(cswRequest);
      cswResponse = resp.getResponseXml();
     
      records = this.parseResponse(cswResponse);
    } catch (DiscoveryException e) {
      throw new SearchException("Error quering GetRecordById: "+e.getMessage(),e);
    } catch (Exception e) {
      throw new SearchException("Error generating GetRecordById: "+e.getMessage(),e);
    }

    // get the first record
    if (records != null) {
      Iterator iter = records.iterator();
      if (iter.hasNext()) {
        Object obj = iter.next();
        if(obj instanceof CswRecord ) {
          record = (CswRecord)obj;
        }
      }
    }
   
    // parse the GetRecordsById response
    if (record != null) {
      record.setId(uuid);
      try {
        getCswProfile().readCSWGetMetadataByIDResponseLocal(cswResponse, record);
      } catch (Exception e) {
        throw new SearchException("Error parsing GetRecordById: "+e.getMessage(),e);
      }
      if (record != null) {
       
        // read the full metadata XML (acl was already processed by above CSW request)
        String fullMetadataXml = "";      
        try {
         
          RequestHandler handler = ProviderFactory.newHandler(this.getRequestContext());
          OperationContext ctx = handler.getOperationContext();
          IOriginalXmlProvider oxp = ctx.getProviderFactory().makeOriginalXmlProvider(ctx);
          fullMetadataXml = oxp.provideOriginalXml(ctx,uuid);
         
        } catch (Exception e) {
          throw new SearchException("Error accessing full metadata xml for: "+uuid);
View Full Code Here

      Object obj = this.getRequestContext().getObjectMap().get("com.esri.gpt.catalog.search.isSitemapRequest");
      if ((obj != null) && (obj instanceof String)) {
        isSitemapRequest = ((String)obj).equalsIgnoreCase("true");
      }
     
      RequestHandler handler = ProviderFactory.newHandler(this.getRequestContext());
      OperationResponse resp = handler.handleXML(cswRequest);
      String cswResponse = resp.getResponseXml();
     
      LOGGER.log(Level.FINER, "cswResponse:\n{0}", cswResponse);
     
      //return this.parseResponse(cswResponse);
View Full Code Here

    String cswRequest = template.transform(axlRequest, params);
    getLogger().finest(" AXL2CSW transformed request : " + cswRequest);
    String cswResponse = "";
    try {
      RequestHandler handler = ProviderFactory.newHandler(context);
      OperationResponse resp = handler.handleXML(cswRequest);
      cswResponse = resp.getResponseXml();
    } catch (Exception e) {
      throw new SearchException(e);
    }
   
View Full Code Here

   * @param action the active test action
   * @throws Exception if a processing exception occurs
   */
  public void testAction(CfgAction action) throws Exception {
    RequestContext rc = null;
    RequestHandler handler = null;
    boolean succeeded = false;
    try {

      // make the HTTP servlet request
      String actionName = action.nodeName;
      String queryString = null;
      if (action.nodeName.equalsIgnoreCase("url")) {
        queryString = Val.chkStr(action.nodeText);
      }
      HttpServletRequestFacade httpRequest = new HttpServletRequestFacade(queryString);
     
      // set up an administrative publisher
      if (this.admin == null) {
        RequestContext rc2 = null;
        try {
          rc2 = RequestContext.extract(null);
          this.admin = Publisher.makeSystemAdministrator(rc2);
        } finally {
          if (rc2 != null) rc2.onExecutionPhaseCompleted();
        }
      }
      httpRequest.getSession().setAttribute("com.esri.gpt.user",admin);
     
      // make the CSW request handler
      rc = RequestContext.extract(httpRequest);
      handler = ProviderFactory.newHandler(rc);
      RequestOptions rOptions = handler.getOperationContext().getRequestOptions();
      rOptions.getTransactionOptions().setAutoApprove(true);
     
      // execute the testable action
      if (action.nodeName.equalsIgnoreCase("url")) {
        handler.handleGet(httpRequest);
      } else if (actionName.equalsIgnoreCase("xml")) {
        handler.handleXML(Val.chkStr(action.nodeText));
      } else if (actionName.equalsIgnoreCase("file")) {
        handler.handleXML(XmlIoUtil.readXml(action.dataFile.getCanonicalPath()));
      } else {
        throw new Exception(action.makeMessagePrefix()+" The action is invalid: "+actionName);
      }
      if (this.verbose) {
        System.err.println(handler.getOperationContext().getOperationResponse().getResponseXml());
      }
  
      // assert that the action should have passed
      succeeded = true;
      action.onSucceeded();
             
    // OWS exceptions
    } catch (OwsException ows) {
      if (this.verbose) {
        System.err.println(ows.getReport());
      }
      action.onFailed(ows,false);
     
      // assert the owsLocator and owsCode if set
      NamedNodeMap nnmItemAttributes = action.item.node.getAttributes();
      String owsCode = Val.chkStr(DomUtil.getAttributeValue(nnmItemAttributes,"owsCode"));
      String owsLocator = Val.chkStr(DomUtil.getAttributeValue(nnmItemAttributes,"owsLocator"));
      if (owsLocator.startsWith("@")) {
        owsLocator = Val.chkStr(owsLocator.substring(1));
      }
      if (owsLocator.length() > 0) {
        String msg = action.makeMessagePrefix()+" The OwsException locator is incorrect.";
        org.junit.Assert.assertEquals(msg,owsLocator,ows.getLocator());
      }
      if (owsCode.length() > 0) {
        String msg = action.makeMessagePrefix()+" The OwsException code is incorrect.";
        org.junit.Assert.assertEquals(msg,owsCode,ows.getCode());
      }
     
    // other exceptions
    } catch (Exception e) {
      action.onFailed(e,true);
    } finally {
      if (rc != null) rc.onExecutionPhaseCompleted();
    }
   
    // handle remaining assertions   
    CfgAssertion[] assertions = action.item.assertions;
    if (succeeded && (assertions != null) && (assertions.length > 0)) {
      CfgAssertionHelper helper = new CfgAssertionHelper();
      OperationContext ctx = handler.getOperationContext();
      String resultXml = ctx.getOperationResponse().getResponseXml();
      if (this.xpath == null) {
        CswNamespaces ns = new CswNamespaces();
        this.xpath = XPathFactory.newInstance().newXPath();
        this.xpath.setNamespaceContext(ns.makeNamespaceContext());
View Full Code Here

TOP

Related Classes of com.esri.gpt.server.csw.provider.components.RequestHandler

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.