use of org.wso2.carbon.governance.custom.lifecycles.checklist.util.Property in project carbon-business-process by wso2.
the class TenantProcessStoreImpl method handleUndeployOnSlaveNode.
/**
* Undeployment scenario in a worker node( Slave ) in the clustered setup
* When the BPELDeployer get called for undeploying the bpel package, following has already taken place.
* The package information stored in the registry as well as the zip archive is deleted
* Process, Instance information have been removed from the ODE database
* However, on the slave node, the bpel process and the web services associated with the bpel process
* is still in memory. We need to unload the bpel process and the associated web services
*
* @param bpelPackageName bpel package name
* @return
*/
private int handleUndeployOnSlaveNode(String bpelPackageName) {
List<String> packageList = findMatchingProcessByPackageName(bpelPackageName);
if (packageList.size() < 1) {
log.debug("Handling un-deploy operation on salve (worker) node : package list is empty");
return -1;
}
for (String packageName : packageList) {
// location for extracted BPEL package
String bpelPackageLocation = parentProcessStore.getLocalDeploymentUnitRepo().getAbsolutePath() + File.separator + tenantId + File.separator + packageName;
File bpelPackage = new File(bpelPackageLocation);
// removing extracted bpel package at repository/bpel/tenantID/
deleteBpelPackageFromRepo(bpelPackage);
for (QName pid : getProcessesInPackage(packageName)) {
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);
}
}
Collection<QName> undeployedProcesses = new ArrayList<QName>();
for (String nameWithVersion : packageList) {
undeploySpecificVersionOfBPELPackage(nameWithVersion, undeployedProcesses);
}
BPELServerImpl instance = BPELServerImpl.getInstance();
BpelServerImpl odeBpelServer = instance.getODEBPELServer();
for (QName pid : undeployedProcesses) {
odeBpelServer.unregister(pid);
ProcessConf pConf = parentProcessStore.getProcessConfiguration(pid);
if (pConf != null) {
if (log.isDebugEnabled()) {
log.debug("Cancelling all cron scheduled jobs for process " + pid);
}
odeBpelServer.getContexts().cronScheduler.cancelProcessCronJobs(pid, true);
}
log.info("Process " + pid + " un-deployed.");
}
parentProcessStore.updateProcessAndDUMapsForSalve(tenantId, bpelPackageName, undeployedProcesses);
return 0;
}
use of org.wso2.carbon.governance.custom.lifecycles.checklist.util.Property in project carbon-business-process by wso2.
the class AbstractPaginateList method paginateList.
public DataResponse paginateList(Map<String, String> requestParams, PaginateRequest paginateRequest, Query query, String defaultSort, Map<String, QueryProperty> properties) {
if (paginateRequest == null) {
paginateRequest = new PaginateRequest();
}
// In case pagination request is incomplete, fill with values found in URL if possible
if (paginateRequest.getStart() == null) {
paginateRequest.setStart(RequestUtil.getInteger(requestParams, "start", 0));
}
if (paginateRequest.getSize() == null) {
paginateRequest.setSize(RequestUtil.getInteger(requestParams, "size", 10));
}
if (paginateRequest.getOrder() == null) {
paginateRequest.setOrder(requestParams.get("order"));
}
if (paginateRequest.getSort() == null) {
paginateRequest.setSort(requestParams.get("sort"));
}
// Use defaults for paging, if not set in the PaginationRequest, nor in the URL
Integer start = paginateRequest.getStart();
if (start == null || start < 0) {
start = 0;
}
Integer size = paginateRequest.getSize();
if (size == null || size < 0) {
size = 10;
}
String sort = paginateRequest.getSort();
if (sort == null) {
// id
sort = defaultSort;
}
String order = paginateRequest.getOrder();
if (order == null) {
order = "asc";
}
// Sort order
if (sort != null && !properties.isEmpty()) {
QueryProperty qp = properties.get(sort);
if (qp == null) {
throw new ActivitiIllegalArgumentException("Value for param 'sort' is not valid, '" + sort + "' is not a valid property");
}
((AbstractQuery) query).orderBy(qp);
if (order.equals("asc")) {
query.asc();
} else if (order.equals("desc")) {
query.desc();
} else {
throw new ActivitiIllegalArgumentException("Value for param 'order' is not valid : '" + order + "', must be 'asc' or 'desc'");
}
}
// Get result and set pagination parameters
List list = processList(query.listPage(start, size));
DataResponse response = new DataResponse();
response.setStart(start);
response.setSize(list.size());
response.setSort(sort);
response.setOrder(order);
response.setTotal(query.count());
response.setData(list);
return response;
}
use of org.wso2.carbon.governance.custom.lifecycles.checklist.util.Property in project carbon-business-process by wso2.
the class SubstitutionDataHolder method isTransitivityEnabled.
/**
* Get the transitivity enabled value for substitution from configuration.
* @return true if transitivity enabled
*/
public boolean isTransitivityEnabled() {
if (transitivityEnabled != null) {
return transitivityEnabled;
} else {
transitivityEnabled = BPMNConstants.SUBSTITUTION_TRANSITIVITY_DEFAULT;
BPMNActivitiConfiguration bpmnActivitiConfiguration = BPMNActivitiConfiguration.getInstance();
if (bpmnActivitiConfiguration != null) {
String transitivityEnabledProperty = bpmnActivitiConfiguration.getBPMNPropertyValue(BPMNConstants.SUBSTITUTION_CONFIG, BPMNConstants.SUBSTITUTION_TRANSITIVITY_PROPERTY);
if (transitivityEnabledProperty != null) {
if (transitivityEnabledProperty.trim().equalsIgnoreCase("true") || transitivityEnabledProperty.trim().equalsIgnoreCase("false")) {
transitivityEnabled = Boolean.parseBoolean(transitivityEnabledProperty);
if (log.isDebugEnabled()) {
log.debug("User substitution transitivity enabled : " + transitivityEnabled);
}
} else {
log.warn("Invalid value for the property: " + BPMNConstants.SUBSTITUTION_TRANSITIVITY_PROPERTY + ". Transitivity is being disabled by default.");
}
}
}
return transitivityEnabled;
}
}
use of org.wso2.carbon.governance.custom.lifecycles.checklist.util.Property in project product-iots by wso2.
the class ZipUtil method getSketchArchive.
/**
* Get agent sketch.
*
* @param archivesPath Path of the zip file to create.
* @param templateSketchPath Path of the sketch.
* @param contextParams Map of parameters to be included in the zip file.
* @param zipFileName Name of the zip file.
* @return Created zip archive.
* @throws DeviceManagementException
* @throws IOException
*/
public static ZipArchive getSketchArchive(String archivesPath, String templateSketchPath, Map contextParams, String zipFileName) throws DeviceManagementException, IOException {
String sketchPath = CarbonUtils.getCarbonHome() + File.separator + templateSketchPath;
// clear directory
FileUtils.deleteDirectory(new File(archivesPath));
// clear zip
FileUtils.deleteDirectory(new File(archivesPath + ".zip"));
if (!new File(archivesPath).mkdirs()) {
// new dir
String message = "Could not create directory at path: " + archivesPath;
throw new DeviceManagementException(message);
}
zipFileName = zipFileName + ".zip";
try {
Map<String, List<String>> properties = getProperties(sketchPath + File.separator + "sketch" + ".properties");
List<String> templateFiles = properties.get("templates");
for (String templateFile : templateFiles) {
parseTemplate(templateSketchPath + File.separator + templateFile, archivesPath + File.separator + templateFile, contextParams);
}
// ommit copying the props file
templateFiles.add("sketch.properties");
copyFolder(new File(sketchPath), new File(archivesPath), templateFiles);
createZipArchive(archivesPath);
FileUtils.deleteDirectory(new File(archivesPath));
File zip = new File(archivesPath + ".zip");
return new ZipArchive(zipFileName, zip);
} catch (IOException ex) {
throw new DeviceManagementException("Error occurred when trying to read property " + "file sketch.properties", ex);
}
}
use of org.wso2.carbon.governance.custom.lifecycles.checklist.util.Property in project carbon-apimgt by wso2.
the class SubscriberInfoLoader method handleThrottle.
private boolean handleThrottle(WebhooksDTO subscriber, MessageContext messageContext) {
AuthenticationContext authContext = new AuthenticationContext();
populateAuthContext(subscriber.getTenantDomain(), Integer.parseInt(subscriber.getAppID()), authContext);
messageContext.setProperty(APISecurityUtils.API_AUTH_CONTEXT, authContext);
if (subscriber.isThrottled()) {
if (APIUtil.isAnalyticsEnabled()) {
String errorMessage = "Message throttled out";
String errorDescription = "You have exceeded your quota";
int errorCode = APIThrottleConstants.EVENTS_COUNT_THROTTLE_OUT_ERROR_CODE;
messageContext.setProperty(SynapseConstants.ERROR_CODE, errorCode);
messageContext.setProperty(SynapseConstants.ERROR_MESSAGE, errorMessage);
messageContext.setProperty(SynapseConstants.ERROR_DETAIL, errorDescription);
messageContext.setProperty(Constants.BACKEND_RESPONSE_CODE, APIThrottleConstants.SC_TOO_MANY_REQUESTS);
((Axis2MessageContext) messageContext).getAxis2MessageContext().setProperty(SynapseConstants.HTTP_SC, APIThrottleConstants.SC_TOO_MANY_REQUESTS);
WebhooksUtils.publishAnalyticsData(messageContext);
}
return false;
}
if (doThrottle(subscriber, messageContext, authContext)) {
messageContext.setProperty(APIConstants.Webhooks.SUBSCRIBER_CALLBACK_PROPERTY, subscriber.getCallbackURL());
String errorMessage = "Message throttled out";
String errorDescription = "You have exceeded your quota";
int errorCode = APIThrottleConstants.EVENTS_COUNT_THROTTLE_OUT_ERROR_CODE;
int httpErrorCode = APIThrottleConstants.SC_TOO_MANY_REQUESTS;
messageContext.setProperty(SynapseConstants.ERROR_CODE, errorCode);
messageContext.setProperty(SynapseConstants.ERROR_MESSAGE, errorMessage);
messageContext.setProperty(SynapseConstants.ERROR_DETAIL, errorDescription);
messageContext.setProperty(APIMgtGatewayConstants.HTTP_RESPONSE_STATUS_CODE, httpErrorCode);
org.apache.axis2.context.MessageContext axis2MC = ((Axis2MessageContext) messageContext).getAxis2MessageContext();
// This property need to be set to avoid sending the content in pass-through pipe (request message)
// as the response.
axis2MC.setProperty(PassThroughConstants.MESSAGE_BUILDER_INVOKED, Boolean.TRUE);
try {
RelayUtils.consumeAndDiscardMessage(axis2MC);
} catch (AxisFault axisFault) {
// In case of an error it is logged and the process is continued because we're setting a fault message
// in the payload.
log.error("Error occurred while consuming and discarding the message", axisFault);
}
if (APIUtil.isAnalyticsEnabled()) {
messageContext.setProperty(Constants.BACKEND_RESPONSE_CODE, httpErrorCode);
((Axis2MessageContext) messageContext).getAxis2MessageContext().setProperty(SynapseConstants.HTTP_SC, APIThrottleConstants.SC_TOO_MANY_REQUESTS);
WebhooksUtils.publishAnalyticsData(messageContext);
}
Mediator sequence = messageContext.getSequence(APIThrottleConstants.API_THROTTLE_OUT_HANDLER);
// Invoke the custom error handler specified by the user
if (sequence != null && !sequence.mediate(messageContext)) {
// logic from getting executed
return true;
}
Utils.sendFault(messageContext, httpErrorCode);
}
return true;
}
Aggregations