Package org.jbpm.formapi.shared.form

Examples of org.jbpm.formapi.shared.form.FormRepresentationDecoder


        }
        return null;
    }
   
    private static FormRepresentation toForm(String json) throws FormEncodingException {
        FormRepresentationDecoder decoder = FormEncodingFactory.getDecoder();
        FormRepresentation form = decoder.decode(json);
        return form;
    }
View Full Code Here


    @POST @Path("/definitions/package/{pkgName}")
    @Consumes("text/plain")
    @DoNotUseJAXBProvider
    public Response saveForm(String jsonBody, @PathParam("pkgName") String pkgName, @Context HttpServletRequest request) {
        setContext(request.getSession().getServletContext());
        FormRepresentationDecoder decoder = FormEncodingFactory.getDecoder();
        try {
            FormRepresentation form = decoder.decode(jsonBody);
            String formId = formService.saveForm(pkgName, form);
            return Response.ok("<formId>"+formId+"</formId>", MediaType.APPLICATION_XML).
                status(Status.CREATED).build();
        } catch (FormEncodingException e) {
            return error("Problem decoding form", e);
View Full Code Here

    @DoNotUseJAXBProvider
    public Response saveFormItem(String jsonBody,
            @PathParam("pkgName") String pkgName,
            @PathParam("fItemName") String formItemName, @Context HttpServletRequest request) {
        setContext(request.getSession().getServletContext());
        FormRepresentationDecoder decoder = FormEncodingFactory.getDecoder();
        try {
            FormItemRepresentation item = decoder.decodeItem(jsonBody);
            String formItemId = formService.saveFormItem(pkgName, formItemName, item);
            return Response.ok("<formItemId>"+formItemId+"</formItemId>",
                    MediaType.APPLICATION_XML).status(Status.CREATED).build();
        } catch (FormEncodingException e) {
            return error("Problem encoding form item", e);
View Full Code Here

        return url;
    }
   
   
    private URL createTemplate(String language, FormPreviewDTO dto) throws FormEncodingException, TranslatorException {
        FormRepresentationDecoder decoder = FormEncodingFactory.getDecoder();
        String json = dto.getRepresentation();
        FormRepresentation form = decoder.decode(json);
        dto.setForm(form);
        Translator translator = getTranslator(language);
        URL url = translator.translateForm(form);
        return url;
    }
View Full Code Here

     */
    public List<FormRepresentation> readForms(String responseText) {
        Document xml = XMLParser.parse(responseText);
        NodeList list = xml.getElementsByTagName("json");
        List<FormRepresentation> retval = new ArrayList<FormRepresentation>();
        FormRepresentationDecoder decoder = FormEncodingFactory.getDecoder();
        if (list != null) {
            for (int index = 0; index < list.getLength(); index++) {
                Node node = list.item(index);
                String json = getText(node);
                try {
                    FormRepresentation form = decoder.decode(json);
                    retval.add(form);
                } catch (FormEncodingException e) {
                    FormRepresentation error = new FormRepresentation();
                    error.setName(i18n.Error(e.getLocalizedMessage()));
                    retval.add(error);
View Full Code Here

        NodeList list = ((Element) itemNode).getElementsByTagName("itemJson");
        FormItemRepresentation rep = null;
        if (list.getLength() > 0) {
            Node node = list.item(0);
            String json = getText(node);
            FormRepresentationDecoder decoder = FormEncodingFactory.getDecoder();
            rep = (FormItemRepresentation) decoder.decodeItem(json);
        }
        return rep;
    }
View Full Code Here

    @Override
    public Map<String, List<MenuItemDescription>> listMenuItems() throws MenuServiceException {
        Map<String, List<MenuItemDescription>> retval = null;
        try {
            FormRepresentationDecoder decoder = FormEncodingFactory.getDecoder();
            URL url = asURL("/menuItems.json");
            String json = readURL(url);
            retval = decoder.decodeMenuItemsMap(json);
        } catch (FormEncodingException e) {
            throw new MenuServiceException("Problem parsing menu items json file", e);
        } catch (URISyntaxException e) {
            throw new MenuServiceException("Problem finding menu items json file", e);
        } catch (FileNotFoundException e) {
View Full Code Here

    public FormRepresentation getForm(String pkgName, String formId) throws FormServiceException {
        HttpClient client = helper.getHttpClient();
        if (formId != null && !"".equals(formId)) {
           
            GetMethod method = null;
            FormRepresentationDecoder decoder = FormEncodingFactory.getDecoder();
            try {
                String getUrl = helper.getApiSearchUrl(pkgName) +
                        URLEncoder.encode(formId, GuvnorHelper.ENCODING) + ".formdef";
                method = helper.createGetMethod(getUrl);
                helper.setAuth(client, method);
                client.executeMethod(method);
                String json = method.getResponseBodyAsString();
                return decoder.decode(json);
            } catch (IOException e) {
                throw new FormServiceException(e);
            } catch (FormEncodingException e) {
                throw new FormServiceException(e);
            } catch (Exception e) {
View Full Code Here

                    try {
                        helper.setAuth(client, processCall);
                        client.executeMethod(processCall);
                        String formJson = processCall.getResponseBodyAsString();
                        if (formJson != null && !"".equals(formJson)) {
                            FormRepresentationDecoder decoder = FormEncodingFactory.getDecoder();
                            return decoder.decode(formJson);
                        }
                    } finally {
                        processCall.releaseConnection();
                    }
                }
View Full Code Here

    @Override
    public FormItemRepresentation getFormItem(String pkgName, String formItemId) throws FormServiceException {
        HttpClient client = helper.getHttpClient();
        if (formItemId != null && !"".equals(formItemId)) {
            GetMethod method = null;
            FormRepresentationDecoder decoder = FormEncodingFactory.getDecoder();
            try {
                String getUrl = helper.getApiSearchUrl(pkgName) +
                        URLEncoder.encode(formItemId, GuvnorHelper.ENCODING) + ".json";
                method = helper.createGetMethod(getUrl);
                helper.setAuth(client, method);
                client.executeMethod(method);
                String json = method.getResponseBodyAsString();
                return decoder.decodeItem(json);
            } catch (IOException e) {
                throw new FormServiceException(e);
            } catch (FormEncodingException e) {
                throw new FormServiceException(e);
            } finally {
View Full Code Here

TOP

Related Classes of org.jbpm.formapi.shared.form.FormRepresentationDecoder

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.