From 50ef68260c2dab843aec14c056b36451082d6a1b Mon Sep 17 00:00:00 2001 From: jdewinne Date: Thu, 12 Feb 2015 09:34:48 +0100 Subject: [PATCH] Renamed FlowDock to Flowdock --- README.md | 8 ++--- .../{FlowDockApi.java => FlowdockApi.java} | 26 +++++++-------- ...ration.java => FlowdockConfiguration.java} | 4 +-- ...ockListener.java => FlowdockListener.java} | 28 ++++++++-------- ...wDockMessage.java => FlowdockMessage.java} | 2 +- ...ce.java => FlowdockRepositoryService.java} | 32 +++++++++---------- .../flowdock/plugin/TeamInboxMessage.java | 3 +- ...kException.java => FlowdockException.java} | 4 +-- ...va => FlowdockNotConfiguredException.java} | 2 +- 9 files changed, 54 insertions(+), 55 deletions(-) rename src/main/java/com/xebialabs/xlrelease/flowdock/plugin/{FlowDockApi.java => FlowdockApi.java} (76%) rename src/main/java/com/xebialabs/xlrelease/flowdock/plugin/{FlowDockConfiguration.java => FlowdockConfiguration.java} (84%) rename src/main/java/com/xebialabs/xlrelease/flowdock/plugin/{FlowDockListener.java => FlowdockListener.java} (62%) rename src/main/java/com/xebialabs/xlrelease/flowdock/plugin/{FlowDockMessage.java => FlowdockMessage.java} (93%) rename src/main/java/com/xebialabs/xlrelease/flowdock/plugin/{FlowDockRepositoryService.java => FlowdockRepositoryService.java} (54%) rename src/main/java/com/xebialabs/xlrelease/flowdock/plugin/exception/{FlowDockException.java => FlowdockException.java} (57%) rename src/main/java/com/xebialabs/xlrelease/flowdock/plugin/exception/{FlowDockNotConfiguredException.java => FlowdockNotConfiguredException.java} (61%) diff --git a/README.md b/README.md index 88f33aa..1a37890 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Preface # -This document describes the functionality provided by the XL Release FlowDock plugin. +This document describes the functionality provided by the XL Release Flowdock plugin. See the **XL Release Reference Manual** for background information on XL Release and release orchestration concepts. # Overview # -The XL Release FlowDock plugin is a XL Release plugin that adds capability for sending message to a flowdock inbox. +The XL Release Flowdock plugin is a XL Release plugin that adds capability for sending message to a flowdock inbox. # Requirements # @@ -22,5 +22,5 @@ Place the plugin JAR file into your `SERVER_HOME/plugins` directory. 1. Go to `Settings - Configuration - Flowdock: Configuration`, add a new configuration 2. Provide Title (Can be anything) 3. Provide API url (eg: https://api.flowdock.com) -4. Provide Flow token (See your Flow configuration in FlowDock) -5. Enable or Disable the FlowDock configuration. +4. Provide Flow token (See your Flow configuration in Flowdock) +5. Enable or Disable the Flowdock configuration. diff --git a/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowDockApi.java b/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowdockApi.java similarity index 76% rename from src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowDockApi.java rename to src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowdockApi.java index d38184a..605a865 100644 --- a/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowDockApi.java +++ b/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowdockApi.java @@ -1,7 +1,7 @@ package com.xebialabs.xlrelease.flowdock.plugin; -import com.xebialabs.xlrelease.flowdock.plugin.exception.FlowDockException; +import com.xebialabs.xlrelease.flowdock.plugin.exception.FlowdockException; import java.net.HttpURLConnection; import java.net.URL; @@ -16,25 +16,25 @@ /** * Created by jdewinne on 2/5/15. */ -public class FlowDockApi { - private FlowDockConfiguration flowDockConfiguration; +public class FlowdockApi { + private FlowdockConfiguration flowdockConfiguration; - public FlowDockApi(FlowDockConfiguration flowDockConfiguration) { - this.flowDockConfiguration = flowDockConfiguration; + public FlowdockApi(FlowdockConfiguration flowdockConfiguration) { + this.flowdockConfiguration = flowdockConfiguration; } - public void pushTeamInboxMessage(TeamInboxMessage msg) throws FlowDockException { + public void pushTeamInboxMessage(TeamInboxMessage msg) throws FlowdockException { try { doPost("/messages/team_inbox/", msg.asPostData()); } catch(UnsupportedEncodingException ex) { - throw new FlowDockException("Cannot encode request data: " + ex.getMessage()); + throw new FlowdockException("Cannot encode request data: " + ex.getMessage()); } } - private void doPost(String path, String data) throws FlowDockException { + private void doPost(String path, String data) throws FlowdockException { URL url; HttpURLConnection connection = null; - String flowdockUrl = flowDockConfiguration.getApiUrl() + path + flowDockConfiguration.getFlowToken(); + String flowdockUrl = flowdockConfiguration.getApiUrl() + path + flowdockConfiguration.getFlowToken(); try { // create connection url = new URL(flowdockUrl); @@ -64,17 +64,17 @@ private void doPost(String path, String data) throws FlowDockException { } catch(Exception ex) { // nothing we can do about this } finally { - throw new FlowDockException("Flowdock returned an error response with status " + + throw new FlowdockException("Flowdock returned an error response with status " + connection.getResponseCode() + " " + connection.getResponseMessage() + ", " + responseContent.toString() + "\n\nURL: " + flowdockUrl); } } } catch(MalformedURLException ex) { - throw new FlowDockException("Flowdock API URL is invalid: " + flowdockUrl); + throw new FlowdockException("Flowdock API URL is invalid: " + flowdockUrl); } catch(ProtocolException ex) { - throw new FlowDockException("ProtocolException in connecting to Flowdock: " + ex.getMessage()); + throw new FlowdockException("ProtocolException in connecting to Flowdock: " + ex.getMessage()); } catch(IOException ex) { - throw new FlowDockException("IOException in connecting to Flowdock: " + ex.getMessage()); + throw new FlowdockException("IOException in connecting to Flowdock: " + ex.getMessage()); } } diff --git a/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowDockConfiguration.java b/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowdockConfiguration.java similarity index 84% rename from src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowDockConfiguration.java rename to src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowdockConfiguration.java index 4713df9..c2e8b19 100644 --- a/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowDockConfiguration.java +++ b/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowdockConfiguration.java @@ -3,13 +3,13 @@ /** * Created by jdewinne on 2/5/15. */ -public class FlowDockConfiguration { +public class FlowdockConfiguration { private String apiUrl = ""; private String flowToken = ""; private Boolean enabled = Boolean.FALSE; - public FlowDockConfiguration(String apiUrl, String flowToken, Boolean enabled) { + public FlowdockConfiguration(String apiUrl, String flowToken, Boolean enabled) { this.apiUrl = apiUrl; this.flowToken = flowToken.replaceAll("\\s", ""); this.enabled = enabled; diff --git a/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowDockListener.java b/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowdockListener.java similarity index 62% rename from src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowDockListener.java rename to src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowdockListener.java index 34ea249..b28d66a 100644 --- a/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowDockListener.java +++ b/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowdockListener.java @@ -6,8 +6,8 @@ import com.xebialabs.deployit.plugin.api.reflect.Type; import com.xebialabs.deployit.plugin.api.udm.ConfigurationItem; -import com.xebialabs.xlrelease.flowdock.plugin.exception.FlowDockException; -import com.xebialabs.xlrelease.flowdock.plugin.exception.FlowDockNotConfiguredException; +import com.xebialabs.xlrelease.flowdock.plugin.exception.FlowdockException; +import com.xebialabs.xlrelease.flowdock.plugin.exception.FlowdockNotConfiguredException; import nl.javadude.t2bus.Subscribe; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -19,29 +19,29 @@ * Created by jdewinne on 2/4/15. */ @DeployitEventListener -public class FlowDockListener { +public class FlowdockListener { - Logger logger = LoggerFactory.getLogger(FlowDockListener.class); + Logger logger = LoggerFactory.getLogger(FlowdockListener.class); - public FlowDockListener() { + public FlowdockListener() { } @Subscribe - public void sendUpdateToFlowDock(AuditableDeployitEvent event) { - FlowDockRepositoryService flowDockRepositoryService = new FlowDockRepositoryService(); + public void sendUpdateToFlowdock(AuditableDeployitEvent event) { + FlowdockRepositoryService flowdockRepositoryService = new FlowdockRepositoryService(); try { - if (flowDockRepositoryService.isFlowDockEnabled()) { + if (flowdockRepositoryService.isFlowdockEnabled()) { if (event instanceof CiBaseEvent) { CiBaseEvent ciEvent = (CiBaseEvent) event; for (ConfigurationItem ci : ciEvent.getCis()) { if (ci.getType().equals(Type.valueOf("xlrelease.ActivityLogEntry"))) { // Get flowdock properties - List flowDockConfigurations = flowDockRepositoryService.getFlowDockConfigurations(); + List flowdockConfigurations = flowdockRepositoryService.getFlowdockConfigurations(); - for (FlowDockConfiguration flowDockConfiguration : flowDockConfigurations) { - if (flowDockConfiguration.isEnabled()) { + for (FlowdockConfiguration flowdockConfiguration : flowdockConfigurations) { + if (flowdockConfiguration.isEnabled()) { // Send message to flowdock - FlowDockApi api = new FlowDockApi(flowDockConfiguration); + FlowdockApi api = new FlowdockApi(flowdockConfiguration); TeamInboxMessage msg = TeamInboxMessage.fromAuditableDeployitEvent(ci); api.pushTeamInboxMessage(msg); logger.info("Flowdock: Team Inbox notification sent successfully"); @@ -51,9 +51,9 @@ public void sendUpdateToFlowDock(AuditableDeployitEvent event) { } } } - } catch (FlowDockNotConfiguredException e) { + } catch (FlowdockNotConfiguredException e) { // Do nothing, as Flowdock is not yet configured. - } catch (FlowDockException e) { + } catch (FlowdockException e) { e.printStackTrace(); } diff --git a/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowDockMessage.java b/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowdockMessage.java similarity index 93% rename from src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowDockMessage.java rename to src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowdockMessage.java index cde2deb..9ebdb49 100644 --- a/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowDockMessage.java +++ b/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowdockMessage.java @@ -6,7 +6,7 @@ /** * Created by jdewinne on 2/5/15. */ -public abstract class FlowDockMessage { +public abstract class FlowdockMessage { protected String content; protected String tags; diff --git a/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowDockRepositoryService.java b/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowdockRepositoryService.java similarity index 54% rename from src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowDockRepositoryService.java rename to src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowdockRepositoryService.java index 1581e49..5cf065a 100644 --- a/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowDockRepositoryService.java +++ b/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/FlowdockRepositoryService.java @@ -4,7 +4,7 @@ import com.xebialabs.deployit.plugin.api.udm.ConfigurationItem; import com.xebialabs.xlrelease.api.XLReleaseServiceHolder; import com.xebialabs.deployit.repository.SearchParameters; -import com.xebialabs.xlrelease.flowdock.plugin.exception.FlowDockNotConfiguredException; +import com.xebialabs.xlrelease.flowdock.plugin.exception.FlowdockNotConfiguredException; import java.util.ArrayList; import java.util.List; @@ -12,42 +12,42 @@ /** * Created by jdewinne on 2/5/15. */ -public class FlowDockRepositoryService { +public class FlowdockRepositoryService { - private List flowDockConfigurations; + private List flowdockConfigurations; - public List getFlowDockConfigurations() throws FlowDockNotConfiguredException { - if (flowDockConfigurations == null) { - setFlowDockConfigurations(); + public List getFlowdockConfigurations() throws FlowdockNotConfiguredException { + if (flowdockConfigurations == null) { + setFlowdockConfigurations(); } - return flowDockConfigurations; + return flowdockConfigurations; } - public Boolean isFlowDockEnabled() throws FlowDockNotConfiguredException { - if (flowDockConfigurations == null) { - setFlowDockConfigurations(); + public Boolean isFlowdockEnabled() throws FlowdockNotConfiguredException { + if (flowdockConfigurations == null) { + setFlowdockConfigurations(); } - for (FlowDockConfiguration flowDockConfiguration : flowDockConfigurations) { - if (flowDockConfiguration.isEnabled()) { + for (FlowdockConfiguration flowdockConfiguration : flowdockConfigurations) { + if (flowdockConfiguration.isEnabled()) { return Boolean.TRUE; } } return Boolean.FALSE; } - private void setFlowDockConfigurations() throws FlowDockNotConfiguredException { + private void setFlowdockConfigurations() throws FlowdockNotConfiguredException { // Get flowdock properties SearchParameters parameters = new SearchParameters().setType(Type.valueOf("flowdock.configuration")); List query = XLReleaseServiceHolder.getRepositoryService().listEntities(parameters); if (query.size() > 0) { - flowDockConfigurations = new ArrayList(); + flowdockConfigurations = new ArrayList(); for (ConfigurationItem read : query) { - flowDockConfigurations.add(new FlowDockConfiguration((String) read.getProperty("apiUrl"), (String) read.getProperty("flowToken"), (Boolean) read.getProperty("enabled"))); + flowdockConfigurations.add(new FlowdockConfiguration((String) read.getProperty("apiUrl"), (String) read.getProperty("flowToken"), (Boolean) read.getProperty("enabled"))); } } else { - throw new FlowDockNotConfiguredException(); + throw new FlowdockNotConfiguredException(); } } diff --git a/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/TeamInboxMessage.java b/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/TeamInboxMessage.java index e847f4d..c318dbe 100644 --- a/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/TeamInboxMessage.java +++ b/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/TeamInboxMessage.java @@ -1,6 +1,5 @@ package com.xebialabs.xlrelease.flowdock.plugin; -import com.xebialabs.deployit.engine.spi.event.AuditableDeployitEvent; import com.xebialabs.deployit.plugin.api.udm.ConfigurationItem; import java.io.UnsupportedEncodingException; @@ -8,7 +7,7 @@ /** * Created by jdewinne on 2/5/15. */ -public class TeamInboxMessage extends FlowDockMessage { +public class TeamInboxMessage extends FlowdockMessage { public static final String XLRELEASE_RELEASE_STARTED_MAIL = "xlrelease+started@flowdock.com"; diff --git a/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/exception/FlowDockException.java b/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/exception/FlowdockException.java similarity index 57% rename from src/main/java/com/xebialabs/xlrelease/flowdock/plugin/exception/FlowDockException.java rename to src/main/java/com/xebialabs/xlrelease/flowdock/plugin/exception/FlowdockException.java index e11e382..ee27bcb 100644 --- a/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/exception/FlowDockException.java +++ b/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/exception/FlowdockException.java @@ -3,8 +3,8 @@ /** * Created by jdewinne on 2/5/15. */ -public class FlowDockException extends Throwable { - public FlowDockException(String message) { +public class FlowdockException extends Throwable { + public FlowdockException(String message) { super(message); } } diff --git a/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/exception/FlowDockNotConfiguredException.java b/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/exception/FlowdockNotConfiguredException.java similarity index 61% rename from src/main/java/com/xebialabs/xlrelease/flowdock/plugin/exception/FlowDockNotConfiguredException.java rename to src/main/java/com/xebialabs/xlrelease/flowdock/plugin/exception/FlowdockNotConfiguredException.java index b2d268d..b213d22 100644 --- a/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/exception/FlowDockNotConfiguredException.java +++ b/src/main/java/com/xebialabs/xlrelease/flowdock/plugin/exception/FlowdockNotConfiguredException.java @@ -3,5 +3,5 @@ /** * Created by jdewinne on 2/5/15. */ -public class FlowDockNotConfiguredException extends Throwable { +public class FlowdockNotConfiguredException extends Throwable { }