Package org.openstreetmap.osmosis.core

Examples of org.openstreetmap.osmosis.core.OsmosisRuntimeException


            FixedPrecisionCoordinateConvertor.convertToDouble(dataInStream.readInt())
          );
        }
       
      } catch (IOException e) {
        throw new OsmosisRuntimeException("Unable to read node information from the node storage file.", e);
      }
    }
   
    return nodeLocation;
  }
View Full Code Here


   */
  public EntityType getEntityType(String memberType) {
    if (memberToEntityMap.containsKey(memberType)) {
      return memberToEntityMap.get(memberType);
    } else {
      throw new OsmosisRuntimeException("The member type " + memberType + " is not recognised.");
    }
  }
View Full Code Here

  private FileChannel openFileChannel(File file) {
    try {
      return new FileInputStream(file).getChannel();
    } catch (FileNotFoundException e) {
      throw new OsmosisRuntimeException("Unable to open file " + file, e);
    }
  }
View Full Code Here

  public void process(ChangeContainer changeContainer) {
    // If this is not the first entity in the pipeline, make sure this
    // entity is greater than the previous.
    if (previousChangeContainer != null) {
      if (comparator.compare(previousChangeContainer, changeContainer) >= 0) {
        throw new OsmosisRuntimeException(
          "Pipeline entities are not sorted or contain multiple versions of a single entity"
          + ", previous entity type=" + previousChangeContainer.getEntityContainer().getEntity().getType()
          + ", id=" + previousChangeContainer.getEntityContainer().getEntity().getId()
          + ", version=" + previousChangeContainer.getEntityContainer().getEntity().getVersion()
          + " current entity type=" + changeContainer.getEntityContainer().getEntity().getType()
View Full Code Here

      for (int bytesRead = 0; bytesRead < bytesToRead;) {
        int lastBytesRead = fileChannel.read(nioBuffer);

        // We always expect to read data.
        if (lastBytesRead < 0) {
          throw new OsmosisRuntimeException("Unexpectedly reached the end of the replication data file");
        }
        if (lastBytesRead == 0) {
          throw new OsmosisRuntimeException("Last read of the replication data file returned 0 bytes");
        }

        bytesRead += lastBytesRead;
      }

      // Create and return a Netty buffer.
      return ChannelBuffers.wrappedBuffer(rawBuffer);

    } catch (IOException e) {
      throw new OsmosisRuntimeException("Unable to read from the replication data file", e);
    }
  }
View Full Code Here

  private ChannelBuffer loadFile(File file) {
    FileChannel fileChannel = openFileChannel(file);

    try {
      if (fileChannel.size() > Integer.MAX_VALUE) {
        throw new OsmosisRuntimeException("Maximum file size supported is " + Integer.MAX_VALUE + " bytes");
      }

      // Determine the size of the file.
      int fileSize = (int) fileChannel.size();

      // Read the entire file.
      ChannelBuffer buffer = readFromFile(fileChannel, fileSize);

      // We no longer need access to the file.
      fileChannel.close();

      return buffer;

    } catch (IOException e) {
      throw new OsmosisRuntimeException("Unable to read from file " + file, e);
    } finally {
      try {
        fileChannel.close();
      } catch (IOException e) {
        LOG.log(Level.WARNING, "Unable to close channel for file " + file, e);
View Full Code Here

      }

      return buffer;

    } catch (IOException e) {
      throw new OsmosisRuntimeException("Unable to read from the replication data file", e);
    }
  }
View Full Code Here

   *            The task to be added.
   */
  public void putTask(String taskId, String pipeName, Task task) {
    // Verify that the output pipe is not already taken.
    if (namedTasks.containsKey(pipeName)) {
      throw new OsmosisRuntimeException("Task " + taskId
          + " cannot write to pipe " + pipeName
          + " because the pipe is already being written to.");
    }
   
    namedTasks.put(pipeName, task);
View Full Code Here

    final String dataContentType = "application/octet-stream";

    // Split the request Uri into its path elements.
    String uri = request.getUri();
    if (!uri.startsWith("/")) {
      throw new OsmosisRuntimeException("Uri doesn't start with a / character: " + uri);
    }
    Queue<String> uriElements = new LinkedList<String>(Arrays.asList(uri.split("/")));
    uriElements.remove(); // First element is empty due to leading '/'.

    // First element must be either the replication state or replication
View Full Code Here

   */
  public Task retrieveTask(String taskId, String pipeName, Class<? extends Task> requiredTaskType) {
    Task task;
   
    if (!namedTasks.containsKey(pipeName)) {
      throw new OsmosisRuntimeException(
          "No pipe named " + pipeName + " is available as input for task " + taskId + ".");
    }
   
    task = namedTasks.remove(pipeName);
   
    // Ensure the task is of the correct type.
    if (!verifyPipeType(requiredTaskType, task)) {
      throw new OsmosisRuntimeException(
          "Task " + taskId + " does not support data provided by input pipe " + pipeName + ".");
    }
   
    if (LOG.isLoggable(Level.FINE)) {
      LOG.fine("Task \"" + taskId + "\" consumed pipe \"" + pipeName + "\"");
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.