Search in sources :

Example 1 with EventProcessorAdminServiceStub

use of org.wso2.carbon.event.processor.stub.EventProcessorAdminServiceStub in project carbon-apimgt by wso2.

the class GlobalThrottleEngineClient method deploy.

/**
 * 1. Check validity of execution plan
 * 2. If execution plan exist with same name edit it
 * 3. Else deploy new execution plan
 *
 * @param executionPlan execution query plan
 * @param sessionCookie session cookie to use established connection
 * @throws RemoteException
 */
private void deploy(String executionPlan, String sessionCookie) throws RemoteException {
    ServiceClient serviceClient;
    Options options;
    EventProcessorAdminServiceStub eventProcessorAdminServiceStub = getEventProcessorAdminServiceStub();
    serviceClient = eventProcessorAdminServiceStub._getServiceClient();
    options = serviceClient.getOptions();
    options.setManageSession(true);
    options.setProperty(HTTPConstants.COOKIE_STRING, sessionCookie);
    eventProcessorAdminServiceStub.deployExecutionPlan(executionPlan);
}
Also used : Options(org.apache.axis2.client.Options) ServiceClient(org.apache.axis2.client.ServiceClient) EventProcessorAdminServiceStub(org.wso2.carbon.event.processor.stub.EventProcessorAdminServiceStub)

Example 2 with EventProcessorAdminServiceStub

use of org.wso2.carbon.event.processor.stub.EventProcessorAdminServiceStub in project carbon-apimgt by wso2.

the class GlobalThrottleEngineClient method validateExecutionPlan.

/**
 * Checks the validity of a execution plan
 *
 * @param executionPlan
 * @return boolean
 */
public boolean validateExecutionPlan(String executionPlan) {
    ServiceClient serviceClient;
    Options options;
    String result = null;
    try {
        String sessionCookie = login();
        EventProcessorAdminServiceStub eventProcessorAdminServiceStub = getEventProcessorAdminServiceStub();
        serviceClient = eventProcessorAdminServiceStub._getServiceClient();
        options = serviceClient.getOptions();
        options.setManageSession(true);
        options.setProperty(HTTPConstants.COOKIE_STRING, sessionCookie);
        result = eventProcessorAdminServiceStub.validateExecutionPlan(executionPlan);
    } catch (RemoteException e) {
        return false;
    } catch (MalformedURLException e) {
        return false;
    } catch (LoginAuthenticationExceptionException e) {
        return false;
    }
    if ("success".equalsIgnoreCase(result)) {
        return true;
    }
    return false;
}
Also used : Options(org.apache.axis2.client.Options) MalformedURLException(java.net.MalformedURLException) ServiceClient(org.apache.axis2.client.ServiceClient) EventProcessorAdminServiceStub(org.wso2.carbon.event.processor.stub.EventProcessorAdminServiceStub) RemoteException(java.rmi.RemoteException) LoginAuthenticationExceptionException(org.wso2.carbon.authenticator.stub.LoginAuthenticationExceptionException)

Example 3 with EventProcessorAdminServiceStub

use of org.wso2.carbon.event.processor.stub.EventProcessorAdminServiceStub in project carbon-apimgt by wso2.

the class GlobalThrottleEngineClient method update.

/**
 *  Updates a deployed execution plan
 *
 * @param name          Name of execution plan
 * @param executionPlan execution query plan
 * @param sessionCookie session cookie to use established connection
 * @throws RemoteException
 */
private void update(String name, String executionPlan, String sessionCookie) throws RemoteException {
    ServiceClient serviceClient;
    Options options;
    EventProcessorAdminServiceStub eventProcessorAdminServiceStub = getEventProcessorAdminServiceStub();
    serviceClient = eventProcessorAdminServiceStub._getServiceClient();
    options = serviceClient.getOptions();
    options.setManageSession(true);
    options.setProperty(HTTPConstants.COOKIE_STRING, sessionCookie);
    eventProcessorAdminServiceStub.validateExecutionPlan(executionPlan);
    eventProcessorAdminServiceStub.editActiveExecutionPlan(executionPlan, name);
}
Also used : Options(org.apache.axis2.client.Options) ServiceClient(org.apache.axis2.client.ServiceClient) EventProcessorAdminServiceStub(org.wso2.carbon.event.processor.stub.EventProcessorAdminServiceStub)

Example 4 with EventProcessorAdminServiceStub

use of org.wso2.carbon.event.processor.stub.EventProcessorAdminServiceStub in project carbon-apimgt by wso2.

the class GlobalThrottleEngineClient method deleteExecutionPlan.

/**
 * This method will be used to delete single execution plan.
 * @param name execution plan name to be deleted.
 */
public void deleteExecutionPlan(String name) {
    ServiceClient serviceClient;
    Options options;
    String sessionID = null;
    try {
        sessionID = login();
    } catch (RemoteException e) {
        log.error("Error while connecting to login central policy management server" + e.getMessage());
    } catch (LoginAuthenticationExceptionException e) {
        log.error("Error while connecting to login central policy management server, " + "Check user name and password" + e.getMessage());
    } catch (MalformedURLException e) {
        log.error("Error while connecting to login central policy management server, check URL" + e.getMessage());
    }
    EventProcessorAdminServiceStub eventProcessorAdminServiceStub = null;
    try {
        eventProcessorAdminServiceStub = getEventProcessorAdminServiceStub();
        serviceClient = eventProcessorAdminServiceStub._getServiceClient();
        options = serviceClient.getOptions();
        options.setManageSession(true);
        options.setProperty(HTTPConstants.COOKIE_STRING, sessionID);
        eventProcessorAdminServiceStub.undeployActiveExecutionPlan(name);
    } catch (AxisFault axisFault) {
        log.error("Error while connecting to login central policy management server to delete " + "execution plan." + axisFault);
    } catch (RemoteException e) {
        log.error("Error while connecting to login central policy management server to delete " + "execution plan." + e.getMessage());
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) Options(org.apache.axis2.client.Options) MalformedURLException(java.net.MalformedURLException) ServiceClient(org.apache.axis2.client.ServiceClient) EventProcessorAdminServiceStub(org.wso2.carbon.event.processor.stub.EventProcessorAdminServiceStub) RemoteException(java.rmi.RemoteException) LoginAuthenticationExceptionException(org.wso2.carbon.authenticator.stub.LoginAuthenticationExceptionException)

Aggregations

Options (org.apache.axis2.client.Options)4 ServiceClient (org.apache.axis2.client.ServiceClient)4 EventProcessorAdminServiceStub (org.wso2.carbon.event.processor.stub.EventProcessorAdminServiceStub)4 MalformedURLException (java.net.MalformedURLException)2 RemoteException (java.rmi.RemoteException)2 LoginAuthenticationExceptionException (org.wso2.carbon.authenticator.stub.LoginAuthenticationExceptionException)2 AxisFault (org.apache.axis2.AxisFault)1