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