use of org.wso2.carbon.device.mgt.common.operation.mgt.Operation in project carbon-business-process by wso2.
the class TaskOperationsImpl method setOutput.
/**
* Set the data for the part of the task's output message.
*
* @param taskIdURI : task identifier
* @param ncName : PartName
* @param o
* @throws IllegalStateFault
* @throws IllegalOperationFault
* @throws IllegalArgumentFault
* @throws IllegalAccessFault
*/
public void setOutput(URI taskIdURI, NCName ncName, Object o) throws IllegalStateFault, IllegalOperationFault, IllegalArgumentFault, IllegalAccessFault {
try {
final Long taskId = validateTaskId(taskIdURI);
if (ncName != null && o != null) {
final String outputName = ncName.toString();
final Element outputData = DOMUtils.stringToDOM((String) o);
HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getScheduler().execTransaction(new Callable<Object>() {
public Object call() throws Exception {
SetOutput setOutputCommand = new SetOutput(getCaller(), taskId, outputName, outputData);
setOutputCommand.execute();
return null;
}
});
} else {
log.error("The output data for setOutput operation cannot be empty");
throw new IllegalArgumentFault("The output data cannot be empty!");
}
} catch (Exception ex) {
handleException(ex);
}
}
use of org.wso2.carbon.device.mgt.common.operation.mgt.Operation in project carbon-business-process by wso2.
the class TaskOperationsImpl method addAttachment.
/**
* Add attachment to a task. Returns an identifier for the attachment.
* @param taskIdentifier : task identifier
* @param name : attachment name
* @param accessType : access type
* @param contentType : content type
* @param attachment : attachment ID (String)
* @return
* @throws IllegalStateFault
* @throws IllegalOperationFault
* @throws IllegalArgumentFault
* @throws IllegalAccessFault
*/
public boolean addAttachment(URI taskIdentifier, String name, String accessType, String contentType, Object attachment) throws IllegalStateFault, IllegalOperationFault, IllegalArgumentFault, IllegalAccessFault {
final Long taskId = validateTaskId(taskIdentifier);
final String attachmentID = (String) attachment;
try {
Boolean isAdded = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getScheduler().execTransaction(new Callable<Boolean>() {
public Boolean call() throws Exception {
HumanTaskEngine engine = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine();
HumanTaskDAOConnection daoConn = engine.getDaoConnectionFactory().getConnection();
TaskDAO taskDAO = daoConn.getTask(taskId);
validateTaskTenant(taskDAO);
try {
boolean isAdded = taskDAO.addAttachment(TransformerUtils.generateAttachmentDAOFromID(taskDAO, attachmentID));
if (!isAdded) {
throw new HumanTaskException("Attachment with id: " + attachmentID + "was not associated " + "task with id:" + taskId);
}
return isAdded;
} catch (HumanTaskException ex) {
String errMsg = "getAttachmentInfos operation failed. Reason: ";
log.error(errMsg + ex.getLocalizedMessage(), ex);
throw ex;
}
}
});
return isAdded;
} catch (Exception ex) {
handleException(ex);
}
return false;
}
use of org.wso2.carbon.device.mgt.common.operation.mgt.Operation in project carbon-business-process by wso2.
the class TaskOperationsImpl method authoriseToLoadTask.
/**
* Throws an exception if the current user is not allowed to perform loadTask() operation
* @param taskId
*/
private void authoriseToLoadTask(TaskDAO task) throws Exception {
List<GenericHumanRoleDAO.GenericHumanRoleType> allowedRoles = new ArrayList<GenericHumanRoleDAO.GenericHumanRoleType>();
allowedRoles.add(GenericHumanRoleDAO.GenericHumanRoleType.ACTUAL_OWNER);
allowedRoles.add(GenericHumanRoleDAO.GenericHumanRoleType.BUSINESS_ADMINISTRATORS);
allowedRoles.add(GenericHumanRoleDAO.GenericHumanRoleType.NOTIFICATION_RECIPIENTS);
allowedRoles.add(GenericHumanRoleDAO.GenericHumanRoleType.POTENTIAL_OWNERS);
allowedRoles.add(GenericHumanRoleDAO.GenericHumanRoleType.STAKEHOLDERS);
allowedRoles.add(GenericHumanRoleDAO.GenericHumanRoleType.TASK_INITIATOR);
HumanTaskEngine taskEngine = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine();
PeopleQueryEvaluator pqe = taskEngine.getPeopleQueryEvaluator();
OrganizationalEntityDAO invoker = taskEngine.getScheduler().execTransaction(new Callable<OrganizationalEntityDAO>() {
@Override
public OrganizationalEntityDAO call() throws Exception {
return HumanTaskServiceComponent.getHumanTaskServer().getDaoConnectionFactory().getConnection().createNewOrgEntityObject(getCaller(), OrganizationalEntityDAO.OrganizationalEntityType.USER);
}
});
if (!OperationAuthorizationUtil.authoriseUser(task, invoker, allowedRoles, pqe)) {
String errorMsg = String.format("The user[%s] cannot perform loadTask()" + " operation as either he is in EXCLUDED_OWNERS role or he is not in task roles [%s]", invoker.getName(), allowedRoles);
log.error(errorMsg);
throw new HumanTaskIllegalAccessException("Access Denied. You are not authorized to perform this task");
}
}
use of org.wso2.carbon.device.mgt.common.operation.mgt.Operation in project carbon-business-process by wso2.
the class BPELServerConfiguration method populateDataSourceConfigFields.
private void populateDataSourceConfigFields() {
TDataBaseConfig databaseConfig = bpsConfigDocument.getWSO2BPS().getDataBaseConfig();
if (databaseConfig != null) {
// Now we do not have concept called EMBEDDED. All the DBs are configured as EXTERNAL.
// This way users can modify the default db config as well. And also support the
// -Dsetup
dsType = DataSourceType.EXTERNAL;
if (databaseConfig.getDataSource().getName() != null && databaseConfig.getDataSource().getName().length() > 0) {
dataSourceName = databaseConfig.getDataSource().getName();
} else {
throw new RuntimeException("Data Source name cannot be null, " + "when data source mode is external.");
}
if (databaseConfig.getDataSource().isSetJNDI()) {
TDataBaseConfig.DataSource.JNDI jndiConfig = databaseConfig.getDataSource().getJNDI();
if (jndiConfig.getContextFactory() != null && jndiConfig.getContextFactory().length() > 0 && jndiConfig.getProviderURL() != null && jndiConfig.getProviderURL().length() > 0) {
dataSourceJNDIRepoInitialContextFactory = jndiConfig.getContextFactory().trim();
dataSourceJNDIRepoProviderURL = jndiConfig.getProviderURL().trim();
// Read Port Offset
int portOffset = readPortOffset();
// applying port offset operation
String urlWithoutPort = dataSourceJNDIRepoProviderURL.substring(0, dataSourceJNDIRepoProviderURL.lastIndexOf(':') + 1);
int dataSourceJNDIRepoProviderPort = Integer.parseInt(dataSourceJNDIRepoProviderURL.substring(urlWithoutPort.length())) + portOffset;
dataSourceJNDIRepoProviderURL = urlWithoutPort + dataSourceJNDIRepoProviderPort;
}
}
}
}
use of org.wso2.carbon.device.mgt.common.operation.mgt.Operation in project carbon-business-process by wso2.
the class HumanTaskStore method createAxisService.
// Creates the AxisService object from the provided ServiceBuilder object.
private AxisService createAxisService(WSDL11ToAxisServiceBuilder serviceBuilder, HumanTaskBaseConfiguration config) throws AxisFault {
AxisService axisService;
axisService = serviceBuilder.populateService();
axisService.setParent(getTenantAxisConfig());
axisService.setWsdlFound(true);
axisService.setCustomWsdl(true);
// axisService.setFileName(new URL(taskConfig.getWsdlDefLocation()));
axisService.setClassLoader(getTenantAxisConfig().getServiceClassLoader());
Utils.setEndpointsToAllUsedBindings(axisService);
axisService.addParameter(new Parameter("modifyUserWSDLPortAddress", "true"));
/* Setting service type to use in service management*/
axisService.addParameter(ServerConstants.SERVICE_TYPE, "humantask");
/* Fix for losing of security configuration when updating human-task package*/
axisService.addParameter(new Parameter(CarbonConstants.PRESERVE_SERVICE_HISTORY_PARAM, "true"));
Iterator operations = axisService.getOperations();
AxisHumanTaskMessageReceiver msgReceiver = new AxisHumanTaskMessageReceiver();
msgReceiver.setHumanTaskEngine(HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine());
// Setting the task configuration to the message receiver. Hence no need to search for task configuration, when
// the actual task invocation happens, we will already have the task configuration attached to the message receiver
// itself
msgReceiver.setTaskBaseConfiguration(config);
while (operations.hasNext()) {
AxisOperation operation = (AxisOperation) operations.next();
// Setting Message Receiver even if operation has a message receiver specified.
// This is to fix the issue when build service configuration using services.xml(Always RPCMessageReceiver
// is set to operations).
operation.setMessageReceiver(msgReceiver);
getTenantAxisConfig().getPhasesInfo().setOperationPhases(operation);
}
Set<String> exposedTransports = getTenantAxisConfig().getTransportsIn().keySet();
// Add the transports to axis2 service by reading from the tenant transport config
for (String transport : exposedTransports) {
axisService.addExposedTransport(transport);
}
if (HumanTaskServiceComponent.getHumanTaskServer().getServerConfig().isHtCoordinationEnabled() && HumanTaskServiceComponent.getHumanTaskServer().getServerConfig().isTaskRegistrationEnabled() && config.getConfigurationType() == HumanTaskBaseConfiguration.ConfigurationType.TASK) {
// Only Engage coordination module in-case of Tasks. Coordination module is not required for notifications
axisService.engageModule(getConfigContext().getAxisConfiguration().getModule("htcoordination"));
}
return axisService;
}
Aggregations