Skip to content

Commit

Permalink
Change from workspace to work services
Browse files Browse the repository at this point in the history
  • Loading branch information
Francis committed Mar 7, 2017
1 parent 4baf161 commit 01cc0a6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Watsonwork-Java-Starter
This is an app for Java which demonstrates the basic integration flows with Workspaces.
This is an app for Java which demonstrates the basic integration flows with Watson Work Services.
You can see this app:

- Post a message to a space using its own credentials
Expand Down Expand Up @@ -51,11 +51,11 @@ You can see this app:
This can only be done if you have the app set up on a public address, you can use bluemix for this, see [Run on Bluemix](#run-on-bluemix), or port forwarding if you control the wifi router.

1. Go back to the [app creation page](https://workspace.ibm.com/developer/apps) and edit your app.
2. Click on **Add an outbound webhook** and give it a name. The callback url should be your app's public base url followed by `/webhook`, for example `https://watsonwork-java-starter.mybluemix.net/webhook`. Tick the `message-created` event. Do not tick the enable checbox yet, because your app needs to know the webhook secret in order to respond to a verification request from the `Workspaces` server.
2. Click on **Add an outbound webhook** and give it a name. The callback url should be your app's public base url followed by `/webhook`, for example `https://watsonwork-java-starter.mybluemix.net/webhook`. Tick the `message-created` event. Do not tick the "enable" checkbox yet, because your app needs to know the webhook secret in order to respond to a verification request from the Watson Work Services.
3. Click the save button and take note of the **webhook secret**.
4. Go back to your **config.yml** in the local project, and fill in the value for **webhookSecret**.
5. Push to bluemix by following steps 4-6 in [Run on Bluemix](#run-on-bluemix)
6. When the app is finished pushing to bluemix, go back to the [app creation page](https://workspace.ibm.com/developer/apps) one last time, edit your app and enable the webhook. Click save. Your app will now receive webhook events of the types you asked for.
7. Go to workspaces and select the space you want to add the app to. Click the dropdown at the top of the page where its name is, and then click the **Apps** section. You will see your app here.
7. Go to Workspaces and select the space you want to add the app to. Click the dropdown at the top of the page where its name is, and then click the **Apps** section. You will see your app here.
8. Hover over your app and click **Add to space**.
9. Post a message in your space and watch your app respond.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ distributions {
}
}

mainClassName = 'app.WorkspaceApplication server "`dirname $0`/../config.yml"'
mainClassName = 'app.WorkServicesApplication server "`dirname $0`/../config.yml"'

run {
args 'server', 'config.yml'
main = 'app.WorkspaceApplication'
main = 'app.WorkServicesApplication'
}

task processManifest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package app;

import app.resources.WorkspaceResource;
import app.resources.WorkServicesResource;
import app.workspace.WorkspaceClient;
import app.workspace.WorkspaceService;
import app.workspace.auth.AuthManager;
Expand All @@ -14,9 +14,9 @@
import retrofit2.Retrofit;
import retrofit2.converter.jackson.JacksonConverterFactory;

public class WorkspaceApplication extends Application<WorkspaceConfiguration> {
public class WorkServicesApplication extends Application<WorkServicesConfiguration> {
public static void main(String[] args) throws Exception {
new WorkspaceApplication().run(args);
new WorkServicesApplication().run(args);
}

@Override
Expand All @@ -25,12 +25,12 @@ public String getName() {
}

@Override
public void initialize(Bootstrap<WorkspaceConfiguration> bootstrap) {
public void initialize(Bootstrap<WorkServicesConfiguration> bootstrap) {
bootstrap.addBundle(new AssetsBundle("/vendor"));
}

@Override
public void run(WorkspaceConfiguration config,
public void run(WorkServicesConfiguration config,
Environment environment) {
ObjectMapper mapper = environment.getObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
Expand All @@ -43,7 +43,7 @@ public void run(WorkspaceConfiguration config,
WorkspaceClient workspaceClient = new WorkspaceClient(workspaceService, authManager);

//register jax-rs resources
final WorkspaceResource resource = new WorkspaceResource(workspaceClient, authManager);
final WorkServicesResource resource = new WorkServicesResource(workspaceClient, authManager);
environment.jersey().register(resource);

// TODO This is the app entry point. You can do what you like starting from here.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import io.dropwizard.Configuration;
import org.hibernate.validator.constraints.NotEmpty;

public class WorkspaceConfiguration extends Configuration {
public class WorkServicesConfiguration extends Configuration {
@NotEmpty
private String appId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@

@Path("")
@Produces(MediaType.APPLICATION_JSON)
public class WorkspaceResource {
public class WorkServicesResource {

@Context
private UriInfo uriInfo;
private WorkspaceClient workspaceClient;
private AuthManager authManager;

public WorkspaceResource(WorkspaceClient workspaceClient, AuthManager authManager) {
public WorkServicesResource(WorkspaceClient workspaceClient, AuthManager authManager) {
this.workspaceClient = workspaceClient;
this.authManager = authManager;
}
Expand Down Expand Up @@ -161,7 +161,7 @@ private String getRedirectUri() {
}

private String getUnauthenticatedPage() throws IOException {
String htmlTemplate = CharStreams.toString(new InputStreamReader(WorkspaceResource.class.getResourceAsStream("/unauthenticated.htm")));
String htmlTemplate = CharStreams.toString(new InputStreamReader(WorkServicesResource.class.getResourceAsStream("/unauthenticated.htm")));

return htmlTemplate
.replace("@WORKSPACE_API_URL@", authManager.getWorkspaceApiUrl())
Expand All @@ -171,7 +171,7 @@ private String getUnauthenticatedPage() throws IOException {
}

private String getAuthenticatedPage(OauthResponse oauthResponse) throws IOException {
String htmlTemplate = CharStreams.toString(new InputStreamReader(WorkspaceResource.class.getResourceAsStream("/authenticated.htm")));
String htmlTemplate = CharStreams.toString(new InputStreamReader(WorkServicesResource.class.getResourceAsStream("/authenticated.htm")));

return htmlTemplate.replace("@DISPLAY_NAME@", oauthResponse.getDisplayName());
}
Expand Down

0 comments on commit 01cc0a6

Please sign in to comment.