Search in sources :

Example 16 with AiravataException

use of org.apache.airavata.common.exception.AiravataException in project airavata by apache.

the class ProfileServiceUtils method getDBEventMessageContext.

/**
 * Constructs the dbEventMessageContext
 * @param entityType
 * @param crudType
 * @param entityModel
 * @return
 * @throws AiravataException
 */
public static MessageContext getDBEventMessageContext(EntityType entityType, CrudType crudType, TBase entityModel) throws AiravataException {
    try {
        // set the publisherContext
        DBEventMessage dbEventMessage = new DBEventMessage();
        DBEventPublisherContext publisherContext = new DBEventPublisherContext();
        publisherContext.setCrudType(crudType);
        publisherContext.setEntityDataModel(ThriftUtils.serializeThriftObject(entityModel));
        publisherContext.setEntityType(entityType);
        // create dbEventPublisher with publisherContext
        DBEventPublisher dbEventPublisher = new DBEventPublisher();
        dbEventPublisher.setPublisherContext(publisherContext);
        // set messageContext to dbEventPublisher
        DBEventMessageContext dbMessageContext = DBEventMessageContext.publisher(dbEventPublisher);
        // set dbEventMessage with messageContext
        dbEventMessage.setDbEventType(DBEventType.PUBLISHER);
        dbEventMessage.setPublisherService(DBEventManagerConstants.getDbEventServiceName(entityType));
        dbEventMessage.setMessageContext(dbMessageContext);
        // construct and return messageContext
        return new MessageContext(dbEventMessage, MessageType.DB_EVENT, "", "");
    } catch (Exception ex) {
        throw new AiravataException(ex.getMessage(), ex);
    }
}
Also used : MessageContext(org.apache.airavata.messaging.core.MessageContext) AiravataException(org.apache.airavata.common.exception.AiravataException) AiravataException(org.apache.airavata.common.exception.AiravataException)

Example 17 with AiravataException

use of org.apache.airavata.common.exception.AiravataException in project airavata by apache.

the class OrchestratorUtils method updageAndPublishExperimentStatus.

public static void updageAndPublishExperimentStatus(String experimentId, ExperimentStatus status, Publisher publisher, String gatewayId) {
    try {
        RegistryFactory.getDefaultExpCatalog().update(ExperimentCatalogModelType.EXPERIMENT_STATUS, status, experimentId);
        ExperimentStatusChangeEvent event = new ExperimentStatusChangeEvent(status.getState(), experimentId, gatewayId);
        String messageId = AiravataUtils.getId("EXPERIMENT");
        MessageContext messageContext = new MessageContext(event, MessageType.EXPERIMENT, messageId, gatewayId);
        messageContext.setUpdatedTime(AiravataUtils.getCurrentTimestamp());
        publisher.publish(messageContext);
    } catch (RegistryException e) {
        log.error("expId : " + experimentId + " Error while updating experiment status to " + status.toString(), e);
    } catch (AiravataException e) {
        log.error("expId : " + experimentId + " Error while publishing experiment status to " + status.toString(), e);
    }
}
Also used : ExperimentStatusChangeEvent(org.apache.airavata.model.messaging.event.ExperimentStatusChangeEvent) MessageContext(org.apache.airavata.messaging.core.MessageContext) RegistryException(org.apache.airavata.registry.cpi.RegistryException) AiravataException(org.apache.airavata.common.exception.AiravataException)

Example 18 with AiravataException

use of org.apache.airavata.common.exception.AiravataException in project airavata by apache.

the class OrchestratorUtils method getLoginUserName.

public static String getLoginUserName(OrchestratorContext context, ProcessModel processModel, String gatewayId) throws RegistryException, AiravataException {
    try {
        ComputeResourcePreference computeResourcePreference = getComputeResourcePreference(context, gatewayId, processModel.getComputeResourceId());
        ComputationalResourceSchedulingModel processResourceSchedule = processModel.getProcessResourceSchedule();
        if (processModel.isUseUserCRPref()) {
            UsrResourceProfile userResourceProfile = getUserResourceProfile(context);
            UserComputeResourcePreference userComputeResourcePreference = userResourceProfile.getUserComputeResourcePreference(processModel.getUserName(), gatewayId, processModel.getComputeResourceId());
            if (isValid(userComputeResourcePreference.getLoginUserName())) {
                return userComputeResourcePreference.getLoginUserName();
            } else if (isValid(processResourceSchedule.getOverrideLoginUserName())) {
                logger.warn("User computer resource preference doesn't have valid user login name, using computer " + "resource scheduling login name " + processResourceSchedule.getOverrideLoginUserName());
                return processResourceSchedule.getOverrideLoginUserName();
            } else if (isValid(computeResourcePreference.getLoginUserName())) {
                logger.warn("Either User computer resource preference or computer resource scheduling " + "doesn't have valid user login name, using  gateway computer resource preference login name " + computeResourcePreference.getLoginUserName());
                return computeResourcePreference.getLoginUserName();
            } else {
                throw new AiravataException("Login name is not found");
            }
        } else {
            if (isValid(processResourceSchedule.getOverrideLoginUserName())) {
                return processResourceSchedule.getOverrideLoginUserName();
            } else if (isValid(computeResourcePreference.getLoginUserName())) {
                logger.warn("Process compute resource scheduling doesn't have valid user login name, " + "using  gateway computer resource preference login name " + computeResourcePreference.getLoginUserName());
                return computeResourcePreference.getLoginUserName();
            } else {
                throw new AiravataException("Login name is not found");
            }
        }
    } catch (AppCatalogException e) {
        logger.error("Error occurred while initializing app catalog to fetch login username", e);
        throw new RegistryException("Error occurred while initializing app catalog to fetch login username", e);
    }
}
Also used : UserComputeResourcePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference) ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) UserComputeResourcePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference) ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel) AiravataException(org.apache.airavata.common.exception.AiravataException)

Example 19 with AiravataException

use of org.apache.airavata.common.exception.AiravataException in project airavata by apache.

the class Workflow method clone.

/**
 * @see java.lang.Object#clone()
 */
@Override
public Workflow clone() {
    XmlElement originalXML = toXML();
    try {
        XmlElement newXML = XMLUtil.deepClone(originalXML);
        Workflow newWorkflow = new Workflow(newXML);
        return newWorkflow;
    } catch (GraphException e) {
        // This should not happen.
        throw new WorkflowRuntimeException(e);
    } catch (WorkflowException e) {
        // This should not happen.
        throw new WorkflowRuntimeException(e);
    } catch (AiravataException e) {
        // This should not happen.
        throw new WorkflowRuntimeException(e);
    }
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) WorkflowException(org.apache.airavata.workflow.model.exceptions.WorkflowException) XmlElement(org.xmlpull.infoset.XmlElement) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) AiravataException(org.apache.airavata.common.exception.AiravataException)

Example 20 with AiravataException

use of org.apache.airavata.common.exception.AiravataException in project airavata by apache.

the class WorkflowWSDL method addParameter.

/**
 * Adds the parameter element.
 *
 * @param node
 * @param sequence
 * @param schema
 * @return The parameter element
 */
private XmlElement addParameter(ParameterNode node, XmlElement sequence, XmlElement schema) {
    XmlElement element;
    SystemDataPort port = node.getPort();
    element = addParameter(node, port, sequence, schema);
    // 
    // Annotation
    // 
    String description = node.getDescription();
    XmlElement appinfo = node.getMetadata();
    // description
    if (description != null && description.trim().length() != 0) {
        XmlElement annotation = element.element(null, WSConstants.ANNOTATION_TAG, true);
        XmlElement documentation = annotation.addElement(WSConstants.DOCUMENTATION_TAG);
        documentation.setText(node.getDescription());
    }
    // appinfo
    if (appinfo != null) {
        XmlElement annotation = element.element(null, WSConstants.ANNOTATION_TAG, true);
        try {
            annotation.addElement(XMLUtil.deepClone(appinfo));
        } catch (AiravataException e) {
            log.error(e.getMessage(), e);
        }
    }
    // 
    if (node instanceof InputNode) {
        InputNode inputNode = (InputNode) node;
        Object value = inputNode.getDefaultValue();
        if (value instanceof String) {
            element.setAttributeValue(WSConstants.DEFAULT_ATTRIBUTE, (String) value);
        } else if (value instanceof XmlElement) {
            // Add the default value in <annotation><default> because there
            // is no standard way.
            XmlElement valueElement = null;
            try {
                valueElement = XMLUtil.deepClone((XmlElement) value);
            } catch (AiravataException e) {
                log.error(e.getMessage(), e);
            }
            XmlElement annotation = element.element(null, WSConstants.ANNOTATION_TAG, true);
            XmlElement defaultElement = annotation.addElement(WSComponentPort.DEFAULT);
            defaultElement.addElement(valueElement);
        }
    }
    return element;
}
Also used : InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) SystemDataPort(org.apache.airavata.workflow.model.graph.system.SystemDataPort) XmlElement(org.xmlpull.infoset.XmlElement) AiravataException(org.apache.airavata.common.exception.AiravataException)

Aggregations

AiravataException (org.apache.airavata.common.exception.AiravataException)40 IOException (java.io.IOException)10 TException (org.apache.thrift.TException)8 GFacException (org.apache.airavata.gfac.core.GFacException)6 RegistryException (org.apache.airavata.registry.cpi.RegistryException)6 XmlElement (org.xmlpull.infoset.XmlElement)5 ShutdownSignalException (com.rabbitmq.client.ShutdownSignalException)4 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)4 ProcessContext (org.apache.airavata.gfac.core.context.ProcessContext)4 MessagingException (javax.mail.MessagingException)3 MessageContext (org.apache.airavata.messaging.core.MessageContext)3 Session (com.jcraft.jsch.Session)2 ConnectionFactory (com.rabbitmq.client.ConnectionFactory)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 Flags (javax.mail.Flags)2 Message (javax.mail.Message)2 EmailParser (org.apache.airavata.gfac.core.monitor.EmailParser)2