Package ORG.oclc.oai.harvester2.verb

Examples of ORG.oclc.oai.harvester2.verb.Identify


     * @param metadataPrefix the OAI metadataPrefix of the desired metadata
     * @return list of JDOM elements corresponding to the metadata entries in the located record.
     */
    private List<Element> getMDrecord(String oaiSource, String itemOaiId, String metadataPrefix) throws IOException, ParserConfigurationException, SAXException, TransformerException, HarvestingException
    {
    GetRecord getRecord = new GetRecord(oaiSource,itemOaiId,metadataPrefix);
    Set<String> errorSet = new HashSet<String>();       
    // If the metadata is not available for this item, can the whole thing
    if (getRecord != null && getRecord.getErrors() != null && getRecord.getErrors().getLength() > 0) {
      for (int i=0; i<getRecord.getErrors().getLength(); i++) {
        String errorCode = getRecord.getErrors().item(i).getAttributes().getNamedItem("code").getTextContent();
        errorSet.add(errorCode);
      }
      throw new HarvestingException("OAI server returned the following errors during getDescMD execution: " + errorSet.toString());
    }

    Document record = db.build(getRecord.getDocument());
    Element root = record.getRootElement();

    return root.getChild("GetRecord",OAI_NS).getChild("record", OAI_NS).getChild("metadata",OAI_NS).getChildren();
    }
View Full Code Here


     * @throws ParserConfigurationException
     * @throws IOException
     */
    private String OAIGetDateGranularity(String oaiSource) throws IOException, ParserConfigurationException, SAXException, TransformerException
    {
      Identify iden = new Identify(oaiSource);
      return iden.getDocument().getElementsByTagNameNS(OAI_NS.getURI(), "granularity").item(0).getTextContent();
    }
View Full Code Here

      String OREOAIPrefix = null;
      Namespace DMD_NS = OAIHarvester.getDMDNamespace(metaPrefix);
      String DMDOAIPrefix = null;
     
      try {
        Identify idenTest = new Identify(oaiSource);
      }
      catch (Exception ex) {
        errorSet.add(OAI_ADDRESS_ERROR + ": OAI server could not be reached.");
        return errorSet;
      }
View Full Code Here

    public static String OAIResolveNamespaceToPrefix(String oaiSource, String MDNamespace) throws IOException, ParserConfigurationException, SAXException, TransformerException, ConnectException
    {
      String metaPrefix = null;

      // Query the OAI server for the metadata
      ListMetadataFormats lmf = new ListMetadataFormats(oaiSource);
     
      if (lmf != null) {
        Document lmfResponse = db.build(lmf.getDocument());
        List<Element> mdFormats = lmfResponse.getRootElement().getChild("ListMetadataFormats", OAI_NS).getChildren("metadataFormat", OAI_NS);
       
        for (Element mdFormat : mdFormats) {
          if (MDNamespace.equals(mdFormat.getChildText("metadataNamespace", OAI_NS)))
          {
View Full Code Here

     
      // main loop to keep requesting more objects until we're done
      List<Element> records;
      Set<String> errorSet = new HashSet<String>();
   
      ListRecords listRecords = new ListRecords(oaiSource, fromDate, toDate, oaiSetId, descMDPrefix);
      log.debug("Harvesting request parameters: listRecords " + oaiSource + " " + fromDate + " " + toDate + " " + oaiSetId + " " + descMDPrefix);
      if (listRecords != null)
        log.info("HTTP Request: " + listRecords.getRequestURL());
      while (listRecords != null)
      {
        records = new ArrayList<Element>();
        oaiResponse = db.build(listRecords.getDocument());

        if (listRecords.getErrors() != null && listRecords.getErrors().getLength() > 0)
        {
          for (int i=0; i<listRecords.getErrors().getLength(); i++)
          {
            String errorCode = listRecords.getErrors().item(i).getAttributes().getNamedItem("code").getTextContent();
            errorSet.add(errorCode);
          }
          if (errorSet.contains("noRecordsMatch"))
          {
            log.info("noRecordsMatch: OAI server did not contain any updates");
            harvestRow.setHarvestResult(new Date(), "OAI server did not contain any updates");
            harvestRow.setHarvestStatus(HarvestedCollection.STATUS_READY);
            harvestRow.update();
            return;
          } else {
            throw new HarvestingException(errorSet.toString());
          }
        }
        else
        {
          root = oaiResponse.getRootElement();
          records.addAll(root.getChild("ListRecords", OAI_NS).getChildren("record", OAI_NS));
        }

        // Process the obtained records
        if (records != null && records.size()>0)
        {
          log.info("Found " + records.size() + " records to process");
          for (Element record : records) {
            // check for STOP interrupt from the scheduler
            if (HarvestScheduler.interrupt == HarvestScheduler.HARVESTER_INTERRUPT_STOP)
              throw new HarvestingException("Harvest process for " + targetCollection.getID() + " interrupted by stopping the scheduler.");
            // check for timeout
            if (expirationTime.before(new Date()))
              throw new HarvestingException("runHarvest method timed out for collection " + targetCollection.getID());
           
            processRecord(record,OREPrefix);
            ourContext.commit();
          }
        }

        // keep going if there are more records to process
        resumptionToken = listRecords.getResumptionToken();
        if (resumptionToken == null || resumptionToken.length() == 0) {
          listRecords = null;
        }
        else {
          listRecords = new ListRecords(oaiSource, resumptionToken);
        }
        targetCollection.update();
        ourContext.commit();
      }
    }
View Full Code Here

      // Now scan the sets and make sure the one supplied is in the list
      boolean foundSet = false;
      try {
            //If we do not want to harvest from one set, then skip this.
        if(!"all".equals(oaiSetId)){
                ListSets ls = new ListSets(oaiSource);

                // The only error we can really get here is "noSetHierarchy"
                if (ls.getErrors() != null && ls.getErrors().getLength() > 0) {
                    for (int i=0; i<ls.getErrors().getLength(); i++) {
                        String errorCode = ls.getErrors().item(i).getAttributes().getNamedItem("code").getTextContent();
                        errorSet.add(errorCode);
                    }
                }
                else {
                    // Drilling down to /OAI-PMH/ListSets/set
                    Document reply = db.build(ls.getDocument());
                    Element root = reply.getRootElement();
                    List<Element> sets= root.getChild("ListSets",OAI_NS).getChildren("set",OAI_NS);

                    for (Element set : sets)
                    {
View Full Code Here

TOP

Related Classes of ORG.oclc.oai.harvester2.verb.Identify

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.