You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2018/06/06 14:38:46 UTC
[airavata] branch group-based-auth updated: AIRAVATA-2704 Add
plugin for running AiravataDataMigrator with maven
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch group-based-auth
in repository https://gitbox.apache.org/repos/asf/airavata.git
The following commit(s) were added to refs/heads/group-based-auth by this push:
new f5bd24a AIRAVATA-2704 Add plugin for running AiravataDataMigrator with maven
f5bd24a is described below
commit f5bd24a7fd4ee29f3b4b2510387f1a175e6d0bc7
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Wed Jun 6 10:37:06 2018 -0400
AIRAVATA-2704 Add plugin for running AiravataDataMigrator with maven
Can run the migration script by using `mvn compile exec:java`. See
README.md for details.
---
.../sharing-data-migrator/README.md | 4 ++-
.../sharing-registry/sharing-data-migrator/pom.xml | 37 +++++++++++++++-------
.../migrator/airavata/AiravataDataMigrator.java | 24 +++++++++++---
3 files changed, 49 insertions(+), 16 deletions(-)
diff --git a/modules/sharing-registry/sharing-data-migrator/README.md b/modules/sharing-registry/sharing-data-migrator/README.md
index 03d452a..8d4bf45 100644
--- a/modules/sharing-registry/sharing-data-migrator/README.md
+++ b/modules/sharing-registry/sharing-data-migrator/README.md
@@ -4,4 +4,6 @@
1. Copy the file `src/main/resources/airavata-server.properties.sample` to `src/main/resources/airavata-server.properties`.
2. Edit the `airavata-server.properties` file and make sure all properties are specified correctly.
3. Make sure that you have run `mvn install` in the root directory of the airavata project.
-4. Run the `AiravataDataMigrator` class.
\ No newline at end of file
+4. Run `mvn compile exec:java` in this directory. If you want to run the
+ migration for just a single gateway, you can instead run
+ `mvn compile exec:java -Dexec.args=gatewayId`.
diff --git a/modules/sharing-registry/sharing-data-migrator/pom.xml b/modules/sharing-registry/sharing-data-migrator/pom.xml
index b2dead9..9762d7a 100644
--- a/modules/sharing-registry/sharing-data-migrator/pom.xml
+++ b/modules/sharing-registry/sharing-data-migrator/pom.xml
@@ -35,17 +35,32 @@
<name>Sharing Data Migrator</name>
<build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.5.1</version>
- <configuration>
- <source>1.8</source>
- <target>1.8</target>
- </configuration>
- </plugin>
- </plugins>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.5.1</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.6.0</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <mainClass>org.apache.airavata.sharing.registry.migrator.airavata.AiravataDataMigrator</mainClass>
+ </configuration>
+ </plugin>
+ </plugins>
</build>
<dependencies>
diff --git a/modules/sharing-registry/sharing-data-migrator/src/main/java/org/apache/airavata/sharing/registry/migrator/airavata/AiravataDataMigrator.java b/modules/sharing-registry/sharing-data-migrator/src/main/java/org/apache/airavata/sharing/registry/migrator/airavata/AiravataDataMigrator.java
index cf4747b..2f88b7e 100644
--- a/modules/sharing-registry/sharing-data-migrator/src/main/java/org/apache/airavata/sharing/registry/migrator/airavata/AiravataDataMigrator.java
+++ b/modules/sharing-registry/sharing-data-migrator/src/main/java/org/apache/airavata/sharing/registry/migrator/airavata/AiravataDataMigrator.java
@@ -55,12 +55,24 @@ import java.util.stream.Collectors;
public class AiravataDataMigrator {
public static void main(String[] args) throws SQLException, ClassNotFoundException, TException, ApplicationSettingsException {
+ String gatewayId = null;
+ if (args.length > 0) {
+ gatewayId = args[0];
+ }
+ String gatewayWhereClause = "";
+ if (gatewayId != null) {
+ System.out.println("Running sharing data migration for " + gatewayId);
+ gatewayWhereClause = " WHERE GATEWAY_ID = '" + gatewayId + "'";
+ } else {
+ System.out.println("Running sharing data migration for all gateways");
+ }
+
Connection expCatConnection = ConnectionFactory.getInstance().getExpCatConnection();
SharingRegistryServerHandler sharingRegistryServerHandler = new SharingRegistryServerHandler();
CredentialStoreService.Client credentialStoreServiceClient = getCredentialStoreServiceClient();
- String query = "SELECT * FROM GATEWAY";
+ String query = "SELECT * FROM GATEWAY" + gatewayWhereClause;
Statement statement = expCatConnection.createStatement();
ResultSet rs = statement.executeQuery(query);
@@ -139,7 +151,7 @@ public class AiravataDataMigrator {
}
//Creating user entries
- query = "SELECT * FROM USERS";
+ query = "SELECT * FROM USERS" + gatewayWhereClause;
statement = expCatConnection.createStatement();
rs = statement.executeQuery(query);
while(rs.next()){
@@ -165,6 +177,10 @@ public class AiravataDataMigrator {
List<Domain> domainList = sharingRegistryServerHandler.getDomains(0, -1);
final RegistryService.Client registryServiceClient = getRegistryServiceClient();
for (Domain domain : domainList) {
+ // If we're only running migration for gatewayId, then skip other gateways
+ if (gatewayId != null && !gatewayId.equals(domain.domainId)) {
+ continue;
+ }
String ownerId = getAdminOwnerUser(domain, sharingRegistryServerHandler, credentialStoreServiceClient, registryServiceClient);
if (ownerId != null) {
domainOwnerMap.put(domain.domainId, ownerId);
@@ -183,7 +199,7 @@ public class AiravataDataMigrator {
}
//Creating project entries
- query = "SELECT * FROM PROJECT";
+ query = "SELECT * FROM PROJECT" + gatewayWhereClause;
statement = expCatConnection.createStatement();
rs = statement.executeQuery(query);
List<Entity> projectEntities = new ArrayList<>();
@@ -216,7 +232,7 @@ public class AiravataDataMigrator {
}
//Creating experiment entries
- query = "SELECT * FROM EXPERIMENT";
+ query = "SELECT * FROM EXPERIMENT" + gatewayWhereClause;
statement = expCatConnection.createStatement();
rs = statement.executeQuery(query);
List<Entity> experimentEntities = new ArrayList<>();
--
To stop receiving notification emails like this one, please contact
machristie@apache.org.