Search in sources :

Example 11 with Notification

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);
}
Also used : NotificationScheduler(org.wso2.carbon.humantask.core.scheduler.NotificationScheduler)

Example 12 with Notification

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);
    }
}
Also used : IllegalAccessFault(org.wso2.carbon.humantask.client.api.IllegalAccessFault) HumanTaskIllegalAccessException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException) IllegalOperationFault(org.wso2.carbon.humantask.client.api.IllegalOperationFault) HumanTaskIllegalOperationException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalOperationException) Remove(org.wso2.carbon.humantask.core.engine.commands.Remove) IllegalArgumentFault(org.wso2.carbon.humantask.client.api.IllegalArgumentFault) HumanTaskIllegalArgumentException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalArgumentException) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) HumanTaskIllegalOperationException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalOperationException) HumanTaskException(org.wso2.carbon.humantask.core.engine.HumanTaskException) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException) HumanTaskIllegalStateException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalStateException) RecipientNotAllowedException(org.wso2.carbon.humantask.client.api.RecipientNotAllowedException) UserStoreException(org.wso2.carbon.user.core.UserStoreException) HumanTaskIllegalAccessException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException)

Example 13 with Notification

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;
}
Also used : QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) TNotification(org.wso2.carbon.humantask.TNotification) TTask(org.wso2.carbon.humantask.TTask)

Example 14 with Notification

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);
        }
    }
}
Also used : OrganizationalEntityProvider(org.wso2.carbon.humantask.core.dao.jpa.openjpa.model.provider.OrganizationalEntityProvider) NotificationConfiguration(org.wso2.carbon.humantask.core.store.NotificationConfiguration) TaskConfiguration(org.wso2.carbon.humantask.core.store.TaskConfiguration)

Example 15 with Notification

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);
        }
    }
}
Also used : PublisherEvent(org.wso2.carbon.identity.notification.mgt.bean.PublisherEvent)

Aggregations

HashMap (java.util.HashMap)31 IdentityEventException (org.wso2.carbon.identity.event.IdentityEventException)25 UserRecoveryData (org.wso2.carbon.identity.recovery.model.UserRecoveryData)21 UserRecoveryDataStore (org.wso2.carbon.identity.recovery.store.UserRecoveryDataStore)18 IdentityRecoveryException (org.wso2.carbon.identity.recovery.IdentityRecoveryException)17 UserStoreException (org.wso2.carbon.user.api.UserStoreException)17 Event (org.wso2.carbon.identity.event.event.Event)14 IdentityException (org.wso2.carbon.identity.base.IdentityException)13 User (org.wso2.carbon.identity.application.common.model.User)10 NotificationResponseBean (org.wso2.carbon.identity.recovery.bean.NotificationResponseBean)10 ArrayList (java.util.ArrayList)8 QName (javax.xml.namespace.QName)8 PrivilegedCarbonContext (org.wso2.carbon.context.PrivilegedCarbonContext)8 Map (java.util.Map)7 Test (org.testng.annotations.Test)7 Property (org.wso2.carbon.identity.recovery.model.Property)7 NotificationChannels (org.wso2.carbon.identity.governance.service.notification.NotificationChannels)6 UserStoreException (org.wso2.carbon.user.core.UserStoreException)6 NotificationException (org.wso2.carbon.apimgt.impl.notification.exception.NotificationException)5 NotificationDataDTO (org.wso2.carbon.identity.mgt.dto.NotificationDataDTO)5