Search in sources :

Example 31 with RegistryException

use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.

the class ExperimentRegistry method addTask.

public String addTask(TaskModel task, String processID) throws RegistryException {
    try {
        TaskResource taskResource = new TaskResource();
        task.setTaskId(AiravataUtils.getId("TASK"));
        taskResource.setTaskId(task.getTaskId());
        taskResource.setParentProcessId(task.getParentProcessId());
        taskResource.setTaskType(task.getTaskType().toString());
        taskResource.setCreationTime(AiravataUtils.getTime(task.getCreationTime()));
        taskResource.setLastUpdateTime(AiravataUtils.getTime(task.getLastUpdateTime()));
        taskResource.setTaskDetail(task.getTaskDetail());
        taskResource.setSubTaskModel(task.getSubTaskModel());
        taskResource.save();
        TaskStatus taskStatus = new TaskStatus();
        taskStatus.setState(TaskState.CREATED);
        taskStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
        addTaskStatus(taskStatus, task.getTaskId());
        if (task.getTaskErrors() != null) {
            addTaskError(task.getTaskErrors().get(0), task.getTaskId());
        }
    } catch (Exception e) {
        logger.error(processID, "Error while adding task...", e);
        throw new RegistryException(e);
    }
    return task.getTaskId();
}
Also used : RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 32 with RegistryException

use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.

the class GatewayRegistry method updateGateway.

public void updateGateway(String gatewayId, Gateway updatedGateway) throws RegistryException {
    try {
        GatewayResource existingGateway = (GatewayResource) ExpCatResourceUtils.getGateway(gatewayId);
        existingGateway.setGatewayApprovalStatus(updatedGateway.getGatewayApprovalStatus().toString());
        existingGateway.setGatewayName(updatedGateway.getGatewayName());
        existingGateway.setEmailAddress(updatedGateway.getEmailAddress());
        existingGateway.setDomain(updatedGateway.getDomain());
        existingGateway.setGatewayAcronym(updatedGateway.getGatewayAcronym());
        existingGateway.setGatewayUrl(updatedGateway.getGatewayURL());
        existingGateway.setGatewayPublicAbstract(updatedGateway.getGatewayPublicAbstract());
        existingGateway.setReviewProposalDescription(updatedGateway.getReviewProposalDescription());
        existingGateway.setGatewayAdminFirstName(updatedGateway.getGatewayAdminFirstName());
        existingGateway.setGetGatewayAdminLastName(updatedGateway.getGatewayAdminLastName());
        existingGateway.setGatewayAdminEmail(updatedGateway.getGatewayAdminEmail());
        existingGateway.setIdentityServerUserName(updatedGateway.getIdentityServerUserName());
        existingGateway.setIdentityServerPasswordToken(updatedGateway.getIdentityServerPasswordToken());
        existingGateway.setDeclinedReason(updatedGateway.getDeclinedReason());
        existingGateway.setOauthClientId(updatedGateway.getOauthClientId());
        existingGateway.setOauthClientSecret(updatedGateway.getOauthClientSecret());
        existingGateway.setRequesterUsername(updatedGateway.getRequesterUsername());
        existingGateway.save();
    } catch (RegistryException e) {
        logger.error("Error while updating gateway to registry", e);
        throw new RegistryException(e);
    }
}
Also used : GatewayResource(org.apache.airavata.registry.core.experiment.catalog.resources.GatewayResource) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 33 with RegistryException

use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.

the class ProjectRegistry method addProject.

public String addProject(Project project, String gatewayId) throws RegistryException {
    String projectId;
    try {
        if (!ExpCatResourceUtils.isUserExist(project.getOwner(), gatewayId)) {
            ExpCatResourceUtils.addUser(project.getOwner(), null, gatewayId);
        }
        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();
    } catch (Exception e) {
        logger.error("Error while saving project to registry", e);
        throw new RegistryException(e);
    }
    return projectId;
}
Also used : RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 34 with RegistryException

use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.

the class ProjectRegistry method getProjectList.

/**
 * 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;
}
Also used : Project(org.apache.airavata.model.workspace.Project) RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 35 with RegistryException

use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.

the class ProjectRegistry method updateProject.

public void updateProject(Project project, String projectId) throws RegistryException {
    try {
        ProjectResource existingProject = workerResource.getProject(projectId);
        existingProject.setDescription(project.getDescription());
        existingProject.setName(project.getName());
        WorkerResource worker = new WorkerResource(project.getOwner(), project.getGatewayId());
        existingProject.setWorker(worker);
        existingProject.save();
        ProjectUserResource resource = (ProjectUserResource) existingProject.create(ResourceType.PROJECT_USER);
        resource.setProjectId(projectId);
        resource.setUserName(project.getOwner());
        resource.save();
    } catch (Exception e) {
        logger.error("Error while saving project to registry", e);
        throw new RegistryException(e);
    }
}
Also used : RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Aggregations

RegistryException (org.apache.airavata.registry.cpi.RegistryException)134 EntityManager (javax.persistence.EntityManager)54 Query (javax.persistence.Query)29 QueryGenerator (org.apache.airavata.registry.core.experiment.catalog.utils.QueryGenerator)29 ArrayList (java.util.ArrayList)15 List (java.util.List)12 ExperimentCatResource (org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource)12 OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)11 ExperimentCatalogException (org.apache.airavata.registry.cpi.ExperimentCatalogException)8 AiravataException (org.apache.airavata.common.exception.AiravataException)6 GFacException (org.apache.airavata.gfac.core.GFacException)6 InputDataObjectType (org.apache.airavata.model.application.io.InputDataObjectType)6 Node (org.apache.airavata.workflow.model.graph.Node)6 DynamicNode (org.apache.airavata.workflow.model.graph.dynamic.DynamicNode)6 SubWorkflowNode (org.apache.airavata.workflow.model.graph.subworkflow.SubWorkflowNode)6 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)6 Timestamp (java.sql.Timestamp)5 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)4 DataPort (org.apache.airavata.workflow.model.graph.DataPort)4 HashMap (java.util.HashMap)3