http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/impl/GatewayRegistry.java ---------------------------------------------------------------------- diff --git a/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/impl/GatewayRegistry.java b/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/impl/GatewayRegistry.java deleted file mode 100644 index a98de72..0000000 --- a/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/impl/GatewayRegistry.java +++ /dev/null @@ -1,115 +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.experiment.catalog.impl; - -import org.apache.airavata.common.exception.ApplicationSettingsException; -import org.apache.airavata.common.utils.ServerSettings; -import org.apache.airavata.model.workspace.Gateway; -import org.apache.airavata.experiment.catalog.Resource; -import org.apache.airavata.experiment.catalog.ResourceUtils; -import org.apache.airavata.experiment.catalog.resources.GatewayResource; -import org.apache.airavata.experiment.catalog.utils.ThriftDataModelConversion; -import org.apache.airavata.registry.cpi.RegistryException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.List; - -public class GatewayRegistry { - - private final static Logger logger = LoggerFactory.getLogger(GatewayRegistry.class); - public GatewayResource getDefaultGateway () throws ApplicationSettingsException, RegistryException { - return (GatewayResource)ResourceUtils.getGateway(ServerSettings.getDefaultUserGateway()); - } - - public GatewayResource getExistingGateway (String gatewayName) throws RegistryException { - return (GatewayResource)ResourceUtils.getGateway(gatewayName); - } - - public String addGateway (Gateway gateway) throws RegistryException{ - try { - GatewayResource resource = (GatewayResource)ResourceUtils.createGateway(gateway.getGatewayId()); - resource.setGatewayName(gateway.getGatewayName()); - resource.setEmailAddress(gateway.getEmailAddress()); - resource.setDomain(gateway.getDomain()); - resource.save(); - return gateway.getGatewayId(); - }catch (RegistryException e){ - logger.error("Error while saving gateway to registry", e); - throw new RegistryException(e); - } - } - - public void updateGateway (String gatewayId, Gateway updatedGateway) throws RegistryException{ - try { - GatewayResource existingGateway = (GatewayResource)ResourceUtils.getGateway(gatewayId); - existingGateway.setGatewayName(updatedGateway.getGatewayName()); - existingGateway.setEmailAddress(updatedGateway.getEmailAddress()); - existingGateway.setDomain(updatedGateway.getDomain()); - existingGateway.save(); - }catch (RegistryException e){ - logger.error("Error while updating gateway to registry", e); - throw new RegistryException(e); - } - } - - public Gateway getGateway (String gatewayId) throws RegistryException{ - try { - GatewayResource resource = (GatewayResource)ResourceUtils.getGateway(gatewayId); - return ThriftDataModelConversion.getGateway(resource); - }catch (RegistryException e){ - logger.error("Error while getting gateway", e); - throw new RegistryException(e); - } - } - - public boolean isGatewayExist (String gatewayId) throws RegistryException{ - try { - return ResourceUtils.isGatewayExist(gatewayId); - }catch (RegistryException e){ - logger.error("Error while checking gateway exists", e); - throw new RegistryException(e); - } - } - - public boolean removeGateway (String gatewayId) throws RegistryException{ - try { - return ResourceUtils.removeGateway(gatewayId); - }catch (Exception e){ - logger.error("Error while removing the gateway", e); - throw new RegistryException(e); - } - } - - public List<Gateway> getAllGateways () throws RegistryException { - List<Gateway> gatewayList = new ArrayList<Gateway>(); - try { - List<Resource> allGateways = ResourceUtils.getAllGateways(); - return ThriftDataModelConversion.getAllGateways(allGateways); - }catch (Exception e){ - logger.error("Error while getting all the gateways", e); - throw new RegistryException(e); - } - } - -}
http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/impl/LoggingRegistryImpl.java ---------------------------------------------------------------------- diff --git a/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/impl/LoggingRegistryImpl.java b/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/impl/LoggingRegistryImpl.java deleted file mode 100644 index d4b735a..0000000 --- a/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/impl/LoggingRegistryImpl.java +++ /dev/null @@ -1,97 +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.experiment.catalog.impl; - -import org.apache.airavata.registry.cpi.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.List; -import java.util.Map; - -public class LoggingRegistryImpl implements Registry { - private final static Logger logger = LoggerFactory.getLogger(LoggingRegistryImpl.class); - - @Override - public Object add(ParentDataType dataType, Object newObjectToAdd, String gatewayId) throws RegistryException { - return null; - } - - @Override - public Object add(ChildDataType dataType, Object newObjectToAdd, Object dependentIdentifiers) throws RegistryException { - return null; - } - - @Override - public void update(RegistryModelType dataType, Object newObjectToUpdate, Object identifier) throws RegistryException { - - } - - @Override - public void update(RegistryModelType dataType, Object identifier, String fieldName, Object value) throws RegistryException { - - } - - @Override - public Object get(RegistryModelType dataType, Object identifier) throws RegistryException { - return null; - } - - @Override - public List<Object> get(RegistryModelType dataType, String fieldName, Object value) throws RegistryException { - return null; - } - - @Override - public List<Object> get(RegistryModelType dataType, String fieldName, Object value, int limit, int offset, Object orderByIdentifier, ResultOrderType resultOrderType) throws RegistryException { - return null; - } - - @Override - public List<Object> search(RegistryModelType dataType, Map<String, String> filters) throws RegistryException { - return null; - } - - @Override - public List<Object> search(RegistryModelType dataType, Map<String, String> filters, int limit, int offset, Object orderByIdentifier, ResultOrderType resultOrderType) throws RegistryException { - return null; - } - - @Override - public Object getValue(RegistryModelType dataType, Object identifier, String field) throws RegistryException { - return null; - } - - @Override - public List<String> getIds(RegistryModelType dataType, String fieldName, Object value) throws RegistryException { - return null; - } - - @Override - public void remove(RegistryModelType dataType, Object identifier) throws RegistryException { - - } - - @Override - public boolean isExist(RegistryModelType dataType, Object identifier) throws RegistryException { - return false; - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/impl/ProjectRegistry.java ---------------------------------------------------------------------- diff --git a/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/impl/ProjectRegistry.java b/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/impl/ProjectRegistry.java deleted file mode 100644 index 52a9ee4..0000000 --- a/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/impl/ProjectRegistry.java +++ /dev/null @@ -1,303 +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.experiment.catalog.impl; - -import org.apache.airavata.common.utils.AiravataUtils; -import org.apache.airavata.model.workspace.Project; -import org.apache.airavata.experiment.catalog.ResourceType; -import org.apache.airavata.experiment.catalog.ResourceUtils; -import org.apache.airavata.experiment.catalog.resources.*; -import org.apache.airavata.experiment.catalog.utils.ThriftDataModelConversion; -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 java.util.*; - -public class ProjectRegistry { - private GatewayResource gatewayResource; - private WorkerResource workerResource; - private final static Logger logger = LoggerFactory.getLogger(ProjectRegistry.class); - - public ProjectRegistry(GatewayResource gatewayResource, UserResource user) throws RegistryException { - if (!ResourceUtils.isGatewayExist(gatewayResource.getGatewayId())){ - this.gatewayResource = gatewayResource; - }else { - this.gatewayResource = (GatewayResource)ResourceUtils.getGateway(gatewayResource.getGatewayId()); - } - if (!gatewayResource.isExists(ResourceType.GATEWAY_WORKER, user.getUserName())){ - workerResource = ResourceUtils.addGatewayWorker(gatewayResource, user); - }else { - workerResource = (WorkerResource)ResourceUtils.getWorker(gatewayResource.getGatewayId(), - user.getUserName()); - } - } - - public String addProject (Project project, String gatewayId) throws RegistryException{ - String projectId; - try { - if (!ResourceUtils.isUserExist(project.getOwner())){ - ResourceUtils.addUser(project.getOwner(), null); - } - ProjectResource projectResource = new ProjectResource(); - projectId = getProjectId(project.getName()); - projectResource.setId(projectId); - project.setProjectID(projectId); - projectResource.setName(project.getName()); - projectResource.setDescription(project.getDescription()); - projectResource.setCreationTime(AiravataUtils.getTime(project.getCreationTime())); - projectResource.setGatewayId(gatewayId); - WorkerResource worker = new WorkerResource(project.getOwner(), gatewayId); - projectResource.setWorker(worker); - projectResource.save(); - ProjectUserResource resource = (ProjectUserResource)projectResource.create( - ResourceType.PROJECT_USER); - resource.setProjectId(project.getProjectID()); - resource.setUserName(project.getOwner()); - resource.save(); - List<String> sharedGroups = project.getSharedGroups(); - if (sharedGroups != null && !sharedGroups.isEmpty()){ - for (String group : sharedGroups){ - //TODO - add shared groups - logger.info("Groups are not supported at the moment..."); - } - } - - List<String> sharedUsers = project.getSharedUsers(); - if (sharedUsers != null && !sharedUsers.isEmpty()){ - for (String username : sharedUsers){ - ProjectUserResource pr = (ProjectUserResource)projectResource. - create(ResourceType.PROJECT_USER); - pr.setUserName(username); - pr.save(); - } - } - }catch (Exception e){ - logger.error("Error while saving project to registry", e); - throw new RegistryException(e); - } - return projectId; - } - - private String getProjectId (String projectName){ - String pro = projectName.replaceAll("\\s", ""); - return pro + "_" + UUID.randomUUID(); - } - - public void updateProject (Project project, String projectId) throws RegistryException{ - try { - ProjectResource existingProject = workerResource.getProject(projectId); - existingProject.setDescription(project.getDescription()); - existingProject.setName(project.getName()); -// existingProject.setGateway(gatewayResource); - UserResource user = (UserResource)ResourceUtils.getUser(project.getOwner()); - if (!gatewayResource.isExists(ResourceType.GATEWAY_WORKER, user.getUserName())){ - workerResource = ResourceUtils.addGatewayWorker(gatewayResource, user); - }else { - workerResource = (WorkerResource)ResourceUtils.getWorker( - gatewayResource.getGatewayName(), user.getUserName()); - } - WorkerResource worker = new WorkerResource(project.getOwner(), gatewayResource.getGatewayId()); - existingProject.setWorker(worker); - existingProject.save(); - ProjectUserResource resource = (ProjectUserResource)existingProject.create( - ResourceType.PROJECT_USER); - resource.setProjectId(projectId); - resource.setUserName(project.getOwner()); - resource.save(); - List<String> sharedGroups = project.getSharedGroups(); - if (sharedGroups != null && !sharedGroups.isEmpty()){ - for (String group : sharedGroups){ - //TODO - add shared groups - logger.info("Groups are not supported at the moment..."); - } - } - - List<String> sharedUsers = project.getSharedUsers(); - if (sharedUsers != null && !sharedUsers.isEmpty()){ - for (String username : sharedUsers){ - ProjectUserResource pr = (ProjectUserResource)existingProject.create( - ResourceType.PROJECT_USER); - pr.setUserName(username); - pr.save(); - } - } - }catch (Exception e){ - logger.error("Error while saving project to registry", e); - throw new RegistryException(e); - } - } - - public Project getProject (String projectId) throws RegistryException{ - try { - ProjectResource project = workerResource.getProject(projectId); - if (project != null){ - return ThriftDataModelConversion.getProject(project); - } - }catch (Exception e){ - logger.error("Error while retrieving project from registry", e); - throw new RegistryException(e); - } - return null; - } - - /** - * Get list of projects of the user - * @param fieldName - * @param value - * @return - * @throws RegistryException - */ - public List<Project> getProjectList (String fieldName, Object value) throws RegistryException{ - return getProjectList(fieldName, value, -1, -1, null, null); - } - - /** - * Get projects list with pagination and result ordering - * @param fieldName - * @param value - * @param limit - * @param offset - * @param orderByIdentifier - * @param resultOrderType - * @return - * @throws RegistryException - */ - public List<Project> getProjectList (String fieldName, Object value, int limit, int offset, - Object orderByIdentifier, ResultOrderType resultOrderType) throws RegistryException{ - List<Project> projects = new ArrayList<Project>(); - try { - if (fieldName.equals(Constants.FieldConstants.ProjectConstants.OWNER)){ - workerResource.setUser((String)value); - List<ProjectResource> projectList = workerResource.getProjects(); - if (projectList != null && !projectList.isEmpty()){ - for (ProjectResource pr : projectList){ - projects.add(ThriftDataModelConversion.getProject(pr)); - } - } - return projects; - } - }catch (Exception e){ - logger.error("Error while retrieving project from registry", e); - throw new RegistryException(e); - } - return projects; - } - - /** - * To search projects of user with the given filter criteria. All the matching results will be sent. - * Results are not ordered in any order - * @param filters - * @return - * @throws RegistryException - */ - public List<Project> searchProjects (Map<String, String> filters) throws RegistryException{ - return searchProjects(filters, -1, -1, null, null); - } - - /** - * To search the projects of user with the given filter criteria and retrieve the results with - * pagination support. Results can be ordered based on an identifier (i.e column) either ASC or - * DESC. - * - * @param filters - * @param limit - * @param offset - * @param orderByIdentifier - * @param resultOrderType - * @return - * @throws RegistryException - */ - public List<Project> searchProjects(Map<String, String> filters, int limit, - int offset, Object orderByIdentifier, ResultOrderType resultOrderType) throws RegistryException { - Map<String, String> fil = new HashMap<String, String>(); - if (filters != null && filters.size() != 0){ - List<Project> projects = new ArrayList<Project>(); - try { - for (String field : filters.keySet()){ - if (field.equals(Constants.FieldConstants.ProjectConstants.PROJECT_NAME)){ - fil.put(AbstractResource.ProjectConstants.PROJECT_NAME, filters.get(field)); - }else if (field.equals(Constants.FieldConstants.ProjectConstants.OWNER)){ - fil.put(AbstractResource.ProjectConstants.USERNAME, filters.get(field)); - }else if (field.equals(Constants.FieldConstants.ProjectConstants.DESCRIPTION)){ - fil.put(AbstractResource.ProjectConstants.DESCRIPTION, filters.get(field)); - }else if (field.equals(Constants.FieldConstants.ProjectConstants.GATEWAY_ID)){ - fil.put(AbstractResource.ProjectConstants.GATEWAY_ID, filters.get(field)); - } - } - List<ProjectResource> projectResources = workerResource - .searchProjects(fil, limit, offset, orderByIdentifier, resultOrderType); - if (projectResources != null && !projectResources.isEmpty()){ - for (ProjectResource pr : projectResources){ - projects.add(ThriftDataModelConversion.getProject(pr)); - } - } - return projects; - }catch (Exception e){ - logger.error("Error while retrieving project from registry", e); - throw new RegistryException(e); - } - } - return null; - } - - public List<String> getProjectIDs (String fieldName, Object value) throws RegistryException{ - List<String> projectIds = new ArrayList<String>(); - try { - if (fieldName.equals(Constants.FieldConstants.ProjectConstants.OWNER)){ - workerResource.setUser((String)value); - List<ProjectResource> projectList = workerResource.getProjects(); - if (projectList != null && !projectList.isEmpty()){ - for (ProjectResource pr : projectList){ - projectIds.add(pr.getName()); - } - } - return projectIds; - } - }catch (Exception e){ - logger.error("Error while retrieving projects from registry", e); - throw new RegistryException(e); - } - return projectIds; - } - - public void removeProject (String projectId) throws RegistryException { - try { - workerResource.removeProject(projectId); - } catch (Exception e) { - logger.error("Error while removing the project..", e); - throw new RegistryException(e); - } - } - - public boolean isProjectExist(String projectId) throws RegistryException { - try { - return workerResource.isProjectExists(projectId); - } catch (Exception e) { - logger.error("Error while retrieving project...", e); - throw new RegistryException(e); - } - } - -} http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/impl/RegistryFactory.java ---------------------------------------------------------------------- diff --git a/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/impl/RegistryFactory.java b/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/impl/RegistryFactory.java deleted file mode 100644 index 80eb09c..0000000 --- a/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/impl/RegistryFactory.java +++ /dev/null @@ -1,80 +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.experiment.catalog.impl; - -import org.apache.airavata.common.exception.ApplicationSettingsException; -import org.apache.airavata.common.utils.ServerSettings; -import org.apache.airavata.registry.cpi.Registry; -import org.apache.airavata.registry.cpi.RegistryException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class RegistryFactory { - private static Registry registry; - private static Logger logger = LoggerFactory.getLogger(RegistryFactory.class); - - public static Registry getRegistry(String gateway, String username, String password) throws RegistryException { - try { - if (registry == null) { - registry = new RegistryImpl(gateway, username, password); - } - } catch (RegistryException e) { - logger.error("Unable to create registry instance", e); - throw new RegistryException(e); - } - return registry; - } - - public static Registry getRegistry(String gateway) throws RegistryException { - try { - if (registry == null) { - registry = new RegistryImpl(gateway, ServerSettings.getDefaultUser(), ServerSettings.getDefaultUserPassword()); - } - } catch (RegistryException e) { - logger.error("Unable to create registry instance", e); - throw new RegistryException(e); - } catch (ApplicationSettingsException e) { - logger.error("Unable to create registry instance", e); - throw new RegistryException(e); - } - return registry; - } - - public static Registry getDefaultRegistry () throws RegistryException { - try { - if (registry == null) { - registry = new RegistryImpl(); - } - } catch (RegistryException e) { - logger.error("Unable to create registry instance", e); - throw new RegistryException(e); - } - return registry; - } - - public static Registry getLoggingRegistry() { - if(registry == null) { - registry = new LoggingRegistryImpl(); - } - return registry; - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/impl/RegistryImpl.java ---------------------------------------------------------------------- diff --git a/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/impl/RegistryImpl.java b/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/impl/RegistryImpl.java deleted file mode 100644 index 3cee954..0000000 --- a/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/impl/RegistryImpl.java +++ /dev/null @@ -1,735 +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.experiment.catalog.impl; - -import org.apache.airavata.common.exception.ApplicationSettingsException; -import org.apache.airavata.common.utils.ServerSettings; -import org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType; -import org.apache.airavata.model.workspace.Gateway; -import org.apache.airavata.model.workspace.Project; -import org.apache.airavata.model.workspace.experiment.*; -import org.apache.airavata.experiment.catalog.ResourceUtils; -import org.apache.airavata.experiment.catalog.resources.GatewayResource; -import org.apache.airavata.experiment.catalog.resources.UserResource; -import org.apache.airavata.registry.cpi.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -public class RegistryImpl implements Registry { - private GatewayResource gatewayResource; - private UserResource user; - private final static Logger logger = LoggerFactory.getLogger(RegistryImpl.class); - private ExperimentRegistry experimentRegistry = null; - private ProjectRegistry projectRegistry = null; - private GatewayRegistry gatewayRegistry = null; - - public RegistryImpl() throws RegistryException{ - try { - if (!ResourceUtils.isGatewayExist(ServerSettings.getDefaultUserGateway())){ - gatewayResource = (GatewayResource) ResourceUtils.createGateway(ServerSettings.getDefaultUserGateway()); - gatewayResource.setGatewayName(ServerSettings.getDefaultUserGateway()); - gatewayResource.save(); - }else { - gatewayResource = (GatewayResource)ResourceUtils.getGateway(ServerSettings.getDefaultUserGateway()); - } - - if (!ResourceUtils.isUserExist(ServerSettings.getDefaultUser())){ - user = ResourceUtils.createUser(ServerSettings.getDefaultUser(), ServerSettings.getDefaultUserPassword()); - user.save(); - }else { - user = (UserResource)ResourceUtils.getUser(ServerSettings.getDefaultUser()); - } - experimentRegistry = new ExperimentRegistry(gatewayResource, user); - projectRegistry = new ProjectRegistry(gatewayResource, user); - gatewayRegistry = new GatewayRegistry(); - } catch (ApplicationSettingsException e) { - logger.error("Unable to read airavata server properties..", e); - throw new RegistryException("Unable to read airavata server properties..", e); - } - } - - public RegistryImpl(String gateway, String username, String password) throws RegistryException{ - if (!ResourceUtils.isGatewayExist(gateway)){ - gatewayResource = (GatewayResource) ResourceUtils.createGateway(gateway); - gatewayResource.save(); - }else { - gatewayResource = (GatewayResource)ResourceUtils.getGateway(gateway); - } - - if (!ResourceUtils.isUserExist(username)){ - user = ResourceUtils.createUser(username, password); - user.save(); - }else { - user = (UserResource)ResourceUtils.getUser(username); - } - experimentRegistry = new ExperimentRegistry(gatewayResource, user); - projectRegistry = new ProjectRegistry(gatewayResource, user); - } - - /** - * This method is to add an object in to the registry - * - * @param dataType Data type is a predefined type which the programmer should choose according to the object he - * is going to save in to registry - * @param newObjectToAdd Object which contains the fields that need to be saved in to registry. This object is a - * thrift model object. In experiment case this object can be BasicMetadata, ConfigurationData - * etc - * @return return the identifier to identify the object - */ - @Override - public Object add(ParentDataType dataType, Object newObjectToAdd, String gatewayId) throws RegistryException { - try { - switch (dataType) { - case PROJECT: - return projectRegistry.addProject((Project)newObjectToAdd, gatewayId); - case EXPERIMENT: - return experimentRegistry.addExperiment((Experiment) newObjectToAdd, gatewayId); - case GATEWAY: - return gatewayRegistry.addGateway((Gateway)newObjectToAdd); - default: - logger.error("Unsupported top level type..", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - } catch (Exception e) { - logger.error("Error while adding the resource " + dataType.toString(), new RegistryException(e)); - throw new RegistryException("Error while adding the resource " + dataType.toString(), e); - } - } - - /** - * This method is to add an object in to the registry - * - * @param dataType Data type is a predefined type which the programmer should choose according to the object he - * is going to save in to registry - * @param newObjectToAdd Object which contains the fields that need to be saved in to registry. This object is a - * thrift model object. In experiment case this object can be BasicMetadata, ConfigurationData - * etc - * @param dependentIdentifier Object which contains the identifier if the object that is going to add is not a top - * level object in the data model. If it is a top level object, programmer can pass it as - * null - */ - @Override - public Object add(ChildDataType dataType, Object newObjectToAdd, Object dependentIdentifier) throws RegistryException { - try { - switch (dataType) { - case EXPERIMENT_CONFIGURATION_DATA: - return experimentRegistry.addUserConfigData((UserConfigurationData) newObjectToAdd, (String) dependentIdentifier); - case EXPERIMENT_OUTPUT: - return experimentRegistry.addExpOutputs((List<OutputDataObjectType>) newObjectToAdd, (String) dependentIdentifier); - case EXPERIMENT_STATUS: - return experimentRegistry.updateExperimentStatus((ExperimentStatus) newObjectToAdd, (String) dependentIdentifier); - case WORKFLOW_NODE_DETAIL: - return experimentRegistry.addWorkflowNodeDetails((WorkflowNodeDetails) newObjectToAdd, (String) dependentIdentifier); - case WORKFLOW_NODE_STATUS: - return experimentRegistry.addWorkflowNodeStatus((WorkflowNodeStatus) newObjectToAdd, (CompositeIdentifier) dependentIdentifier); - case NODE_OUTPUT: - return experimentRegistry.addNodeOutputs((List<OutputDataObjectType>) newObjectToAdd, (CompositeIdentifier) dependentIdentifier); - case TASK_DETAIL: - return experimentRegistry.addTaskDetails((TaskDetails) newObjectToAdd, (String) dependentIdentifier); - case APPLICATION_OUTPUT: - return experimentRegistry.addApplicationOutputs((List<OutputDataObjectType>) newObjectToAdd, (CompositeIdentifier) dependentIdentifier); - case TASK_STATUS: - return experimentRegistry.addTaskStatus((TaskStatus) newObjectToAdd, (CompositeIdentifier) dependentIdentifier); - case JOB_DETAIL: - return experimentRegistry.addJobDetails((JobDetails) newObjectToAdd, (CompositeIdentifier) dependentIdentifier); - case JOB_STATUS: - return experimentRegistry.addJobStatus((JobStatus) newObjectToAdd, (CompositeIdentifier) dependentIdentifier); - case APPLICATION_STATUS: - return experimentRegistry.addApplicationStatus((ApplicationStatus) newObjectToAdd, (CompositeIdentifier) dependentIdentifier); - case DATA_TRANSFER_DETAIL: - return experimentRegistry.addDataTransferDetails((DataTransferDetails) newObjectToAdd, (String) dependentIdentifier); - case TRANSFER_STATUS: - return experimentRegistry.addTransferStatus((TransferStatus) newObjectToAdd, (CompositeIdentifier) dependentIdentifier); - case COMPUTATIONAL_RESOURCE_SCHEDULING: - return experimentRegistry.addComputationalResourceScheduling((ComputationalResourceScheduling) newObjectToAdd, (CompositeIdentifier) dependentIdentifier); - case ADVANCE_OUTPUT_DATA_HANDLING: - return experimentRegistry.addOutputDataHandling((AdvancedOutputDataHandling) newObjectToAdd, (CompositeIdentifier) dependentIdentifier); - case ADVANCE_INPUT_DATA_HANDLING: - return experimentRegistry.addInputDataHandling((AdvancedInputDataHandling) newObjectToAdd, (CompositeIdentifier) dependentIdentifier); - case QOS_PARAM: - return experimentRegistry.addQosParams((QualityOfServiceParams) newObjectToAdd, (CompositeIdentifier) dependentIdentifier); - case ERROR_DETAIL: - return experimentRegistry.addErrorDetails((ErrorDetails) newObjectToAdd, dependentIdentifier); - default: - logger.error("Unsupported dependent data type...", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - } catch (Exception e) { - logger.error("Error while adding " + dataType.toString() , new RegistryException(e)); - throw new RegistryException("Error while adding " + dataType.toString(), e); - } - - } - - /** - * This method is to update the whole object in registry - * - * @param dataType Data type is a predefined type which the programmer should choose according to the object he - * is going to save in to registry - * @param newObjectToUpdate Object which contains the fields that need to be updated in to registry. This object is a - * thrift model object. In experiment case this object can be BasicMetadata, ConfigurationData - * etc. CPI programmer can only fill necessary fields that need to be updated. He does not - * have to fill the whole object. He needs to only fill the mandatory fields and whatever the - * other fields that need to be updated. - */ - @Override - public void update(RegistryModelType dataType, Object newObjectToUpdate, Object identifier) throws RegistryException { - try { - switch (dataType) { - case PROJECT: - projectRegistry.updateProject((Project)newObjectToUpdate, (String)identifier); - break; - case GATEWAY: - gatewayRegistry.updateGateway((String)identifier, (Gateway)newObjectToUpdate); - break; - case EXPERIMENT: - experimentRegistry.updateExperiment((Experiment) newObjectToUpdate, (String) identifier); - break; - case EXPERIMENT_CONFIGURATION_DATA: - experimentRegistry.updateUserConfigData((UserConfigurationData) newObjectToUpdate, (String) identifier); - break; - case EXPERIMENT_OUTPUT: - experimentRegistry.updateExpOutputs((List<OutputDataObjectType>) newObjectToUpdate, (String) identifier); - break; - case EXPERIMENT_STATUS: - experimentRegistry.updateExperimentStatus((ExperimentStatus) newObjectToUpdate, (String) identifier); - break; - case WORKFLOW_NODE_DETAIL: - experimentRegistry.updateWorkflowNodeDetails((WorkflowNodeDetails) newObjectToUpdate, (String) identifier); - break; - case WORKFLOW_NODE_STATUS: - experimentRegistry.updateWorkflowNodeStatus((WorkflowNodeStatus) newObjectToUpdate, (String) identifier); - break; - case NODE_OUTPUT: - experimentRegistry.updateNodeOutputs((List<OutputDataObjectType>) newObjectToUpdate, (String) identifier); - break; - case TASK_DETAIL: - experimentRegistry.updateTaskDetails((TaskDetails) newObjectToUpdate, (String) identifier); - break; - case APPLICATION_OUTPUT: - experimentRegistry.updateAppOutputs((List<OutputDataObjectType>) newObjectToUpdate, (String) identifier); - break; - case TASK_STATUS: - experimentRegistry.updateTaskStatus((TaskStatus) newObjectToUpdate, (String) identifier); - break; - case JOB_DETAIL: - experimentRegistry.updateJobDetails((JobDetails) newObjectToUpdate, (CompositeIdentifier) identifier); - break; - case JOB_STATUS: - experimentRegistry.updateJobStatus((JobStatus) newObjectToUpdate, (CompositeIdentifier) identifier); - break; - case APPLICATION_STATUS: - experimentRegistry.updateApplicationStatus((ApplicationStatus) newObjectToUpdate, (String) identifier); - break; - case DATA_TRANSFER_DETAIL: - experimentRegistry.updateDataTransferDetails((DataTransferDetails) newObjectToUpdate, (String) identifier); - break; - case TRANSFER_STATUS: - experimentRegistry.updateTransferStatus((TransferStatus) newObjectToUpdate, (String) identifier); - break; - case COMPUTATIONAL_RESOURCE_SCHEDULING: - experimentRegistry.updateScheduling((ComputationalResourceScheduling) newObjectToUpdate, (String) identifier, dataType.toString()); - break; - case ADVANCE_INPUT_DATA_HANDLING: - experimentRegistry.updateInputDataHandling((AdvancedInputDataHandling) newObjectToUpdate, (String) identifier, dataType.toString()); - break; - case ADVANCE_OUTPUT_DATA_HANDLING: - experimentRegistry.updateOutputDataHandling((AdvancedOutputDataHandling) newObjectToUpdate, (String) identifier, dataType.toString()); - break; - case QOS_PARAM: - experimentRegistry.updateQOSParams((QualityOfServiceParams) newObjectToUpdate, (String) identifier, dataType.toString()); - break; - default: - logger.error("Unsupported data type...", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - } catch (Exception e) { - logger.error("Error while updating the resource " + dataType.toString(), new RegistryException(e)); - throw new RegistryException("Error while updating the resource.." + dataType.toString(), e); - } - - } - - /** - * This method is to update a specific field of the data model - * - * @param dataType Data type is a predefined type which the programmer should choose according to the object he - * is going to save in to registry - * @param identifier Identifier which will uniquely identify the data model. For example, in Experiment_Basic_Type, - * identifier will be generated experimentID - * @param fieldName Field which need to be updated in the registry. In Experiment_Basic_Type, if you want to update the - * description, field will be "description". Field names are defined in - * org.apache.airavata.registry.cpi.utils.Constants - * @param value Value by which the given field need to be updated. If the field is "description", that field will be - * updated by given value - */ - @Override - public void update(RegistryModelType dataType, Object identifier, String fieldName, Object value) throws RegistryException { - try { - switch (dataType) { - case EXPERIMENT: - experimentRegistry.updateExperimentField((String) identifier, fieldName, value); - break; - case EXPERIMENT_CONFIGURATION_DATA: - experimentRegistry.updateExpConfigDataField((String) identifier, fieldName, value); - break; - default: - logger.error("Unsupported data type...", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - } catch (Exception e) { - logger.error("Error while updating the resource " + dataType.toString(), new RegistryException(e)); - throw new RegistryException("Error while updating the resource " + dataType.toString(), e); - } - - } - - /** - * This method is to retrieve object according to the identifier. In the experiment basic data type, if you give the - * experiment id, this method will return the BasicMetadata object - * - * @param dataType Data type is a predefined type which the programmer should choose according to the object he - * is going to save in to registry - * @param identifier Identifier which will uniquely identify the data model. For example, in Experiment_Basic_Type, - * identifier will be generated experimentID - * @return object according to the given identifier. - */ - @Override - public Object get(RegistryModelType dataType, Object identifier) throws RegistryException { - try { - switch (dataType) { - case PROJECT: - return projectRegistry.getProject((String)identifier); - case GATEWAY: - return gatewayRegistry.getGateway((String)identifier); - case EXPERIMENT: - return experimentRegistry.getExperiment((String) identifier, null); - case EXPERIMENT_CONFIGURATION_DATA: - return experimentRegistry.getConfigData((String) identifier, null); - case EXPERIMENT_OUTPUT: - return experimentRegistry.getExperimentOutputs((String) identifier); - case EXPERIMENT_STATUS: - return experimentRegistry.getExperimentStatus((String) identifier); - case WORKFLOW_NODE_DETAIL: - return experimentRegistry.getWorkflowNodeDetails((String) identifier); - case WORKFLOW_NODE_STATUS: - return experimentRegistry.getWorkflowNodeStatus((String) identifier); - case NODE_OUTPUT: - return experimentRegistry.getNodeOutputs((String) identifier); - case TASK_DETAIL: - return experimentRegistry.getTaskDetails((String) identifier); - case APPLICATION_OUTPUT: - return experimentRegistry.getApplicationOutputs((String) identifier); - case TASK_STATUS: - return experimentRegistry.getTaskStatus((String) identifier); - case JOB_DETAIL: - return experimentRegistry.getJobDetails((CompositeIdentifier) identifier); - case JOB_STATUS: - return experimentRegistry.getJobStatus((CompositeIdentifier) identifier); - case APPLICATION_STATUS: - return experimentRegistry.getApplicationStatus((CompositeIdentifier) identifier); - case DATA_TRANSFER_DETAIL: - return experimentRegistry.getDataTransferDetails((String) identifier); - case TRANSFER_STATUS: - return experimentRegistry.getDataTransferStatus((String) identifier); - case COMPUTATIONAL_RESOURCE_SCHEDULING: - return experimentRegistry.getComputationalScheduling(dataType, (String) identifier); - case ADVANCE_INPUT_DATA_HANDLING: - return experimentRegistry.getInputDataHandling(dataType, (String) identifier); - case ADVANCE_OUTPUT_DATA_HANDLING: - return experimentRegistry.getOutputDataHandling(dataType, (String) identifier); - case QOS_PARAM: - return experimentRegistry.getQosParams(dataType, (String) identifier); - default: - logger.error("Unsupported data type...", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - } catch (Exception e) { - logger.error("Error while retrieving the resource " + dataType.toString(), new RegistryException(e)); - throw new RegistryException("Error while retrieving the resource " + dataType.toString() , e); - } - } - - /** - * This method is to retrieve list of objects according to a given criteria - * - * @param dataType Data type is a predefined type which the programmer should choose according to the object he - * is going to save in to registry - * @param fieldName FieldName is the field that filtering should be done. For example, if we want to retrieve all - * the experiments for a given user, filterBy will be "userName" - * @param value value for the filtering field. In the experiment case, value for "userName" can be "admin" - * @return List of objects according to the given criteria - */ - @Override - public List<Object> get(RegistryModelType dataType, String fieldName, Object value) throws RegistryException { - try { - List<Object> result = new ArrayList<Object>(); - switch (dataType) { - case PROJECT: - List<Project> projectList = projectRegistry.getProjectList(fieldName, value); - for (Project project : projectList ){ - result.add(project); - } - return result; - case GATEWAY: - List<Gateway> allGateways = gatewayRegistry.getAllGateways(); - for (Gateway gateway : allGateways){ - result.add(gateway); - } - return result; - case EXPERIMENT: - List<Experiment> experimentList = experimentRegistry.getExperimentList(fieldName, value); - for (Experiment experiment : experimentList) { - result.add(experiment); - } - return result; - case WORKFLOW_NODE_DETAIL: - List<WorkflowNodeDetails> wfNodeDetails = experimentRegistry.getWFNodeDetails(fieldName, value); - for (WorkflowNodeDetails wf : wfNodeDetails) { - result.add(wf); - } - return result; - case WORKFLOW_NODE_STATUS: - List<WorkflowNodeStatus> wfNodeStatusList = experimentRegistry.getWFNodeStatusList(fieldName, value); - for (WorkflowNodeStatus wfs : wfNodeStatusList) { - result.add(wfs); - } - return result; - case TASK_DETAIL: - List<TaskDetails> taskDetails = experimentRegistry.getTaskDetails(fieldName, value); - for (TaskDetails task : taskDetails) { - result.add(task); - } - return result; - case JOB_DETAIL: - List<JobDetails> jobDetails = experimentRegistry.getJobDetails(fieldName, value); - for (JobDetails job : jobDetails) { - result.add(job); - } - return result; - case DATA_TRANSFER_DETAIL: - List<DataTransferDetails> dataTransferDetails = experimentRegistry.getDataTransferDetails(fieldName, value); - for (DataTransferDetails transferDetails : dataTransferDetails) { - result.add(transferDetails); - } - return result; - case ERROR_DETAIL: - List<ErrorDetails> errorDetails = experimentRegistry.getErrorDetails(fieldName, value); - for (ErrorDetails error : errorDetails) { - result.add(error); - } - return result; - default: - logger.error("Unsupported data type...", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - } catch (Exception e) { - logger.error("Error while retrieving the resource " + dataType.toString(), new RegistryException(e)); - throw new RegistryException("Error while retrieving the resource " + dataType.toString(), e); - } - - } - - /** - * This method is to retrieve list of objects according to a given criteria with pagination and ordering - * - * @param dataType Data type is a predefined type which the programmer should choose according to the object he - * is going to save in to registry - * @param fieldName FieldName is the field that filtering should be done. For example, if we want to retrieve all - * the experiments for a given user, filterBy will be "userName" - * @param value value for the filtering field. In the experiment case, value for "userName" can be "admin" - * @param limit Size of the results to be returned - * @param offset Start position of the results to be retrieved - * @param orderByIdentifier Named of the column in which the ordering is based - * @param resultOrderType Type of ordering i.e ASC or DESC - * @return - * @throws RegistryException - */ - @Override - public List<Object> get(RegistryModelType dataType, String fieldName, Object value, int limit, - int offset, Object orderByIdentifier, ResultOrderType resultOrderType) throws RegistryException { - try { - List<Object> result = new ArrayList<Object>(); - switch (dataType) { - case PROJECT: - List<Project> projectList = projectRegistry - .getProjectList(fieldName, value, limit, offset, orderByIdentifier, resultOrderType); - for (Project project : projectList ){ - result.add(project); - } - return result; - case EXPERIMENT: - List<Experiment> experimentList = experimentRegistry.getExperimentList(fieldName, value, - limit, offset, orderByIdentifier, resultOrderType); - for (Experiment experiment : experimentList) { - result.add(experiment); - } - return result; - default: - logger.error("Unsupported data type...", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - } catch (Exception e) { - logger.error("Error while retrieving the resource " + dataType.toString(), new RegistryException(e)); - throw new RegistryException("Error while retrieving the resource " + dataType.toString(), e); - } - } - - /** - * This method is to retrieve list of objects according to a given criteria - * @param dataType Data type is a predefined type which the programmer should choose according to the object he - * is going to save in to registry - * @param filters filters is a map of field name and value that you need to use for search filtration - * @return List of objects according to the given criteria - */ - @Override - public List<Object> search(RegistryModelType dataType, Map<String, String> filters) throws RegistryException { - return search(dataType, filters, -1, -1, null, null); - } - - /** - * This method is to retrieve list of objects with pagination according to a given criteria sorted - * according by the specified identified and specified ordering (i.e either ASC or DESC) - * @param dataType Data type is a predefined type which the programmer should choose according to the object he - * is going to save in to registry - * @param filters filters is a map of field name and value that you need to use for search filtration - * @param limit amount of the results to be returned - * @param offset offset of the results from the sorted list to be fetched from - * @param orderByIdentifier identifier (i.e the column) which will be used as the basis to sort the results - * @param resultOrderType The type of ordering (i.e ASC or DESC) that has to be used when retrieving the results - * @return List of objects according to the given criteria - */ - @Override - public List<Object> search(RegistryModelType dataType, Map<String, String> filters, int limit, - int offset, Object orderByIdentifier, ResultOrderType resultOrderType) throws RegistryException { - try { - List<Object> result = new ArrayList<Object>(); - switch (dataType) { - case PROJECT: - List<Project> projectList - = projectRegistry.searchProjects(filters, limit, offset, - orderByIdentifier, resultOrderType); - for (Project project : projectList ){ - result.add(project); - } - return result; - case EXPERIMENT: - List<ExperimentSummary> experimentSummaries = experimentRegistry - .searchExperiments(filters, limit, offset, orderByIdentifier, - resultOrderType); - for (ExperimentSummary ex : experimentSummaries){ - result.add(ex); - } - return result; - default: - logger.error("Unsupported data type...", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - } catch (Exception e) { - logger.error("Error while retrieving the resource " + dataType.toString(), new RegistryException(e)); - throw new RegistryException("Error while retrieving the resource " + dataType.toString(), e); - } - } - - /** - * This method is to retrieve a specific value for a given field. - * - * @param dataType Data type is a predefined type which the programmer should choose according to the object he - * is going to save in to registry - * @param identifier Identifier which will uniquely identify the data model. For example, in Experiment_Basic_Type, - * identifier will be generated experimentID - * @param field field that filtering should be done. For example, if we want to execution user for a given - * experiment, field will be "userName" - * @return return the value for the specific field where data model is identified by the unique identifier that has - * given - */ - @Override - public Object getValue(RegistryModelType dataType, Object identifier, String field) throws RegistryException { - try { - switch (dataType) { - case EXPERIMENT: - return experimentRegistry.getExperiment((String) identifier, field); - case EXPERIMENT_CONFIGURATION_DATA: - return experimentRegistry.getConfigData((String) identifier, field); - default: - logger.error("Unsupported data type...", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - } catch (Exception e) { - logger.error("Error while retrieving the resource " + dataType.toString(), new RegistryException(e)); - throw new RegistryException("Error while retrieving the resource " + dataType.toString(), e); - } - - } - - /** - * This method is to retrieve all the identifiers according to given filtering criteria. For an example, if you want - * to get all the experiment ids for a given gateway, your field name will be "gateway" and the value will be the - * name of the gateway ("default"). Similar manner you can retrieve all the experiment ids for a given user. - * - * @param dataType Data type is a predefined type which the programmer should choose according to the object he - * is going to save in to registry - * @param fieldName FieldName is the field that filtering should be done. For example, if we want to retrieve all - * the experiments for a given user, filterBy will be "userName" - * @param value value for the filtering field. In the experiment case, value for "userName" can be "admin" - * @return id list according to the filtering criteria - */ - @Override - public List<String> getIds(RegistryModelType dataType, String fieldName, Object value) throws RegistryException { - try { - switch (dataType) { - case PROJECT: - return projectRegistry.getProjectIDs(fieldName, value); - case EXPERIMENT: - return experimentRegistry.getExperimentIDs(fieldName, value); - case EXPERIMENT_CONFIGURATION_DATA: - return experimentRegistry.getExperimentIDs(fieldName, value); - case WORKFLOW_NODE_DETAIL: - return experimentRegistry.getWorkflowNodeIds(fieldName, value); - case TASK_DETAIL: - return experimentRegistry.getTaskDetailIds(fieldName, value); - case JOB_DETAIL: - return experimentRegistry.getJobDetailIds(fieldName, value); - case DATA_TRANSFER_DETAIL: - return experimentRegistry.getTransferDetailIds(fieldName, value); - default: - logger.error("Unsupported data type...", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - } catch (Exception e) { - logger.error("Error while retrieving the ids for" + dataType.toString(), new RegistryException(e)); - throw new RegistryException("Error while retrieving the ids for " + dataType.toString(), e); - } - - } - - /** - * This method is to remove a item from the registry - * - * @param dataType Data type is a predefined type which the programmer should choose according to the object he - * is going to save in to registry - * @param identifier Identifier which will uniquely identify the data model. For example, in Experiment_Basic_Type, - * identifier will be generated experimentID - */ - @Override - public void remove(RegistryModelType dataType, Object identifier) throws RegistryException { - try { - switch (dataType) { - case PROJECT: - projectRegistry.removeProject((String)identifier); - break; - case GATEWAY: - gatewayRegistry.removeGateway((String)identifier); - break; - case EXPERIMENT: - experimentRegistry.removeExperiment((String) identifier); - break; - case EXPERIMENT_CONFIGURATION_DATA: - experimentRegistry.removeExperimentConfigData((String) identifier); - break; - case WORKFLOW_NODE_DETAIL: - experimentRegistry.removeWorkflowNode((String) identifier); - break; - case TASK_DETAIL: - experimentRegistry.removeTaskDetails((String) identifier); - break; - case JOB_DETAIL: - experimentRegistry.removeJobDetails((CompositeIdentifier) identifier); - break; - case DATA_TRANSFER_DETAIL: - experimentRegistry.removeDataTransferDetails((String) identifier); - break; - case COMPUTATIONAL_RESOURCE_SCHEDULING: - experimentRegistry.removeComputationalScheduling(dataType, (String) identifier); - break; - case ADVANCE_OUTPUT_DATA_HANDLING: - experimentRegistry.removeOutputDataHandling(dataType, (String) identifier); - break; - case ADVANCE_INPUT_DATA_HANDLING: - experimentRegistry.removeInputDataHandling(dataType, (String) identifier); - break; - case QOS_PARAM: - experimentRegistry.removeQOSParams(dataType, (String) identifier); - break; - default: - logger.error("Unsupported data type...", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - } catch (Exception e) { - logger.error("Error while removing the resource " + dataType.toString(), new RegistryException(e)); - throw new RegistryException("Error while removing the resource " + dataType.toString(), e); - } - - } - - /** - * This method will check whether a given data type which can be identified with the identifier exists or not - * - * @param dataType Data type is a predefined type which the programmer should choose according to the object he - * is going to save in to registry - * @param identifier Identifier which will uniquely identify the data model. For example, in Experiment_Basic_Type, - * identifier will be generated experimentID - * @return whether the given data type exists or not - */ - @Override - public boolean isExist(RegistryModelType dataType, Object identifier) throws RegistryException { - try { - switch (dataType) { - case PROJECT: - return projectRegistry.isProjectExist((String)identifier); - case GATEWAY: - return gatewayRegistry.isGatewayExist((String)identifier); - case EXPERIMENT: - return experimentRegistry.isExperimentExist((String) identifier); - case EXPERIMENT_CONFIGURATION_DATA: - return experimentRegistry.isExperimentConfigDataExist((String) identifier); - case WORKFLOW_NODE_DETAIL: - return experimentRegistry.isWFNodeExist((String) identifier); - case TASK_DETAIL: - return experimentRegistry.isTaskDetailExist((String) identifier); - case JOB_DETAIL: - return experimentRegistry.isJobDetailExist((CompositeIdentifier) identifier); - case DATA_TRANSFER_DETAIL: - return experimentRegistry.isTransferDetailExist((String) identifier); - case COMPUTATIONAL_RESOURCE_SCHEDULING: - return experimentRegistry.isComputationalSchedulingExist(dataType, (String) identifier); - case ADVANCE_INPUT_DATA_HANDLING: - return experimentRegistry.isInputDataHandlingExist(dataType, (String) identifier); - case ADVANCE_OUTPUT_DATA_HANDLING: - return experimentRegistry.isOutputDataHandlingExist(dataType, (String) identifier); - case QOS_PARAM: - return experimentRegistry.isQOSParamsExist(dataType, (String) identifier); - default: - logger.error("Unsupported data type...", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - } catch (Exception e) { - logger.error("Error while checking existence of the resource " + dataType.toString(), new RegistryException(e)); - throw new RegistryException("Error while checking existence of the resource " + dataType.toString(), e); - } - } - -} http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/impl/UserReg.java ---------------------------------------------------------------------- diff --git a/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/impl/UserReg.java b/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/impl/UserReg.java deleted file mode 100644 index 67166e2..0000000 --- a/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/impl/UserReg.java +++ /dev/null @@ -1,41 +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.experiment.catalog.impl; - -import org.apache.airavata.common.exception.ApplicationSettingsException; -import org.apache.airavata.common.utils.ServerSettings; -import org.apache.airavata.experiment.catalog.ResourceUtils; -import org.apache.airavata.experiment.catalog.resources.WorkerResource; -import org.apache.airavata.registry.cpi.RegistryException; - -public class UserReg { - public WorkerResource getSystemUser() throws ApplicationSettingsException, RegistryException { - return (WorkerResource)ResourceUtils.getWorker(ServerSettings.getDefaultUserGateway(), ServerSettings.getDefaultUser()); - } - - public WorkerResource getExistingUser (String gatewayName, String userName) throws RegistryException { - return (WorkerResource)ResourceUtils.getWorker(gatewayName, userName); - } - - - -} http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/model/AdvancedInputDataHandling.java ---------------------------------------------------------------------- diff --git a/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/model/AdvancedInputDataHandling.java b/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/model/AdvancedInputDataHandling.java deleted file mode 100644 index 87fb256..0000000 --- a/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/model/AdvancedInputDataHandling.java +++ /dev/null @@ -1,113 +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.experiment.catalog.model; - -import org.apache.openjpa.persistence.DataCache; - -import javax.persistence.*; -import java.io.Serializable; - -@DataCache -@Entity -@Table(name = "ADVANCE_INPUT_DATA_HANDLING") -public class AdvancedInputDataHandling implements Serializable { - @Id - @GeneratedValue - @Column(name = "INPUT_DATA_HANDLING_ID") - private int dataHandlingId; - @Column(name = "EXPERIMENT_ID") - private String expId; - @Column(name = "TASK_ID") - private String taskId; - @Column(name = "WORKING_DIR_PARENT") - private String parentWorkingDir; - @Column(name = "UNIQUE_WORKING_DIR") - private String workingDir; - @Column(name = "STAGE_INPUT_FILES_TO_WORKING_DIR") - private boolean stageInputsToWorkingDir; - @Column(name = "CLEAN_AFTER_JOB") - private boolean cleanAfterJob; - - @ManyToOne(cascade= CascadeType.MERGE) - @JoinColumn(name = "EXPERIMENT_ID") - private Experiment experiment; - - @ManyToOne(cascade= CascadeType.MERGE) - @JoinColumn(name = "TASK_ID") - private TaskDetail task; - - public int getDataHandlingId() { - return dataHandlingId; - } - - public void setDataHandlingId(int dataHandlingId) { - this.dataHandlingId = dataHandlingId; - } - - public String getExpId() { - return expId; - } - - public void setExpId(String expId) { - this.expId = expId; - } - - public String getTaskId() { - return taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getParentWorkingDir() { - return parentWorkingDir; - } - - public void setParentWorkingDir(String parentWorkingDir) { - this.parentWorkingDir = parentWorkingDir; - } - - public String getWorkingDir() { - return workingDir; - } - - public void setWorkingDir(String workingDir) { - this.workingDir = workingDir; - } - - public boolean isStageInputsToWorkingDir() { - return stageInputsToWorkingDir; - } - - public void setStageInputsToWorkingDir(boolean stageInputsToWorkingDir) { - this.stageInputsToWorkingDir = stageInputsToWorkingDir; - } - - public boolean isCleanAfterJob() { - return cleanAfterJob; - } - - public void setCleanAfterJob(boolean cleanAfterJob) { - this.cleanAfterJob = cleanAfterJob; - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/model/AdvancedOutputDataHandling.java ---------------------------------------------------------------------- diff --git a/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/model/AdvancedOutputDataHandling.java b/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/model/AdvancedOutputDataHandling.java deleted file mode 100644 index e3a35b4..0000000 --- a/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/model/AdvancedOutputDataHandling.java +++ /dev/null @@ -1,104 +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.experiment.catalog.model; - -import org.apache.openjpa.persistence.DataCache; - -import javax.persistence.*; -import java.io.Serializable; - -@DataCache -@Entity -@Table(name = "ADVANCE_OUTPUT_DATA_HANDLING") -public class AdvancedOutputDataHandling implements Serializable { - @Id - @GeneratedValue - @Column(name = "OUTPUT_DATA_HANDLING_ID") - private int outputDataHandlingId; - @Column(name = "EXPERIMENT_ID") - private String expId; - @Column(name = "TASK_ID") - private String taskId; - @Column(name = "OUTPUT_DATA_DIR") - private String outputDataDir; - @Column(name = "DATA_REG_URL") - private String dataRegUrl; - @Column(name = "PERSIST_OUTPUT_DATA") - private boolean persistOutputData; - - @ManyToOne(cascade= CascadeType.MERGE) - @JoinColumn(name = "EXPERIMENT_ID") - private Experiment experiment; - - @ManyToOne(cascade= CascadeType.MERGE) - @JoinColumn(name = "TASK_ID") - private TaskDetail task; - - public int getOutputDataHandlingId() { - return outputDataHandlingId; - } - - public void setOutputDataHandlingId(int outputDataHandlingId) { - this.outputDataHandlingId = outputDataHandlingId; - } - - public String getExpId() { - return expId; - } - - public void setExpId(String expId) { - this.expId = expId; - } - - public String getTaskId() { - return taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getOutputDataDir() { - return outputDataDir; - } - - public void setOutputDataDir(String outputDataDir) { - this.outputDataDir = outputDataDir; - } - - public String getDataRegUrl() { - return dataRegUrl; - } - - public void setDataRegUrl(String dataRegUrl) { - this.dataRegUrl = dataRegUrl; - } - - public boolean isPersistOutputData() { - return persistOutputData; - } - - public void setPersistOutputData(boolean persistOutputData) { - this.persistOutputData = persistOutputData; - } - -} http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/model/ApplicationInput.java ---------------------------------------------------------------------- diff --git a/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/model/ApplicationInput.java b/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/model/ApplicationInput.java deleted file mode 100644 index 89cdf76..0000000 --- a/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/model/ApplicationInput.java +++ /dev/null @@ -1,165 +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.experiment.catalog.model; - -import org.apache.openjpa.persistence.DataCache; - -import javax.persistence.*; -import java.io.Serializable; - -@DataCache -@Entity -@Table(name = "APPLICATION_INPUT") -@IdClass(ApplicationInput_PK.class) -public class ApplicationInput implements Serializable { - @Id - @Column(name = "TASK_ID") - private String taskId; - @Id - @Column(name = "INPUT_KEY") - private String inputKey; - @Column(name = "DATA_TYPE") - private String dataType; - @Column(name = "METADATA") - private String metadata; - @Lob - @Column(name = "VALUE") - private char[] value; - @Column(name = "APP_ARGUMENT") - private String appArgument; - - @Column(name = "INPUT_ORDER") - private int inputOrder; - - @Column(name = "STANDARD_INPUT") - private boolean standardInput; - - @Column(name = "USER_FRIENDLY_DESC") - private String userFriendlyDesc; - - @Column(name="IS_REQUIRED") - private boolean isRequired; - @Column(name="REQUIRED_TO_COMMANDLINE") - private boolean requiredToCMD; - @Column(name = "DATA_STAGED") - private boolean dataStaged; - - @ManyToOne(cascade= CascadeType.MERGE) - @JoinColumn(name = "TASK_ID") - private TaskDetail task; - - public int getInputOrder() { - return inputOrder; - } - - public void setInputOrder(int inputOrder) { - this.inputOrder = inputOrder; - } - - public String getTaskId() { - return taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getInputKey() { - return inputKey; - } - - public void setInputKey(String inputKey) { - this.inputKey = inputKey; - } - - public String getDataType() { - return dataType; - } - - public void setDataType(String dataType) { - this.dataType = dataType; - } - - public String getMetadata() { - return metadata; - } - - public void setMetadata(String metadata) { - this.metadata = metadata; - } - - public char[] getValue() { - return value; - } - - public void setValue(char[] value) { - this.value = value; - } - - public String getAppArgument() { - return appArgument; - } - - public void setAppArgument(String appArgument) { - this.appArgument = appArgument; - } - - public boolean isStandardInput() { - return standardInput; - } - - public void setStandardInput(boolean standardInput) { - this.standardInput = standardInput; - } - - public String getUserFriendlyDesc() { - return userFriendlyDesc; - } - - public void setUserFriendlyDesc(String userFriendlyDesc) { - this.userFriendlyDesc = userFriendlyDesc; - } - - public boolean isRequired() { - return isRequired; - } - - public void setRequired(boolean isRequired) { - this.isRequired = isRequired; - } - - public boolean isRequiredToCMD() { - return requiredToCMD; - } - - public void setRequiredToCMD(boolean requiredToCMD) { - this.requiredToCMD = requiredToCMD; - } - - public boolean isDataStaged() { - return dataStaged; - } - - public void setDataStaged(boolean dataStaged) { - this.dataStaged = dataStaged; - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/model/ApplicationInput_PK.java ---------------------------------------------------------------------- diff --git a/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/model/ApplicationInput_PK.java b/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/model/ApplicationInput_PK.java deleted file mode 100644 index 84979b4..0000000 --- a/modules/registry/experiment-catalog/src/main/java/org/apache/airavata/experiment/catalog/model/ApplicationInput_PK.java +++ /dev/null @@ -1,65 +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.experiment.catalog.model; - -import java.io.Serializable; - -public class ApplicationInput_PK implements Serializable { - private String taskId; - private String inputKey; - - public ApplicationInput_PK(String inputKey, String taskId) { - this.inputKey = inputKey; - this.taskId = taskId; - } - - public ApplicationInput_PK() { - ; - } - - @Override - public boolean equals(Object o) { - return false; - } - - @Override - public int hashCode() { - return 1; - } - - - public String getTaskId() { - return taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getInputKey() { - return inputKey; - } - - public void setInputKey(String inputKey) { - this.inputKey = inputKey; - } -}
