use of org.wso2.carbon.identity.mgt.mail.Notification in project carbon-business-process by wso2.
the class HumanTaskServer method initNotificationScheduler.
/**
* Notification scheduler initialisation.
*/
private void initNotificationScheduler() {
NotificationScheduler notificationScheduler = new NotificationScheduler();
taskEngine.setNotificationScheduler(notificationScheduler);
}
use of org.wso2.carbon.identity.mgt.mail.Notification in project carbon-business-process by wso2.
the class TaskOperationsImpl method remove.
/**
* Applies to notifications only.
* Used by notification recipients to remove the notification permanently from their task list client.
* @param taskId : Notification identifier
* @throws IllegalOperationFault
* @throws IllegalArgumentFault
* @throws IllegalAccessFault
*/
public void remove(URI taskId) throws IllegalOperationFault, IllegalArgumentFault, IllegalAccessFault {
try {
final Long notificationId = validateTaskId(taskId);
HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getScheduler().execTransaction(new Callable<Object>() {
public Object call() throws Exception {
Remove removeCommand = new Remove(getCaller(), notificationId);
removeCommand.execute();
return null;
}
});
} catch (HumanTaskIllegalOperationException ex) {
log.error(ex);
throw new IllegalOperationFault(ex);
} catch (HumanTaskIllegalAccessException ex) {
log.error(ex);
throw new IllegalAccessFault(ex);
} catch (Exception ex) {
log.error(ex);
throw new IllegalArgumentFault(ex);
}
}
use of org.wso2.carbon.identity.mgt.mail.Notification in project carbon-business-process by wso2.
the class HumanTaskStore method deploy.
/**
* This will simply deploy the new task and will not perform removal of existing tasks, which should be done prior to
* deploying this task
* @param humanTaskDU
* @return List of task configuration Qnames deployed
* @throws HumanTaskDeploymentException
*/
public List<QName> deploy(HumanTaskDeploymentUnit humanTaskDU) throws HumanTaskDeploymentException {
List<QName> taskConfigsInPackage = new ArrayList<QName>();
TTask[] tasks = humanTaskDU.getTasks();
List<HumanTaskBaseConfiguration> configurations = new ArrayList<HumanTaskBaseConfiguration>();
if (tasks != null) {
for (TTask task : tasks) {
QName taskQName = new QName(humanTaskDU.getNamespace(), task.getName());
if (log.isDebugEnabled()) {
log.debug(" Adding task " + task.getName() + "to task configuration");
}
TaskConfiguration taskConf = new TaskConfiguration(task, humanTaskDU.getTaskServiceInfo(taskQName), humanTaskDU.getHumanInteractionsDefinition(), humanTaskDU.getWSDLs(), humanTaskDU.getNamespace(), humanTaskDU.getName(), getTenantAxisConfig(), humanTaskDU.getPackageName(), humanTaskDU.getVersion(), humanTaskDU.getHumanTaskDefinitionFile());
taskConf.setPackageStatus(humanTaskDU.getTaskPackageStatus());
configurations.add(taskConf);
if (!taskConf.isErroneous()) {
createCallBackService(taskConf);
if (taskConf.getPackageStatus() == TaskPackageStatus.ACTIVE) {
deploy(taskConf);
// activeTaskConfigurationQNameMap.put(taskQName, taskConf.getName());
}
}
}
}
TNotification[] notifications = humanTaskDU.getNotifications();
if (notifications != null) {
for (TNotification notification : notifications) {
QName notificationQName = new QName(humanTaskDU.getNamespace(), notification.getName());
NotificationConfiguration notificationConf = new NotificationConfiguration(notification, humanTaskDU.getNotificationServiceInfo(notificationQName), humanTaskDU.getHumanInteractionsDefinition(), humanTaskDU.getWSDLs(), humanTaskDU.getNamespace(), humanTaskDU.getName(), getTenantAxisConfig(), humanTaskDU.getPackageName(), humanTaskDU.getVersion(), humanTaskDU.getHumanTaskDefinitionFile());
notificationConf.setPackageStatus(humanTaskDU.getTaskPackageStatus());
configurations.add(notificationConf);
if (!notificationConf.isErroneous()) {
// Deploy the axis2 service only for the active version of the task/notification
if (notificationConf.getPackageStatus() == TaskPackageStatus.ACTIVE) {
deploy(notificationConf);
// activeTaskConfigurationQNameMap.put(notificationQName, notificationConf.getName());
}
}
}
}
// condition if a service name is deployed with same name outside of this task package
for (HumanTaskBaseConfiguration configuration : configurations) {
taskConfigurations.add(configuration);
taskBaseConfigurationHashMap.put(configuration.getName(), configuration);
taskConfigsInPackage.add(configuration.getName());
if (configuration.getPackageStatus() == TaskPackageStatus.ACTIVE) {
activeTaskConfigurationQNameMap.put(configuration.getDefinitionName(), configuration.getName());
}
}
for (TNotification inlineNotification : humanTaskDU.getInlineNotifications()) {
QName notificationQName = new QName(humanTaskDU.getNamespace(), inlineNotification.getName());
NotificationConfiguration notificationConf = new NotificationConfiguration(inlineNotification, humanTaskDU.getNotificationServiceInfo(notificationQName), humanTaskDU.getHumanInteractionsDefinition(), humanTaskDU.getWSDLs(), humanTaskDU.getNamespace(), humanTaskDU.getName(), getTenantAxisConfig(), humanTaskDU.getPackageName(), humanTaskDU.getVersion(), humanTaskDU.getHumanTaskDefinitionFile());
notificationConf.setPackageStatus(humanTaskDU.getTaskPackageStatus());
taskConfigurations.add(notificationConf);
taskConfigsInPackage.add(notificationConf.getName());
taskBaseConfigurationHashMap.put(notificationConf.getName(), notificationConf);
if (notificationConf.getPackageStatus() == TaskPackageStatus.ACTIVE) {
activeTaskConfigurationQNameMap.put(notificationQName, notificationConf.getName());
}
}
taskConfigurationsInTaskPackage.put(humanTaskDU.getName(), taskConfigsInPackage);
return taskConfigsInPackage;
}
use of org.wso2.carbon.identity.mgt.mail.Notification in project carbon-business-process by wso2.
the class JPATaskUtil method processGenericHumanRoles.
public static void processGenericHumanRoles(TaskDAO task, HumanTaskBaseConfiguration taskConfiguration, PeopleQueryEvaluator peopleQueryEvaluator, EvaluationContext evaluationContext) throws HumanTaskException {
if (taskConfiguration.isTask()) {
// Task
TTask tTask = ((TaskConfiguration) taskConfiguration).getTask();
// TODO move the reading of configuration file in to the TaskConfiguration class
// Reading Excluded users
TGenericHumanRoleAssignment[] tExcludedOwners = tTask.getPeopleAssignments().getExcludedOwnersArray();
if (tExcludedOwners != null && tExcludedOwners.length > 0) {
assignHumanRoles(task, peopleQueryEvaluator, tExcludedOwners[0], GenericHumanRoleDAO.GenericHumanRoleType.EXCLUDED_OWNERS, evaluationContext);
}
// Reading potential owners
TPotentialOwnerAssignment[] tPotentialOwners = tTask.getPeopleAssignments().getPotentialOwnersArray();
if (tPotentialOwners != null && tPotentialOwners.length > 0) {
TPotentialOwnerAssignment tPotentialOwner = tPotentialOwners[0];
OrganizationalEntityProvider provider = OrganizationalEntityProviderFactory.getOrganizationalEntityProvider(tPotentialOwner.getFrom());
List<OrganizationalEntityDAO> orgEntities = provider.getOrganizationalEntities(peopleQueryEvaluator, tPotentialOwner.getFrom(), evaluationContext);
if (tExcludedOwners != null && tExcludedOwners.length > 0) {
GenericHumanRoleDAO excludedOwners = task.getGenericHumanRole(GenericHumanRoleDAO.GenericHumanRoleType.EXCLUDED_OWNERS);
for (OrganizationalEntityDAO excludedEntity : excludedOwners.getOrgEntities()) {
for (OrganizationalEntityDAO ownerEntity : orgEntities) {
if (excludedEntity.getOrgEntityType() == ownerEntity.getOrgEntityType() && excludedEntity.getName().equals(ownerEntity.getName())) {
orgEntities.remove(ownerEntity);
break;
}
}
}
}
GenericHumanRole potentialOwnersGHRole = new GenericHumanRole();
potentialOwnersGHRole.setType(GenericHumanRole.GenericHumanRoleType.POTENTIAL_OWNERS);
potentialOwnersGHRole.setOrgEntities(orgEntities);
potentialOwnersGHRole.setTask(task);
for (OrganizationalEntityDAO oe : orgEntities) {
oe.addGenericHumanRole(potentialOwnersGHRole);
}
task.addHumanRole(potentialOwnersGHRole);
}
// Reading Stake holders
TGenericHumanRoleAssignment[] tStakeHolders = tTask.getPeopleAssignments().getTaskStakeholdersArray();
if (tStakeHolders != null && tStakeHolders.length > 0) {
assignHumanRoles(task, peopleQueryEvaluator, tStakeHolders[0], GenericHumanRoleDAO.GenericHumanRoleType.STAKEHOLDERS, evaluationContext);
}
// Reading Business administrators
TGenericHumanRoleAssignment[] tBusinessAdministrators = tTask.getPeopleAssignments().getBusinessAdministratorsArray();
if (tBusinessAdministrators != null && tBusinessAdministrators.length > 0) {
assignHumanRoles(task, peopleQueryEvaluator, tBusinessAdministrators[0], GenericHumanRoleDAO.GenericHumanRoleType.BUSINESS_ADMINISTRATORS, evaluationContext);
}
} else {
// Notification
TNotification tNotification = ((NotificationConfiguration) taskConfiguration).getNotificationDefinition();
// Reading Notification recipients
TGenericHumanRoleAssignment[] tRecipients = tNotification.getPeopleAssignments().getRecipientsArray();
if (tRecipients != null && tRecipients.length > 0) {
assignHumanRoles(task, peopleQueryEvaluator, tRecipients[0], GenericHumanRoleDAO.GenericHumanRoleType.NOTIFICATION_RECIPIENTS, evaluationContext);
}
}
}
use of org.wso2.carbon.identity.mgt.mail.Notification in project carbon-identity-framework by wso2.
the class EventDistributionTask method run.
@Override
public void run() {
running = true;
// Run forever until stop the bundle. Will stop in eventQueue.take()
while (running) {
try {
final PublisherEvent event = eventQueue.take();
for (final NotificationSendingModule module : notificationSendingModules) {
// If the module is subscribed to the event, module will be executed.
try {
if (module.isSubscribed(event)) {
// Create a runnable and submit to the thread pool for sending message.
Runnable msgSender = new Runnable() {
@Override
public void run() {
if (log.isDebugEnabled()) {
log.debug("Executing " + module.getModuleName() + " on event" + event.getEventName());
}
try {
module.sendMessage(event);
} catch (NotificationManagementException e) {
log.error("Error while invoking notification sending module " + module.getModuleName(), e);
}
}
};
NotificationManagementServiceDataHolder.getInstance().getThreadPool().submit(msgSender);
}
} catch (NotificationManagementException e) {
log.error("Error while getting subscription status from notification module " + module.getModuleName(), e);
}
}
} catch (InterruptedException e) {
log.error("Error while picking up event from event queue", e);
}
}
}
Aggregations