From 01cc0a68c42879e7c13fa91e97e0a086cf4e1d5a Mon Sep 17 00:00:00 2001 From: Francis Date: Tue, 7 Mar 2017 11:20:42 +0000 Subject: [PATCH] Change from workspace to work services --- README.md | 6 +++--- build.gradle | 4 ++-- ...Application.java => WorkServicesApplication.java} | 12 ++++++------ ...iguration.java => WorkServicesConfiguration.java} | 2 +- ...kspaceResource.java => WorkServicesResource.java} | 8 ++++---- 5 files changed, 16 insertions(+), 16 deletions(-) rename src/main/java/app/{WorkspaceApplication.java => WorkServicesApplication.java} (81%) rename src/main/java/app/{WorkspaceConfiguration.java => WorkServicesConfiguration.java} (94%) rename src/main/java/app/resources/{WorkspaceResource.java => WorkServicesResource.java} (96%) diff --git a/README.md b/README.md index 77ac9b2..0c5f74b 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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. diff --git a/build.gradle b/build.gradle index 6d07222..89e9cac 100644 --- a/build.gradle +++ b/build.gradle @@ -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 { diff --git a/src/main/java/app/WorkspaceApplication.java b/src/main/java/app/WorkServicesApplication.java similarity index 81% rename from src/main/java/app/WorkspaceApplication.java rename to src/main/java/app/WorkServicesApplication.java index 4f5d151..4392367 100644 --- a/src/main/java/app/WorkspaceApplication.java +++ b/src/main/java/app/WorkServicesApplication.java @@ -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; @@ -14,9 +14,9 @@ import retrofit2.Retrofit; import retrofit2.converter.jackson.JacksonConverterFactory; -public class WorkspaceApplication extends Application { +public class WorkServicesApplication extends Application { public static void main(String[] args) throws Exception { - new WorkspaceApplication().run(args); + new WorkServicesApplication().run(args); } @Override @@ -25,12 +25,12 @@ public String getName() { } @Override - public void initialize(Bootstrap bootstrap) { + public void initialize(Bootstrap 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); @@ -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. diff --git a/src/main/java/app/WorkspaceConfiguration.java b/src/main/java/app/WorkServicesConfiguration.java similarity index 94% rename from src/main/java/app/WorkspaceConfiguration.java rename to src/main/java/app/WorkServicesConfiguration.java index fcb1bca..e651330 100644 --- a/src/main/java/app/WorkspaceConfiguration.java +++ b/src/main/java/app/WorkServicesConfiguration.java @@ -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; diff --git a/src/main/java/app/resources/WorkspaceResource.java b/src/main/java/app/resources/WorkServicesResource.java similarity index 96% rename from src/main/java/app/resources/WorkspaceResource.java rename to src/main/java/app/resources/WorkServicesResource.java index b0914ee..b043f3f 100644 --- a/src/main/java/app/resources/WorkspaceResource.java +++ b/src/main/java/app/resources/WorkServicesResource.java @@ -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; } @@ -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()) @@ -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()); }