Package org.geoserver.importer

Examples of org.geoserver.importer.ImportContext


        getResponse().setStatus(Status.SUCCESS_NO_CONTENT);
    }
   
    private ImportContext createImport(Long id) {
        //create a new import
        ImportContext context;
        try {
            context = importer.createContext(id);

            if (MediaType.APPLICATION_JSON.equals(getRequest().getEntity().getMediaType())) {
                //read representation specified by user, use it to read
                ImportContext newContext =
                    (ImportContext) getFormatPostOrPut().toObject(getRequest().getEntity());

                WorkspaceInfo targetWorkspace = newContext.getTargetWorkspace();
                StoreInfo targetStore = newContext.getTargetStore();

                if (targetWorkspace != null) {
                    // resolve to the 'real' workspace
                    WorkspaceInfo ws = importer.getCatalog().getWorkspaceByName(
                            newContext.getTargetWorkspace().getName());
                    if (ws == null) {
                        throw new RestletException("Target workspace does not exist : "
                                + newContext.getTargetStore().getName(), Status.CLIENT_ERROR_BAD_REQUEST);

                    }
                    context.setTargetWorkspace(ws);
                }
                if (targetStore != null) {
                    StoreInfo ts = importer.getCatalog().getStoreByName(newContext.getTargetStore().getName(), StoreInfo.class);
                    if (ts == null) {
                        throw new RestletException("Target store does not exist : "
                                + newContext.getTargetStore().getName(), Status.CLIENT_ERROR_BAD_REQUEST);
                    }
                    context.setTargetStore(ts);
                }
                if (targetStore != null && targetWorkspace == null) {
                    //take it from the store
                    context.setTargetWorkspace(targetStore.getWorkspace());
                }

                context.setData(newContext.getData());
                if (newContext.getData() != null) {
                    importer.init(context, true);
                }
            }

            context.reattach(importer.getCatalog(), true);
View Full Code Here


    }
   
    @Override
    public void handlePost() {
        Object obj = lookupContext(true, true);
        ImportContext context = null;
        if (obj instanceof ImportContext) {
            //run an existing import
            try {
                runImport((ImportContext) obj);
            } catch (Throwable t) {
View Full Code Here

            try {
                id = new Long(i);
            } catch (NumberFormatException nfe) {
                throw new RestletException("Invalid ID : " + i, Status.CLIENT_ERROR_BAD_REQUEST);
            }
            ImportContext context = createImport(id);
            assert context.getId() >= id;
        } else {
            throw new RestletException("ID must be provided for PUT", Status.CLIENT_ERROR_BAD_REQUEST);
        }
    }
View Full Code Here

    }

    Object lookupContext(boolean allowAll, boolean mustExist) {
        String i = getAttribute("import");
        if (i != null) {
            ImportContext context = null;
            try {
                context = importer.getContext(Long.parseLong(i));
            } catch (NumberFormatException e) {
            }
            if (context == null && mustExist) {
View Full Code Here

TOP

Related Classes of org.geoserver.importer.ImportContext

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.