use of de.dytanic.cloudnet.lib.utility.document.Document in project CloudNet by Dytanic.
the class CloudFlareDatabase method putPostResponse.
public void putPostResponse(String wrapper, PostResponse postResponse) {
Document document = database.getDocument("cloudflare_cache");
document.append(wrapper, postResponse);
database.insert(document);
}
use of de.dytanic.cloudnet.lib.utility.document.Document in project CloudNet by Dytanic.
the class CloudFlareDatabase method remove.
public void remove(PostResponse postResponse) {
Document document = database.getDocument("cloudflare_cache_dnsrequests");
if (document.contains("requests")) {
Collection<String> responses = document.getObject("requests", new TypeToken<Collection<String>>() {
}.getType());
responses.remove(postResponse.getId());
document.append("requests", responses);
} else {
document.append("requests", new String[0]);
}
database.insert(document);
}
use of de.dytanic.cloudnet.lib.utility.document.Document in project CloudNet by Dytanic.
the class CloudFlareDatabase method getAndRemove.
public Collection<String> getAndRemove() {
Document document = database.getDocument("cloudflare_cache_dnsrequests");
if (document.contains("requests")) {
Collection<String> responses = document.getObject("requests", new TypeToken<Collection<String>>() {
}.getType());
document.append("requests", new String[0]);
database.insert(document);
return responses;
}
return new ArrayList<>();
}
use of de.dytanic.cloudnet.lib.utility.document.Document in project CloudNet by Dytanic.
the class DatabaseImpl method delete.
@Override
public Database delete(String name) {
Document document = getDocument(name);
if (document != null) {
documents.remove(document);
}
new File("database/" + this.name + NetworkUtils.SLASH_STRING + name).delete();
return this;
}
use of de.dytanic.cloudnet.lib.utility.document.Document in project CloudNet by Dytanic.
the class DatabaseImpl method getDocument.
@Override
public Document getDocument(String name) {
Result result = CloudAPI.getInstance().getNetworkConnection().getPacketManager().sendQuery(new PacketDBOutGetDocument(name, this.name), CloudAPI.getInstance().getNetworkConnection());
Document document = result.getResult().getDocument("result");
this.docs.put(document.getString(Database.UNIQUE_NAME_KEY), document);
return document;
}
Aggregations