Search in sources :

Example 26 with Document

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);
}
Also used : Document(de.dytanic.cloudnet.lib.utility.document.Document) DatabaseDocument(de.dytanic.cloudnet.lib.database.DatabaseDocument)

Example 27 with 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);
}
Also used : TypeToken(com.google.gson.reflect.TypeToken) Document(de.dytanic.cloudnet.lib.utility.document.Document) DatabaseDocument(de.dytanic.cloudnet.lib.database.DatabaseDocument)

Example 28 with 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<>();
}
Also used : TypeToken(com.google.gson.reflect.TypeToken) ArrayList(java.util.ArrayList) Document(de.dytanic.cloudnet.lib.utility.document.Document) DatabaseDocument(de.dytanic.cloudnet.lib.database.DatabaseDocument)

Example 29 with Document

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;
}
Also used : Document(de.dytanic.cloudnet.lib.utility.document.Document) File(java.io.File)

Example 30 with Document

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;
}
Also used : Document(de.dytanic.cloudnet.lib.utility.document.Document) Result(de.dytanic.cloudnet.lib.network.protocol.packet.result.Result)

Aggregations

Document (de.dytanic.cloudnet.lib.utility.document.Document)69 DatabaseDocument (de.dytanic.cloudnet.lib.database.DatabaseDocument)26 TypeToken (com.google.gson.reflect.TypeToken)7 ArrayList (java.util.ArrayList)7 File (java.io.File)6 UUID (java.util.UUID)6 OfflinePlayer (de.dytanic.cloudnet.lib.player.OfflinePlayer)5 ServerGroup (de.dytanic.cloudnet.lib.server.ServerGroup)5 ServerConfig (de.dytanic.cloudnet.lib.server.ServerConfig)4 ServerInfo (de.dytanic.cloudnet.lib.server.info.ServerInfo)4 HttpURLConnection (java.net.HttpURLConnection)4 URL (java.net.URL)4 ConnectableAddress (de.dytanic.cloudnet.lib.ConnectableAddress)3 CloudPlayer (de.dytanic.cloudnet.lib.player.CloudPlayer)3 Template (de.dytanic.cloudnet.lib.server.template.Template)3 ServerInstallablePlugin (de.dytanic.cloudnet.lib.service.plugin.ServerInstallablePlugin)3 SimpledUser (de.dytanic.cloudnet.lib.user.SimpledUser)3 Acceptable (de.dytanic.cloudnet.lib.utility.Acceptable)3 MinecraftServer (de.dytanic.cloudnetcore.network.components.MinecraftServer)3 IOException (java.io.IOException)3