Package org.wso2.carbon.utils

Examples of org.wso2.carbon.utils.FileItemData


        layoutManager.setVerticalLayout(true);
        layoutManager.setYSpacing(20);
        layoutManager.setYSpacing(50);
        layoutManager.layoutSVG(bpel.getRootActivity());

        SVGImpl svg = new SVGImpl();
        svg.setRootActivity(bpel.getRootActivity());
       
        return(svg);
    }
View Full Code Here


                new RuleServiceFileUploadClient(configurationContext, serverURL, cookie);
        String msg;
        try {
            for (Object o : fileItemsMap.keySet()) {
                String fieldName = (String) o;
                FileItemData fileItemData = fileItemsMap.get(fieldName).get(0);
                String fileName = getFileName(fileItemData.getFileItem().getName());
                checkServiceFileExtensionValidity(fileName, ALLOWED_FILE_EXTENSIONS);

                if (fileName.endsWith(".aar") || fileName.endsWith(".rsl")) {
                    serviceUploaderClient.uploadService(fileName, fileItemData.getDataHandler());
                } else {
                    throw new CarbonException("File with extension " + fileName
                            + " is not supported!. Supported extensions are : .aar and .rsl");
                }
            }
View Full Code Here

            }
            if (formFieldsMap.get("errorRedirect") != null) {
                errorRedirect = formFieldsMap.get("errorRedirect").get(0);
            }

            FileItemData fileItemData = fileItemsMap.get("upload").get(0);

            if ((fileItemData == null) || (fileItemData.getFileItem().getSize() == 0)) {
                String msg = "Failed add resource. Resource content is empty.";
                log.error(msg);

                buildUIError(request, response, webContext, errorRedirect, msg);
                return false;
            }
            client.addExtension(formFieldsMap.get("filename").get(0),
                    fileItemData.getDataHandler());

            response.setContentType("text/html; charset=utf-8");
            String msg = "Successfully uploaded extension.";
            if (redirect == null) {
                CarbonUIMessage.sendCarbonUIMessage(msg, CarbonUIMessage.INFO, request);
View Full Code Here

            }
            if (symlinkLocation != null) {
                symlinkLocation = chroot + symlinkLocation;
            }

            FileItemData fileItemData = fileItemsMap.get("upload").get(0);

            if ("".equals(resourceName) || resourceName == null) {
                resourceName = getFileName(fileItemData.getFileItem().getName());
            }

            if ((fileItemData == null) || (fileItemData.getFileItem().getSize() == 0)) {
                String msg = "Failed add resource. Resource content is empty.";
                log.error(msg);

                CarbonUIMessage.sendCarbonUIMessage(msg, CarbonUIMessage.ERROR, request);
                if (errorRedirect == null) {
                    response.sendRedirect(
                            getContextRoot(request) + "/" + webContext + "/admin/error.jsp");
                } else {
                    response.sendRedirect(
                            getContextRoot(request) + "/" + webContext + "/" + errorRedirect + (errorRedirect.indexOf("?")
                                    == -1 ? "?" : "&") + "msg=" + URLEncoder.encode(msg, "UTF-8"));
                }
                return false;
            }
            DataHandler dataHandler = fileItemData.getDataHandler();

            client.addResource(
                    calcualtePath(parentPath, resourceName), mediaType, description, dataHandler,
                    symlinkLocation);
View Full Code Here

            }
            if (symlinkLocation != null) {
                symlinkLocation = chroot + symlinkLocation;
            }

            FileItemData gadgetScreenData = null;
            if (fileItemsMap.get("gadgetScreen") != null) {
                gadgetScreenData = fileItemsMap.get("gadgetScreen").get(0);
            }

            DataHandler gadgetThumb = null;
            if (gadgetScreenData != null) {
                gadgetThumb = gadgetScreenData.getDataHandler();
            }

            String cType = null;
            if (gadgetThumb != null) {
                cType = gadgetThumb.getContentType();
            }

            FileItemData gadgetArchive = null;
            if (fileItemsMap.get("gadget") != null) {
                gadgetArchive = fileItemsMap.get("gadget").get(0);
            } else if (gUrl == null || "".equals(gUrl)) {
                String msg = "Failed add resource. Gadget URL is empty";
                log.error(msg);

                if (errorRedirect == null) {
                    CarbonUIMessage.sendCarbonUIMessage(
                            msg, CarbonUIMessage.ERROR, request, response,
                            getContextRoot(request) + "/" +  webContext + "/admin/error.jsp");
                } else {
                    CarbonUIMessage.sendCarbonUIMessage(
                            msg, CarbonUIMessage.ERROR, request, response,
                            getContextRoot(request) + "/" + webContext + "/" + errorRedirect +
                            (errorRedirect.indexOf("?") == -1 ? "?" : "&") +
                            "msg=" + URLEncoder.encode(msg, "UTF-8"));
                }
                return false;

            }

            DataHandler gadgetFile = null;
            if (gadgetArchive != null) {
                gadgetFile = gadgetArchive.getDataHandler();
                if ("application/zip".equals(gadgetFile.getContentType())) {
                     /* This is a zip file. So upload gadget using zip file (Replaces new media type now). In this case
                     there is no gadget thumbnail. So use the cType var to store media type for gadget */
                    cType = DashboardConstants.GADGET_MEDIA_TYPE;
                }
View Full Code Here

        DBSFileUploadClient serviceUploaderClient = new DBSFileUploadClient(configurationContext, serverURL, cookie);
        String msg;
        try {
            for (Object o : fileItemsMap.keySet()) {
                String fieldName = (String) o;
                FileItemData fileItemData = fileItemsMap.get(fieldName).get(0);
                String fileName = getFileName(fileItemData.getFileItem().getName());
                checkServiceFileExtensionValidity(fileName, ALLOWED_FILE_EXTENSIONS);
                if (fileName.endsWith(".wsdl")) {
                    serviceUploaderClient.uploadWsdl(fileName, fileItemData.getDataHandler());
                } else {
                    throw new CarbonException("File with extension " + fileName
                            + " is not supported!");
                }
            }
View Full Code Here

                configurationContext,serverURL, cookie);
        String msg;
        try {
            for (Object o : fileItemsMap.keySet()) {
                String fieldName = (String) o;
                FileItemData fileItemData = fileItemsMap.get(fieldName).get(0);
                String fileName = getFileName(fileItemData.getFileItem().getName());
                checkServiceFileExtensionValidity(fileName, ALLOWED_FILE_EXTENSIONS);

                if (fileName.endsWith(".dbs")) {
                    serviceUploaderClient.uploadService(fileName, "", fileItemData.getDataHandler());
                } else {
                    throw new CarbonException("File with extension " + fileName
                            + " is not supported!");
                }
            }
View Full Code Here

        String fileToRedirect = "";
        try {
            for (Object o : fileItemsMap.keySet()) {
                String fieldName = (String) o;
                if ("factFilename".equals(fieldName)) {
                    FileItemData fileItemData = fileItemsMap.get(fieldName).get(0);
                    String fileName = getFileName(fileItemData.getFileItem().getName());
                    checkServiceFileExtensionValidity(fileName, ALLOWED_FILE_EXTENSIONS);
                    if (fileName.endsWith(".jar")) {
                        String[] facts =
                                adminClient.uploadFacts(ruleServiceName,
                                        fileName, fileItemData.getDataHandler(), request);
                        request.getSession().setAttribute(RuleServiceAdminClient.FACTS, facts);

                        String[] allFacts = ((String[]) request.getSession().getAttribute("allFacts"));
                        if (allFacts != null) {
                            if (allFacts.length > 0) {
                                HashSet<String> factSet = new HashSet<String>();
                                for (String fact : allFacts) {
                                    factSet.add(fact);
                                }
                                for (String fact : facts) {
                                    factSet.add(fact);
                                }
                                String[] mergedFacts = factSet.toArray(new String[factSet.size()]);
                                request.getSession().setAttribute("allFacts", mergedFacts);
                            }
                        } else {
                            HashSet<String> factSet = new HashSet<String>();
                            for (String fact : facts) {
                                factSet.add(fact);
                            }
                            String[] mergedFacts = factSet.toArray(new String[factSet.size()]);
                            request.getSession().setAttribute("allFacts", mergedFacts);
                        }
                    } else {
                        throw new CarbonException("File with extension " + fileName
                                + " is not supported!");
                    }
                    msg = "Facts file uploaded successfully.";
                    fileToRedirect = "/ruleservices/rule_service_wizard_step3.jsp";
                } else if ("ruleFilename".equals(fieldName)) {
                    FileItemData fileItemData = fileItemsMap.get(fieldName).get(0);
                    String fileName = getFileName(fileItemData.getFileItem().getName());
                    adminClient.uploadRuleFile(ruleServiceName,
                            fileName, fileItemData.getDataHandler(), request);
                    msg = "Rule Script file uploaded successfully.";
                    fileToRedirect = "/ruleservices/rule_service_wizard_step2.jsp";
                }
            }
            response.setContentType("text/html; charset=utf-8");
View Full Code Here

        }

        try {
            for (Object o : fileItemsMap.keySet()) {
                String fieldName = (String) o;
                FileItemData fileItemData = fileItemsMap.get(fieldName).get(0);
                String fileName = getFileName(fileItemData.getFileItem().getName());
                File servicesDir;
                File uploadedFile;
                if (fieldName.trim().equals("springBeans")) {
                    String uuid = generateUUID();
                    String serviceUploadDir = getWorkingDir() +
                            File.separator + "spring" +
                            File.separator + uuid +
                            File.separator;

                    if (fileName.endsWith(".jar")) {

                        servicesDir = new File(serviceUploadDir);
                        servicesDir.mkdirs();
                        uploadedFile = new File(servicesDir, fileName);

                        uuids[0] = uuid;
                        fileResourceMap.put(uuid, uploadedFile.getAbsolutePath());
                        fileItemData.getFileItem().write(uploadedFile);
                    }

                }
                if (fieldName.trim().equals("springContext")) {
                    String uuid = generateUUID();
                    String serviceUploadDir = getWorkingDir() +
                            File.separator + "spring" +
                            File.separator + uuid +
                            File.separator;
                    //Assumed this is the springs applicationContext.xml
                    // This can be safely assumed as, this class has been written only for
                    // uploading this.
                    servicesDir = new File(serviceUploadDir);
                    servicesDir.mkdirs();
                    uploadedFile = new File(servicesDir, fileName);

                    uuids[1] = uuid;
                    fileResourceMap.put(uuid, uploadedFile.getAbsolutePath());
                    fileItemData.getFileItem().write(uploadedFile);

                }

            }
            response.setContentType("text/html; charset=utf-8");
View Full Code Here

            }
            if (symlinkLocation != null) {
                symlinkLocation = chroot + symlinkLocation;
            }

            FileItemData fileItemData = fileItemsMap.get("upload").get(0);

            if ((fileItemData == null) || (fileItemData.getFileItem().getSize() == 0)) {
                String msg = "Failed add resource. Resource content is empty.";
                log.error(msg);

                buildUIError(request, response, webContext, errorRedirect, msg);
                return false;
            }
            DataHandler dataHandler = fileItemData.getDataHandler();

            client.addResource(
                    calcualtePath(parentPath, resourceName), mediaType, description, dataHandler,
                    symlinkLocation);
View Full Code Here

TOP

Related Classes of org.wso2.carbon.utils.FileItemData

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.