Search in sources :

Example 26 with TypeToken

use of com.google.gson.reflect.TypeToken in project Applozic-Android-SDK by AppLozic.

the class ChannelClientService method createMultipleChannels.

public List<ChannelFeed> createMultipleChannels(List<ChannelInfo> channels) {
    List<ChannelFeed> channelFeeds = null;
    try {
        String jsonFromObject = GsonUtils.getJsonFromObject(channels, new TypeToken<List<ChannelInfo>>() {
        }.getType());
        String createChannelResponse = httpRequestUtils.postData(getCreateMultipleChannelUrl(), "application/json", "application/json", jsonFromObject);
        Utils.printLog(context, TAG, "Create Multiple channel Response :" + createChannelResponse);
        MultipleChannelFeedApiResponse channelFeedApiResponse = (MultipleChannelFeedApiResponse) GsonUtils.getObjectFromJson(createChannelResponse, MultipleChannelFeedApiResponse.class);
        if (channelFeedApiResponse != null && channelFeedApiResponse.isSuccess()) {
            channelFeeds = channelFeedApiResponse.getResponse();
        }
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
    return channelFeeds;
}
Also used : TypeToken(com.google.gson.reflect.TypeToken) ChannelInfo(com.applozic.mobicomkit.api.people.ChannelInfo) SyncChannelFeed(com.applozic.mobicomkit.sync.SyncChannelFeed) ChannelFeed(com.applozic.mobicomkit.feed.ChannelFeed) MultipleChannelFeedApiResponse(com.applozic.mobicomkit.MultipleChannelFeedApiResponse)

Example 27 with TypeToken

use of com.google.gson.reflect.TypeToken in project CloudNet by Dytanic.

the class PacketInUpdateServerGroup method handleInput.

@Override
public void handleInput(Document data, PacketSender packetSender) {
    ServerGroup proxyGroup = data.getObject("group", new TypeToken<ServerGroup>() {
    }.getType());
    CloudNet.getInstance().getConfig().createGroup(proxyGroup);
    try {
        CloudNet.getInstance().getConfig().load();
    } catch (Exception e) {
        e.printStackTrace();
    }
    CloudNet.getInstance().getServerGroups().clear();
    CloudNet.getInstance().getProxyGroups().clear();
    NetworkUtils.addAll(CloudNet.getInstance().getServerGroups(), CloudNet.getInstance().getConfig().getServerGroups(), new Acceptable<ServerGroup>() {

        @Override
        public boolean isAccepted(ServerGroup value) {
            System.out.println("Loading server group: " + value.getName());
            return true;
        }
    });
    NetworkUtils.addAll(CloudNet.getInstance().getProxyGroups(), CloudNet.getInstance().getConfig().getProxyGroups(), new Acceptable<ProxyGroup>() {

        @Override
        public boolean isAccepted(ProxyGroup value) {
            System.out.println("Loading proxy group: " + value.getName());
            return true;
        }
    });
    CloudNet.getInstance().getNetworkManager().reload();
    CloudNet.getInstance().getNetworkManager().updateAll0();
    CloudNet.getInstance().getWrappers().values().forEach(new Consumer<Wrapper>() {

        @Override
        public void accept(Wrapper wrapper) {
            wrapper.updateWrapper();
        }
    });
}
Also used : Wrapper(de.dytanic.cloudnetcore.network.components.Wrapper) ProxyGroup(de.dytanic.cloudnet.lib.server.ProxyGroup) ServerGroup(de.dytanic.cloudnet.lib.server.ServerGroup) TypeToken(com.google.gson.reflect.TypeToken)

Example 28 with TypeToken

use of com.google.gson.reflect.TypeToken in project CloudNet by Dytanic.

the class PacketInServerDispatchCommand method handleInput.

@Override
public void handleInput(Document data, PacketSender packetSender) {
    DefaultType defaultType = data.getObject("defaultType", new TypeToken<DefaultType>() {
    }.getType());
    String serverId = data.getString("serverId");
    String commandLine = data.getString("commandLine");
    if (defaultType == DefaultType.BUKKIT) {
        MinecraftServer minecraftServer = CloudNet.getInstance().getServer(serverId);
        if (minecraftServer != null) {
            minecraftServer.getWrapper().writeServerCommand(commandLine, minecraftServer.getServerInfo());
        }
        CloudServer cloudServer = CloudNet.getInstance().getCloudGameServer(serverId);
        if (cloudServer != null) {
            cloudServer.getWrapper().writeServerCommand(commandLine, minecraftServer.getServerInfo());
        }
    } else {
        ProxyServer proxyServer = CloudNet.getInstance().getProxy(serverId);
        if (proxyServer != null) {
            proxyServer.getWrapper().writeProxyCommand(commandLine, proxyServer.getProxyInfo());
        }
    }
}
Also used : DefaultType(de.dytanic.cloudnet.lib.DefaultType) TypeToken(com.google.gson.reflect.TypeToken) CloudServer(de.dytanic.cloudnetcore.network.components.CloudServer) MinecraftServer(de.dytanic.cloudnetcore.network.components.MinecraftServer) ProxyServer(de.dytanic.cloudnetcore.network.components.ProxyServer)

Example 29 with TypeToken

use of com.google.gson.reflect.TypeToken in project CloudNet by Dytanic.

the class PacketAPIInNameUUID method handleInput.

@Override
public void handleInput(Document data, PacketSender packetSender) {
    if (data.contains("uniqueId")) {
        UUID uniqueId = data.getObject("uniqueId", new TypeToken<UUID>() {
        }.getType());
        String name = CloudNet.getInstance().getDbHandlers().getNameToUUIDDatabase().get(uniqueId);
        packetSender.sendPacket(getResult(new Document("name", name)));
    } else {
        String name = data.getString("name");
        UUID uniqueId = CloudNet.getInstance().getDbHandlers().getNameToUUIDDatabase().get(name);
        packetSender.sendPacket(getResult(new Document("uniqueId", uniqueId)));
    }
}
Also used : TypeToken(com.google.gson.reflect.TypeToken) UUID(java.util.UUID) Document(de.dytanic.cloudnet.lib.utility.document.Document)

Example 30 with TypeToken

use of com.google.gson.reflect.TypeToken in project CloudNet by Dytanic.

the class PacketInUpdatePlayer method handleInput.

@Override
public void handleInput(Document data, PacketSender packetSender) {
    OfflinePlayer offlinePlayer = data.getObject("player", new TypeToken<OfflinePlayer>() {
    }.getType());
    CloudNet.getInstance().getDbHandlers().getPlayerDatabase().updatePlayer(offlinePlayer);
    if (CloudNet.getInstance().getNetworkManager().getOnlinePlayers().containsKey(offlinePlayer.getUniqueId())) {
        CloudPlayer cloudPlayer = CloudNet.getInstance().getNetworkManager().getOnlinePlayers().get(offlinePlayer.getUniqueId());
        cloudPlayer.setMetaData(offlinePlayer.getMetaData());
        cloudPlayer.setPermissionEntity(offlinePlayer.getPermissionEntity());
        CloudNet.getInstance().getNetworkManager().handlePlayerUpdate(cloudPlayer);
    } else
        CloudNet.getInstance().getNetworkManager().sendAllUpdate(new PacketOutUpdateOfflinePlayer(offlinePlayer));
}
Also used : TypeToken(com.google.gson.reflect.TypeToken) CloudPlayer(de.dytanic.cloudnet.lib.player.CloudPlayer) PacketOutUpdateOfflinePlayer(de.dytanic.cloudnetcore.network.packet.out.PacketOutUpdateOfflinePlayer) OfflinePlayer(de.dytanic.cloudnet.lib.player.OfflinePlayer) PacketOutUpdateOfflinePlayer(de.dytanic.cloudnetcore.network.packet.out.PacketOutUpdateOfflinePlayer)

Aggregations

TypeToken (com.google.gson.reflect.TypeToken)419 Gson (com.google.gson.Gson)178 Test (org.junit.Test)100 IOException (java.io.IOException)83 Map (java.util.Map)71 List (java.util.List)56 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)54 ArrayList (java.util.ArrayList)53 HashMap (java.util.HashMap)53 GsonBuilder (com.google.gson.GsonBuilder)45 File (java.io.File)34 Notebook (org.apache.zeppelin.notebook.Notebook)32 Type (java.lang.reflect.Type)31 FileNotFoundException (java.io.FileNotFoundException)29 Paragraph (org.apache.zeppelin.notebook.Paragraph)27 RestResponse (com.google.gerrit.acceptance.RestResponse)24 JsonElement (com.google.gson.JsonElement)24 JsonObject (com.google.gson.JsonObject)24 OutputStreamWriter (java.io.OutputStreamWriter)22 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)21