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);
}
}
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);
}
}
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);
}
}
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);
}
}
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;
}
Aggregations