Search in sources :

Example 1 with AnalyticsServerProfile

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);
        }
    }
}
Also used : TAnalyticsServerProfiles(org.apache.ode.bpel.dd.TAnalyticsServerProfiles) AnalyticsServerProfile(org.wso2.carbon.bpel.core.ode.integration.config.analytics.AnalyticsServerProfile) AnalyticsServerProfileBuilder(org.wso2.carbon.bpel.core.ode.integration.config.analytics.AnalyticsServerProfileBuilder)

Example 2 with AnalyticsServerProfile

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);
    }
}
Also used : Resource(org.wso2.carbon.registry.api.Resource) RegistryException(org.wso2.carbon.registry.api.RegistryException)

Example 3 with AnalyticsServerProfile

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;
}
Also used : Registry(org.wso2.carbon.registry.api.Registry) RegistryException(org.wso2.carbon.registry.api.RegistryException)

Example 4 with 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);
}
Also used : AnalyticsServerProfile(org.wso2.carbon.bpel.core.ode.integration.config.analytics.AnalyticsServerProfile)

Example 5 with AnalyticsServerProfile

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));
}
Also used : DataPublisher(org.wso2.carbon.databridge.agent.DataPublisher) AnalyticsStreamConfiguration(org.wso2.carbon.bpel.core.ode.integration.config.analytics.AnalyticsStreamConfiguration)

Aggregations

AnalyticsServerProfile (org.wso2.carbon.bpel.core.ode.integration.config.analytics.AnalyticsServerProfile)3 DataPublisher (org.wso2.carbon.databridge.agent.DataPublisher)2 RegistryException (org.wso2.carbon.registry.api.RegistryException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 OMElement (org.apache.axiom.om.OMElement)1 StAXOMBuilder (org.apache.axiom.om.impl.builder.StAXOMBuilder)1 TAnalyticsServerProfiles (org.apache.ode.bpel.dd.TAnalyticsServerProfiles)1 AnalyticsServerProfileBuilder (org.wso2.carbon.bpel.core.ode.integration.config.analytics.AnalyticsServerProfileBuilder)1 AnalyticsStreamConfiguration (org.wso2.carbon.bpel.core.ode.integration.config.analytics.AnalyticsStreamConfiguration)1 TenantProcessStore (org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStore)1 CryptoException (org.wso2.carbon.core.util.CryptoException)1 DataEndpointAgentConfigurationException (org.wso2.carbon.databridge.agent.exception.DataEndpointAgentConfigurationException)1 DataEndpointAuthenticationException (org.wso2.carbon.databridge.agent.exception.DataEndpointAuthenticationException)1 DataEndpointConfigurationException (org.wso2.carbon.databridge.agent.exception.DataEndpointConfigurationException)1 DataEndpointException (org.wso2.carbon.databridge.agent.exception.DataEndpointException)1 Registry (org.wso2.carbon.registry.api.Registry)1 Resource (org.wso2.carbon.registry.api.Resource)1