Class UploadBuilder

java.lang.Object
nl.bimbase.bimworks.client.upload.UploadBuilder

public class UploadBuilder extends Object
A convenient builder to construct the arguments for uploading a model
  • Constructor Details

    • UploadBuilder

      public UploadBuilder(UUID nodeUuid)
      Create a new UploadBuilder
      Parameters:
      nodeUuid - The UUID of the Node that you intend to upload to
  • Method Details

    • fromPath

      public UploadBuilder fromPath(Path path) throws UploadBuilderException
      Instruct the UploadBuilder to read the actual data from the given Path
      Parameters:
      path - The Path on which to find the data to upload
      Returns:
      Returns the UploadBuilder (this)
      Throws:
      UploadBuilderException - Will be thrown when a data source had already been provided
    • fromFile

      public UploadBuilder fromFile(File file) throws UploadBuilderException
      Instruct the UploadBuilder to read the actual data from the given File
      Parameters:
      file - The File in which to find the data to upload
      Returns:
      Returns the UploadBuilder (this)
      Throws:
      UploadBuilderException - Will be thrown when a data source had already been provided
    • fromInputStream

      public UploadBuilder fromInputStream(InputStream inputStream, long filesize) throws UploadBuilderException
      Instruct the UploadBuilder to read the actual data from the given InputStream. The client will always read and send the full stream, regardless of the provided filesize.
      Parameters:
      inputStream - The stream to take the data from, called stays responsible for closing the InputStream.
      filesize - The size in bytes of the data that is provided.
      Returns:
      Returns the UploadBuilder (this)
      Throws:
      UploadBuilderException - Will be thrown when a data source had already been provided
    • fromInputStreamNoCheck

      public UploadBuilder fromInputStreamNoCheck(InputStream inputStream, long filesize) throws UploadBuilderException
      Instruct the UploadBuilder to read the actual data from the given InputStream. The client will always read and send the full stream, regardless of the provided filesize. This implementation does not check for previous data set on the UploadBuilder and will overwrite it.
      Parameters:
      inputStream - The stream to take the data from, called stays responsible for closing the InputStream.
      filesize - The size in bytes of the data that is provided.
      Returns:
      Returns the UploadBuilder (this)
      Throws:
      UploadBuilderException - Will be thrown when a data source had already been provided
    • fromInputStream

      public UploadBuilder fromInputStream(InputStream inputStream) throws UploadBuilderException
      Instruct the UploadBuilder to read the actual data from the given InputStream.
      Parameters:
      inputStream - The stream to take the data from, called stays responsible for closing the InputStream.
      Returns:
      Returns the UploadBuilder (this)
      Throws:
      UploadBuilderException - Will be thrown when a data source had already been provided
    • fromBytes

      public UploadBuilder fromBytes(byte[] bytes) throws UploadBuilderException
      Instruct the UploadBuilder to read the actual data from the given byte[]. NoteKeep in mind that sending around large byte[] could cause heap size issues, if possible prefer reading from fromFile(java.io.File), fromPath(java.nio.file.Path) or fromInputStream(java.io.InputStream,long)
      Parameters:
      bytes - The data as a byte[]
      Returns:
      Returns the UploadBuilder (this)
      Throws:
      UploadBuilderException - Will be thrown when a data source had already been provided
    • url

      public UploadBuilder url(URL url) throws UploadBuilderException
      Instruct the UploadBuilder to read the actual data from the given URL. This method will store the data in the default tmp location, and then send the data to the BIM.works Repository. Use urlPassThrough to actually send the URL to BIM.works Repository and let the repository download the data. This can be a more efficient way to pass large models to the BIM.works repository (for example from S3, Azure Blob Storage etc...). Please note that this method will download the full file to tmp storage first, so it can be very inefficient
      Parameters:
      url - A URL to the location of the data
      Returns:
      Returns the UploadBuilder (this)
      Throws:
      UploadBuilderException - Will be thrown when a data source had already been provided
    • urlPassThrough

      public UploadBuilder urlPassThrough(URL url, long filesize) throws UploadBuilderException
      Instruct the UploadBuilder to pass the given URL to the BIM.works Repository and to start processing it. This method will send the URL itself to the BIM.works Repository (pass through). This can be useful when your data is not stored on your application server (or client) but for example on AWS S3, Azure Blob Storage or a similar storage solution. When using this method make sure that: - The host in the URL can be resolved (DNS) from the BIM.works Repository location - The host in the URL can be reached (routed) from the BIM.works Repository location - The URL includes the proper authentication. On AWS S3 you can use pre-signed URLs, on Azure Blob Storage you can use Shared Access Signatures (SAS) - You provide a filename, often this cannot be inferred from the URL. This method is agnostic of any storage provider, although examples are given for S3 and Azure Blob Storage.
      Parameters:
      url - A URL to the location of the data
      filesize - Since it is not guaranteed that the data-sending server will include a Content-Length, and for verification purposes, the size of the file must always be specified when using this method
      Returns:
      Returns the UploadBuilder (this)
      Throws:
      UploadBuilderException - Will be thrown when a data source had already been provided
    • from

      public UploadBuilder from(com.google.common.io.ByteSource byteSource) throws UploadBuilderException
      Instruct the UploadBuilder to read the actual data from the given ByteSource (From the Google Guava library)
      Parameters:
      byteSource - The ByteSource to read the data from
      Returns:
      Returns the UploadBuilder (this)
      Throws:
      UploadBuilderException - Will be thrown when a data source had already been provided
    • getNodeUuid

      public UUID getNodeUuid()
      Returns:
      The UUID of the Node the data will be uploaded to
    • getPath

      public Path getPath()
      Returns:
      The currently set Path
    • getFilename

      public String getFilename()
      Returns:
      The currently set filename
    • determineFilename

      public String determineFilename()
      Determines the filename from the data given so far, generally not required to call this manually.
      Returns:
      The determined filename
    • determineFilesize

      public long determineFilesize() throws IOException
      Determines the filesize from the given data so far, generally not required to call this manually
      Returns:
      The determined filesize
      Throws:
      IOException
    • option

      public UploadBuilder option(UploadOption uploadOption)
      Deprecated.
      This will be removed in the future
      Provide additional upload options.
      Parameters:
      uploadOption -
      Returns:
    • getUploadOption

      public UploadOption getUploadOption()
    • getUrl

      public URL getUrl()
    • getTimeOutUnit

      public TimeUnit getTimeOutUnit()
    • getTimeOutValue

      public long getTimeOutValue()
    • timeOut

      public UploadBuilder timeOut(long timeOutValue, TimeUnit timeOutUnit)
    • getInputStream

      public InputStream getInputStream()
      Returns:
      The currently configured InputStream
    • getContentType

      public String getContentType()
      Returns:
      The currently configured Content-Type
    • setContentType

      public void setContentType(String contentType)
      Manually set the Content-Type
      Parameters:
      contentType - The Content-Type, should be in the same format as HTTP Header Content-Type
    • filename

      public UploadBuilder filename(String filename)
      Sets the filename. Note This is not a method to provide the data, it only set's the name of the file for meta-data purposes
      Parameters:
      filename - The filename of the model
      Returns:
      UploadBuilder (this)
    • forceReprocessing

      public UploadBuilder forceReprocessing(boolean forceReprocessing)
    • isForceReprocessing

      public boolean isForceReprocessing()
    • getByteSource

      public com.google.common.io.ByteSource getByteSource()
      Returns:
      The currently set ByteSource
    • progressListener

      public UploadBuilder progressListener(nl.sascom.backplane.common.ProgressListener progressListener)
      Attach a progress listener, for feedback on the progress of the upload once it has started. Only one progress listener can be set, calling this method twice will overwrite the previous listener
      Parameters:
      progressListener - The listener that should be called
      Returns:
      UploadBuilder (this)
    • getProgressListener

      public nl.sascom.backplane.common.ProgressListener getProgressListener()
      Returns:
      The currently attached progress listener or null
    • suppressDebugMessages

      public UploadBuilder suppressDebugMessages(boolean suppressDebugMessages)
      Instruct BIM.works Repository to suppress any debug messages. Currently does not do anything
      Parameters:
      suppressDebugMessages -
      Returns:
    • isSuppressDebugMessages

      public boolean isSuppressDebugMessages()
      Returns:
      Whether debug messages are currently suppressed
    • validationLevel

      public UploadBuilder validationLevel(nl.bimbase.bimworks.api.render.ValidationLevel validationLevel)
      Set the validation level. This allows you to instruct BIM.works on how strict the model should be validated. This is only IFC-level validation, for model checking please refer to ModelChecksApi The default validation level is ValidationLevel.DEFAULT
      Parameters:
      validationLevel - The validation level to use
      Returns:
      UploadBuilder (this)
    • getValidationLevel

      public nl.bimbase.bimworks.api.render.ValidationLevel getValidationLevel()
      Returns:
      The currently set validation level
    • getUrlPassThrough

      public URL getUrlPassThrough()
      Returns:
      Any currently set passthrough URL
    • filesize

      public UploadBuilder filesize(long filesize)
      Set the filesize manually. Generally this is not required and will be done automatically, but for example for urlPassThrough uploads this is required.
      Parameters:
      filesize - The size of the file in bytes
      Returns:
      UploadBuilder (this)
    • explicitCompression

      public UploadBuilder explicitCompression(nl.sascom.backplane.common.CompressionType explicitCompressionType)
    • getExplicitCompressionType

      public nl.sascom.backplane.common.CompressionType getExplicitCompressionType()