Package org.cafesip.gwtcomp.server

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


    {
        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

                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

    private String uploadFilePath;

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

    {
        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

                    if (f
                            .copyFile(uploadedFile.getAbsolutePath(),
                                    tempFilePath) == 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);
                    serverPath = tempFile.getAbsolutePath();
                }
                else
                {
                    serverPath = uploadedFile.getAbsolutePath();
                }
            }

            if ((!FileUtils.validDeployableSrr(serverPath))
                    && (!FileUtils.validDeployableRealmDir(serverPath)))
            {
                return new FormResponse(
                        HttpServletResponse.SC_BAD_REQUEST,
                        "The realm could not be created because the path does not have a valid signature",
                        true);
            }

            RealmMgmt rlm = new RealmMgmt();
            rlm.createRealm(serverPath);

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

            return new FormResponse(HttpServletResponse.SC_OK, "OK", true);

        }
        catch (Throwable e)
        {
            e.printStackTrace();
            return new FormResponse(
                    HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getClass()
                            .getName()
                            + ": " + e.getMessage(), true);
        }
        finally
View Full Code Here

TOP

Related Classes of org.cafesip.gwtcomp.server.FormResponse

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.