Package org.geoserver.importer

Examples of org.geoserver.importer.ImportTask


        Integer t = obj.integer("task");
        if (t == null) {
            throw new BadRequestException("Request must contain task identifier");
        }

        final ImportTask task = imp.task(t);
        if (task == null) {
            throw new NotFoundException("No such task: " + t + " for import: " + id);
        }

        ResourceInfo resource = task.getLayer().getResource();

        if (task.getState() == ImportTask.State.NO_CRS) {
            JSONObj proj = obj.object("proj");
            if (proj == null) {
                throw new BadRequestException("Request must contain a 'proj' property");
            }

            try {
                resource.setSRS(IO.srs(proj));
                resource.setNativeCRS(IO.crs(proj));
                importer.changed(task);
            }
            catch(Exception e) {
                throw new BadRequestException("Unable to parse proj: " + proj.toString());
            }
        }

        importer.run(imp, new ImportFilter() {
            @Override
            public boolean include(ImportTask t) {
                return task.getId() == t.getId();
            }
        });

        if (task.getState() == ImportTask.State.COMPLETE) {
            return complete(task);
        }
        else {
            switch(task.getState()) {
                case NO_CRS:
                case NO_BOUNDS:
                    return pending(task);
                case ERROR:
                    return failed(task);
View Full Code Here


    public void testSimpleMosaic() throws Exception {
        File dir = unpack("mosaic/bm.zip");
        ImportContext context = importer.createContext(new Mosaic(dir));
        assertEquals(1, context.getTasks().size());

        ImportTask task = context.getTasks().get(0);
        assertTrue(task.getData() instanceof Mosaic);
        assertTrue(task.getData().getFormat() instanceof MosaicFormat);

        importer.run(context);

        runChecks(dir.getName());
    }
View Full Code Here

        ft.setNativeBoundingBox(bounds);

        LayerInfo layer = catalog.getFactory().createLayer();
        layer.setResource(ft);

        ImportTask task = new ImportTask(data);
        task.setLayer(layer);

        task.getMetadata().put(FeatureType.class, featureType);

        return task;
    }
View Full Code Here

                new ItemLayerJSONFormat(MediaType.TEXT_HTML));
    }

    @Override
    public void handleGet() {
        ImportTask task = task();
        getResponse().setEntity(getFormatGet().toRepresentation(task.getLayer()));
    }
View Full Code Here

        return true;
    }

    @Override
    public void handlePut() {
        ImportTask task = task();

        LayerInfo layer = (LayerInfo) getFormatPostOrPut().toObject(getRequest().getEntity());
       
        updateLayer(task, layer, importer);
        importer.changed(task);
View Full Code Here

            formatGet = new ImportDataJSONFormat(MediaType.APPLICATION_JSON);
        }

        ImportData data = null;

        ImportTask task = task(true);
        if (task != null) {
            data = task.getData();
        }
        else {
            data = context().getData();
        }
View Full Code Here

        return getAttribute("task") != null;
    }

    @Override
    public void handleDelete() {
        ImportTask task = (ImportTask) lookupTask(false);
        task.getContext().removeTask(task);
        importer.changed(task.getContext());
        getResponse().setStatus(Status.SUCCESS_NO_CONTENT);
    }
View Full Code Here

        getResponse().setStatus(Status.SUCCESS_NO_CONTENT);
    }

   
    Object lookupTask(boolean allowAll) {
        ImportTask task = task(allowAll);

        if (task == null) {
            if (allowAll) {
                return context().getTasks();
            }
View Full Code Here

        }
        return task;
    }

    void handleTaskPut() {
        ImportTask orig = (ImportTask) lookupTask(false);
        ImportTask task;
        try {
            task = (ImportTask) getFormatPostOrPut().toObject(getRequest().getEntity());
        } catch (ValidationException ve) {
            getLogger().log(Level.WARNING, null, ve);
            throw ImportJSONWriter.badRequest(ve.getMessage());
        }

        boolean change = false;
        if (task.getStore() != null) {
            //JD: moved to TaskTargetResource, but handle here for backward compatability
            TaskTargetResource.updateStoreInfo(orig, task.getStore(), importer);
            change = true;
        }
        if (task.getData() != null) {
            //TODO: move this to data endpoint
            orig.getData().setCharsetEncoding(task.getData().getCharsetEncoding());
            change = true;
        }
        if (task.getUpdateMode() != null) {
            orig.setUpdateMode(task.getUpdateMode());
            change = orig.getUpdateMode() != task.getUpdateMode();
        }

        if (task.getLayer() != null) {
            change = true;
            //now handled by LayerResource, but handle here for backwards compatability
            LayerResource.updateLayer(orig, task.getLayer(), importer);
        }

        TransformChain chain = task.getTransform();
        if (chain != null) {
            orig.setTransform(chain);
            change = true;
        }
View Full Code Here

    }

    private Representation createProgressRepresentation() {
        JSONObject progress = new JSONObject();
        long imprt = Long.parseLong(getAttribute("import"));
        ImportTask inProgress = importer.getCurrentlyProcessingTask(imprt);
        try {
            if (inProgress != null) {
                progress.put("progress", inProgress.getNumberProcessed());
                progress.put("total", inProgress.getTotalToProcess());
                progress.put("state", inProgress.getState().toString());
            } else {
                ImportTask task = (ImportTask) lookupTask(false);
                progress.put("state", task.getState().toString());
                if (task.getState() == ImportTask.State.ERROR) {
                    if (task.getError() != null) {
                        progress.put("message", task.getError().getMessage());
                    }
                }
            }
        } catch (JSONException jex) {
            throw new RestletException("Internal Error", Status.SERVER_ERROR_INTERNAL, jex);
View Full Code Here

TOP

Related Classes of org.geoserver.importer.ImportTask

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.