use of org.wso2.siddhi.query.api.execution.query.input.store.Store in project carbon-business-process by wso2.
the class HumanTaskPackageManagementSkeleton method getTenantTaskStore.
// Returns the task store for the tenant.
private HumanTaskStore getTenantTaskStore() {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
HumanTaskServer server = HumanTaskServiceComponent.getHumanTaskServer();
return server.getTaskStoreManager().getHumanTaskStore(tenantId);
}
use of org.wso2.siddhi.query.api.execution.query.input.store.Store in project carbon-business-process by wso2.
the class HumanTaskStore method deploy.
/**
* Handles the deployment steps for the master node and salve node in the cluster
* @param humanTaskFile
* @throws Exception
*/
public void deploy(File humanTaskFile) throws Exception {
// Currently using the registry read/write mount property to determine whether this node is a master node
// or a salve node.
// Handle this properly with hazelcast leader for cluster scenario TODO
boolean isMasterServer = !isServerReadOnly();
// Versions of this ht package is already deployed
boolean isExistingPackage = false;
// Exactly matching ht package already exists
boolean isPackageReload = false;
DeploymentUnitDAO currentlyActiveTaskPackage = null;
String md5sum = HumanTaskStoreUtils.getMD5Checksum(humanTaskFile);
String packageName = FilenameUtils.removeExtension(humanTaskFile.getName());
List<DeploymentUnitDAO> existingDeploymentUnitsForPackage = getExistingDeploymentUnitsForPackage(packageName.trim());
if (existingDeploymentUnitsForPackage != null && existingDeploymentUnitsForPackage.size() > 0) {
isExistingPackage = true;
for (DeploymentUnitDAO dao : existingDeploymentUnitsForPackage) {
if ((dao.getStatus() == (TaskPackageStatus.ACTIVE))) {
// extract the currently active task package
currentlyActiveTaskPackage = dao;
if (dao.getChecksum().equals(md5sum)) {
// Check whether the md5sum matches the active task package.
isPackageReload = true;
}
}
}
}
// We will only allow writes to db only for the master node to avoid duplicate version creation
if (isExistingPackage && isPackageReload) {
// Reload the existing versions of the human task package . No need of creating a new version of the package
// This could be due to server restart, deployment of the same package or master node has already deployed the
// new version of the package
// First check if the currently active task package is already loaded
String activePackageName = loadedPackages.get(currentlyActiveTaskPackage.getPackageName());
if (activePackageName != null && activePackageName.equals(currentlyActiveTaskPackage.getName())) {
if (log.isDebugEnabled()) {
log.debug("This task package and its previous versions are already loaded " + activePackageName);
}
// This task package and its previous versions are already loaded , hence return
return;
}
// Load the existing versions of the package
reloadExistingTaskVersions(existingDeploymentUnitsForPackage, humanTaskFile, md5sum, isMasterServer);
return;
}
// New version of the package is being deployed on top of the existing version
if (isExistingPackage && !isPackageReload) {
if (isMasterServer) {
// Retire the existing version of the package and deploy the new version
// This could be two scenarios. Server restart with new version and deploying on existing version.
String activePackageName = loadedPackages.get(currentlyActiveTaskPackage.getPackageName());
if (activePackageName == null) {
// This is a server restart, we need to load existing versions
reloadExistingTaskVersions(existingDeploymentUnitsForPackage, humanTaskFile, md5sum, isMasterServer);
}
long newVersion = getNextVersion();
HumanTaskDeploymentUnit newDeploymentUnit = createNewDeploymentUnit(humanTaskFile, tenantId, newVersion, md5sum);
validateTaskConfig(newDeploymentUnit);
retireTaskPackageConfigurations(currentlyActiveTaskPackage.getName());
currentlyActiveTaskPackage.setStatus(TaskPackageStatus.RETIRED);
updateDeploymentUnitDao(currentlyActiveTaskPackage);
// Retiring of currently active package is complete.
// Create and deploy new version
deployNewTaskVersion(newDeploymentUnit, newVersion);
// Add new version of human task package to registry
// Update the zip and package properties in the registry
repository.handleNewHumanTaskPackageAddition(newDeploymentUnit, humanTaskFile);
// Successfully deployed the packages.
return;
} else {
// Cannot allow creation of a new version from slave nodes, deploy the new version on the master node
// first to avoid duplicate version creation
// Write log, issue warning and return
log.warn("Cannot deploy new version of the task in slave node. Hence deploy the task archive in master" + "node fist");
return;
}
}
if (!isMasterServer) {
// Issue warning, write warn message and return as we cannot allow deployment of new versions on slave nodes
// before deployment of the ht package in the master node
log.warn("Cannot deploy a new version on the package on the salve node first, " + "Deploy the package on the master node first");
return;
}
// Create new version of deployment unit
// Process the human task configurations
// Store deployment unit information to the db
// Deploy axis2 services
// Adding HumanTask package the registry.
long newVersion = getNextVersion();
HumanTaskDeploymentUnit newDeploymentUnit = createNewDeploymentUnit(humanTaskFile, tenantId, newVersion, md5sum);
validateTaskConfig(newDeploymentUnit);
deployNewTaskVersion(newDeploymentUnit, newVersion);
repository.handleNewHumanTaskPackageAddition(newDeploymentUnit, humanTaskFile);
return;
}
use of org.wso2.siddhi.query.api.execution.query.input.store.Store in project carbon-business-process by wso2.
the class OperationAuthorizationUtil method authoriseUser.
/**
* @param task : The task against which the user being validated.
* @param validatee : The OrganizationalEntityDAO being validated.
* @param allowedRoleTypes : The allowed role types for the validatee object.
* @param pqe : PeopleQueryEvaluator for people queries.
* @return : true if the user is in the specified roles for the given task. false otherwise.
*/
public static boolean authoriseUser(TaskDAO task, OrganizationalEntityDAO validatee, List<GenericHumanRoleDAO.GenericHumanRoleType> allowedRoleTypes, PeopleQueryEvaluator pqe) {
List<GenericHumanRoleDAO> humanRolesInTask = task.getHumanRoles();
if (isExcludedEntity(task, validatee, pqe)) {
return false;
}
for (GenericHumanRoleDAO role : humanRolesInTask) {
if (allowedRoleTypes.contains(role.getType())) {
// check for groups
for (OrganizationalEntityDAO entityForRole : getGroupOrganizationalEntities(role)) {
if (OrganizationalEntityDAO.OrganizationalEntityType.GROUP.equals(entityForRole.getOrgEntityType())) {
String roleName = entityForRole.getName();
List<String> userListForRole = pqe.getUserNameListForRole(roleName);
if (userListForRole.contains(validatee.getName())) {
return true;
}
}
}
// check for users
// TODO validate user existance in the user store.
List<OrganizationalEntityDAO> orgEntities = getUserOrganizationalEntities(role);
Collections.sort(orgEntities, PeopleQueryComparators.peopleNameComparator());
if (Collections.binarySearch(orgEntities, validatee, PeopleQueryComparators.peopleNameComparator()) >= 0) {
return true;
}
}
}
return false;
}
use of org.wso2.siddhi.query.api.execution.query.input.store.Store in project carbon-business-process by wso2.
the class BPELPackageRepository method createBPELPackageParentCollectionWithProperties.
/**
* Create parent collection to persisting BPEL package information. For example, if you deploy
* a BPEL archive called 'HelloWorld.zip', we store information of that package in collection
* named 'HelloWorld'. This will be the root for 'HelloWorld' BPEL package information and
* there will several versions of this BPEL package in this registry collection which relates
* to the versions deployed in BPEL engine.
*
* @param deploymentContext containing information on current deployment
* @throws RegistryException when there is a error accessing registry
* @throws IOException if file access error occurred during MD5 checksum generation
* @throws NoSuchAlgorithmException when there is a error during MD5 generation
*/
private void createBPELPackageParentCollectionWithProperties(BPELDeploymentContext deploymentContext) throws RegistryException, IOException, NoSuchAlgorithmException {
Collection bpelPackage = configRegistry.newCollection();
bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_LATEST_CHECKSUM, Utils.getMD5Checksum(deploymentContext.getBpelArchive()));
if (log.isDebugEnabled()) {
log.debug(deploymentContext.getBpelPackageName() + " updating checksum: " + Utils.getMD5Checksum(deploymentContext.getBpelArchive()) + " in registry");
}
if (deploymentContext.isFailed()) {
bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_STATUS, BPELConstants.STATUS_FAILED);
bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_DEPLOYMENT_ERROR_LOG, deploymentContext.getDeploymentFailureCause());
// bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_DEPLOYMENT_STACK_TRACE,
// ExceptionUtils.getStackTrace(deploymentContext.getStackTrace()));
} else {
bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_STATUS, BPELConstants.STATUS_DEPLOYED);
}
bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_LATEST_VERSION, Long.toString(deploymentContext.getVersion()));
configRegistry.put(BPELPackageRepositoryUtils.getResourcePathForBPELPackage(deploymentContext), bpelPackage);
}
use of org.wso2.siddhi.query.api.execution.query.input.store.Store in project carbon-business-process by wso2.
the class BPELServerImpl method init.
/**
* Initialize the ODE BPEL engine.
*
* @throws Exception if failed to start the BPEL engine.
*/
public void init() throws Exception {
bpelServerConfiguration = new BPELServerConfiguration();
odeConfigurationProperties = new ODEConfigurationProperties(bpelServerConfiguration);
if (log.isDebugEnabled()) {
log.debug("Initializing transaction manager");
}
initTransactionManager();
if (log.isDebugEnabled()) {
log.debug("Creating data source");
}
initDataSource();
if (log.isDebugEnabled()) {
log.debug("Starting DAO");
}
initDAO();
BPELEndpointReferenceContextImpl eprContext = new BPELEndpointReferenceContextImpl();
if (log.isDebugEnabled()) {
log.debug("Initializing BPEL process store");
}
initProcessStore(eprContext);
if (log.isDebugEnabled()) {
log.debug("Initializing BPEL server");
}
initBPELServer(eprContext);
if (log.isDebugEnabled()) {
log.debug("Initializing multithreaded connection manager");
}
initHttpConnectionManager();
/* Register event listeners configured in ode-axis2.properties file*/
registerEventListeners();
/* Register message exchange interceptors configured in ode-axis.properties file*/
registerMexInterceptors();
registerExtensionActivityBundles();
registerExtensionCorrelationFilters();
try {
odeBpelServer.start();
} catch (Exception e) {
shutdown();
String errMsg = "BPEL Server failed to start.";
log.error(errMsg, e);
throw new Exception(errMsg, e);
}
if (bpelServerConfiguration.getUseDistributedLock() && isAxis2ClusteringEnabled()) {
BPELServerHolder.getInstance().addObserver(this);
if (log.isDebugEnabled()) {
log.debug("Clustering Enabled, Registering Observer for HazelCast service");
}
}
registerMBeans();
}
Aggregations