Skip to content
This repository has been archived by the owner on Apr 13, 2019. It is now read-only.

Commit

Permalink
Merge branch 'nrowles_enum-dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas Rowles committed Aug 24, 2016
2 parents cc43de6 + 5c0f6f8 commit 80f0893
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 24 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>

<artifactId>phone-home-api</artifactId>
<version>1.0.3-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Phone Home API</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
import org.slf4j.LoggerFactory;

import com.blackducksoftware.integration.phone.home.client.PhoneHomeClientApi;
import com.blackducksoftware.integration.phone.home.enums.BlackDuckName;
import com.blackducksoftware.integration.phone.home.enums.PhoneHomeSource;
import com.blackducksoftware.integration.phone.home.enums.ThirdPartyName;
import com.blackducksoftware.integration.phone.home.exception.PhoneHomeException;
import com.blackducksoftware.integration.phone.home.exception.PropertiesLoaderException;
import com.blackducksoftware.integration.phone.home.util.AuthenticatorUtil;
Expand Down Expand Up @@ -168,7 +170,7 @@ public void callHome(PhoneHomeInfo info, final String targetUrl) throws Resource
* as it points to a valid properties file containing the URL to
* the internal 'BlackDuck' server.
*/
public void callHomeIntegrations(final String regId, final String blackDuckName, final String blackDuckVersion, final String thirdPartyName,
public void callHomeIntegrations(final String regId, final BlackDuckName blackDuckName, final String blackDuckVersion, final ThirdPartyName thirdPartyName,
final String thirdPartyVersion, final String pluginVersion, final PhoneHomeSource source, final String propertiesPath)
throws IOException, ResourceException, JSONException, PropertiesLoaderException, PhoneHomeException {

Expand All @@ -177,9 +179,9 @@ public void callHomeIntegrations(final String regId, final String blackDuckName,
logger.debug("Integrations phone-home URL: " + targetUrl);

final Map<String, String> infoMap = new HashMap<String, String>();
infoMap.put(PhoneHomeApiConstants.BLACK_DUCK_NAME, blackDuckName);
infoMap.put(PhoneHomeApiConstants.BLACK_DUCK_NAME, blackDuckName.getName());
infoMap.put(PhoneHomeApiConstants.BLACK_DUCK_VERSION, blackDuckVersion);
infoMap.put(PhoneHomeApiConstants.THIRD_PARTY_NAME, thirdPartyName);
infoMap.put(PhoneHomeApiConstants.THIRD_PARTY_NAME, thirdPartyName.getName());
infoMap.put(PhoneHomeApiConstants.THIRD_PARTY_VERSION, thirdPartyVersion);
infoMap.put(PhoneHomeApiConstants.PLUGIN_VERSION, pluginVersion);

Expand Down Expand Up @@ -215,7 +217,7 @@ public void callHomeIntegrations(final String regId, final String blackDuckName,
* This method is used to phone-home to the internal 'BlackDuck'
* Integrations server with integrations usage information.
*/
public void callHomeIntegrations(final String regId, final String blackDuckName, final String blackDuckVersion, final String thirdPartyName,
public void callHomeIntegrations(final String regId, final BlackDuckName blackDuckName, final String blackDuckVersion, final ThirdPartyName thirdPartyName,
final String thirdPartyVersion, final String pluginVersion)
throws IOException, ResourceException, JSONException, PropertiesLoaderException, PhoneHomeException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public String toString(){
StringBuilder str = new StringBuilder();
str.append("{regId:" + regId + ", ");

str.append("source:" + source + ", ");
str.append("source:" + source.getName() + ", ");

str.append("infoMap:{");
for(String key : infoMap.keySet()){
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.blackducksoftware.integration.phone.home.enums;

public enum BlackDuckName {
HUB ("Hub"),
PROTEX ("Protex"),
CODE_CENTER ("Code-Center");

private final String name;

private BlackDuckName(String name){
this.name = name;
}

public String getName(){
return this.name;
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
package com.blackducksoftware.integration.phone.home.enums;

import com.blackducksoftware.integration.phone.home.exception.PhoneHomeException;

public enum PhoneHomeSource {
HUB, INTEGRATIONS;
HUB ("Hub"),
INTEGRATIONS ("Integrations");

private String name;

private PhoneHomeSource(String name){
this.name = name;
}

@Override
public String toString(){
String s = null;

switch(this) {
case HUB:
s = "Hub";
break;
case INTEGRATIONS:
s = "Integrations";
break;
}

return s;
public String getName(){
return this.name;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.blackducksoftware.integration.phone.home.enums;

public enum ThirdPartyName {
JENKINS ("Jenkins"),
BAMBOO ("Bamboo"),
TEAM_CITY ("Team-City"),
JIRA ("Jira"),
MAVEN ("Maven"),
GRADLE ("Gradle"),
ARTIFACTORY ("Artifactory"),
FORTIFY ("Fortify");

private final String name;

private ThirdPartyName(String name){
this.name = name;
}

public String getName(){
return this.name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
import org.mockserver.model.HttpResponse;
import org.restlet.resource.ResourceException;

import com.blackducksoftware.integration.phone.home.enums.BlackDuckName;
import com.blackducksoftware.integration.phone.home.enums.PhoneHomeSource;
import com.blackducksoftware.integration.phone.home.enums.ThirdPartyName;
import com.blackducksoftware.integration.phone.home.exception.PhoneHomeException;
import com.blackducksoftware.integration.phone.home.exception.PropertiesLoaderException;

Expand Down Expand Up @@ -133,7 +135,7 @@ public void callHomeIntegrationsTest() throws Exception {

String propertiesPath = PhoneHomeApiConstants.MOCKSERVER_CONFIG_FILE_NAME;

phClient.callHomeIntegrations("regKey", "blackDuckName", "blackDuckVersion", "thirdPartyName",
phClient.callHomeIntegrations("regKey", BlackDuckName.HUB, "blackDuckVersion", ThirdPartyName.JENKINS,
"thirdPartyVersion", "pluginVersion", PhoneHomeSource.INTEGRATIONS, propertiesPath);
}
}

0 comments on commit 80f0893

Please sign in to comment.