You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sc...@apache.org on 2015/06/07 19:01:14 UTC

[33/44] airavata git commit: Mongo Registry WIP

http://git-wip-us.apache.org/repos/asf/airavata/blob/801489bf/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NotificationEmailResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NotificationEmailResource.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NotificationEmailResource.java
deleted file mode 100644
index 5ac864f..0000000
--- a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NotificationEmailResource.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
-*
-* 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.persistance.registry.jpa.resources;
-
-import org.apache.airavata.persistance.registry.jpa.Resource;
-import org.apache.airavata.persistance.registry.jpa.ResourceType;
-import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
-import org.apache.airavata.persistance.registry.jpa.model.*;
-import org.apache.airavata.registry.cpi.RegistryException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import java.util.List;
-
-public class NotificationEmailResource extends AbstractResource {
-    private static final Logger logger = LoggerFactory.getLogger(NotificationEmailResource.class);
-
-    private int emailId = 0;
-    private ExperimentResource experimentResource;
-    private TaskDetailResource taskDetailResource;
-    private String emailAddress;
-
-
-    public String getEmailAddress() {
-        return emailAddress;
-    }
-
-    public void setEmailAddress(String emailAddress) {
-        this.emailAddress = emailAddress;
-    }
-
-    public ExperimentResource getExperimentResource() {
-        return experimentResource;
-    }
-
-    public void setExperimentResource(ExperimentResource experimentResource) {
-        this.experimentResource = experimentResource;
-    }
-
-    public TaskDetailResource getTaskDetailResource() {
-        return taskDetailResource;
-    }
-
-    public void setTaskDetailResource(TaskDetailResource taskDetailResource) {
-        this.taskDetailResource = taskDetailResource;
-    }
-
-    public Resource create(ResourceType type) throws RegistryException {
-        logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
-        throw new UnsupportedOperationException();
-    }
-
-    public void remove(ResourceType type, Object name) throws RegistryException{
-        logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
-        throw new UnsupportedOperationException();
-    }
-
-    public Resource get(ResourceType type, Object name) throws RegistryException {
-        logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
-        throw new UnsupportedOperationException();
-    }
-
-    public List<Resource> get(ResourceType type) throws RegistryException {
-        logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
-        throw new UnsupportedOperationException();
-    }
-
-    public void save() throws RegistryException{
-        EntityManager em = null;
-        try {
-            em = ResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-            Notification_Email notification_email;
-            if (emailId != 0 ){
-                notification_email  = em.find(Notification_Email.class, emailId);
-                notification_email.setEmailId(emailId);
-            }else {
-                notification_email = new Notification_Email();
-            }
-            Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
-            notification_email.setExperiment(experiment);
-            notification_email.setExperiment_id(experiment.getExpId());
-            if (taskDetailResource != null){
-                TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
-                notification_email.setTaskDetail(taskDetail);
-                notification_email.setTaskId(taskDetail.getTaskId());
-            }
-            notification_email.setEmailAddress(emailAddress);
-            em.persist(notification_email);
-            emailId = notification_email.getEmailId();
-            em.getTransaction().commit();
-            em.close();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            throw new RegistryException(e);
-        } finally {
-            if (em != null && em.isOpen()) {
-                if (em.getTransaction().isActive()){
-                    em.getTransaction().rollback();
-                }
-                em.close();
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/801489bf/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectResource.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectResource.java
deleted file mode 100644
index 9432067..0000000
--- a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectResource.java
+++ /dev/null
@@ -1,531 +0,0 @@
-/*
- *
- * 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.persistance.registry.jpa.resources;
-
-import org.apache.airavata.persistance.registry.jpa.Resource;
-import org.apache.airavata.persistance.registry.jpa.ResourceType;
-import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
-import org.apache.airavata.persistance.registry.jpa.model.*;
-import org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator;
-import org.apache.airavata.registry.cpi.RegistryException;
-import org.apache.airavata.registry.cpi.ResultOrderType;
-import org.apache.airavata.registry.cpi.utils.Constants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.List;
-
-public class ProjectResource extends AbstractResource {
-    private final static Logger logger = LoggerFactory.getLogger(ProjectResource.class);
-    private String name;
-    private String id;
-    private GatewayResource gateway;
-    private WorkerResource worker;
-    private String description;
-    private Timestamp creationTime;
-
-    /**
-     *
-     */
-    public ProjectResource() {
-    }
-
-    /**
-     *
-     * @param worker gateway worker
-     * @param gateway gateway
-     * @param projectId project name
-     */
-    public ProjectResource(WorkerResource worker, GatewayResource gateway, String projectId) {
-        this.setWorker(worker);
-        this.setGateway(gateway);
-        this.id = projectId;
-    }
-
-    /**
-     *
-     * @param type child resource type
-     * @return child resource
-     */
-    public Resource create(ResourceType type) throws RegistryException {
-        if (type == ResourceType.EXPERIMENT) {
-            ExperimentResource experimentResource = new ExperimentResource();
-            experimentResource.setGateway(getGateway());
-            experimentResource.setExecutionUser(worker.getUser());
-            experimentResource.setProject(this);
-            return experimentResource;
-        } else if (type == ResourceType.PROJECT_USER){
-            ProjectUserResource pr = new ProjectUserResource();
-            pr.setProjectId(id);
-            pr.setUserName(worker.getUser());
-            return pr;
-        }
-        else {
-            logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
-            throw new IllegalArgumentException("Unsupported resource type for project resource.");
-        }
-    }
-
-    /**
-     *
-     * @param type child resource type
-     * @param name child resource name
-     */
-    public void remove(ResourceType type, Object name) throws RegistryException{
-        EntityManager em = null;
-        try {
-            em = ResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-            if (type == ResourceType.EXPERIMENT) {
-                QueryGenerator generator = new QueryGenerator(EXPERIMENT);
-                generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
-                Query q = generator.deleteQuery(em);
-                q.executeUpdate();
-            } else if (type == ResourceType.PROJECT_USER) {
-                QueryGenerator generator = new QueryGenerator(PROJECT_USER);
-                generator.setParameter(ProjectUserConstants.USERNAME, name);
-                generator.setParameter(ProjectUserConstants.PROJECT_ID, this.id);
-                Query q = generator.deleteQuery(em);
-                q.executeUpdate();
-            } else {
-                logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
-                throw new IllegalArgumentException("Unsupported resource type for project resource.");
-            }
-            em.getTransaction().commit();
-            em.close();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            throw new RegistryException(e);
-        } finally {
-            if (em != null && em.isOpen()) {
-                if (em.getTransaction().isActive()){
-                    em.getTransaction().rollback();
-                }
-                em.close();
-            }
-        }
-    }
-
-    /**
-     *
-     * @param type child resource type
-     * @param name child resource name
-     * @return child resource
-     */
-    public Resource get(ResourceType type, Object name) throws RegistryException {
-        EntityManager em = null;
-        try {
-            if (type == ResourceType.EXPERIMENT) {
-                em = ResourceUtils.getEntityManager();
-                em.getTransaction().begin();
-                QueryGenerator generator = new QueryGenerator(EXPERIMENT);
-                generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
-                Query q = generator.selectQuery(em);
-                Experiment experiment = (Experiment) q.getSingleResult();
-                ExperimentResource experimentResource = (ExperimentResource)
-                        Utils.getResource(ResourceType.EXPERIMENT, experiment);
-                em.getTransaction().commit();
-                em.close();
-                return experimentResource;
-            } else if (type == ResourceType.PROJECT_USER) {
-                em = ResourceUtils.getEntityManager();
-                em.getTransaction().begin();
-                QueryGenerator generator = new QueryGenerator(PROJECT_USER);
-                generator.setParameter(ProjectUserConstants.USERNAME, name);
-                generator.setParameter(ProjectUserConstants.PROJECT_ID, this.id);
-                Query q = generator.selectQuery(em);
-                ProjectUser prUser = (ProjectUser) q.getSingleResult();
-                ExperimentResource experimentResource = (ExperimentResource)
-                        Utils.getResource(ResourceType.PROJECT_USER, prUser);
-                em.getTransaction().commit();
-                em.close();
-                return experimentResource;
-            } else {
-                logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
-                throw new IllegalArgumentException("Unsupported resource type for project resource.");
-            }
-        } catch (Exception e) {
-            throw new RegistryException(e);
-        } finally {
-            if (em != null && em.isOpen()) {
-                if (em.getTransaction().isActive()){
-                    em.getTransaction().rollback();
-                }
-                em.close();
-            }
-        }
-    }
-
-    /**
-     *
-     * @param type child resource type
-     * @return list of child resources
-     */
-    @Override
-    public List<Resource> get(ResourceType type) throws RegistryException{
-        List<Resource> resourceList = new ArrayList<Resource>();
-        EntityManager em = null;
-        try {
-            if (type == ResourceType.EXPERIMENT) {
-                em = ResourceUtils.getEntityManager();
-                em.getTransaction().begin();
-                QueryGenerator generator = new QueryGenerator(EXPERIMENT);
-                generator.setParameter(ExperimentConstants.PROJECT_ID, id);
-                Query q = generator.selectQuery(em);
-                List<?> results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        Experiment experiment = (Experiment) result;
-                        ExperimentResource experimentResource = (ExperimentResource)
-                                Utils.getResource(ResourceType.EXPERIMENT, experiment);
-                        resourceList.add(experimentResource);
-                    }
-                }
-                em.getTransaction().commit();
-                em.close();
-            } else if (type == ResourceType.PROJECT_USER) {
-                em = ResourceUtils.getEntityManager();
-                em.getTransaction().begin();
-                QueryGenerator generator = new QueryGenerator(PROJECT_USER);
-                generator.setParameter(ProjectUserConstants.PROJECT_ID, id);
-                Query q = generator.selectQuery(em);
-                List<?> results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        ProjectUser projectUser = (ProjectUser) result;
-                        ProjectUserResource pr = (ProjectUserResource)
-                                Utils.getResource(ResourceType.PROJECT_USER, projectUser);
-                        resourceList.add(pr);
-                    }
-                }
-                em.getTransaction().commit();
-                em.close();
-            } else {
-                logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
-                throw new IllegalArgumentException("Unsupported resource type for project resource.");
-            }
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            throw new RegistryException(e);
-        } finally {
-            if (em != null && em.isOpen()) {
-                if (em.getTransaction().isActive()){
-                    em.getTransaction().rollback();
-                }
-                em.close();
-            }
-        }
-        return resourceList;
-    }
-
-    /**
-     * Get results with pagination and ordering
-     *
-     * @param type
-     * @param limit
-     * @param offset
-     * @param orderByIdentifier
-     * @return
-     * @throws RegistryException
-     */
-    public List<Resource> get(ResourceType type, int limit, int offset, Object orderByIdentifier,
-                              ResultOrderType resultOrderType) throws RegistryException{
-        List<Resource> resourceList = new ArrayList<Resource>();
-        EntityManager em = null;
-        try {
-            if (type == ResourceType.EXPERIMENT) {
-                em = ResourceUtils.getEntityManager();
-                em.getTransaction().begin();
-                QueryGenerator generator = new QueryGenerator(EXPERIMENT);
-                generator.setParameter(ExperimentConstants.PROJECT_ID, id);
-                Query q;
-                //ordering - supported only by CREATION_TIME
-                if(orderByIdentifier != null && resultOrderType != null
-                        && orderByIdentifier.equals(Constants.FieldConstants.ExperimentConstants.CREATION_TIME)) {
-                    q = generator.selectQuery(em, ExperimentConstants.CREATION_TIME, resultOrderType);
-                }else{
-                    q = generator.selectQuery(em);
-                }
-
-                //pagination
-                if(limit>0 && offset>=0){
-                    q.setFirstResult(offset);
-                    q.setMaxResults(limit);
-                }
-                List<?> results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        Experiment experiment = (Experiment) result;
-                        ExperimentResource experimentResource = (ExperimentResource)
-                                Utils.getResource(ResourceType.EXPERIMENT, experiment);
-                        resourceList.add(experimentResource);
-                    }
-                }
-                em.getTransaction().commit();
-                em.close();
-            } else if (type == ResourceType.PROJECT_USER) {
-                em = ResourceUtils.getEntityManager();
-                em.getTransaction().begin();
-                QueryGenerator generator = new QueryGenerator(PROJECT_USER);
-                generator.setParameter(ProjectUserConstants.PROJECT_ID, id);
-                Query q;
-                //ordering - only supported only by CREATION_TIME
-                if(orderByIdentifier != null && resultOrderType != null
-                        && orderByIdentifier.equals(Constants.FieldConstants.ProjectConstants.CREATION_TIME)) {
-                    q = generator.selectQuery(em, ProjectConstants.CREATION_TIME, resultOrderType);
-                }else{
-                    q = generator.selectQuery(em);
-                }
-
-                //pagination
-                if(limit>0 && offset>=0){
-                    q.setFirstResult(offset);
-                    q.setMaxResults(limit);
-                }
-                List<?> results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        ProjectUser projectUser = (ProjectUser) result;
-                        ProjectUserResource pr = (ProjectUserResource)
-                                Utils.getResource(ResourceType.PROJECT_USER, projectUser);
-                        resourceList.add(pr);
-                    }
-                }
-                em.getTransaction().commit();
-                em.close();
-            } else {
-                logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
-                throw new IllegalArgumentException("Unsupported resource type for project resource.");
-            }
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            throw new RegistryException(e);
-        } finally {
-            if (em != null && em.isOpen()) {
-                if (em.getTransaction().isActive()){
-                    em.getTransaction().rollback();
-                }
-                em.close();
-            }
-        }
-        return resourceList;
-    }
-
-    /**
-     * saveExperiment project to the database
-     */
-    public void save() throws RegistryException{
-        EntityManager em = null;
-        try {
-            em = ResourceUtils.getEntityManager();
-            Project existingProject = em.find(Project.class, id);
-            em.close();
-
-            em = ResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-            Project project = new Project();
-            project.setProject_id(id);
-            project.setProject_name(name);
-            Gateway modelGateway = em.find(Gateway.class, gateway.getGatewayId());
-            project.setGateway(modelGateway);
-            project.setGateway_id(modelGateway.getGateway_id());
-            Users user = em.find(Users.class, worker.getUser());
-            project.setUsers(user);
-            project.setUser_name(user.getUser_name());
-            project.setDescription(description);
-            project.setCreationTime(creationTime);
-
-            if (existingProject != null) {
-                existingProject.setProject_name(name);
-                existingProject.setGateway(modelGateway);
-                existingProject.setGateway_id(modelGateway.getGateway_id());
-                existingProject.setUsers(user);
-                existingProject.setUser_name(user.getUser_name());
-                existingProject.setDescription(description);
-                existingProject.setCreationTime(creationTime);
-                project = em.merge(existingProject);
-            } else {
-                em.persist(project);
-            }
-
-            em.getTransaction().commit();
-            em.close();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            throw new RegistryException(e);
-        } finally {
-            if (em != null && em.isOpen()) {
-                if (em.getTransaction().isActive()){
-                    em.getTransaction().rollback();
-                }
-                em.close();
-            }
-        }
-    }
-
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    /**
-     *
-     * @return project name
-     */
-    public String getName() {
-        return name;
-    }
-
-    /**
-     *
-     * @param name  project name
-     */
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    /**
-     *
-     * @return gateway worker
-     */
-    public WorkerResource getWorker() {
-		return worker;
-	}
-
-    /**
-     *
-     * @param worker gateway worker
-     */
-    public void setWorker(WorkerResource worker) {
-		this.worker = worker;
-	}
-
-    /**
-     *
-     * @return gateway resource
-     */
-    public GatewayResource getGateway() {
-		return gateway;
-	}
-
-    /**
-     *
-     * @param gateway gateway resource
-     */
-    public void setGateway(GatewayResource gateway) {
-		this.gateway = gateway;
-	}
-
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    public Timestamp getCreationTime() {
-        return creationTime;
-    }
-
-    public void setCreationTime(Timestamp creationTime) {
-        this.creationTime = creationTime;
-    }
-
-    /**
-     *
-     * @param experimentId experiment ID
-     * @return whether the experiment exist
-     */
-    public boolean isExperimentExists(String experimentId) throws RegistryException{
-		return isExists(ResourceType.EXPERIMENT, experimentId);
-	}
-
-    /**
-     *
-     * @param experimentId experiment ID
-     * @return  experiment resource
-     */
-    public ExperimentResource createExperiment(String experimentId) throws RegistryException{
-		ExperimentResource experimentResource = (ExperimentResource)create(ResourceType.EXPERIMENT);
-		experimentResource.setExpID(experimentId);
-		return experimentResource;
-	}
-
-    /**
-     *
-     * @param experimentId experiment ID
-     * @return experiment resource
-     */
-	public ExperimentResource getExperiment(String experimentId) throws RegistryException{
-		return (ExperimentResource)get(ResourceType.EXPERIMENT,experimentId);
-	}
-
-    /**
-     *
-     * @return  list of experiments
-     */
-    public List<ExperimentResource> getExperiments() throws RegistryException{
-		List<Resource> list = get(ResourceType.EXPERIMENT);
-		List<ExperimentResource> result=new ArrayList<ExperimentResource>();
-		for (Resource resource : list) {
-			result.add((ExperimentResource) resource);
-		}
-		return result;
-	}
-
-    public List<ExperimentResource> getExperiments(int limit, int offset, Object orderByIdentifier,
-                                                   ResultOrderType resultOrderType) throws RegistryException{
-        List<Resource> list = get(ResourceType.EXPERIMENT, limit, offset, orderByIdentifier, resultOrderType);
-        List<ExperimentResource> result=new ArrayList<ExperimentResource>();
-        for (Resource resource : list) {
-            result.add((ExperimentResource) resource);
-        }
-        return result;
-    }
-
-    /**
-     *
-     * @param experimentId experiment ID
-     */
-    public void removeExperiment(String experimentId) throws RegistryException{
-		remove(ResourceType.EXPERIMENT, experimentId);
-	}
-
-    public List<ProjectUserResource> getProjectUserList () throws RegistryException{
-        List<Resource> resources = get(ResourceType.PROJECT_USER);
-        List<ProjectUserResource> projectUserResources = new ArrayList<ProjectUserResource>();
-        if (resources != null && !resources.isEmpty()){
-            for (Resource r : resources){
-                projectUserResources.add((ProjectUserResource)r);
-            }
-        }
-        return projectUserResources;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/801489bf/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectUserResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectUserResource.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectUserResource.java
deleted file mode 100644
index 336a9ee..0000000
--- a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectUserResource.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- *
- * 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.persistance.registry.jpa.resources;
-
-import org.apache.airavata.persistance.registry.jpa.Resource;
-import org.apache.airavata.persistance.registry.jpa.ResourceType;
-import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
-import org.apache.airavata.persistance.registry.jpa.model.*;
-import org.apache.airavata.registry.cpi.RegistryException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import java.util.List;
-
-public class ProjectUserResource extends AbstractResource {
-    private String projectId;
-    private String userName;
-
-    private static final Logger logger = LoggerFactory.getLogger(ProjectUserResource.class);
-
-    public String getProjectId() {
-        return projectId;
-    }
-
-    public void setProjectId(String projectId) {
-        this.projectId = projectId;
-    }
-
-    public String getUserName() {
-        return userName;
-    }
-
-    public void setUserName(String userName) {
-        this.userName = userName;
-    }
-
-    
-    public Resource create(ResourceType type) throws RegistryException {
-        logger.error("Unsupported resource type for project resource data resource.", new UnsupportedOperationException());
-        throw new UnsupportedOperationException();
-    }
-
-    
-    public void remove(ResourceType type, Object name) throws RegistryException{
-        logger.error("Unsupported resource type for project resource data resource.", new UnsupportedOperationException());
-        throw new UnsupportedOperationException();
-    }
-
-    
-    public Resource get(ResourceType type, Object name) throws RegistryException{
-        logger.error("Unsupported resource type for project resource data resource.", new UnsupportedOperationException());
-        throw new UnsupportedOperationException();
-    }
-
-    
-    public List<Resource> get(ResourceType type) throws RegistryException{
-        logger.error("Unsupported resource type for project resource data resource.", new UnsupportedOperationException());
-        throw new UnsupportedOperationException();
-    }
-
-    
-    public void save() throws RegistryException{
-        EntityManager em = null;
-        try {
-            em = ResourceUtils.getEntityManager();
-            ProjectUser existingPrUser = em.find(ProjectUser.class, new ProjectUser_PK(projectId, userName));
-            em.close();
-
-            em = ResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-            ProjectUser prUser = new ProjectUser();
-            prUser.setProjectId(projectId);
-            prUser.setUserName(userName);
-            Users user = em.find(Users.class, userName);
-            prUser.setUser(user);
-            Project project = em.find(Project.class, projectId);
-            prUser.setProject(project);
-
-            if (existingPrUser != null) {
-                existingPrUser.setProjectId(projectId);
-                existingPrUser.setUserName(userName);
-                existingPrUser.setUser(user);
-                existingPrUser.setProject(project);
-                prUser = em.merge(existingPrUser);
-            } else {
-                em.persist(prUser);
-            }
-
-            em.getTransaction().commit();
-            em.close();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            throw new RegistryException(e);
-        } finally {
-            if (em != null && em.isOpen()) {
-                if (em.getTransaction().isActive()){
-                    em.getTransaction().rollback();
-                }
-                em.close();
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/801489bf/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/QosParamResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/QosParamResource.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/QosParamResource.java
deleted file mode 100644
index 6f906cd..0000000
--- a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/QosParamResource.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- *
- * 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.persistance.registry.jpa.resources;
-
-import org.apache.airavata.persistance.registry.jpa.Resource;
-import org.apache.airavata.persistance.registry.jpa.ResourceType;
-import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
-import org.apache.airavata.persistance.registry.jpa.model.Experiment;
-import org.apache.airavata.persistance.registry.jpa.model.QosParam;
-import org.apache.airavata.persistance.registry.jpa.model.TaskDetail;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.airavata.registry.cpi.RegistryException;
-
-import javax.persistence.EntityManager;
-import java.util.List;
-
-public class QosParamResource extends AbstractResource {
-    private static final Logger logger = LoggerFactory.getLogger(QosParamResource.class);
-    private int  qosId;
-    private ExperimentResource experimentResource;
-    private TaskDetailResource taskDetailResource;
-    private String startExecutionAt;
-    private String executeBefore;
-    private int noOfRetries;
-
-    public int getQosId() {
-        return qosId;
-    }
-
-    public void setQosId(int qosId) {
-        this.qosId = qosId;
-    }
-
-    public ExperimentResource getExperimentResource() {
-        return experimentResource;
-    }
-
-    public void setExperimentResource(ExperimentResource experimentResource) {
-        this.experimentResource = experimentResource;
-    }
-
-    public TaskDetailResource getTaskDetailResource() {
-        return taskDetailResource;
-    }
-
-    public void setTaskDetailResource(TaskDetailResource taskDetailResource) {
-        this.taskDetailResource = taskDetailResource;
-    }
-
-    public String getStartExecutionAt() {
-        return startExecutionAt;
-    }
-
-    public void setStartExecutionAt(String startExecutionAt) {
-        this.startExecutionAt = startExecutionAt;
-    }
-
-    public String getExecuteBefore() {
-        return executeBefore;
-    }
-
-    public void setExecuteBefore(String executeBefore) {
-        this.executeBefore = executeBefore;
-    }
-
-    public int getNoOfRetries() {
-        return noOfRetries;
-    }
-
-    public void setNoOfRetries(int noOfRetries) {
-        this.noOfRetries = noOfRetries;
-    }
-
-    
-    public Resource create(ResourceType type) throws RegistryException{
-        logger.error("Unsupported resource type for qos params resource.", new UnsupportedOperationException());
-        throw new UnsupportedOperationException();
-    }
-
-    
-    public void remove(ResourceType type, Object name) throws RegistryException{
-        logger.error("Unsupported resource type for qos params resource.", new UnsupportedOperationException());
-        throw new UnsupportedOperationException();
-    }
-
-    
-    public Resource get(ResourceType type, Object name) throws RegistryException{
-        logger.error("Unsupported resource type for qos params resource.", new UnsupportedOperationException());
-        throw new UnsupportedOperationException();
-    }
-
-    
-    public List<Resource> get(ResourceType type) throws RegistryException{
-        logger.error("Unsupported resource type for qos params resource.", new UnsupportedOperationException());
-        throw new UnsupportedOperationException();
-    }
-
-    
-    public void save() throws RegistryException{
-        EntityManager em = null;
-        try {
-            em = ResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-            QosParam qosParam = new QosParam();
-            Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
-            if (taskDetailResource != null) {
-                TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
-                qosParam.setTaskId(taskDetailResource.getTaskId());
-                qosParam.setTask(taskDetail);
-            }
-            qosParam.setExpId(experimentResource.getExpID());
-            qosParam.setExperiment(experiment);
-            qosParam.setStartExecutionAt(startExecutionAt);
-            qosParam.setExecuteBefore(executeBefore);
-            qosParam.setNoOfRetries(noOfRetries);
-            em.persist(qosParam);
-            qosId = qosParam.getQosId();
-            em.getTransaction().commit();
-            em.close();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            throw new RegistryException(e);
-        } finally {
-            if (em != null && em.isOpen()) {
-                if (em.getTransaction().isActive()){
-                    em.getTransaction().rollback();
-                }
-                em.close();
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/801489bf/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/StatusResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/StatusResource.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/StatusResource.java
deleted file mode 100644
index 169e1c7..0000000
--- a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/StatusResource.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- *
- * 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.persistance.registry.jpa.resources;
-
-import org.apache.airavata.persistance.registry.jpa.Resource;
-import org.apache.airavata.persistance.registry.jpa.ResourceType;
-import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
-import org.apache.airavata.persistance.registry.jpa.model.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.airavata.registry.cpi.RegistryException;
-
-import javax.persistence.EntityManager;
-import java.sql.Timestamp;
-import java.util.List;
-
-public class StatusResource extends AbstractResource {
-    private static final Logger logger = LoggerFactory.getLogger(StatusResource.class);
-    private int statusId = 0;
-    private ExperimentResource experimentResource;
-    private WorkflowNodeDetailResource workflowNodeDetail;
-    private DataTransferDetailResource dataTransferDetail;
-    private TaskDetailResource taskDetailResource;
-    private String jobId;
-    private String state;
-    private Timestamp statusUpdateTime;
-    private String statusType;
-
-    public int getStatusId() {
-        return statusId;
-    }
-
-    public void setStatusId(int statusId) {
-        this.statusId = statusId;
-    }
-
-    public ExperimentResource getExperimentResource() {
-        return experimentResource;
-    }
-
-    public void setExperimentResource(ExperimentResource experimentResource) {
-        this.experimentResource = experimentResource;
-    }
-
-    public WorkflowNodeDetailResource getWorkflowNodeDetail() {
-        return workflowNodeDetail;
-    }
-
-    public void setWorkflowNodeDetail(WorkflowNodeDetailResource workflowNodeDetail) {
-        this.workflowNodeDetail = workflowNodeDetail;
-    }
-
-    public DataTransferDetailResource getDataTransferDetail() {
-        return dataTransferDetail;
-    }
-
-    public void setDataTransferDetail(DataTransferDetailResource dataTransferDetail) {
-        this.dataTransferDetail = dataTransferDetail;
-    }
-
-    public TaskDetailResource getTaskDetailResource() {
-        return taskDetailResource;
-    }
-
-    public void setTaskDetailResource(TaskDetailResource taskDetailResource) {
-        this.taskDetailResource = taskDetailResource;
-    }
-
-    public String getJobId() {
-        return jobId;
-    }
-
-    public void setJobId(String jobId) {
-        this.jobId = jobId;
-    }
-
-    public String getState() {
-        return state;
-    }
-
-    public void setState(String state) {
-        this.state = state;
-    }
-
-    public Timestamp getStatusUpdateTime() {
-        return statusUpdateTime;
-    }
-
-    public void setStatusUpdateTime(Timestamp statusUpdateTime) {
-        this.statusUpdateTime = statusUpdateTime;
-    }
-
-    public String getStatusType() {
-        return statusType;
-    }
-
-    public void setStatusType(String statusType) {
-        this.statusType = statusType;
-    }
-
-    
-    public Resource create(ResourceType type) throws RegistryException{
-        logger.error("Unsupported resource type for status resource.", new UnsupportedOperationException());
-        throw new UnsupportedOperationException();
-    }
-
-    
-    public void remove(ResourceType type, Object name) throws RegistryException{
-        logger.error("Unsupported resource type for status resource.", new UnsupportedOperationException());
-        throw new UnsupportedOperationException();
-    }
-
-    
-    public Resource get(ResourceType type, Object name) throws RegistryException{
-        logger.error("Unsupported resource type for status resource.", new UnsupportedOperationException());
-        throw new UnsupportedOperationException();
-    }
-
-    
-    public List<Resource> get(ResourceType type) throws RegistryException{
-        logger.error("Unsupported resource type for status resource.", new UnsupportedOperationException());
-        throw new UnsupportedOperationException();
-    }
-
-    
-    public void save() throws RegistryException{
-        EntityManager em = null;
-        try {
-            em = ResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-            Status status;
-            if (statusId != 0) {
-                status = em.find(Status.class, statusId);
-                status.setStatusId(statusId);
-            } else {
-                status = new Status();
-            }
-            Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
-            if (taskDetailResource != null) {
-                TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
-                status.setTask(taskDetail);
-                status.setTaskId(taskDetailResource.getTaskId());
-            }
-            if (workflowNodeDetail != null) {
-                WorkflowNodeDetail nodeDetail = em.find(WorkflowNodeDetail.class, workflowNodeDetail.getNodeInstanceId());
-                status.setNode(nodeDetail);
-                status.setNodeId(workflowNodeDetail.getNodeInstanceId());
-            }
-            if (dataTransferDetail != null) {
-                DataTransferDetail transferDetail = em.find(DataTransferDetail.class, dataTransferDetail.getTransferId());
-                status.setTransferDetail(transferDetail);
-                status.setTransferId(dataTransferDetail.getTransferId());
-            }
-            status.setExperiment(experiment);
-            status.setJobId(jobId);
-            status.setExpId(experimentResource.getExpID());
-            status.setState(state);
-            status.setStatusUpdateTime(statusUpdateTime);
-            status.setStatusType(statusType);
-            em.persist(status);
-            statusId = status.getStatusId();
-            em.getTransaction().commit();
-            em.close();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            throw new RegistryException(e);
-        } finally {
-            if (em != null && em.isOpen()) {
-                if (em.getTransaction().isActive()){
-                    em.getTransaction().rollback();
-                }
-                em.close();
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/801489bf/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/TaskDetailResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/TaskDetailResource.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/TaskDetailResource.java
deleted file mode 100644
index 791c9f9..0000000
--- a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/TaskDetailResource.java
+++ /dev/null
@@ -1,661 +0,0 @@
-/*
- *
- * 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.persistance.registry.jpa.resources;
-
-import org.apache.airavata.persistance.registry.jpa.Resource;
-import org.apache.airavata.persistance.registry.jpa.ResourceType;
-import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
-import org.apache.airavata.persistance.registry.jpa.model.*;
-import org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator;
-import org.apache.airavata.registry.cpi.RegistryException;
-import org.apache.airavata.registry.cpi.utils.StatusType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.List;
-
-public class TaskDetailResource extends AbstractResource {
-    private static final Logger logger = LoggerFactory.getLogger(TaskDetailResource.class);
-    private String taskId;
-    private WorkflowNodeDetailResource workflowNodeDetailResource;
-    private Timestamp creationTime;
-    private String applicationId;
-    private String applicationVersion;
-    private String applicationDeploymentId;
-    private boolean enableEmailNotifications;
-
-    public boolean isEnableEmailNotifications() {
-        return enableEmailNotifications;
-    }
-
-    public void setEnableEmailNotifications(boolean enableEmailNotifications) {
-        this.enableEmailNotifications = enableEmailNotifications;
-    }
-
-    public String getTaskId() {
-        return taskId;
-    }
-
-    public void setTaskId(String taskId) {
-        this.taskId = taskId;
-    }
-
-    public WorkflowNodeDetailResource getWorkflowNodeDetailResource() {
-        return workflowNodeDetailResource;
-    }
-
-    public void setWorkflowNodeDetailResource(WorkflowNodeDetailResource workflowNodeDetailResource) {
-        this.workflowNodeDetailResource = workflowNodeDetailResource;
-    }
-
-    public Timestamp getCreationTime() {
-        return creationTime;
-    }
-
-    public void setCreationTime(Timestamp creationTime) {
-        this.creationTime = creationTime;
-    }
-
-    public String getApplicationId() {
-        return applicationId;
-    }
-
-    public void setApplicationId(String applicationId) {
-        this.applicationId = applicationId;
-    }
-
-    public String getApplicationVersion() {
-        return applicationVersion;
-    }
-
-    public void setApplicationVersion(String applicationVersion) {
-        this.applicationVersion = applicationVersion;
-    }
-
-    
-    public Resource create(ResourceType type) throws RegistryException{
-       switch (type){
-           case ERROR_DETAIL:
-               ErrorDetailResource errorDetailResource = new ErrorDetailResource();
-               errorDetailResource.setTaskDetailResource(this);
-               return errorDetailResource;
-           case NOTIFICATION_EMAIL:
-               NotificationEmailResource emailResource = new NotificationEmailResource();
-               emailResource.setTaskDetailResource(this);
-               return emailResource;
-           case APPLICATION_INPUT:
-               ApplicationInputResource applicationInputResource = new ApplicationInputResource();
-               applicationInputResource.setTaskDetailResource(this);
-               return applicationInputResource;
-           case APPLICATION_OUTPUT:
-               ApplicationOutputResource applicationOutputResource = new ApplicationOutputResource();
-               applicationOutputResource.setTaskDetailResource(this);
-               return applicationOutputResource;
-           case JOB_DETAIL:
-               JobDetailResource jobDetailResource = new JobDetailResource();
-               jobDetailResource.setTaskDetailResource(this);
-               return jobDetailResource;
-           case DATA_TRANSFER_DETAIL:
-               DataTransferDetailResource dataTransferDetailResource = new DataTransferDetailResource();
-               dataTransferDetailResource.setTaskDetailResource(this);
-               return dataTransferDetailResource;
-           case STATUS:
-               StatusResource statusResource = new StatusResource();
-               statusResource.setTaskDetailResource(this);
-               return statusResource;
-           case COMPUTATIONAL_RESOURCE_SCHEDULING:
-               ComputationSchedulingResource schedulingResource = new ComputationSchedulingResource();
-               schedulingResource.setTaskDetailResource(this);
-               return schedulingResource;
-           case ADVANCE_INPUT_DATA_HANDLING:
-               AdvanceInputDataHandlingResource inputDataHandlingResource = new AdvanceInputDataHandlingResource();
-               inputDataHandlingResource.setTaskDetailResource(this);
-               return inputDataHandlingResource;
-           case ADVANCE_OUTPUT_DATA_HANDLING:
-               AdvancedOutputDataHandlingResource outputDataHandlingResource = new AdvancedOutputDataHandlingResource();
-               outputDataHandlingResource.setTaskDetailResource(this);
-               return outputDataHandlingResource;
-           case QOS_PARAM:
-               QosParamResource qosParamResource = new QosParamResource();
-               qosParamResource.setTaskDetailResource(this);
-               return qosParamResource;
-           default:
-               logger.error("Unsupported resource type for task detail resource.", new IllegalArgumentException());
-               throw new IllegalArgumentException("Unsupported resource type for task detail resource.");
-       }
-    }
-
-    
-    public void remove(ResourceType type, Object name) throws RegistryException{
-        EntityManager em = null;
-        try {
-            em = ResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-            Query q;
-            QueryGenerator generator;
-            switch (type) {
-                case ERROR_DETAIL:
-                    generator = new QueryGenerator(ERROR_DETAIL);
-                    generator.setParameter(ErrorDetailConstants.TASK_ID, name);
-                    q = generator.deleteQuery(em);
-                    q.executeUpdate();
-                    break;
-                case NOTIFICATION_EMAIL:
-                    generator = new QueryGenerator(NOTIFICATION_EMAIL);
-                    generator.setParameter(NotificationEmailConstants.TASK_ID, name);
-                    q = generator.deleteQuery(em);
-                    q.executeUpdate();
-                    break;
-                case APPLICATION_INPUT:
-                    generator = new QueryGenerator(APPLICATION_INPUT);
-                    generator.setParameter(ApplicationInputConstants.TASK_ID, name);
-                    q = generator.deleteQuery(em);
-                    q.executeUpdate();
-                    break;
-                case APPLICATION_OUTPUT:
-                    generator = new QueryGenerator(APPLICATION_OUTPUT);
-                    generator.setParameter(ApplicationOutputConstants.TASK_ID, name);
-                    q = generator.deleteQuery(em);
-                    q.executeUpdate();
-                    break;
-                case JOB_DETAIL:
-                    generator = new QueryGenerator(JOB_DETAIL);
-                    generator.setParameter(JobDetailConstants.TASK_ID, taskId);
-                    generator.setParameter(JobDetailConstants.JOB_ID, name);
-                    q = generator.deleteQuery(em);
-                    q.executeUpdate();
-                    break;
-                case DATA_TRANSFER_DETAIL:
-                    generator = new QueryGenerator(DATA_TRANSFER_DETAIL);
-                    generator.setParameter(DataTransferDetailConstants.TRANSFER_ID, name);
-                    q = generator.deleteQuery(em);
-                    q.executeUpdate();
-                    break;
-                case STATUS:
-                    generator = new QueryGenerator(STATUS);
-                    generator.setParameter(StatusConstants.TASK_ID, name);
-                    generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.TASK.toString());
-                    q = generator.deleteQuery(em);
-                    q.executeUpdate();
-                    break;
-                case COMPUTATIONAL_RESOURCE_SCHEDULING:
-                    generator = new QueryGenerator(COMPUTATIONAL_RESOURCE_SCHEDULING);
-                    generator.setParameter(ComputationalResourceSchedulingConstants.TASK_ID, name);
-                    q = generator.deleteQuery(em);
-                    q.executeUpdate();
-                    break;
-                case ADVANCE_INPUT_DATA_HANDLING:
-                    generator = new QueryGenerator(ADVANCE_INPUT_DATA_HANDLING);
-                    generator.setParameter(AdvancedInputDataHandlingConstants.TASK_ID, name);
-                    q = generator.deleteQuery(em);
-                    q.executeUpdate();
-                    break;
-                case ADVANCE_OUTPUT_DATA_HANDLING:
-                    generator = new QueryGenerator(ADVANCE_OUTPUT_DATA_HANDLING);
-                    generator.setParameter(AdvancedOutputDataHandlingConstants.TASK_ID, name);
-                    q = generator.deleteQuery(em);
-                    q.executeUpdate();
-                    break;
-                case QOS_PARAM:
-                    generator = new QueryGenerator(QOS_PARAMS);
-                    generator.setParameter(QosParamsConstants.TASK_ID, name);
-                    q = generator.deleteQuery(em);
-                    q.executeUpdate();
-                    break;
-                default:
-                    logger.error("Unsupported resource type for task detail resource.", new IllegalArgumentException());
-                    break;
-            }
-            em.getTransaction().commit();
-            em.close();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            throw new RegistryException(e);
-        } finally {
-            if (em != null && em.isOpen()) {
-                if (em.getTransaction().isActive()){
-                    em.getTransaction().rollback();
-                }
-                em.close();
-            }
-        }
-    }
-
-    
-    public Resource get(ResourceType type, Object name) throws RegistryException{
-        EntityManager em = null;
-        try {
-            em = ResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-            QueryGenerator generator;
-            Query q;
-            switch (type) {
-                case ERROR_DETAIL:
-                    generator = new QueryGenerator(ERROR_DETAIL);
-                    generator.setParameter(ErrorDetailConstants.TASK_ID, name);
-                    q = generator.selectQuery(em);
-                    ErrorDetail errorDetail = (ErrorDetail) q.getSingleResult();
-                    ErrorDetailResource errorDetailResource = (ErrorDetailResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
-                    em.getTransaction().commit();
-                    em.close();
-                    return errorDetailResource;
-                case NOTIFICATION_EMAIL:
-                    generator = new QueryGenerator(NOTIFICATION_EMAIL);
-                    generator.setParameter(NotificationEmailConstants.TASK_ID, name);
-                    q = generator.selectQuery(em);
-                    Notification_Email notificationEmail = (Notification_Email) q.getSingleResult();
-                    NotificationEmailResource emailResource = (NotificationEmailResource) Utils.getResource(ResourceType.NOTIFICATION_EMAIL, notificationEmail);
-                    em.getTransaction().commit();
-                    em.close();
-                    return emailResource;
-                case APPLICATION_INPUT:
-                    generator = new QueryGenerator(APPLICATION_INPUT);
-                    generator.setParameter(ApplicationInputConstants.TASK_ID, name);
-                    q = generator.selectQuery(em);
-                    ApplicationInput applicationInput = (ApplicationInput) q.getSingleResult();
-                    ApplicationInputResource inputResource = (ApplicationInputResource) Utils.getResource(ResourceType.APPLICATION_INPUT, applicationInput);
-                    em.getTransaction().commit();
-                    em.close();
-                    return inputResource;
-                case APPLICATION_OUTPUT:
-                    generator = new QueryGenerator(APPLICATION_OUTPUT);
-                    generator.setParameter(ApplicationOutputConstants.TASK_ID, name);
-                    q = generator.selectQuery(em);
-                    ApplicationOutput applicationOutput = (ApplicationOutput) q.getSingleResult();
-                    ApplicationOutputResource outputResource = (ApplicationOutputResource) Utils.getResource(ResourceType.APPLICATION_OUTPUT, applicationOutput);
-                    em.getTransaction().commit();
-                    em.close();
-                    return outputResource;
-                case JOB_DETAIL:
-                    generator = new QueryGenerator(JOB_DETAIL);
-                    generator.setParameter(JobDetailConstants.JOB_ID, name);
-                    generator.setParameter(JobDetailConstants.TASK_ID, taskId);
-                    q = generator.selectQuery(em);
-                    JobDetail jobDetail = (JobDetail) q.getSingleResult();
-                    JobDetailResource jobDetailResource = (JobDetailResource) Utils.getResource(ResourceType.JOB_DETAIL, jobDetail);
-                    em.getTransaction().commit();
-                    em.close();
-                    return jobDetailResource;
-                case DATA_TRANSFER_DETAIL:
-                    generator = new QueryGenerator(DATA_TRANSFER_DETAIL);
-                    generator.setParameter(DataTransferDetailConstants.TRANSFER_ID, name);
-                    q = generator.selectQuery(em);
-                    DataTransferDetail transferDetail = (DataTransferDetail) q.getSingleResult();
-                    DataTransferDetailResource transferDetailResource = (DataTransferDetailResource) Utils.getResource(ResourceType.DATA_TRANSFER_DETAIL, transferDetail);
-                    em.getTransaction().commit();
-                    em.close();
-                    return transferDetailResource;
-                case STATUS:
-                    generator = new QueryGenerator(STATUS);
-                    generator.setParameter(StatusConstants.TASK_ID, name);
-                    generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.TASK.toString());
-                    q = generator.selectQuery(em);
-                    Status status = (Status) q.getSingleResult();
-                    StatusResource statusResource = (StatusResource) Utils.getResource(ResourceType.STATUS, status);
-                    em.getTransaction().commit();
-                    em.close();
-                    return statusResource;
-                case COMPUTATIONAL_RESOURCE_SCHEDULING:
-                    generator = new QueryGenerator(COMPUTATIONAL_RESOURCE_SCHEDULING);
-                    generator.setParameter(ComputationalResourceSchedulingConstants.TASK_ID, name);
-                    q = generator.selectQuery(em);
-                    Computational_Resource_Scheduling resourceScheduling = (Computational_Resource_Scheduling) q.getSingleResult();
-                    ComputationSchedulingResource schedulingResource = (ComputationSchedulingResource) Utils.getResource(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING, resourceScheduling);
-                    em.getTransaction().commit();
-                    em.close();
-                    return schedulingResource;
-                case ADVANCE_INPUT_DATA_HANDLING:
-                    generator = new QueryGenerator(ADVANCE_INPUT_DATA_HANDLING);
-                    generator.setParameter(AdvancedInputDataHandlingConstants.TASK_ID, name);
-                    q = generator.selectQuery(em);
-                    AdvancedInputDataHandling dataHandling = (AdvancedInputDataHandling) q.getSingleResult();
-                    AdvanceInputDataHandlingResource inputDataHandlingResource = (AdvanceInputDataHandlingResource) Utils.getResource(ResourceType.ADVANCE_INPUT_DATA_HANDLING, dataHandling);
-                    em.getTransaction().commit();
-                    em.close();
-                    return inputDataHandlingResource;
-                case ADVANCE_OUTPUT_DATA_HANDLING:
-                    generator = new QueryGenerator(ADVANCE_OUTPUT_DATA_HANDLING);
-                    generator.setParameter(AdvancedOutputDataHandlingConstants.TASK_ID, name);
-                    q = generator.selectQuery(em);
-                    AdvancedOutputDataHandling outputDataHandling = (AdvancedOutputDataHandling) q.getSingleResult();
-                    AdvancedOutputDataHandlingResource outputDataHandlingResource = (AdvancedOutputDataHandlingResource) Utils.getResource(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING, outputDataHandling);
-                    em.getTransaction().commit();
-                    em.close();
-                    return outputDataHandlingResource;
-                case QOS_PARAM:
-                    generator = new QueryGenerator(QOS_PARAMS);
-                    generator.setParameter(QosParamsConstants.TASK_ID, name);
-                    q = generator.selectQuery(em);
-                    QosParam qosParam = (QosParam) q.getSingleResult();
-                    QosParamResource qosParamResource = (QosParamResource) Utils.getResource(ResourceType.QOS_PARAM, qosParam);
-                    em.getTransaction().commit();
-                    em.close();
-                    return qosParamResource;
-                default:
-                    em.getTransaction().commit();
-                    em.close();
-                    logger.error("Unsupported resource type for workflow node resource.", new IllegalArgumentException());
-                    throw new IllegalArgumentException("Unsupported resource type for workflow node resource.");
-            }
-        } catch (Exception e) {
-//            logger.error(e.getMessage(), e);
-            throw new RegistryException(e);
-        } finally {
-            if (em != null && em.isOpen()) {
-                if (em.getTransaction().isActive()){
-                    em.getTransaction().rollback();
-                }
-                em.close();
-            }
-        }
-    }
-
-    
-    public List<Resource> get(ResourceType type) throws RegistryException{
-        List<Resource> resourceList = new ArrayList<Resource>();
-        EntityManager em = null;
-        try {
-            em = ResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-            Query q;
-            QueryGenerator generator;
-            List results;
-            switch (type) {
-                case ERROR_DETAIL:
-                    generator = new QueryGenerator(ERROR_DETAIL);
-                    generator.setParameter(ErrorDetailConstants.TASK_ID, taskId);
-                    q = generator.selectQuery(em);
-                    results = q.getResultList();
-                    if (results.size() != 0) {
-                        for (Object result : results) {
-                            ErrorDetail errorDetail = (ErrorDetail) result;
-                            ErrorDetailResource errorDetailResource =
-                                    (ErrorDetailResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
-                            resourceList.add(errorDetailResource);
-                        }
-                    }
-                    break;
-                case NOTIFICATION_EMAIL:
-                    generator = new QueryGenerator(NOTIFICATION_EMAIL);
-                    generator.setParameter(NotificationEmailConstants.TASK_ID, taskId);
-                    q = generator.selectQuery(em);
-                    results = q.getResultList();
-                    if (results.size() != 0) {
-                        for (Object result : results) {
-                            Notification_Email notificationEmail = (Notification_Email) result;
-                            NotificationEmailResource emailResource =
-                                    (NotificationEmailResource) Utils.getResource(ResourceType.NOTIFICATION_EMAIL, notificationEmail);
-                            resourceList.add(emailResource);
-                        }
-                    }
-                    break;
-                case APPLICATION_INPUT:
-                    generator = new QueryGenerator(APPLICATION_INPUT);
-                    generator.setParameter(ApplicationInputConstants.TASK_ID, taskId);
-                    q = generator.selectQuery(em);
-                    results = q.getResultList();
-                    if (results.size() != 0) {
-                        for (Object result : results) {
-                            ApplicationInput applicationInput = (ApplicationInput) result;
-                            ApplicationInputResource inputResource =
-                                    (ApplicationInputResource) Utils.getResource(ResourceType.APPLICATION_INPUT, applicationInput);
-                            resourceList.add(inputResource);
-                        }
-                    }
-                    break;
-                case APPLICATION_OUTPUT:
-                    generator = new QueryGenerator(APPLICATION_OUTPUT);
-                    generator.setParameter(ApplicationOutputConstants.TASK_ID, taskId);
-                    q = generator.selectQuery(em);
-                    results = q.getResultList();
-                    if (results.size() != 0) {
-                        for (Object result : results) {
-                            ApplicationOutput applicationOutput = (ApplicationOutput) result;
-                            ApplicationOutputResource outputResource =
-                                    (ApplicationOutputResource) Utils.getResource(ResourceType.APPLICATION_OUTPUT, applicationOutput);
-                            resourceList.add(outputResource);
-                        }
-                    }
-                    break;
-                case JOB_DETAIL:
-                    generator = new QueryGenerator(JOB_DETAIL);
-                    generator.setParameter(JobDetailConstants.TASK_ID, taskId);
-                    q = generator.selectQuery(em);
-                    results = q.getResultList();
-                    if (results.size() != 0) {
-                        for (Object result : results) {
-                            JobDetail jobDetail = (JobDetail) result;
-                            JobDetailResource jobDetailResource =
-                                    (JobDetailResource) Utils.getResource(ResourceType.JOB_DETAIL, jobDetail);
-                            resourceList.add(jobDetailResource);
-                        }
-                    }
-                    break;
-                case DATA_TRANSFER_DETAIL:
-                    generator = new QueryGenerator(DATA_TRANSFER_DETAIL);
-                    generator.setParameter(DataTransferDetailConstants.TASK_ID, taskId);
-                    q = generator.selectQuery(em);
-                    results = q.getResultList();
-                    if (results.size() != 0) {
-                        for (Object result : results) {
-                            DataTransferDetail transferDetail = (DataTransferDetail) result;
-                            DataTransferDetailResource transferDetailResource =
-                                    (DataTransferDetailResource) Utils.getResource(ResourceType.DATA_TRANSFER_DETAIL, transferDetail);
-                            resourceList.add(transferDetailResource);
-                        }
-                    }
-                    break;
-                case STATUS:
-                    generator = new QueryGenerator(STATUS);
-                    generator.setParameter(StatusConstants.TASK_ID, taskId);
-                    q = generator.selectQuery(em);
-                    results = q.getResultList();
-                    if (results.size() != 0) {
-                        for (Object result : results) {
-                            Status status = (Status) result;
-                            StatusResource statusResource =
-                                    (StatusResource) Utils.getResource(ResourceType.STATUS, status);
-                            resourceList.add(statusResource);
-                        }
-                    }
-                    break;
-                default:
-                    em.getTransaction().commit();
-                    em.close();
-                    logger.error("Unsupported resource type for workflow node details resource.", new UnsupportedOperationException());
-                    throw new UnsupportedOperationException();
-            }
-            em.getTransaction().commit();
-            em.close();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            throw new RegistryException(e);
-        } finally {
-            if (em != null && em.isOpen()) {
-                if (em.getTransaction().isActive()){
-                    em.getTransaction().rollback();
-                }
-                em.close();
-            }
-        }
-        return resourceList;
-    }
-
-    
-    public void save() throws RegistryException{
-        EntityManager em = null;
-        try {
-            em = ResourceUtils.getEntityManager();
-            TaskDetail taskDetail = em.find(TaskDetail.class, taskId);
-            em.close();
-            em = ResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-            WorkflowNodeDetail workflowNodeDetail = em.find(WorkflowNodeDetail.class, workflowNodeDetailResource.getNodeInstanceId());
-            if (taskDetail != null) {
-            	updateTaskDetail(taskDetail, workflowNodeDetail);
-                em.merge(taskDetail);
-            } else {
-                taskDetail = new TaskDetail();
-                updateTaskDetail(taskDetail, workflowNodeDetail);                
-                em.persist(taskDetail);
-            }
-            em.getTransaction().commit();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            throw new RegistryException(e);
-        } finally {
-            if (em != null && em.isOpen()) {
-                if (em.getTransaction().isActive()){
-                    em.getTransaction().rollback();
-                }
-                em.close();
-            }
-        }
-    }
-
-	private void updateTaskDetail(TaskDetail taskDetail,
-			WorkflowNodeDetail workflowNodeDetail) {
-		taskDetail.setTaskId(taskId);
-		taskDetail.setNodeDetail(workflowNodeDetail);
-		taskDetail.setNodeId(workflowNodeDetailResource.getNodeInstanceId());
-		taskDetail.setCreationTime(creationTime);
-		taskDetail.setAppId(applicationId);
-		taskDetail.setAppVersion(applicationVersion);
-        taskDetail.setAllowNotification(enableEmailNotifications);
-		taskDetail.setApplicationDeploymentId(getApplicationDeploymentId());
-	}
-
-    public List<ApplicationInputResource> getApplicationInputs() throws RegistryException{
-        List<ApplicationInputResource> applicationInputResources = new ArrayList<ApplicationInputResource>();
-        List<Resource> resources = get(ResourceType.APPLICATION_INPUT);
-        for (Resource resource : resources) {
-            ApplicationInputResource inputResource = (ApplicationInputResource) resource;
-            applicationInputResources.add(inputResource);
-        }
-        return applicationInputResources;
-    }
-
-    public List<ApplicationOutputResource> getApplicationOutputs() throws RegistryException{
-        List<ApplicationOutputResource> outputResources = new ArrayList<ApplicationOutputResource>();
-        List<Resource> resources = get(ResourceType.APPLICATION_OUTPUT);
-        for (Resource resource : resources) {
-            ApplicationOutputResource outputResource = (ApplicationOutputResource) resource;
-            outputResources.add(outputResource);
-        }
-        return outputResources;
-    }
-
-    public StatusResource getTaskStatus() throws RegistryException{
-        List<Resource> resources = get(ResourceType.STATUS);
-        for (Resource resource : resources) {
-            StatusResource taskStatus = (StatusResource) resource;
-            if(taskStatus.getStatusType().equals(StatusType.TASK.toString())){
-                if (taskStatus.getState() == null || taskStatus.getState().equals("") ){
-                    taskStatus.setState("UNKNOWN");
-                }
-                return taskStatus;
-            }
-        }
-        return null;
-    }
-
-    public List<JobDetailResource> getJobDetailList() throws RegistryException{
-        List<JobDetailResource> jobDetailResources = new ArrayList<JobDetailResource>();
-        List<Resource> resources = get(ResourceType.JOB_DETAIL);
-        for (Resource resource : resources) {
-            JobDetailResource jobDetailResource = (JobDetailResource) resource;
-            jobDetailResources.add(jobDetailResource);
-        }
-        return jobDetailResources;
-    }
-
-    public List<DataTransferDetailResource> getDataTransferDetailList() throws RegistryException{
-        List<DataTransferDetailResource> transferDetails = new ArrayList<DataTransferDetailResource>();
-        List<Resource> resources = get(ResourceType.DATA_TRANSFER_DETAIL);
-        for (Resource resource : resources) {
-            DataTransferDetailResource transferDetailResource = (DataTransferDetailResource) resource;
-            transferDetails.add(transferDetailResource);
-        }
-        return transferDetails;
-    }
-
-    public List<ErrorDetailResource> getErrorDetailList() throws RegistryException{
-        List<ErrorDetailResource> errorDetailResources = new ArrayList<ErrorDetailResource>();
-        List<Resource> resources = get(ResourceType.ERROR_DETAIL);
-        for (Resource resource : resources) {
-            ErrorDetailResource errorDetailResource = (ErrorDetailResource) resource;
-            errorDetailResources.add(errorDetailResource);
-        }
-        return errorDetailResources;
-    }
-
-    public ComputationSchedulingResource getComputationScheduling (String taskId) throws RegistryException{
-        return  (ComputationSchedulingResource)get(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING, taskId);
-    }
-
-    public AdvanceInputDataHandlingResource getInputDataHandling (String taskId) throws RegistryException{
-        return  (AdvanceInputDataHandlingResource)get(ResourceType.ADVANCE_INPUT_DATA_HANDLING, taskId);
-    }
-
-    public AdvancedOutputDataHandlingResource getOutputDataHandling (String taskId) throws RegistryException{
-        return  (AdvancedOutputDataHandlingResource)get(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING, taskId);
-    }
-
-    public JobDetailResource createJobDetail (String jobId) throws RegistryException{
-        JobDetailResource resource = (JobDetailResource)create(ResourceType.JOB_DETAIL);
-        resource.setJobId(jobId);
-        return resource;
-    }
-
-    public JobDetailResource getJobDetail (String jobId) throws RegistryException{
-        return (JobDetailResource)get(ResourceType.JOB_DETAIL, jobId);
-    }
-
-    public DataTransferDetailResource getDataTransferDetail (String dataTransferId) throws RegistryException{
-        return (DataTransferDetailResource)get(ResourceType.DATA_TRANSFER_DETAIL, dataTransferId);
-    }
-
-    public  boolean isTaskStatusExist (String taskId) throws RegistryException{
-        return isExists(ResourceType.STATUS, taskId);
-    }
-
-	public String getApplicationDeploymentId() {
-		return applicationDeploymentId;
-	}
-
-	public void setApplicationDeploymentId(String applicationDeploymentId) {
-		this.applicationDeploymentId = applicationDeploymentId;
-	}
-
-    public List<NotificationEmailResource> getNotificationEmails () throws RegistryException{
-        List<NotificationEmailResource> emailResources = new ArrayList<NotificationEmailResource>();
-        List<Resource> resources = get(ResourceType.NOTIFICATION_EMAIL);
-        for (Resource resource : resources) {
-            emailResources.add((NotificationEmailResource) resource);
-        }
-        return emailResources;
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/801489bf/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/UserResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/UserResource.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/UserResource.java
deleted file mode 100644
index 11f2a4f..0000000
--- a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/UserResource.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- *
- * 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.persistance.registry.jpa.resources;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.SecurityUtil;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.persistance.registry.jpa.Resource;
-import org.apache.airavata.persistance.registry.jpa.ResourceType;
-import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
-import org.apache.airavata.persistance.registry.jpa.model.Users;
-import org.apache.airavata.registry.cpi.RegistryException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import java.security.NoSuchAlgorithmException;
-import java.util.List;
-
-public class UserResource extends AbstractResource {
-    private final static Logger logger = LoggerFactory.getLogger(UserResource.class);
-    private String userName;
-    private String password;
-    /**
-     *
-     */
-    public UserResource() {
-    }
-
-    /**
-     *
-     * @param userName user name
-     */
-    public void setUserName(String userName) {
-        this.userName = userName;
-    }
-
-    /**
-     *
-     * @return user name
-     */
-    public String getUserName() {
-        return userName;
-    }
-
-
-    /**
-     * User is a hypothical data structure.
-     * @param type child resource type
-     * @return child resource
-     */
-    public Resource create(ResourceType type) throws RegistryException {
-        logger.error("Unsupported resource type for user resource.", new UnsupportedOperationException());
-        throw new UnsupportedOperationException();
-    }
-
-    /**
-     *
-     * @param type child resource type
-     * @param name child resource name
-     */
-    public void remove(ResourceType type, Object name) throws RegistryException{
-        logger.error("Unsupported resource type for user resource.", new UnsupportedOperationException());
-        throw new UnsupportedOperationException();
-    }
-
-    /**
-     *
-     * @param type child resource type
-     * @param name child resource name
-     * @return UnsupportedOperationException
-     */
-    public Resource get(ResourceType type, Object name) throws RegistryException {
-        logger.error("Unsupported resource type for user resource.", new UnsupportedOperationException());
-        throw new UnsupportedOperationException();
-    }
-
-    /**
-     *
-     * @param type child resource type
-     * @return UnsupportedOperationException
-     */
-    public List<Resource> get(ResourceType type) throws RegistryException{
-        logger.error("Unsupported resource type for user resource.", new UnsupportedOperationException());
-        throw new UnsupportedOperationException();
-    }
-
-    /**
-     * saveExperiment user to the database
-     */
-    public void save() throws RegistryException {
-        EntityManager em = null;
-        try {
-            em = ResourceUtils.getEntityManager();
-            Users existingUser = em.find(Users.class, userName);
-            em.close();
-
-            em = ResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-            Users user = new Users();
-            user.setUser_name(userName);
-            if (password != null && !password.equals("")) {
-                try {
-                    user.setPassword(SecurityUtil.digestString(password,
-                            ServerSettings.getSetting("default.registry.password.hash.method")));
-                } catch (NoSuchAlgorithmException e) {
-                    throw new RuntimeException("Error hashing default admin password. Invalid hash algorithm.", e);
-                } catch (ApplicationSettingsException e) {
-                    throw new RuntimeException("Error reading hash algorithm from configurations", e);
-                }
-            }
-            if (existingUser != null) {
-                if (password != null && !password.equals("")) {
-                    try {
-                        existingUser.setPassword(SecurityUtil.digestString(password,
-                                ServerSettings.getSetting("default.registry.password.hash.method")));
-                    } catch (NoSuchAlgorithmException e) {
-                        throw new RuntimeException("Error hashing default admin password. Invalid hash algorithm.", e);
-                    } catch (ApplicationSettingsException e) {
-                        throw new RuntimeException("Error reading hash algorithm from configurations", e);
-                    }
-                }
-                user = em.merge(existingUser);
-            } else {
-                em.persist(user);
-            }
-            em.getTransaction().commit();
-            em.close();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            throw new RegistryException(e);
-        } finally {
-            if (em != null && em.isOpen()) {
-                if (em.getTransaction().isActive()){
-                    em.getTransaction().rollback();
-                }
-                em.close();
-            }
-        }
-    }
-
-    /**
-     *
-     * @param type child resource type
-     * @param name child resource name
-     * @return UnsupportedOperationException
-     */
-    public boolean isExists(ResourceType type, Object name) throws RegistryException{
-        logger.error("Unsupported resource type for user resource.", new UnsupportedOperationException());
-        throw new UnsupportedOperationException();
-    }
-
-    /**
-     *
-     * @return  password
-     */
-    public String getPassword() {
-        return password;
-    }
-
-    /**
-     *
-     * @param password  password
-     */
-    public void setPassword(String password) {
-        this.password = password;
-    }
-}