Search in sources :

Example 1 with HumanTaskServerConfiguration

use of org.wso2.carbon.humantask.core.configuration.HumanTaskServerConfiguration in project carbon-business-process by wso2.

the class TaskCleanupSchedulerUtil method initTaskCleanupJob.

/**
 * Initialises the task clean up task.
 *
 * @throws HumanTaskServerException :
 */
public static void initTaskCleanupJob() throws HumanTaskServerException {
    HumanTaskServerConfiguration serverConfig = HumanTaskCleanupSchedulerServiceComponent.getHumanTaskServer().getServerConfig();
    if (serverConfig.isTaskCleanupEnabled()) {
        try {
            log.info("Initialising the task cleanup service.....");
            HumanTaskCleanupSchedulerServiceComponent.getTaskService().registerTaskType(HumanTaskConstants.HUMANTASK_TASK_TYPE);
            TaskManager taskManager = HumanTaskCleanupSchedulerServiceComponent.getTaskService().getTaskManager(HumanTaskConstants.HUMANTASK_TASK_TYPE);
            TaskInfo.TriggerInfo triggerInfo = new TaskInfo.TriggerInfo();
            triggerInfo.setCronExpression(serverConfig.getTaskCleanupCronExpression());
            triggerInfo.setDisallowConcurrentExecution(true);
            Map<String, String> propertyMap = new LinkedHashMap<String, String>();
            TaskInfo taskInfo = new TaskInfo(HumanTaskConstants.HUMANTASK_CLEANUP_JOB, RemovableTaskCleanupJob.class.getName(), propertyMap, triggerInfo);
            taskManager.registerTask(taskInfo);
            taskManager.rescheduleTask(HumanTaskConstants.HUMANTASK_CLEANUP_JOB);
        } catch (TaskException ex) {
            String errMsg = "Error occurred while registering task type : " + HumanTaskConstants.HUMANTASK_TASK_TYPE;
            throw new HumanTaskServerException(errMsg, ex);
        }
    }
}
Also used : TaskInfo(org.wso2.carbon.ntask.core.TaskInfo) TaskManager(org.wso2.carbon.ntask.core.TaskManager) TaskException(org.wso2.carbon.ntask.common.TaskException) HumanTaskServerException(org.wso2.carbon.humantask.core.engine.HumanTaskServerException) HumanTaskServerConfiguration(org.wso2.carbon.humantask.core.configuration.HumanTaskServerConfiguration) RemovableTaskCleanupJob(org.wso2.carbon.humantask.cleanup.scheduler.ntask.RemovableTaskCleanupJob) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with HumanTaskServerConfiguration

use of org.wso2.carbon.humantask.core.configuration.HumanTaskServerConfiguration in project carbon-business-process by wso2.

the class ServiceUtils method invokeRegistrationService.

public static MessageContext invokeRegistrationService(MessageContext mctx, String registrationService) throws AxisFault {
    int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
    ConfigurationContext configurationContext = HTCoordinationModuleContentHolder.getInstance().getHtServer().getTaskStoreManager().getHumanTaskStore(tenantId).getConfigContext();
    OperationClient opClient = getOperationClient(mctx, configurationContext);
    mctx.getOptions().setParent(opClient.getOptions());
    opClient.addMessageContext(mctx);
    Options operationOptions = opClient.getOptions();
    operationOptions.setTo(new EndpointReference(registrationService));
    operationOptions.setAction(Constants.WS_COOR_REGISTERATION_ACTION);
    // operationOptions.setTransportInProtocol(org.apache.axis2.Constants.TRANSPORT_HTTPS);
    // Setting basic auth headers. Reading those information using HT server config.
    HumanTaskServerConfiguration serverConfig = HTCoordinationModuleContentHolder.getInstance().getHtServer().getServerConfig();
    // String tenantDomain = MultitenantUtils.getTenantDomainFromUrl(registrationService);
    // if (registrationService.equals(tenantDomain)) {
    // //this is a Super tenant registration service
    // if (log.isDebugEnabled()) {
    // log.debug("Sending Username" + serverConfig.getRegistrationServiceAuthUsername() + " - " + serverConfig.getRegistrationServiceAuthPassword());  //TODO REMOVE this
    // }
    // setBasicAccessSecurityHeaders(serverConfig.getRegistrationServiceAuthUsername(), serverConfig.getRegistrationServiceAuthPassword(), true, operationOptions);
    // } else {
    // if (log.isDebugEnabled()) {
    // log.debug("Sending ws-coor Registration request to tenant domain: " + tenantDomain);
    // }
    // // Tenant's registration service
    // 
    // String username = serverConfig.getRegistrationServiceAuthUsername() + "@" + tenantDomain;
    // String pass = serverConfig.getRegistrationServiceAuthPassword();
    // if (log.isDebugEnabled()) {
    // log.debug("Sending Username" + username + " - " + pass);  //TODO REMOVE this
    // }
    // setBasicAccessSecurityHeaders(username,pass,true,operationOptions);
    // }
    HttpTransportProperties.Authenticator basicAuthentication = new HttpTransportProperties.Authenticator();
    basicAuthentication.setPreemptiveAuthentication(true);
    basicAuthentication.setUsername(serverConfig.getRegistrationServiceAuthUsername());
    basicAuthentication.setPassword(serverConfig.getRegistrationServiceAuthPassword());
    operationOptions.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, basicAuthentication);
    if (log.isDebugEnabled()) {
        log.debug("Invoking Registration service");
    }
    opClient.execute(true);
    MessageContext responseMessageContext = opClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
    return responseMessageContext;
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) OperationClient(org.apache.axis2.client.OperationClient) Options(org.apache.axis2.client.Options) HttpTransportProperties(org.apache.axis2.transport.http.HttpTransportProperties) HumanTaskServerConfiguration(org.wso2.carbon.humantask.core.configuration.HumanTaskServerConfiguration) MessageContext(org.apache.axis2.context.MessageContext) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Example 3 with HumanTaskServerConfiguration

use of org.wso2.carbon.humantask.core.configuration.HumanTaskServerConfiguration in project carbon-business-process by wso2.

the class ServiceUtils method getTaskProtocolHandlerURL.

/**
 * Returns URL of the of the Task engine's Protocol Handler Admin service.
 * eg: https://localhost:9443/services/HumanTaskProtocolHandler/
 *
 * @return HumanTask protocol handler admin service's url
 */
public static String getTaskProtocolHandlerURL(ConfigurationContext serverConfigurationContext) throws HumanTaskCoordinationException {
    HumanTaskServerConfiguration serverConfig = HTCoordinationModuleContentHolder.getInstance().getHtServer().getServerConfig();
    String baseURL;
    if (serverConfig.isClusteredTaskEngines()) {
        baseURL = serverConfig.getLoadBalancerURL();
    } else {
        String scheme = CarbonConstants.HTTPS_TRANSPORT;
        String host;
        try {
            host = NetworkUtils.getLocalHostname();
        } catch (SocketException e) {
            log.error(e.getMessage(), e);
            throw new HumanTaskCoordinationException(e.getLocalizedMessage(), e);
        }
        int port = 9443;
        port = CarbonUtils.getTransportProxyPort(serverConfigurationContext, scheme);
        if (port == -1) {
            port = CarbonUtils.getTransportPort(serverConfigurationContext, scheme);
        }
        baseURL = scheme + "://" + host + ":" + port;
    }
    String webContext = ServerConfiguration.getInstance().getFirstProperty("WebContextRoot");
    if (webContext == null || webContext.equals("/")) {
        webContext = "";
    }
    String tenantDomain = "";
    try {
        tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true);
    } catch (Throwable e) {
        tenantDomain = null;
    }
    String protocolHandlerURL = baseURL + webContext + ((tenantDomain != null && !MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) ? "/" + MultitenantConstants.TENANT_AWARE_URL_PREFIX + "/" + tenantDomain : "") + Constants.CARBON_ADMIN_SERVICE_CONTEXT_ROOT + "/" + Constants.HUMANTASK_ENGINE_COORDINATION_PROTOCOL_HANDLER_SERVICE;
    return protocolHandlerURL;
}
Also used : SocketException(java.net.SocketException) HumanTaskServerConfiguration(org.wso2.carbon.humantask.core.configuration.HumanTaskServerConfiguration) HumanTaskCoordinationException(org.wso2.carbon.humantask.coordination.module.HumanTaskCoordinationException)

Example 4 with HumanTaskServerConfiguration

use of org.wso2.carbon.humantask.core.configuration.HumanTaskServerConfiguration in project carbon-business-process by wso2.

the class RemovableTaskCleanupJob method execute.

/**
 * The task clean up execution logic.
 */
public void execute() {
    HumanTaskServerConfiguration serverConfiguration = HumanTaskCleanupSchedulerServiceComponent.getHumanTaskServer().getServerConfig();
    final SimpleQueryCriteria queryCriteria = createQueryCriteria(serverConfiguration);
    log.info("Running the task cleanup service.....");
    try {
        HumanTaskCleanupSchedulerServiceComponent.getHumanTaskServer().getTaskEngine().getScheduler().execTransaction(new Callable<Object>() {

            public Object call() throws Exception {
                HumanTaskDAOConnection daoConnection = HumanTaskCleanupSchedulerServiceComponent.getHumanTaskServer().getDaoConnectionFactory().getConnection();
                daoConnection.removeTasks(queryCriteria);
                return null;
            }
        });
    } catch (Exception ex) {
        String errMsg = "Task Cleanup operation failed! :";
        log.error(errMsg, ex);
        throw new HumanTaskRuntimeException(errMsg, ex);
    }
}
Also used : HumanTaskServerConfiguration(org.wso2.carbon.humantask.core.configuration.HumanTaskServerConfiguration) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException) HumanTaskDAOConnection(org.wso2.carbon.humantask.core.dao.HumanTaskDAOConnection) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException) SimpleQueryCriteria(org.wso2.carbon.humantask.core.dao.SimpleQueryCriteria)

Example 5 with HumanTaskServerConfiguration

use of org.wso2.carbon.humantask.core.configuration.HumanTaskServerConfiguration in project carbon-business-process by wso2.

the class RemovableTaskCleanupJob method createQueryCriteria.

/**
 * Create task removal query criteria.
 *
 * @param serverConfiguration : The server config.
 * @return : The SimpleQueryCriteria.
 */
private SimpleQueryCriteria createQueryCriteria(HumanTaskServerConfiguration serverConfiguration) {
    SimpleQueryCriteria queryCriteria = new SimpleQueryCriteria();
    queryCriteria.setSimpleQueryType(SimpleQueryCriteria.QueryType.REMOVE_TASKS);
    queryCriteria.setStatuses(serverConfiguration.getRemovableTaskStatuses());
    return queryCriteria;
}
Also used : SimpleQueryCriteria(org.wso2.carbon.humantask.core.dao.SimpleQueryCriteria)

Aggregations

HumanTaskServerConfiguration (org.wso2.carbon.humantask.core.configuration.HumanTaskServerConfiguration)5 SimpleQueryCriteria (org.wso2.carbon.humantask.core.dao.SimpleQueryCriteria)2 File (java.io.File)1 SocketException (java.net.SocketException)1 LinkedHashMap (java.util.LinkedHashMap)1 EndpointReference (org.apache.axis2.addressing.EndpointReference)1 OperationClient (org.apache.axis2.client.OperationClient)1 Options (org.apache.axis2.client.Options)1 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)1 MessageContext (org.apache.axis2.context.MessageContext)1 HttpTransportProperties (org.apache.axis2.transport.http.HttpTransportProperties)1 RemovableTaskCleanupJob (org.wso2.carbon.humantask.cleanup.scheduler.ntask.RemovableTaskCleanupJob)1 HumanTaskCoordinationException (org.wso2.carbon.humantask.coordination.module.HumanTaskCoordinationException)1 HumanTaskDAOConnection (org.wso2.carbon.humantask.core.dao.HumanTaskDAOConnection)1 HumanTaskServerException (org.wso2.carbon.humantask.core.engine.HumanTaskServerException)1 HumanTaskRuntimeException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)1 TaskException (org.wso2.carbon.ntask.common.TaskException)1 TaskInfo (org.wso2.carbon.ntask.core.TaskInfo)1 TaskManager (org.wso2.carbon.ntask.core.TaskManager)1