OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Compare Revisions

Regard whitespace Rev 179 → Rev 180

/trunk/OpenConcerto/src/org/openconcerto/utils/sync/SimpleSyncClient.java
204,8 → 204,12
}
 
public DirContent getDir(final String path) throws Exception {
if (path == null) {
throw new IllegalArgumentException("null path");
}
 
final HttpsURLConnection con = openConnection("/getDir");
final Response res = checkResponseCode(send(con, NetUtils.urlEncode("rp", path, "type", "json")));
final Response res = checkResponseCode(send(con, NetUtils.urlEncode("rp", path, "type", "json"), false));
if (!res.isSuccess())
return null;
final JSONParser p = new JSONParser(JSONParser.MODE_STRICTEST);
222,8 → 226,14
static private final Set<Integer> GETFILE_OK_CODES = CollectionUtils.createSet(200, 404);
 
public Response getFile(final String path, final String fileName, final FileConsumer fileConsumer) throws IOException {
if (path == null) {
throw new IllegalArgumentException("null path");
}
if (fileName == null) {
throw new IllegalArgumentException("null fileName");
}
final HttpsURLConnection con = openConnection("/get");
send(con, NetUtils.urlEncode("rn", fileName, "rp", path));
send(con, NetUtils.urlEncode("rn", fileName, "rp", path), false);
final Response res = checkResponseCode(con, GETFILE_OK_CODES);
if (res.getCode() == 404) {
fileConsumer.accept(null, null);
240,6 → 250,13
// throwsException() and always throws. The return value is true if the file existed and was
// saved.
public boolean saveFile(final String path, final String fileName, final Path localFile) throws IOException {
if (path == null) {
throw new IllegalArgumentException("null path");
}
if (fileName == null) {
throw new IllegalArgumentException("null fileName");
}
 
final AtomicBoolean missing = new AtomicBoolean(true);
final Response res = this.getFile(path, fileName, (fileAttrs, in) -> {
missing.set(fileAttrs == null);
253,8 → 270,14
}
 
public Response deleteFile(final String path, final String fileName) throws IOException {
if (path == null) {
throw new IllegalArgumentException("null path");
}
if (fileName == null) {
throw new IllegalArgumentException("null fileName");
}
final HttpsURLConnection con = openConnection("/delete");
return checkResponseCode(send(con, NetUtils.urlEncode("rn", fileName, "rp", path)));
return checkResponseCode(send(con, NetUtils.urlEncode("rn", fileName, "rp", path), false));
}
 
public final Response renameFile(final String path, final String fileName, final String newFileName) throws IOException {
262,8 → 285,20
}
 
public final Response renameFile(final String path, final String fileName, final String newPath, final String newFileName) throws IOException {
if (path == null) {
throw new IllegalArgumentException("null path");
}
if (fileName == null) {
throw new IllegalArgumentException("null fileName");
}
if (newPath == null) {
throw new IllegalArgumentException("null newPath");
}
if (newFileName == null) {
throw new IllegalArgumentException("null newFileName");
}
final HttpsURLConnection con = openConnection("/rename");
return checkResponseCode(send(con, NetUtils.urlEncode("rn", fileName, "rp", path, "newPath", newPath, "newName", newFileName)));
return checkResponseCode(send(con, NetUtils.urlEncode("rn", fileName, "rp", path, "newPath", newPath, "newName", newFileName), false));
}
 
public Response sendFile(String path, File localFile) throws IOException {
271,6 → 306,10
}
 
public Response sendFile(String path, File localFile, final boolean overwrite) throws IOException {
if (path == null) {
throw new IllegalArgumentException("null path");
}
 
final long size = localFile.length();
if (size >= Integer.MAX_VALUE)
throw new OutOfMemoryError("Required array size too large : " + size);