intitializing credenital store db using JPA models
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/06ef33f9 Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/06ef33f9 Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/06ef33f9 Branch: refs/heads/lahiru/AIRAVATA-2065 Commit: 06ef33f94328c2c7d59f52bc01756a688ea25744 Parents: 875fc27 Author: scnakandala <[email protected]> Authored: Thu Sep 15 14:40:23 2016 -0400 Committer: scnakandala <[email protected]> Committed: Thu Sep 15 14:40:42 2016 -0400 ---------------------------------------------------------------------- .../main/resources/airavata-server.properties | 1 + .../credential-store-service/pom.xml | 19 +++-- .../store/server/CredentialStoreServer.java | 4 + modules/registry/registry-core/pom.xml | 5 -- .../credential/catalog/model/CommunityUser.java | 72 +++++++++++++++++ .../catalog/model/CommunityUser_Pk.java | 63 +++++++++++++++ .../credential/catalog/model/Configuration.java | 54 +++++++++++++ .../catalog/model/Configuration_PK.java | 60 ++++++++++++++ .../credential/catalog/model/Credential.java | 83 ++++++++++++++++++++ .../credential/catalog/model/Credential_PK.java | 55 +++++++++++++ .../catalog/util/CredentialCatalogJPAUtils.java | 82 +++++++++++++++++++ .../replica/catalog/model/Configuration.java | 1 - .../replica/catalog/model/Configuration_PK.java | 65 +++++++++++++++ .../src/main/resources/META-INF/persistence.xml | 8 ++ .../src/main/resources/credstore-derby.sql | 12 ++- .../src/main/resources/credstore-mysql.sql | 12 ++- 16 files changed, 581 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata/blob/06ef33f9/modules/configuration/server/src/main/resources/airavata-server.properties ---------------------------------------------------------------------- diff --git a/modules/configuration/server/src/main/resources/airavata-server.properties b/modules/configuration/server/src/main/resources/airavata-server.properties index 2ce3701..30a6338 100644 --- a/modules/configuration/server/src/main/resources/airavata-server.properties +++ b/modules/configuration/server/src/main/resources/airavata-server.properties @@ -190,6 +190,7 @@ credential.store.jdbc.url=jdbc:derby://localhost:1527/credential-store;create=tr credential.store.jdbc.user=airavata credential.store.jdbc.password=airavata credential.store.jdbc.driver=org.apache.derby.jdbc.ClientDriver +credential.store.jdbc.validationQuery=SELECT 1 from CONFIGURATION credential.store.server.host=localhost credential.store.server.port=8960 credentialstore=org.apache.airavata.credential.store.server.CredentialStoreServer http://git-wip-us.apache.org/repos/asf/airavata/blob/06ef33f9/modules/credential-store/credential-store-service/pom.xml ---------------------------------------------------------------------- diff --git a/modules/credential-store/credential-store-service/pom.xml b/modules/credential-store/credential-store-service/pom.xml index 57d5155..7c03c4f 100644 --- a/modules/credential-store/credential-store-service/pom.xml +++ b/modules/credential-store/credential-store-service/pom.xml @@ -11,7 +11,8 @@ OF ANY ~ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <groupId>org.apache.airavata</groupId> <artifactId>airavata</artifactId> @@ -62,11 +63,11 @@ <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </dependency> - <dependency> - <groupId>mysql</groupId> - <artifactId>mysql-connector-java</artifactId> - <version>5.1.34</version> - </dependency> + <!--<dependency>--> + <!--<groupId>mysql</groupId>--> + <!--<artifactId>mysql-connector-java</artifactId>--> + <!--<version>5.1.34</version>--> + <!--</dependency>--> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> @@ -78,6 +79,11 @@ <scope>test</scope> </dependency> <dependency> + <groupId>org.apache.airavata</groupId> + <artifactId>airavata-registry-core</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> <groupId>org.apache.derby</groupId> <artifactId>derby</artifactId> <version>${derby.version}</version> @@ -157,7 +163,6 @@ <testSourceDirectory>${basedir}\src\test\java\</testSourceDirectory> </configuration> </plugin> - </plugins> <testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory> <testOutputDirectory>${project.build.directory}/test-classes</testOutputDirectory> http://git-wip-us.apache.org/repos/asf/airavata/blob/06ef33f9/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/server/CredentialStoreServer.java ---------------------------------------------------------------------- diff --git a/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/server/CredentialStoreServer.java b/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/server/CredentialStoreServer.java index 5ccec02..0829fda 100644 --- a/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/server/CredentialStoreServer.java +++ b/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/server/CredentialStoreServer.java @@ -24,6 +24,7 @@ package org.apache.airavata.credential.store.server; import org.apache.airavata.common.utils.IServer; import org.apache.airavata.common.utils.ServerSettings; import org.apache.airavata.credential.store.cpi.CredentialStoreService; +import org.apache.airavata.registry.core.credential.catalog.util.CredentialCatalogJPAUtils; import org.apache.thrift.server.TServer; import org.apache.thrift.server.TThreadPoolServer; import org.apache.thrift.transport.TServerSocket; @@ -107,6 +108,9 @@ public class CredentialStoreServer implements IServer { public static void main(String[] args) { try { + //Initializing the database; + CredentialCatalogJPAUtils.getEntityManager(); + new CredentialStoreServer().start(); } catch (Exception e) { logger.error(e.getMessage(), e); http://git-wip-us.apache.org/repos/asf/airavata/blob/06ef33f9/modules/registry/registry-core/pom.xml ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/pom.xml b/modules/registry/registry-core/pom.xml index aa9a61b..1bea32f 100644 --- a/modules/registry/registry-core/pom.xml +++ b/modules/registry/registry-core/pom.xml @@ -56,11 +56,6 @@ </dependency> <dependency> <groupId>org.apache.airavata</groupId> - <artifactId>airavata-credential-store</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.airavata</groupId> <artifactId>airavata-data-models</artifactId> <version>${project.version}</version> </dependency> http://git-wip-us.apache.org/repos/asf/airavata/blob/06ef33f9/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/credential/catalog/model/CommunityUser.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/credential/catalog/model/CommunityUser.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/credential/catalog/model/CommunityUser.java new file mode 100644 index 0000000..24a9669 --- /dev/null +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/credential/catalog/model/CommunityUser.java @@ -0,0 +1,72 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ +package org.apache.airavata.registry.core.credential.catalog.model; + +import javax.persistence.*; + +@Entity +@Table(name ="COMMUNITY_USER") +@IdClass(CommunityUser_PK.class) +public class CommunityUser { + private String gatewayId; + private String communityUserName; + private String tokenId; + private String communityUserEmail; + + @Id + @Column(name = "GATEWAY_ID") + public String getGatewayId() { + return gatewayId; + } + + public void setGatewayId(String gatewayId) { + this.gatewayId = gatewayId; + } + + @Id + @Column(name = "COMMUNITY_USER_NAME") + public String getCommunityUserName() { + return communityUserName; + } + + public void setCommunityUserName(String communityUserName) { + this.communityUserName = communityUserName; + } + + @Id + @Column(name = "TOKEN_ID") + public String getTokenId() { + return tokenId; + } + + public void setTokenId(String tokenId) { + this.tokenId = tokenId; + } + + @Column(name = "COMMUNITY_USER_EMAIL") + public String getCommunityUserEmail() { + return communityUserEmail; + } + + public void setCommunityUserEmail(String communityUserEmail) { + this.communityUserEmail = communityUserEmail; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/06ef33f9/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/credential/catalog/model/CommunityUser_Pk.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/credential/catalog/model/CommunityUser_Pk.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/credential/catalog/model/CommunityUser_Pk.java new file mode 100644 index 0000000..47988c2 --- /dev/null +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/credential/catalog/model/CommunityUser_Pk.java @@ -0,0 +1,63 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ +package org.apache.airavata.registry.core.credential.catalog.model; + +import java.io.Serializable; + +public class CommunityUser_PK implements Serializable{ + private String gatewayId; + private String communityUserName; + private String tokenId; + + @Override + public boolean equals(Object o) { + return false; + } + + @Override + public int hashCode() { + return 1; + } + + public String getGatewayId() { + return gatewayId; + } + + public void setGatewayId(String gatewayId) { + this.gatewayId = gatewayId; + } + + public String getCommunityUserName() { + return communityUserName; + } + + public void setCommunityUserName(String communityUserName) { + this.communityUserName = communityUserName; + } + + public String getTokenId() { + return tokenId; + } + + public void setTokenId(String tokenId) { + this.tokenId = tokenId; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/06ef33f9/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/credential/catalog/model/Configuration.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/credential/catalog/model/Configuration.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/credential/catalog/model/Configuration.java new file mode 100644 index 0000000..281a3a1 --- /dev/null +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/credential/catalog/model/Configuration.java @@ -0,0 +1,54 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ +package org.apache.airavata.registry.core.credential.catalog.model; + + +import javax.persistence.*; +import java.io.Serializable; + +@Entity +@Table(name ="CONFIGURATION") +@IdClass(Configuration_PK.class) +public class Configuration implements Serializable { + @Id + @Column(name = "CONFIG_KEY") + private String config_key; + + @Id + @Column(name = "CONFIG_VAL") + private String config_val; + + public String getConfig_key() { + return config_key; + } + + public String getConfig_val() { + return config_val; + } + + public void setConfig_key(String config_key) { + this.config_key = config_key; + } + + public void setConfig_val(String config_val) { + this.config_val = config_val; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/06ef33f9/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/credential/catalog/model/Configuration_PK.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/credential/catalog/model/Configuration_PK.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/credential/catalog/model/Configuration_PK.java new file mode 100644 index 0000000..1a18aea --- /dev/null +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/credential/catalog/model/Configuration_PK.java @@ -0,0 +1,60 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.airavata.registry.core.credential.catalog.model; + +import java.io.Serializable; + +public class Configuration_PK implements Serializable { + private String config_key; + private String config_val; + + public Configuration_PK() { + ; + } + + @Override + public boolean equals(Object o) { + return false; + } + + @Override + public int hashCode() { + return 1; + } + + public String getConfig_key() { + return config_key; + } + + public void setConfig_key(String config_key) { + this.config_key = config_key; + } + + public void setConfig_val(String config_val) { + this.config_val = config_val; + } + + public String getConfig_val() { + return config_val; + } + +} http://git-wip-us.apache.org/repos/asf/airavata/blob/06ef33f9/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/credential/catalog/model/Credential.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/credential/catalog/model/Credential.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/credential/catalog/model/Credential.java new file mode 100644 index 0000000..ed146f7 --- /dev/null +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/credential/catalog/model/Credential.java @@ -0,0 +1,83 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ +package org.apache.airavata.registry.core.credential.catalog.model; + +import javax.persistence.*; +import java.sql.Timestamp; + +@Entity +@Table(name ="CREDENTIAL") +@IdClass(Credential_PK.class) +public class Credential { + private String gatewayId; + private String tokenId; + private Byte[] credential; + private String portalUserId; + private Timestamp timePersisted; + + @Id + @Column(name = "GATEWAY_ID") + public String getGatewayId() { + return gatewayId; + } + + public void setGatewayId(String gatewayId) { + this.gatewayId = gatewayId; + } + + @Id + @Column(name = "TOKEN_ID") + public String getTokenId() { + return tokenId; + } + + public void setTokenId(String tokenId) { + this.tokenId = tokenId; + } + + @Lob + @Column(name = "CREDENTIAL") + public Byte[] getCredential() { + return credential; + } + + public void setCredential(Byte[] credential) { + this.credential = credential; + } + + @Column(name = "PORTAL_USER_ID") + public String getPortalUserId() { + return portalUserId; + } + + public void setPortalUserId(String portalUserId) { + this.portalUserId = portalUserId; + } + + @Column(name = "TIME_PERSISTED") + public Timestamp getTimePersisted() { + return timePersisted; + } + + public void setTimePersisted(Timestamp timePersisted) { + this.timePersisted = timePersisted; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/06ef33f9/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/credential/catalog/model/Credential_PK.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/credential/catalog/model/Credential_PK.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/credential/catalog/model/Credential_PK.java new file mode 100644 index 0000000..a9db85f --- /dev/null +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/credential/catalog/model/Credential_PK.java @@ -0,0 +1,55 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ +package org.apache.airavata.registry.core.credential.catalog.model; + +import java.io.Serializable; + +public class Credential_PK implements Serializable{ + private String gatewayId; + private String tokenId; + + + @Override + public boolean equals(Object o) { + return false; + } + + @Override + public int hashCode() { + return 1; + } + + public String getGatewayId() { + return gatewayId; + } + + public void setGatewayId(String gatewayId) { + this.gatewayId = gatewayId; + } + + public String getTokenId() { + return tokenId; + } + + public void setTokenId(String tokenId) { + this.tokenId = tokenId; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/06ef33f9/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/credential/catalog/util/CredentialCatalogJPAUtils.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/credential/catalog/util/CredentialCatalogJPAUtils.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/credential/catalog/util/CredentialCatalogJPAUtils.java new file mode 100644 index 0000000..5a509c7 --- /dev/null +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/credential/catalog/util/CredentialCatalogJPAUtils.java @@ -0,0 +1,82 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.airavata.registry.core.credential.catalog.util; + +import org.apache.airavata.common.exception.ApplicationSettingsException; +import org.apache.airavata.common.utils.ServerSettings; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.persistence.*; +import java.util.HashMap; +import java.util.Map; + +public class CredentialCatalogJPAUtils { + private final static Logger logger = LoggerFactory.getLogger(CredentialCatalogJPAUtils.class); + + private static final String PERSISTENCE_UNIT_NAME = "credentialcatalog_data"; + private static final String CREDCATALOG_JDBC_DRIVER = "credential.store.jdbc.driver"; + private static final String CREDCATALOG_JDBC_URL = "credential.store.jdbc.url"; + private static final String CREDCATALOG_JDBC_USER = "credential.store.jdbc.user"; + private static final String CREDCACATALOG_JDBC_PWD = "credential.store.jdbc.password"; + private static final String CREDCACATALOG_VALIDATION_QUERY = "credential.store.jdbc.validationQuery"; + + @PersistenceUnit(unitName="credentialcatalog_data") + protected static EntityManagerFactory factory; + + @PersistenceContext(unitName="credentialcatalog_data") + private static EntityManager credCatEntityManager; + + public static EntityManager getEntityManager() throws ApplicationSettingsException { + if (factory == null) { + String connectionProperties = "DriverClassName=" + readServerProperties(CREDCATALOG_JDBC_DRIVER) + "," + + "Url=" + readServerProperties(CREDCATALOG_JDBC_URL) + "?autoReconnect=true," + + "Username=" + readServerProperties(CREDCATALOG_JDBC_USER) + "," + + "Password=" + readServerProperties(CREDCACATALOG_JDBC_PWD) + + ",validationQuery=" + readServerProperties(CREDCACATALOG_VALIDATION_QUERY); + System.out.println(connectionProperties); + Map<String, String> properties = new HashMap<String, String>(); + properties.put("openjpa.ConnectionDriverName", "org.apache.commons.dbcp.BasicDataSource"); + properties.put("openjpa.ConnectionProperties", connectionProperties); + properties.put("openjpa.DynamicEnhancementAgent", "true"); + properties.put("openjpa.RuntimeUnenhancedClasses", "unsupported"); + properties.put("openjpa.RemoteCommitProvider","sjvm"); + properties.put("openjpa.Log","DefaultLevel=INFO, Runtime=INFO, Tool=INFO, SQL=INFO"); + properties.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)"); + properties.put("openjpa.jdbc.QuerySQLCache", "false"); + properties.put("openjpa.ConnectionFactoryProperties", "PrettyPrint=true, PrettyPrintLineLength=72," + + " PrintParameters=true, MaxActive=10, MaxIdle=5, MinIdle=2, MaxWait=31536000, autoReconnect=true"); + factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME, properties); + } + credCatEntityManager = factory.createEntityManager(); + return credCatEntityManager; + } + + private static String readServerProperties (String propertyName) throws ApplicationSettingsException { + try { + return ServerSettings.getSetting(propertyName); + } catch (ApplicationSettingsException e) { + logger.error("Unable to read airavata-server.properties...", e); + throw new ApplicationSettingsException("Unable to read airavata-server.properties..."); + } + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/06ef33f9/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/model/Configuration.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/model/Configuration.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/model/Configuration.java index 881d043..8564d24 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/model/Configuration.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/model/Configuration.java @@ -20,7 +20,6 @@ */ package org.apache.airavata.registry.core.replica.catalog.model; -import org.apache.airavata.registry.core.app.catalog.model.Configuration_PK; import javax.persistence.*; import java.io.Serializable; http://git-wip-us.apache.org/repos/asf/airavata/blob/06ef33f9/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/model/Configuration_PK.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/model/Configuration_PK.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/model/Configuration_PK.java new file mode 100644 index 0000000..5769478 --- /dev/null +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/replica/catalog/model/Configuration_PK.java @@ -0,0 +1,65 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.airavata.registry.core.replica.catalog.model; + +import java.io.Serializable; + +public class Configuration_PK implements Serializable { + private String config_key; + private String config_val; + + public Configuration_PK(String config_key, String config_val) { + this.config_key = config_key; + this.config_val = config_val; + } + + public Configuration_PK() { + ; + } + + @Override + public boolean equals(Object o) { + return false; + } + + @Override + public int hashCode() { + return 1; + } + + public String getConfig_key() { + return config_key; + } + + public void setConfig_key(String config_key) { + this.config_key = config_key; + } + + public void setConfig_val(String config_val) { + this.config_val = config_val; + } + + public String getConfig_val() { + return config_val; + } + +} http://git-wip-us.apache.org/repos/asf/airavata/blob/06ef33f9/modules/registry/registry-core/src/main/resources/META-INF/persistence.xml ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/resources/META-INF/persistence.xml b/modules/registry/registry-core/src/main/resources/META-INF/persistence.xml index e502ae2..af23674 100644 --- a/modules/registry/registry-core/src/main/resources/META-INF/persistence.xml +++ b/modules/registry/registry-core/src/main/resources/META-INF/persistence.xml @@ -95,6 +95,7 @@ </persistence-unit> <persistence-unit name="replicacatalog_data"> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider> + <class>org.apache.airavata.registry.core.replica.catalog.model.Configuration</class> <class>org.apache.airavata.registry.core.replica.catalog.model.DataProduct</class> <class>org.apache.airavata.registry.core.replica.catalog.model.DataReplicaLocation</class> <class>org.apache.airavata.registry.core.replica.catalog.model.DataProductMetaData</class> @@ -114,4 +115,11 @@ <class>org.apache.airavata.registry.core.workflow.catalog.model.WorkflowStatus</class> <exclude-unlisted-classes>true</exclude-unlisted-classes> </persistence-unit> + <persistence-unit name="credentialcatalog_data"> + <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider> + <class>org.apache.airavata.registry.core.credential.catalog.model.CommunityUser</class> + <class>org.apache.airavata.registry.core.credential.catalog.model.Configuration</class> + <class>org.apache.airavata.registry.core.credential.catalog.model.Credential</class> + <exclude-unlisted-classes>true</exclude-unlisted-classes> + </persistence-unit> </persistence> http://git-wip-us.apache.org/repos/asf/airavata/blob/06ef33f9/modules/registry/registry-core/src/main/resources/credstore-derby.sql ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/resources/credstore-derby.sql b/modules/registry/registry-core/src/main/resources/credstore-derby.sql index 9403cfd..bdae2bd 100644 --- a/modules/registry/registry-core/src/main/resources/credstore-derby.sql +++ b/modules/registry/registry-core/src/main/resources/credstore-derby.sql @@ -36,4 +36,14 @@ CREATE TABLE CREDENTIALS PORTAL_USER_ID VARCHAR(256) NOT NULL, TIME_PERSISTED TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (GATEWAY_ID, TOKEN_ID) -); \ No newline at end of file +); + +CREATE TABLE CONFIGURATION +( + CONFIG_KEY VARCHAR(255), + CONFIG_VAL VARCHAR(255), + PRIMARY KEY(CONFIG_KEY, CONFIG_VAL) +); + +INSERT INTO CONFIGURATION (CONFIG_KEY, CONFIG_VAL) VALUES('app_catalog_version', '0.16'); + http://git-wip-us.apache.org/repos/asf/airavata/blob/06ef33f9/modules/registry/registry-core/src/main/resources/credstore-mysql.sql ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/resources/credstore-mysql.sql b/modules/registry/registry-core/src/main/resources/credstore-mysql.sql index df9e2bc..3d924ce 100644 --- a/modules/registry/registry-core/src/main/resources/credstore-mysql.sql +++ b/modules/registry/registry-core/src/main/resources/credstore-mysql.sql @@ -36,4 +36,14 @@ CREATE TABLE CREDENTIALS PORTAL_USER_ID VARCHAR(256) NOT NULL, TIME_PERSISTED TIMESTAMP DEFAULT NOW() ON UPDATE NOW(), PRIMARY KEY (GATEWAY_ID, TOKEN_ID) -); \ No newline at end of file +); + +CREATE TABLE CONFIGURATION +( + CONFIG_KEY VARCHAR(255), + CONFIG_VAL VARCHAR(255), + PRIMARY KEY(CONFIG_KEY, CONFIG_VAL) +); + +INSERT INTO CONFIGURATION (CONFIG_KEY, CONFIG_VAL) VALUES('app_catalog_version', '0.16'); +
