-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5558 from Sage-Bionetworks/release-518
- Loading branch information
Showing
20 changed files
with
219 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 5 additions & 51 deletions
56
src/main/java/org/sagebionetworks/web/client/OneSageUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,16 @@ | ||
package org.sagebionetworks.web.client; | ||
|
||
import static org.sagebionetworks.web.shared.WebConstants.ONESAGE_ACCOUNT_SETTINGS_PATH; | ||
public interface OneSageUtils { | ||
String getAppIdForOneSage(); | ||
|
||
import com.google.gwt.user.client.Window; | ||
import org.sagebionetworks.web.shared.WebConstants; | ||
|
||
public class OneSageUtils { | ||
|
||
private static String getHostForOneSage() { | ||
// SWC-6533: We do not want to stack hop for Prod and Staging | ||
switch (Window.Location.getHostName().toLowerCase()) { | ||
case "staging.synapse.org": | ||
return "https://staging.accounts.synapse.org"; | ||
case "portal-dev.dev.sagebase.org": | ||
return "https://accounts-dev.dev.sagebase.org"; | ||
case "localhost": | ||
case "127.0.0.1": | ||
return "http://" + Window.Location.getHostName() + ":3000"; | ||
default: | ||
return "https://accounts.synapse.org"; | ||
} | ||
} | ||
|
||
public static String getAppIdForOneSage() { | ||
switch (Window.Location.getHostName().toLowerCase()) { | ||
case "staging.synapse.org": | ||
return "staging.synapse.org"; | ||
case "portal-dev.dev.sagebase.org": | ||
return "dev.synapse.org"; | ||
case "localhost": | ||
case "127.0.0.1": | ||
return "localhost"; | ||
default: | ||
return "synapse.org"; | ||
} | ||
} | ||
|
||
public static String getOneSageURL() { | ||
return getOneSageURL("/"); | ||
} | ||
String getOneSageURL(); | ||
|
||
/** | ||
* Based on the current hostname, generate a URL pointing to an instance of OneSage with an appropriate appId search param. | ||
* @param path | ||
* @return a String representation of the OneSage URL | ||
*/ | ||
public static String getOneSageURL(String path) { | ||
return ( | ||
getHostForOneSage() + | ||
path + | ||
"?" + | ||
WebConstants.ONESAGE_SYNAPSE_APPID_QUERY_PARAM_KEY + | ||
"=" + | ||
getAppIdForOneSage() | ||
); | ||
} | ||
String getOneSageURL(String path); | ||
|
||
public static String getAccountSettingsURL() { | ||
return getOneSageURL(ONESAGE_ACCOUNT_SETTINGS_PATH); | ||
} | ||
String getAccountSettingsURL(); | ||
} |
70 changes: 70 additions & 0 deletions
70
src/main/java/org/sagebionetworks/web/client/OneSageUtilsImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package org.sagebionetworks.web.client; | ||
|
||
import static org.sagebionetworks.web.shared.WebConstants.ONESAGE_ACCOUNT_SETTINGS_PATH; | ||
|
||
import com.google.gwt.user.client.Window; | ||
import com.google.inject.Inject; | ||
import org.sagebionetworks.web.shared.WebConstants; | ||
|
||
public class OneSageUtilsImpl implements OneSageUtils { | ||
|
||
private final GWTWrapper gwtWrapper; | ||
|
||
@Inject | ||
public OneSageUtilsImpl(GWTWrapper gwtWrapper) { | ||
this.gwtWrapper = gwtWrapper; | ||
} | ||
|
||
private String getHostForOneSage() { | ||
// SWC-6533: We do not want to stack hop for Prod and Staging | ||
switch (gwtWrapper.getHostName().toLowerCase()) { | ||
case "staging.synapse.org": | ||
return "https://staging.accounts.synapse.org"; | ||
case "portal-dev.dev.sagebase.org": | ||
return "https://accounts-dev.dev.sagebase.org"; | ||
case "localhost": | ||
case "127.0.0.1": | ||
return "http://" + Window.Location.getHostName() + ":3000"; | ||
default: | ||
return "https://accounts.synapse.org"; | ||
} | ||
} | ||
|
||
public String getAppIdForOneSage() { | ||
switch (gwtWrapper.getHostName().toLowerCase()) { | ||
case "staging.synapse.org": | ||
return "staging.synapse.org"; | ||
case "portal-dev.dev.sagebase.org": | ||
return "dev.synapse.org"; | ||
case "localhost": | ||
case "127.0.0.1": | ||
return "localhost"; | ||
default: | ||
return "synapse.org"; | ||
} | ||
} | ||
|
||
public String getOneSageURL() { | ||
return getOneSageURL("/"); | ||
} | ||
|
||
/** | ||
* Based on the current hostname, generate a URL pointing to an instance of OneSage with an appropriate appId search param. | ||
* @param path | ||
* @return a String representation of the OneSage URL | ||
*/ | ||
public String getOneSageURL(String path) { | ||
return ( | ||
getHostForOneSage() + | ||
path + | ||
"?" + | ||
WebConstants.ONESAGE_SYNAPSE_APPID_QUERY_PARAM_KEY + | ||
"=" + | ||
getAppIdForOneSage() | ||
); | ||
} | ||
|
||
public String getAccountSettingsURL() { | ||
return getOneSageURL(ONESAGE_ACCOUNT_SETTINGS_PATH); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.