Package org.wso2.carbon.utils

Examples of org.wso2.carbon.utils.FileItemData


            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);

                CarbonUIMessage.sendCarbonUIMessage(msg, CarbonUIMessage.ERROR, request);
                response.sendRedirect(
                        "../" + webContext + "/admin/error.jsp");

                return false;
            }
            DataHandler dataHandler = scaleImage(fileItemData.getDataHandler(), 48, 119, 100);

            client.addResource(
                    calcualtePath(parentPath, resourceName), mediaType, description, dataHandler,
                    symlinkLocation, redirectWith);

View Full Code Here


                configurationContext, serverURL + "CarbonAppUploader", cookie);

        try {
            for (Object o : fileItemsMap.keySet()) {
                String fieldName = (String) o;
                FileItemData fileItemData = fileItemsMap.get(fieldName).get(0);
                String fileName = getFileName(fileItemData.getFileItem().getName());
                uploaderClient.addUploadedFileItem(fileItemData.getDataHandler(), fileName, "jar");
            }

            //Uploading files to back end service
            uploaderClient.uploadFileItems();
            msg = "Your Application has been uploaded successfully. Please refresh this page in a" +
View Full Code Here

        ArchiveManipulator archiveManipulator = new ArchiveManipulator();
        String[] serviceNames = new String[tempDataList.size()];
        ArrayList<File> tempFiles = new ArrayList<File>();
        try {
            for (int i = 0; i < tempDataList.size(); i++) {
                FileItemData fileData = tempDataList.get(i);
                String fileName = getFileName(fileData.getFileItem().getName());
                checkServiceFileExtensionValidity(fileName, ALLOWED_FILE_EXTENSIONS);
                JSServiceUploadData tempData = new JSServiceUploadData();
                tempData.setFileName(fileName);
                tempData.setDataHandler(fileData.getDataHandler());

                if (fileName.endsWith(".zip")) {
                    //validating the content of the zip file.
                    File zipFile = ((DeferredFileOutputStream) fileData.getFileItem().
                            getOutputStream()).getFile();
                    fileData.getFileItem().write(zipFile);
                    tempFiles.add(zipFile);
                    String[] files = archiveManipulator.check(zipFile.getAbsolutePath());
                    boolean jsFile = false;
                    boolean resourceFolder = false;
                    //validates the structure of zip file. i.e. zip file shoud contains only one
                    //.js file in the root folder and no other file types, but directories.
                    for (String file : files) {
                        if (file.indexOf("/") == -1) {
                            String extension = file.substring(file.indexOf(".") + 1);
                            String jsName = file.substring(0, (file.indexOf(".")));
                            if ("js".equals(extension)) {
                                if (jsFile) {
                                    message = getFileName(fileData.getFileItem().getName()) +
                                              " file should contain only " +
                                              "one '.js' file in the root folder";
                                    log.error(message);
                                    CarbonUIMessage
                                            .sendCarbonUIMessage(message, CarbonUIMessage.ERROR,
                                                                 request, response,
                                                                 getContextRoot(request) + "/" + webContext +
                                                                 "/js_service/upload.jsp");
                                    return false;
                                }
                                serviceNames[i] = username + "/" + jsName;
                                jsFile = true;
                            } else if ("resources".equals(extension)) {
                                if(resourceFolder) {
                                    message = getFileName(fileData.getFileItem().getName()) +
                                              " file contains an invalid file in the root folder : " +
                                              file;
                                    log.error(message);
                                    CarbonUIMessage.sendCarbonUIMessage(message, CarbonUIMessage.ERROR,
                                                                        request, response,
                                                                        getContextRoot(request) + "/" + webContext +
                                                                        "/js_service/upload.jsp");
                                    return false;
                                }
                                resourceFolder = true;
                            } else {
                                message =getFileName( fileData.getFileItem().getName()) +
                                          " file contains an invalid file in the root folder : " +
                                          file;
                                log.error(message);
                                CarbonUIMessage.sendCarbonUIMessage(message, CarbonUIMessage.ERROR,
                                                                    request, response,
                                                                    getContextRoot(request) + "/" + webContext +
                                                                    "/js_service/upload.jsp");
                                return false;
                            }
                        }
                    }
                    if (!jsFile) {
                        message =
                                getFileName(fileData.getFileItem().getName()) + " file doesn't contain a '.js'" +
                                " file in the root folder";

                        log.error(message);
                        CarbonUIMessage.sendCarbonUIMessage(message, CarbonUIMessage.ERROR, request,
                                                            response, getContextRoot(request) + "/" + webContext +
View Full Code Here

    try {
            if(!isSoapText){
                boolean hasFile = false;
                for (Object o : fileItemsMap.keySet()) {
                    String fieldName = (String) o;
                    FileItemData fileItemData = fileItemsMap.get(fieldName);
                    String fileName = getFileName(fileItemData.getFileItem().getName());
                    if (fieldName.indexOf("soapFile") > -1) {
                        uploaderClient.UploadSoapFile(fileItemData.getDataHandler());
                        hasFile = true;
                        break;
                    }
                }
                if (!hasFile) {
View Full Code Here

                    if (fileItemsMap.get(fieldName) == null) {
                        fileItemsMap.put(fieldName, new ArrayList<FileItemData>());
                    }
                    totalFileSize += item.getSize();
                    if (totalFileSize < totalFileUploadSizeLimit) {
                        fileItemsMap.get(fieldName).add(new FileItemData(item));
                    } else {
                        throw new FileSizeLimitExceededException(getFileSizeLimit() / 1024 / 1024);
                    }
                }
            }
View Full Code Here

                String fieldName = iterator.next();
                String fileName = fileItemsMap.get(fieldName).get(0).getFileItem().getName();
                if ((fileName == null || fileName.length() == 0) && multiItems) {
                    continue;
                }
                FileItemData fileItemData = fileItemsMap.get(fieldName).get(0);
                UploadedFileItem uploadedFileItem = new UploadedFileItem();
                uploadedFileItem.setDataHandler(fileItemData.getDataHandler());
                uploadedFileItem.setFileName(fileName);
                uploadedFileItem.setFileType("");
                uploadedFileItems[i] = uploadedFileItem;
                i++;
            }
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);

                CarbonUIMessage.sendCarbonUIMessage(msg, CarbonUIMessage.ERROR, request);
                response.sendRedirect(
                        "../" + webContext + "/admin/error.jsp");

                return false;
            }
            DataHandler dataHandler = scaleImage(fileItemData.getDataHandler(), 48, 119);

            client.addResource(
                    calculatePath(parentPath, resourceName), mediaType, description, dataHandler,
                    symlinkLocation, redirectWith);

View Full Code Here

                    if (fileItemsMap.get().get(fieldName) == null) {
                        fileItemsMap.get().put(fieldName, new ArrayList<FileItemData>());
                    }
                    totalFileSize += item.getSize();
                    if (totalFileSize < totalFileUploadSizeLimit) {
                        fileItemsMap.get().get(fieldName).add(new FileItemData(item));
                    } else {
                        throw new FileSizeLimitExceededException(getFileSizeLimit() / 1024 / 1024);
                    }
                }
            }
View Full Code Here

                String fieldName = iterator.next();
                String fileName = fileItemsMap.get().get(fieldName).get(0).getFileItem().getName();
                if ((fileName == null || fileName.length() == 0) && multiItems) {
                    continue;
                }
                FileItemData fileItemData = fileItemsMap.get().get(fieldName).get(0);
                UploadedFileItem uploadedFileItem = new UploadedFileItem();
                uploadedFileItem.setDataHandler(fileItemData.getDataHandler());
                uploadedFileItem.setFileName(fileName);
                uploadedFileItem.setFileType("");
                uploadedFileItems[i] = uploadedFileItem;
                i++;
            }
View Full Code Here

     * @throws EventException event
     */
    private void processGetStatusRequest(MessageContext mc,
                                         ResponseMessageBuilder messageBuilder)
            throws AxisFault, EventException {
        Subscription subscription =
                SubscriptionMessageBuilder.createGetStatusMessage(mc);
        if (log.isDebugEnabled()) {
            log.debug("GetStatus request recived for SynapseSubscription ID : " +
                    subscription.getId());
        }
        subscription = subscriptionManager.getSubscription(subscription.getId());
        if (subscription != null) {
            if (log.isDebugEnabled()) {
                log.debug("Sending GetStatus responce for SynapseSubscription ID : " +
                        subscription.getId());
            }
            //send the responce
            SOAPEnvelope soapEnvelope = messageBuilder.genGetStatusResponse(subscription);
            dispatchResponse(soapEnvelope, EventingConstants.WSE_GET_STATUS_RESPONSE,
                    mc, false);
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.