Class GeoServerRESTImporter


  • @Component
    public class GeoServerRESTImporter
    extends java.lang.Object
    Author:
    Daniel Koch, terrestris GmbH & Co. KG
    • Constructor Summary

      Constructors 
      Constructor Description
      GeoServerRESTImporter()  
      GeoServerRESTImporter​(java.lang.String importerBaseURL, java.lang.String username, java.lang.String password)
      Constructs a new importer with values set.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.net.URI addEndPoint​(java.lang.String endPoint)
      Add an endpoint.
      static java.io.File addPrjFileToArchive​(java.io.File file, java.lang.String targetCrs)
      Add a projection file to a shapefile zip archive.
      protected java.lang.String asJSON​(java.lang.Object entity)
      Convert an object to json.
      boolean createGdalAddOverviewTask​(java.lang.Integer importJobId, java.lang.Integer importTaskId, java.util.List<java.lang.String> opts, java.util.List<java.lang.Integer> levels)
      Create and append importer task for gdaladdo
      boolean createGdalTranslateTask​(java.lang.Integer importJobId, java.lang.Integer importTaskId, java.util.List<java.lang.String> optsGdalTranslate)
      Create and append importer task for gdal_translate
      boolean createGdalWarpTask​(java.lang.Integer importJobId, java.lang.Integer importTaskId, java.util.List<java.lang.String> optsGdalWarp)
      Create and append importer task for gdalwarp
      RESTImport createImportJob​(java.lang.String workSpaceName, java.lang.String dataStoreName)
      Create a new import job.
      boolean createReprojectTransformTask​(java.lang.Integer importJobId, java.lang.Integer taskId, java.lang.String sourceSrs, java.lang.String targetSrs)
      Create a reprojection task.
      boolean deleteImportJob​(java.lang.Integer importJobId)
      Deletes an importJob.
      java.util.List<RESTLayer> getAllImportedLayers​(java.lang.Integer importJobId, java.util.List<RESTImportTask> tasks)
      fetch all created Layers of import job
      RESTData getDataOfImportTask​(java.lang.Integer importJobId, java.lang.Integer taskId)
      Get the data of an import task.
      RESTLayer getLayer​(java.lang.Integer importJobId, java.lang.Integer taskId)
      Get a layer.
      RESTImportTask getRESTImportTask​(java.lang.Integer importJobId, java.lang.Integer taskId)
      Get an import task.
      RESTImportTaskList getRESTImportTasks​(java.lang.Integer importJobId)  
      boolean runImportJob​(java.lang.Integer importJobId)
      Run a previously configured import job.
      static java.lang.String toSingleLineWKT​(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
      Turns the CRS into a single line WKT
      boolean updateImportTask​(int importJobId, int importTaskId, AbstractRESTEntity updateTaskEntity)
      Updates the given import task.
      boolean updateLayerForImportTask​(int importJobId, int importTaskId, AbstractRESTEntity updateTaskEntity)
      Update layer object for a given task of an import job (via PUT)
      RESTImportTaskList uploadFile​(java.lang.Integer importJobId, java.io.File file, java.lang.String sourceSrs)
      Upload an import file.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GeoServerRESTImporter

        public GeoServerRESTImporter()
      • GeoServerRESTImporter

        public GeoServerRESTImporter​(java.lang.String importerBaseURL,
                                     java.lang.String username,
                                     java.lang.String password)
                              throws java.net.URISyntaxException
        Constructs a new importer with values set.
        Throws:
        java.net.URISyntaxException
    • Method Detail

      • addPrjFileToArchive

        public static java.io.File addPrjFileToArchive​(java.io.File file,
                                                       java.lang.String targetCrs)
                                                throws net.lingala.zip4j.exception.ZipException,
                                                       java.io.IOException,
                                                       org.opengis.referencing.FactoryException
        Add a projection file to a shapefile zip archive.
        Throws:
        net.lingala.zip4j.exception.ZipException
        java.io.IOException
        org.opengis.referencing.FactoryException
      • toSingleLineWKT

        public static java.lang.String toSingleLineWKT​(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
        Turns the CRS into a single line WKT
        Parameters:
        crs - CoordinateReferenceSystem which should be formatted
        Returns:
        Single line String which can be written to PRJ file
      • createImportJob

        public RESTImport createImportJob​(java.lang.String workSpaceName,
                                          java.lang.String dataStoreName)
                                   throws java.lang.Exception
        Create a new import job.
        Throws:
        java.lang.Exception
      • createReprojectTransformTask

        public boolean createReprojectTransformTask​(java.lang.Integer importJobId,
                                                    java.lang.Integer taskId,
                                                    java.lang.String sourceSrs,
                                                    java.lang.String targetSrs)
                                             throws java.net.URISyntaxException,
                                                    org.apache.http.HttpException
        Create a reprojection task.
        Throws:
        java.net.URISyntaxException
        org.apache.http.HttpException
      • createGdalAddOverviewTask

        public boolean createGdalAddOverviewTask​(java.lang.Integer importJobId,
                                                 java.lang.Integer importTaskId,
                                                 java.util.List<java.lang.String> opts,
                                                 java.util.List<java.lang.Integer> levels)
                                          throws java.net.URISyntaxException,
                                                 org.apache.http.HttpException
        Create and append importer task for gdaladdo
        Throws:
        java.net.URISyntaxException
        org.apache.http.HttpException
      • createGdalWarpTask

        public boolean createGdalWarpTask​(java.lang.Integer importJobId,
                                          java.lang.Integer importTaskId,
                                          java.util.List<java.lang.String> optsGdalWarp)
                                   throws java.net.URISyntaxException,
                                          org.apache.http.HttpException
        Create and append importer task for gdalwarp
        Throws:
        java.net.URISyntaxException
        org.apache.http.HttpException
      • createGdalTranslateTask

        public boolean createGdalTranslateTask​(java.lang.Integer importJobId,
                                               java.lang.Integer importTaskId,
                                               java.util.List<java.lang.String> optsGdalTranslate)
                                        throws java.net.URISyntaxException,
                                               org.apache.http.HttpException
        Create and append importer task for gdal_translate
        Throws:
        java.net.URISyntaxException
        org.apache.http.HttpException
      • uploadFile

        public RESTImportTaskList uploadFile​(java.lang.Integer importJobId,
                                             java.io.File file,
                                             java.lang.String sourceSrs)
                                      throws java.lang.Exception
        Upload an import file.
        Throws:
        java.lang.Exception
      • updateImportTask

        public boolean updateImportTask​(int importJobId,
                                        int importTaskId,
                                        AbstractRESTEntity updateTaskEntity)
                                 throws java.lang.Exception
        Updates the given import task.
        Throws:
        java.lang.Exception
      • updateLayerForImportTask

        public boolean updateLayerForImportTask​(int importJobId,
                                                int importTaskId,
                                                AbstractRESTEntity updateTaskEntity)
                                         throws java.net.URISyntaxException,
                                                org.apache.http.HttpException
        Update layer object for a given task of an import job (via PUT)
        Parameters:
        importJobId - The import job ID
        importTaskId - The import task ID
        updateTaskEntity - The entity to use for update
        Returns:
        true if successful, false otherwise
        Throws:
        java.net.URISyntaxException
        org.apache.http.HttpException
      • deleteImportJob

        public boolean deleteImportJob​(java.lang.Integer importJobId)
                                throws java.net.URISyntaxException,
                                       org.apache.http.HttpException
        Deletes an importJob.
        Throws:
        java.net.URISyntaxException
        org.apache.http.HttpException
      • runImportJob

        public boolean runImportJob​(java.lang.Integer importJobId)
                             throws java.io.UnsupportedEncodingException,
                                    java.net.URISyntaxException,
                                    org.apache.http.HttpException
        Run a previously configured import job.
        Throws:
        java.io.UnsupportedEncodingException
        java.net.URISyntaxException
        org.apache.http.HttpException
      • getLayer

        public RESTLayer getLayer​(java.lang.Integer importJobId,
                                  java.lang.Integer taskId)
                           throws java.lang.Exception
        Get a layer.
        Throws:
        java.lang.Exception
      • getAllImportedLayers

        public java.util.List<RESTLayer> getAllImportedLayers​(java.lang.Integer importJobId,
                                                              java.util.List<RESTImportTask> tasks)
                                                       throws java.lang.Exception
        fetch all created Layers of import job
        Throws:
        java.lang.Exception
      • getDataOfImportTask

        public RESTData getDataOfImportTask​(java.lang.Integer importJobId,
                                            java.lang.Integer taskId)
                                     throws java.lang.Exception
        Get the data of an import task.
        Throws:
        java.lang.Exception
      • getRESTImportTask

        public RESTImportTask getRESTImportTask​(java.lang.Integer importJobId,
                                                java.lang.Integer taskId)
                                         throws java.lang.Exception
        Get an import task.
        Throws:
        java.lang.Exception
      • getRESTImportTasks

        public RESTImportTaskList getRESTImportTasks​(java.lang.Integer importJobId)
                                              throws java.lang.Exception
        Parameters:
        importJobId -
        Throws:
        java.lang.Exception
      • asJSON

        protected java.lang.String asJSON​(java.lang.Object entity)
        Convert an object to json.
      • addEndPoint

        protected java.net.URI addEndPoint​(java.lang.String endPoint)
                                    throws java.net.URISyntaxException
        Add an endpoint.
        Throws:
        java.net.URISyntaxException