Skip to content

Commit

Permalink
Refactor code to treat default token pair as a default team
Browse files Browse the repository at this point in the history
  • Loading branch information
lacostej committed Jul 31, 2013
1 parent 0c09d15 commit 74c31a4
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions src/main/java/testflight/TestflightRecorder.java
Expand Up @@ -172,27 +172,17 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, final Build
String workspace = vars.expand("$WORKSPACE");

List<TestflightUploader.UploadRequest> urList = new ArrayList<TestflightUploader.UploadRequest>();
try {
TestflightUploader.UploadRequest ur = createPartialUploadRequest(new TestflightTeam(getTokenPairName(), getFilePath(), getDsymPath()), vars, build);
urList.add(ur);
} catch (MisconfiguredJobException mje) {
listener.getLogger().println(mje.getConfigurationMessage());
return false;
}

if(additionalTeams != null) {
for(TestflightTeam team : additionalTeams) {
try {
TestflightUploader.UploadRequest ur = createPartialUploadRequest(team, vars, build);
urList.add(ur);
} catch (MisconfiguredJobException mje) {
listener.getLogger().println(mje.getConfigurationMessage());
return false;
}

for(TestflightTeam team : createDefaultPlusAdditionalTeams()) {
try {
TestflightUploader.UploadRequest ur = createPartialUploadRequest(team, vars, build);
urList.add(ur);
} catch (MisconfiguredJobException mje) {
listener.getLogger().println(mje.getConfigurationMessage());
return false;
}
}

for(TestflightUploader.UploadRequest ur : urList) {
TestflightRemoteRecorder remoteRecorder = new TestflightRemoteRecorder(workspace, ur, listener);

Expand Down Expand Up @@ -224,6 +214,16 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, final Build
return true;
}

private List<TestflightTeam> createDefaultPlusAdditionalTeams() {
List<TestflightTeam> allTeams = new ArrayList<TestflightTeam>();
// first team is default
allTeams.add(new TestflightTeam(getTokenPairName(), getFilePath(), getDsymPath()));
if(additionalTeams != null) {
allTeams.addAll(Arrays.asList(additionalTeams));
}
return allTeams;
}

private void addTestflightLinks(AbstractBuild<?, ?> build, BuildListener listener, Map parsedMap) {
TestflightBuildAction installAction = new TestflightBuildAction();
String installUrl = (String) parsedMap.get("install_url");
Expand Down Expand Up @@ -341,7 +341,6 @@ public boolean evaluate(Object o) {
}

private TokenPair getTokenPair(String tokenPairName) {
//String tokenPairName = getTokenPairName();
for (TokenPair tokenPair : getDescriptor().getTokenPairs()) {
if (tokenPair.getTokenPairName().equals(tokenPairName))
return tokenPair;
Expand Down

0 comments on commit 74c31a4

Please sign in to comment.