@PUT @Path("file_format/{path: .*}") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public FileFormatUI saveFormatSettings(FileFormat fileFormat, @PathParam("path") String path) throws FileNotFoundException, HomeNotFoundException, NamespaceException { FilePath filePath = FilePath.fromURLPath(homeName, path); // merge file configs final DatasetConfig existingDSConfig = namespaceService.getDataset(filePath.toNamespaceKey()); final FileConfig oldConfig = toFileConfig(existingDSConfig); final FileConfig newConfig = fileFormat.asFileConfig(); newConfig.setCtime(oldConfig.getCtime()); newConfig.setFullPathList(oldConfig.getFullPathList()); newConfig.setName(oldConfig.getName()); newConfig.setOwner(oldConfig.getOwner()); newConfig.setLocation(oldConfig.getLocation()); catalog.createOrUpdateDataset(namespaceService, new NamespaceKey(HomeFileSystemStoragePlugin.HOME_PLUGIN_NAME), filePath.toNamespaceKey(), toDatasetConfig(newConfig, DatasetType.PHYSICAL_DATASET_HOME_FILE, securityContext.getUserPrincipal().getName(), existingDSConfig.getId())); return new FileFormatUI(FileFormat.getForFile(newConfig), filePath); }
config.setCtime(System.currentTimeMillis()); config.setFullPathList(filePath.toPathList()); config.setOwner(securityContext.getUserPrincipal().getName()); config.setType(FileFormat.getFileFormatType(Collections.singletonList(extension))); } catch (IOException ioe) {
public File getFileDataset(SourceName source, final SourceFilePath filePath, String owner) throws PhysicalDatasetNotFoundException, NamespaceException { final PhysicalDatasetConfig physicalDatasetConfig = getFilesystemPhysicalDataset(filePath, DatasetType.PHYSICAL_DATASET_SOURCE_FILE); final FileConfig fileConfig = physicalDatasetConfig.getFormatSettings(); fileConfig.setOwner(owner); fileConfig.setTag(physicalDatasetConfig.getTag()); final File file = File.newInstance(physicalDatasetConfig.getId(), filePath, FileFormat.getForFile(fileConfig), datasetService.getJobsCount(filePath.toNamespaceKey()), false, false, fileConfig.getType() != FileType.UNKNOWN, null ); return file; }
public static FileConfig toFileConfig(DatasetConfig datasetConfig) { final FileConfig fileConfig = datasetConfig.getPhysicalDataset().getFormatSettings(); fileConfig.setCtime(datasetConfig.getCreatedAt()); fileConfig.setTag(datasetConfig.getTag()); fileConfig.setOwner(datasetConfig.getOwner()); fileConfig.setFullPathList(datasetConfig.getFullPathList()); fileConfig.setName(datasetConfig.getName()); return fileConfig; }
@JsonIgnore @SuppressWarnings({ "rawtypes", "unchecked" }) public FileConfig asFileConfig() { buffer.clear(); FileConfig fc = new FileConfig(); fc.setType(getFileType()); fc.setName(name); fc.setOwner(owner); fc.setCtime(ctime); fc.setType(getFileType()); fc.setTag(getVersion()); fc.setLocation(location); byte[] bytes = ProtobufIOUtil.toByteArray(this, (Schema) getPrivateSchema(), buffer); fc.setExtendedConfig(ByteString.copyFrom(bytes)); fc.setFullPathList(fullPath); return fc; }
protected DatasetConfig addDataSet(DatasetPath path) throws Exception { final DatasetConfig dataset = new DatasetConfig() .setType(DatasetType.PHYSICAL_DATASET_SOURCE_FOLDER) .setFullPathList(path.toPathList()) .setName(path.getLeaf().getName()) .setCreatedAt(System.currentTimeMillis()) .setOwner(DEFAULT_USERNAME) .setPhysicalDataset(new PhysicalDataset() .setFormatSettings(new FileConfig().setType(FileType.PARQUET).setCtime(1L).setOwner (DEFAULT_USERNAME)) ); final NamespaceService nsService = getNamespaceService(); nsService.addOrUpdateDataset(path.toNamespaceKey(), dataset); return nsService.getDataset(path.toNamespaceKey()); } }
fileConfig.setOwner(entity.getOwner());