Class GeoServerRESTImporter
- java.lang.Object
-
- de.terrestris.shoguncore.importer.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.URIaddEndPoint(java.lang.String endPoint)Add an endpoint.static java.io.FileaddPrjFileToArchive(java.io.File file, java.lang.String targetCrs)Add a projection file to a shapefile zip archive.protected java.lang.StringasJSON(java.lang.Object entity)Convert an object to json.booleancreateGdalAddOverviewTask(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 forgdaladdobooleancreateGdalTranslateTask(java.lang.Integer importJobId, java.lang.Integer importTaskId, java.util.List<java.lang.String> optsGdalTranslate)Create and append importer task forgdal_translatebooleancreateGdalWarpTask(java.lang.Integer importJobId, java.lang.Integer importTaskId, java.util.List<java.lang.String> optsGdalWarp)Create and append importer task forgdalwarpRESTImportcreateImportJob(java.lang.String workSpaceName, java.lang.String dataStoreName)Create a new import job.booleancreateReprojectTransformTask(java.lang.Integer importJobId, java.lang.Integer taskId, java.lang.String sourceSrs, java.lang.String targetSrs)Create a reprojection task.booleandeleteImportJob(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 jobRESTDatagetDataOfImportTask(java.lang.Integer importJobId, java.lang.Integer taskId)Get the data of an import task.RESTLayergetLayer(java.lang.Integer importJobId, java.lang.Integer taskId)Get a layer.RESTImportTaskgetRESTImportTask(java.lang.Integer importJobId, java.lang.Integer taskId)Get an import task.RESTImportTaskListgetRESTImportTasks(java.lang.Integer importJobId)booleanrunImportJob(java.lang.Integer importJobId)Run a previously configured import job.static java.lang.StringtoSingleLineWKT(org.opengis.referencing.crs.CoordinateReferenceSystem crs)Turns the CRS into a single line WKTbooleanupdateImportTask(int importJobId, int importTaskId, AbstractRESTEntity updateTaskEntity)Updates the given import task.booleanupdateLayerForImportTask(int importJobId, int importTaskId, AbstractRESTEntity updateTaskEntity)Update layer object for a given task of an import job (via PUT)RESTImportTaskListuploadFile(java.lang.Integer importJobId, java.io.File file, java.lang.String sourceSrs)Upload an import file.
-
-
-
Constructor Detail
-
GeoServerRESTImporter
public GeoServerRESTImporter()
-
GeoServerRESTImporter
public GeoServerRESTImporter(java.lang.String importerBaseURL, java.lang.String username, java.lang.String password) throws java.net.URISyntaxExceptionConstructs a new importer with values set.- Throws:
java.net.URISyntaxException
-
-
Method Detail
-
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.HttpExceptionCreate a reprojection task.- Throws:
java.net.URISyntaxExceptionorg.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.HttpExceptionCreate and append importer task forgdaladdo- Throws:
java.net.URISyntaxExceptionorg.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.HttpExceptionCreate and append importer task forgdalwarp- Throws:
java.net.URISyntaxExceptionorg.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.HttpExceptionCreate and append importer task forgdal_translate- Throws:
java.net.URISyntaxExceptionorg.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.ExceptionUpdates 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.HttpExceptionUpdate layer object for a given task of an import job (via PUT)- Parameters:
importJobId- The import job IDimportTaskId- The import task IDupdateTaskEntity- The entity to use for update- Returns:
- true if successful, false otherwise
- Throws:
java.net.URISyntaxExceptionorg.apache.http.HttpException
-
deleteImportJob
public boolean deleteImportJob(java.lang.Integer importJobId) throws java.net.URISyntaxException, org.apache.http.HttpExceptionDeletes an importJob.- Throws:
java.net.URISyntaxExceptionorg.apache.http.HttpException
-
runImportJob
public boolean runImportJob(java.lang.Integer importJobId) throws java.io.UnsupportedEncodingException, java.net.URISyntaxException, org.apache.http.HttpExceptionRun a previously configured import job.- Throws:
java.io.UnsupportedEncodingExceptionjava.net.URISyntaxExceptionorg.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
-
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.NoSuchAuthorityCodeException, org.opengis.referencing.FactoryExceptionAdd a projection file to a shapefile zip archive.- Throws:
net.lingala.zip4j.exception.ZipExceptionjava.io.IOExceptionorg.opengis.referencing.NoSuchAuthorityCodeExceptionorg.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
-
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.URISyntaxExceptionAdd an endpoint.- Throws:
java.net.URISyntaxException
-
-