Class GeoServerRESTImporter
- java.lang.Object
-
- de.terrestris.shoguncore.importer.GeoServerRESTImporter
-
@Component public class GeoServerRESTImporter extends Object
- Author:
- Daniel Koch, terrestris GmbH & Co. KG
-
-
Constructor Summary
Constructors Constructor Description GeoServerRESTImporter()GeoServerRESTImporter(String importerBaseURL, String username, 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 URIaddEndPoint(String endPoint)Add an endpoint.static FileaddPrjFileToArchive(File file, String targetCrs)Add a projection file to a shapefile zip archive.protected StringasJSON(Object entity)Convert an object to json.booleancreateGdalAddOverviewTask(Integer importJobId, Integer importTaskId, List<String> opts, List<Integer> levels)Create and append importer task forgdaladdobooleancreateGdalTranslateTask(Integer importJobId, Integer importTaskId, List<String> optsGdalTranslate)Create and append importer task forgdal_translatebooleancreateGdalWarpTask(Integer importJobId, Integer importTaskId, List<String> optsGdalWarp)Create and append importer task forgdalwarpRESTImportcreateImportJob(String workSpaceName, String dataStoreName)Create a new import job.booleancreateReprojectTransformTask(Integer importJobId, Integer taskId, String sourceSrs, String targetSrs)Create a reprojection task.booleandeleteImportJob(Integer importJobId)Deletes an importJob.List<RESTLayer>getAllImportedLayers(Integer importJobId, List<RESTImportTask> tasks)fetch all created Layers of import jobRESTDatagetDataOfImportTask(Integer importJobId, Integer taskId)Get the data of an import task.RESTLayergetLayer(Integer importJobId, Integer taskId)Get a layer.RESTImportTaskgetRESTImportTask(Integer importJobId, Integer taskId)Get an import task.RESTImportTaskListgetRESTImportTasks(Integer importJobId)booleanrunImportJob(Integer importJobId)Run a previously configured import job.static 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(Integer importJobId, File file, String sourceSrs)Upload an import file.
-
-
-
Constructor Detail
-
GeoServerRESTImporter
public GeoServerRESTImporter()
-
GeoServerRESTImporter
public GeoServerRESTImporter(String importerBaseURL, String username, String password) throws URISyntaxException
Constructs a new importer with values set.- Throws:
URISyntaxException
-
-
Method Detail
-
addPrjFileToArchive
public static File addPrjFileToArchive(File file, String targetCrs) throws net.lingala.zip4j.exception.ZipException, IOException, org.opengis.referencing.FactoryException
Add a projection file to a shapefile zip archive.- Throws:
net.lingala.zip4j.exception.ZipExceptionIOExceptionorg.opengis.referencing.FactoryException
-
toSingleLineWKT
public static 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(String workSpaceName, String dataStoreName) throws Exception
Create a new import job.- Throws:
Exception
-
createReprojectTransformTask
public boolean createReprojectTransformTask(Integer importJobId, Integer taskId, String sourceSrs, String targetSrs) throws URISyntaxException, org.apache.http.HttpException
Create a reprojection task.- Throws:
URISyntaxExceptionorg.apache.http.HttpException
-
createGdalAddOverviewTask
public boolean createGdalAddOverviewTask(Integer importJobId, Integer importTaskId, List<String> opts, List<Integer> levels) throws URISyntaxException, org.apache.http.HttpException
Create and append importer task forgdaladdo- Throws:
URISyntaxExceptionorg.apache.http.HttpException
-
createGdalWarpTask
public boolean createGdalWarpTask(Integer importJobId, Integer importTaskId, List<String> optsGdalWarp) throws URISyntaxException, org.apache.http.HttpException
Create and append importer task forgdalwarp- Throws:
URISyntaxExceptionorg.apache.http.HttpException
-
createGdalTranslateTask
public boolean createGdalTranslateTask(Integer importJobId, Integer importTaskId, List<String> optsGdalTranslate) throws URISyntaxException, org.apache.http.HttpException
Create and append importer task forgdal_translate- Throws:
URISyntaxExceptionorg.apache.http.HttpException
-
uploadFile
public RESTImportTaskList uploadFile(Integer importJobId, File file, String sourceSrs) throws Exception
Upload an import file.- Throws:
Exception
-
updateImportTask
public boolean updateImportTask(int importJobId, int importTaskId, AbstractRESTEntity updateTaskEntity) throws ExceptionUpdates the given import task.- Throws:
Exception
-
updateLayerForImportTask
public boolean updateLayerForImportTask(int importJobId, int importTaskId, AbstractRESTEntity updateTaskEntity) throws 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:
URISyntaxExceptionorg.apache.http.HttpException
-
deleteImportJob
public boolean deleteImportJob(Integer importJobId) throws URISyntaxException, org.apache.http.HttpException
Deletes an importJob.- Throws:
URISyntaxExceptionorg.apache.http.HttpException
-
runImportJob
public boolean runImportJob(Integer importJobId) throws UnsupportedEncodingException, URISyntaxException, org.apache.http.HttpException
Run a previously configured import job.- Throws:
UnsupportedEncodingExceptionURISyntaxExceptionorg.apache.http.HttpException
-
getLayer
public RESTLayer getLayer(Integer importJobId, Integer taskId) throws Exception
Get a layer.- Throws:
Exception
-
getAllImportedLayers
public List<RESTLayer> getAllImportedLayers(Integer importJobId, List<RESTImportTask> tasks) throws Exception
fetch all created Layers of import job- Throws:
Exception
-
getDataOfImportTask
public RESTData getDataOfImportTask(Integer importJobId, Integer taskId) throws Exception
Get the data of an import task.- Throws:
Exception
-
getRESTImportTask
public RESTImportTask getRESTImportTask(Integer importJobId, Integer taskId) throws Exception
Get an import task.- Throws:
Exception
-
getRESTImportTasks
public RESTImportTaskList getRESTImportTasks(Integer importJobId) throws Exception
- Parameters:
importJobId-- Throws:
Exception
-
addEndPoint
protected URI addEndPoint(String endPoint) throws URISyntaxException
Add an endpoint.- Throws:
URISyntaxException
-
-