Package org.openstreetmap.osmosis.core

Examples of org.openstreetmap.osmosis.core.OsmosisRuntimeException


        @Override
        public void process(EntityContainer entityContainer) {
            if (progressListener.isCanceled()) {
                target.cancel();
                throw new OsmosisRuntimeException("Cancelled by user");
            }
            Entity entity = entityContainer.getEntity();
            if (++count % 10 == 0) {
                progressListener.setProgress(count);
            }
View Full Code Here


        @Override
        public void process(ChangeContainer container) {
            if (progressListener.isCanceled()) {
                target.cancel();
                throw new OsmosisRuntimeException("Cancelled by user");
            }
            final EntityContainer entityContainer = container.getEntityContainer();
            final Entity entity = entityContainer.getEntity();
            final ChangeAction changeAction = container.getAction();
            if (changeAction.equals(ChangeAction.Delete)) {
View Full Code Here

    private SAXParser createParser() {
        try {
            return SAXParserFactory.newInstance().newSAXParser();

        } catch (ParserConfigurationException e) {
            throw new OsmosisRuntimeException("Unable to create SAX Parser.", e);
        } catch (SAXException e) {
            throw new OsmosisRuntimeException("Unable to create SAX Parser.", e);
        }
    }
View Full Code Here

            parser.parse(inputStream, new OsmHandler(sink, enableDateParsing));

            sink.complete();

        } catch (SAXParseException e) {
            throw new OsmosisRuntimeException("Unable to parse xml file " + file + ".  publicId=("
                    + e.getPublicId() + "), systemId=(" + e.getSystemId() + "), lineNumber="
                    + e.getLineNumber() + ", columnNumber=" + e.getColumnNumber() + ".", e);
        } catch (SAXException e) {
            throw new OsmosisRuntimeException("Unable to parse XML.", e);
        } catch (IOException e) {
            throw new OsmosisRuntimeException("Unable to read XML file " + file + ".", e);
        } finally {
            sink.release();

            if (inputStream != null) {
                try {
View Full Code Here

    reader.run();

    // Delete the destination file if it already exists.
    if (file.exists()) {
      if (!file.delete()) {
        throw new OsmosisRuntimeException("Unable to delete existing file " + file + ".");
      }
    }

    // Rename the temporary file to the final file name.
    if (!tmpFile.renameTo(file)) {
      throw new OsmosisRuntimeException("Unable to rename temporary file " + tmpFile + " to " + file + ".");
    }
  }
View Full Code Here

      Osmformat.HeaderBlock message = headerblock.build();
      try {
          output.write(FileBlock.newInstance("OSMHeader", message
                  .toByteString(), null));
      } catch (IOException e) {
          throw new OsmosisRuntimeException("Unable to write OSM header.", e);
      }
      headerWritten = true;
    }
View Full Code Here

    jndiLocation = credentials.getDatasourceJndiLocation();
   
    try {
      cxt = new InitialContext();
    } catch (NamingException e) {
      throw new OsmosisRuntimeException("Unable to create an initial JNDI context.", e);
    }
   
    try {
      dataSource = (DataSource) cxt.lookup(jndiLocation);
    } catch (NamingException e) {
      throw new OsmosisRuntimeException("Unable to locate the datasource (" + jndiLocation + ")", e);
    }
  }
View Full Code Here

    try {
      // Register the database driver.
      try {
        Class.forName("org.postgresql.Driver");
      } catch (ClassNotFoundException e) {
        throw new OsmosisRuntimeException("Unable to find database driver.", e);
      }
     
      return DriverManager.getConnection(
        "jdbc:postgresql://" + credentials.getHost() + "/"
        + credentials.getDatabase(),
          // + "?logLevel=2"
        credentials.getUser(),
        credentials.getPassword()
        );
     
    } catch (SQLException e) {
      throw new OsmosisRuntimeException("Unable to establish a new database connection.", e);
    }
  }
View Full Code Here

      connection = createConnectionFromDriverManager();
    } else {
      try {
        connection = dataSource.getConnection();
      } catch (SQLException e) {
        throw new OsmosisRuntimeException("Unable to obtain a connection from the datasource.", e);
      }
    }
   
    return connection;
  }
View Full Code Here

   * Performs any validation and pre-processing required for all entity types.
   */
  private void processEntityPrerequisites(Entity entity) {
    // We can't write an entity with a null timestamp.
    if (entity.getTimestamp() == null) {
      throw new OsmosisRuntimeException("Entity(" + entity.getType()
          + ") " + entity.getId() + " does not have a timestamp set.");
    }
   
    // Process the user data.
    writeUser(entity.getUser());
View Full Code Here

TOP

Related Classes of org.openstreetmap.osmosis.core.OsmosisRuntimeException

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.