org.wso2.carbon.application.mgt.stub.upload.types.carbon.UploadedFileItem Java Examples

The following examples show how to use org.wso2.carbon.application.mgt.stub.upload.types.carbon.UploadedFileItem. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DeviceAnalyticsArtifactUploaderAdminServiceImpl.java    From carbon-device-mgt with Apache License 2.0 6 votes vote down vote up
private UploadedFileItem[] loadCappFromFileSystem(String deviceType) throws IOException {

        File directory = new File(CAR_FILE_LOCATION + File.separator + deviceType);
        File[] carFiles = directory.listFiles(new FilenameFilter() {
            @Override
            public boolean accept(File dir, String name) {
                return name.toLowerCase().endsWith(".car");
            }
        });
        List<UploadedFileItem> uploadedFileItemLis = new ArrayList<>();
        if (carFiles != null) {

            for (File carFile : carFiles) {
                UploadedFileItem uploadedFileItem = new UploadedFileItem();
                DataHandler param = new DataHandler(carFile.toURI().toURL());
                uploadedFileItem.setDataHandler(param);
                uploadedFileItem.setFileName(carFile.getName());
                uploadedFileItem.setFileType("jar");
                uploadedFileItemLis.add(uploadedFileItem);
            }
        }
        UploadedFileItem[] fileItems = new UploadedFileItem[uploadedFileItemLis.size()];
        fileItems = uploadedFileItemLis.toArray(fileItems);
        return fileItems;
    }
 
Example #2
Source File: DeviceAnalyticsArtifactUploaderAdminServiceImpl.java    From carbon-device-mgt with Apache License 2.0 6 votes vote down vote up
private UploadedFileItem[] loadCappFromFileSystem(String deviceType) throws IOException {

        File directory = new File(CAR_FILE_LOCATION + File.separator + deviceType);
        File[] carFiles = directory.listFiles(new FilenameFilter() {
            @Override
            public boolean accept(File dir, String name) {
                return name.toLowerCase().endsWith(".car");
            }
        });
        List<UploadedFileItem> uploadedFileItemLis = new ArrayList<>();
        if (carFiles != null) {

            for (File carFile : carFiles) {
                UploadedFileItem uploadedFileItem = new UploadedFileItem();
                DataHandler param = new DataHandler(carFile.toURI().toURL());
                uploadedFileItem.setDataHandler(param);
                uploadedFileItem.setFileName(carFile.getName());
                uploadedFileItem.setFileType("jar");
                uploadedFileItemLis.add(uploadedFileItem);
            }
        }
        UploadedFileItem[] fileItems = new UploadedFileItem[uploadedFileItemLis.size()];
        fileItems = uploadedFileItemLis.toArray(fileItems);
        return fileItems;
    }
 
Example #3
Source File: CarbonAppUploaderClient.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public CarbonAppUploaderClient(ConfigurationContext ctx,
                               String serviceURL, String cookie)  throws AxisFault {
    stub = new CarbonAppUploaderStub(ctx, serviceURL);
    Options options =  stub._getServiceClient().getOptions();
    options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
    options.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
    options.setManageSession(true);
    //Increase the time out when sending large attachments
    options.setTimeOutInMilliSeconds(10000);
    uploadServiceTypeList = new ArrayList<UploadedFileItem>();
}
 
Example #4
Source File: CarbonAppUploaderClient.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public void addUploadedFileItem(DataHandler dataHandler, String fileName, String fileType) {
    UploadedFileItem uploadedFileItem = new UploadedFileItem();
    uploadedFileItem.setDataHandler(dataHandler);
    uploadedFileItem.setFileName(fileName);
    uploadedFileItem.setFileType(fileType);
    uploadServiceTypeList.add(uploadedFileItem);
}
 
Example #5
Source File: CarbonAppUploaderClient.java    From product-es with Apache License 2.0 5 votes vote down vote up
public void uploadCarbonAppArtifact(String fileName, DataHandler dh)
        throws RemoteException {
    UploadedFileItem[] carbonAppArray = new UploadedFileItem[1];
    UploadedFileItem carbonApp = new UploadedFileItem();

    carbonApp.setFileName(fileName);
    carbonApp.setDataHandler(dh);
    carbonApp.setFileType("jar");

    carbonAppArray[0] = carbonApp;
    carbonAppUploaderStub.uploadApp(carbonAppArray);

}
 
Example #6
Source File: CarbonAppUploaderClient.java    From carbon-commons with Apache License 2.0 4 votes vote down vote up
public void uploadFileItems() throws RemoteException {
    UploadedFileItem[] uploadServiceTypes = new UploadedFileItem[uploadServiceTypeList.size()];
    uploadServiceTypes = uploadServiceTypeList.toArray(uploadServiceTypes);
    stub.uploadApp(uploadServiceTypes);
}