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

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


    // 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";
        }
      }
View Full Code Here


   
    // initialize
    ServiceProperties svcProps = context.getServiceProperties();
    String httpContextPath = Val.chkStr(svcProps.getHttpContextPath());
    String cswBaseUrl = Val.chkStr(svcProps.getCswBaseURL());
    OperationResponse opResponse = context.getOperationResponse();
    Document responseDom = opResponse.getResponseDom();
    PropertyMeaning meaning = returnable.getMeaning();
    PropertyMeaningType meaningType = meaning.getMeaningType();
    Object[] values = returnable.getValues();
    DcElement dcElement = meaning.getDcElement();
    if ((dcElement == null) || dcElement.getElementName().startsWith("!")) {
      return;
    }
   
    // TODO create an empty element if the values are null?
    // return if the values are null
    if (values == null) {
      //Element elField = dom.createElement(returnable.getClientName());
      //elField.appendChild(dom.createTextNode(""));
      //record.appendChild(elField);
      return;
    }
   
    // add an element for each value found
    for (Object oValue: values) {
      if (oValue != null) {
        if (meaning.getValueType().equals(PropertyValueType.GEOMETRY)) {
          if (oValue instanceof Envelope) {
           
            // TODO include multiple envelope types in the response
            Envelope env = (Envelope)oValue;
            String sLower = env.getMinX()+" "+env.getMinY();
            String sUpper = env.getMaxX()+" "+env.getMaxY();
           
            Element elField = responseDom.createElement("ows:WGS84BoundingBox");
            Element elLower = responseDom.createElement("ows:LowerCorner");
            Element elUpper = responseDom.createElement("ows:UpperCorner");
            elLower.appendChild(responseDom.createTextNode(sLower));
            elUpper.appendChild(responseDom.createTextNode(sUpper));
            elField.appendChild(elLower);
            elField.appendChild(elUpper);
            record.appendChild(elField);
           
            elField = responseDom.createElement("ows:BoundingBox");
            elLower = responseDom.createElement("ows:LowerCorner");
            elUpper = responseDom.createElement("ows:UpperCorner");
            elLower.appendChild(responseDom.createTextNode(sLower));
            elUpper.appendChild(responseDom.createTextNode(sUpper));
            elField.appendChild(elLower);
            elField.appendChild(elUpper);
            record.appendChild(elField);
          }
                    
        } else {
         
          String sValue = oValue.toString();
          if (oValue instanceof Timestamp) {
            if (meaningType.equals(PropertyMeaningType.DATEMODIFIED)) {
              sValue = opResponse.toIso8601((Timestamp)oValue);
            } else {
              sValue = opResponse.toIso8601Date((Timestamp)oValue);
            }
          }
          if (meaningType.equals(PropertyMeaningType.XMLURL)) {
            if ((sValue != null) && sValue.startsWith("?getxml=")) {
              sValue = cswBaseUrl+sValue;
View Full Code Here

    boolean isSummary = elementSetType.equalsIgnoreCase(CswConstants.ElementSetType_Summary);
    boolean isFull = elementSetType.equalsIgnoreCase(CswConstants.ElementSetType_Full);
   
    // Dublin Core based responses
    if (isDublinCore) {
      OperationResponse opResponse = context.getOperationResponse();
      Document responseDom = opResponse.getResponseDom();
      String recNamespacePfx = "csw";
      String recNamespaceUri = CswNamespaces.URI_CSW;
      String recLocalName = "Record";
      StringSet elementNames = qOptions.getElementNames();
      boolean hasElementNames = (elementNames != null) && (elementNames.size() > 0);
View Full Code Here

    throws Exception{
   
    // determine records counts
    QueryOptions qOptions = context.getRequestOptions().getQueryOptions();
    DiscoveryQuery query = this.getDiscoveryContext().getDiscoveryQuery();
    OperationResponse opResponse = context.getOperationResponse();
    Document responseDom = opResponse.getResponseDom();
    DiscoveryResult result = query.getResult();
    int numberOfRecordsMatched = result.getNumberOfHits();
    int numberOfRecordsReturned = 0;
    int nextRecord = 0;
    String rtname = qOptions.getResultType();
    boolean isHits = rtname.equalsIgnoreCase(CswConstants.ResultType_Hits);
    if (isHits || (query.getFilter().getMaxRecords() <= 0)) {
      if (numberOfRecordsMatched > 0) {
        nextRecord = 1;
      }
    } else {
      numberOfRecordsReturned = result.getRecords().size();
      if (numberOfRecordsReturned > 0) {
        if (numberOfRecordsReturned < numberOfRecordsMatched) {
          nextRecord = query.getFilter().getStartRecord() + numberOfRecordsReturned;
          if (nextRecord > numberOfRecordsMatched) nextRecord = 0;
        }
      }
    }
     
    // the following attributes are not currently populated:
    //   resultSetId expires
   
    // create and add the status element
    String sTimestamp = opResponse.toIso8601(new Timestamp(System.currentTimeMillis()));
    Element elStatus = responseDom.createElementNS(CswNamespaces.URI_CSW,"csw:SearchStatus");
    elStatus.setAttribute("timestamp",sTimestamp);
    parent.appendChild(elStatus);
   
    // create and add the results element
View Full Code Here

  public void generateResponse(OperationContext context) throws Exception {
    String opName = Val.chkStr(context.getOperationName());
   
    if (opName.equalsIgnoreCase(CswConstants.Operation_GetRecordById)) {
      LOGGER.finer("Generating GetRecordByIdResponse...");
      OperationResponse opResponse = context.getOperationResponse();
      Element root = this.newResponseDom(context,"GetRecordByIdResponse");
      this.appendDiscoveredRecords(context,root);
      opResponse.setResponseXml(XmlIoUtil.domToString(opResponse.getResponseDom()));
     
    } else if (opName.equalsIgnoreCase(CswConstants.Operation_GetRecords)) {
      LOGGER.finer("Generating GetRecordsResponse...");
      OperationResponse opResponse = context.getOperationResponse();
      Element root = this.newResponseDom(context,"GetRecordsResponse");
      this.appendSearchResultsElement(context,root);
      opResponse.setResponseXml(XmlIoUtil.domToString(opResponse.getResponseDom()));
    }
  }
View Full Code Here

    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) {
View Full Code Here

      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);
    }
   
    getLogger().finest(" CSW response : " + cswResponse);
View Full Code Here

TOP

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

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.