Examples of PJsonObject


Examples of org.mapfish.print.utils.PJsonObject

    }

    public File generateThumbnail(String jsonConfig, Integer rotationAngle)
            throws IOException, DocumentException {

        PJsonObject specJson = MapPrinter.parseSpec(jsonConfig);
        if (Log.isDebugEnabled(LOGGER_NAME)) {
            Log.debug(LOGGER_NAME, "Generating thumbnail from config: " +
                jsonConfig);
        }
        final OutputFormat outputFormat =
View Full Code Here

Examples of org.mapfish.print.wrapper.json.PJsonObject

    }

    private static void setMapAttribute(final JSONObject attributes,
            final PJsonObject oldRequest, final Template template) throws JSONException {
        final CreateMapProcessor mapProcessor = getMapProcessor(template);
        final PJsonObject oldMapPage = (PJsonObject) getOldMapPage(oldRequest);

        if (mapProcessor == null) {
            if (oldMapPage == null) {
                // no map, no work
                return;
            } else {
                LOGGER.warn("The request json data has attribute information for creating the map but config does not have a" +
                            "map attribute.  Check that the request and the config.yaml are correct.");
                return;
            }
        } else if (oldMapPage == null) {
            LOGGER.warn("The request json data does not have attribute information for creating the map." +
                        "  Check that the request and the config.yaml are correct.");
            return;
        }

        String mapAttributeName = "map";
        if (mapProcessor.getInputMapperBiMap().containsValue("map")) {
            mapAttributeName = mapProcessor.getInputMapperBiMap().inverse().get("map");
        }

        final JSONObject map = new JSONObject();
        attributes.put(mapAttributeName, map);

        if (oldRequest.has("srs")) {
            map.put("projection", oldRequest.getString("srs"));
        }
        if (oldRequest.has("dpi")) {
            map.put("dpi", oldRequest.getInt("dpi"));
        }
        if (oldMapPage.has("rotation")) {
            map.put("rotation", oldMapPage.getDouble("rotation"));
        }
        if (oldMapPage.has("bbox")) {
            map.put("bbox", oldMapPage.getInternalObj().getJSONArray("bbox"));
        } else if (oldMapPage.has("center") && oldMapPage.has("scale")) {
            map.put("center", oldMapPage.getInternalObj().getJSONArray("center"));
            map.put("scale", oldMapPage.getDouble("scale"));
        }
        setMapLayers(map, oldRequest);
    }
View Full Code Here

Examples of org.mapfish.print.wrapper.json.PJsonObject

            return;
        }

        PArray oldLayers = oldRequest.getArray("layers");
        for (int i = oldLayers.size() - 1; i > -1; i--) {
            PJsonObject oldLayer = (PJsonObject) oldLayers.getObject(i);
            layers.put(OldAPILayerConverter.convert(oldLayer));
        }
    }
View Full Code Here

Examples of org.mapfish.print.wrapper.json.PJsonObject

     *   },
     */
    private static void setTableAttribute(final JSONObject attributes,
            final PJsonObject oldRequest, final Template template) throws JSONException {
        final TableProcessor tableProcessor = getTableProcessor(template);
        PJsonObject oldTablePage = (PJsonObject) getOldTablePage(oldRequest);

        if (tableProcessor == null) {
            if (oldTablePage == null) {
                // no table, no work
                return;
            } else {
                LOGGER.warn("The request json data has attribute information for creating the map but config does not have a" +
                            "map attribute.  Check that the request and the config.yaml are correct.");
                return;
            }
        } else if (oldTablePage == null) {
            LOGGER.warn("Configuration expects a table, but no table data is defined in the request");
            oldTablePage = new PJsonObject(oldRequest, new JSONObject(), "generated");
        }

        String tableAttributeName = "table";
        if (tableProcessor.getInputMapperBiMap().containsValue("table")) {
            tableAttributeName = tableProcessor.getInputMapperBiMap().inverse().get("table");
View Full Code Here

Examples of org.mapfish.print.wrapper.json.PJsonObject

        }
        return false;
    }

    private static List<String> getTableColumnKeys(final PJsonObject oldTablePage) {
        final PJsonObject table = oldTablePage.optJSONObject("table");
        final List<String> columnKeys = new LinkedList<String>();
        if (table != null) {
            final PArray columns = table.optArray("columns", new PJsonArray(table, new JSONArray(), "columns"));

            for (int i = 0; i < columns.size(); i++) {
                columnKeys.add(columns.getString(i));
            }
        }
View Full Code Here

Examples of org.mapfish.print.wrapper.json.PJsonObject

        return columnLabels;
    }

    private static List<JSONArray> getTableData(final List<String> columnKeys,
            final PJsonObject oldTablePage) {
        final PJsonObject table = oldTablePage.optJSONObject("table");

        final List<JSONArray> tableData = new LinkedList<JSONArray>();
        if (table != null) {
            final PArray oldTableRows = table.optArray("data", new PJsonArray(table, new JSONArray(), "data"));

            for (int i = 0; i < oldTableRows.size(); i++) {
                final PObject oldRow = oldTableRows.getObject(i);
                if (!oldRow.keys().hasNext()) {
                    // row is empty, skip
View Full Code Here

Examples of org.mapfish.print.wrapper.json.PJsonObject

            InterruptedException, NoSuchAppException, NoSuchReferenceException {
        if (SPEC_LOGGER.isInfoEnabled()) {
            SPEC_LOGGER.info("\nOLD-API:\n" + spec);
        }

        PJsonObject specJson = MapPrinterServlet.parseJson(spec, httpServletResponse);
        String appId;
        if (specJson.has("app")) {
            appId = specJson.getString("app");
        } else {
            appId = DEFAULT_CONFIGURATION_FILE_KEY;
        }
        MapPrinter mapPrinter = this.printerFactory.create(appId);
        PJsonObject updatedSpecJson = null;
        try {
            updatedSpecJson = OldAPIRequestConverter.convert(specJson, mapPrinter.getConfiguration());

            String format = updatedSpecJson.optString(MapPrinterServlet.JSON_OUTPUT_FORMAT, "pdf");
            final String jobReferenceId = this.primaryApiServlet.createAndSubmitPrintJob(appId, format,
                    updatedSpecJson.getInternalObj().toString(), httpServletRequest,
                    httpServletResponse);
            boolean isDone = false;
            while (!isDone) {
                Thread.sleep(HALF_SECOND);
                isDone = this.jobManager.isDone(jobReferenceId);
View Full Code Here

Examples of org.mapfish.print.wrapper.json.PJsonObject

                } else if (opt instanceof PYamlArray) {
                    opt = ((PYamlArray) opt).toJSON().getInternalArray();
                }
                json.put(key, opt);
            }
            return new PJsonObject(json, this.getContextName());
        } catch (Throwable e) {
            throw ExceptionUtils.getRuntimeException(e);
        }
    }
View Full Code Here

Examples of org.mapfish.print.wrapper.json.PJsonObject

     */
    public final String createAndSubmitPrintJob(final String appId, final String format, final String requestDataRaw,
                                           final HttpServletRequest httpServletRequest,
                                           final HttpServletResponse httpServletResponse) throws JSONException, NoSuchAppException {

        PJsonObject specJson = parseJson(requestDataRaw, httpServletResponse);
        if (specJson == null) {
            return null;
        }
        if (SPEC_LOGGER.isInfoEnabled()) {
            SPEC_LOGGER.info(specJson.toString());
        }

        specJson.getInternalObj().remove(JSON_OUTPUT_FORMAT);
        specJson.getInternalObj().put(JSON_OUTPUT_FORMAT, format);
        specJson.getInternalObj().remove(JSON_APP);
        specJson.getInternalObj().put(JSON_APP, appId);
        final JSONObject requestHeaders = getHeaders(httpServletRequest);
        if (requestHeaders.length() > 0) {
            specJson.getInternalObj().getJSONObject(JSON_ATTRIBUTES).put(JSON_REQUEST_HEADERS, requestHeaders);
        }
        String ref = UUID.randomUUID().toString() + "@" + this.servletInfo.getServletId();

        PrintJob job = this.context.getBean(PrintJob.class);

        job.setReferenceId(ref);
        job.setRequestData(specJson);
        job.setSecurityContext(SecurityContextHolder.getContext());

        // check that we have authorization and configure the job so it can only be access by users with sufficient authorization
        final String templateName = specJson.getString(Constants.JSON_LAYOUT_KEY);
        final MapPrinter mapPrinter = this.mapPrinterFactory.create(appId);
        final Template template = mapPrinter.getConfiguration().getTemplate(templateName);
        job.configureAccess(template);

        try {
View Full Code Here

Examples of org.mapfish.print.wrapper.json.PJsonObject

        if (oldRequest.has(JSON_OUTPUT_FORMAT)) {
            request.put(JSON_OUTPUT_FORMAT, oldRequest.getString(JSON_OUTPUT_FORMAT));
        }
        request.put(MapPrinterServlet.JSON_ATTRIBUTES, getAttributes(oldRequest, configuration.getTemplate(layout)));

        return new PJsonObject(request, "spec");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.