Package org.cafesip.jiplet.utils

Examples of org.cafesip.jiplet.utils.FileUtils


            if (findContext(name) != null)
            {
                return "The context could not be created because a context with the same name already exists";
            }

            FileUtils ant = new FileUtils();

            File exploded = new File(deployDir, name);

            boolean extr = false;
            if ((spr == true) || (internal == false))
            {
                if (FileUtils.validDeployableJipletDir(exploded
                        .getAbsolutePath()) == true)
                {
                    if (f.lastModified() > exploded.lastModified())
                    {
                        if (JipletLogger.isDebugEnabled() == true)
                        {
                            JipletLogger
                                    .info("Found older exploded context entry "
                                            + exploded.getAbsolutePath()
                                            + " while creating the context "
                                            + name + ". Deleting the directory");
                        }

                        ant.deleteDir(exploded.getAbsolutePath());
                        extr = true;
                    }
                }
                else
                {
                    if (exploded.isDirectory() == true)
                    {
                        ant.deleteDir(exploded.getAbsolutePath());
                    }
                    extr = true;
                }
            }

            if (extr == true)
            {
                if (spr == true)
                {
                    if (ant.extractSpr(f.getAbsolutePath(), deployDir
                            .getAbsolutePath(), name) == false)
                    {
                        JipletLogger.error("Error extracting context " + name
                                + " from the corresponding spr file");
                        return "The zipped context could not be extracted";
                    }
                }
                else
                // exploded
                {
                    if (ant.copy(path, deployDir.getAbsolutePath()) == false)
                    {
                        JipletLogger.error("Error copying exploded context "
                                + name + " file: " + path
                                + " to deploy directory");
                        return "The exploded context could not be copied to the deploy dir";
View Full Code Here


                        + " from deploy directory");
            }

            deployedContexts.remove(name);

            FileUtils ant = new FileUtils();
            File exploded = new File(deployDir, name);

            // if a spr file exists, delete the spr
            File spr_file = new File(deployDir, name + FileUtils.SPR_EXTENSION);

            // Delete the contexts so that the contexts wont be started during
            // server re-start
            if (spr_file.exists() == true)
            {
                JipletLogger.info("Deleting deployment spr file "
                        + spr_file.getAbsolutePath());

                if (spr_file.delete() == false)
                {
                    // this can happen in a windoze environment because the file
                    // may be in use
                    JipletLogger.error("The context spr file "
                            + spr_file.getAbsolutePath()
                            + ". could not be deleted.");
                }
            }

            JipletLogger.info("Deleting deployment directory "
                    + exploded.getAbsolutePath());
            if (ant.deleteDir(exploded.getAbsolutePath()) == false)
            {
                JipletLogger
                        .warn("The context  directory   "
                                + exploded.getAbsolutePath()
                                + ". Could not be deleted. We will try again during server restart");
View Full Code Here

            else
            {
                return "The realm could not be created because the path does not have a valid signature";
            }

            FileUtils ant = new FileUtils();
            File exploded = new File(deployDir, name);

            boolean extr = false;
            if (srr)
            {
                if (FileUtils.validDeployableRealmDir(exploded
                        .getAbsolutePath()))
                {
                    if (f.lastModified() > exploded.lastModified())
                    {
                        if (JipletLogger.isDebugEnabled())
                        {
                            JipletLogger
                                    .info("Found older exploded realm entry "
                                            + exploded.getAbsolutePath()
                                            + " while creating the realm on directory "
                                            + name + ". Deleting the directory");
                        }

                        ant.deleteDir(exploded.getAbsolutePath());
                        extr = true;
                    }
                }
                else
                {
                    if (exploded.isDirectory())
                    {
                        ant.deleteDir(exploded.getAbsolutePath());
                    }
                    extr = true;
                }
            }

            // new code
            boolean internal = deployDirExists(deployDir, path);
            if (srr || !internal)
            {
                if (FileUtils.validDeployableRealmDir(exploded
                        .getAbsolutePath()))
                {
                    if (f.lastModified() > exploded.lastModified())
                    {
                        if (JipletLogger.isDebugEnabled())
                        {
                            JipletLogger
                                    .info("Found older exploded context entry "
                                            + exploded.getAbsolutePath()
                                            + " while creating the realm "
                                            + name + ". Deleting the directory");
                        }

                        ant.deleteDir(exploded.getAbsolutePath());
                        extr = true;
                    }
                }
                else
                {
                    if (exploded.isDirectory())
                    {
                        ant.deleteDir(exploded.getAbsolutePath());
                    }
                    extr = true;
                }
            }
            // new code ends

            if (extr)
            {
                if (srr)
                {
                    if (!ant.extractSpr(f.getAbsolutePath(), deployDir
                            .getAbsolutePath(), name))
                    {
                        JipletLogger
                                .error("Error extracting realm with directory "
                                        + name
                                        + " from the corresponding srr file");
                        return "The zipped context could not be extracted";
                    }
                }
                else
                // exploded
                {
                    if (!ant.copy(path, deployDir.getAbsolutePath()))
                    {
                        JipletLogger.error("Error copying exploded realm "
                                + name + " file: " + path
                                + " to deploy directory");
                        return "The exploded realm could not be copied to the deploy dir";
View Full Code Here

                                    + spr_file.getAbsolutePath()
                                    + " could not be deleted. On re-start, the realm will get started up.");
                }
            }

            FileUtils futils = new FileUtils();
            if (futils.deleteDir(path) == false)
            {
                JipletLogger.warn("While deleting realm " + realmName
                        + ", the realm directory " + path
                        + " could not be deleted.");
View Full Code Here

                throw new JipletException ("Could not create jiplet deployment directory "
                        + deploy_dir.getAbsolutePath());
            }
        }
       
        FileUtils fu = new FileUtils();
        fu.cleanupDir(deploy_dir.getAbsolutePath());
        JipletContainer.setDeployDir(deploy_dir);
    }
View Full Code Here

            override_name = new_name;

            File uploadedFile = fileList.values().iterator().next();
            if (uploadedFile.getName().endsWith(FileUtils.SPR_EXTENSION) == false)
            {
                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",
View Full Code Here

                // directory
                String home = System.getProperty("jboss.server.home.url");
                URL home_url = new URL(home);
                File home_path = new File(home_url.getPath(), "deploy");

                FileUtils f = new FileUtils();

                if (overriddenName != null)
                {
                    String path_name = null;
                    if (name.endsWith(FileUtils.SPR_EXTENSION) == true)
                    {
                        path_name = (new File(home_path, overriddenName
                                + FileUtils.SPR_EXTENSION)).getAbsolutePath();
                    }
                    else
                    {
                        path_name = (new File(home_path, overriddenName))
                                .getAbsolutePath();
                    }

                    // System.out.println("(O) Copying from " + path + " to " +
                    // path_name);
                    if (f.copyFile(path, path_name) == false)
                    {
                        throw new Exception(
                                "Error copying file to the J2EE deploy directory");
                    }
                }
                else
                {
                    // System.out.println("Copying from " + path + " to " +
                    // home_path.getAbsolutePath());
                    if (f.copy(path, home_path.getAbsolutePath()) == false)
                    {
                        throw new Exception(
                                "Error copying file to the J2EE deploy directory");
                    }
                }
View Full Code Here

                            + FileUtils.SPR_EXTENSION);
                }

                if (f.isDirectory() == true)
                {
                    FileUtils futils = new FileUtils();
                    if (futils.deleteDir(f.getAbsolutePath()) == false)
                    {
                        throw new Exception(
                                "Error deleting J2EE deploy directory");
                    }
                }
View Full Code Here

            if (isUpload(serverPath) == true)
            {
                File uploadedFile = fileList.values().iterator().next();
                if (uploadedFile.getName().endsWith(FileUtils.SRR_EXTENSION) == false)
                {
                    FileUtils f = new FileUtils();

                    String uploadedFileName = new File(uploadFilePath)
                            .getName();
                    String tempFilePath = new File(uploadedFile.getParent(),
                            uploadedFileName).getAbsolutePath();

                    if (f
                            .copyFile(uploadedFile.getAbsolutePath(),
                                    tempFilePath) == false)
                    {
                        return new FormResponse(
                                HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
View Full Code Here

                // directory
                String home = System.getProperty("jboss.server.home.url");
                URL home_url = new URL(home);
                File home_path = new File(home_url.getPath(), "deploy");

                FileUtils f = new FileUtils();
                if (f.copy(path, home_path.getAbsolutePath()) == false)
                {
                    throw new Exception(
                            "Error copying file to the J2EE deploy directory");
                }
            }
View Full Code Here

TOP

Related Classes of org.cafesip.jiplet.utils.FileUtils

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.