Skip to content
This repository has been archived by the owner on Jul 21, 2020. It is now read-only.

Update of title/name of channel #44

Open
OsteHovel opened this issue Aug 19, 2016 · 4 comments
Open

Update of title/name of channel #44

OsteHovel opened this issue Aug 19, 2016 · 4 comments

Comments

@OsteHovel
Copy link

I have a issue with updating the title, I can get the BeamChannel using

 Futures.addCallback(beam.use(ChannelsService.class).findOne(beamUser.channel.id), new ResponseHandler<BeamChannel>() {

but how do i update the title/name and push it back again?
Ive tried to change the name by:

beamChannel.name = "Maybe API is working?";
Futures.addCallback(beam.use(ChannelsService.class).update(beamChannel), new ResponseHandler<BeamChannel>() {

I get this error:

aug 18, 2016 1:29:55 PM com.google.common.util.concurrent.ExecutionList executeListener
SEVERE: RuntimeException while executing runnable com.google.common.util.concurrent.Futures$5@120db25 with executor com.google.common.util.concurrent.MoreExecutors$SameThreadExecutorService@73c6c8da
java.lang.NullPointerException: null value in entry: streamKey=null
at com.google.common.collect.CollectPreconditions.checkEntryNotNull(CollectPreconditions.java:33)

Code

package com.ostsoft.stream.beam;

import com.google.common.util.concurrent.Futures;
import pro.beam.api.BeamAPI;
import pro.beam.api.resource.BeamUser;
import pro.beam.api.resource.channel.BeamChannel;
import pro.beam.api.services.impl.ChannelsService;
import pro.beam.api.services.impl.UsersService;
import pro.beam.api.util.ResponseHandler;

import java.net.URI;

public class TestBeam {

    public static void main(String[] args) throws InterruptedException {
        new TestBeam("YourUsername", "YourPassword");
    }

    private BeamAPI beam;

    private TestBeam(String username, String password) {
        beam = new BeamAPI(URI.create("https://beam.pro/api/v1/"), username, password);
        Futures.addCallback(beam.use(UsersService.class).login(username, password), new ResponseHandler<BeamUser>() {
            @Override
            public void onSuccess(BeamUser beamUser) {
                Futures.addCallback(beam.use(ChannelsService.class).findOne(beamUser.channel.id), new ResponseHandler<BeamChannel>() {
                    @Override
                    public void onSuccess(BeamChannel beamChannel) {
                        beamChannel.name = "Maybe API is working?";
                        Futures.addCallback(beam.use(ChannelsService.class).update(beamChannel), new ResponseHandler<BeamChannel>() {
                            @Override
                            public void onSuccess(BeamChannel beamChannel) {
                                System.out.println(beamChannel.name);
                            }
                        });
                    }
                });
            }
        });


    }

}

Complete stacktrace

aug 18, 2016 2:25:44 PM com.google.common.util.concurrent.ExecutionList executeListener
SEVERE: RuntimeException while executing runnable com.google.common.util.concurrent.Futures$5@767c3401 with executor com.google.common.util.concurrent.MoreExecutors$SameThreadExecutorService@316aba68
java.lang.NullPointerException: null value in entry: streamKey=null
    at com.google.common.collect.CollectPreconditions.checkEntryNotNull(CollectPreconditions.java:33)
    at com.google.common.collect.ImmutableMap.entryOf(ImmutableMap.java:135)
    at com.google.common.collect.ImmutableMap$Builder.put(ImmutableMap.java:206)
    at pro.beam.api.services.impl.ChannelsService.update(ChannelsService.java:106)
    at com.ostsoft.stream.beam.TestBeam$1$1.onSuccess(TestBeam.java:30)
    at com.ostsoft.stream.beam.TestBeam$1$1.onSuccess(TestBeam.java:26)
    at com.google.common.util.concurrent.Futures$5.run(Futures.java:1231)
    at com.google.common.util.concurrent.MoreExecutors$SameThreadExecutorService.execute(MoreExecutors.java:297)
    at com.google.common.util.concurrent.ExecutionList.executeListener(ExecutionList.java:156)
    at com.google.common.util.concurrent.ExecutionList.execute(ExecutionList.java:145)
    at com.google.common.util.concurrent.ListenableFutureTask.done(ListenableFutureTask.java:91)
    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:384)
    at java.util.concurrent.FutureTask.set(FutureTask.java:233)
    at java.util.concurrent.FutureTask.run(FutureTask.java:274)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
@OsteHovel OsteHovel changed the title Update of title via Java Update of title/name of channel Aug 19, 2016
@ProbablePrime
Copy link
Contributor

Thank you, i'll take a look at this soon.

@OsteHovel
Copy link
Author

Bump?

@chaz-wood
Copy link

I know this is old, but the first thing I noticed is the stream key is null. This is the first I've seen this API but I don't think I should assume utilizing the username and password automatically implicate the stream key was used.

@d33pfr13d
Copy link

I have the same problem. Probably a usage error. How are we supposed to update channel information with the java api?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

4 participants