use of io.syndesis.server.dao.DaoException in project syndesis by syndesisio.
the class SqlFileStore method move.
public boolean move(String fromPath, String toPath) {
FileStoreSupport.checkValidPath(fromPath);
FileStoreSupport.checkValidPath(toPath);
try {
return dbi.inTransaction((h, status) -> {
boolean existed = h.select("SELECT 1 from filestore WHERE path=?", fromPath).size() > 0;
if (existed) {
doDelete(h, toPath);
h.update("UPDATE filestore SET path=? WHERE path=?", toPath, fromPath);
}
return existed;
});
} catch (CallbackFailedException ex) {
throw new DaoException("Unable to move file from path " + fromPath + " to path " + toPath, ex);
}
}
use of io.syndesis.server.dao.DaoException in project syndesis by syndesisio.
the class SqlFileStore method write.
public void write(String path, InputStream file) {
FileStoreSupport.checkValidPath(path);
Objects.requireNonNull(file, "file cannot be null");
try {
dbi.inTransaction((h, status) -> {
doWrite(h, path, file);
return true;
});
} catch (CallbackFailedException ex) {
throw new DaoException("Unable to write on path " + path, ex);
}
}
use of io.syndesis.server.dao.DaoException in project syndesis by syndesisio.
the class SqlFileStore method writeTemporaryFile.
public String writeTemporaryFile(InputStream file) {
Objects.requireNonNull(file, "file cannot be null");
try {
return dbi.inTransaction((h, status) -> {
String path = newRandomTempFilePath();
doWrite(h, path, file);
return path;
});
} catch (CallbackFailedException ex) {
throw new DaoException("Unable to write on temporary path", ex);
}
}
use of io.syndesis.server.dao.DaoException in project syndesis by syndesisio.
the class SqlFileStore method doReadStandard.
private InputStream doReadStandard(Handle h, String path) {
List<Map<String, Object>> res = h.select("SELECT data FROM filestore WHERE path=?", path);
Optional<Blob> blob = res.stream().map(row -> row.get("data")).map(Blob.class::cast).findFirst();
if (blob.isPresent()) {
try {
return blob.get().getBinaryStream();
} catch (SQLException ex) {
throw new DaoException("Unable to read from BLOB", ex);
}
}
return null;
}
Aggregations