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 2017/12/15 16:43:14 UTC
[airavata] 14/20: User Profile CPI Server
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch registry-refactoring
in repository https://gitbox.apache.org/repos/asf/airavata.git
commit 9599a91052e0a61f884c990a318bb86454f5b334
Author: Abhiit Karanjkar <ay...@indiana.edu>
AuthorDate: Fri Nov 18 20:15:59 2016 -0500
User Profile CPI Server
Merge conflicts: discarded all changes to
airavata-api/airavata-model-utils/pom.xml
---
.../airavata/common/utils/ApplicationSettings.java | 8 ++
.../org/apache/airavata/common/utils/IServer.java | 26 ++--
.../airavata/common/utils/ServerSettings.java | 6 +
.../src/main/resources/airavata-server.properties | 8 ++
.../core/repositories/AbstractRepository.java | 32 ++++-
.../workspacecatalog/UserProfileRepository.java | 88 +++++++++++++
.../registry/core/utils/QueryConstants.java | 22 ++++
modules/user-profile/.project | 17 +++
.../.settings/org.eclipse.core.resources.prefs | 2 +
.../.settings/org.eclipse.m2e.core.prefs | 4 +
modules/user-profile/pom.xml | 2 +
modules/user-profile/user-profile-core/.classpath | 26 ++++
modules/user-profile/user-profile-core/.project | 23 ++++
.../.settings/org.eclipse.core.resources.prefs | 4 +
.../.settings/org.eclipse.jdt.core.prefs | 5 +
.../.settings/org.eclipse.m2e.core.prefs | 4 +
.../user-profile/user-profile-service/.classpath | 26 ++++
modules/user-profile/user-profile-service/.project | 23 ++++
.../.settings/org.eclipse.core.resources.prefs | 3 +
.../.settings/org.eclipse.jdt.core.prefs | 5 +
.../.settings/org.eclipse.m2e.core.prefs | 4 +
modules/user-profile/user-profile-service/pom.xml | 27 ++++
.../server/UserProfileHandler.java | 83 ++++++++++++
.../server/UserProfileServer.java | 141 +++++++++++++++++++++
modules/user-profile/user-profile-stubs/pom.xml | 5 +
.../airavata/userprofile/crude/cpi/Test.java | 14 ++
.../component-cpis/user-profile-crud-cpi.thrift | 2 +-
27 files changed, 590 insertions(+), 20 deletions(-)
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java
index bbf5102..c3382e8 100644
--- a/modules/commons/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java
@@ -360,9 +360,17 @@ public class ApplicationSettings {
return getSetting("credential.store.server.host");
}
+ public static String getUserProfileServerHost() throws ApplicationSettingsException {
+ return getSetting(ServerSettings.USER_PROFILE_SERVER_HOST);
+ }
+
public static String getCredentialStoreServerPort() throws ApplicationSettingsException {
return getSetting("credential.store.server.port");
}
+
+ public static String getUserProfileServerPort() throws ApplicationSettingsException {
+ return getSetting(ServerSettings.USER_PROFILE_SERVER_PORT);
+ }
public static String getCredentialStoreNotifierEnabled() throws ApplicationSettingsException {
return getSetting("notifier.enabled");
}
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/IServer.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/IServer.java
index ad5a70f..f1807fc 100644
--- a/modules/commons/src/main/java/org/apache/airavata/common/utils/IServer.java
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/IServer.java
@@ -23,20 +23,20 @@ import java.util.Calendar;
import java.util.Date;
public interface IServer {
- public enum ServerStatus{
- STOPING,
- STOPPED,
- STARTING,
- STARTED,
- FAILED;
- public void updateTime(){
- now=Calendar.getInstance().getTime();
+ public enum ServerStatus{
+ STOPING,
+ STOPPED,
+ STARTING,
+ STARTED,
+ FAILED;
+ public void updateTime(){
+ now=Calendar.getInstance().getTime();
+ }
+ private Date now;
+ public Date getTime(){
+ return now;
+ }
}
- private Date now;
- public Date getTime(){
- return now;
- }
- }
public String getName();
public String getVersion();
public void start() throws Exception;
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/ServerSettings.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/ServerSettings.java
index f5a44d7..03da208 100644
--- a/modules/commons/src/main/java/org/apache/airavata/common/utils/ServerSettings.java
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/ServerSettings.java
@@ -57,6 +57,12 @@ public class ServerSettings extends ApplicationSettings {
// Credential Store constants
public static final String CREDENTIAL_SERVER_HOST = "credential.store.server.host";
public static final String CREDENTIAL_SERVER_PORT = "credential.store.server.port";
+
+ //User Profile onstants
+
+ public static final String USER_PROFILE_SERVER_HOST = "user.profile.server.host";
+ public static final String USER_PROFILE_SERVER_PORT = "user.profile.server.port";
+
// Zookeeper + curator constants
public static final String EMBEDDED_ZK = "embedded.zk";
public static final String ZOOKEEPER_SERVER_CONNECTION = "zookeeper.server.connection";
diff --git a/modules/configuration/server/src/main/resources/airavata-server.properties b/modules/configuration/server/src/main/resources/airavata-server.properties
index 9db7893..e6b494f 100644
--- a/modules/configuration/server/src/main/resources/airavata-server.properties
+++ b/modules/configuration/server/src/main/resources/airavata-server.properties
@@ -221,6 +221,14 @@ credential.store.server.host=localhost
credential.store.server.port=8960
credentialstore=org.apache.airavata.credential.store.server.CredentialStoreServer
+
+###########################################################################
+# User Profile module Configuration
+###########################################################################
+user.profile.server.host=localhost
+user.profile.server.port=8961
+user_profile=com.apache.airavata.user.profile.server.UserProfileServer
+
# these properties used by credential store email notifications
email.server=smtp.googlemail.com
email.server.port=465
diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/AbstractRepository.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/AbstractRepository.java
index bc3a9da..a83928d 100644
--- a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/AbstractRepository.java
+++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/AbstractRepository.java
@@ -26,8 +26,10 @@ import org.dozer.Mapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.persistence.Query;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
public abstract class AbstractRepository<T, E, Id> {
private final static Logger logger = LoggerFactory.getLogger(AbstractRepository.class);
@@ -35,23 +37,23 @@ public abstract class AbstractRepository<T, E, Id> {
private Class<T> thriftGenericClass;
private Class<E> dbEntityGenericClass;
- public AbstractRepository(Class<T> thriftGenericClass, Class<E> dbEntityGenericClass){
+ public AbstractRepository(Class<T> thriftGenericClass, Class<E> dbEntityGenericClass) {
this.thriftGenericClass = thriftGenericClass;
this.dbEntityGenericClass = dbEntityGenericClass;
}
- public T create(T t){
+ public T create(T t) {
return update(t);
}
- public T update(T t){
+ public T update(T t) {
Mapper mapper = ObjectMapperSingleton.getInstance();
E entity = mapper.map(t, dbEntityGenericClass);
E persistedCopy = JPAUtils.execute(entityManager -> entityManager.merge(entity));
return mapper.map(persistedCopy, thriftGenericClass);
}
- public boolean delete(Id id){
+ public boolean delete(Id id) {
JPAUtils.execute(entityManager -> {
E entity = entityManager.find(dbEntityGenericClass, id);
entityManager.remove(entity);
@@ -60,14 +62,14 @@ public abstract class AbstractRepository<T, E, Id> {
return true;
}
- public T get(Id id){
+ public T get(Id id) {
E entity = JPAUtils.execute(entityManager -> entityManager
.find(dbEntityGenericClass, id));
Mapper mapper = ObjectMapperSingleton.getInstance();
return mapper.map(entity, thriftGenericClass);
}
- public List<T> select(String query, int limit, int offset){
+ public List<T> select(String query, int limit, int offset) {
List resultSet = (List) JPAUtils.execute(entityManager -> entityManager.createQuery(query).setFirstResult(offset)
.setMaxResults(offset).getResultList());
Mapper mapper = ObjectMapperSingleton.getInstance();
@@ -75,4 +77,22 @@ public abstract class AbstractRepository<T, E, Id> {
resultSet.stream().forEach(rs -> gatewayList.add(mapper.map(rs, thriftGenericClass)));
return gatewayList;
}
+
+ public List<T> select(String query, int limit, int offset, Map<String, Object> queryParams) {
+ List resultSet = (List) JPAUtils.execute(entityManager -> {
+ Query jpaQuery = entityManager.createQuery(query);
+
+ for (Map.Entry<String, Object> entry : queryParams.entrySet()) {
+
+ jpaQuery.setParameter(entry.getKey(), entry.getValue());
+ }
+
+ return jpaQuery.setFirstResult(offset).setMaxResults(limit).getResultList();
+
+ });
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ List<T> gatewayList = new ArrayList<>();
+ resultSet.stream().forEach(rs -> gatewayList.add(mapper.map(rs, thriftGenericClass)));
+ return gatewayList;
+ }
}
\ No newline at end of file
diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workspacecatalog/UserProfileRepository.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workspacecatalog/UserProfileRepository.java
new file mode 100644
index 0000000..7c5bd4b
--- /dev/null
+++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workspacecatalog/UserProfileRepository.java
@@ -0,0 +1,88 @@
+/*
+ *
+ * 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.repositories.workspacecatalog;
+
+import org.apache.airavata.model.user.UserProfile;
+import org.apache.airavata.registry.core.entities.workspacecatalog.UserProfileEntity;
+import org.apache.airavata.registry.core.repositories.AbstractRepository;
+import org.apache.airavata.registry.core.utils.QueryConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class UserProfileRepository extends AbstractRepository<UserProfile, UserProfileEntity, String> {
+ private final static Logger logger = LoggerFactory.getLogger(UserProfileRepository.class);
+
+ public UserProfileRepository(Class<UserProfile> thriftGenericClass, Class<UserProfileEntity> dbEntityGenericClass) {
+ super(thriftGenericClass, dbEntityGenericClass);
+ }
+
+ @Override
+ public List<UserProfile> select(String query, int offset, int limit) {
+ throw new UnsupportedOperationException("Due to performance overheads this method is not supported. Instead use" +
+ " UserProfileSummaryRepository");
+ }
+
+ public UserProfile getUserProfileByIdAndGateWay(String userId, String gatewayId) {
+
+ UserProfile userProfile = null;
+
+ Map<String, Object> queryParam = new HashMap<String, Object>();
+ queryParam.put(UserProfile._Fields.USER_ID.getFieldName(), userId);
+ queryParam.put(UserProfile._Fields.GATEWAY_ID.getFieldName(), gatewayId);
+ List<UserProfile> resultList = select(QueryConstants.FIND_USER_PROFILE_BY_USER_ID, 0, 1, queryParam);
+
+ if (resultList != null && resultList.size() > 0)
+ userProfile = resultList.get(0);
+
+
+ return userProfile;
+ }
+
+ public List<UserProfile> getAllUserProfilesInGateway(String gatewayId) {
+
+ Map<String, Object> queryParam = new HashMap<String, Object>();
+ queryParam.put(UserProfile._Fields.GATEWAY_ID.getFieldName(), gatewayId);
+
+ List<UserProfile> resultList = select(QueryConstants.FIND_ALL_USER_PROFILES_BY_GATEWAY_ID, 0, 1, queryParam);
+
+ return resultList;
+ }
+
+ public UserProfile getUserProfileByNameAndGateWay(String name, String gatewayId) {
+
+ UserProfile userProfile = null;
+
+ Map<String, Object> queryParam = new HashMap<String, Object>();
+ queryParam.put(UserProfile._Fields.USER_NAME.getFieldName(), name);
+ queryParam.put(UserProfile._Fields.GATEWAY_ID.getFieldName(), gatewayId);
+ List<UserProfile> resultList = select(QueryConstants.FIND_USER_PROFILE_BY_USER_NAME, 0, 1, queryParam);
+
+ if (resultList != null && resultList.size() > 0)
+ userProfile = resultList.get(0);
+
+
+ return userProfile;
+ }
+}
\ No newline at end of file
diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/QueryConstants.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/QueryConstants.java
new file mode 100644
index 0000000..171317e
--- /dev/null
+++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/QueryConstants.java
@@ -0,0 +1,22 @@
+package org.apache.airavata.registry.core.utils;
+
+import org.apache.airavata.model.user.UserProfile;
+
+/**
+ * Created by abhij on 11/11/2016.
+ */
+public interface QueryConstants {
+
+
+
+ String FIND_USER_PROFILE_BY_USER_ID = "SELECT u FROM UserProfileEntity u " +
+ "where u.userId LIKE :" + UserProfile._Fields.USER_ID.getFieldName() + " " +
+ "AND u.gatewayId LIKE :"+ UserProfile._Fields.GATEWAY_ID.getFieldName() + "";
+
+ String FIND_ALL_USER_PROFILES_BY_GATEWAY_ID = "SELECT u FROM UserProfileEntity u " +
+ "where u.gatewayId LIKE :"+ UserProfile._Fields.GATEWAY_ID.getFieldName() + "";
+
+ String FIND_USER_PROFILE_BY_USER_NAME = "SELECT u FROM UserProfileEntity u " +
+ "where u.userId LIKE :" + UserProfile._Fields.USER_NAME.getFieldName() + " " +
+ "AND u.gatewayId LIKE :"+ UserProfile._Fields.GATEWAY_ID.getFieldName() + "";
+}
diff --git a/modules/user-profile/.project b/modules/user-profile/.project
new file mode 100644
index 0000000..788ce56
--- /dev/null
+++ b/modules/user-profile/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>user-profile</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ </natures>
+</projectDescription>
diff --git a/modules/user-profile/.settings/org.eclipse.core.resources.prefs b/modules/user-profile/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..99f26c0
--- /dev/null
+++ b/modules/user-profile/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/modules/user-profile/.settings/org.eclipse.m2e.core.prefs b/modules/user-profile/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/modules/user-profile/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/modules/user-profile/pom.xml b/modules/user-profile/pom.xml
index 7f60f9c..37efc57 100644
--- a/modules/user-profile/pom.xml
+++ b/modules/user-profile/pom.xml
@@ -22,6 +22,8 @@
<packaging>pom</packaging>
<modules>
<module>user-profile-stubs</module>
+ <module>user-profile-service</module>
+
</modules>
diff --git a/modules/user-profile/user-profile-core/.classpath b/modules/user-profile/user-profile-core/.classpath
new file mode 100644
index 0000000..af1430b
--- /dev/null
+++ b/modules/user-profile/user-profile-core/.classpath
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/modules/user-profile/user-profile-core/.project b/modules/user-profile/user-profile-core/.project
new file mode 100644
index 0000000..e2dfe96
--- /dev/null
+++ b/modules/user-profile/user-profile-core/.project
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>user-profile-core</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ </natures>
+</projectDescription>
diff --git a/modules/user-profile/user-profile-core/.settings/org.eclipse.core.resources.prefs b/modules/user-profile/user-profile-core/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..f9fe345
--- /dev/null
+++ b/modules/user-profile/user-profile-core/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,4 @@
+eclipse.preferences.version=1
+encoding//src/main/java=UTF-8
+encoding//src/test/java=UTF-8
+encoding/<project>=UTF-8
diff --git a/modules/user-profile/user-profile-core/.settings/org.eclipse.jdt.core.prefs b/modules/user-profile/user-profile-core/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..714351a
--- /dev/null
+++ b/modules/user-profile/user-profile-core/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,5 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/modules/user-profile/user-profile-core/.settings/org.eclipse.m2e.core.prefs b/modules/user-profile/user-profile-core/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/modules/user-profile/user-profile-core/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/modules/user-profile/user-profile-service/.classpath b/modules/user-profile/user-profile-service/.classpath
new file mode 100644
index 0000000..af1430b
--- /dev/null
+++ b/modules/user-profile/user-profile-service/.classpath
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/modules/user-profile/user-profile-service/.project b/modules/user-profile/user-profile-service/.project
new file mode 100644
index 0000000..15b1016
--- /dev/null
+++ b/modules/user-profile/user-profile-service/.project
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>user-profile-cpi</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ </natures>
+</projectDescription>
diff --git a/modules/user-profile/user-profile-service/.settings/org.eclipse.core.resources.prefs b/modules/user-profile/user-profile-service/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..e9441bb
--- /dev/null
+++ b/modules/user-profile/user-profile-service/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+encoding//src/main/java=UTF-8
+encoding/<project>=UTF-8
diff --git a/modules/user-profile/user-profile-service/.settings/org.eclipse.jdt.core.prefs b/modules/user-profile/user-profile-service/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..714351a
--- /dev/null
+++ b/modules/user-profile/user-profile-service/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,5 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/modules/user-profile/user-profile-service/.settings/org.eclipse.m2e.core.prefs b/modules/user-profile/user-profile-service/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/modules/user-profile/user-profile-service/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/modules/user-profile/user-profile-service/pom.xml b/modules/user-profile/user-profile-service/pom.xml
new file mode 100644
index 0000000..3e35699
--- /dev/null
+++ b/modules/user-profile/user-profile-service/pom.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>user-profile-service</artifactId>
+ <version>0.17-SNAPSHOT</version>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-commons</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>user-profile-stubs</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/modules/user-profile/user-profile-service/src/main/java/com.apache.airavata.user.profile/server/UserProfileHandler.java b/modules/user-profile/user-profile-service/src/main/java/com.apache.airavata.user.profile/server/UserProfileHandler.java
new file mode 100644
index 0000000..8f04204
--- /dev/null
+++ b/modules/user-profile/user-profile-service/src/main/java/com.apache.airavata.user.profile/server/UserProfileHandler.java
@@ -0,0 +1,83 @@
+package com.apache.airavata.user.profile.server;
+
+import org.apache.airavata.model.user.UserProfile;
+import org.apache.airavata.registry.api.exception.RegistryServiceException;
+import org.apache.airavata.registry.core.entities.workspacecatalog.UserProfileEntity;
+import org.apache.airavata.registry.core.repositories.workspacecatalog.UserProfileRepository;
+import org.apache.airavata.userprofile.crude.cpi.UserProfileCrudeService;
+import org.apache.thrift.TException;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by Airavata on 11/11/2016.
+ */
+public class UserProfileHandler implements UserProfileCrudeService.Iface {
+
+ private UserProfileRepository userProfileRepository;
+
+ public UserProfileHandler() {
+
+ userProfileRepository = new UserProfileRepository(UserProfile.class, UserProfileEntity.class);
+ }
+
+ public String addUserProfile(UserProfile userProfile) throws RegistryServiceException, TException {
+
+ userProfileRepository.create(userProfile);
+
+ if (null != userProfile)
+ return userProfile.getUserId();
+
+ return null;
+ }
+
+ public boolean updateUserProfile(UserProfile userProfile) throws RegistryServiceException, TException {
+
+ try {
+ userProfileRepository.update(userProfile);
+ } catch (Exception e) {
+
+ return false;
+ }
+
+ return true;
+ }
+
+ public UserProfile getUserProfileById(String userId, String gatewayId) throws RegistryServiceException, TException {
+
+
+ UserProfile userProfile = userProfileRepository.getUserProfileByIdAndGateWay(userId, gatewayId);
+
+ return userProfile;
+ }
+
+ public boolean deleteUserProfile(String userId) throws RegistryServiceException, TException {
+
+ boolean deleteResult = userProfileRepository.delete(userId);
+
+ return deleteResult;
+ }
+
+ public List<UserProfile> getAllUserProfilesInGateway(String gatewayId) throws RegistryServiceException, TException {
+
+ List<UserProfile> usersInGateway = userProfileRepository.getAllUserProfilesInGateway(gatewayId);
+ return usersInGateway;
+ }
+
+ public UserProfile getUserProfileByName(String userName, String gatewayId) throws RegistryServiceException, TException {
+
+ UserProfile userProfile = userProfileRepository.getUserProfileByNameAndGateWay(userName, gatewayId);
+ return userProfile;
+ }
+
+ public boolean doesUserExist(String userName, String gatewayId) throws RegistryServiceException, TException {
+
+ UserProfile userProfile = userProfileRepository.getUserProfileByNameAndGateWay(userName, gatewayId);
+
+ if(null != userProfile)
+ return true;
+ return false;
+ }
+}
diff --git a/modules/user-profile/user-profile-service/src/main/java/com.apache.airavata.user.profile/server/UserProfileServer.java b/modules/user-profile/user-profile-service/src/main/java/com.apache.airavata.user.profile/server/UserProfileServer.java
new file mode 100644
index 0000000..5fb2ac2
--- /dev/null
+++ b/modules/user-profile/user-profile-service/src/main/java/com.apache.airavata.user.profile/server/UserProfileServer.java
@@ -0,0 +1,141 @@
+package com.apache.airavata.user.profile.server;
+
+import org.apache.airavata.common.utils.IServer;
+import org.apache.airavata.common.utils.ServerSettings;
+import org.apache.airavata.userprofile.crude.cpi.UserProfileCrudeService;
+import org.apache.thrift.server.TServer;
+import org.apache.thrift.server.TThreadPoolServer;
+import org.apache.thrift.transport.TServerSocket;
+import org.apache.thrift.transport.TServerTransport;
+import org.apache.thrift.transport.TTransportException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.InetSocketAddress;
+import java.util.Date;
+
+/**
+ * Created by abhij on 11/11/2016.
+ */
+public class UserProfileServer implements IServer {
+
+ private final static Logger logger = LoggerFactory.getLogger(UserProfileServer.class);
+
+ private static final String SERVER_NAME = "User Profile Server";
+ private static final String SERVER_VERSION = "1.0";
+
+ private IServer.ServerStatus status;
+ private TServer server;
+
+ public UserProfileServer() {
+ setStatus(IServer.ServerStatus.STOPPED);
+ }
+
+ public void updateTime() {
+
+ }
+
+ public Date getTime() {
+ return null;
+ }
+
+ public String getName() {
+ return SERVER_NAME;
+ }
+
+ public String getVersion() {
+ return SERVER_VERSION;
+ }
+
+ public void start() throws Exception {
+
+
+ try {
+ setStatus(ServerStatus.STARTING);
+ final int serverPort = Integer.parseInt(ServerSettings.getUserProfileServerPort());
+ final String serverHost = ServerSettings.getUserProfileServerHost();
+ UserProfileCrudeService.Processor processor = new UserProfileCrudeService.Processor(new UserProfileHandler());
+
+ TServerTransport serverTransport;
+
+ if (serverHost == null) {
+ serverTransport = new TServerSocket(serverPort);
+ } else {
+ InetSocketAddress inetSocketAddress = new InetSocketAddress(serverHost, serverPort);
+ serverTransport = new TServerSocket(inetSocketAddress);
+ }
+ TThreadPoolServer.Args options = new TThreadPoolServer.Args(serverTransport);
+ options.minWorkerThreads = 30;
+ server = new TThreadPoolServer(options.processor(processor));
+
+ new Thread() {
+ public void run() {
+ server.serve();
+ setStatus(ServerStatus.STOPPED);
+ logger.info("Credential store Server Stopped.");
+ }
+ }.start();
+ new Thread() {
+ public void run() {
+ while (!server.isServing()) {
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ break;
+ }
+ }
+ if (server.isServing()) {
+ setStatus(ServerStatus.STARTED);
+ logger.info("Starting Credential store Server on Port " + serverPort);
+ logger.info("Listening to Credential store clients ....");
+ }
+ }
+ }.start();
+ } catch (TTransportException e) {
+ setStatus(ServerStatus.FAILED);
+ throw new Exception("Error while starting the credential store service", e);
+ }
+ }
+
+ public void stop() throws Exception {
+
+ if (server!=null && server.isServing()){
+ setStatus(ServerStatus.STOPING);
+ server.stop();
+ }
+ }
+
+ public void restart() throws Exception {
+
+ stop();
+ start();
+ }
+
+ public void configure() throws Exception {
+
+ }
+
+ public ServerStatus getStatus() throws Exception {
+ return status; }
+
+ private void setStatus(IServer.ServerStatus stat){
+ status=stat;
+ status.updateTime();
+ }
+
+ public TServer getServer() {
+ return server;
+ }
+
+ public void setServer(TServer server) {
+ this.server = server;
+ }
+
+ public static void main(String[] args) {
+ try {
+ new UserProfileServer().start();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ }
+ }
+}
diff --git a/modules/user-profile/user-profile-stubs/pom.xml b/modules/user-profile/user-profile-stubs/pom.xml
index 80ac86f..3f9bce8 100644
--- a/modules/user-profile/user-profile-stubs/pom.xml
+++ b/modules/user-profile/user-profile-stubs/pom.xml
@@ -26,5 +26,10 @@
<artifactId>airavata-data-models</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>registry-refactoring</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
diff --git a/modules/user-profile/user-profile-stubs/src/main/java/org/apache/airavata/userprofile/crude/cpi/Test.java b/modules/user-profile/user-profile-stubs/src/main/java/org/apache/airavata/userprofile/crude/cpi/Test.java
new file mode 100644
index 0000000..9914906
--- /dev/null
+++ b/modules/user-profile/user-profile-stubs/src/main/java/org/apache/airavata/userprofile/crude/cpi/Test.java
@@ -0,0 +1,14 @@
+package org.apache.airavata.userprofile.crude.cpi;
+
+import org.apache.airavata.model.user.UserProfile;
+
+/**
+ * Created by abhij on 11/17/2016.
+ */
+public class Test {
+
+ public static void main(String args[]) {
+
+ System.out.println();
+ }
+}
diff --git a/thrift-interface-descriptions/component-cpis/user-profile-crud-cpi.thrift b/thrift-interface-descriptions/component-cpis/user-profile-crud-cpi.thrift
index b3951d2..bea5ca7 100644
--- a/thrift-interface-descriptions/component-cpis/user-profile-crud-cpi.thrift
+++ b/thrift-interface-descriptions/component-cpis/user-profile-crud-cpi.thrift
@@ -45,7 +45,7 @@ service UserProfileCrudeService {
bool deleteUserProfile(1: required string userId)
throws (1:registry_api_errors.RegistryServiceException registryException);
- list<user_profile_model.UserProfile> getAllUserProfilesInGateway (1: required string gatewayId)
+ list<user_profile_model.UserProfile> getAllUserProfilesInGateway (1: required string gatewayId, 2: required i32 offset, 3: required i32 limit)
throws (1:registry_api_errors.RegistryServiceException registryException);
user_profile_model.UserProfile getUserProfileByName(1: required string userName, 2: required string gatewayId)
--
To stop receiving notification emails like this one, please contact
"commits@airavata.apache.org" <co...@airavata.apache.org>.