use of org.pentaho.di.plugins.fileopensave.api.providers.exception.InvalidFileTypeException in project pentaho-kettle by pentaho.
the class RepositoryFileProvider method writeFile.
@Override
public RepositoryFile writeFile(InputStream inputStream, RepositoryFile destDir, String path, boolean overwrite) throws FileException {
RepositoryObjectType type = getType(path);
String name = Util.getName(path).replace(" ", "_");
RepositoryElementInterface repositoryElementInterface = null;
if (type != null) {
if (type.equals(RepositoryObjectType.TRANSFORMATION)) {
try {
repositoryElementInterface = new TransMeta(inputStream, null, false, null, null);
} catch (KettleException e) {
return null;
}
} else if (type.equals(RepositoryObjectType.JOB)) {
try {
repositoryElementInterface = new JobMeta(inputStream, null, null);
} catch (KettleException e) {
return null;
}
} else {
throw new InvalidFileTypeException();
}
}
try {
RepositoryDirectoryInterface directoryInterface = getRepository().findDirectory(destDir.getPath());
if (repositoryElementInterface != null) {
repositoryElementInterface.setRepositoryDirectory(directoryInterface);
getRepository().save(repositoryElementInterface, null, null);
return null;
}
return null;
} catch (KettleException e) {
return null;
}
}
Aggregations