use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.LOCAL in project carbon-apimgt by wso2.
the class InMemoryAPIDeployer method cleanDeployment.
public void cleanDeployment(String artifactRepositoryPath) {
File artifactRepoPath = Paths.get(artifactRepositoryPath, SynapseConstants.SYNAPSE_CONFIGS, SynapseConstants.DEFAULT_DIR).toFile();
if (artifactRepoPath.exists() && artifactRepoPath.isDirectory()) {
GatewayCleanupSkipList gatewayCleanupSkipList = ServiceReferenceHolder.getInstance().getAPIManagerConfiguration().getGatewayCleanupSkipList();
File apiPath = Paths.get(artifactRepoPath.getAbsolutePath(), "api").toFile();
if (apiPath.exists() && apiPath.isDirectory()) {
clean(apiPath, gatewayCleanupSkipList.getApis());
}
File localEntryPath = Paths.get(artifactRepoPath.getAbsolutePath(), "local-entries").toFile();
if (localEntryPath.exists() && localEntryPath.isDirectory()) {
clean(localEntryPath, gatewayCleanupSkipList.getLocalEntries());
}
File endpointPath = Paths.get(artifactRepoPath.getAbsolutePath(), "endpoints").toFile();
if (endpointPath.exists() && endpointPath.isDirectory()) {
clean(endpointPath, gatewayCleanupSkipList.getEndpoints());
}
File sequencesPath = Paths.get(artifactRepoPath.getAbsolutePath(), "sequences").toFile();
if (sequencesPath.exists() && sequencesPath.isDirectory()) {
clean(sequencesPath, gatewayCleanupSkipList.getSequences());
}
}
}
use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.LOCAL in project carbon-apimgt by wso2.
the class APIProviderImpl method updateAPIResources.
/**
* Update resources of the API including local scopes and resource to scope attachments.
*
* @param api API
* @param tenantId Tenant Id
* @throws APIManagementException If fails to update local scopes of the API.
*/
private void updateAPIResources(API api, int tenantId) throws APIManagementException {
String tenantDomain = APIUtil.getTenantDomainFromTenantId(tenantId);
APIIdentifier apiIdentifier = api.getId();
// Get the new URI templates for the API
Set<URITemplate> uriTemplates = api.getUriTemplates();
// Get the existing local scope keys attached for the API
Set<String> oldLocalScopeKeys = apiMgtDAO.getAllLocalScopeKeysForAPI(api.getUuid(), tenantId);
// Get the existing URI templates for the API
Set<URITemplate> oldURITemplates = apiMgtDAO.getURITemplatesOfAPI(api.getUuid());
// Get the new local scope keys from URI templates
Set<Scope> newLocalScopes = getScopesToRegisterFromURITemplates(api.getId().getApiName(), api.getOrganization(), uriTemplates);
Set<String> newLocalScopeKeys = newLocalScopes.stream().map(Scope::getKey).collect(Collectors.toSet());
// Get the existing versioned local scope keys attached for the API
Set<String> oldVersionedLocalScopeKeys = apiMgtDAO.getVersionedLocalScopeKeysForAPI(api.getUuid(), tenantId);
// Get the existing versioned local scope keys which needs to be removed (not updated) from the current updating
// API and remove them from the oldLocalScopeKeys set before sending to KM, so that they will not be removed
// from KM and can be still used by other versioned APIs.
Iterator oldLocalScopesItr = oldLocalScopeKeys.iterator();
while (oldLocalScopesItr.hasNext()) {
String oldLocalScopeKey = (String) oldLocalScopesItr.next();
// if the scope is used in versioned APIs and it is not in new local scope key set
if (oldVersionedLocalScopeKeys.contains(oldLocalScopeKey) && !newLocalScopeKeys.contains(oldLocalScopeKey)) {
// remove from old local scope key set which will be send to KM
oldLocalScopesItr.remove();
}
}
apiMgtDAO.updateURITemplates(api, tenantId);
if (log.isDebugEnabled()) {
log.debug("Successfully updated the URI templates of API: " + apiIdentifier + " in the database");
}
// Update the resource scopes of the API in KM.
// Need to remove the old local scopes and register new local scopes and, update the resource scope mappings
// using the updated URI templates of the API.
deleteScopes(oldLocalScopeKeys, tenantId);
addScopes(newLocalScopes, tenantId);
Map<String, KeyManagerDto> tenantKeyManagers = KeyManagerHolder.getTenantKeyManagers(tenantDomain);
for (Map.Entry<String, KeyManagerDto> keyManagerDtoEntry : tenantKeyManagers.entrySet()) {
KeyManager keyManager = keyManagerDtoEntry.getValue().getKeyManager();
if (keyManager != null) {
try {
keyManager.updateResourceScopes(api, oldLocalScopeKeys, newLocalScopes, oldURITemplates, uriTemplates);
if (log.isDebugEnabled()) {
log.debug("Successfully updated the resource scopes of API: " + apiIdentifier + " in Key Manager " + keyManagerDtoEntry.getKey() + " .");
}
} catch (APIManagementException e) {
log.error("Error while updating resource to scope attachment in Key Manager " + keyManagerDtoEntry.getKey(), e);
}
}
}
}
use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.LOCAL in project siddhi by wso2.
the class PartitionStreamReceiver method addStreamJunction.
/**
* create local streamJunctions through which events received by partitionStreamReceiver, are sent to
* queryStreamReceivers
*
* @param key partitioning key
* @param queryRuntimeList queryRuntime list of the partition
*/
public void addStreamJunction(String key, List<QueryRuntime> queryRuntimeList) {
StreamJunction streamJunction = cachedStreamJunctionMap.get(streamId + key);
if (streamJunction == null) {
streamJunction = partitionRuntime.getLocalStreamJunctionMap().get(streamId + key);
if (streamJunction == null) {
streamJunction = createStreamJunction();
partitionRuntime.addStreamJunction(streamId + key, streamJunction);
}
cachedStreamJunctionMap.put(streamId + key, streamJunction);
}
for (QueryRuntime queryRuntime : queryRuntimeList) {
StreamRuntime streamRuntime = queryRuntime.getStreamRuntime();
for (int i = 0; i < queryRuntime.getInputStreamId().size(); i++) {
if ((streamRuntime.getSingleStreamRuntimes().get(i)).getProcessStreamReceiver().getStreamId().equals(streamId + key)) {
streamJunction.subscribe((streamRuntime.getSingleStreamRuntimes().get(i)).getProcessStreamReceiver());
}
}
}
}
use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.LOCAL in project carbon-business-process by wso2.
the class AttachmentMgtDAOConnectionFactoryImpl method init.
@Override
public void init() {
if (transactionManager == null) {
log.debug("Transaction-Manager is not initialized before initializing entityManager. So internal " + "transaction-manager in entity manager will be used.");
}
JPAVendorAdapter vendorAdapter = getJPAVendorAdapter();
// Here we pass a "null" valued transaction manager,
// as we enforce the entity-manager-factory to use its local transactions. In future,
// if required to use external JTA transactions, a transaction reference should be passed
// as the input parameter.
this.entityManagerFactory = Persistence.createEntityManagerFactory("Attachment-Mgt-PU", vendorAdapter.getJpaPropertyMap(null));
}
use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.LOCAL in project carbon-business-process by wso2.
the class HistoricTaskInstanceService method getVariableFromRequest.
protected RestVariable getVariableFromRequest(boolean includeBinary, String taskId, String variableName, String scope) {
HistoryService historyService = BPMNOSGIService.getHistoryService();
RestVariable.RestVariableScope variableScope = RestVariable.getScopeFromString(scope);
HistoricTaskInstanceQuery taskQuery = historyService.createHistoricTaskInstanceQuery().taskId(taskId);
if (variableScope != null) {
if (variableScope == RestVariable.RestVariableScope.GLOBAL) {
taskQuery.includeProcessVariables();
} else {
taskQuery.includeTaskLocalVariables();
}
} else {
taskQuery.includeTaskLocalVariables().includeProcessVariables();
}
HistoricTaskInstance taskObject = taskQuery.singleResult();
if (taskObject == null) {
throw new ActivitiObjectNotFoundException("Historic task instance '" + taskId + "' couldn't be found.", HistoricTaskInstanceEntity.class);
}
Object value = null;
if (variableScope != null) {
if (variableScope == RestVariable.RestVariableScope.GLOBAL) {
value = taskObject.getProcessVariables().get(variableName);
} else {
value = taskObject.getTaskLocalVariables().get(variableName);
}
} else {
// look for local task restVariables first
if (taskObject.getTaskLocalVariables().containsKey(variableName)) {
value = taskObject.getTaskLocalVariables().get(variableName);
} else {
value = taskObject.getProcessVariables().get(variableName);
}
}
if (value == null) {
throw new ActivitiObjectNotFoundException("Historic task instance '" + taskId + "' variable value for " + variableName + " couldn't be found.", VariableInstanceEntity.class);
} else {
return new RestResponseFactory().createRestVariable(variableName, value, null, taskId, RestResponseFactory.VARIABLE_HISTORY_TASK, includeBinary, uriInfo.getBaseUri().toString());
}
}
Aggregations