[#1] add client environment

add client cut
code cleanup
Signed-off-by: Ori Bruk <o.bruk@yadro.com>
This commit is contained in:
Ori Bruk 2024-07-22 19:13:52 +03:00
parent dc0eef770c
commit b0db7df192
95 changed files with 1202 additions and 560 deletions

View file

@ -0,0 +1,76 @@
package info.FrostFS.sdk.tools;
import info.FrostFS.sdk.dto.object.ObjectHeader;
import java.io.FileInputStream;
import static java.util.Objects.isNull;
public class PutObjectParameters {
private static final String ERROR_TEMPLATE = "%s value cannot be null.";
public ObjectHeader header;
public FileInputStream payload;
public boolean clientCut;
public int bufferMaxSize;
public PutObjectParameters(ObjectHeader header, FileInputStream payload, boolean clientCut, int bufferMaxSize) {
this.header = header;
this.payload = payload;
this.clientCut = clientCut;
this.bufferMaxSize = bufferMaxSize;
}
public PutObjectParameters(ObjectHeader header, FileInputStream payload) {
this.header = header;
this.payload = payload;
}
public ObjectHeader getHeader() {
return header;
}
public void setHeader(ObjectHeader header) {
this.header = header;
}
public FileInputStream getPayload() {
return payload;
}
public void setPayload(FileInputStream payload) {
this.payload = payload;
}
public boolean isClientCut() {
return clientCut;
}
public void setClientCut(boolean clientCut) {
this.clientCut = clientCut;
}
public int getBufferMaxSize() {
return bufferMaxSize;
}
public void setBufferMaxSize(int bufferMaxSize) {
this.bufferMaxSize = bufferMaxSize;
}
public void validate() {
StringBuilder errorMessage = new StringBuilder();
if (isNull(header)) {
errorMessage.append(String.format(ERROR_TEMPLATE, "Header")).append(System.lineSeparator());
}
if (isNull(payload)) {
errorMessage.append(String.format(ERROR_TEMPLATE, "Payload")).append(System.lineSeparator());
}
if (errorMessage.length() != 0) {
throw new IllegalArgumentException(errorMessage.toString());
}
}
}