Package org.fao.geonet.kernel.harvest.harvester

Examples of org.fao.geonet.kernel.harvest.harvester.HarvestError


          try {
                        if(log.isDebugEnabled()) log.debug("Before transform: "+Xml.getString(md));
            md = Xml.transform(md, thisXslt);
                        if(log.isDebugEnabled()) log.debug("After transform: "+Xml.getString(md));
          } catch (Exception e) {
              HarvestError error = new HarvestError(e, log);
              error.setDescription("Cannot transform XML, ignoring. Error was: "+e.getMessage());
            this.errors.add(error);
            error.printLog(log);
            result.badFormat++;
            continue; // skip this one
          }
        }

        // detect schema, extract uuid and add
        String schema = dataMan.autodetectSchema(md, null);
        if (schema == null) {
          log.warning("Skipping metadata with unknown schema.");
          result.unknownSchema++;
          continue;
        }

        String uuid = null;
        try {
          uuid = dataMan.extractUUID(schema, md);
        } catch (Exception e) {
                    HarvestError error = new HarvestError(e, log);
                    error.setDescription("Unable to extract UUID. " + e.getMessage());
                    this.errors.add(error);
                    error.printLog(log);
        }

        if (uuid == null || uuid.equals("")) {
          log.warning("Skipping metadata due to failure extracting uuid (uuid null or empty).");
          result.unretrievable++;
          continue;
        }

        log.info("  - Adding metadata with " + uuid);

        //--- generate a new metadata id
   
        String docType = "";
        if (!transformIt && (doc.getDocType() != null)) {
          docType = Xml.getString(doc.getDocType());
        }

        //--- check for duplicate uuid - violates constraints on metadata table
        //--- if we attempt insert
        boolean alreadyAdded = !newUuids.add(uuid);
        boolean alreadyInDb  = (dataMan.getMetadataId(uuid) != null);
        if (alreadyAdded || alreadyInDb) {
          log.error("Uuid "+uuid+" already exists in this set/database - cannot insert");
          result.couldNotInsert++;
          continue;
        }

                final String id;
                //
                // insert metadata
                //
        try {
                    String groupOwner = "1", isTemplate = "n", title = null;
                    int owner = 1;
                    String category = null, createDate = new ISODate().toString(), changeDate = createDate;
                    boolean ufo = false, indexImmediate = false;
                    id = dataMan.insertMetadata(context, schema, md, uuid, owner, groupOwner, params.uuid,
                            isTemplate, docType, category, createDate, changeDate, ufo, indexImmediate);

                }
                catch (Exception e) {
                    HarvestError error = new HarvestError(e, log);
                    error.setDescription("Unable to insert metadata. "+e.getMessage());
                    this.errors.add(error);
                    error.printLog(log);
          result.couldNotInsert++;
          continue;
        }

                addPrivileges(id, params.getPrivileges(), localGroups, dataMan, context, log);
View Full Code Here


      return response;
    }
    catch(Exception e)
    {
            HarvestError error = new HarvestError(e, log);
            error.setDescription("Raised exception when searching : "+ e);
            this.errors.add(error);
            error.printLog(log);
      throw new OperationAbortedEx("Raised exception when searching", e);
    }
  }
View Full Code Here

            records.addAll(search(server, s));
        } catch (Exception t) {
            log.error("Unknown error trying to harvest");
            log.error(t.getMessage());
            log.error(t);
            errors.add(new HarvestError(t, log));
        } catch (Throwable t) {
            log.fatal("Something unknown and terrible happened while harvesting");
            log.fatal(t.getMessage());
            errors.add(new HarvestError(t, log));
        }

    if (params.isSearchEmpty()) {
        try {
            log.debug("Doing an empty search");
            records.addAll(search(server, Search.createEmptySearch()));
            } catch(Exception t) {
                log.error("Unknown error trying to harvest");
                log.error(t.getMessage());
                log.error(t);
                errors.add(new HarvestError(t, log));
        } catch(Throwable t) {
                log.fatal("Something unknown and terrible happened while harvesting");
                log.fatal(t.getMessage());
                errors.add(new HarvestError(t, log));
            }
      }

    log.info("Total records processed in all searches :"+ records.size());
View Full Code Here

   
        if (!checkOperation(log, server, "GetRecordById"))
          throw new OperationAbortedEx("GetRecordById operation not found");

    } catch(BadXmlResponseEx e) {
            errors.add(new HarvestError(e, log, params.capabUrl));
            throw e;
    }
       
    return server;
  }
View Full Code Here

        } catch(Exception ex) {
            if(log.isDebugEnabled()) {
                log.debug(ex.getMessage());
                log.debug("Changing to CSW harvester to use " + (PREFERRED_HTTP_METHOD.equals("GET")?"POST":"GET"));
            }
            errors.add(new HarvestError(ex, log));

            configRequest(request, oper, server, s, PREFERRED_HTTP_METHOD.equals("GET")?"POST":"GET");
        }

    Set<RecordInfo> records = new HashSet<RecordInfo>();

    while (true)
    {
      request.setStartPosition(start +"");
      Element response = doSearch(request, start, GETRECORDS_NUMBER_OF_RESULTS_PER_PAGE);
            if(log.isDebugEnabled())
                log.debug("Number of child elements in response: " + response.getChildren().size());

      Element results  = response.getChild("SearchResults", Csw.NAMESPACE_CSW);
      // heikki: some providers forget to update their CSW namespace to the CSW 2.0.2 specification
      if(results == null) {
        // in that case, try to accommodate them anyway:
        results = response.getChild("SearchResults", Csw.NAMESPACE_CSW_OLD);
        if (results == null) {
          throw new OperationAbortedEx("Missing 'SearchResults'", response);
        }
        else {
          log.warning("Received GetRecords response with incorrect namespace: " + Csw.NAMESPACE_CSW_OLD);
        }
      }

      @SuppressWarnings("unchecked")
            List<Element> list = results.getChildren();
      int counter = 0;

      log.debug("Extracting all elements in the csw harvesting response");
      for (Element record :list) {
                try {
            RecordInfo recInfo= getRecordInfo((Element)record.clone());

            if (recInfo != null)
              records.add(recInfo);

            counter++;

                } catch (Exception ex) {
                    errors.add(new HarvestError(ex, log));
                    log.error("Unable to process record from csw (" + this.params.name + ")");
                    log.error("   Record failed: " + counter);
                    log.debug("   Record: " ((Element)record).getName());
                }
View Full Code Here

      return response;
    }
    catch(Exception e)
    {
            errors.add(new HarvestError(e, log));
      log.warning("Raised exception when searching : "+ e);
      throw new OperationAbortedEx("Raised exception when searching: " + e.getMessage(), e);
    }
  }
View Full Code Here

                records.addAll(search(req, s));
            } catch (Exception t) {
                log.error("Unknown error trying to harvest");
                log.error(t.getMessage());
                log.error(t);
                errors.add(new HarvestError(t, log));
            } catch (Throwable t) {
                log.fatal("Something unknown and terrible happened while harvesting");
                log.fatal(t.getMessage());
                t.printStackTrace();
                errors.add(new HarvestError(t, log));
            }
        }

        if (params.isSearchEmpty()) {
            try {
                log.debug("Doing an empty search");
                records.addAll(search(req, Search.createEmptySearch()));
            } catch (Exception t) {
                log.error("Unknown error trying to harvest");
                log.error(t.getMessage());
                log.error(t);
                errors.add(new HarvestError(t, log));
            } catch (Throwable t) {
                log.fatal("Something unknown and terrible happened while harvesting");
                log.fatal(t.getMessage());
                t.printStackTrace();
                errors.add(new HarvestError(t, log));
            }
        }

    log.info("Total records processed in all searches :"+ records.size());
View Full Code Here

        String source     = info.getChildText("source");

        records.add(new RecordInfo(uuid, changeDate, schema, source));
      }
            } catch (Exception e) {
                HarvestError harvestError = new HarvestError(e, log);
                harvestError.setDescription("Malformed element '"
                        + o.toString() + "'");
                harvestError
                        .setHint("It seems that there was some malformed element. Check with your administrator.");
                this.errors.add(harvestError);
            }
    }
View Full Code Here

            if(log.isDebugEnabled()) log.debug("Search results:\n"+ Xml.getString(response));

      return response;
        } catch (BadSoapResponseEx e) {
            log.warning("Raised exception when searching : " + e.getMessage());
            this.errors.add(new HarvestError(e, log));
            throw new OperationAbortedEx("Raised exception when searching", e);
        } catch (BadXmlResponseEx e) {
            HarvestError harvestError = new HarvestError(e, log);
            harvestError.setDescription("Error while searching on "
                    + params.name + ". Excepted XML, returned: "
                    + e.getMessage());
            harvestError.setHint("Check with your administrator.");
            this.errors.add(harvestError);
            throw new OperationAbortedEx("Raised exception when searching", e);
        } catch (IOException e) {
            HarvestError harvestError = new HarvestError(e, log);
            harvestError.setDescription("Error while searching on "
                    + params.name + ". ");
            harvestError.setHint("Check with your administrator.");
            this.errors.add(harvestError);
            throw new OperationAbortedEx("Raised exception when searching", e);
        } catch(Exception e) {
            HarvestError harvestError = new HarvestError(e, log);
            harvestError.setDescription("Error while searching on "
                    + params.name + ". ");
            harvestError.setHint("Check with your administrator.");
            this.errors.add(harvestError);
            log.warning("Raised exception when searching : "+ e);
            return new Element("response");
    }
  }
View Full Code Here

TOP

Related Classes of org.fao.geonet.kernel.harvest.harvester.HarvestError

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.