use of org.wso2.carbon.bpel.core.ode.integration.config.analytics.AnalyticsServerProfile in project carbon-business-process by wso2.
the class TenantProcessStoreImpl method readAnalyticsServerProfiles.
private void readAnalyticsServerProfiles(TDeployment.Process processDD, DeploymentUnitDir du) {
TAnalyticsServerProfiles analyticsServerProfiles = processDD.getAnalyticsServerProfiles();
if (analyticsServerProfiles != null) {
for (TAnalyticsServerProfiles.Profile analyticsServerProfile : analyticsServerProfiles.getProfileList()) {
String location = analyticsServerProfile.getLocation();
if (location.startsWith(UnifiedEndpointConstants.VIRTUAL_FILE)) {
if (!EndpointConfiguration.isAbsolutePath(location.substring(UnifiedEndpointConstants.VIRTUAL_FILE.length()))) {
location = EndpointConfiguration.getAbsolutePath(du.getDeployDir().getAbsolutePath(), location.substring(UnifiedEndpointConstants.VIRTUAL_FILE.length()));
}
} else if ((!location.startsWith(UnifiedEndpointConstants.VIRTUAL_CONF_REG) && !location.startsWith(UnifiedEndpointConstants.VIRTUAL_GOV_REG) && !location.startsWith(UnifiedEndpointConstants.VIRTUAL_REG))) {
if (EndpointConfiguration.isAbsolutePath(location)) {
location = UnifiedEndpointConstants.VIRTUAL_FILE + location;
} else {
location = EndpointConfiguration.getAbsolutePath(du.getDeployDir().getAbsolutePath(), location);
location = UnifiedEndpointConstants.VIRTUAL_FILE + location;
}
}
AnalyticsServerProfileBuilder builder = new AnalyticsServerProfileBuilder(location, tenantId);
AnalyticsServerProfile profile = builder.build();
addAnalyticsServerProfile(profile.getName(), profile);
}
}
}
use of org.wso2.carbon.bpel.core.ode.integration.config.analytics.AnalyticsServerProfile in project carbon-business-process by wso2.
the class AnalyticsServerProfileBuilder method loadAnalyticsProfileFromRegistry.
/**
* Load Analytics profile from given registry and registry path.
*
* @param analyticsServerProfile AnalyticsServerProfile instance
* @param registry Registry space where file is located
* @param location Registry path of the profile file
*/
private void loadAnalyticsProfileFromRegistry(AnalyticsServerProfile analyticsServerProfile, Registry registry, String location) {
try {
if (registry.resourceExists(location)) {
Resource resource = registry.get(location);
String resourceContent = new String((byte[]) resource.getContent());
parseAnalyticsProfile(resourceContent, analyticsServerProfile);
} else {
String errMsg = "The resource: " + location + " does not exist.";
handleError(errMsg);
}
} catch (RegistryException e) {
String errMsg = "Error occurred while reading the resource from registry: " + location + " to build the Analytics server profile: " + profileLocation;
handleError(errMsg, e);
}
}
use of org.wso2.carbon.bpel.core.ode.integration.config.analytics.AnalyticsServerProfile in project carbon-business-process by wso2.
the class AnalyticsServerProfileBuilder method build.
/**
* Creates AnalyticsServerProfile for given tenant and Analytic profile.
*
* @return AnalyticsServerProfile instance
*/
public AnalyticsServerProfile build() {
AnalyticsServerProfile analyticsServerProfile = new AnalyticsServerProfile();
Registry registry;
String location;
if (profileLocation.startsWith(UnifiedEndpointConstants.VIRTUAL_CONF_REG)) {
try {
registry = BPELServiceComponent.getRegistryService().getConfigSystemRegistry(tenantId);
location = profileLocation.substring(profileLocation.indexOf(UnifiedEndpointConstants.VIRTUAL_CONF_REG) + UnifiedEndpointConstants.VIRTUAL_CONF_REG.length());
loadAnalyticsProfileFromRegistry(analyticsServerProfile, registry, location);
} catch (RegistryException re) {
String errMsg = "Error while loading Analytic profile from config registry.";
handleError(errMsg, re);
}
} else if (profileLocation.startsWith(UnifiedEndpointConstants.VIRTUAL_GOV_REG)) {
try {
registry = BPELServiceComponent.getRegistryService().getGovernanceSystemRegistry(tenantId);
location = profileLocation.substring(profileLocation.indexOf(UnifiedEndpointConstants.VIRTUAL_GOV_REG) + UnifiedEndpointConstants.VIRTUAL_GOV_REG.length());
loadAnalyticsProfileFromRegistry(analyticsServerProfile, registry, location);
} catch (RegistryException re) {
String errMsg = "Error while loading Analytic profile from governance registry.";
handleError(errMsg, re);
}
} else if (profileLocation.startsWith(UnifiedEndpointConstants.VIRTUAL_REG)) {
try {
registry = BPELServiceComponent.getRegistryService().getLocalRepository(tenantId);
location = profileLocation.substring(profileLocation.indexOf(UnifiedEndpointConstants.VIRTUAL_REG) + UnifiedEndpointConstants.VIRTUAL_REG.length());
loadAnalyticsProfileFromRegistry(analyticsServerProfile, registry, location);
} catch (RegistryException re) {
String errMsg = "Error while loading Analytic profile from local registry";
handleError(errMsg, re);
}
} else if (profileLocation.startsWith(UnifiedEndpointConstants.VIRTUAL_FILE)) {
location = profileLocation.substring(profileLocation.indexOf(UnifiedEndpointConstants.VIRTUAL_FILE) + UnifiedEndpointConstants.VIRTUAL_FILE.length());
loadAnalyticsProfileFromFileSystem(analyticsServerProfile, location);
} else {
String errMsg = "Invalid analytics profile location: " + profileLocation;
handleError(errMsg);
}
return analyticsServerProfile;
}
use of org.wso2.carbon.bpel.core.ode.integration.config.analytics.AnalyticsServerProfile in project carbon-business-process by wso2.
the class AnalyticsPublisherExtensionOperation method getEventStream.
private AnalyticsStreamConfiguration getEventStream(int tenantId, String analyticsServerProfileName, String streamName, String streamVersion) {
AnalyticsServerProfile analyticsServerProfile = getAnalyticsServerProfile(tenantId, analyticsServerProfileName);
if (null == analyticsServerProfile) {
String errMsg = "AnalyticsServerProfile not found for stream name and version " + streamName + " " + streamVersion;
log.error(errMsg);
return null;
}
return analyticsServerProfile.getAnalyticsStreamConfiguration(streamName, streamVersion);
}
use of org.wso2.carbon.bpel.core.ode.integration.config.analytics.AnalyticsServerProfile in project carbon-business-process by wso2.
the class AnalyticsPublisherExtensionOperation method runSync.
@Override
protected void runSync(ExtensionContext extensionContext, Element element) throws FaultException {
String analyticsServerProfileName = element.getAttribute("analyticsServerProfile");
String streamName = element.getAttribute(AnalyticsPublisherConstants.STREAM_NAME_ATTR);
String streamVersion = element.getAttribute(AnalyticsPublisherConstants.STREAM_VERSION);
Integer tenantId = getTenantId(extensionContext);
AnalyticsStreamConfiguration stream = getEventStream(tenantId, analyticsServerProfileName, streamName, streamVersion);
if (stream == null) {
log.debug("Stream configuration is invalid");
return;
}
DataPublisher dataPublisher = getDataPublisher(extensionContext, tenantId, analyticsServerProfileName);
if (dataPublisher == null) {
String msg = "Error while creating data publisher";
handleException(msg);
}
String streamId = DataBridgeCommonsUtils.generateStreamId(stream.getName(), stream.getVersion());
dataPublisher.tryPublish(streamId, createMetadata(stream, extensionContext, element), createCorrelationData(stream, extensionContext, element), createPayloadData(stream, extensionContext, element));
}
Aggregations