Examples of FormResponse


Examples of br.com.objectos.way.ui.form.FormResponse

*/
@Test
public class FormResponseBuilderTest {

  public void default_response() {
    FormResponse res = new FormResponseBuilder()
        .get();

    assertThat(res.isValid(), equalTo(true));

    List<Error> errors = res.getErrors();
    assertThat(errors.size(), equalTo(0));

    assertThat(res.getRedirectUrl(), nullValue());
  }
View Full Code Here

Examples of br.com.objectos.way.ui.form.FormResponse

    assertThat(res.getRedirectUrl(), nullValue());
  }

  public void invalid_response() {
    FormResponse res = new FormResponseBuilder()

        .addMessage("a").toField("f")

        .get();

    assertThat(res.isValid(), equalTo(false));

    List<Error> errors = res.getErrors();
    assertThat(errors.size(), equalTo(1));

    Error e0 = errors.get(0);
    assertThat(e0.getName(), equalTo("f"));
    assertThat(e0.getMessage(), equalTo("a"));

    assertThat(res.getRedirectUrl(), nullValue());
  }
View Full Code Here

Examples of br.com.objectos.way.ui.form.FormResponse

    assertThat(res.getRedirectUrl(), nullValue());
  }

  public void redirect_url() {
    FormResponse res = new FormResponseBuilder()

        .redirectTo("http://localhost/whatever")

        .get();

    assertThat(res.getRedirectUrl(), equalTo("http://localhost/whatever"));
  }
View Full Code Here

Examples of br.com.objectos.way.ui.form.FormResponse

    assertThat(res.getRedirectUrl(), equalTo("http://localhost/whatever"));
  }

  public void form_message() {
    FormResponse res = new FormResponseBuilder()

        .addMessage("a").toForm()

        .get();

    assertThat(res.isValid(), equalTo(false));

    List<Error> errors = res.getErrors();
    assertThat(errors.size(), equalTo(1));

    Error e0 = errors.get(0);
    assertThat(e0.getName(), nullValue());
    assertThat(e0.getMessage(), equalTo("a"));
View Full Code Here

Examples of br.com.objectos.way.ui.form.FormResponse

    assertThat(e0.getName(), nullValue());
    assertThat(e0.getMessage(), equalTo("a"));
  }

  public void form_message_template() {
    FormResponse res = new FormResponseBuilder()

        .addMessage("%s:%d", "a", Integer.valueOf(1)).toField("f")

        .get();

    assertThat(res.isValid(), equalTo(false));

    List<Error> errors = res.getErrors();
    assertThat(errors.size(), equalTo(1));

    Error e0 = errors.get(0);
    assertThat(e0.getName(), equalTo("f"));
    assertThat(e0.getMessage(), equalTo("a:1"));
View Full Code Here

Examples of org.cafesip.gwtcomp.server.FormResponse

     * org.cafesip.gwtcomp.server.FileUploadAction#onSubmit(javax.servlet.http
     * .HttpServlet, javax.servlet.http.HttpServletRequest)
     */
    public FormResponse onSubmit(HttpServlet servlet, HttpServletRequest request)
    {
        FormResponse response = validateSubmission();
        if (response == null)
        {
            response = processSubmission(servlet, request);
        }

View Full Code Here

Examples of org.cafesip.gwtcomp.server.FormResponse

    {
        if (isUpload(serverContextPath) == true)
        {
            if ((fileList == null) || (fileList.size() == 0))
            {
                return new FormResponse(HttpServletResponse.SC_BAD_REQUEST,
                        "You have not provided a file to upload", true);
            }

            if (fileList.size() > 1)
            {
                return new FormResponse(HttpServletResponse.SC_BAD_REQUEST,
                        "Please select one file/directory to upload", true);
            }
        }
        else
        {
            // it's a path on the server
            File file = new File(serverContextPath);
            if (file.exists() == false)
            {
                // in the rare case that the file/directory was deleted after
                // the server-side file/dir has been selected from the client
                return new FormResponse(HttpServletResponse.SC_BAD_REQUEST,
                        "The file/directory does not exist on the server", true);
            }

            if (file.isDirectory() == true)
            {
                if ((contextNameOverride != null)
                        && (contextNameOverride.length() > 0))
                {
                    return new FormResponse(
                            HttpServletResponse.SC_BAD_REQUEST,
                            "The specified path is a directory. Therefore the name cannot be overridden",
                            true);
                }
            }
            else if (serverContextPath.endsWith(FileUtils.SPR_EXTENSION) == false)
            {
                return new FormResponse(
                        HttpServletResponse.SC_BAD_REQUEST,
                        "The specified path is a file but it does not have the '.spr' extension",
                        true);
            }
        }
View Full Code Here

Examples of org.cafesip.gwtcomp.server.FormResponse

                FileUtils f = new FileUtils();
                String tempFilePath = uploadedFile.getAbsolutePath();
                if (f.copyFile(tempFilePath, tempFilePath
                        + FileUtils.SPR_EXTENSION) == false)
                {
                    return new FormResponse(
                            HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                            "There was an error executing your request - the uploaded file copy failed",
                            true);
                }

                tempFile = new File(tempFilePath + FileUtils.SPR_EXTENSION);
                serverContextPath = tempFile.getAbsolutePath();
            }
            else
            {
                serverContextPath = uploadedFile.getAbsolutePath();
            }
        }

        if ((!FileUtils.validDeployableSpr(serverContextPath))
                && (!FileUtils.validDeployableJipletDir(serverContextPath)))
        {
            return new FormResponse(
                    HttpServletResponse.SC_BAD_REQUEST,
                    "The context could not be created because the path does not have a valid signature",
                    true);
        }

        String cmap = getContextCriteriaXML(domainName, selectedConnector,
                contextCriteria, new_name);

        try
        {
            ContainerMgmt cont = new ContainerMgmt();

            if ((override_name != null) && (override_name.length() > 0))
            {
                cont.createContext(serverContextPath, override_name, cmap);
            }
            else
            {
                cont.createContext(serverContextPath, null, cmap);
            }

            if (Model.getDeploymentType().equals("JBOSS") == true)
            {
                servlet.log("User " + request.getUserPrincipal().getName()
                        + " initiated the creation of the J2EE context "
                        + new_name);
                try
                {
                    Thread.sleep(10000L);
                }
                catch (InterruptedException e)
                {
                }
            }
            else
            {
                servlet.log("User " + request.getUserPrincipal().getName()
                        + " created context " + new_name);
            }

            return new FormResponse(HttpServletResponse.SC_OK, "OK", true);
        }
        catch (Throwable e)
        {
            servlet.log("Failure creating context: " + e.getClass().getName()
                    + ": " + e.getMessage());
            return new FormResponse(
                    HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                    "Failure creating context: " + e.getMessage(), true);
        }
        finally
        {
View Full Code Here

Examples of org.cafesip.gwtcomp.server.FormResponse

    private String uploadFilePath;

    public FormResponse onSubmit(HttpServlet servlet, HttpServletRequest request)
    {
        FormResponse response = initialValidation();
        if (response == null)
        {
            response = processSubmission(servlet, request);
        }
View Full Code Here

Examples of org.cafesip.gwtcomp.server.FormResponse

    {
        if (isUpload(serverPath) == true)
        {
            if ((fileList == null) || (fileList.size() == 0))
            {
                return new FormResponse(HttpServletResponse.SC_BAD_REQUEST,
                        "You have not provided a file to upload", true);
            }

            if (fileList.size() > 1)
            {
                return new FormResponse(HttpServletResponse.SC_BAD_REQUEST,
                        "Please select one file/directory to upload", true);
            }
        }
        else
        {
            // it's a path on the server
            File file = new File(serverPath);
            if (file.exists() == false)
            {
                // in the rare case that the file/directory was deleted after
                // the server-side file/dir has been selected from the client
                return new FormResponse(HttpServletResponse.SC_BAD_REQUEST,
                        "The file/directory does not exist on the server", true);
            }

            if ((file.isDirectory() == false)
                    && (serverPath.endsWith(FileUtils.SRR_EXTENSION) == false))
            {
                return new FormResponse(
                        HttpServletResponse.SC_BAD_REQUEST,
                        "The specified path is a file but it does not have the '.srr' extension",
                        true);
            }
        }
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.