org.bdware.doip.sbyterepo.JsonDO Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of doip-audit-tool Show documentation
Show all versions of doip-audit-tool Show documentation
doip audit tool developed by bdware
The newest version!
package org.bdware.doip.sbyterepo;
import com.google.gson.JsonObject;
import org.bdware.doip.codec.digitalObject.DigitalObject;
import org.bdware.doip.codec.digitalObject.DoType;
import org.bdware.doip.codec.doipMessage.DoipMessage;
import org.bdware.doip.codec.doipMessage.DoipMessageFactory;
import org.bdware.doip.codec.operations.BasicOperations;
import java.nio.charset.StandardCharsets;
public class JsonDO extends DigitalObject {
static DoipMessageFactory factory = new DoipMessageFactory();
public JsonDO(String id, DoType type) {
super(id, type);
}
public static JsonDO createDO(byte[] data) {
JsonDO digitalObject = new JsonDO(null, DoType.DO);
return digitalObject;
}
public static JsonDO updateDO(String doid, String url, String method, JsonObject headers) {
JsonDO digitalObject = new JsonDO(doid, DoType.DO);
digitalObject.addAttribute("url", url);
digitalObject.addAttribute("method", method);
digitalObject.attributes.add("headers", headers);
return digitalObject;
}
public static DoipMessage retrieveMsg(String doid, String query, JsonObject headers, byte[] body) {
DoipMessageFactory.DoipMessageBuilder builder = new DoipMessageFactory.DoipMessageBuilder();
builder.createRequest(doid, BasicOperations.Retrieve.getName());
builder.addAttributes("query", query);
builder.addAttributes("headers", headers);
builder.setBody(body);
return builder.create();
}
public static DoipMessage helloMsg(String doid) {
DoipMessageFactory.DoipMessageBuilder builder = new DoipMessageFactory.DoipMessageBuilder();
builder.createRequest(doid, BasicOperations.Hello.getName());
return builder.create();
}
//delete is not supported
}