use of org.wso2.carbon.mediation.initializer.persistence.MediationPersistenceManager in project carbon-mediation by wso2.
the class ConfigAdmin method updateConfiguration.
/**
* Update the active configuration with the new configuration
*
* @param configElement a SOAPElement for the configuration
* @return true if the update is successful
* @throws org.apache.axis2.AxisFault if an error occurs
*/
public boolean updateConfiguration(OMElement configElement) throws AxisFault {
Exception error = null;
final Lock lock = getLock();
try {
lock.lock();
ConfigurationUpdater updater = new ConfigurationUpdater(getServerContextInformation(), getConfigContext(), getMediationPersistenceManager(), (UserRegistry) getConfigSystemRegistry());
updater.update(configElement);
if (!Boolean.parseBoolean(System.getProperty("NonRegistryMode"))) {
MediationPersistenceManager pm = getMediationPersistenceManager();
if (pm != null) {
pm.saveItem(null, ServiceBusConstants.ITEM_TYPE_FULL_CONFIG);
}
}
} catch (Exception e) {
handleException("Error while updating the Synapse configuration", e);
} finally {
lock.unlock();
}
return true;
}
use of org.wso2.carbon.mediation.initializer.persistence.MediationPersistenceManager in project carbon-mediation by wso2.
the class TemplateEditorAdmin method deleteTemplate.
/*
*/
/**
* Deletes the sequence with the given name from SynapseConfiguration
*
* @param templateName - Name of the sequence to delete
* @throws AxisFault if the Sequence described by the given name doesnt
* exists in the Synapse Configuration
*/
public void deleteTemplate(String templateName) throws AxisFault {
final Lock lock = getLock();
try {
lock.lock();
SynapseConfiguration synCfg = getSynapseConfiguration();
TemplateMediator sequence = synCfg.getSequenceTemplates().get(templateName);
if (sequence != null) {
synCfg.removeSequenceTemplate(templateName);
if (!Boolean.parseBoolean(System.getProperty("NonRegistryMode"))) {
MediationPersistenceManager pm = getMediationPersistenceManager();
pm.deleteItem(templateName, sequence.getFileName(), ServiceBusConstants.ITEM_TYPE_TEMPLATE);
}
} else {
handleException("No defined sequence with name " + templateName + " found to delete in the Synapse configuration");
}
} catch (Exception fault) {
handleException("Couldn't get the Synapse Configuration to delete the sequence", fault);
} finally {
lock.unlock();
}
}
use of org.wso2.carbon.mediation.initializer.persistence.MediationPersistenceManager in project carbon-mediation by wso2.
the class EndpointTemplateEditorAdmin method persistTemplate.
private void persistTemplate(Template template) throws AxisFault {
if (template instanceof Template) {
if (!Boolean.parseBoolean(System.getProperty("NonRegistryMode"))) {
MediationPersistenceManager pm = getMediationPersistenceManager();
pm.saveItem(((Template) template).getName(), ServiceBusConstants.ITEM_TYPE_TEMPLATE_ENDPOINTS);
}
}
}
use of org.wso2.carbon.mediation.initializer.persistence.MediationPersistenceManager in project carbon-mediation by wso2.
the class ProxyObserver method serviceUpdate.
public void serviceUpdate(AxisEvent event, AxisService axisService) {
Parameter serviceTypeParam = axisService.getParameter(SynapseConstants.SERVICE_TYPE_PARAM_NAME);
if (serviceTypeParam == null || !SynapseConstants.PROXY_SERVICE_TYPE.equals(serviceTypeParam.getValue().toString())) {
// We are only interested about the proxy services
return;
}
if (getSynapseConfiguration() == null) {
// through the OSGi console or the system is shutting down.
if (log.isDebugEnabled()) {
log.debug("SynapseConfiguration in ProxyObserver is null. The service" + " update event will not be processed further.");
}
return;
}
if (CarbonConstants.POLICY_ADDED == event.getEventType()) {
updateProxyServicePolicies(axisService, getSynapseConfiguration());
}
if (CarbonConstants.AxisEvent.TRANSPORT_BINDING_ADDED == event.getEventType()) {
ProxyService proxy = getSynapseConfiguration().getProxyService(axisService.getName());
if (proxy != null && proxy.getTransports() != null) {
List<String> transports = axisService.getExposedTransports();
for (String trp : transports) {
if (!proxy.getTransports().contains(trp)) {
proxy.getTransports().add(trp);
}
}
}
}
ProxyService proxy = getSynapseConfiguration().getProxyService(axisService.getName());
if (proxy != null && proxy.getTransports() != null) {
proxy.setRunning(axisService.isActive());
}
if (AxisEvent.SERVICE_REMOVE == event.getEventType()) {
Parameter keepServiceHistoryParam = axisService.getParameter(CarbonConstants.KEEP_SERVICE_HISTORY_PARAM);
Parameter originator = axisService.getParameter("originator");
boolean keepHistory = keepServiceHistoryParam != null && JavaUtils.isTrue(keepServiceHistoryParam.getValue());
// during hot update
if (originator != null && "ServiceAdmin".equals(originator.getValue().toString())) {
if (!keepHistory) {
ProxyService proxySvc = getSynapseConfiguration().getProxyService(axisService.getName());
if (proxySvc != null) {
getSynapseConfiguration().removeProxyService(axisService.getName());
if (!Boolean.parseBoolean(System.getProperty("NonRegistryMode"))) {
MediationPersistenceManager pm = getMediationPersistenceManager();
pm.deleteItem(proxySvc.getName(), proxySvc.getFileName(), ServiceBusConstants.ITEM_TYPE_PROXY_SERVICE);
}
log.info("Deleted the proxy service : " + proxySvc.getName());
} else if (log.isDebugEnabled()) {
log.debug("Proxy Service representing the service " + axisService.getName() + " of type proxy is not found in the SynapseConfiguration");
}
}
}
}
}
use of org.wso2.carbon.mediation.initializer.persistence.MediationPersistenceManager in project carbon-mediation by wso2.
the class ProxyServiceAdmin method deleteProxyService.
/**
* Deletes a proxy service from the synapse configuration
*
* @param proxyName name of the proxy service which needs to be deleted
* @throws ProxyAdminException if the proxy service name given is not existent in the
* synapse configuration
* @return <code>successful</code> on success or <code>failed</code> otherwise
*/
public String deleteProxyService(String proxyName) throws ProxyAdminException {
final Lock lock = getLock();
try {
lock.lock();
if (log.isDebugEnabled()) {
log.debug("Deleting proxy service : " + proxyName);
}
SynapseConfiguration synapseConfiguration = getSynapseConfiguration();
ProxyService proxy = synapseConfiguration.getProxyService(proxyName);
if (proxy != null) {
synapseConfiguration.removeProxyService(proxyName);
if (!Boolean.parseBoolean(System.getProperty("NonRegistryMode"))) {
MediationPersistenceManager pm = getMediationPersistenceManager();
pm.deleteItem(proxyName, proxy.getFileName(), ServiceBusConstants.ITEM_TYPE_PROXY_SERVICE);
}
if (log.isDebugEnabled()) {
log.debug("Proxy service : " + proxyName + " deleted");
}
return SUCCESSFUL;
} else {
log.warn("No proxy service exists by the name : " + proxyName);
return FAILED;
}
} catch (Exception e) {
handleException(log, "Unable to delete proxy service : " + proxyName, e);
} finally {
lock.unlock();
}
return FAILED;
}
Aggregations