Package com.sun.webui.jsf.model

Examples of com.sun.webui.jsf.model.UploadedFile


            @HandlerInput(name="file", type=UploadedFile.class)},
  output={
            @HandlerOutput(name="origPath", type=String.class),
            @HandlerOutput(name="uploadedTempFile", type=String.class)})
    public static void uploadFileToTempDir(HandlerContext handlerCtx) {
  UploadedFile uploadedFile = (UploadedFile)handlerCtx.getInputValue("file");
  File tmpFile = null;
        String uploadTmpFile = "";
  if(uploadedFile != null) {
            String name = uploadedFile.getOriginalName();
            //see bug# 6498910, for IE, getOriginalName() returns the full path, including the drive.
            //for any other browser, it just returns the file name.
            int lastIndex = name.lastIndexOf("\\");
            if (lastIndex != -1){
                name = name.substring(lastIndex+1, name.length());
            }
      int index = name.indexOf(".");
      if(index <= 0) {
        String mesg = GuiUtil.getMessage("msg.deploy.nullArchiveError");
                GuiUtil.handleError(handlerCtx, mesg);
        return;
      }
            String suffix = name.substring(index);
            String prefix = name.substring(0, index);
            handlerCtx.setOutputValue("origPath", prefix);
            try {
                //createTempFile requires min. of 3 char for prefix.
                if (prefix.length() <=2)
                    prefix= prefix + new Random().nextInt(100000);
                tmpFile = File.createTempFile(prefix, suffix);
    tmpFile.deleteOnExit();
    uploadedFile.write(tmpFile);
    uploadTmpFile = tmpFile.getCanonicalPath();
            } catch (IOException ioex) {
                try {
                    uploadTmpFile = tmpFile.getAbsolutePath();
    } catch (Exception ex) {
View Full Code Here


    private static String processCustomMBeanJar(String locationType, HandlerContext handlerCtx) throws Exception {
        String fileName = "";
        String jarToExtract = "";
        try{
            if(locationType.equals("client")){
                UploadedFile uploadJar = (UploadedFile)handlerCtx.getInputValue("UploadedJar");
                if(uploadJar != null) {
                    fileName = uploadJar.getOriginalName();
                    //see bug# 6498910, 6511392, for IE, getOriginalName() returns the full path, including the drive.
                    //for any other browser, it just returns the file name.
                    int lastIndex = fileName.lastIndexOf("\\");
                    if (lastIndex != -1){
                        fileName = fileName.substring(lastIndex+1, fileName.length());
                    }
                    File tmpFile = null;
                    String suffix = fileName.substring(fileName.indexOf("."));
                    String prefix = fileName.substring(0, fileName.indexOf("."));
                    try {
                        tmpFile = File.createTempFile(prefix, suffix);
                        uploadJar.write(tmpFile);
                        jarToExtract = tmpFile.getCanonicalPath();
                    } catch (IOException ioex) {
                        try {
                            jarToExtract = tmpFile.getAbsolutePath();
                        } catch (Exception ex) {
View Full Code Here

    output={
        @HandlerOutput(name="origPath", type=String.class),
        @HandlerOutput(name="uploadedTempFile", type=String.class)
    })
    public static void uploadFile(HandlerContext handlerCtx) {
        UploadedFile uploadedFile = (UploadedFile)handlerCtx.getInputValue("file");
        String uploadTmpFile = "";
       
        if(uploadedFile != null) {
            String name = uploadedFile.getOriginalName();
            //see bug# 6498910, for IE, getOriginalName() returns the full path, including the drive.
            //for any other browser, it just returns the file name.
            int lastIndex = name.lastIndexOf("\\");
            if (lastIndex != -1){
                name = name.substring(lastIndex+1, name.length());
            }
      // The name can be an empty string where the user has selected nothing and clicked
      // save/ok button
      if (name.trim().length() == 0) {
    handlerCtx.setOutputValue("uploadedTempFile", uploadTmpFile);
    return;
      }
            handlerCtx.setOutputValue("origPath", name);
            File target = new File(TargetUtil.getDomainRoot() + File.separator + "config" + File.separator + name);
            try {
                uploadedFile.write(target);
                uploadTmpFile = target.getCanonicalPath();
            } catch (IOException ioex) {
                try {
                    uploadTmpFile = target.getAbsolutePath();
                } catch (Exception ex) {
View Full Code Here

    public static void uploadFileToTempDir(HandlerContext handlerCtx) {
        Logger logger = GuiUtil.getLogger();
        if (logger.isLoggable(Level.FINE)){
            logger.fine(GuiUtil.getCommonMessage("log.inUploadFileToTmpDir"));
        }
        UploadedFile uploadedFile = (UploadedFile) handlerCtx.getInputValue("file");
        File tmpFile = null;
        String uploadTmpFile = "";
        if (uploadedFile != null) {

            String name = uploadedFile.getOriginalName();
            logger.info("uploadFileName="+name);
            //see bug# 6498910, for IE, getOriginalName() returns the full path, including the drive.
            //for any other browser, it just returns the file name.
            int lastIndex = name.lastIndexOf("\\");
            if (lastIndex != -1) {
                name = name.substring(lastIndex + 1, name.length());
            }
            int index = name.indexOf(".");
            if (index <= 0) {
                logger.info("name="+name + ",index="+index);
                String mesg = GuiUtil.getMessage("msg.deploy.nullArchiveError");
                GuiUtil.handleError(handlerCtx, mesg);
                return;
            }
            String suffix = name.substring(index);
            String prefix = name.substring(0, index);
            handlerCtx.setOutputValue("origPath", prefix);
            try {
                //createTempFile requires min. of 3 char for prefix.
                if (prefix.length() <= 2) {
                    prefix = prefix + new Random().nextInt(100000);
                }
                tmpFile = File.createTempFile(prefix, suffix);
                tmpFile.deleteOnExit();
                logger.fine(GuiUtil.getCommonMessage("log.writeToTmpFile"));
                uploadedFile.write(tmpFile);
                logger.fine(GuiUtil.getCommonMessage("log.afterWriteToTmpFile"));
                uploadTmpFile = tmpFile.getCanonicalPath();
            } catch (IOException ioex) {
                try {
                    uploadTmpFile = tmpFile.getAbsolutePath();
View Full Code Here

    public static void uploadFileToTempDir(HandlerContext handlerCtx) {
        Logger logger = GuiUtil.getLogger();
        if (logger.isLoggable(Level.FINE)){
            logger.fine(GuiUtil.getCommonMessage("log.inUploadFileToTmpDir"));
        }
        UploadedFile uploadedFile = (UploadedFile) handlerCtx.getInputValue("file");
        File tmpFile = null;
        String uploadTmpFile = "";
        if (uploadedFile != null) {

            String name = uploadedFile.getOriginalName();
            logger.info("uploadFileName="+name);
            //see bug# 6498910, for IE, getOriginalName() returns the full path, including the drive.
            //for any other browser, it just returns the file name.
            int lastIndex = name.lastIndexOf("\\");
            if (lastIndex != -1) {
                name = name.substring(lastIndex + 1, name.length());
            }
            int index = name.indexOf(".");
            if (index <= 0) {
                logger.info("name="+name + ",index="+index);
                String mesg = GuiUtil.getMessage("msg.deploy.nullArchiveError");
                GuiUtil.handleError(handlerCtx, mesg);
                return;
            }
            String suffix = name.substring(index);
            String prefix = name.substring(0, index);
            handlerCtx.setOutputValue("origPath", prefix);
            try {
                //createTempFile requires min. of 3 char for prefix.
                if (prefix.length() <= 2) {
                    prefix = prefix + new Random().nextInt(100000);
                }
                tmpFile = File.createTempFile(prefix, suffix);
                tmpFile.deleteOnExit();
                logger.fine(GuiUtil.getCommonMessage("log.writeToTmpFile"));
                uploadedFile.write(tmpFile);
                logger.fine(GuiUtil.getCommonMessage("log.afterWriteToTmpFile"));
                uploadTmpFile = tmpFile.getCanonicalPath();
            } catch (IOException ioex) {
                try {
                    uploadTmpFile = tmpFile.getAbsolutePath();
View Full Code Here

    public static void uploadFileToTempDir(HandlerContext handlerCtx) {
        Logger logger = GuiUtil.getLogger();
        if (logger.isLoggable(Level.FINE)){
            logger.fine(GuiUtil.getCommonMessage("log.inUploadFileToTmpDir"));
        }
        UploadedFile uploadedFile = (UploadedFile) handlerCtx.getInputValue("file");
        File tmpFile = null;
        String uploadTmpFile = "";
        if (uploadedFile != null) {

            String name = uploadedFile.getOriginalName();
            logger.info("uploadFileName="+name);
            //see bug# 6498910, for IE, getOriginalName() returns the full path, including the drive.
            //for any other browser, it just returns the file name.
            int lastIndex = name.lastIndexOf("\\");
            if (lastIndex != -1) {
                name = name.substring(lastIndex + 1, name.length());
            }
            int index = name.indexOf(".");
            if (index <= 0) {
                logger.info("name="+name + ",index="+index);
                String mesg = GuiUtil.getMessage("msg.deploy.nullArchiveError");
                GuiUtil.handleError(handlerCtx, mesg);
                return;
            }
            String suffix = name.substring(index);
            String prefix = name.substring(0, index);
            handlerCtx.setOutputValue("origPath", prefix);
            try {
                //createTempFile requires min. of 3 char for prefix.
                if (prefix.length() <= 2) {
                    prefix = prefix + new Random().nextInt(100000);
                }
                tmpFile = File.createTempFile(prefix, suffix);
                tmpFile.deleteOnExit();
                logger.fine(GuiUtil.getCommonMessage("log.writeToTmpFile"));
                uploadedFile.write(tmpFile);
                logger.fine(GuiUtil.getCommonMessage("log.afterWriteToTmpFile"));
                uploadTmpFile = tmpFile.getCanonicalPath();
            } catch (IOException ioex) {
                try {
                    if (tmpFile != null){
View Full Code Here

    public static void uploadFileToTempDir(HandlerContext handlerCtx) {
        Logger logger = GuiUtil.getLogger();
        if (logger.isLoggable(Level.FINE)){
            logger.fine(GuiUtil.getCommonMessage("log.inUploadFileToTmpDir"));
        }
        UploadedFile uploadedFile = (UploadedFile) handlerCtx.getInputValue("file");
        File tmpFile = null;
        String uploadTmpFile = "";
        if (uploadedFile != null) {

            String name = uploadedFile.getOriginalName();
            logger.info("uploadFileName="+name);
            //see bug# 6498910, for IE, getOriginalName() returns the full path, including the drive.
            //for any other browser, it just returns the file name.
            int lastIndex = name.lastIndexOf("\\");
            if (lastIndex != -1) {
                name = name.substring(lastIndex + 1, name.length());
            }
            int index = name.indexOf(".");
            if (index <= 0) {
                logger.info("name="+name + ",index="+index);
                String mesg = GuiUtil.getMessage("msg.deploy.nullArchiveError");
                GuiUtil.handleError(handlerCtx, mesg);
                return;
            }
            String suffix = name.substring(index);
            String prefix = name.substring(0, index);
            handlerCtx.setOutputValue("origPath", prefix);
            try {
                //createTempFile requires min. of 3 char for prefix.
                if (prefix.length() <= 2) {
                    prefix = prefix + new Random().nextInt(100000);
                }
                tmpFile = File.createTempFile(prefix, suffix);
                tmpFile.deleteOnExit();
    if (logger.isLoggable(Level.FINE)){
                    logger.fine(GuiUtil.getCommonMessage("log.writeToTmpFile"));
    }
                uploadedFile.write(tmpFile);
    if (logger.isLoggable(Level.FINE)){
                    logger.fine(GuiUtil.getCommonMessage("log.afterWriteToTmpFile"));
    }
                uploadTmpFile = tmpFile.getCanonicalPath();
            } catch (IOException ioex) {
View Full Code Here

    public static void uploadFileToTempDir(HandlerContext handlerCtx) {
        Logger logger = GuiUtil.getLogger();
        if (logger.isLoggable(Level.FINE)){
            logger.fine(GuiUtil.getCommonMessage("log.inUploadFileToTmpDir"));
        }
        UploadedFile uploadedFile = (UploadedFile) handlerCtx.getInputValue("file");
        File tmpFile = null;
        String uploadTmpFile = "";
        if (uploadedFile != null) {

            String name = uploadedFile.getOriginalName();
            logger.info("uploadFileName="+name);
            //see bug# 6498910, for IE, getOriginalName() returns the full path, including the drive.
            //for any other browser, it just returns the file name.
            int lastIndex = name.lastIndexOf("\\");
            if (lastIndex != -1) {
                name = name.substring(lastIndex + 1, name.length());
            }
            int index = name.indexOf(".");
            if (index <= 0) {
                logger.info("name="+name + ",index="+index);
                String mesg = GuiUtil.getMessage("msg.deploy.nullArchiveError");
                GuiUtil.handleError(handlerCtx, mesg);
                return;
            }
            String suffix = name.substring(index);
            String prefix = name.substring(0, index);
            handlerCtx.setOutputValue("origPath", prefix);
            try {
                //createTempFile requires min. of 3 char for prefix.
                if (prefix.length() <= 2) {
                    prefix = prefix + new Random().nextInt(100000);
                }
                tmpFile = File.createTempFile(prefix, suffix);
                tmpFile.deleteOnExit();
                logger.fine(GuiUtil.getCommonMessage("log.writeToTmpFile"));
                uploadedFile.write(tmpFile);
                logger.fine(GuiUtil.getCommonMessage("log.afterWriteToTmpFile"));
                uploadTmpFile = tmpFile.getCanonicalPath();
            } catch (IOException ioex) {
                try {
                    uploadTmpFile = tmpFile.getAbsolutePath();
View Full Code Here

    public static void uploadFileToTempDir(HandlerContext handlerCtx) {
        Logger logger = GuiUtil.getLogger();
        if (logger.isLoggable(Level.FINE)){
            logger.fine(GuiUtil.getCommonMessage("log.inUploadFileToTmpDir"));
        }
        UploadedFile uploadedFile = (UploadedFile) handlerCtx.getInputValue("file");
        File tmpFile = null;
        String uploadTmpFile = "";
        if (uploadedFile != null) {

            String name = uploadedFile.getOriginalName();
            logger.info("uploadFileName="+name);
            //see bug# 6498910, for IE, getOriginalName() returns the full path, including the drive.
            //for any other browser, it just returns the file name.
            int lastIndex = name.lastIndexOf("\\");
            if (lastIndex != -1) {
                name = name.substring(lastIndex + 1, name.length());
            }
            int index = name.indexOf(".");
            if (index <= 0) {
                logger.info("name="+name + ",index="+index);
                String mesg = GuiUtil.getMessage("msg.deploy.nullArchiveError");
                GuiUtil.handleError(handlerCtx, mesg);
                return;
            }
            String suffix = name.substring(index);
            String prefix = name.substring(0, index);
            handlerCtx.setOutputValue("origPath", prefix);
            try {
                //createTempFile requires min. of 3 char for prefix.
                if (prefix.length() <= 2) {
                    prefix = prefix + new Random().nextInt(100000);
                }
                tmpFile = File.createTempFile(prefix, suffix);
                tmpFile.deleteOnExit();
                logger.fine(GuiUtil.getCommonMessage("log.writeToTmpFile"));
                uploadedFile.write(tmpFile);
                logger.fine(GuiUtil.getCommonMessage("log.afterWriteToTmpFile"));
                uploadTmpFile = tmpFile.getCanonicalPath();
            } catch (IOException ioex) {
                try {
                    if (tmpFile != null){
View Full Code Here

TOP

Related Classes of com.sun.webui.jsf.model.UploadedFile

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.