use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.PACKAGE in project ballerina by ballerina-lang.
the class HtmlDocTest method testStructs.
@Test(description = "Structs in a package should be shown in the constructs")
public void testStructs() throws Exception {
BLangPackage bLangPackage = createPackage("package x.y; public struct Message {}");
Page page = generatePage(bLangPackage);
Assert.assertEquals(page.constructs.size(), 1);
Assert.assertEquals(page.constructs.get(0).name, "Message");
}
use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.PACKAGE in project ballerina by ballerina-lang.
the class HtmlDocTest method testEnums.
@Test(description = "Enums in a package should be shown in the constructs")
public void testEnums() throws Exception {
BLangPackage bLangPackage = createPackage("package x.y; " + "public enum Direction {IN,OUT}" + "public enum Money {USD,LKR}");
Page page = generatePage(bLangPackage);
Assert.assertEquals(page.constructs.size(), 2);
Assert.assertEquals(page.constructs.get(0).name, "Direction");
Assert.assertTrue(page.constructs.get(0) instanceof EnumDoc, "Invalid documentable type.");
Assert.assertEquals(((EnumDoc) page.constructs.get(0)).enumerators.get(0).toString(), "IN", "Invalid enum val");
Assert.assertEquals(((EnumDoc) page.constructs.get(0)).enumerators.get(1).toString(), "OUT", "Invalid enum val");
Assert.assertEquals(page.constructs.get(1).name, "Money");
}
use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.PACKAGE in project carbon-business-process by wso2.
the class BPELPackageRepository method createPropertiesForUpdatedDeploymentInfo.
/**
* Creates new properties for the details of updated deployment descriptor information
* for a process in the package location of the registry
*
* @param processConfiguration - Process's configuration details after updated
* @throws RegistryException on registry rollback error case, we'll init the cause to the
* original exception we got when accessing registry
* @throws IOException if file access error occurred during MD5 checksum generation
* @throws NoSuchAlgorithmException when there is a error during MD5 generation
* @throws ProcessManagementException
*/
public void createPropertiesForUpdatedDeploymentInfo(ProcessConfigurationImpl processConfiguration) throws RegistryException, IOException, NoSuchAlgorithmException, ProcessManagementException {
String versionlessPackageName = BPELPackageRepositoryUtils.getVersionlessPackageName(processConfiguration.getPackage());
String packageLocation = BPELPackageRepositoryUtils.getResourcePathForDeployInfoUpdatedBPELPackage(processConfiguration.getPackage(), versionlessPackageName);
Resource bpelPackage = configRegistry.get(packageLocation);
bpelPackage.setProperty(BPELConstants.BPEL_INSTANCE_CLEANUP_FAILURE + processConfiguration.getProcessId(), BPELPackageRepositoryUtils.getBPELPackageFailureCleanUpsAsString(processConfiguration.getCleanupCategories(false)));
bpelPackage.setProperty(BPELConstants.BPEL_INSTANCE_CLEANUP_SUCCESS + processConfiguration.getProcessId(), BPELPackageRepositoryUtils.getBPELPackageSuccessCleanUpsInList(processConfiguration.getCleanupCategories(true)));
bpelPackage.setProperty(BPELConstants.BPEL_PROCESS_EVENT_GENERATE + processConfiguration.getProcessId(), BPELPackageRepositoryUtils.getBPELPackageProcessGenerateType(processConfiguration.getGenerateType()));
bpelPackage.setProperty(BPELConstants.BPEL_PROCESS_EVENTS + processConfiguration.getProcessId(), BPELPackageRepositoryUtils.getBPELPackageProcessEventsInList(processConfiguration.getEvents()));
bpelPackage.setProperty(BPELConstants.BPEL_PROCESS_INMEMORY + processConfiguration.getProcessId(), String.valueOf(processConfiguration.isTransient()));
bpelPackage.setProperty(BPELConstants.BPEL_PROCESS_STATE + processConfiguration.getProcessId(), processConfiguration.getState().name());
// ScopeLevelEnabledEvents list of a process in a bpel package
List<String> scopeEvents;
scopeEvents = BPELPackageRepositoryUtils.getBPELPackageScopeEventsInList(processConfiguration.getEvents());
if (!scopeEvents.isEmpty()) {
for (int k = 0; k < scopeEvents.size(); k++) {
bpelPackage.setProperty(BPELConstants.BPEL_PROCESS_SCOPE_EVENT + (k + 1) + processConfiguration.getProcessId(), scopeEvents.get(k));
}
}
configRegistry.put(packageLocation, bpelPackage);
}
use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.PACKAGE in project carbon-business-process by wso2.
the class TenantProcessStoreImpl method undeploy.
/**
* Undeploying BPEL package.
*
* @param bpelPackageName Name of the BPEL package which going to be undeployed
*/
public void undeploy(String bpelPackageName) throws RegistryException, BPELUIException {
if (log.isDebugEnabled()) {
log.debug("Un-deploying BPEL package " + bpelPackageName + " ....");
}
if (!repository.isExistingBPELPackage(bpelPackageName)) {
// This can be a situation where we un-deploy the archive through management console,
// so that, the archive is deleted from the repo. As a result this method get invoked.
// to handle this case we just log the message but does not throw an exception.
final String warningMsg = "Cannot find BPEL package with name " + bpelPackageName + " in the repository. If the bpel package is un-deployed through the management" + " console or if this node is a member of a cluster, please ignore this warning.";
if (isConfigRegistryReadOnly()) {
// This is for the deployment synchronizer scenarios where package un-deployment on a worker node
// has to remove the deployed bpel package from the memory and remove associated services
handleUndeployOnSlaveNode(bpelPackageName);
} else {
log.warn(warningMsg);
}
return;
}
if (repository.isExistingBPELPackage(bpelPackageName) && isConfigRegistryReadOnly()) {
log.warn("This node seems to be a slave, since the configuration registry is in read-only mode, hence " + "processes cannot be directly undeployed from this node. Please undeploy the process in Master " + "node first.");
return;
}
List<String> versionsOfThePackage;
try {
versionsOfThePackage = repository.getAllVersionsForPackage(bpelPackageName);
} catch (RegistryException re) {
String errMessage = "Cannot get all versions of the package " + bpelPackageName + " from registry.";
log.error(errMessage);
throw re;
}
// check the instance count to be deleted
long instanceCount = getInstanceCountForPackage(versionsOfThePackage);
if (instanceCount > BPELServerImpl.getInstance().getBpelServerConfiguration().getBpelInstanceDeletionLimit()) {
throw new BPELUIException("Instance deletion limit reached.");
}
for (String nameWithVersion : versionsOfThePackage) {
parentProcessStore.deleteDeploymentUnitDataFromDB(nameWithVersion);
Utils.deleteInstances(getProcessesInPackage(nameWithVersion));
// location for extracted BPEL package
String bpelPackageLocation = parentProcessStore.getLocalDeploymentUnitRepo().getAbsolutePath() + File.separator + tenantId + File.separator + nameWithVersion;
File bpelPackage = new File(bpelPackageLocation);
// removing extracted bpel package at repository/bpel/0/
deleteBpelPackageFromRepo(bpelPackage);
for (QName pid : getProcessesInPackage(nameWithVersion)) {
ProcessConfigurationImpl processConf = (ProcessConfigurationImpl) getProcessConfiguration(pid);
// This property is read when we removing the axis service for this process.
// So that we can decide whether we should persist service QOS configs
processConf.setUndeploying(true);
}
}
try {
repository.handleBPELPackageUndeploy(bpelPackageName);
} catch (RegistryException re) {
String errMessage = "Cannot update the BPEL package repository for undeployment of" + "package " + bpelPackageName + ".";
log.error(errMessage);
throw re;
}
updateLocalInstanceWithUndeployment(bpelPackageName, versionsOfThePackage);
// We should use the deployment synchronizer, instead of the code below.
// parentProcessStore.sendProcessDeploymentNotificationsToCluster(
// new BPELPackageUndeployedCommand(versionsOfThePackage, bpelPackageName, tenantId),
// configurationContext);
}
use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.PACKAGE in project carbon-business-process by wso2.
the class TenantProcessStoreImpl method findBPELPackageInFileSystem.
private File findBPELPackageInFileSystem(DeploymentUnitDAO dudao) {
String duName = dudao.getName();
// Done: Fix the logic to handle registry
log.info("Looking for BPEL package in file system for deployment unit " + duName);
File bpelDUDirectory = new File(bpelDURepo, duName);
if (bpelDUDirectory.exists()) {
return bpelDUDirectory;
} else {
String registryCollectionPath = dudao.getDeploymentUnitDir();
try {
if (tenantConfigRegistry.resourceExists(registryCollectionPath)) {
if (!bpelDUDirectory.exists() && !bpelDUDirectory.mkdirs()) {
String errMsg = "Error creating BPEL deployment unit repository for " + "tenant " + tenantId;
log.error(errMsg);
log.error("Failed to load BPEL deployment unit " + duName + " due to above error.");
throw new BPELDeploymentException(errMsg);
}
boolean deployedOnCarbon310 = false;
// Check whether the registry repo is of type carbon 3.1.0
if (tenantConfigRegistry.resourceExists(registryCollectionPath + RegistryConstants.PATH_SEPARATOR + duName)) {
registryCollectionPath += RegistryConstants.PATH_SEPARATOR + duName;
deployedOnCarbon310 = true;
if (log.isDebugEnabled()) {
log.debug("Found a carbon 3.1.0 compatible deployment unit at " + registryCollectionPath);
}
}
RegistryClientUtils.exportFromRegistry(bpelDUDirectory, registryCollectionPath, tenantConfigRegistry);
if (deployedOnCarbon310) {
if (log.isDebugEnabled()) {
log.debug("Recompiling the carbon 3.1.0 compatible deployment unit at " + bpelDUDirectory);
}
// Re-compiling to get rid of binary compatibility issues.
DeploymentUnitDir du = new DeploymentUnitDir(bpelDUDirectory);
for (File file : du.allFiles()) {
if (file.getAbsolutePath().endsWith(".cbp") && !file.delete()) {
log.warn("Unable to delete " + file);
}
}
du.compile();
}
return bpelDUDirectory;
} else {
String errMsg = "Expected resource: " + registryCollectionPath + " not found in the registry";
log.error(errMsg);
throw new BPELDeploymentException(errMsg);
}
} catch (RegistryException re) {
String errMsg = "Error while exporting deployment unit: " + duName + " to file system from the registry.";
log.error(errMsg, re);
throw new BPELDeploymentException(errMsg, re);
}
}
}
Aggregations