Package net.sf.json

Examples of net.sf.json.JSONObject


    }

    public Node reconfigure(final StaplerRequest req, JSONObject form) throws FormException {
        if (form==null)     return null;

        final JSONObject jsonForProperties = form.optJSONObject("nodeProperties");
        BindInterceptor old = req.setBindListener(new BindInterceptor() {
            @Override
            public Object onConvert(Type targetType, Class targetTypeErasure, Object jsonSource) {
                if (jsonForProperties!=jsonSourcereturn DEFAULT;
View Full Code Here


        List<T> newList = new ArrayList<T>();

        for (Descriptor<T> d : descriptors) {
            T existing = get((D)d);
            String name = d.getJsonSafeClassName();
            JSONObject o = json.optJSONObject(name);

            T instance = null;
            if (o!=null) {
                if (existing instanceof ReconfigurableDescribable)
                    instance = (T)((ReconfigurableDescribable)existing).reconfigure(req,o);
View Full Code Here

    @Override
    protected void submit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, FormException {
        super.submit(req, rsp);

        JSONObject json = req.getSubmittedForm();

        if(req.getParameter("hasCombinationFilter")!=null) {
            this.combinationFilter = Util.nullify(req.getParameter("combinationFilter"));
        } else {
            this.combinationFilter = null;
        }

        if(req.hasParameter("customWorkspace")) {
            setChildCustomWorkspace(Util.fixEmptyAndTrim(req.getParameter("childCustomWorkspace.directory")));
        } else {
            setChildCustomWorkspace(null);
        }

        List<MatrixExecutionStrategyDescriptor> esd = getDescriptor().getExecutionStrategyDescriptors();
        if (esd.size()>1)
            executionStrategy = req.bindJSON(MatrixExecutionStrategy.class,json.getJSONObject("executionStrategy"));
        else
            executionStrategy = req.bindJSON(esd.get(0).clazz,json.getJSONObject("executionStrategy"));

        // parse system axes
        DescribableList<Axis,AxisDescriptor> newAxes = new DescribableList<Axis,AxisDescriptor>(this);
        newAxes.rebuildHetero(req, json, Axis.all(),"axis");
        checkAxisNames(newAxes);
View Full Code Here

        f.getInputByName("c").click();
        submit(f);
    }

    public FormValidation doSubmitNestedOptionalBlock(StaplerRequest req) throws Exception {
        JSONObject f = req.getSubmittedForm();
        System.out.println(f);
        assertEquals("avalue",f.getString("a"));
        assertEquals("bvalue",f.getString("b"));
        JSONObject c = f.getJSONObject("c");
        assertEquals("dvalue",c.getString("d"));
        return FormValidation.ok();
    }
View Full Code Here

    @Bug(5536)
    public void testPost() throws Exception {
        assertNull(job.getData());
        createWebClient().goTo("/self/testPost");
        JSONObject d = job.getData();
        assertEquals(hashCode(),d.getInt("hello"));
    }
View Full Code Here

    /**
     * Accepts submission from the configuration page.
     */
    @RequirePOST
    public synchronized void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
        JSONObject src = req.getSubmittedForm();

        String newName = src.getString("name"), redirect = ".";
        XmlFile oldFile = null;
        if(!name.equals(newName)) {
            Jenkins.checkGoodName(newName);
            oldFile = getConfigFile();
            // rename
            getParent().logRecorders.remove(name);
            this.name = newName;
            getParent().logRecorders.put(name,this);
            redirect = "../" + Util.rawEncode(newName) + '/';
        }

        List<Target> newTargets = req.bindJSONToList(Target.class, src.get("targets"));
        for (Target t : newTargets)
            t.enable();
        targets.replaceBy(newTargets);

        save();
View Full Code Here

     */
    @Override
    public JobProperty<?> newInstance(StaplerRequest req, JSONObject formData) throws FormException {
        // JobPropertyDescriptors are bit different in that we allow them even without any user-visible configuration parameter,
        // so replace the lack of form data by an empty one.
        if(formData.isNullObject()) formData=new JSONObject();

        return super.newInstance(req, formData);
    }
View Full Code Here

        submit(p.getFormByName("config"));
        assertEqualDataBoundBeans(beer,new Beer("",new Nested("Budweiser")));
    }

    public void doSubmitTest2(StaplerRequest req) throws Exception {
        JSONObject json = req.getSubmittedForm();
        System.out.println(json);
        beer = (Beer)req.bindJSON(Drink.class,json.getJSONObject("drink"));
    }
View Full Code Here

            return FormValidation.ok();
        }

        @Override
        public AggregatedTestResultPublisher newInstance(StaplerRequest req, JSONObject formData) throws FormException {
            JSONObject s = formData.getJSONObject("specify");
            if(s.isNullObject())
                return new AggregatedTestResultPublisher(null, req.getParameter("includeFailedBuilds") != null);
            else
                return new AggregatedTestResultPublisher(s.getString("jobs"), req.getParameter("includeFailedBuilds") != null);
        }
View Full Code Here

        HtmlForm f = p.getFormByName("config");
        submit(f);
    }

    public FormValidation doSubmitTest1(StaplerRequest req) throws Exception {
        JSONObject f = req.getSubmittedForm();
        System.out.println(f);
        EnumSetTest r = req.bindJSON(EnumSetTest.class,f);
        System.out.println(r.f);
        return FormValidation.ok();
    }
View Full Code Here

TOP

Related Classes of net.sf.json.JSONObject

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.