Search in sources :

Example 1 with MetadataTempFilesListBundleDto

use of org.pentaho.platform.dataaccess.datasource.api.resources.MetadataTempFilesListBundleDto in project data-access by pentaho.

the class DataSourceWizardService method publishDswFromTemp.

public String publishDswFromTemp(String domainId, MetadataTempFilesListDto fileList, boolean overwrite, boolean checkConnection, RepositoryFileAclDto acl) throws PentahoAccessControlException, IllegalArgumentException, DswPublishValidationException, Exception {
    String metadataTempFileName = fileList.getXmiFileName();
    InputStream metaDataFileInputStream = createInputStreamFromFile(MetadataService.getUploadDir() + File.separatorChar + metadataTempFileName);
    List<MetadataTempFilesListBundleDto> locBundles = fileList.getBundles();
    List<String> localeFileNames = new ArrayList<String>();
    List<InputStream> localeFileStreams = new ArrayList<InputStream>();
    if (locBundles != null) {
        for (MetadataTempFilesListBundleDto bundle : locBundles) {
            localeFileNames.add(bundle.getOriginalFileName());
            localeFileStreams.add(new FileInputStream(MetadataService.getUploadDir() + File.separatorChar + bundle.getTempFileName()));
        }
    }
    return publishDsw(domainId + DataSourceWizardService.METADATA_EXT, metaDataFileInputStream, localeFileStreams, localeFileNames, overwrite, checkConnection, acl);
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) MetadataTempFilesListBundleDto(org.pentaho.platform.dataaccess.datasource.api.resources.MetadataTempFilesListBundleDto) FileInputStream(java.io.FileInputStream)

Example 2 with MetadataTempFilesListBundleDto

use of org.pentaho.platform.dataaccess.datasource.api.resources.MetadataTempFilesListBundleDto in project data-access by pentaho.

the class MetadataService method uploadMetadataFilesToTempDir.

public MetadataTempFilesListDto uploadMetadataFilesToTempDir(InputStream metadataFile, List<InputStream> localeFileStreams, List<String> localeFileNames) throws Exception {
    String fileName = uploadFile(metadataFile);
    MetadataTempFilesListDto dto = new MetadataTempFilesListDto();
    dto.setXmiFileName(fileName);
    logger.info("metadata file uploaded: " + fileName);
    if (localeFileStreams != null && localeFileStreams.size() != 0) {
        List<MetadataTempFilesListBundleDto> bundles = new ArrayList<MetadataTempFilesListBundleDto>();
        int cntr = 0;
        for (InputStream inputStream : localeFileStreams) {
            fileName = uploadFile(inputStream);
            MetadataTempFilesListBundleDto bundle = new MetadataTempFilesListBundleDto(localeFileNames.get(cntr), fileName);
            bundles.add(bundle);
            logger.info("locale file uploaded: " + fileName);
            cntr++;
        }
        dto.setBundles(bundles);
    }
    return dto;
}
Also used : MetadataTempFilesListDto(org.pentaho.platform.dataaccess.datasource.api.resources.MetadataTempFilesListDto) ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) MetadataTempFilesListBundleDto(org.pentaho.platform.dataaccess.datasource.api.resources.MetadataTempFilesListBundleDto)

Example 3 with MetadataTempFilesListBundleDto

use of org.pentaho.platform.dataaccess.datasource.api.resources.MetadataTempFilesListBundleDto in project data-access by pentaho.

the class MetadataService method importMetadataFromTemp.

public void importMetadataFromTemp(String domainId, MetadataTempFilesListDto fileList, boolean overwrite, RepositoryFileAclDto acl) throws PentahoAccessControlException, PlatformImportException, Exception {
    String metadataTempFileName = fileList.getXmiFileName();
    InputStream metaDataFileInputStream = createInputStreamFromFile(internalGetUploadDir() + File.separatorChar + metadataTempFileName);
    List<MetadataTempFilesListBundleDto> locBundles = fileList.getBundles();
    List<String> localeFileNames = new ArrayList<String>();
    List<InputStream> localeFileStreams = new ArrayList<InputStream>();
    if (locBundles != null) {
        for (MetadataTempFilesListBundleDto bundle : locBundles) {
            localeFileNames.add(bundle.getOriginalFileName());
            localeFileStreams.add(createInputStreamFromFile(internalGetUploadDir() + File.separatorChar + bundle.getTempFileName()));
        }
    }
    importMetadataDatasource(domainId, metaDataFileInputStream, overwrite, localeFileStreams, localeFileNames, acl);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) MetadataTempFilesListBundleDto(org.pentaho.platform.dataaccess.datasource.api.resources.MetadataTempFilesListBundleDto)

Aggregations

FileInputStream (java.io.FileInputStream)3 InputStream (java.io.InputStream)3 ArrayList (java.util.ArrayList)3 MetadataTempFilesListBundleDto (org.pentaho.platform.dataaccess.datasource.api.resources.MetadataTempFilesListBundleDto)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 MetadataTempFilesListDto (org.pentaho.platform.dataaccess.datasource.api.resources.MetadataTempFilesListDto)1