use of com.googlecode.objectify.util.Closeable in project teammates by TEAMMATES.
the class RemoteApiClient method doOperationRemotely.
protected void doOperationRemotely() throws IOException {
String appUrl = TestProperties.TEAMMATES_URL.replaceAll("^https?://", "");
String appDomain = appUrl.split(":")[0];
int appPort = appUrl.contains(":") ? Integer.parseInt(appUrl.split(":")[1]) : 443;
System.out.println("--- Starting remote operation ---");
System.out.println("Going to connect to:" + appDomain + ":" + appPort);
RemoteApiOptions options = new RemoteApiOptions().server(appDomain, appPort);
if (TestProperties.isDevServer()) {
// Dev Server doesn't require credential.
options.useDevelopmentServerCredential();
} else {
// Your Google Cloud SDK needs to be authenticated for Application Default Credentials
// in order to run any script in production server.
// Refer to https://developers.google.com/identity/protocols/application-default-credentials.
options.useApplicationDefaultCredential();
}
RemoteApiInstaller installer = new RemoteApiInstaller();
installer.install(options);
OfyHelper.registerEntityClasses();
Closeable objectifySession = ObjectifyService.begin();
try {
doOperation();
} finally {
objectifySession.close();
installer.uninstall();
}
System.out.println("--- Remote operation completed ---");
}
Aggregations