Package com.esri.gpt.catalog.harvest.protocols

Examples of com.esri.gpt.catalog.harvest.protocols.HarvestProtocolCsw


public CswQueryBuilderTest() {
}

@BeforeClass
public static void setUpClass() throws Exception {
  HarvestProtocolCsw protocol = new HarvestProtocolCsw();
  protocol.setProfile("urn:ogc:CSW:2.0.2:HTTP:OGCCORE:ESRI:GPT");
  IterationContext context = new IterationContext() {
    public void onIterationException(Exception ex) {
    }
  };
  instance  = new CswQueryBuilder(context, protocol, "http://geoss.esri.com/geoportal/csw/discovery?service=CSW&request=getCapabilities");
View Full Code Here


    return ProtocolType.CSW.name();
  }

  @Override
  public Protocol newProtocol() {
    return new HarvestProtocolCsw();
  }
View Full Code Here

private void init(boolean calledByFactory) throws SearchException {
 
  HrRecord record = this.getHrRecord();
  if(record != null && calledByFactory == true) {
    if(record.getProtocol() instanceof HarvestProtocolCsw) {
      HarvestProtocolCsw hpCsw = (HarvestProtocolCsw) record.getProtocol();
      this.setProfileId(hpCsw.getProfile());
    }
   
    return;
  }
 
  boolean doCapabilities = false;
 
  // get uuid for this search
  String uuid = "";
  Map<String, String> map = super.getFactoryAttributes();
  if(map != null) {
    uuid = Val.chkStr(super.getFactoryAttributes().get("uuid"));
  }
  if("".equals(uuid)) {
    uuid = this.getKey();
  }
 
  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"
View Full Code Here

TOP

Related Classes of com.esri.gpt.catalog.harvest.protocols.HarvestProtocolCsw

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.